diff options
Diffstat (limited to 'packages/browser/src/helpers')
-rw-r--r-- | packages/browser/src/helpers/identifyRegistrationError.ts | 8 | ||||
-rw-r--r-- | packages/browser/src/helpers/structs.ts | 23 |
2 files changed, 24 insertions, 7 deletions
diff --git a/packages/browser/src/helpers/identifyRegistrationError.ts b/packages/browser/src/helpers/identifyRegistrationError.ts index 4779f1a..8da0c97 100644 --- a/packages/browser/src/helpers/identifyRegistrationError.ts +++ b/packages/browser/src/helpers/identifyRegistrationError.ts @@ -1,4 +1,5 @@ import { isValidDomain } from './isValidDomain'; +import { WebAuthnError } from './structs'; export function identifyRegistrationError({ error, options }: { error: Error, @@ -73,10 +74,3 @@ export function identifyRegistrationError({ error, options }: { return error; } - -class WebAuthnError extends Error { - constructor(message: string) { - super(message); - this.name = 'WebAuthnError'; - } -} diff --git a/packages/browser/src/helpers/structs.ts b/packages/browser/src/helpers/structs.ts new file mode 100644 index 0000000..66b6d63 --- /dev/null +++ b/packages/browser/src/helpers/structs.ts @@ -0,0 +1,23 @@ +/** + * A custom Error used to return a more nuanced error detailing _why_ one of the eight documented + * errors in the spec was raised after calling `navigator.credentials.create()` or + * `navigator.credentials.get()`: + * + * - `AbortError` + * - `ConstraintError` + * - `InvalidStateError` + * - `NotAllowedError` + * - `NotSupportedError` + * - `SecurityError` + * - `TypeError` + * - `UnknownError` + * + * Error messages were determined through investigation of the spec to determine under which + * scenarios a given error would be raised. + */ +export class WebAuthnError extends Error { + constructor(message: string) { + super(message); + this.name = 'WebAuthnError'; + } +} |