Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions app/javascript/packages/webauthn/is-expected-error.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
/**
* Set of expected DOM exceptions, which occur based on some user behavior that is not noteworthy,
* such as declining permissions or timeout due to inactivity.
* Set of expected DOM exceptions, which occur based on some user behavior that is not noteworthy:
*
* - Declining permissions
* - Timeout due to inactivity
* - Invalid state such as duplicate key enrollment
*
* @see https://webidl.spec.whatwg.org/#idl-DOMException
*/
const EXPECTED_DOM_EXCEPTIONS: Set<string> = new Set(['NotAllowedError', 'TimeoutError']);
const EXPECTED_DOM_EXCEPTIONS: Set<string> = new Set([
'NotAllowedError',
'TimeoutError',
'InvalidStateError',
]);

const isExpectedWebauthnError = (error: Error): boolean =>
error instanceof DOMException && EXPECTED_DOM_EXCEPTIONS.has(error.name);
Expand Down