diff --git a/libs/common/src/auth/login-strategies/webauthn-login.strategy.spec.ts b/libs/common/src/auth/login-strategies/webauthn-login.strategy.spec.ts index 83de3b5d6a3..5f7c8de0254 100644 --- a/libs/common/src/auth/login-strategies/webauthn-login.strategy.spec.ts +++ b/libs/common/src/auth/login-strategies/webauthn-login.strategy.spec.ts @@ -179,7 +179,11 @@ describe("WebAuthnLoginStrategy", () => { // Act await webAuthnLoginStrategy.logIn(webAuthnCredentials); - // // Assert + // Assert + // Master key encrypted user key should be set + expect(cryptoService.setMasterKeyEncryptedUserKey).toHaveBeenCalledTimes(1); + expect(cryptoService.setMasterKeyEncryptedUserKey).toHaveBeenCalledWith(idTokenResponse.key); + expect(cryptoService.decryptToBytes).toHaveBeenCalledTimes(1); expect(cryptoService.decryptToBytes).toHaveBeenCalledWith( idTokenResponse.userDecryptionOptions.webAuthnPrfOption.encryptedPrivateKey, diff --git a/libs/common/src/auth/login-strategies/webauthn-login.strategy.ts b/libs/common/src/auth/login-strategies/webauthn-login.strategy.ts index 8d47be0197c..3c8a3cf73cb 100644 --- a/libs/common/src/auth/login-strategies/webauthn-login.strategy.ts +++ b/libs/common/src/auth/login-strategies/webauthn-login.strategy.ts @@ -15,6 +15,13 @@ export class WebAuthnLoginStrategy extends LoginStrategy { } protected override async setUserKey(idTokenResponse: IdentityTokenResponse) { + const masterKeyEncryptedUserKey = idTokenResponse.key; + + if (masterKeyEncryptedUserKey) { + // set the master key encrypted user key if it exists + await this.cryptoService.setMasterKeyEncryptedUserKey(masterKeyEncryptedUserKey); + } + const userDecryptionOptions = idTokenResponse?.userDecryptionOptions; if (userDecryptionOptions?.webAuthnPrfOption) {