diff options
author | Matthew Miller <matthew@millerti.me> | 2022-12-27 19:21:46 -0800 |
---|---|---|
committer | Matthew Miller <matthew@millerti.me> | 2022-12-27 19:21:46 -0800 |
commit | 3170379c67a9cf33374d9f9ab89dafed16ba7edf (patch) | |
tree | 9bcbfcce2a3c1e24b2ee524e88f6c3416eae56a6 /packages/browser/src/helpers | |
parent | 0571dbea85f539b350e853e716ba5489c49646c5 (diff) |
Update startRegistration to use new values
Diffstat (limited to 'packages/browser/src/helpers')
-rw-r--r-- | packages/browser/src/helpers/toAuthenticatorAttachment.ts | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/packages/browser/src/helpers/toAuthenticatorAttachment.ts b/packages/browser/src/helpers/toAuthenticatorAttachment.ts new file mode 100644 index 0000000..7a2aca0 --- /dev/null +++ b/packages/browser/src/helpers/toAuthenticatorAttachment.ts @@ -0,0 +1,18 @@ +import { AuthenticatorAttachment } from '@simplewebauthn/typescript-types'; + +const attachments: AuthenticatorAttachment[] = ['cross-platform', 'platform']; + +/** + * If possible coerce a `string` value into a known `AuthenticatorAttachment` + */ +export function toAuthenticatorAttachment(attachment: string | null): AuthenticatorAttachment | undefined { + if (!attachment) { + return; + } + + if (attachments.indexOf(attachment as AuthenticatorAttachment) < 0) { + return; + } + + return attachment as AuthenticatorAttachment; +} |