diff options
author | Matthew Miller <matthew@millerti.me> | 2024-04-12 13:34:15 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-12 13:34:15 -0700 |
commit | b2a6e96005660431dc4598eb5d717802b6c238e3 (patch) | |
tree | daf7b0e5316703898d7621e4da52e7dfabde6802 /packages/browser/src/methods/startRegistration.ts | |
parent | fe90e2765b2bfab2405ef2875c9c98d39d66416e (diff) | |
parent | b316c3f6de77824680c8e153e9124aeaf9c10d4f (diff) |
Merge pull request #552 from MasterKale/feat/530-remove-user-id-footgun
feat/530-remove-user-id-footgun
Diffstat (limited to 'packages/browser/src/methods/startRegistration.ts')
-rw-r--r-- | packages/browser/src/methods/startRegistration.ts | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/packages/browser/src/methods/startRegistration.ts b/packages/browser/src/methods/startRegistration.ts index 09117c3..b661de7 100644 --- a/packages/browser/src/methods/startRegistration.ts +++ b/packages/browser/src/methods/startRegistration.ts @@ -5,7 +5,6 @@ import { RegistrationResponseJSON, } from '@simplewebauthn/types'; -import { utf8StringToBuffer } from '../helpers/utf8StringToBuffer'; import { bufferToBase64URLString } from '../helpers/bufferToBase64URLString'; import { base64URLStringToBuffer } from '../helpers/base64URLStringToBuffer'; import { browserSupportsWebAuthn } from '../helpers/browserSupportsWebAuthn'; @@ -17,10 +16,10 @@ import { toAuthenticatorAttachment } from '../helpers/toAuthenticatorAttachment' /** * Begin authenticator "registration" via WebAuthn attestation * - * @param creationOptionsJSON Output from **@simplewebauthn/server**'s `generateRegistrationOptions()` + * @param optionsJSON Output from **@simplewebauthn/server**'s `generateRegistrationOptions()` */ export async function startRegistration( - creationOptionsJSON: PublicKeyCredentialCreationOptionsJSON, + optionsJSON: PublicKeyCredentialCreationOptionsJSON, ): Promise<RegistrationResponseJSON> { if (!browserSupportsWebAuthn()) { throw new Error('WebAuthn is not supported in this browser'); @@ -28,13 +27,13 @@ export async function startRegistration( // We need to convert some values to Uint8Arrays before passing the credentials to the navigator const publicKey: PublicKeyCredentialCreationOptions = { - ...creationOptionsJSON, - challenge: base64URLStringToBuffer(creationOptionsJSON.challenge), + ...optionsJSON, + challenge: base64URLStringToBuffer(optionsJSON.challenge), user: { - ...creationOptionsJSON.user, - id: utf8StringToBuffer(creationOptionsJSON.user.id), + ...optionsJSON.user, + id: base64URLStringToBuffer(optionsJSON.user.id), }, - excludeCredentials: creationOptionsJSON.excludeCredentials?.map( + excludeCredentials: optionsJSON.excludeCredentials?.map( toPublicKeyCredentialDescriptor, ), }; |