1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-10 13:40:06 +00:00

Added function to decrypt fido2 key value and updated test

This commit is contained in:
gbubemismith
2025-04-15 11:51:28 -04:00
parent 561bfb612d
commit 69bc7cfb85
2 changed files with 14 additions and 14 deletions

View File

@@ -194,7 +194,7 @@ describe("DefaultCipherEncryptionService", () => {
mockSdkClient.vault().ciphers().decrypt.mockReturnValue(sdkCipherView);
mockSdkClient.vault().ciphers().decrypt_fido2_credentials.mockReturnValue(fido2Credentials);
mockSdkClient.vault().ciphers().decrypt_key = jest
mockSdkClient.vault().ciphers().decrypt_fido2_private_key = jest
.fn()
.mockReturnValue("decrypted-key-value");
@@ -210,9 +210,9 @@ describe("DefaultCipherEncryptionService", () => {
expect(mockSdkClient.vault().ciphers().decrypt_fido2_credentials).toHaveBeenCalledWith(
sdkCipherView,
);
expect(mockSdkClient.vault().ciphers().decrypt_key).toHaveBeenCalledWith(
expect(mockSdkClient.vault().ciphers().decrypt_fido2_private_key).toHaveBeenCalledWith(
sdkCipherView,
fido2CredentialView.keyValue,
fido2Credentials[0].keyValue,
);
expect(Fido2CredentialView.fromSdkFido2CredentialView).toHaveBeenCalledTimes(1);
});

View File

@@ -45,19 +45,19 @@ export class DefaultCipherEncryptionService implements CipherEncryptionService {
clientCipherView.login.fido2Credentials = fido2CredentialViews
.map((f) => {
const view = Fido2CredentialView.fromSdkFido2CredentialView(f);
// TEMPORARY: Manually decrypt the keyValue for Fido2 credentials since don't currently use
// the SDK for Fido2 Authentication.
const decryptedKeyValue = ref.value
.vault()
.ciphers()
.decrypt_fido2_private_key(sdkCipherView, f.keyValue);
if (view) {
// TEMPORARY: Manually decrypt the keyValue for Fido2 credentials since don't currently use
// the SDK for Fido2 Authentication.
const decryptedKeyValue = ref.value
.vault()
.ciphers()
.decrypt_key(sdkCipherView, view.keyValue);
view.keyValue = decryptedKeyValue;
}
const view = Fido2CredentialView.fromSdkFido2CredentialView(f)!;
return view;
return {
...view,
keyValue: decryptedKeyValue,
};
})
.filter((view): view is Fido2CredentialView => view !== undefined);
}