Comparing version 11.4.0 to 11.5.0
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import { EventEmitter } from 'events'; | ||
import { Secret } from 'jsonwebtoken'; | ||
import { PrivateKey } from 'fast-jwt'; | ||
import { Notification } from './notifications/notification'; | ||
@@ -15,3 +16,3 @@ export declare enum Host { | ||
team: string; | ||
signingKey: Secret; | ||
signingKey: string | Buffer | PrivateKey; | ||
keyId: string; | ||
@@ -21,2 +22,3 @@ defaultTopic?: string; | ||
requestTimeout?: number; | ||
keepAlive?: boolean | number; | ||
pingInterval?: number; | ||
@@ -28,5 +30,6 @@ } | ||
readonly host: Host | string; | ||
readonly signingKey: Secret; | ||
readonly signingKey: string | Buffer | PrivateKey; | ||
readonly defaultTopic?: string; | ||
readonly requestTimeout?: number; | ||
readonly keepAlive?: boolean | number; | ||
readonly pingInterval?: number; | ||
@@ -33,0 +36,0 @@ private _token; |
@@ -5,4 +5,4 @@ "use strict"; | ||
const events_1 = require("events"); | ||
const fast_jwt_1 = require("fast-jwt"); | ||
const fetch_http2_1 = require("fetch-http2"); | ||
const jsonwebtoken_1 = require("jsonwebtoken"); | ||
const errors_1 = require("./errors"); | ||
@@ -30,2 +30,3 @@ const notification_1 = require("./notifications/notification"); | ||
this.requestTimeout = options.requestTimeout; | ||
this.keepAlive = options.keepAlive; | ||
this.pingInterval = options.pingInterval; | ||
@@ -56,3 +57,3 @@ this._token = null; | ||
timeout: this.requestTimeout, | ||
keepAlive: this.pingInterval ?? 5000 | ||
keepAlive: this.keepAlive ?? this.pingInterval ?? 5000 | ||
}; | ||
@@ -87,3 +88,7 @@ if (notification.priority !== notification_1.Priority.immediate) { | ||
json.notification = notification; | ||
this.emit(json.reason, json); | ||
// Emit specific error | ||
if (json.reason) { | ||
this.emit(json.reason, json); | ||
} | ||
// Emit generic error | ||
this.emit(errors_1.Errors.error, json); | ||
@@ -100,9 +105,8 @@ throw json; | ||
}; | ||
const token = (0, jsonwebtoken_1.sign)(claims, this.signingKey, { | ||
const signer = (0, fast_jwt_1.createSigner)({ | ||
key: this.signingKey, | ||
algorithm: SIGNING_ALGORITHM, | ||
header: { | ||
alg: SIGNING_ALGORITHM, | ||
kid: this.keyId | ||
} | ||
kid: this.keyId | ||
}); | ||
const token = signer(claims); | ||
this._token = { | ||
@@ -109,0 +113,0 @@ value: token, |
{ | ||
"name": "apns2", | ||
"version": "11.4.0", | ||
"version": "11.5.0", | ||
"description": "Node client for connecting to Apple's Push Notification Service using the new HTTP/2 protocol with JSON web tokens.", | ||
@@ -31,13 +31,12 @@ "author": "Andrew Barba <barba@hey.com>", | ||
"dependencies": { | ||
"fetch-http2": "^1.3.0", | ||
"jsonwebtoken": "^9.0.2" | ||
"fetch-http2": "^1.4.0", | ||
"fast-jwt": "^3.3.2" | ||
}, | ||
"devDependencies": { | ||
"@biomejs/biome": "^1.2.2", | ||
"@biomejs/biome": "^1.5.3", | ||
"@tsconfig/node16": "^16.1.1", | ||
"@types/jsonwebtoken": "^9.0.3", | ||
"@types/node": "^20.8.2", | ||
"chai": "^4.3.10", | ||
"typescript": "^5.2.2", | ||
"vitest": "^0.34.6" | ||
"@types/node": "^20.11.6", | ||
"chai": "^5.0.3", | ||
"typescript": "^5.3.3", | ||
"vitest": "^1.2.1" | ||
}, | ||
@@ -44,0 +43,0 @@ "scripts": { |
@@ -1,2 +0,2 @@ | ||
# APNS2 | ||
# apns2 | ||
@@ -23,3 +23,3 @@ [![npm version](https://badge.fury.io/js/apns2.svg)](https://badge.fury.io/js/apns2) | ||
requestTimeout: 0, // optional, Default: 0 (without timeout) | ||
pingInterval: 5000, // optional, Default: 5000 | ||
keepAlive: true, // optional, Default: 5000 | ||
}) | ||
@@ -26,0 +26,0 @@ ``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21325
6
408
+ Addedfast-jwt@^3.3.2
+ Added@lukeed/ms@2.0.2(transitive)
+ Addedasn1.js@5.4.1(transitive)
+ Addedbn.js@4.12.1(transitive)
+ Addedfast-jwt@3.3.3(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedminimalistic-assert@1.0.1(transitive)
+ Addedmnemonist@0.39.8(transitive)
+ Addedobliterator@2.0.5(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
- Removedjsonwebtoken@^9.0.2
- Removedbuffer-equal-constant-time@1.0.1(transitive)
- Removedjsonwebtoken@9.0.2(transitive)
- Removedjwa@1.4.1(transitive)
- Removedjws@3.2.2(transitive)
- Removedlodash.includes@4.3.0(transitive)
- Removedlodash.isboolean@3.0.3(transitive)
- Removedlodash.isinteger@4.0.4(transitive)
- Removedlodash.isnumber@3.0.3(transitive)
- Removedlodash.isplainobject@4.0.6(transitive)
- Removedlodash.isstring@4.0.1(transitive)
- Removedlodash.once@4.1.1(transitive)
- Removedms@2.1.3(transitive)
- Removedsemver@7.6.3(transitive)
Updatedfetch-http2@^1.4.0