summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--packages/browser/src/helpers/identifyAuthenticationError.ts8
-rw-r--r--packages/browser/src/helpers/identifyRegistrationError.ts20
2 files changed, 14 insertions, 14 deletions
diff --git a/packages/browser/src/helpers/identifyAuthenticationError.ts b/packages/browser/src/helpers/identifyAuthenticationError.ts
index 4c0cfe2..d5ba5fa 100644
--- a/packages/browser/src/helpers/identifyAuthenticationError.ts
+++ b/packages/browser/src/helpers/identifyAuthenticationError.ts
@@ -20,7 +20,7 @@ export function identifyAuthenticationError({
if (error.name === 'AbortError') {
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');
+ return new WebAuthnError('Authentication ceremony was sent an abort signal', error);
}
} else if (error.name === 'NotAllowedError') {
/**
@@ -31,12 +31,12 @@ export function identifyAuthenticationError({
const effectiveDomain = window.location.hostname;
if (!isValidDomain(effectiveDomain)) {
// https://www.w3.org/TR/webauthn-2/#sctn-discover-from-external-source (Step 5)
- return new WebAuthnError(`${window.location.hostname} is an invalid domain`, 'SecurityError');
+ return new WebAuthnError(`${window.location.hostname} is an invalid domain`, error);
} 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',
+ error,
);
}
} else if (error.name === 'UnknownError') {
@@ -44,7 +44,7 @@ export function identifyAuthenticationError({
// 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',
+ error,
);
}
diff --git a/packages/browser/src/helpers/identifyRegistrationError.ts b/packages/browser/src/helpers/identifyRegistrationError.ts
index 6134227..57bfe51 100644
--- a/packages/browser/src/helpers/identifyRegistrationError.ts
+++ b/packages/browser/src/helpers/identifyRegistrationError.ts
@@ -20,26 +20,26 @@ export function identifyRegistrationError({
if (error.name === 'AbortError') {
if (options.signal === new AbortController().signal) {
// https://www.w3.org/TR/webauthn-2/#sctn-createCredential (Step 16)
- return new WebAuthnError('Registration ceremony was sent an abort signal', 'AbortError');
+ return new WebAuthnError('Registration ceremony was sent an abort signal', error);
}
} else if (error.name === 'ConstraintError') {
if (publicKey.authenticatorSelection?.requireResidentKey === true) {
// https://www.w3.org/TR/webauthn-2/#sctn-op-make-cred (Step 4)
return new WebAuthnError(
'Discoverable credentials were required but no available authenticator supported it',
- 'ConstraintError',
+ error,
);
} else if (publicKey.authenticatorSelection?.userVerification === 'required') {
// https://www.w3.org/TR/webauthn-2/#sctn-op-make-cred (Step 5)
return new WebAuthnError(
'User verification was required but no available authenticator supported it',
- 'ConstraintError',
+ error,
);
}
} else if (error.name === 'InvalidStateError') {
// https://www.w3.org/TR/webauthn-2/#sctn-createCredential (Step 20)
// https://www.w3.org/TR/webauthn-2/#sctn-op-make-cred (Step 3)
- return new WebAuthnError('The authenticator was previously registered', 'InvalidStateError');
+ return new WebAuthnError('The authenticator was previously registered', error);
} else if (error.name === 'NotAllowedError') {
/**
* Pass the error directly through. Platforms are overloading this error beyond what the spec
@@ -54,38 +54,38 @@ export function identifyRegistrationError({
// https://www.w3.org/TR/webauthn-2/#sctn-createCredential (Step 10)
return new WebAuthnError(
'No entry in pubKeyCredParams was of type "public-key"',
- 'NotSupportedError',
+ error,
);
}
// https://www.w3.org/TR/webauthn-2/#sctn-op-make-cred (Step 2)
return new WebAuthnError(
'No available authenticator supported any of the specified pubKeyCredParams algorithms',
- 'NotSupportedError',
+ error,
);
} else if (error.name === 'SecurityError') {
const effectiveDomain = window.location.hostname;
if (!isValidDomain(effectiveDomain)) {
// https://www.w3.org/TR/webauthn-2/#sctn-createCredential (Step 7)
- return new WebAuthnError(`${window.location.hostname} is an invalid domain`, 'SecurityError');
+ return new WebAuthnError(`${window.location.hostname} is an invalid domain`, error);
} else if (publicKey.rp.id !== effectiveDomain) {
// https://www.w3.org/TR/webauthn-2/#sctn-createCredential (Step 8)
return new WebAuthnError(
`The RP ID "${publicKey.rp.id}" is invalid for this domain`,
- 'SecurityError',
+ error,
);
}
} else if (error.name === 'TypeError') {
if (publicKey.user.id.byteLength < 1 || publicKey.user.id.byteLength > 64) {
// https://www.w3.org/TR/webauthn-2/#sctn-createCredential (Step 5)
- return new WebAuthnError('User ID was not between 1 and 64 characters', 'TypeError');
+ return new WebAuthnError('User ID was not between 1 and 64 characters', error);
}
} else if (error.name === 'UnknownError') {
// https://www.w3.org/TR/webauthn-2/#sctn-op-make-cred (Step 1)
// https://www.w3.org/TR/webauthn-2/#sctn-op-make-cred (Step 8)
return new WebAuthnError(
'The authenticator was unable to process the specified options, or could not create a new credential',
- 'UnknownError',
+ error,
);
}