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

@pusher/push-notifications-web

Package Overview
Dependencies
Maintainers
8
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 0.9.0 to 0.9.1

23

dist/push-notifications-esm.js

@@ -258,3 +258,3 @@ function _defineProperty(obj, key, value) {

var version = "0.9.0";
var version = "0.9.1";

@@ -337,5 +337,16 @@ const SERVICE_WORKER_URL = `/service-worker.js?pusherBeamsWebSDKVersion=${version}`;

this.userId = userId;
this._serviceWorkerRegistration = serviceWorkerRegistration;
this._deviceStateStore = deviceStateStore;
this._endpoint = endpointOverride; // Internal only
if (serviceWorkerRegistration) {
const serviceWorkerScope = serviceWorkerRegistration.scope;
const currentURL = window.location.href;
const scopeMatchesCurrentPage = currentURL.startsWith(serviceWorkerScope);
if (!scopeMatchesCurrentPage) {
throw new Error(`Could not initialize Pusher web push: current page not in serviceWorkerRegistration scope (${serviceWorkerScope})`);
}
}
this._serviceWorkerRegistration = serviceWorkerRegistration;
}

@@ -458,3 +469,7 @@

try {
if (this._serviceWorkerRegistration) ; else {
let reg;
if (this._serviceWorkerRegistration) {
reg = this._serviceWorkerRegistration; // TODO: Call update only when we detect an SDK change
} else {
// Check that service worker file exists

@@ -475,5 +490,5 @@ const {

});
reg = await window.navigator.serviceWorker.ready;
}
const reg = await window.navigator.serviceWorker.ready;
const sub = await reg.pushManager.subscribe({

@@ -480,0 +495,0 @@ userVisibleOnly: true,

@@ -156,2 +156,28 @@ import { launchServer, createChromeWebDriver } from './test-utils';

test('SDK should fail if provided service worker is in wrong scope', async () => {
await chromeDriver.get('http://localhost:3000');
await chromeDriver.wait(() => {
return chromeDriver.getTitle().then(title => title.includes('Test Page'));
}, 2000);
const errorMessage = await chromeDriver.executeAsyncScript(() => {
const asyncScriptReturnCallback = arguments[arguments.length - 1];
const instanceId = 'deadc0de-2ce6-46e3-ad9a-5c02d0ab119b';
return window.navigator.serviceWorker
.register('/not-the-root/service-worker.js')
.then(registration =>
PusherPushNotifications.init({
instanceId,
serviceWorkerRegistration: registration,
})
)
.catch(e => asyncScriptReturnCallback(e.message));
});
expect(errorMessage).toContain(
'current page not in serviceWorkerRegistration scope'
);
});
afterAll(() => {

@@ -158,0 +184,0 @@ if (killServer) {

@@ -36,2 +36,8 @@ const express = require('express');

// Service worker in unusual location
app.get('/not-the-root/service-worker.js', (req, res) => {
res.set('Content-Type', 'text/javascript');
res.send('');
});
app.listen(PORT, () => console.log(`Listening on port ${PORT}...`));

3

package.json
{
"name": "@pusher/push-notifications-web",
"version": "0.9.0",
"version": "0.9.1",
"description": "",

@@ -15,2 +15,3 @@ "main": "dist/push-notifications-esm.js",

"prepublishchecks": "npm run lint && npm run test:unit && npm run build:cdn && npm run build:esm && npm run test:e2e",
"prepublishOnly": "publish-please guard",
"publish-please": "publish-please"

@@ -17,0 +18,0 @@ },

@@ -89,6 +89,17 @@ import doRequest from './do-request';

this.userId = userId;
this._serviceWorkerRegistration = serviceWorkerRegistration;
this._deviceStateStore = deviceStateStore;
this._endpoint = endpointOverride; // Internal only
if (serviceWorkerRegistration) {
const serviceWorkerScope = serviceWorkerRegistration.scope;
const currentURL = window.location.href;
const scopeMatchesCurrentPage = currentURL.startsWith(serviceWorkerScope);
if (!scopeMatchesCurrentPage) {
throw new Error(
`Could not initialize Pusher web push: current page not in serviceWorkerRegistration scope (${serviceWorkerScope})`
);
}
}
this._serviceWorkerRegistration = serviceWorkerRegistration;
}

@@ -223,3 +234,6 @@

try {
let reg;
if (this._serviceWorkerRegistration) {
reg = this._serviceWorkerRegistration;
// TODO: Call update only when we detect an SDK change

@@ -241,4 +255,5 @@ } else {

});
reg = await window.navigator.serviceWorker.ready;
}
const reg = await window.navigator.serviceWorker.ready;
const sub = await reg.pushManager.subscribe({

@@ -245,0 +260,0 @@ userVisibleOnly: true,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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