Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/npm_and_yarn/decode-uri-compone…
Browse files Browse the repository at this point in the history
…nt-0.2.2
  • Loading branch information
mtrezza authored Oct 21, 2023
2 parents 92c3d5b + ba48dd6 commit 0e98ccd
Show file tree
Hide file tree
Showing 9 changed files with 136 additions and 96 deletions.
36 changes: 25 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,41 @@
name: ci
on:
push:
branches: [ master, release, alpha, beta ]
branches:
- master
pull_request:
branches: [ '**' ]
branches:
- '**'
jobs:
test:
runs-on: ubuntu-18.04
timeout-minutes: 30
strategy:
matrix:
include:
- name: Node.js 14
NODE_VERSION: 14
- name: Node.js 16
NODE_VERSION: 16
- name: Node.js 18
NODE_VERSION: 18
- name: Node.js 20
NODE_VERSION: 20
fail-fast: false
name: ${{ matrix.name }}
timeout-minutes: 15
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v2
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.NODE_VERSION }}
uses: actions/setup-node@v1
with:
node-version: 14
node-version: ${{ matrix.NODE_VERSION }}
- name: Cache Node.js modules
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
key: ${{ runner.os }}-node-${{ matrix.NODE_VERSION }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
${{ runner.os }}-node-${{ matrix.NODE_VERSION }}-
- name: Install dependencies
run: npm ci
- name: Build package
Expand Down
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
## [4.2.1](https://github.com/parse-community/parse-server-push-adapter/compare/4.2.0...4.2.1) (2023-10-02)


### Bug Fixes

* Upgrade @parse/node-apn from 5.2.1 to 5.2.3 ([#221](https://github.com/parse-community/parse-server-push-adapter/issues/221)) ([7aaab38](https://github.com/parse-community/parse-server-push-adapter/commit/7aaab38b8c97215ea9e63f87fc627450646c714e))

# [4.2.0](https://github.com/parse-community/parse-server-push-adapter/compare/4.1.3...4.2.0) (2023-08-06)


### Features

* Upgrade @parse/node-apn from 5.1.3 to 5.2.1 ([#220](https://github.com/parse-community/parse-server-push-adapter/issues/220)) ([3b932d1](https://github.com/parse-community/parse-server-push-adapter/commit/3b932d1e40ddf81d38fcd7f3bbb71bbdcf848978))

## [4.1.3](https://github.com/parse-community/parse-server-push-adapter/compare/4.1.2...4.1.3) (2023-05-20)


### Bug Fixes

* Validate push notification payload; fixes a security vulnerability in which the adapter can crash Parse Server due to an invalid push notification payload ([#217](https://github.com/parse-community/parse-server-push-adapter/issues/217)) ([598cb84](https://github.com/parse-community/parse-server-push-adapter/commit/598cb84d0866b7c5850ca96af920e8cb5ba243ec))

## [4.1.2](https://github.com/parse-community/parse-server-push-adapter/compare/4.1.1...4.1.2) (2022-03-27)


Expand Down
30 changes: 12 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ The official Push Notification adapter for Parse Server. See [Parse Server Push
- [Install Push Adapter](#install-push-adapter)
- [Configure Parse Server](#configure-parse-server)



# Silent Notifications

If you have migrated from parse.com and you are seeing situations where silent (newsstand-like presentless) notifications are failing to deliver please ensure that your payload is setting the content-available attribute to Int(1) and not "1" This value will be explicitly checked.
Expand All @@ -44,30 +42,26 @@ This will produce a more verbose output for all the push sending attempts
## Install Push Adapter

```
npm install --save @parse/push-adapter@VERSION
npm install --save @parse/push-adapter@<VERSION>
```

Replace VERSION with the version you want to install.
Replace `<VERSION>` with the version you want to install.

## Configure Parse Server

```js
const PushAdapter = require('@parse/push-adapter').default;
const pushOptions = {
ios: { /* iOS push options */ } ,
android: { /* android push options */ }
}
// starting 3.0.0
const options = {
appId: "****",
masterKey: "****",
const parseServerOptions = {
push: {
adapter: new PushAdapter(pushOptions),
adapter: new PushAdapter({
ios: {
/* Apple push notification options */
},
android: {
/* Android push options */
}
})
},
/* ... */
/* Other Parse Server options */
}

const server = new ParseServer(options);

/* continue with the initialization of parse-server */
```
95 changes: 38 additions & 57 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@parse/push-adapter",
"version": "4.1.2",
"version": "4.2.1",
"description": "Base parse-server-push-adapter",
"main": "lib/index.js",
"files": [
Expand Down Expand Up @@ -40,7 +40,7 @@
"semantic-release": "17.4.6"
},
"dependencies": {
"@parse/node-apn": "5.1.3",
"@parse/node-apn": "5.2.3",
"@parse/node-gcm": "1.0.2",
"npmlog": "4.1.2",
"parse": "3.4.0"
Expand Down
26 changes: 20 additions & 6 deletions spec/APNS.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ describe('APNS', () => {

var prodApnsConnection = apns.providers[0];
expect(prodApnsConnection.index).toBe(0);

// TODO: Remove this checking onec we inject APNS
var prodApnsOptions = prodApnsConnection.client.config;
expect(prodApnsOptions.cert).toBe(args[1].cert);
Expand Down Expand Up @@ -239,7 +239,7 @@ describe('APNS', () => {
expect(notification.pushType).toEqual('alert');
done();
});

it('can generate APNS notification from raw data', (done) => {
//Mock request data
let data = {
Expand All @@ -259,17 +259,17 @@ describe('APNS', () => {
let collapseId = "collapseIdentifier";
let pushType = "background";
let priority = 5;

let notification = APNS._generateNotification(data, { expirationTime: expirationTime, collapseId: collapseId, pushType: pushType, priority: priority });

expect(notification.expiry).toEqual(Math.round(expirationTime / 1000));
expect(notification.collapseId).toEqual(collapseId);
expect(notification.pushType).toEqual(pushType);
expect(notification.priority).toEqual(priority);

let stringifiedJSON = notification.compile();
let jsonObject = JSON.parse(stringifiedJSON);

expect(jsonObject.aps.alert).toEqual({ "loc-key" : "GAME_PLAY_REQUEST_FORMAT", "loc-args" : [ "Jenna", "Frank"] });
expect(jsonObject.aps.badge).toEqual(100);
expect(jsonObject.aps.sound).toEqual('test');
Expand Down Expand Up @@ -315,6 +315,20 @@ describe('APNS', () => {
done();
});

it('does log on invalid APNS notification', async () => {
const args = {
cert: new Buffer('testCert'),
key: new Buffer('testKey'),
production: true,
topic: 'topic'
};
const log = require('npmlog');
const spy = spyOn(log, 'warn');
const apns = new APNS(args);
apns.send();
expect(spy).toHaveBeenCalled();
});

it('can send APNS notification', (done) => {
let args = {
cert: new Buffer('testCert'),
Expand Down
Loading

0 comments on commit 0e98ccd

Please sign in to comment.