@@ -13,6 +13,7 @@ import { CallbackType } from '../auth/enums';
1313import type HiddenValueCallback from '../fr-auth/callbacks/hidden-value-callback' ;
1414import type MetadataCallback from '../fr-auth/callbacks/metadata-callback' ;
1515import type FRStep from '../fr-auth/fr-step' ;
16+ import { FRLogger } from '../util/logger' ;
1617import { WebAuthnOutcome , WebAuthnOutcomeType , WebAuthnStepType } from './enums' ;
1718import {
1819 arrayBufferToString ,
@@ -30,6 +31,7 @@ import type {
3031} from './interfaces' ;
3132import type TextOutputCallback from '../fr-auth/callbacks/text-output-callback' ;
3233import { parseWebAuthnAuthenticateText , parseWebAuthnRegisterText } from './script-parser' ;
34+ import { withTimeout } from '../util/timeout' ;
3335
3436// <clientdata>::<attestation>::<publickeyCredential>::<DeviceName>
3537type OutcomeWithName <
@@ -44,6 +46,8 @@ type OutcomeWithName<
4446type WebAuthnMetadata = WebAuthnAuthenticationMetadata | WebAuthnRegistrationMetadata ;
4547// Script-based WebAuthn
4648type WebAuthnTextOutput = WebAuthnTextOutputRegistration ;
49+ const ONE_SECOND = 1000 ;
50+
4751/**
4852 * Utility for integrating a web browser's WebAuthn API.
4953 *
@@ -123,10 +127,12 @@ abstract class FRWebAuthn {
123127 }
124128
125129 // Check if the browser supports conditional mediation
126- if ( typeof PublicKeyCredential . isConditionalMediationAvailable === 'function' ) {
127- return await PublicKeyCredential . isConditionalMediationAvailable ( ) ;
130+ try {
131+ return withTimeout ( PublicKeyCredential . isConditionalMediationAvailable ( ) , ONE_SECOND )
132+ } catch {
133+ throw new Error ( 'Error determining conditional mediation support' ) ;
128134 }
129-
135+
130136 return false ;
131137 }
132138
@@ -370,6 +376,7 @@ abstract class FRWebAuthn {
370376 credentialRequestOptions . mediation = 'conditional' as CredentialMediationRequirement ;
371377 } else {
372378 // eslint-disable-next-line no-console
379+ FRLogger . warn ( 'Conditional UI was requested, but is not supported by this browser.' ) ;
373380 console . warn ( 'Conditional UI was requested, but is not supported by this browser.' ) ;
374381 }
375382 }
0 commit comments