service-worker-mock
Advanced tools
Comparing version 2.0.3 to 2.0.4
@@ -38,3 +38,3 @@ const EventTarget = require('./EventTarget'); | ||
*/ | ||
postMessage(message /* , transfer?: Transferable[]*/) { | ||
postMessage(message /* , transfer?: Transferable[] */) { | ||
const event = new MessageEvent('message', { | ||
@@ -41,0 +41,0 @@ data: message |
@@ -5,5 +5,6 @@ const ExtendableEvent = require('./ExtendableEvent'); | ||
class NotificationEvent extends ExtendableEvent { | ||
constructor(args) { | ||
super(); | ||
this.notification = args; | ||
constructor(type, init) { | ||
super(type, init); | ||
this.notification = init ? init.notification : null; | ||
this.action = init ? init.action : null; | ||
} | ||
@@ -10,0 +11,0 @@ } |
@@ -49,2 +49,19 @@ // stubs https://developer.mozilla.org/en-US/docs/Web/API/Response | ||
/** | ||
* Creates a new response with a different URL. | ||
* @param url The URL that the new response is to originate from. | ||
* @param status [Optional] An optional status code for the response (e.g., 302.) | ||
* @returns {Response} | ||
*/ | ||
static redirect(url, status = 302) { | ||
// see https://fetch.spec.whatwg.org/#dom-response-redirect | ||
if (![301, 302, 303, 307, 308].includes(status)) { | ||
throw new RangeError('Invalid status code'); | ||
} | ||
return new Response(null, { | ||
status: status, | ||
headers: { Location: new URL(url).href } | ||
}); | ||
} | ||
static error() { | ||
@@ -51,0 +68,0 @@ const errorResponse = new Response(null, { |
@@ -36,3 +36,3 @@ const PushManager = require('./PushManager'); | ||
}; | ||
return Promise.resolve(new NotificationEvent(notification)); | ||
return Promise.resolve(new NotificationEvent('notification', { notification })); | ||
} | ||
@@ -39,0 +39,0 @@ |
{ | ||
"name": "service-worker-mock", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"main": "index.js", | ||
@@ -27,3 +27,3 @@ "repository": { | ||
"dom-urls": "^1.1.0", | ||
"shelving-mock-indexeddb": "github:philipwalton/shelving-mock-indexeddb#621b7a275568051846d20e3e557fa1101418b1d1", | ||
"shelving-mock-indexeddb": "^1.1.0", | ||
"url-search-params": "^0.10.0", | ||
@@ -30,0 +30,0 @@ "w3c-hr-time": "^1.0.1" |
@@ -13,3 +13,3 @@ const ExtendableEvent = require('../models/ExtendableEvent'); | ||
case 'notificationclose': | ||
return new NotificationEvent(args); | ||
return new NotificationEvent('notification', { notification: args }); | ||
case 'push': | ||
@@ -16,0 +16,0 @@ return new PushEvent(args); |
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
GitHub dependency
Supply chain riskContains a dependency which resolves to a GitHub URL. Dependencies fetched from GitHub specifiers are not immutable can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
38810
1071
0
1
+ Addedlodash._basefor@3.0.3(transitive)
+ Addedlodash.isarguments@3.1.0(transitive)
+ Addedlodash.isarray@3.0.4(transitive)
+ Addedlodash.isplainobject@3.2.0(transitive)
+ Addedlodash.keysin@3.0.8(transitive)
+ Addedrealistic-structured-clone@1.0.1(transitive)
+ Addedshelving-mock-event@1.0.12(transitive)
+ Addedshelving-mock-indexeddb@1.1.0(transitive)