@@ -199,6 +199,26 @@ abstract class FRWebAuthn {
199199 } else {
200200 throw new Error ( 'No Credential found from Public Key' ) ;
201201 }
202+ const credential : PublicKeyCredential | null = await this . getAuthenticationCredential (
203+ optionsTransformer ( options ) ,
204+ ) ;
205+ const outcome : ReturnType < typeof this . getAuthenticationOutcome > =
206+ this . getAuthenticationOutcome ( credential ) ;
207+
208+ if ( metadataCallback ) {
209+ const meta = metadataCallback . getOutputValue ( 'data' ) as WebAuthnAuthenticationMetadata ;
210+ if ( meta ?. supportsJsonResponse && credential && 'authenticatorAttachment' in credential ) {
211+ hiddenCallback . setInputValue (
212+ JSON . stringify ( {
213+ authenticatorAttachment : credential . authenticatorAttachment ,
214+ legacyData : outcome ,
215+ } ) ,
216+ ) ;
217+ return step ;
218+ }
219+ }
220+ hiddenCallback . setInputValue ( outcome ) ;
221+ return step ;
202222 } catch ( error ) {
203223 if ( ! ( error instanceof Error ) ) throw error ;
204224 // NotSupportedError is a special case
@@ -209,27 +229,6 @@ abstract class FRWebAuthn {
209229 hiddenCallback . setInputValue ( `${ WebAuthnOutcome . Error } ::${ error . name } :${ error . message } ` ) ;
210230 throw error ;
211231 }
212-
213- const credential : PublicKeyCredential | null = await this . getAuthenticationCredential (
214- optionsTransformer ( options ) ,
215- ) ;
216- const outcome : ReturnType < typeof this . getAuthenticationOutcome > =
217- this . getAuthenticationOutcome ( credential ) ;
218-
219- if ( metadataCallback ) {
220- const meta = metadataCallback . getOutputValue ( 'data' ) as WebAuthnAuthenticationMetadata ;
221- if ( meta ?. supportsJsonResponse && credential && 'authenticatorAttachment' in credential ) {
222- hiddenCallback . setInputValue (
223- JSON . stringify ( {
224- authenticatorAttachment : credential . authenticatorAttachment ,
225- legacyData : outcome ,
226- } ) ,
227- ) ;
228- return step ;
229- }
230- }
231- hiddenCallback . setInputValue ( outcome ) ;
232- return step ;
233232 } else {
234233 const e = new Error ( 'Incorrect callbacks for WebAuthn authentication' ) ;
235234 e . name = WebAuthnOutcomeType . DataError ;
0 commit comments