diff --git a/src/index.ts b/src/index.ts index a474414..fb74d93 100644 --- a/src/index.ts +++ b/src/index.ts @@ -379,7 +379,10 @@ class CookieStoreManager { } } -if (!('cookies' in ServiceWorkerRegistration.prototype)) { +if ( + typeof ServiceWorkerRegistration !== 'undefined' && + !('cookies' in ServiceWorkerRegistration.prototype) +) { Object.defineProperty(ServiceWorkerRegistration.prototype, 'cookies', { configurable: true, enumerable: true,