diff --git a/package-lock.json b/package-lock.json index 59359d13..1f15fe4f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,8 +13,7 @@ "http_ece": "1.1.0", "https-proxy-agent": "^5.0.0", "jws": "^4.0.0", - "minimist": "^1.2.5", - "urlsafe-base64": "^1.0.0" + "minimist": "^1.2.5" }, "bin": { "web-push": "src/cli.js" @@ -3106,9 +3105,9 @@ } }, "node_modules/http-cache-semantics": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz", - "integrity": "sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz", + "integrity": "sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ==", "dev": true }, "node_modules/http-signature": { @@ -3774,9 +3773,9 @@ "dev": true }, "node_modules/json5": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz", - "integrity": "sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==", + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", "dev": true, "bin": { "json5": "lib/cli.js" @@ -5985,9 +5984,9 @@ } }, "node_modules/tsconfig-paths/node_modules/json5": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", - "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz", + "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==", "dev": true, "dependencies": { "minimist": "^1.2.0" @@ -8698,9 +8697,9 @@ } }, "http-cache-semantics": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz", - "integrity": "sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz", + "integrity": "sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ==", "dev": true }, "http-signature": { @@ -9189,9 +9188,9 @@ "dev": true }, "json5": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz", - "integrity": "sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==", + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", "dev": true }, "jsonfile": { @@ -10895,9 +10894,9 @@ }, "dependencies": { "json5": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", - "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz", + "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==", "dev": true, "requires": { "minimist": "^1.2.0" diff --git a/package.json b/package.json index 30c3200d..c575345f 100644 --- a/package.json +++ b/package.json @@ -33,8 +33,7 @@ "http_ece": "1.1.0", "https-proxy-agent": "^5.0.0", "jws": "^4.0.0", - "minimist": "^1.2.5", - "urlsafe-base64": "^1.0.0" + "minimist": "^1.2.5" }, "devDependencies": { "chromedriver": "101.0.0", diff --git a/src/encryption-helper.js b/src/encryption-helper.js index 321d3eef..3c11571a 100644 --- a/src/encryption-helper.js +++ b/src/encryption-helper.js @@ -2,7 +2,7 @@ const crypto = require('crypto'); const ece = require('http_ece'); -const urlBase64 = require('urlsafe-base64'); +const urlBase64Helper = require('./urlsafe-base64-helper'); const encrypt = function(userPublicKey, userAuth, payload, contentEncoding) { if (!userPublicKey) { @@ -13,7 +13,7 @@ const encrypt = function(userPublicKey, userAuth, payload, contentEncoding) { throw new Error('The subscription p256dh value must be a string.'); } - if (urlBase64.decode(userPublicKey).length !== 65) { + if (urlBase64Helper.decode(userPublicKey).length !== 65) { throw new Error('The subscription p256dh value should be 65 bytes long.'); } @@ -25,7 +25,7 @@ const encrypt = function(userPublicKey, userAuth, payload, contentEncoding) { throw new Error('The subscription auth key must be a string.'); } - if (urlBase64.decode(userAuth).length < 16) { + if (urlBase64Helper.decode(userAuth).length < 16) { throw new Error('The subscription auth key should be at least 16 ' + 'bytes long'); } @@ -41,7 +41,7 @@ const encrypt = function(userPublicKey, userAuth, payload, contentEncoding) { const localCurve = crypto.createECDH('prime256v1'); const localPublicKey = localCurve.generateKeys(); - const salt = urlBase64.encode(crypto.randomBytes(16)); + const salt = urlBase64Helper.encode(crypto.randomBytes(16)); const cipherText = ece.encrypt(payload, { version: contentEncoding, diff --git a/src/urlsafe-base64-helper.js b/src/urlsafe-base64-helper.js new file mode 100644 index 00000000..6a7a6c2e --- /dev/null +++ b/src/urlsafe-base64-helper.js @@ -0,0 +1,32 @@ +// Largely ported from https://github.com/RGBboy/urlsafe-base64 + +'use strict'; + +function encode(buffer) { + return buffer.toString('base64') + .replace(/\+/g, '-') // Convert '+' to '-' + .replace(/\//g, '_') // Convert '/' to '_' + .replace(/=+$/, ''); // Remove ending '=' +} + +function decode(base64) { + // Add removed at end '=' + base64 += Array(5 - (base64.length % 4)).join('='); + + base64 = base64 + .replace(/-/g, '+') // Convert '-' to '+' + .replace(/_/g, '/'); // Convert '_' to '/' + + // change from urlsafe-base64 since new Buffer() is deprecated + return Buffer.from(base64, 'base64'); +} + +function validate(base64) { + return /^[A-Za-z0-9\-_]+$/.test(base64); + } + +module.exports = { + encode: encode, + decode: decode, + validate: validate +}; diff --git a/src/vapid-helper.js b/src/vapid-helper.js index 4c6cfe27..9329f048 100644 --- a/src/vapid-helper.js +++ b/src/vapid-helper.js @@ -1,12 +1,12 @@ 'use strict'; const crypto = require('crypto'); -const urlBase64 = require('urlsafe-base64'); const asn1 = require('asn1.js'); const jws = require('jws'); const { URL } = require('url'); const WebPushConstants = require('./web-push-constants.js'); +const urlBase64Helper = require('./urlsafe-base64-helper'); /** * DEFAULT_EXPIRATION is set to seconds in 12 hours @@ -60,8 +60,8 @@ function generateVAPIDKeys() { } return { - publicKey: urlBase64.encode(publicKeyBuffer), - privateKey: urlBase64.encode(privateKeyBuffer) + publicKey: urlBase64Helper.encode(publicKeyBuffer), + privateKey: urlBase64Helper.encode(privateKeyBuffer) }; } @@ -100,11 +100,11 @@ function validatePublicKey(publicKey) { + 'encoded string.'); } - if (!urlBase64.validate(publicKey)) { + if (!urlBase64Helper.validate(publicKey)) { throw new Error('Vapid public key must be a URL safe Base 64 (without "=")'); } - publicKey = urlBase64.decode(publicKey); + publicKey = urlBase64Helper.decode(publicKey); if (publicKey.length !== 65) { throw new Error('Vapid public key should be 65 bytes long when decoded.'); @@ -121,11 +121,11 @@ function validatePrivateKey(privateKey) { + 'encoded string.'); } - if (!urlBase64.validate(privateKey)) { + if (!urlBase64Helper.validate(privateKey)) { throw new Error('Vapid private key must be a URL safe Base 64 (without "=")'); } - privateKey = urlBase64.decode(privateKey); + privateKey = urlBase64Helper.decode(privateKey); if (privateKey.length !== 32) { throw new Error('Vapid private key should be 32 bytes long when decoded.'); @@ -203,7 +203,7 @@ function getVapidHeaders(audience, subject, publicKey, privateKey, contentEncodi validatePublicKey(publicKey); validatePrivateKey(privateKey); - privateKey = urlBase64.decode(privateKey); + privateKey = urlBase64Helper.decode(privateKey); if (expiration) { validateExpiration(expiration); diff --git a/src/web-push-lib.js b/src/web-push-lib.js index bec919dd..1fdb73d3 100644 --- a/src/web-push-lib.js +++ b/src/web-push-lib.js @@ -1,6 +1,5 @@ 'use strict'; -const urlBase64 = require('urlsafe-base64'); const url = require('url'); const https = require('https'); @@ -8,6 +7,7 @@ const WebPushError = require('./web-push-error.js'); const vapidHelper = require('./vapid-helper.js'); const encryptionHelper = require('./encryption-helper.js'); const webPushConstants = require('./web-push-constants.js'); +const urlBase64Helper = require('./urlsafe-base64-helper'); // Default TTL is four weeks. const DEFAULT_TTL = 2419200; @@ -189,7 +189,7 @@ WebPushLib.prototype.generateRequestDetails = function(subscription, payload, op } if (options.topic) { - if (!urlBase64.validate(options.topic)) { + if (!urlBase64Helper.validate(options.topic)) { throw new Error('Unsupported characters set use the URL or filename-safe Base64 characters set'); } if (options.topic.length > 32) { @@ -251,7 +251,7 @@ WebPushLib.prototype.generateRequestDetails = function(subscription, payload, op } else if (contentEncoding === webPushConstants.supportedContentEncodings.AES_GCM) { requestDetails.headers['Content-Encoding'] = webPushConstants.supportedContentEncodings.AES_GCM; requestDetails.headers.Encryption = 'salt=' + encrypted.salt; - requestDetails.headers['Crypto-Key'] = 'dh=' + urlBase64.encode(encrypted.localPublicKey); + requestDetails.headers['Crypto-Key'] = 'dh=' + urlBase64Helper.encode(encrypted.localPublicKey); } requestPayload = encrypted.cipherText; diff --git a/test/test-cli.js b/test/test-cli.js index 900244ee..7174bbd1 100644 --- a/test/test-cli.js +++ b/test/test-cli.js @@ -8,8 +8,8 @@ } const assert = require('assert'); - const urlBase64 = require('urlsafe-base64'); const spawn = require('child_process').spawn; + const urlBase64Helper = require('../src/urlsafe-base64-helper'); const cliPath = 'src/cli.js'; @@ -147,13 +147,13 @@ return line.indexOf('Public Key:') !== -1; }); const publicKey = lines[publicKeyTitleIndex + 1].trim(); - assert.equal(urlBase64.decode(publicKey).length, 65); + assert.equal(urlBase64Helper.decode(publicKey).length, 65); const privateKeyTitleIndex = lines.findIndex(function(line) { return line.indexOf('Private Key:') !== -1; }); const privateKey = lines[privateKeyTitleIndex + 1].trim(); - assert.equal(urlBase64.decode(privateKey).length, 32); + assert.equal(urlBase64Helper.decode(privateKey).length, 32); resolve(); }); }); @@ -185,8 +185,8 @@ assert(vapidKeys.publicKey); assert(vapidKeys.privateKey); - assert.equal(urlBase64.decode(vapidKeys.privateKey).length, 32); - assert.equal(urlBase64.decode(vapidKeys.publicKey).length, 65); + assert.equal(urlBase64Helper.decode(vapidKeys.privateKey).length, 32); + assert.equal(urlBase64Helper.decode(vapidKeys.publicKey).length, 65); resolve(); }); diff --git a/test/test-encryption-helper.js b/test/test-encryption-helper.js index 1de19b60..5476bf54 100644 --- a/test/test-encryption-helper.js +++ b/test/test-encryption-helper.js @@ -3,12 +3,12 @@ const assert = require('assert'); const crypto = require('crypto'); const webPush = require('../src/index'); +const urlBase64Helper = require('../src/urlsafe-base64-helper'); const ece = require('http_ece'); -const urlBase64 = require('urlsafe-base64'); const userCurve = crypto.createECDH('prime256v1'); -const VALID_PUBLIC_KEY = urlBase64.encode(userCurve.generateKeys()); -const VALID_AUTH = urlBase64.encode(crypto.randomBytes(16)); +const VALID_PUBLIC_KEY = urlBase64Helper.encode(userCurve.generateKeys()); +const VALID_AUTH = urlBase64Helper.encode(crypto.randomBytes(16)); suite('Test Encryption Helpers', function() { test('is defined', function() { @@ -20,7 +20,7 @@ suite('Test Encryption Helpers', function() { return ece.decrypt(encrypted.cipherText, { version: contentEncoding, - dh: urlBase64.encode(encrypted.localPublicKey), + dh: urlBase64Helper.encode(encrypted.localPublicKey), privateKey: userCurve, salt: encrypted.salt, authSecret: VALID_AUTH diff --git a/test/test-generate-request-details.js b/test/test-generate-request-details.js index 407256c8..4361bad1 100644 --- a/test/test-generate-request-details.js +++ b/test/test-generate-request-details.js @@ -1,8 +1,8 @@ 'use strict'; const assert = require('assert'); -const urlBase64 = require('urlsafe-base64'); const webPush = require('../src/index'); +const urlBase64Helper = require('../src/urlsafe-base64-helper'); const crypto = require('crypto'); const jws = require('jws'); const urlParse = require('url').parse; @@ -19,8 +19,8 @@ suite('Test Generate Request Details', function() { const vapidKeys = require('../src/vapid-helper').generateVAPIDKeys(); const VALID_KEYS = { - p256dh: urlBase64.encode(userPublicKey), - auth: urlBase64.encode(userAuth) + p256dh: urlBase64Helper.encode(userPublicKey), + auth: urlBase64Helper.encode(userAuth) }; const invalidRequests = [ @@ -85,7 +85,7 @@ suite('Test Generate Request Details', function() { subscription: { endpoint: true, keys: { - p256dh: urlBase64.encode(userPublicKey) + p256dh: urlBase64Helper.encode(userPublicKey) } }, message: 'hello' @@ -96,7 +96,7 @@ suite('Test Generate Request Details', function() { subscription: { endpoint: true, keys: { - auth: urlBase64.encode(userAuth) + auth: urlBase64Helper.encode(userAuth) } }, message: 'hello' @@ -107,7 +107,7 @@ suite('Test Generate Request Details', function() { subscription: { keys: { p256dh: userPublicKey, - auth: urlBase64.encode(userAuth) + auth: urlBase64Helper.encode(userAuth) } }, message: 'hello' @@ -118,7 +118,7 @@ suite('Test Generate Request Details', function() { requestOptions: { subscription: { keys: { - p256dh: urlBase64.encode(userPublicKey), + p256dh: urlBase64Helper.encode(userPublicKey), auth: userAuth } }, @@ -130,8 +130,8 @@ suite('Test Generate Request Details', function() { requestOptions: { subscription: { keys: { - p256dh: urlBase64.encode(Buffer.concat([userPublicKey, Buffer.alloc(1)])), - auth: urlBase64.encode(userAuth) + p256dh: urlBase64Helper.encode(Buffer.concat([userPublicKey, Buffer.alloc(1)])), + auth: urlBase64Helper.encode(userAuth) } }, message: 'hello' @@ -142,8 +142,8 @@ suite('Test Generate Request Details', function() { requestOptions: { subscription: { keys: { - p256dh: urlBase64.encode(userPublicKey.slice(1)), - auth: urlBase64.encode(userAuth) + p256dh: urlBase64Helper.encode(userPublicKey.slice(1)), + auth: urlBase64Helper.encode(userAuth) } }, message: 'hello' @@ -154,8 +154,8 @@ suite('Test Generate Request Details', function() { requestOptions: { subscription: { keys: { - p256dh: urlBase64.encode(userPublicKey), - auth: urlBase64.encode(userAuth.slice(1)) + p256dh: urlBase64Helper.encode(userPublicKey), + auth: urlBase64Helper.encode(userAuth.slice(1)) } }, message: 'hello' diff --git a/test/test-set-vapid-details.js b/test/test-set-vapid-details.js index e3f15e7c..36cd956c 100644 --- a/test/test-set-vapid-details.js +++ b/test/test-set-vapid-details.js @@ -1,13 +1,13 @@ 'use strict'; const assert = require('assert'); -const urlBase64 = require('urlsafe-base64'); const webPush = require('../src/index'); +const urlBase64Helper = require('../src/urlsafe-base64-helper'); const VALID_SUBJECT_MAILTO = 'mailto: example@example.com'; const VALID_SUBJECT_URL = 'https://exampe.com/contact'; -const VALID_PUBLIC_KEY = urlBase64.encode(Buffer.alloc(65)); -const VALID_PRIVATE_KEY = urlBase64.encode(Buffer.alloc(32)); +const VALID_PUBLIC_KEY = urlBase64Helper.encode(Buffer.alloc(65)); +const VALID_PRIVATE_KEY = urlBase64Helper.encode(Buffer.alloc(32)); suite('setVapidDetails()', function() { test('is defined', function() { @@ -55,7 +55,7 @@ suite('setVapidDetails()', function() { }, { subject: VALID_SUBJECT_URL, - publicKey: urlBase64.encode(Buffer.alloc(60)), + publicKey: urlBase64Helper.encode(Buffer.alloc(60)), privateKey: VALID_PRIVATE_KEY }, { @@ -81,7 +81,7 @@ suite('setVapidDetails()', function() { { subject: VALID_SUBJECT_URL, publicKey: VALID_PUBLIC_KEY, - privateKey: urlBase64.encode(Buffer.alloc(60)) + privateKey: urlBase64Helper.encode(Buffer.alloc(60)) }, { subject: VALID_SUBJECT_URL, diff --git a/test/test-vapid-helper.js b/test/test-vapid-helper.js index 071a44fc..a3624877 100644 --- a/test/test-vapid-helper.js +++ b/test/test-vapid-helper.js @@ -1,12 +1,12 @@ 'use strict'; const assert = require('assert'); -const urlBase64 = require('urlsafe-base64'); const sinon = require('sinon'); const crypto = require('crypto'); const mocha = require('mocha'); const webPush = require('../src/index'); const vapidHelper = require('../src/vapid-helper'); +const urlBase64Helper = require('../src/urlsafe-base64-helper'); const VALID_AUDIENCE = 'https://example.com'; const VALID_SUBJECT_MAILTO = 'mailto:example@example.com'; @@ -15,9 +15,9 @@ const VALID_SUBJECT_URL = 'https://example.com/contact'; const WARN_SUBJECT_LOCALHOST_URL = 'https://localhost'; const INVALID_SUBJECT_URL_1 = 'http://example.gov'; const INVALID_SUBJECT_URL_2 = 'ftp://example.net'; -const VALID_PUBLIC_KEY = urlBase64.encode(Buffer.alloc(65)); +const VALID_PUBLIC_KEY = urlBase64Helper.encode(Buffer.alloc(65)); const VALID_UNSAFE_BASE64_PUBLIC_KEY = Buffer.alloc(65).toString('base64'); -const VALID_PRIVATE_KEY = urlBase64.encode(Buffer.alloc(32)); +const VALID_PRIVATE_KEY = urlBase64Helper.encode(Buffer.alloc(32)); const VALID_UNSAFE_BASE64_PRIVATE_KEY = Buffer.alloc(32).toString('base64'); const VALID_CONTENT_ENCODING = webPush.supportedContentEncodings.AES_GCM; const VALID_EXPIRATION = Math.floor(Date.now() / 1000) + (60 * 60 * 12); @@ -46,8 +46,8 @@ suite('Test Vapid Helpers', function() { assert.equal(typeof keys.privateKey, 'string'); assert.equal(typeof keys.publicKey, 'string'); - assert.equal(urlBase64.decode(keys.privateKey).length, 32); - assert.equal(urlBase64.decode(keys.publicKey).length, 65); + assert.equal(urlBase64Helper.decode(keys.privateKey).length, 32); + assert.equal(urlBase64Helper.decode(keys.publicKey).length, 65); }); test('generate vapid keys with padding', function() { @@ -66,8 +66,8 @@ suite('Test Vapid Helpers', function() { assert.equal(typeof keys.privateKey, 'string'); assert.equal(typeof keys.publicKey, 'string'); - assert.equal(urlBase64.decode(keys.privateKey).length, 32); - assert.equal(urlBase64.decode(keys.publicKey).length, 65); + assert.equal(urlBase64Helper.decode(keys.privateKey).length, 32); + assert.equal(urlBase64Helper.decode(keys.publicKey).length, 65); }); test('generate new vapid keys between calls', function() { diff --git a/test/testSendNotification.js b/test/testSendNotification.js index ea73bd8f..b55310b5 100644 --- a/test/testSendNotification.js +++ b/test/testSendNotification.js @@ -6,11 +6,11 @@ const https = require('https'); const fs = require('fs'); const path = require('path'); const ece = require('http_ece'); -const urlBase64 = require('urlsafe-base64'); const portfinder = require('portfinder'); const jws = require('jws'); const mocha = require('mocha'); const WebPushConstants = require('../src/web-push-constants.js'); +const urlBase64Helper = require('../src/urlsafe-base64-helper'); suite('sendNotification', function() { test('is defined', function() { @@ -62,8 +62,8 @@ suite('sendNotification', function() { const userAuth = crypto.randomBytes(16); const VALID_KEYS = { - p256dh: urlBase64.encode(userPublicKey), - auth: urlBase64.encode(userAuth) + p256dh: urlBase64Helper.encode(userPublicKey), + auth: urlBase64Helper.encode(userAuth) }; const vapidKeys = require('../src/vapid-helper').generateVAPIDKeys(); @@ -166,7 +166,7 @@ suite('sendNotification', function() { privateKey: userCurve, dh: appServerPublicKey, salt: salt, - authSecret: urlBase64.encode(userAuth) + authSecret: urlBase64Helper.encode(userAuth) }); assert(decrypted.equals(Buffer.from(options.message)), 'Check cipher text can be correctly decoded'); @@ -671,7 +671,7 @@ suite('sendNotification', function() { subscription: { endpoint: true, keys: { - p256dh: urlBase64.encode(userPublicKey) + p256dh: urlBase64Helper.encode(userPublicKey) } }, message: 'hello' @@ -682,7 +682,7 @@ suite('sendNotification', function() { subscription: { endpoint: true, keys: { - auth: urlBase64.encode(userAuth) + auth: urlBase64Helper.encode(userAuth) } }, message: 'hello' @@ -693,7 +693,7 @@ suite('sendNotification', function() { subscription: { keys: { p256dh: userPublicKey, - auth: urlBase64.encode(userAuth) + auth: urlBase64Helper.encode(userAuth) } }, message: 'hello' @@ -704,7 +704,7 @@ suite('sendNotification', function() { requestOptions: { subscription: { keys: { - p256dh: urlBase64.encode(userPublicKey), + p256dh: urlBase64Helper.encode(userPublicKey), auth: userAuth } }, @@ -716,8 +716,8 @@ suite('sendNotification', function() { requestOptions: { subscription: { keys: { - p256dh: urlBase64.encode(Buffer.concat([userPublicKey, Buffer.alloc(1)])), - auth: urlBase64.encode(userAuth) + p256dh: urlBase64Helper.encode(Buffer.concat([userPublicKey, Buffer.alloc(1)])), + auth: urlBase64Helper.encode(userAuth) } }, message: 'hello' @@ -728,8 +728,8 @@ suite('sendNotification', function() { requestOptions: { subscription: { keys: { - p256dh: urlBase64.encode(userPublicKey.slice(1)), - auth: urlBase64.encode(userAuth) + p256dh: urlBase64Helper.encode(userPublicKey.slice(1)), + auth: urlBase64Helper.encode(userAuth) } }, message: 'hello' @@ -740,8 +740,8 @@ suite('sendNotification', function() { requestOptions: { subscription: { keys: { - p256dh: urlBase64.encode(userPublicKey), - auth: urlBase64.encode(userAuth.slice(1)) + p256dh: urlBase64Helper.encode(userPublicKey), + auth: urlBase64Helper.encode(userAuth.slice(1)) } }, message: 'hello'