summaryrefslogtreecommitdiffhomepage
path: root/packages/browser/src/helpers/browserSupportsWebAuthnAutofill.ts
blob: d0a5ca6b51f09bae4356c7875403ef97f13b8f43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/* eslint-disable @typescript-eslint/ban-ts-comment */
/**
 * Determine if the browser supports conditional UI, so that WebAuthn credentials can
 * be shown to the user in the browser's typical password autofill popup.
 */
export async function browserSupportsWebAuthnAutofill(): Promise<boolean> {
  // Just for Chrome Canary right now; the PublicKeyCredential logic below is the real API
  // @ts-ignore
  if (navigator.credentials.conditionalMediationSupported) {
    return true;
  }

  return (
    // @ts-ignore
    PublicKeyCredential.isConditionalMediationAvailable
    // @ts-ignore
    && PublicKeyCredential.isConditionalMediationAvailable()
  );
}