File tree Expand file tree Collapse file tree 1 file changed +15
-9
lines changed
Expand file tree Collapse file tree 1 file changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -238,15 +238,6 @@ export class Web3AuthNoModal extends SafeEventEmitter<Web3AuthNoModalEvents> imp
238238
239239 return new Promise ( ( resolve , reject ) => {
240240 this . once ( CONNECTOR_EVENTS . CONNECTED , async ( _ ) => {
241- // when ssr is enabled, we need to get the idToken from the connector.
242- if ( this . coreOptions . ssr ) {
243- // TODO: handle the idToken being expired if saved in storage.
244- const data = await connector . authenticateUser ( ) ;
245- this . setState ( {
246- idToken : data . idToken ,
247- } ) ;
248- }
249-
250241 resolve ( this . provider ) ;
251242 } ) ;
252243 this . once ( CONNECTOR_EVENTS . ERRORED , ( err ) => {
@@ -523,6 +514,21 @@ export class Web3AuthNoModal extends SafeEventEmitter<Web3AuthNoModalEvents> imp
523514 if ( ! this . commonJRPCProvider ) throw WalletInitializationError . notFound ( `CommonJrpcProvider not found` ) ;
524515 const { provider } = data ;
525516
517+ // when ssr is enabled, we need to get the idToken from the connector.
518+ if ( this . coreOptions . ssr ) {
519+ try {
520+ // TODO: handle the idToken being expired if saved in storage.
521+ const data = await connector . authenticateUser ( ) ;
522+ if ( ! data . idToken ) throw WalletLoginError . connectionError ( "No idToken found" ) ;
523+ this . setState ( {
524+ idToken : data . idToken ,
525+ } ) ;
526+ } catch ( error ) {
527+ log . error ( error ) ;
528+ throw error ;
529+ }
530+ }
531+
526532 let finalProvider = ( provider as IBaseProvider < unknown > ) . provider || ( provider as SafeEventEmitterProvider ) ;
527533
528534 // setup AA provider if AA is enabled
You can’t perform that action at this time.
0 commit comments