summaryrefslogtreecommitdiffhomepage
path: root/packages/browser/src/helpers/browserSupportsWebAuthnAutofill.ts
diff options
context:
space:
mode:
authorMatthew Miller <matthew@millerti.me>2023-08-22 10:13:03 -0700
committerGitHub <noreply@github.com>2023-08-22 10:13:03 -0700
commitfefc95e4535e6ecf903f647124a492fba3fd11d6 (patch)
tree4c924d43d32fb12a780533302eaf5dee08875d75 /packages/browser/src/helpers/browserSupportsWebAuthnAutofill.ts
parent443c341bc2163f07b93a3ef84a43294d10b826f8 (diff)
parent2935857c76d458c26701842e500f8d97d17499c5 (diff)
Merge pull request #425 from MasterKale/feat/server-esm-take-2-dnt
feat/server-esm-take-2-dnt
Diffstat (limited to 'packages/browser/src/helpers/browserSupportsWebAuthnAutofill.ts')
-rw-r--r--packages/browser/src/helpers/browserSupportsWebAuthnAutofill.ts15
1 files changed, 8 insertions, 7 deletions
diff --git a/packages/browser/src/helpers/browserSupportsWebAuthnAutofill.ts b/packages/browser/src/helpers/browserSupportsWebAuthnAutofill.ts
index afc1176..cfdfb52 100644
--- a/packages/browser/src/helpers/browserSupportsWebAuthnAutofill.ts
+++ b/packages/browser/src/helpers/browserSupportsWebAuthnAutofill.ts
@@ -4,18 +4,19 @@ import { PublicKeyCredentialFuture } from '@simplewebauthn/typescript-types';
* 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> {
+export function browserSupportsWebAuthnAutofill(): Promise<boolean> {
/**
* I don't like the `as unknown` here but there's a `declare var PublicKeyCredential` in
* TS' DOM lib that's making it difficult for me to just go `as PublicKeyCredentialFuture` as I
* want. I think I'm fine with this for now since it's _supposed_ to be temporary, until TS types
* have a chance to catch up.
*/
- const globalPublicKeyCredential =
- window.PublicKeyCredential as unknown as PublicKeyCredentialFuture;
+ const globalPublicKeyCredential = window
+ .PublicKeyCredential as unknown as PublicKeyCredentialFuture;
- return (
- globalPublicKeyCredential.isConditionalMediationAvailable !== undefined &&
- globalPublicKeyCredential.isConditionalMediationAvailable()
- );
+ if (globalPublicKeyCredential.isConditionalMediationAvailable === undefined) {
+ return new Promise((resolve) => resolve(false));
+ }
+
+ return globalPublicKeyCredential.isConditionalMediationAvailable();
}