mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 16:23:44 +00:00
[EC-598] feat: make fallback working again
This commit is contained in:
@@ -79,14 +79,9 @@ export interface PublicKeyCredentialParam {
|
||||
type: "public-key";
|
||||
}
|
||||
|
||||
export class Fido2Error extends Error {
|
||||
constructor(message: string, readonly fallbackRequested = false) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
||||
export class RequestAbortedError extends Fido2Error {
|
||||
constructor(fallbackRequested = false) {
|
||||
super("Fido2 request was aborted", fallbackRequested);
|
||||
export class FallbackRequestedError extends Error {
|
||||
readonly fallbackRequested = true;
|
||||
constructor() {
|
||||
super("FallbackRequested");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,8 +14,10 @@ import {
|
||||
AssertCredentialResult,
|
||||
CreateCredentialParams,
|
||||
CreateCredentialResult,
|
||||
FallbackRequestedError,
|
||||
Fido2ClientService as Fido2ClientServiceAbstraction,
|
||||
PublicKeyCredentialParam,
|
||||
UserRequestedFallbackAbortReason,
|
||||
UserVerification,
|
||||
} from "../abstractions/fido2-client.service.abstraction";
|
||||
import { Fido2Utils } from "../abstractions/fido2-utils";
|
||||
@@ -116,12 +118,20 @@ export class Fido2ClientService implements Fido2ClientServiceAbstraction {
|
||||
abortController
|
||||
);
|
||||
} catch (error) {
|
||||
if (
|
||||
abortController.signal.aborted &&
|
||||
abortController.signal.reason === UserRequestedFallbackAbortReason
|
||||
) {
|
||||
throw new FallbackRequestedError();
|
||||
}
|
||||
|
||||
if (
|
||||
error instanceof Fido2AutenticatorError &&
|
||||
error.errorCode === Fido2AutenticatorErrorCode.InvalidState
|
||||
) {
|
||||
throw new DOMException(undefined, "InvalidStateError");
|
||||
}
|
||||
|
||||
throw new DOMException(undefined, "NotAllowedError");
|
||||
}
|
||||
|
||||
@@ -198,6 +208,13 @@ export class Fido2ClientService implements Fido2ClientServiceAbstraction {
|
||||
abortController
|
||||
);
|
||||
} catch (error) {
|
||||
if (
|
||||
abortController.signal.aborted &&
|
||||
abortController.signal.reason === UserRequestedFallbackAbortReason
|
||||
) {
|
||||
throw new FallbackRequestedError();
|
||||
}
|
||||
|
||||
if (
|
||||
error instanceof Fido2AutenticatorError &&
|
||||
error.errorCode === Fido2AutenticatorErrorCode.InvalidState
|
||||
|
||||
Reference in New Issue
Block a user