Skip to content

Commit 6e33a62

Browse files
committed
feat: updated code for session-manager changes
Signed-off-by: Gaurav Goel <[email protected]>
1 parent cf5e125 commit 6e33a62

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

core/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ dependencies {
6969
implementation 'org.web3j:core:4.8.8-android'
7070

7171
//session-manager-sdk
72-
implementation 'com.github.grvgoel81:session-manager-android:7.2.0'
72+
implementation 'com.github.grvgoel81:session-manager-android:7.4.0'
7373

7474
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.2.0-alpha01"
7575

core/src/main/java/com/web3auth/core/Web3Auth.kt

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)