1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-02 09:43:29 +00:00
This commit is contained in:
Bernd Schoolmann
2025-11-17 16:31:47 +01:00
parent 7de0b915b6
commit 4a4c9ade0f
2 changed files with 8 additions and 4 deletions

View File

@@ -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");

View File

@@ -23,7 +23,7 @@ export class WebAuthnLoginService implements WebAuthnLoginServiceAbstraction {
protected webAuthnLoginPrfKeyService: WebAuthnLoginPrfKeyServiceAbstraction,
protected navigatorCredentialsService: NavigatorCredentialsService,
protected logService?: LogService,
) {}
) { }
async getCredentialAssertionOptions(): Promise<WebAuthnLoginCredentialAssertionOptionsView> {
const response = await this.webAuthnLoginApiService.getCredentialAssertionOptions();
@@ -32,7 +32,7 @@ export class WebAuthnLoginService implements WebAuthnLoginServiceAbstraction {
async assertCredential(
credentialAssertionOptions: WebAuthnLoginCredentialAssertionOptionsView,
): Promise<WebAuthnLoginCredentialAssertionView> {
): Promise<WebAuthnLoginCredentialAssertionView | undefined> {
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;