Skip to content

Commit

Permalink
remove overly-granular check
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewkmin committed Oct 12, 2023
1 parent d69624b commit 07bb8e3
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions packages/http/src/webauthn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export async function getWebAuthnAssertion(
payload: string,
options?: TurnkeyCredentialRequestOptions
): Promise<string> {
const webAuthnSupported = await hasWebAuthnSupport();
const webAuthnSupported = hasWebAuthnSupport();

if (!webAuthnSupported) {
throw new Error("webauthn is not supported by this browser");
Expand All @@ -136,7 +136,7 @@ export async function getWebAuthnAssertion(
export async function getWebAuthnAttestation(
options: TurnkeyCredentialCreationOptions
): Promise<TAttestation> {
const webAuthnSupported = await hasWebAuthnSupport();
const webAuthnSupported = hasWebAuthnSupport();

if (!webAuthnSupported) {
throw new Error("webauthn is not supported by this browser");
Expand All @@ -147,16 +147,9 @@ export async function getWebAuthnAttestation(
return toInternalAttestation(res.toJSON());
}

// For additional details see https://web.dev/articles/passkey-form-autofill#feature-detection, https://github.com/w3c/webauthn/wiki/Explainer:-WebAuthn-Conditional-UI
async function hasWebAuthnSupport(): Promise<boolean> {
if (
window.PublicKeyCredential &&
PublicKeyCredential.isConditionalMediationAvailable
) {
const isCMA = await PublicKeyCredential.isConditionalMediationAvailable();

return isCMA;
}

return false;
// `hasWebAuthnSupport` checks for barebones webauthn support.
// For additional details and granular settings, see:
// https://web.dev/articles/passkey-form-autofill#feature-detection, https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredential
function hasWebAuthnSupport(): boolean {
return !!window.PublicKeyCredential;
}

0 comments on commit 07bb8e3

Please sign in to comment.