From 7629652a478488623653d15e3727eedc8b950a6e Mon Sep 17 00:00:00 2001 From: Cesar Gonzalez Date: Wed, 21 Feb 2024 09:51:02 -0600 Subject: [PATCH] [PM-5887] Refactor WebCryptoFunction to Remove Usage of the window Object in the Background Script (#7749) --- apps/browser/src/background/main.background.ts | 2 +- .../src/platform/services/web-crypto-function.service.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/browser/src/background/main.background.ts b/apps/browser/src/background/main.background.ts index 3988b3748c..00dc3e3ebc 100644 --- a/apps/browser/src/background/main.background.ts +++ b/apps/browser/src/background/main.background.ts @@ -326,7 +326,7 @@ export default class MainBackground { ? new BrowserMessagingPrivateModeBackgroundService() : new BrowserMessagingService(); this.logService = new ConsoleLogService(false); - this.cryptoFunctionService = new WebCryptoFunctionService(window); + this.cryptoFunctionService = new WebCryptoFunctionService(self); this.storageService = new BrowserLocalStorageService(); this.secureStorageService = new BrowserLocalStorageService(); this.memoryStorageService = diff --git a/libs/common/src/platform/services/web-crypto-function.service.ts b/libs/common/src/platform/services/web-crypto-function.service.ts index fb0bf33b64..fd0763714a 100644 --- a/libs/common/src/platform/services/web-crypto-function.service.ts +++ b/libs/common/src/platform/services/web-crypto-function.service.ts @@ -12,10 +12,10 @@ export class WebCryptoFunctionService implements CryptoFunctionService { private subtle: SubtleCrypto; private wasmSupported: boolean; - constructor(win: Window | typeof global) { - this.crypto = typeof win.crypto !== "undefined" ? win.crypto : null; + constructor(globalContext: Window | typeof global) { + this.crypto = typeof globalContext.crypto !== "undefined" ? globalContext.crypto : null; this.subtle = - !!this.crypto && typeof win.crypto.subtle !== "undefined" ? win.crypto.subtle : null; + !!this.crypto && typeof this.crypto.subtle !== "undefined" ? this.crypto.subtle : null; this.wasmSupported = this.checkIfWasmSupported(); }