summaryrefslogtreecommitdiffhomepage
path: root/packages/browser/src/methods/startAuthentication.ts
diff options
context:
space:
mode:
authorMatthew Miller <matthew@millerti.me>2022-12-27 19:36:52 -0800
committerMatthew Miller <matthew@millerti.me>2022-12-27 19:36:52 -0800
commitc689929d95c09e0c668bb61d6d96110bdffe4120 (patch)
tree2ad0bc004e7b2817fd9dfaca70b5358858f21ab4 /packages/browser/src/methods/startAuthentication.ts
parent468c8ce2f13105fd7e31d84cb41c7bbb07aa9ec9 (diff)
Revert use of new APIs in browser methods
Diffstat (limited to 'packages/browser/src/methods/startAuthentication.ts')
-rw-r--r--packages/browser/src/methods/startAuthentication.ts24
1 files changed, 5 insertions, 19 deletions
diff --git a/packages/browser/src/methods/startAuthentication.ts b/packages/browser/src/methods/startAuthentication.ts
index 8c9564f..fbb840d 100644
--- a/packages/browser/src/methods/startAuthentication.ts
+++ b/packages/browser/src/methods/startAuthentication.ts
@@ -2,7 +2,6 @@ import {
PublicKeyCredentialRequestOptionsJSON,
AuthenticationCredential,
AuthenticationResponseJSON,
- PublicKeyCredentialFuture,
} from '@simplewebauthn/typescript-types';
import { bufferToBase64URLString } from '../helpers/bufferToBase64URLString';
@@ -30,9 +29,6 @@ export async function startAuthentication(
throw new Error('WebAuthn is not supported in this browser');
}
- const globalPublicKeyCredential =
- window.PublicKeyCredential as unknown as PublicKeyCredentialFuture;
-
// We need to avoid passing empty array to avoid blocking retrieval
// of public key
let allowCredentials;
@@ -41,16 +37,11 @@ export async function startAuthentication(
}
// We need to convert some values to Uint8Arrays before passing the credentials to the navigator
- let publicKey: PublicKeyCredentialRequestOptions;
- if (typeof globalPublicKeyCredential.parseRequestOptionsFromJSON === 'function') {
- publicKey = globalPublicKeyCredential.parseRequestOptionsFromJSON(requestOptionsJSON);
- } else {
- publicKey = {
- ...requestOptionsJSON,
- challenge: base64URLStringToBuffer(requestOptionsJSON.challenge),
- allowCredentials,
- };
- }
+ const publicKey: PublicKeyCredentialRequestOptions = {
+ ...requestOptionsJSON,
+ challenge: base64URLStringToBuffer(requestOptionsJSON.challenge),
+ allowCredentials,
+ };
// Prepare options for `.get()`
const options: CredentialRequestOptions = {};
@@ -96,11 +87,6 @@ export async function startAuthentication(
throw new Error('Authentication was not completed');
}
- // Use toJSON() if it's available in the browser
- if (typeof credential.toJSON === 'function') {
- return credential.toJSON() as AuthenticationResponseJSON;
- }
-
// Manually construct an instance of AuthenticationResponseJSON
const { id, rawId, response, type } = credential;