diff options
author | Matthew Miller <matthew@millerti.me> | 2022-12-27 19:36:52 -0800 |
---|---|---|
committer | Matthew Miller <matthew@millerti.me> | 2022-12-27 19:36:52 -0800 |
commit | c689929d95c09e0c668bb61d6d96110bdffe4120 (patch) | |
tree | 2ad0bc004e7b2817fd9dfaca70b5358858f21ab4 /packages/browser/src/methods/startRegistration.ts | |
parent | 468c8ce2f13105fd7e31d84cb41c7bbb07aa9ec9 (diff) |
Revert use of new APIs in browser methods
Diffstat (limited to 'packages/browser/src/methods/startRegistration.ts')
-rw-r--r-- | packages/browser/src/methods/startRegistration.ts | 32 |
1 files changed, 9 insertions, 23 deletions
diff --git a/packages/browser/src/methods/startRegistration.ts b/packages/browser/src/methods/startRegistration.ts index 14419ca..2218725 100644 --- a/packages/browser/src/methods/startRegistration.ts +++ b/packages/browser/src/methods/startRegistration.ts @@ -2,7 +2,6 @@ import { PublicKeyCredentialCreationOptionsJSON, RegistrationCredential, RegistrationResponseJSON, - PublicKeyCredentialFuture, } from '@simplewebauthn/typescript-types'; import { utf8StringToBuffer } from '../helpers/utf8StringToBuffer'; @@ -26,24 +25,16 @@ export async function startRegistration( throw new Error('WebAuthn is not supported in this browser'); } - const globalPublicKeyCredential = - window.PublicKeyCredential as unknown as PublicKeyCredentialFuture; - - let publicKey: PublicKeyCredentialCreationOptions; // We need to convert some values to Uint8Arrays before passing the credentials to the navigator - if (typeof globalPublicKeyCredential.parseCreationOptionsFromJSON === 'function') { - publicKey = globalPublicKeyCredential.parseCreationOptionsFromJSON(creationOptionsJSON); - } else { - publicKey = { - ...creationOptionsJSON, - challenge: base64URLStringToBuffer(creationOptionsJSON.challenge), - user: { - ...creationOptionsJSON.user, - id: utf8StringToBuffer(creationOptionsJSON.user.id), - }, - excludeCredentials: creationOptionsJSON.excludeCredentials?.map(toPublicKeyCredentialDescriptor), - }; - } + const publicKey: PublicKeyCredentialCreationOptions = { + ...creationOptionsJSON, + challenge: base64URLStringToBuffer(creationOptionsJSON.challenge), + user: { + ...creationOptionsJSON.user, + id: utf8StringToBuffer(creationOptionsJSON.user.id), + }, + excludeCredentials: creationOptionsJSON.excludeCredentials?.map(toPublicKeyCredentialDescriptor), + }; // Finalize options const options: CredentialCreationOptions = { publicKey }; @@ -62,11 +53,6 @@ export async function startRegistration( throw new Error('Registration was not completed'); } - // Use toJSON() if it's available in the browser - if (typeof credential.toJSON === 'function') { - return credential.toJSON() as RegistrationResponseJSON; - } - // Manually construct an instance of RegistrationResponseJSON const { id, rawId, response, type } = credential; |