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:
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user