diff --git a/libs/common/src/auth/services/webauthn-login/webauthn-login.service.spec.ts b/libs/common/src/auth/services/webauthn-login/webauthn-login.service.spec.ts index b1e3372bd4d..37782b77186 100644 --- a/libs/common/src/auth/services/webauthn-login/webauthn-login.service.spec.ts +++ b/libs/common/src/auth/services/webauthn-login/webauthn-login.service.spec.ts @@ -210,7 +210,7 @@ describe("WebAuthnLoginService", () => { const credentialAssertionOptions = buildCredentialAssertionOptions(); // Mock the navigatorCredentials.get to return null - navigatorCredentials.get.mockResolvedValue(null); + mockNavigatorCredentialsService.get.mockResolvedValue(null); // Act const result = await webAuthnLoginService.assertCredential(credentialAssertionOptions); @@ -226,7 +226,7 @@ describe("WebAuthnLoginService", () => { // Mock navigatorCredentials.get to throw an error const errorMessage = "Simulated error"; - navigatorCredentials.get.mockRejectedValue(new Error(errorMessage)); + mockNavigatorCredentialsService.get.mockRejectedValue(new Error(errorMessage)); // Spy on logService.error const logServiceErrorSpy = jest.spyOn(logService, "error"); diff --git a/libs/common/src/auth/services/webauthn-login/webauthn-login.service.ts b/libs/common/src/auth/services/webauthn-login/webauthn-login.service.ts index 2a357b32eab..5d1db037c3b 100644 --- a/libs/common/src/auth/services/webauthn-login/webauthn-login.service.ts +++ b/libs/common/src/auth/services/webauthn-login/webauthn-login.service.ts @@ -23,7 +23,7 @@ export class WebAuthnLoginService implements WebAuthnLoginServiceAbstraction { protected webAuthnLoginPrfKeyService: WebAuthnLoginPrfKeyServiceAbstraction, protected navigatorCredentialsService: NavigatorCredentialsService, protected logService?: LogService, - ) {} + ) { } async getCredentialAssertionOptions(): Promise { const response = await this.webAuthnLoginApiService.getCredentialAssertionOptions(); @@ -32,7 +32,7 @@ export class WebAuthnLoginService implements WebAuthnLoginServiceAbstraction { async assertCredential( credentialAssertionOptions: WebAuthnLoginCredentialAssertionOptionsView, - ): Promise { + ): Promise { const nativeOptions: CredentialRequestOptions = { publicKey: credentialAssertionOptions.options, }; @@ -43,6 +43,10 @@ export class WebAuthnLoginService implements WebAuthnLoginServiceAbstraction { try { const response = await this.navigatorCredentialsService.get(nativeOptions); + if (response == null) { + return undefined; + } + // TODO: Remove `any` when typescript typings add support for PRF const prfResult = response.prf; let symmetricPrfKey: PrfKey | undefined;