Skip to content

Commit

Permalink
Merge pull request #303 from web-push-libs/update_deps
Browse files Browse the repository at this point in the history
Update some dependencies
  • Loading branch information
marco-c committed Dec 20, 2017
2 parents e1ccd54 + ba283fb commit c75caf4
Show file tree
Hide file tree
Showing 9 changed files with 2,215 additions and 1,451 deletions.
4 changes: 3 additions & 1 deletion .eslintrc
Expand Up @@ -15,6 +15,8 @@
"no-param-reassign": 0,
"quote-props": 0,
"wrap-iife": [2, "inside"],
"import/no-unresolved": 0
"import/no-unresolved": 0,
"indent": 0,
"no-buffer-constructor": 0, // We still support Node v4.
}
}
3,564 changes: 2,165 additions & 1,399 deletions package-lock.json

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions package.json
Expand Up @@ -29,26 +29,26 @@
},
"homepage": "https://github.com/web-push-libs/web-push#readme",
"dependencies": {
"asn1.js": "^4.8.1",
"asn1.js": "^5.0.0",
"http_ece": "^0.5.2",
"jws": "^3.1.3",
"minimist": "^1.2.0",
"urlsafe-base64": "^1.0.0"
},
"devDependencies": {
"chalk": "^1.1.3",
"chromedriver": "2.24.1",
"del": "^2.2.1",
"eslint": "^3.5.0",
"eslint-config-airbnb": "^11.1.0",
"eslint-plugin-import": "^1.16.0",
"geckodriver": "1.1.3",
"chalk": "^2.3.0",
"chromedriver": "^2.33.2",
"del": "^3.0.0",
"eslint": "^4.12.1",
"eslint-config-airbnb": "^16.1.0",
"eslint-plugin-import": "^2.8.0",
"geckodriver": "^1.10.0",
"istanbul": "^0.4.2",
"mkdirp": "^0.5.1",
"mocha": "^3.0.2",
"mocha": "^4.0.1",
"portfinder": "^1.0.2",
"selenium-assistant": "1.0.0",
"selenium-webdriver": "3.0.0-beta-2",
"selenium-assistant": "^5.2.0",
"selenium-webdriver": "^3.6.0",
"semver": "^5.1.0",
"sinon": "^4.0.1",
"which": "^1.2.11"
Expand Down
3 changes: 2 additions & 1 deletion src/cli.js
@@ -1,5 +1,6 @@
#! /usr/bin/env node
/* eslint consistent-return:0*/
/* eslint consistent-return:0 */

'use strict';

const webPush = require('../src/index.js');
Expand Down
15 changes: 7 additions & 8 deletions src/web-push-lib.js
Expand Up @@ -177,8 +177,7 @@ WebPushLib.prototype.generateRequestDetails =
'required encryption keys'));
}

const encrypted = encryptionHelper.encrypt(
subscription.keys.p256dh, subscription.keys.auth, payload);
const encrypted = encryptionHelper.encrypt(subscription.keys.p256dh, subscription.keys.auth, payload);

requestDetails.headers['Content-Length'] = encrypted.cipherText.length;
requestDetails.headers['Content-Type'] = 'application/octet-stream';
Expand All @@ -191,8 +190,7 @@ WebPushLib.prototype.generateRequestDetails =
requestDetails.headers['Content-Length'] = 0;
}

const isGCM = subscription.endpoint.indexOf(
'https://android.googleapis.com/gcm/send') === 0;
const isGCM = subscription.endpoint.indexOf('https://android.googleapis.com/gcm/send') === 0;
// VAPID isn't supported by GCM hence the if, else if.
if (isGCM) {
if (!currentGCMAPIKey) {
Expand Down Expand Up @@ -247,8 +245,7 @@ WebPushLib.prototype.sendNotification =
function(subscription, payload, options) {
let requestDetails;
try {
requestDetails = this.generateRequestDetails(
subscription, payload, options);
requestDetails = this.generateRequestDetails(subscription, payload, options);
} catch (err) {
return Promise.reject(err);
}
Expand All @@ -272,8 +269,10 @@ WebPushLib.prototype.sendNotification =

pushResponse.on('end', function() {
if (pushResponse.statusCode < 200 || pushResponse.statusCode > 299) {
reject(new WebPushError('Received unexpected response code',
pushResponse.statusCode, pushResponse.headers, responseText, requestDetails.endpoint));
reject(new WebPushError(
'Received unexpected response code',
pushResponse.statusCode, pushResponse.headers, responseText, requestDetails.endpoint
));
} else {
resolve({
statusCode: pushResponse.statusCode,
Expand Down
3 changes: 3 additions & 0 deletions test/data/demo/service-worker.js
@@ -1,3 +1,6 @@
/* Needed because of https://github.com/airbnb/javascript/issues/1632 */
/* eslint no-restricted-globals: 0 */

'use strict';

let port;
Expand Down
12 changes: 9 additions & 3 deletions test/helpers/download-test-browsers.js
@@ -1,18 +1,24 @@
'use strict';

// The latest version of Selenium doesn't support Node 4.
const semver = require('semver');
if (!semver.gte(process.version, '5.0.0')) {
return;
}

const seleniumAssistant = require('selenium-assistant');

const MAX_RETRIES = 3;
let forceDownload = false;
let expiration;
if (process.env.TRAVIS) {
forceDownload = true;
expiration = 0;
}

const downloadBrowser = (name, version, attempt) => {
attempt = attempt || 0;

return new Promise((resolve, reject) => {
seleniumAssistant.downloadBrowser(name, version, forceDownload)
seleniumAssistant.downloadLocalBrowser(name, version, expiration)
.catch((err) => {
if (attempt < MAX_RETRIES) {
console.log(`Attempt ${attempt + 1} of browser ${name} - ${version} failed.`);
Expand Down
9 changes: 3 additions & 6 deletions test/test-vapid-helper.js
Expand Up @@ -152,16 +152,13 @@ suite('Test Vapid Helpers', function() {
test('should get valid VAPID headers', function() {
const validInputs = [
function() {
return vapidHelper.getVapidHeaders(VALID_AUDIENCE, VALID_SUBJECT_URL,
VALID_PUBLIC_KEY, VALID_PRIVATE_KEY);
return vapidHelper.getVapidHeaders(VALID_AUDIENCE, VALID_SUBJECT_URL, VALID_PUBLIC_KEY, VALID_PRIVATE_KEY);
},
function() {
return vapidHelper.getVapidHeaders(VALID_AUDIENCE, VALID_SUBJECT_MAILTO,
VALID_PUBLIC_KEY, VALID_PRIVATE_KEY);
return vapidHelper.getVapidHeaders(VALID_AUDIENCE, VALID_SUBJECT_MAILTO, VALID_PUBLIC_KEY, VALID_PRIVATE_KEY);
},
function() {
return vapidHelper.getVapidHeaders(VALID_AUDIENCE, VALID_SUBJECT_URL,
VALID_PUBLIC_KEY, VALID_PRIVATE_KEY, VALID_EXPIRATION);
return vapidHelper.getVapidHeaders(VALID_AUDIENCE, VALID_SUBJECT_URL, VALID_PUBLIC_KEY, VALID_PRIVATE_KEY, VALID_EXPIRATION);
},
function() {
// 0 is a valid value for `expiration`
Expand Down
34 changes: 12 additions & 22 deletions test/testSelenium.js
@@ -1,5 +1,11 @@
'use strict';

// The latest version of Selenium doesn't support Node 4.
const semver = require('semver');
if (!semver.gte(process.version, '5.0.0')) {
return;
}

const seleniumAssistant = require('selenium-assistant');
const webdriver = require('selenium-webdriver');
const seleniumFirefox = require('selenium-webdriver/firefox');
Expand Down Expand Up @@ -35,19 +41,7 @@ let testServerURL;
function runTest(browser, options) {
options = options || {};

if (browser.getSeleniumBrowserId() === 'firefox' &&
browser.getVersionNumber() <= 48 &&
process.env.TRAVIS === 'true') {
console.log('');
console.warn(chalk.red(
'Running on Travis so skipping firefox tests as ' +
'they don\'t currently work.'
));
console.log('');
return Promise.resolve();
}

if (browser.getSeleniumBrowserId() === 'firefox' &&
if (browser.getId() === 'firefox' &&
process.env.TRAVIS === 'true') {
try {
which.sync('geckodriver');
Expand All @@ -56,10 +50,7 @@ function runTest(browser, options) {
// don't have the GH_TOKEN
if (process.env.TRAVIS_PULL_REQUEST !== false) {
console.log('');
console.warn(chalk.red(
'Running on Travis OS X so skipping firefox tests as ' +
'they don\'t currently work.'
));
console.warn(chalk.red('Running on Travis OS X so skipping firefox tests as they don\'t currently work.'));
console.log('');
return Promise.resolve();
}
Expand All @@ -71,15 +62,15 @@ function runTest(browser, options) {
globalServer = server;
testServerURL = 'http://127.0.0.1:' + server.port;

if (browser.getSeleniumBrowserId() === 'firefox') {
if (browser.getId() === 'firefox') {
// This is based off of: https://bugzilla.mozilla.org/show_bug.cgi?id=1275521
// Unfortunately it doesn't seem to work :(
const ffProfile = new seleniumFirefox.Profile();
ffProfile.setPreference('dom.push.testing.ignorePermission', true);
ffProfile.setPreference('notification.prompt.testing', true);
ffProfile.setPreference('notification.prompt.testing.allow', true);
browser.getSeleniumOptions().setProfile(ffProfile);
} else if (browser.getSeleniumBrowserId() === 'chrome') {
} else if (browser.getId() === 'chrome') {
const chromeOperaPreferences = {
profile: {
content_settings: {
Expand Down Expand Up @@ -199,10 +190,9 @@ function runTest(browser, options) {

seleniumAssistant.printAvailableBrowserInfo();

const availableBrowsers = seleniumAssistant.getAvailableBrowsers();
const availableBrowsers = seleniumAssistant.getLocalBrowsers();
availableBrowsers.forEach(function(browser) {
if (browser.getSeleniumBrowserId() !== 'chrome' &&
browser.getSeleniumBrowserId() !== 'firefox') {
if (browser.getId() !== 'chrome' && browser.getId() !== 'firefox') {
return;
}

Expand Down

0 comments on commit c75caf4

Please sign in to comment.