From b86d25cc465f0ad0c28d320e31bafdb0fa5a9833 Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Fri, 4 Mar 2022 22:33:42 -0800 Subject: Move WebAuthnError into structs for sharing --- packages/browser/src/helpers/structs.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 packages/browser/src/helpers/structs.ts (limited to 'packages/browser/src/helpers/structs.ts') 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'; + } +} -- cgit v1.2.3