blob: 99319fb7fc0672a1f408db76b25e3fab885f3845 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
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;
}
|