1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 00:03:56 +00:00

[PM-21705] Require userID for refreshAdditionalKeys() on key-service (#14810)

* Require userID for refreshAdditionalKeys()

* Add error handling to desktop Unlock settings

* Add more unit test coverage
This commit is contained in:
Thomas Avery
2025-06-06 13:38:25 -05:00
committed by GitHub
parent 3e4c37b8b3
commit 9d743a7ee0
8 changed files with 553 additions and 76 deletions

View File

@@ -122,15 +122,17 @@ export class DefaultKeyService implements KeyServiceAbstraction {
await this.setPrivateKey(encPrivateKey, userId);
}
async refreshAdditionalKeys(): Promise<void> {
const activeUserId = await firstValueFrom(this.stateProvider.activeUserId$);
if (activeUserId == null) {
throw new Error("Can only refresh keys while there is an active user.");
async refreshAdditionalKeys(userId: UserId): Promise<void> {
if (userId == null) {
throw new Error("UserId is required.");
}
const key = await this.getUserKey(activeUserId);
await this.setUserKey(key, activeUserId);
const key = await firstValueFrom(this.userKey$(userId));
if (key == null) {
throw new Error("No user key found for: " + userId);
}
await this.setUserKey(key, userId);
}
everHadUserKey$(userId: UserId): Observable<boolean> {