[PM-5887] Refactor WebCryptoFunction to Remove Usage of the window Object in the Background Script (#7749)

This commit is contained in:
Cesar Gonzalez 2024-02-21 09:51:02 -06:00 committed by GitHub
parent c037b1dbbe
commit 7629652a47
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 4 deletions

View File

@ -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 =

View File

@ -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();
}