@@ -178,7 +178,15 @@ abstract class FRWebAuthn {
178178 credential = await this . getAuthenticationCredential ( { publicKey, mediation } ) ;
179179 outcome = this . getAuthenticationOutcome ( credential ) ;
180180 } else if ( textOutputCallback ) {
181- publicKey = parseWebAuthnAuthenticateText ( textOutputCallback . getMessage ( ) ) ;
181+ const metadata = this . extractMetadata ( textOutputCallback . getMessage ( ) ) ;
182+
183+ if ( metadata ) {
184+ publicKey = this . createAuthenticationPublicKey (
185+ metadata as WebAuthnAuthenticationMetadata ,
186+ ) ;
187+ } else {
188+ publicKey = parseWebAuthnAuthenticateText ( textOutputCallback . getMessage ( ) ) ;
189+ }
182190
183191 credential = await this . getAuthenticationCredential ( { publicKey } ) ;
184192 outcome = this . getAuthenticationOutcome ( credential ) ;
@@ -245,7 +253,13 @@ abstract class FRWebAuthn {
245253 ) ;
246254 outcome = this . getRegistrationOutcome ( credential ) ;
247255 } else if ( textOutputCallback ) {
248- publicKey = parseWebAuthnRegisterText ( textOutputCallback . getMessage ( ) ) ;
256+ const metadata = this . extractMetadata ( textOutputCallback . getMessage ( ) ) ;
257+
258+ if ( metadata ) {
259+ publicKey = this . createRegistrationPublicKey ( metadata as WebAuthnRegistrationMetadata ) ;
260+ } else {
261+ publicKey = parseWebAuthnRegisterText ( textOutputCallback . getMessage ( ) ) ;
262+ }
249263 credential = await this . getRegistrationCredential (
250264 publicKey as PublicKeyCredentialCreationOptions ,
251265 ) ;
@@ -602,6 +616,17 @@ abstract class FRWebAuthn {
602616 window . PingWebAuthnAbortController = abortController ;
603617 return abortController ;
604618 }
619+
620+ private static extractMetadata ( message : string ) : object | null {
621+ const contextMatch = message . match ( / ^ v a r s c r i p t C o n t e x t = ( .* ) $ / ) ;
622+ const jsonString = contextMatch ?. [ 1 ] ;
623+
624+ if ( jsonString ) {
625+ return JSON . parse ( jsonString ) ;
626+ }
627+
628+ return null ;
629+ }
605630}
606631
607632export default FRWebAuthn ;
0 commit comments