@@ -135,15 +135,6 @@ export class Web3AuthMPCCoreKit implements ICoreKit {
135135 network : this . options . web3AuthNetwork ,
136136 enableLogging : options . enableLogging ,
137137 } ) ;
138-
139- const asyncConstructor = async ( ) => {
140- const sessionId = await this . currentStorage . get < string > ( "sessionId" ) ;
141- this . sessionManager = new SessionManager ( {
142- sessionTime : this . options . sessionTime ,
143- sessionId,
144- } ) ;
145- } ;
146- asyncConstructor ( ) ;
147138 }
148139
149140 get tKey ( ) : TKeyTSS {
@@ -179,7 +170,7 @@ export class Web3AuthMPCCoreKit implements ICoreKit {
179170 }
180171
181172 get sessionId ( ) : string {
182- return this . sessionManager . sessionId ;
173+ return this . sessionManager ? .sessionId ;
183174 }
184175
185176 get supportsAccountIndex ( ) : boolean {
@@ -289,6 +280,13 @@ export class Web3AuthMPCCoreKit implements ICoreKit {
289280
290281 this . ready = true ;
291282
283+ // setup session Manager during init instead of async constructor
284+ const sessionId = await this . currentStorage . get < string > ( "sessionId" ) ;
285+ this . sessionManager = new SessionManager ( {
286+ sessionTime : this . options . sessionTime ,
287+ sessionId,
288+ } ) ;
289+
292290 // try handle redirect flow if enabled and return(redirect) from oauth login
293291 if (
294292 params . handleRedirectResult &&
@@ -297,7 +295,6 @@ export class Web3AuthMPCCoreKit implements ICoreKit {
297295 ) {
298296 // on failed redirect, instance is reseted.
299297 await this . handleRedirectResult ( ) ;
300-
301298 // if not redirect flow try to rehydrate session if available
302299 } else if ( params . rehydrate && this . sessionManager . sessionId ) {
303300 // swallowed, should not throw on rehydrate timed out session
0 commit comments