1
0
mirror of https://github.com/bitwarden/browser synced 2026-03-01 19:11:22 +00:00

Key Management in crypto with TS strict

This commit is contained in:
Maciej Zieniuk
2025-02-27 17:33:38 +00:00
parent a5ea8066a3
commit face84937e
15 changed files with 60 additions and 44 deletions

View File

@@ -27,7 +27,7 @@ export class RotateableKeySetService {
const rawPublicKey = Utils.fromB64ToArray(publicKey);
const encryptedUserKey = await this.encryptService.rsaEncrypt(userKey.key, rawPublicKey);
const encryptedPublicKey = await this.encryptService.encrypt(rawPublicKey, userKey);
return new RotateableKeySet(encryptedUserKey, encryptedPublicKey, encryptedPrivateKey);
return new RotateableKeySet(encryptedUserKey, encryptedPublicKey!, encryptedPrivateKey);
}
/**
@@ -64,7 +64,7 @@ export class RotateableKeySetService {
const newRotateableKeySet = new RotateableKeySet<ExternalKey>(
newEncryptedUserKey,
newEncryptedPublicKey,
newEncryptedPublicKey!,
keySet.encryptedPrivateKey,
);

View File

@@ -180,6 +180,6 @@ export class UserKeyRotationService {
if (privateKey == null) {
throw new Error("No private key found for user key rotation");
}
return (await this.encryptService.encrypt(privateKey, newUserKey)).encryptedString;
return (await this.encryptService.encrypt(privateKey, newUserKey))!.encryptedString;
}
}