diff --git a/libs/common/src/vault/services/cipher.service.ts b/libs/common/src/vault/services/cipher.service.ts index a34af32e23..1bc447cf28 100644 --- a/libs/common/src/vault/services/cipher.service.ts +++ b/libs/common/src/vault/services/cipher.service.ts @@ -1252,6 +1252,7 @@ export class CipherService implements CipherServiceAbstraction { cipher.fido2Key, { keyType: null, + keyAlgorithm: null, keyCurve: null, keyValue: null, rpId: null, diff --git a/libs/common/src/webauthn/models/api/fido2-key.api.ts b/libs/common/src/webauthn/models/api/fido2-key.api.ts index 0d5b1c2fa2..49f1ea48fe 100644 --- a/libs/common/src/webauthn/models/api/fido2-key.api.ts +++ b/libs/common/src/webauthn/models/api/fido2-key.api.ts @@ -22,7 +22,7 @@ export class Fido2KeyApi extends BaseResponse { this.nonDiscoverableId = this.getResponseProperty("NonDiscoverableId"); this.keyType = this.getResponseProperty("KeyType"); - this.keyAlgorithm = this.getResponseProperty("KeyType"); + this.keyAlgorithm = this.getResponseProperty("KeyAlgorithm"); this.keyCurve = this.getResponseProperty("KeyCurve"); this.keyValue = this.getResponseProperty("keyValue"); this.rpId = this.getResponseProperty("RpId"); diff --git a/libs/common/src/webauthn/services/fido2-authenticator.service.spec.ts b/libs/common/src/webauthn/services/fido2-authenticator.service.spec.ts index 79b52a45de..4dbf5f44cc 100644 --- a/libs/common/src/webauthn/services/fido2-authenticator.service.spec.ts +++ b/libs/common/src/webauthn/services/fido2-authenticator.service.spec.ts @@ -254,7 +254,7 @@ describe("FidoAuthenticatorService", () => { expect(userInterface.confirmNewCredential).toHaveBeenCalledWith({ credentialName: params.rpEntity.name, - userName: params.userEntity.name, + userName: params.userEntity.displayName, } as NewCredentialParams); }); @@ -284,7 +284,7 @@ describe("FidoAuthenticatorService", () => { rpName: params.rpEntity.name, userHandle: Fido2Utils.bufferToString(params.userEntity.id), counter: 0, - userName: params.userEntity.name, + userName: params.userEntity.displayName, }), }) ); @@ -337,7 +337,7 @@ describe("FidoAuthenticatorService", () => { expect(userInterface.confirmNewNonDiscoverableCredential).toHaveBeenCalledWith({ credentialName: params.rpEntity.name, - userName: params.userEntity.name, + userName: params.userEntity.displayName, } as NewCredentialParams); }); @@ -363,7 +363,7 @@ describe("FidoAuthenticatorService", () => { rpName: params.rpEntity.name, userHandle: Fido2Utils.bufferToString(params.userEntity.id), counter: 0, - userName: params.userEntity.name, + userName: params.userEntity.displayName, }), }) ); diff --git a/libs/common/src/webauthn/services/fido2-authenticator.service.ts b/libs/common/src/webauthn/services/fido2-authenticator.service.ts index e61fcd9cb5..3b89b8e9e8 100644 --- a/libs/common/src/webauthn/services/fido2-authenticator.service.ts +++ b/libs/common/src/webauthn/services/fido2-authenticator.service.ts @@ -65,7 +65,7 @@ export class Fido2AuthenticatorService implements Fido2AuthenticatorServiceAbstr [Utils.guidToStandardFormat(params.excludeCredentialDescriptorList[0].id)], { credentialName: params.rpEntity.name, - userName: params.userEntity.name, + userName: params.userEntity.displayName, } ); @@ -77,7 +77,7 @@ export class Fido2AuthenticatorService implements Fido2AuthenticatorServiceAbstr if (params.requireResidentKey) { const userVerification = await this.userInterface.confirmNewCredential({ credentialName: params.rpEntity.name, - userName: params.userEntity.name, + userName: params.userEntity.displayName, }); if (!userVerification) { @@ -100,7 +100,7 @@ export class Fido2AuthenticatorService implements Fido2AuthenticatorServiceAbstr } else { const cipherId = await this.userInterface.confirmNewNonDiscoverableCredential({ credentialName: params.rpEntity.name, - userName: params.userEntity.name, + userName: params.userEntity.displayName, }); if (cipherId === undefined) { @@ -191,7 +191,11 @@ export class Fido2AuthenticatorService implements Fido2AuthenticatorServiceAbstr : selectedCipher.id; ++selectedCipher.fido2Key.counter; - selectedCipher.localData.lastUsedDate = new Date().getTime(); + + selectedCipher.localData = { + ...selectedCipher.localData, + lastUsedDate: new Date().getTime(), + }; const encrypted = await this.cipherService.encrypt(selectedCipher); await this.cipherService.updateWithServer(encrypted); @@ -268,6 +272,7 @@ export class Fido2AuthenticatorService implements Fido2AuthenticatorServiceAbstr const ciphers = await this.cipherService.getAllDecrypted(); return ciphers.filter( (cipher) => + !cipher.isDeleted && cipher.type === CipherType.Login && cipher.fido2Key != undefined && cipher.fido2Key.rpId === rpId && @@ -278,7 +283,8 @@ export class Fido2AuthenticatorService implements Fido2AuthenticatorServiceAbstr private async findDiscoverableCredentials(rpId: string): Promise { const ciphers = await this.cipherService.getAllDecrypted(); return ciphers.filter( - (cipher) => cipher.type === CipherType.Fido2Key && cipher.fido2Key.rpId === rpId + (cipher) => + !cipher.isDeleted && cipher.type === CipherType.Fido2Key && cipher.fido2Key.rpId === rpId ); } } @@ -313,7 +319,7 @@ async function createKeyView( fido2Key.userHandle = Fido2Utils.bufferToString(params.userEntity.id); fido2Key.counter = 0; fido2Key.rpName = params.rpEntity.name; - fido2Key.userName = params.userEntity.name; + fido2Key.userName = params.userEntity.displayName; return fido2Key; } @@ -324,7 +330,7 @@ async function getPrivateKeyFromCipher(cipher: CipherView): Promise { "pkcs8", keyBuffer, { - name: cipher.fido2Key.keyType, + name: cipher.fido2Key.keyAlgorithm, namedCurve: cipher.fido2Key.keyCurve, } as EcKeyImportParams, true,