@clerk/shared
Version:
Internal package utils used by the Clerk SDKs
1 lines • 1.6 kB
Source Map (JSON)
{"version":3,"file":"webauthn.mjs","names":[],"sources":["../src/webauthn.ts"],"sourcesContent":["import { isValidBrowser } from './browser';\n\n/**\n *\n */\nfunction isWebAuthnSupported() {\n return (\n // `isValidBrowser()` now also returns true in environments that expose a global\n // `navigator` but no `window` (e.g. service workers). WebAuthn requires the DOM\n // `window` (it reads `window.PublicKeyCredential`), so guard on it explicitly.\n typeof window !== 'undefined' &&\n isValidBrowser() &&\n // Check if `PublicKeyCredential` is a constructor\n typeof window.PublicKeyCredential === 'function'\n );\n}\n\n/**\n *\n */\nasync function isWebAuthnAutofillSupported(): Promise<boolean> {\n try {\n return isWebAuthnSupported() && (await window.PublicKeyCredential.isConditionalMediationAvailable());\n } catch {\n return false;\n }\n}\n\n/**\n *\n */\nasync function isWebAuthnPlatformAuthenticatorSupported(): Promise<boolean> {\n try {\n return (\n typeof window !== 'undefined' &&\n (await window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable())\n );\n } catch {\n return false;\n }\n}\n\nexport { isWebAuthnPlatformAuthenticatorSupported, isWebAuthnAutofillSupported, isWebAuthnSupported };\n"],"mappings":";;;;;;AAKA,SAAS,sBAAsB;CAC7B,OAIE,OAAO,WAAW,eAClB,eAAe,KAEf,OAAO,OAAO,wBAAwB;AAE1C;;;;AAKA,eAAe,8BAAgD;CAC7D,IAAI;EACF,OAAO,oBAAoB,KAAM,MAAM,OAAO,oBAAoB,gCAAgC;CACpG,QAAQ;EACN,OAAO;CACT;AACF;;;;AAKA,eAAe,2CAA6D;CAC1E,IAAI;EACF,OACE,OAAO,WAAW,eACjB,MAAM,OAAO,oBAAoB,8CAA8C;CAEpF,QAAQ;EACN,OAAO;CACT;AACF"}