Skip to content

Commit 2ade4f8

Browse files
authored
Merge branch 'master' into dependabot/npm_and_yarn/http-cache-semantics-4.1.1
2 parents dde2444 + 01efbe2 commit 2ade4f8

File tree

9 files changed

+106
-81
lines changed

9 files changed

+106
-81
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
branches: [ '**' ]
77
jobs:
88
test:
9-
runs-on: ubuntu-18.04
9+
runs-on: ubuntu-latest
1010
timeout-minutes: 30
1111
steps:
1212
- name: Checkout repository

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
## [4.2.1](https://github.com/parse-community/parse-server-push-adapter/compare/4.2.0...4.2.1) (2023-10-02)
2+
3+
4+
### Bug Fixes
5+
6+
* 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))
7+
8+
# [4.2.0](https://github.com/parse-community/parse-server-push-adapter/compare/4.1.3...4.2.0) (2023-08-06)
9+
10+
11+
### Features
12+
13+
* 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))
14+
15+
## [4.1.3](https://github.com/parse-community/parse-server-push-adapter/compare/4.1.2...4.1.3) (2023-05-20)
16+
17+
18+
### Bug Fixes
19+
20+
* 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))
21+
122
## [4.1.2](https://github.com/parse-community/parse-server-push-adapter/compare/4.1.1...4.1.2) (2022-03-27)
223

324

README.md

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ The official Push Notification adapter for Parse Server. See [Parse Server Push
1919
- [Install Push Adapter](#install-push-adapter)
2020
- [Configure Parse Server](#configure-parse-server)
2121

22-
23-
2422
# Silent Notifications
2523

2624
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.
@@ -44,30 +42,26 @@ This will produce a more verbose output for all the push sending attempts
4442
## Install Push Adapter
4543

4644
```
47-
npm install --save @parse/push-adapter@VERSION
45+
npm install --save @parse/push-adapter@<VERSION>
4846
```
4947

50-
Replace VERSION with the version you want to install.
48+
Replace `<VERSION>` with the version you want to install.
5149

5250
## Configure Parse Server
5351

5452
```js
5553
const PushAdapter = require('@parse/push-adapter').default;
56-
const pushOptions = {
57-
ios: { /* iOS push options */ } ,
58-
android: { /* android push options */ }
59-
}
60-
// starting 3.0.0
61-
const options = {
62-
appId: "****",
63-
masterKey: "****",
54+
const parseServerOptions = {
6455
push: {
65-
adapter: new PushAdapter(pushOptions),
56+
adapter: new PushAdapter({
57+
ios: {
58+
/* Apple push notification options */
59+
},
60+
android: {
61+
/* Android push options */
62+
}
63+
})
6664
},
67-
/* ... */
65+
/* Other Parse Server options */
6866
}
69-
70-
const server = new ParseServer(options);
71-
72-
/* continue with the initialization of parse-server */
7367
```

package-lock.json

Lines changed: 32 additions & 52 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@parse/push-adapter",
3-
"version": "4.1.2",
3+
"version": "4.2.1",
44
"description": "Base parse-server-push-adapter",
55
"main": "lib/index.js",
66
"files": [
@@ -40,7 +40,7 @@
4040
"semantic-release": "17.4.6"
4141
},
4242
"dependencies": {
43-
"@parse/node-apn": "5.1.3",
43+
"@parse/node-apn": "5.2.3",
4444
"@parse/node-gcm": "1.0.2",
4545
"npmlog": "4.1.2",
4646
"parse": "3.4.0"

spec/APNS.spec.js

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ describe('APNS', () => {
104104

105105
var prodApnsConnection = apns.providers[0];
106106
expect(prodApnsConnection.index).toBe(0);
107-
107+
108108
// TODO: Remove this checking onec we inject APNS
109109
var prodApnsOptions = prodApnsConnection.client.config;
110110
expect(prodApnsOptions.cert).toBe(args[1].cert);
@@ -239,7 +239,7 @@ describe('APNS', () => {
239239
expect(notification.pushType).toEqual('alert');
240240
done();
241241
});
242-
242+
243243
it('can generate APNS notification from raw data', (done) => {
244244
//Mock request data
245245
let data = {
@@ -259,17 +259,17 @@ describe('APNS', () => {
259259
let collapseId = "collapseIdentifier";
260260
let pushType = "background";
261261
let priority = 5;
262-
262+
263263
let notification = APNS._generateNotification(data, { expirationTime: expirationTime, collapseId: collapseId, pushType: pushType, priority: priority });
264-
264+
265265
expect(notification.expiry).toEqual(Math.round(expirationTime / 1000));
266266
expect(notification.collapseId).toEqual(collapseId);
267267
expect(notification.pushType).toEqual(pushType);
268268
expect(notification.priority).toEqual(priority);
269-
269+
270270
let stringifiedJSON = notification.compile();
271271
let jsonObject = JSON.parse(stringifiedJSON);
272-
272+
273273
expect(jsonObject.aps.alert).toEqual({ "loc-key" : "GAME_PLAY_REQUEST_FORMAT", "loc-args" : [ "Jenna", "Frank"] });
274274
expect(jsonObject.aps.badge).toEqual(100);
275275
expect(jsonObject.aps.sound).toEqual('test');
@@ -315,6 +315,20 @@ describe('APNS', () => {
315315
done();
316316
});
317317

318+
it('does log on invalid APNS notification', async () => {
319+
const args = {
320+
cert: new Buffer('testCert'),
321+
key: new Buffer('testKey'),
322+
production: true,
323+
topic: 'topic'
324+
};
325+
const log = require('npmlog');
326+
const spy = spyOn(log, 'warn');
327+
const apns = new APNS(args);
328+
apns.send();
329+
expect(spy).toHaveBeenCalled();
330+
});
331+
318332
it('can send APNS notification', (done) => {
319333
let args = {
320334
cert: new Buffer('testCert'),

spec/GCM.spec.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function mockSender(gcm) {
1010
{"error":"InvalidRegistration"},
1111
{"error":"InvalidRegistration"},
1212
{"error":"InvalidRegistration"}] }*/
13-
13+
1414
let tokens = options.registrationTokens;
1515
const response = {
1616
multicast_id: 7680139367771848000,
@@ -58,6 +58,14 @@ describe('GCM', () => {
5858
done();
5959
});
6060

61+
it('does log on invalid APNS notification', async () => {
62+
const log = require('npmlog');
63+
const spy = spyOn(log, 'warn');
64+
const gcm = new GCM({apiKey: 'apiKey'});
65+
gcm.send();
66+
expect(spy).toHaveBeenCalled();
67+
});
68+
6169
it('can generate GCM Payload without expiration time', (done) => {
6270
//Mock request data
6371
var requestData = {

src/APNS.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,11 @@ export class APNS {
7070
* @returns {Object} A promise which is resolved immediately
7171
*/
7272
send(data, allDevices) {
73-
let coreData = data.data;
73+
let coreData = data && data.data;
74+
if (!coreData || !allDevices || !Array.isArray(allDevices)) {
75+
log.warn(LOG_PREFIX, 'invalid push payload');
76+
return;
77+
}
7478
let expirationTime = data['expiration_time'] || coreData['expiration_time'];
7579
let collapseId = data['collapse_id'] || coreData['collapse_id'];
7680
let pushType = data['push_type'] || coreData['push_type'];

src/GCM.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ GCM.GCMRegistrationTokensMax = GCMRegistrationTokensMax;
2626
* @returns {Object} A promise which is resolved after we get results from gcm
2727
*/
2828
GCM.prototype.send = function(data, devices) {
29+
if (!data || !devices || !Array.isArray(devices)) {
30+
log.warn(LOG_PREFIX, 'invalid push payload');
31+
return;
32+
}
2933
let pushId = randomString(10);
3034
// Make a new array
3135
devices=devices.slice(0);

0 commit comments

Comments
 (0)