From 379ff5c35c7578aed1ff2b78263ab3c2dd2f4873 Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Mon, 20 Jun 2022 10:54:16 -0700 Subject: Attempt to cast PublicKeyCredential for new method --- .../src/helpers/browserSupportsWebAuthnAutofill.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'packages/browser/src') diff --git a/packages/browser/src/helpers/browserSupportsWebAuthnAutofill.ts b/packages/browser/src/helpers/browserSupportsWebAuthnAutofill.ts index d0a5ca6..575d2f1 100644 --- a/packages/browser/src/helpers/browserSupportsWebAuthnAutofill.ts +++ b/packages/browser/src/helpers/browserSupportsWebAuthnAutofill.ts @@ -1,4 +1,5 @@ /* eslint-disable @typescript-eslint/ban-ts-comment */ +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. @@ -10,10 +11,16 @@ export async function browserSupportsWebAuthnAutofill(): Promise { return true; } + /** + * 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 = PublicKeyCredential as unknown as PublicKeyCredentialFuture; + return ( - // @ts-ignore - PublicKeyCredential.isConditionalMediationAvailable - // @ts-ignore - && PublicKeyCredential.isConditionalMediationAvailable() + globalPublicKeyCredential.isConditionalMediationAvailable + && globalPublicKeyCredential.isConditionalMediationAvailable() ); } -- cgit v1.2.3