@@ -166,6 +166,7 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions, context: Context) : WebViewResu
166166 fetchProjectConfig(context).whenComplete { _, err ->
167167 if (err == null ) {
168168 // authorize session
169+ sessionManager.setSessionId(SessionManager .getSessionIdFromStorage())
169170 this .authorizeSession(web3AuthOption.redirectUrl.toString(), context)
170171 .whenComplete { resp, error ->
171172 runOnUIThread {
@@ -218,7 +219,8 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions, context: Context) : WebViewResu
218219 val sessionId = sessionResponse.sessionId
219220
220221 if (sessionId.isNotBlank() && sessionId.isNotEmpty()) {
221- sessionManager.saveSessionId(sessionId)
222+ SessionManager .saveSessionIdToStorage(sessionId)
223+ sessionManager.setSessionId(sessionId)
222224
223225 // Rehydrate Session
224226 this .authorizeSession(web3AuthOption.redirectUrl.toString(), context)
@@ -233,7 +235,10 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions, context: Context) : WebViewResu
233235 throwLoginError(ErrorCode .SOMETHING_WENT_WRONG )
234236 throwEnableMFAError(ErrorCode .SOMETHING_WENT_WRONG )
235237 } else {
236- web3AuthResponse?.sessionId?.let { sessionManager.saveSessionId(it) }
238+ web3AuthResponse?.sessionId?.let {
239+ SessionManager .saveSessionIdToStorage(it)
240+ sessionManager.setSessionId(it)
241+ }
237242
238243 if (web3AuthResponse?.userInfo?.dappShare?.isNotEmpty() == true ) {
239244 KeyStoreManagerUtils .encryptData(
@@ -436,9 +441,11 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions, context: Context) : WebViewResu
436441 * @return A CompletableFuture<String> representing the asynchronous operation, containing the login ID.
437442 */
438443 private fun getLoginId (jsonObject : JSONObject , context : Context ): CompletableFuture <String > {
444+ val sessionId = SessionManager .generateRandomSessionKey()
445+ sessionManager.setSessionId(sessionId)
439446 return sessionManager.createSession(
440447 jsonObject.toString(),
441- context
448+ context,
442449 )
443450 }
444451
@@ -455,7 +462,7 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions, context: Context) : WebViewResu
455462 context : Context
456463 ): CompletableFuture <Void > {
457464 val launchWalletServiceCF: CompletableFuture <Void > = CompletableFuture ()
458- val sessionId = sessionManager.getSessionId ()
465+ val sessionId = SessionManager .getSessionIdFromStorage ()
459466 if (sessionId.isNotBlank()) {
460467 val sdkUrl = Uri .parse(web3AuthOption.walletSdkUrl)
461468
0 commit comments