diff options
Diffstat (limited to 'packages/browser/src/helpers/browserSupportsWebAuthnAutofill.ts')
-rw-r--r-- | packages/browser/src/helpers/browserSupportsWebAuthnAutofill.ts | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/packages/browser/src/helpers/browserSupportsWebAuthnAutofill.ts b/packages/browser/src/helpers/browserSupportsWebAuthnAutofill.ts new file mode 100644 index 0000000..d0a5ca6 --- /dev/null +++ b/packages/browser/src/helpers/browserSupportsWebAuthnAutofill.ts @@ -0,0 +1,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() + ); +} |