1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-01-06 18:57:56 +01:00

clear deprecated keys when setting new user key

This commit is contained in:
Jacob Fink 2023-06-27 09:52:06 -04:00
parent 0bbba9c6f7
commit 156c58fd94
No known key found for this signature in database
GPG Key ID: C2F7ACF05859D008
5 changed files with 8 additions and 5 deletions

View File

@ -36,6 +36,7 @@ export class ElectronCryptoService extends CryptoService {
} else {
await this.stateService.setUserKeyBiometric(null, { userId: userId });
}
await this.stateService.setCryptoMasterKeyBiometric(null, { userId: userId });
}
protected override async getKeyFromStorage(

View File

@ -50,7 +50,7 @@ export class SetPinComponent implements OnInit {
} else {
await this.stateService.setUserKeyPin(pinProtectedKey);
}
await this.cryptoService.clearOldPinKeys();
await this.cryptoService.clearDeprecatedPinKeys();
this.modalRef.close(true);
}

View File

@ -293,7 +293,7 @@ export abstract class CryptoService {
* Clears the user's old pin keys from storage
* @param userId The desired user
*/
clearOldPinKeys: (userId?: string) => Promise<void>;
clearDeprecatedPinKeys: (userId?: string) => Promise<void>;
/**
* Decrypts the user key with their pin
* @param pin The user's PIN

View File

@ -513,10 +513,10 @@ export class CryptoService implements CryptoServiceAbstraction {
async clearPinProtectedKey(userId?: string): Promise<void> {
await this.stateService.setUserKeyPin(null, { userId: userId });
await this.clearOldPinKeys(userId);
await this.clearDeprecatedPinKeys(userId);
}
async clearOldPinKeys(userId?: string): Promise<void> {
async clearDeprecatedPinKeys(userId?: string): Promise<void> {
await this.stateService.setEncryptedPinProtected(null, { userId: userId });
await this.stateService.setDecryptedPinProtected(null, { userId: userId });
}
@ -714,10 +714,12 @@ export class CryptoService implements CryptoServiceAbstraction {
} else {
await this.stateService.setUserKeyAuto(null, { userId: userId });
}
await this.stateService.setCryptoMasterKeyAuto(null, { userId: userId });
const storePin = await this.shouldStoreKey(KeySuffixOptions.Pin, userId);
if (storePin) {
await this.storePinKey(key);
await this.clearDeprecatedPinKeys(userId);
} else {
await this.stateService.setUserKeyPin(null, { userId: userId });
}

View File

@ -118,6 +118,6 @@ export class VaultTimeoutSettingsService implements VaultTimeoutSettingsServiceA
await this.stateService.setEverBeenUnlocked(false, { userId: userId });
await this.stateService.setUserKeyPinEphemeral(null, { userId: userId });
await this.stateService.setProtectedPin(null, { userId: userId });
await this.cryptoService.clearOldPinKeys(userId);
await this.cryptoService.clearDeprecatedPinKeys(userId);
}
}