1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-16 10:45:20 +01: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
No known key found for this signature in database
GPG Key ID: E70B5FFC81DFEC1A
3 changed files with 24 additions and 10 deletions

View File

@ -147,7 +147,9 @@ export class BrowserFido2UserInterfaceSession implements Fido2UserInterfaceSessi
.subscribe((msg) => {
if (msg.type === "AbortResponse") {
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";
}
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");
}
}

View File

@ -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