@digipair/skill-push-notification 0.136.1 → 0.136.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1949,6 +1949,10 @@ bn.exports;
1949
1949
  var mask = 0x3ffffff ^ 0x3ffffff >>> r << r;
1950
1950
  this.words[this.length - 1] &= mask;
1951
1951
  }
1952
+ if (this.length === 0) {
1953
+ this.words[0] = 0;
1954
+ this.length = 1;
1955
+ }
1952
1956
  return this.strip();
1953
1957
  };
1954
1958
  // Return only lowers bits of number
@@ -5140,7 +5144,12 @@ function jwsSign(opts) {
5140
5144
  return util$1.format('%s.%s', securedInput, signature);
5141
5145
  }
5142
5146
  function SignStream$1(opts) {
5143
- var secret = opts.secret || opts.privateKey || opts.key;
5147
+ var secret = opts.secret;
5148
+ secret = secret == null ? opts.privateKey : secret;
5149
+ secret = secret == null ? opts.key : secret;
5150
+ if (/^hs/i.test(opts.header.alg) === true && secret == null) {
5151
+ throw new TypeError('secret must be a string or buffer or a KeyObject');
5152
+ }
5144
5153
  var secretStream = new DataStream$1(secret);
5145
5154
  this.readable = true;
5146
5155
  this.header = opts.header;
@@ -5243,7 +5252,12 @@ function jwsDecode(jwsSig, opts) {
5243
5252
  }
5244
5253
  function VerifyStream$1(opts) {
5245
5254
  opts = opts || {};
5246
- var secretOrKey = opts.secret || opts.publicKey || opts.key;
5255
+ var secretOrKey = opts.secret;
5256
+ secretOrKey = secretOrKey == null ? opts.publicKey : secretOrKey;
5257
+ secretOrKey = secretOrKey == null ? opts.key : secretOrKey;
5258
+ if (/^hs/i.test(opts.algorithm) === true && secretOrKey == null) {
5259
+ throw new TypeError('secret must be a string or buffer or a KeyObject');
5260
+ }
5247
5261
  var secretStream = new DataStream(secretOrKey);
5248
5262
  this.readable = true;
5249
5263
  this.algorithm = opts.algorithm;
@@ -5308,18 +5322,18 @@ jws$1.createVerify = function createVerify(opts) {
5308
5322
  return new VerifyStream(opts);
5309
5323
  };
5310
5324
 
5311
- var WebPushConstants$2 = {};
5312
- WebPushConstants$2.supportedContentEncodings = {
5325
+ var WebPushConstants$1 = {};
5326
+ WebPushConstants$1.supportedContentEncodings = {
5313
5327
  AES_GCM: 'aesgcm',
5314
5328
  AES_128_GCM: 'aes128gcm'
5315
5329
  };
5316
- WebPushConstants$2.supportedUrgency = {
5330
+ WebPushConstants$1.supportedUrgency = {
5317
5331
  VERY_LOW: 'very-low',
5318
5332
  LOW: 'low',
5319
5333
  NORMAL: 'normal',
5320
5334
  HIGH: 'high'
5321
5335
  };
5322
- var webPushConstants$1 = WebPushConstants$2;
5336
+ var webPushConstants$1 = WebPushConstants$1;
5323
5337
 
5324
5338
  /**
5325
5339
  * @param {string} base64
@@ -5335,7 +5349,7 @@ var crypto$2 = require$$0$1;
5335
5349
  var asn1 = asn1$1;
5336
5350
  var jws = jws$1;
5337
5351
  var URL = require$$3$1.URL;
5338
- var WebPushConstants$1 = webPushConstants$1;
5352
+ var WebPushConstants = webPushConstants$1;
5339
5353
  var urlBase64Helper$1 = urlsafeBase64Helper;
5340
5354
  /**
5341
5355
  * DEFAULT_EXPIRATION is set to seconds in 12 hours
@@ -5522,12 +5536,12 @@ function validatePrivateKey(privateKey) {
5522
5536
  payload: jwtPayload,
5523
5537
  privateKey: toPEM(privateKey)
5524
5538
  });
5525
- if (contentEncoding === WebPushConstants$1.supportedContentEncodings.AES_128_GCM) {
5539
+ if (contentEncoding === WebPushConstants.supportedContentEncodings.AES_128_GCM) {
5526
5540
  return {
5527
5541
  Authorization: 'vapid t=' + jwt + ', k=' + publicKey
5528
5542
  };
5529
5543
  }
5530
- if (contentEncoding === WebPushConstants$1.supportedContentEncodings.AES_GCM) {
5544
+ if (contentEncoding === WebPushConstants.supportedContentEncodings.AES_GCM) {
5531
5545
  return {
5532
5546
  Authorization: 'WebPush ' + jwt,
5533
5547
  'Crypto-Key': 'p256ecdsa=' + publicKey
@@ -5535,7 +5549,7 @@ function validatePrivateKey(privateKey) {
5535
5549
  }
5536
5550
  throw new Error('Unsupported encoding type specified.');
5537
5551
  }
5538
- var vapidHelper$2 = {
5552
+ var vapidHelper$1 = {
5539
5553
  generateVAPIDKeys: generateVAPIDKeys,
5540
5554
  getFutureExpirationTimestamp: getFutureExpirationTimestamp,
5541
5555
  getVapidHeaders: getVapidHeaders,
@@ -6097,11 +6111,11 @@ var encrypt = function encrypt(userPublicKey, userAuth, payload, contentEncoding
6097
6111
  cipherText: cipherText
6098
6112
  };
6099
6113
  };
6100
- var encryptionHelper$2 = {
6114
+ var encryptionHelper$1 = {
6101
6115
  encrypt: encrypt
6102
6116
  };
6103
6117
 
6104
- function WebPushError$2(message, statusCode, headers, body, endpoint) {
6118
+ function WebPushError$1(message, statusCode, headers, body, endpoint) {
6105
6119
  Error.captureStackTrace(this, this.constructor);
6106
6120
  this.name = this.constructor.name;
6107
6121
  this.message = message;
@@ -6110,8 +6124,8 @@ function WebPushError$2(message, statusCode, headers, body, endpoint) {
6110
6124
  this.body = body;
6111
6125
  this.endpoint = endpoint;
6112
6126
  }
6113
- require$$5.inherits(WebPushError$2, Error);
6114
- var webPushError = WebPushError$2;
6127
+ require$$5.inherits(WebPushError$1, Error);
6128
+ var webPushError = WebPushError$1;
6115
6129
 
6116
6130
  var dist$1 = {};
6117
6131
 
@@ -8551,9 +8565,9 @@ function _type_of(obj) {
8551
8565
  }
8552
8566
  var url = require$$3$1;
8553
8567
  var https = require$$1;
8554
- var WebPushError$1 = webPushError;
8555
- var vapidHelper$1 = vapidHelper$2;
8556
- var encryptionHelper$1 = encryptionHelper$2;
8568
+ var WebPushError = webPushError;
8569
+ var vapidHelper = vapidHelper$1;
8570
+ var encryptionHelper = encryptionHelper$1;
8557
8571
  var webPushConstants = webPushConstants$1;
8558
8572
  var urlBase64Helper = urlsafeBase64Helper;
8559
8573
  // Default TTL is four weeks.
@@ -8590,9 +8604,9 @@ function WebPushLib$1() {}
8590
8604
  vapidDetails = null;
8591
8605
  return;
8592
8606
  }
8593
- vapidHelper$1.validateSubject(subject);
8594
- vapidHelper$1.validatePublicKey(publicKey);
8595
- vapidHelper$1.validatePrivateKey(privateKey);
8607
+ vapidHelper.validateSubject(subject);
8608
+ vapidHelper.validatePublicKey(publicKey);
8609
+ vapidHelper.validatePrivateKey(privateKey);
8596
8610
  vapidDetails = {
8597
8611
  subject: subject,
8598
8612
  publicKey: publicKey,
@@ -8736,7 +8750,7 @@ function WebPushLib$1() {}
8736
8750
  });
8737
8751
  var requestPayload = null;
8738
8752
  if (payload) {
8739
- var encrypted = encryptionHelper$1.encrypt(subscription.keys.p256dh, subscription.keys.auth, payload, contentEncoding);
8753
+ var encrypted = encryptionHelper.encrypt(subscription.keys.p256dh, subscription.keys.auth, payload, contentEncoding);
8740
8754
  requestDetails.headers['Content-Length'] = encrypted.cipherText.length;
8741
8755
  requestDetails.headers['Content-Type'] = 'application/octet-stream';
8742
8756
  if (contentEncoding === webPushConstants.supportedContentEncodings.AES_128_GCM) {
@@ -8762,7 +8776,7 @@ function WebPushLib$1() {}
8762
8776
  } else if (currentVapidDetails) {
8763
8777
  var parsedUrl = url.parse(subscription.endpoint);
8764
8778
  var audience = parsedUrl.protocol + '//' + parsedUrl.host;
8765
- var vapidHeaders = vapidHelper$1.getVapidHeaders(audience, currentVapidDetails.subject, currentVapidDetails.publicKey, currentVapidDetails.privateKey, contentEncoding);
8779
+ var vapidHeaders = vapidHelper.getVapidHeaders(audience, currentVapidDetails.subject, currentVapidDetails.publicKey, currentVapidDetails.privateKey, contentEncoding);
8766
8780
  requestDetails.headers.Authorization = vapidHeaders.Authorization;
8767
8781
  if (contentEncoding === webPushConstants.supportedContentEncodings.AES_GCM) {
8768
8782
  if (requestDetails.headers['Crypto-Key']) {
@@ -8836,7 +8850,7 @@ function WebPushLib$1() {}
8836
8850
  });
8837
8851
  pushResponse.on('end', function() {
8838
8852
  if (pushResponse.statusCode < 200 || pushResponse.statusCode > 299) {
8839
- reject(new WebPushError$1('Received unexpected response code', pushResponse.statusCode, pushResponse.headers, responseText, requestDetails.endpoint));
8853
+ reject(new WebPushError('Received unexpected response code', pushResponse.statusCode, pushResponse.headers, responseText, requestDetails.endpoint));
8840
8854
  } else {
8841
8855
  resolve({
8842
8856
  statusCode: pushResponse.statusCode,
@@ -8862,18 +8876,9 @@ function WebPushLib$1() {}
8862
8876
  };
8863
8877
  var webPushLib = WebPushLib$1;
8864
8878
 
8865
- var vapidHelper = vapidHelper$2;
8866
- var encryptionHelper = encryptionHelper$2;
8867
8879
  var WebPushLib = webPushLib;
8868
- var WebPushError = webPushError;
8869
- var WebPushConstants = webPushConstants$1;
8870
8880
  var webPush = new WebPushLib();
8871
8881
  var src = {
8872
- WebPushError: WebPushError,
8873
- supportedContentEncodings: WebPushConstants.supportedContentEncodings,
8874
- encrypt: encryptionHelper.encrypt,
8875
- getVapidHeaders: vapidHelper.getVapidHeaders,
8876
- generateVAPIDKeys: vapidHelper.generateVAPIDKeys,
8877
8882
  setGCMAPIKey: webPush.setGCMAPIKey,
8878
8883
  setVapidDetails: webPush.setVapidDetails,
8879
8884
  generateRequestDetails: webPush.generateRequestDetails,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digipair/skill-push-notification",
3
- "version": "0.136.1",
3
+ "version": "0.136.3",
4
4
  "main": "./dist/index.cjs.js",
5
5
  "module": "./dist/index.esm.js",
6
6
  "types": "./dist/index.d.ts",
@@ -1,2 +0,0 @@
1
- export * from './lib/skill-push-notification';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC"}
@@ -1,4 +0,0 @@
1
- import { PinsSettings } from '@digipair/engine';
2
- import * as webPush from 'web-push';
3
- export declare const sendPush: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<webPush.SendResult>;
4
- //# sourceMappingURL=skill-push-notification.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"skill-push-notification.d.ts","sourceRoot":"","sources":["../../../src/lib/skill-push-notification.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,OAAO,MAAM,UAAU,CAAC;AAoBpC,eAAO,MAAM,QAAQ,GAAI,QAAQ,GAAG,EAAE,kBAAkB,YAAY,EAAE,EAAE,SAAS,GAAG,gCACT,CAAC"}