mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 15:53:27 +00:00
Use encrypt service in node env secure storage (#9099)
* Use `EncryptService` In `NodeEnvSecureStorage` To Replace Deprecated Methods * Update Abstract EncryptService Method To Reflect Implementation
This commit is contained in:
@@ -272,7 +272,7 @@ export class Main {
|
||||
this.secureStorageService = new NodeEnvSecureStorageService(
|
||||
this.storageService,
|
||||
this.logService,
|
||||
() => this.cryptoService,
|
||||
this.encryptService,
|
||||
);
|
||||
|
||||
this.memoryStorageService = new MemoryStorageService();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { throwError } from "rxjs";
|
||||
|
||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
||||
import { AbstractStorageService } from "@bitwarden/common/platform/abstractions/storage.service";
|
||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||
@@ -11,7 +11,7 @@ export class NodeEnvSecureStorageService implements AbstractStorageService {
|
||||
constructor(
|
||||
private storageService: AbstractStorageService,
|
||||
private logService: LogService,
|
||||
private cryptoService: () => CryptoService,
|
||||
private encryptService: EncryptService,
|
||||
) {}
|
||||
|
||||
get valuesRequireDeserialization(): boolean {
|
||||
@@ -59,7 +59,7 @@ export class NodeEnvSecureStorageService implements AbstractStorageService {
|
||||
if (sessionKey == null) {
|
||||
throw new Error("No session key available.");
|
||||
}
|
||||
const encValue = await this.cryptoService().encryptToBytes(
|
||||
const encValue = await this.encryptService.encryptToBytes(
|
||||
Utils.fromB64ToArray(plainValue),
|
||||
sessionKey,
|
||||
);
|
||||
@@ -78,7 +78,7 @@ export class NodeEnvSecureStorageService implements AbstractStorageService {
|
||||
}
|
||||
|
||||
const encBuf = EncArrayBuffer.fromB64(encValue);
|
||||
const decValue = await this.cryptoService().decryptFromBytes(encBuf, sessionKey);
|
||||
const decValue = await this.encryptService.decryptToBytes(encBuf, sessionKey);
|
||||
if (decValue == null) {
|
||||
this.logService.info("Failed to decrypt.");
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user