diff options
Diffstat (limited to 'packages/server/src')
-rw-r--r-- | packages/server/src/assertion/generateAssertionOptions.ts | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/packages/server/src/assertion/generateAssertionOptions.ts b/packages/server/src/assertion/generateAssertionOptions.ts index ac18233..8a242dc 100644 --- a/packages/server/src/assertion/generateAssertionOptions.ts +++ b/packages/server/src/assertion/generateAssertionOptions.ts @@ -1,25 +1,29 @@ -import { PublicKeyCredentialRequestOptionsJSON } from '@webauthntine/typescript-types'; +import type { + 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 allowedBase64CredentialIDs Array of base64-encoded authenticator IDs registered by the + * user for assertion * @param timeout How long (in ms) the user can take to complete assertion + * @param suggestedTransports Suggested types of authenticators for assertion */ export default function generateAssertionOptions( challenge: string, - base64CredentialIDs: string[], + allowedBase64CredentialIDs: string[], timeout = 60000, + suggestedTransports: AuthenticatorTransport[] = ['usb', 'ble', 'nfc', 'internal'], ): PublicKeyCredentialRequestOptionsJSON { return { publicKey: { challenge, - allowCredentials: base64CredentialIDs.map(id => ({ + allowCredentials: allowedBase64CredentialIDs.map(id => ({ id, type: 'public-key', - transports: ['usb', 'ble', 'nfc', 'internal'], + transports: suggestedTransports, })), timeout, }, |