New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@pusher/push-notifications-server

Package Overview
Dependencies
Maintainers
0
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pusher/push-notifications-server - npm Package Compare versions

Comparing version 1.2.6 to 1.2.7

eslint.config.mjs

11

__tests__/publishToInterests.test.js

@@ -24,2 +24,3 @@ require('jest');

let uri, headers, body;
nock(new RegExp('/.*/'))

@@ -61,3 +62,3 @@ .post(new RegExp('/.*/'))

accept: 'application/json',
'x-pusher-library': 'pusher-push-notifications-node 1.2.6',
'x-pusher-library': 'pusher-push-notifications-node 1.2.7',
host: 'instance_id.pushnotifications.pusher.com',

@@ -98,3 +99,3 @@ 'content-type': 'application/json',

});
const response = pn.publish(['donuts'], {
const response = pn.publishToInterests(['donuts'], {
apns: {

@@ -119,3 +120,3 @@ aps: {

authorization: 'Bearer SECRET_KEY',
'x-pusher-library': 'pusher-push-notifications-node 1.2.6',
'x-pusher-library': 'pusher-push-notifications-node 1.2.7',
host: 'instance_id.pushnotifications.pusher.com'

@@ -208,3 +209,3 @@ });

authorization: 'Bearer 1234',
'x-pusher-library': 'pusher-push-notifications-node 1.2.6',
'x-pusher-library': 'pusher-push-notifications-node 1.2.7',
host: '1234.pushnotifications.pusher.com'

@@ -241,3 +242,3 @@ });

expect(error.message).toMatch(/contains a forbidden character/);
return pn.publish(['good-interest', 'bad:interest'], {});
return pn.publishToInterests(['good-interest', 'bad:interest'], {});
})

@@ -244,0 +245,0 @@ .catch(error => {

@@ -60,3 +60,3 @@ require('jest');

authorization: 'Bearer SECRET_KEY',
'x-pusher-library': 'pusher-push-notifications-node 1.2.6',
'x-pusher-library': 'pusher-push-notifications-node 1.2.7',
host: 'instance_id.pushnotifications.pusher.com'

@@ -63,0 +63,0 @@ });

# Changelog
## 1.2.7
* [CHANGED] jsonwebtoken package version from v8 to v9
## 1.2.6

@@ -4,0 +8,0 @@

@@ -5,3 +5,3 @@ const PushNotifications = require('./push-notifications.js');

instanceId: '8f9a6e22-2483-49aa-8552-125f1a4c5781',
secretKey: 'C54D42FB7CD2D408DDB22D7A0166F1D'
secretKey: 'C54D42FB7CD2D408DDB22D7A0166F1D',
});

@@ -13,10 +13,10 @@

aps: {
alert: 'Hi!'
}
}
alert: 'Hi!',
},
},
})
.then(response => {
.then((response) => {
console.log('Response:', response);
})
.catch(error => {
.catch((error) => {
console.error('Error:', error);

@@ -30,11 +30,11 @@ });

title: 'Hello, world!',
notification: 'What a time to be alive'
}
}
notification: 'What a time to be alive',
},
},
})
.then(response => {
.then((response) => {
console.log('Response:', response);
})
.catch(error => {
.catch((error) => {
console.error('Error:', error);
});

@@ -309,3 +309,3 @@ declare namespace PushNotifications {

interests: string[],
publishRequest: PushNotifications.PublishRequest
publishRequest: PushNotifications.PublishRequest,
): Promise<PushNotifications.PublishResponse>;

@@ -320,3 +320,3 @@

users: string[],
publishRequest: PushNotifications.PublishRequest
publishRequest: PushNotifications.PublishRequest,
): Promise<PushNotifications.PublishResponse>;

@@ -338,3 +338,3 @@

interests: string[],
publishRequest: T
publishRequest: T,
): Promise<PushNotifications.PublishResponse>;

@@ -341,0 +341,0 @@ }

import { expectType } from 'tsd';
import { createSecretKey, randomFillSync} from 'crypto';
import PushNotifications = require('.');
const secretKey = createSecretKey(randomFillSync(Buffer.alloc(32))).export().toString('hex');
// Create a client
const client = new PushNotifications({
instanceId: 'some-instance-id',
secretKey: 'some-secret-key'
secretKey: secretKey
});

@@ -64,5 +67,5 @@

// Generate Beams token
expectType<PushNotifications.Token>(client.generateToken('user-alice'));
expectType<{token: PushNotifications.Token}>(client.generateToken('user-alice'));
// Delete User
expectType<Promise<void>>(client.deleteUser('user-alice'));
{
"name": "@pusher/push-notifications-server",
"version": "1.2.6",
"version": "1.2.7",
"description": "NodeJS Server SDK for Pusher Push Notifications",

@@ -10,8 +10,8 @@ "main": "push-notifications.js",

"devDependencies": {
"eslint": "^4.14.0",
"eslint-config-prettier": "^4.0.0",
"jest": "^23.6.0",
"nock": "^9.1.5",
"prettier": "1.14.3",
"tsd": "^0.13.1"
"eslint": "^9.17.0",
"eslint-config-prettier": "^9.1.0",
"jest": "^29.7.0",
"nock": "^13.5.6",
"prettier": "3.4.2",
"tsd": "^0.31.2"
},

@@ -34,4 +34,4 @@ "scripts": {

"dependencies": {
"jsonwebtoken": "^8.4.0"
"jsonwebtoken": "^9.0.2"
}
}

@@ -5,3 +5,3 @@ const jwt = require('jsonwebtoken');

const SDK_VERSION = '1.2.6';
const SDK_VERSION = '1.2.7';
const INTERESTS_REGEX = new RegExp('^(_|\\-|=|@|,|\\.|;|[A-Z]|[a-z]|[0-9])*$');

@@ -12,3 +12,3 @@ const {

USERS_ARRAY_MAX_LENGTH,
USERS_STRING_MAX_LENGTH
USERS_STRING_MAX_LENGTH,
} = require('./utils');

@@ -22,3 +22,3 @@

throw new Error(
'"instanceId" is required in PushNotifications options'
'"instanceId" is required in PushNotifications options',
);

@@ -56,3 +56,3 @@ }

PushNotifications.prototype.publish = function(interests, publishRequest) {
PushNotifications.prototype.publish = function (interests, publishRequest) {
console.warn('`publish` is deprecated. Use `publishToInterests` instead.');

@@ -62,3 +62,3 @@ return this.publishToInterests(interests, publishRequest);

PushNotifications.prototype.generateToken = function(userId) {
PushNotifications.prototype.generateToken = function (userId) {
if (userId === undefined || userId === null) {

@@ -75,3 +75,3 @@ throw new Error('userId argument is required');

throw new Error(
`userId is longer than the maximum length of ${USERS_STRING_MAX_LENGTH}`
`userId is longer than the maximum length of ${USERS_STRING_MAX_LENGTH}`,
);

@@ -82,3 +82,4 @@ }

issuer: `https://${this.instanceId}.pushnotifications.pusher.com`,
subject: userId
subject: userId,
allowInsecureKeySizes: true,
};

@@ -88,9 +89,9 @@ const token = jwt.sign({}, this.secretKey, options);

return {
token: token
token: token,
};
};
PushNotifications.prototype.publishToInterests = function(
PushNotifications.prototype.publishToInterests = function (
interests,
publishRequest
publishRequest,
) {

@@ -102,3 +103,3 @@ if (interests === undefined || interests === null) {

return Promise.reject(
new Error('interests argument is must be an array')
new Error('interests argument is must be an array'),
);

@@ -109,4 +110,4 @@ }

new Error(
'Publish requests must target at least one interest to be delivered'
)
'Publish requests must target at least one interest to be delivered',
),
);

@@ -119,4 +120,4 @@ }

interests.length
}) exceeds maximum of ${INTEREST_ARRAY_MAX_LENGTH}.`
)
}) exceeds maximum of ${INTEREST_ARRAY_MAX_LENGTH}.`,
),
);

@@ -130,3 +131,3 @@ }

return Promise.reject(
new Error(`interest ${interest} is not a string`)
new Error(`interest ${interest} is not a string`),
);

@@ -138,4 +139,4 @@ }

`interest ${interest} is longer than the maximum of ` +
`${INTEREST_STRING_MAX_LENGTH} characters`
)
`${INTEREST_STRING_MAX_LENGTH} characters`,
),
);

@@ -148,4 +149,4 @@ }

'Allowed characters are: ASCII upper/lower-case letters, ' +
'numbers or one of _-=@,.;'
)
'numbers or one of _-=@,.;',
),
);

@@ -162,3 +163,3 @@ }

method: 'POST',
body
body,
};

@@ -169,3 +170,3 @@

PushNotifications.prototype.publishToUsers = function(users, publishRequest) {
PushNotifications.prototype.publishToUsers = function (users, publishRequest) {
if (users === undefined || users === null) {

@@ -180,4 +181,4 @@ return Promise.reject(new Error('users argument is required'));

new Error(
'Publish requests must target at least one interest to be delivered'
)
'Publish requests must target at least one interest to be delivered',
),
);

@@ -190,4 +191,4 @@ }

users.length
}) exceeds maximum of ${USERS_ARRAY_MAX_LENGTH}.`
)
}) exceeds maximum of ${USERS_ARRAY_MAX_LENGTH}.`,
),
);

@@ -206,4 +207,4 @@ }

`user ${user} is longer than the maximum of ` +
`${INTEREST_STRING_MAX_LENGTH} characters`
)
`${INTEREST_STRING_MAX_LENGTH} characters`,
),
);

@@ -217,3 +218,3 @@ }

method: 'POST',
body
body,
};

@@ -224,3 +225,3 @@

PushNotifications.prototype.deleteUser = function(userId) {
PushNotifications.prototype.deleteUser = function (userId) {
if (userId === undefined || userId === null) {

@@ -240,3 +241,3 @@ return Promise.reject(new Error('User ID argument is required'));

}/users/${encodeURIComponent(userId)}`,
method: 'DELETE'
method: 'DELETE',
};

@@ -246,3 +247,3 @@ return this._doRequest(options);

PushNotifications.prototype._doRequest = function(options) {
PushNotifications.prototype._doRequest = function (options) {
const httpLib = this.protocol === 'http' ? http : https;

@@ -256,4 +257,4 @@ const reqOptions = {

Authorization: `Bearer ${this.secretKey}`,
'X-Pusher-Library': `pusher-push-notifications-node ${SDK_VERSION}`
}
'X-Pusher-Library': `pusher-push-notifications-node ${SDK_VERSION}`,
},
};

@@ -272,11 +273,11 @@

return new Promise(function(resolve, reject) {
return new Promise(function (resolve, reject) {
try {
const req = httpLib.request(reqOptions, function(response) {
const req = httpLib.request(reqOptions, function (response) {
let resBodyStr = '';
response.on('data', function(chunk) {
response.on('data', function (chunk) {
resBodyStr += chunk;
});
response.on('end', function() {
response.on('end', function () {
let resBody;

@@ -306,4 +307,4 @@

resBody.error
} - ${resBody.description}`
)
} - ${resBody.description}`,
),
);

@@ -315,3 +316,3 @@ }

req.on('error', function(error) {
req.on('error', function (error) {
reject(error);

@@ -318,0 +319,0 @@ });

[![Build](https://github.com/pusher/push-notifications-node/actions/workflows/build.yml/badge.svg)](https://github.com/pusher/push-notifications-node/actions/workflows/build.yml) [![npm](https://img.shields.io/npm/v/@pusher/push-notifications-server)](https://www.npmjs.com/package/@pusher/push-notifications-server) [![npm](https://img.shields.io/npm/dm/@pusher/push-notifications-server)](https://www.npmjs.com/package/@pusher/push-notifications-server)
# Pusher Beams Node.js Server SDK
Full documentation for this SDK can be found [here](https://docs.pusher.com/beams/reference/server-sdk-node)
Full documentation for this SDK can be found [here](https://pusher.com/docs/beams/reference/server-sdk-node/)

@@ -31,3 +31,3 @@ ## Installation

### Publishing a Notification
Once you have created your Beams PushNotifications instance, you can immediately publish a push notification to your devices, using [Device Interests](https://docs.pusher.com/beams/concepts/device-interests):
Once you have created your Beams PushNotifications instance, you can immediately publish a push notification to your devices, using [Device Interests](https://pusher.com/docs/beams/concepts/device-interests/):
```javascript

@@ -34,0 +34,0 @@ pushNotifications.publishToInterests(['hello'], {

@@ -22,3 +22,3 @@ const crypto = require('crypto');

USERS_ARRAY_MAX_LENGTH,
INTEREST_ARRAY_MAX_LENGTH
INTEREST_ARRAY_MAX_LENGTH,
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc