1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 08:43:33 +00:00

[EC-598] feat: make fallback working again

This commit is contained in:
Andreas Coroiu
2023-04-05 16:28:46 +02:00
parent cd70b17b9a
commit 183af55491
3 changed files with 24 additions and 10 deletions

View File

@@ -147,7 +147,9 @@ export class BrowserFido2UserInterfaceSession implements Fido2UserInterfaceSessi
.subscribe((msg) => { .subscribe((msg) => {
if (msg.type === "AbortResponse") { if (msg.type === "AbortResponse") {
this.close(); this.close();
this.abortController.abort(UserRequestedFallbackAbortReason); this.abortController.abort(
msg.fallbackRequested ? UserRequestedFallbackAbortReason : undefined
);
} }
}); });

View File

@@ -79,14 +79,9 @@ export interface PublicKeyCredentialParam {
type: "public-key"; type: "public-key";
} }
export class Fido2Error extends Error { export class FallbackRequestedError extends Error {
constructor(message: string, readonly fallbackRequested = false) { readonly fallbackRequested = true;
super(message); constructor() {
} super("FallbackRequested");
}
export class RequestAbortedError extends Fido2Error {
constructor(fallbackRequested = false) {
super("Fido2 request was aborted", fallbackRequested);
} }
} }

View File

@@ -14,8 +14,10 @@ import {
AssertCredentialResult, AssertCredentialResult,
CreateCredentialParams, CreateCredentialParams,
CreateCredentialResult, CreateCredentialResult,
FallbackRequestedError,
Fido2ClientService as Fido2ClientServiceAbstraction, Fido2ClientService as Fido2ClientServiceAbstraction,
PublicKeyCredentialParam, PublicKeyCredentialParam,
UserRequestedFallbackAbortReason,
UserVerification, UserVerification,
} from "../abstractions/fido2-client.service.abstraction"; } from "../abstractions/fido2-client.service.abstraction";
import { Fido2Utils } from "../abstractions/fido2-utils"; import { Fido2Utils } from "../abstractions/fido2-utils";
@@ -116,12 +118,20 @@ export class Fido2ClientService implements Fido2ClientServiceAbstraction {
abortController abortController
); );
} catch (error) { } catch (error) {
if (
abortController.signal.aborted &&
abortController.signal.reason === UserRequestedFallbackAbortReason
) {
throw new FallbackRequestedError();
}
if ( if (
error instanceof Fido2AutenticatorError && error instanceof Fido2AutenticatorError &&
error.errorCode === Fido2AutenticatorErrorCode.InvalidState error.errorCode === Fido2AutenticatorErrorCode.InvalidState
) { ) {
throw new DOMException(undefined, "InvalidStateError"); throw new DOMException(undefined, "InvalidStateError");
} }
throw new DOMException(undefined, "NotAllowedError"); throw new DOMException(undefined, "NotAllowedError");
} }
@@ -198,6 +208,13 @@ export class Fido2ClientService implements Fido2ClientServiceAbstraction {
abortController abortController
); );
} catch (error) { } catch (error) {
if (
abortController.signal.aborted &&
abortController.signal.reason === UserRequestedFallbackAbortReason
) {
throw new FallbackRequestedError();
}
if ( if (
error instanceof Fido2AutenticatorError && error instanceof Fido2AutenticatorError &&
error.errorCode === Fido2AutenticatorErrorCode.InvalidState error.errorCode === Fido2AutenticatorErrorCode.InvalidState