blob: e9693fae370d1ee76d62bae41312d361e60e9305 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
import { PublicKeyCredentialRequestOptionsJSON } from '@webauthntine/typescript-types';
/**
* Prepare a value to pass into navigator.credentials.get(...) for authenticator "login"
*
* @param challenge Random string the authenticator needs to sign and pass back
* @param base64CredentialIDs Array of base64-encoded authenticator IDs registered by the user for
* assertion
* @param timeout How long (in ms) the user can take to complete attestation
*/
export default function generateAssertionOptions(
challenge: string,
base64CredentialIDs: string[],
timeout: number = 60000,
): PublicKeyCredentialRequestOptionsJSON {
return {
publicKey: {
challenge,
allowCredentials: base64CredentialIDs.map(id => ({
id,
type: 'public-key',
transports: ['usb', 'ble', 'nfc'],
})),
timeout,
},
};
}
|