1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-06 00:13:28 +00:00

[PM-22516] Fix cipher key decryption to handle new error-based API instead of null returns (#15124)

* Replace null check in cipher key decryption

* Handle decryption error properly in user asymmetric key regeneration service
This commit is contained in:
SmithThe4th
2025-06-23 09:11:52 -04:00
committed by GitHub
parent 54d7d27221
commit e253e05c45
3 changed files with 83 additions and 11 deletions

View File

@@ -162,17 +162,26 @@ export class DefaultUserAsymmetricKeysRegenerationService
const ciphers = await this.cipherService.getAll(userId);
const cipher = ciphers.find((cipher) => cipher.organizationId == null);
if (cipher != null) {
try {
await cipher.decrypt(userKey);
return true;
} catch (error) {
if (!cipher) {
return false;
}
try {
const cipherView = await cipher.decrypt(userKey);
if (cipherView.decryptionFailure) {
this.logService.error(
"[UserAsymmetricKeyRegeneration] User Symmetric Key validation error: " + error,
"[UserAsymmetricKeyRegeneration] User Symmetric Key validation error: Cipher decryption failed",
);
return false;
}
return true;
} catch (error) {
this.logService.error(
"[UserAsymmetricKeyRegeneration] User Symmetric Key validation error: " + error,
);
return false;
}
return false;
}
}