1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-15 15:53:27 +00:00

[PM-21611] Require userId on KeyService clear methods (#14788)

This commit is contained in:
Thomas Avery
2025-05-22 13:55:26 -05:00
committed by GitHub
parent 57911f210b
commit bd29397fd8
9 changed files with 41 additions and 35 deletions

View File

@@ -564,11 +564,9 @@ export class DefaultKeyService implements KeyServiceAbstraction {
await this.stateProvider.setUserState(USER_ENCRYPTED_PRIVATE_KEY, null, userId);
}
async clearPinKeys(userId?: UserId): Promise<void> {
userId ??= await firstValueFrom(this.stateProvider.activeUserId$);
async clearPinKeys(userId: UserId): Promise<void> {
if (userId == null) {
throw new Error("Cannot clear PIN keys, no user Id resolved.");
throw new Error("UserId is required");
}
await this.pinService.clearPinKeyEncryptedUserKeyPersistent(userId);
@@ -588,11 +586,9 @@ export class DefaultKeyService implements KeyServiceAbstraction {
return (await this.keyGenerationService.createKey(512)) as CipherKey;
}
async clearKeys(userId?: UserId): Promise<any> {
userId ??= await firstValueFrom(this.stateProvider.activeUserId$);
async clearKeys(userId: UserId): Promise<void> {
if (userId == null) {
throw new Error("Cannot clear keys, no user Id resolved.");
throw new Error("UserId is required");
}
await this.masterPasswordService.clearMasterKeyHash(userId);