coi-serviceworker
Advanced tools
Comparing version 0.1.5 to 0.1.6
@@ -1,2 +0,2 @@ | ||
/*! coi-serviceworker v0.1.4 - Guido Zuidhof, licensed under MIT */ | ||
/*! coi-serviceworker v0.1.6 - Guido Zuidhof, licensed under MIT */ | ||
if (typeof window === 'undefined') { | ||
@@ -3,0 +3,0 @@ self.addEventListener("install", () => self.skipWaiting()); |
@@ -1,2 +0,2 @@ | ||
/*! coi-serviceworker v0.1.4 - Guido Zuidhof, licensed under MIT */ | ||
/*! coi-serviceworker v0.1.6 - Guido Zuidhof, licensed under MIT */ | ||
"undefined"==typeof window?(self.addEventListener("install",(()=>self.skipWaiting())),self.addEventListener("activate",(e=>e.waitUntil(self.clients.claim()))),self.addEventListener("message",(e=>{e.data&&"deregister"===e.data.type&&self.registration.unregister().then((()=>self.clients.matchAll())).then((e=>{e.forEach((e=>e.navigate(e.url)))}))})),self.addEventListener("fetch",(function(e){"only-if-cached"===e.request.cache&&"same-origin"!==e.request.mode||e.respondWith(fetch(e.request).then((e=>{if(0===e.status)return e;const r=new Headers(e.headers);return r.set("Cross-Origin-Embedder-Policy","require-corp"),r.set("Cross-Origin-Opener-Policy","same-origin"),new Response(e.body,{status:e.status,statusText:e.statusText,headers:r})})).catch((e=>console.error(e))))}))):(()=>{const e={shouldRegister:()=>!0,shouldDeregister:()=>!1,doReload:()=>window.location.reload(),quiet:!1,...window.coi},r=navigator;e.shouldDeregister()&&r.serviceWorker&&r.serviceWorker.controller&&r.serviceWorker.controller.postMessage({type:"deregister"}),!1===window.crossOriginIsolated&&e.shouldRegister()&&(window.isSecureContext?r.serviceWorker&&r.serviceWorker.register(window.document.currentScript.src).then((t=>{e.quiet,console.log("COOP/COEP Service Worker registered",t.scope),t.addEventListener("updatefound",(()=>{!e.quiet&&console.log("Reloading page to make use of updated COOP/COEP Service Worker."),e.doReload()})),t.active&&!r.serviceWorker.controller&&(!e.quiet&&console.log("Reloading page to make use of COOP/COEP Service Worker."),e.doReload())}),(r=>{!e.quiet&&console.error("COOP/COEP Service Worker failed to register:",r)})):!e.quiet&&console.log("COOP/COEP Service Worker not registered, a secure context is required."))})(); |
{ | ||
"name": "coi-serviceworker", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"description": "Cross-Origin Isolation through a service worker", | ||
@@ -5,0 +5,0 @@ "main": "coi-serviceworker.js", |
@@ -16,3 +16,3 @@ # coi-serviceworker | ||
This script will reload the page on the user's first load to magically add the required COOP and COEP headers in a serice worker. | ||
This script will reload the page on the user's first load to magically add the required COOP and COEP headers in a service worker. | ||
@@ -22,3 +22,3 @@ **Rules**: | ||
* It can't be loaded from a CDN: it must be served from your own origin. | ||
* Your page will still need to be either localhost or https enabled. | ||
* Your page will still need to be either served from HTTPS, or served from localhost. | ||
@@ -63,2 +63,2 @@ | ||
![Carp or Koi Artwork](https://i.imgur.com/HVyWe6T.jpeg) | ||
> Carp or Koi (1926) by Ohara Koson. Original from the Los Angeles County Museum of Art. Public Domain CC0 image. | ||
> Carp or Koi (1926) by Ohara Koson. Original from the Los Angeles County Museum of Art. Public Domain CC0 image. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
62
10363