From 51df81393d0d6da058664b3c3564aa6b455d7ad6 Mon Sep 17 00:00:00 2001 From: Matt Gibson Date: Mon, 11 Mar 2024 16:51:09 -0500 Subject: [PATCH] Use local storage for browser's secure storage (#8231) UI warns the user whenever using secure storage in browser that it's insecure. This is not a change from the current background behavior, just uses the already existing services in each context. --- apps/browser/src/background/main.background.ts | 2 +- apps/browser/src/popup/services/services.module.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/browser/src/background/main.background.ts b/apps/browser/src/background/main.background.ts index a28afa3339..7512093a2d 100644 --- a/apps/browser/src/background/main.background.ts +++ b/apps/browser/src/background/main.background.ts @@ -352,7 +352,7 @@ export default class MainBackground { this.cryptoFunctionService = new WebCryptoFunctionService(self); this.keyGenerationService = new KeyGenerationService(this.cryptoFunctionService); this.storageService = new BrowserLocalStorageService(); - this.secureStorageService = new BrowserLocalStorageService(); + this.secureStorageService = this.storageService; // secure storage is not supported in browsers, so we use local storage and warn users when it is used this.memoryStorageService = BrowserApi.isManifestVersion(3) ? new LocalBackedSessionStorageService( new EncryptServiceImplementation(this.cryptoFunctionService, this.logService, false), diff --git a/apps/browser/src/popup/services/services.module.ts b/apps/browser/src/popup/services/services.module.ts index 00dee196b5..a9cce99429 100644 --- a/apps/browser/src/popup/services/services.module.ts +++ b/apps/browser/src/popup/services/services.module.ts @@ -417,7 +417,7 @@ function getBgService(service: keyof MainBackground) { }, { provide: SECURE_STORAGE, - useFactory: getBgService("secureStorageService"), + useExisting: AbstractStorageService, // Secure storage is not available in the browser, so we use normal storage instead and warn users when it is used. }, { provide: MEMORY_STORAGE,