summaryrefslogtreecommitdiffhomepage
path: root/packages/browser/src/helpers/identifyAuthenticationError.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/browser/src/helpers/identifyAuthenticationError.ts')
-rw-r--r--packages/browser/src/helpers/identifyAuthenticationError.ts19
1 files changed, 11 insertions, 8 deletions
diff --git a/packages/browser/src/helpers/identifyAuthenticationError.ts b/packages/browser/src/helpers/identifyAuthenticationError.ts
index bf88628..7f9bd82 100644
--- a/packages/browser/src/helpers/identifyAuthenticationError.ts
+++ b/packages/browser/src/helpers/identifyAuthenticationError.ts
@@ -1,7 +1,6 @@
import { isValidDomain } from './isValidDomain';
import { WebAuthnError } from './structs';
-
/**
* Attempt to intuit _why_ an error was raised after calling `navigator.credentials.get()`
*/
@@ -9,8 +8,8 @@ export function identifyAuthenticationError({
error,
options,
}: {
- error: Error,
- options: CredentialRequestOptions,
+ error: Error;
+ options: CredentialRequestOptions;
}): WebAuthnError | Error {
const { publicKey } = options;
@@ -19,7 +18,7 @@ export function identifyAuthenticationError({
}
if (error.name === 'AbortError') {
- if (options.signal === (new AbortController()).signal) {
+ if (options.signal === new AbortController().signal) {
// https://www.w3.org/TR/webauthn-2/#sctn-createCredential (Step 16)
return new WebAuthnError('Authentication ceremony was sent an abort signal (AbortError)');
}
@@ -28,13 +27,15 @@ export function identifyAuthenticationError({
// https://www.w3.org/TR/webauthn-2/#sctn-discover-from-external-source (Step 17)
// https://www.w3.org/TR/webauthn-2/#sctn-op-get-assertion (Step 6)
return new WebAuthnError(
- 'No available authenticator recognized any of the allowed credentials (NotAllowedError)'
+ 'No available authenticator recognized any of the allowed credentials (NotAllowedError)',
);
}
// https://www.w3.org/TR/webauthn-2/#sctn-discover-from-external-source (Step 18)
// https://www.w3.org/TR/webauthn-2/#sctn-op-get-assertion (Step 7)
- return new WebAuthnError('User clicked cancel, or the authentication ceremony timed out (NotAllowedError)');
+ return new WebAuthnError(
+ 'User clicked cancel, or the authentication ceremony timed out (NotAllowedError)',
+ );
} else if (error.name === 'SecurityError') {
const effectiveDomain = window.location.hostname;
if (!isValidDomain(effectiveDomain)) {
@@ -42,13 +43,15 @@ export function identifyAuthenticationError({
return new WebAuthnError(`${window.location.hostname} is an invalid domain (SecurityError)`);
} else if (publicKey.rpId !== effectiveDomain) {
// https://www.w3.org/TR/webauthn-2/#sctn-discover-from-external-source (Step 6)
- return new WebAuthnError(`The RP ID "${publicKey.rpId}" is invalid for this domain (SecurityError)`);
+ return new WebAuthnError(
+ `The RP ID "${publicKey.rpId}" is invalid for this domain (SecurityError)`,
+ );
}
} else if (error.name === 'UnknownError') {
// https://www.w3.org/TR/webauthn-2/#sctn-op-get-assertion (Step 1)
// https://www.w3.org/TR/webauthn-2/#sctn-op-get-assertion (Step 12)
return new WebAuthnError(
- 'The authenticator was unable to process the specified options, or could not create a new assertion signature (UnknownError)'
+ 'The authenticator was unable to process the specified options, or could not create a new assertion signature (UnknownError)',
);
}