summaryrefslogtreecommitdiffhomepage
path: root/packages/browser/src/methods/startAttestation.ts
diff options
context:
space:
mode:
authorMatthew Miller <matthew@millerti.me>2020-07-30 18:13:55 -0700
committerGitHub <noreply@github.com>2020-07-30 18:13:55 -0700
commit34752ae8633895626099ea9111fd4d551f516ab1 (patch)
tree09f0e72869a7f63954b6f813eb18db085eae5315 /packages/browser/src/methods/startAttestation.ts
parente9ef3215693225203920e39707cc6abeca25ae44 (diff)
parent92425fbfa00420d24b32901c4fc2b654f2005a52 (diff)
Merge pull request #42 from MasterKale/feature/better-challenges
feature/better-challenges
Diffstat (limited to 'packages/browser/src/methods/startAttestation.ts')
-rw-r--r--packages/browser/src/methods/startAttestation.ts9
1 files changed, 4 insertions, 5 deletions
diff --git a/packages/browser/src/methods/startAttestation.ts b/packages/browser/src/methods/startAttestation.ts
index d5e540f..b6faa83 100644
--- a/packages/browser/src/methods/startAttestation.ts
+++ b/packages/browser/src/methods/startAttestation.ts
@@ -6,6 +6,7 @@ import {
import toUint8Array from '../helpers/toUint8Array';
import bufferToBase64URLString from '../helpers/bufferToBase64URLString';
+import base64URLStringToBuffer from '../helpers/base64URLStringToBuffer';
import supportsWebauthn from '../helpers/supportsWebauthn';
import toPublicKeyCredentialDescriptor from '../helpers/toPublicKeyCredentialDescriptor';
@@ -24,18 +25,16 @@ export default async function startAttestation(
// We need to convert some values to Uint8Arrays before passing the credentials to the navigator
const publicKey: PublicKeyCredentialCreationOptions = {
...creationOptionsJSON,
- challenge: toUint8Array(creationOptionsJSON.challenge),
+ challenge: base64URLStringToBuffer(creationOptionsJSON.challenge),
user: {
...creationOptionsJSON.user,
id: toUint8Array(creationOptionsJSON.user.id),
},
- excludeCredentials: creationOptionsJSON.excludeCredentials.map(
- toPublicKeyCredentialDescriptor,
- ),
+ excludeCredentials: creationOptionsJSON.excludeCredentials.map(toPublicKeyCredentialDescriptor),
};
// Wait for the user to complete attestation
- const credential = await navigator.credentials.create({ publicKey }) as AttestationCredential;
+ const credential = (await navigator.credentials.create({ publicKey })) as AttestationCredential;
if (!credential) {
throw new Error('Attestation was not completed');