diff options
author | Matthew Miller <matthew@millerti.me> | 2020-05-25 23:27:37 -0700 |
---|---|---|
committer | Matthew Miller <matthew@millerti.me> | 2020-05-25 23:27:37 -0700 |
commit | f910f057457108003bcc39378fb5ad94529c6bad (patch) | |
tree | 9a6064a5a490aecece233c8f845d80c21618de36 /packages/browser/src/methods/startAssertion.ts | |
parent | 916087c78ff525fbdf3a37e13c40276a3cf2d703 (diff) |
Add toPublicKeyCredentialDescriptor browser helper
Diffstat (limited to 'packages/browser/src/methods/startAssertion.ts')
-rw-r--r-- | packages/browser/src/methods/startAssertion.ts | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/packages/browser/src/methods/startAssertion.ts b/packages/browser/src/methods/startAssertion.ts index f504f19..826763a 100644 --- a/packages/browser/src/methods/startAssertion.ts +++ b/packages/browser/src/methods/startAssertion.ts @@ -3,11 +3,11 @@ import { AuthenticatorAssertionResponseJSON, AssertionCredential, } from '@webauthntine/typescript-types'; -import base64js from 'base64-js'; import toUint8Array from '../helpers/toUint8Array'; import toBase64String from '../helpers/toBase64String'; import supportsWebauthn from '../helpers/supportsWebauthn'; +import toPublicKeyCredentialDescriptor from '../helpers/toPublicKeyCredentialDescriptor'; /** * Begin authenticator "login" via WebAuthn assertion @@ -25,16 +25,9 @@ export default async function startAssertion( const publicKey: PublicKeyCredentialRequestOptions = { ...requestOptionsJSON.publicKey, challenge: toUint8Array(requestOptionsJSON.publicKey.challenge), - allowCredentials: requestOptionsJSON.publicKey.allowCredentials.map(cred => { - // Make sure the credential ID length is a multiple of 4 - const padLength = 4 - (cred.id.length % 4); - const id = cred.id.padEnd(cred.id.length + padLength, '='); - - return { - ...cred, - id: base64js.toByteArray(id), - }; - }), + allowCredentials: requestOptionsJSON.publicKey.allowCredentials.map( + toPublicKeyCredentialDescriptor, + ), }; // Wait for the user to complete assertion |