@@ -5,14 +5,16 @@ class default_1 extends Controller {
55 constructor ( ) {
66 super ( ...arguments ) ;
77 this . connect = async ( ) => {
8- var _a , _b ;
8+ var _a , _b , _c , _d ;
99 const options = {
1010 requestResultUrl : this . requestResultUrlValue ,
1111 requestOptionsUrl : this . requestOptionsUrlValue ,
12- requestSuccessRedirectUri : ( _a = this . requestSuccessRedirectUriValue ) !== null && _a !== undefined ? _a : null ,
12+ requestResultField : ( _a = this . requestResultFieldValue ) !== null && _a !== undefined ? _a : null ,
13+ creationResultField : ( _b = this . creationResultFieldValue ) !== null && _b !== undefined ? _b : null ,
14+ requestSuccessRedirectUri : ( _c = this . requestSuccessRedirectUriValue ) !== null && _c !== undefined ? _c : null ,
1315 creationResultUrl : this . creationResultUrlValue ,
1416 creationOptionsUrl : this . creationOptionsUrlValue ,
15- creationSuccessRedirectUri : ( _b = this . creationSuccessRedirectUriValue ) !== null && _b !== undefined ? _b : null ,
17+ creationSuccessRedirectUri : ( _d = this . creationSuccessRedirectUriValue ) !== null && _d !== undefined ? _d : null ,
1618 } ;
1719 this . _dispatchEvent ( 'webauthn:connect' , { options } ) ;
1820 const supportAutofill = await browserSupportsWebAuthnAutofill ( ) ;
@@ -38,9 +40,15 @@ class default_1 extends Controller {
3840 this . _processSignin ( optionsResponseJson , false ) ;
3941 }
4042 async _processSignin ( optionsResponseJson , useBrowserAutofill ) {
43+ var _a ;
4144 try {
4245 const authenticatorResponse = await startAuthentication ( { optionsJSON : optionsResponseJson , useBrowserAutofill } ) ;
4346 this . _dispatchEvent ( 'webauthn:authenticator:response' , { response : authenticatorResponse } ) ;
47+ if ( this . requestResultFieldValue && this . element instanceof HTMLFormElement ) {
48+ ( _a = this . element . querySelector ( this . requestResultFieldValue ) ) === null || _a === void 0 ? void 0 : _a . setAttribute ( 'value' , JSON . stringify ( authenticatorResponse ) ) ;
49+ this . element . submit ( ) ;
50+ return ;
51+ }
4452 const assertionResponse = await this . _getAssertionResponse ( authenticatorResponse ) ;
4553 if ( assertionResponse !== false && this . requestSuccessRedirectUriValue ) {
4654 window . location . replace ( this . requestSuccessRedirectUriValue ) ;
@@ -52,6 +60,7 @@ class default_1 extends Controller {
5260 }
5361 }
5462 async signup ( event ) {
63+ var _a ;
5564 try {
5665 if ( ! browserSupportsWebAuthn ( ) ) {
5766 this . _dispatchEvent ( 'webauthn:unsupported' , { } ) ;
@@ -64,6 +73,11 @@ class default_1 extends Controller {
6473 }
6574 const authenticatorResponse = await startRegistration ( { optionsJSON : optionsResponseJson } ) ;
6675 this . _dispatchEvent ( 'webauthn:authenticator:response' , { response : authenticatorResponse } ) ;
76+ if ( this . creationResultFieldValue && this . element instanceof HTMLFormElement ) {
77+ ( _a = this . element . querySelector ( this . creationResultFieldValue ) ) === null || _a === void 0 ? void 0 : _a . setAttribute ( 'value' , JSON . stringify ( authenticatorResponse ) ) ;
78+ this . element . submit ( ) ;
79+ return ;
80+ }
6781 const attestationResponseJSON = await this . _getAttestationResponse ( authenticatorResponse ) ;
6882 if ( attestationResponseJSON !== false && this . creationSuccessRedirectUriValue ) {
6983 window . location . replace ( this . creationSuccessRedirectUriValue ) ;
@@ -151,9 +165,11 @@ class default_1 extends Controller {
151165default_1 . values = {
152166 requestResultUrl : { type : String , default : '/request' } ,
153167 requestOptionsUrl : { type : String , default : '/request/options' } ,
168+ requestResultField : { type : String , default : null } ,
154169 requestSuccessRedirectUri : String ,
155170 creationResultUrl : { type : String , default : '/creation' } ,
156171 creationOptionsUrl : { type : String , default : '/creation/options' } ,
172+ creationResultField : { type : String , default : null } ,
157173 creationSuccessRedirectUri : String ,
158174 usernameField : { type : String , default : 'username' } ,
159175 displayNameField : { type : String , default : 'displayName' } ,
0 commit comments