diff options
author | Matthew Miller <matthew@millerti.me> | 2023-08-22 10:13:03 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-22 10:13:03 -0700 |
commit | fefc95e4535e6ecf903f647124a492fba3fd11d6 (patch) | |
tree | 4c924d43d32fb12a780533302eaf5dee08875d75 /packages/server/src/authentication/generateAuthenticationOptions.ts | |
parent | 443c341bc2163f07b93a3ef84a43294d10b826f8 (diff) | |
parent | 2935857c76d458c26701842e500f8d97d17499c5 (diff) |
Merge pull request #425 from MasterKale/feat/server-esm-take-2-dnt
feat/server-esm-take-2-dnt
Diffstat (limited to 'packages/server/src/authentication/generateAuthenticationOptions.ts')
-rw-r--r-- | packages/server/src/authentication/generateAuthenticationOptions.ts | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/packages/server/src/authentication/generateAuthenticationOptions.ts b/packages/server/src/authentication/generateAuthenticationOptions.ts index a3ef250..b1c8166 100644 --- a/packages/server/src/authentication/generateAuthenticationOptions.ts +++ b/packages/server/src/authentication/generateAuthenticationOptions.ts @@ -1,12 +1,11 @@ import type { AuthenticationExtensionsClientInputs, - PublicKeyCredentialRequestOptionsJSON, PublicKeyCredentialDescriptorFuture, + PublicKeyCredentialRequestOptionsJSON, UserVerificationRequirement, -} from '@simplewebauthn/typescript-types'; - -import { isoBase64URL, isoUint8Array } from '../helpers/iso'; -import { generateChallenge } from '../helpers/generateChallenge'; +} from '../deps.ts'; +import { isoBase64URL, isoUint8Array } from '../helpers/iso/index.ts'; +import { generateChallenge } from '../helpers/generateChallenge.ts'; export type GenerateAuthenticationOptionsOpts = { allowCredentials?: PublicKeyCredentialDescriptorFuture[]; @@ -30,12 +29,12 @@ export type GenerateAuthenticationOptionsOpts = { * @param extensions Additional plugins the authenticator or browser should use during authentication * @param rpID Valid domain name (after `https://`) */ -export function generateAuthenticationOptions( +export async function generateAuthenticationOptions( options: GenerateAuthenticationOptionsOpts = {}, -): PublicKeyCredentialRequestOptionsJSON { +): Promise<PublicKeyCredentialRequestOptionsJSON> { const { allowCredentials, - challenge = generateChallenge(), + challenge = await generateChallenge(), timeout = 60000, userVerification = 'preferred', extensions, @@ -52,7 +51,7 @@ export function generateAuthenticationOptions( return { challenge: isoBase64URL.fromBuffer(_challenge), - allowCredentials: allowCredentials?.map(cred => ({ + allowCredentials: allowCredentials?.map((cred) => ({ ...cred, id: isoBase64URL.fromBuffer(cred.id as Uint8Array), })), |