mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 15:53:27 +00:00
[PM-24105] Remove usage of getUserKey on keyService (#16626)
• prefer undefined over null • obtain required UserId once per method, before branching • guards moved to beginning of methods * lift UserId retrieval to occur once during import * remove redundant userId retrieval
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { firstValueFrom } from "rxjs";
|
||||
|
||||
import { EncryptService } from "@bitwarden/common/key-management/crypto/abstractions/encrypt.service";
|
||||
import { EncString } from "@bitwarden/common/key-management/crypto/models/enc-string";
|
||||
import { UserId } from "@bitwarden/common/types/guid";
|
||||
@@ -15,7 +17,11 @@ export class LegacyPasswordHistoryDecryptor {
|
||||
|
||||
/** Decrypts a password history. */
|
||||
async decrypt(history: GeneratedPasswordHistory[]): Promise<GeneratedPasswordHistory[]> {
|
||||
const key = await this.keyService.getUserKey(this.userId);
|
||||
const key = await firstValueFrom(this.keyService.userKey$(this.userId));
|
||||
|
||||
if (key == undefined) {
|
||||
throw new Error("No user key found for decryption");
|
||||
}
|
||||
|
||||
const promises = (history ?? []).map(async (item) => {
|
||||
const encrypted = new EncString(item.password);
|
||||
|
||||
Reference in New Issue
Block a user