mirror of
https://github.com/bitwarden/browser
synced 2026-02-02 09:43:29 +00:00
Fix test
This commit is contained in:
@@ -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");
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user