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:
parent
cd70b17b9a
commit
183af55491
@ -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
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user