diff --git a/session-manager-android/src/androidTest/java/com/web3auth/session_manager_android/SessionManagerTest.kt b/session-manager-android/src/androidTest/java/com/web3auth/session_manager_android/SessionManagerTest.kt index 0586f1e..00f9368 100644 --- a/session-manager-android/src/androidTest/java/com/web3auth/session_manager_android/SessionManagerTest.kt +++ b/session-manager-android/src/androidTest/java/com/web3auth/session_manager_android/SessionManagerTest.kt @@ -41,7 +41,7 @@ class SessionManagerTest { fun test_authorizeSession() { val context = InstrumentationRegistry.getInstrumentation().context val sessionId = SessionManager.generateRandomSessionKey() - sessionManager = SessionManager(context, 86400, context.packageName, sessionId) + sessionManager = SessionManager(context, 86400, context.packageName, sessionId, "sfa") val json = JSONObject() json.put( "privateKey", diff --git a/session-manager-android/src/main/java/com/web3auth/session_manager_android/SessionManager.kt b/session-manager-android/src/main/java/com/web3auth/session_manager_android/SessionManager.kt index 4be27c7..a033623 100644 --- a/session-manager-android/src/main/java/com/web3auth/session_manager_android/SessionManager.kt +++ b/session-manager-android/src/main/java/com/web3auth/session_manager_android/SessionManager.kt @@ -27,13 +27,15 @@ class SessionManager( context: Context, sessionTime: Int = 86400, allowedOrigin: String = "*", - sessionId: String? = null + sessionId: String? = null, + sessionNamespace: String? = null ) { private val gson = GsonBuilder().disableHtmlEscaping().create() private val web3AuthApi = ApiHelper.getInstance().create(Web3AuthApi::class.java) private var sessionTime: Int private var allowedOrigin: String + private var sessionNamespace: String = "" private lateinit var sessionId: String companion object { @@ -59,11 +61,14 @@ class SessionManager( init { KeyStoreManager.initializePreferences(context.applicationContext) initiateKeyStoreManager() - if (sessionId != null && sessionId.isNotEmpty()) { + if (!sessionId.isNullOrEmpty()) { this.sessionId = sessionId } this.sessionTime = sessionTime this.allowedOrigin = allowedOrigin + if (!sessionNamespace.isNullOrEmpty()) { + this.sessionNamespace = sessionNamespace + } } fun setSessionId(sessionId: String) { @@ -120,7 +125,7 @@ class SessionManager( withContext(Dispatchers.IO) { web3AuthApi.authorizeSession( origin = origin, - AuthorizeSessionRequest(key = pubKey) + AuthorizeSessionRequest(key = pubKey, namespace = sessionNamespace) ) } } @@ -313,7 +318,8 @@ class SessionManager( BigInteger(newSessionKey, 16), gsonData ), timeout = min(sessionTime, 7 * 86400), - allowedOrigin = allowedOrigin + allowedOrigin = allowedOrigin, + namespace = sessionNamespace ) ) } diff --git a/session-manager-android/src/main/java/com/web3auth/session_manager_android/models/AuthorizeSessionRequest.kt b/session-manager-android/src/main/java/com/web3auth/session_manager_android/models/AuthorizeSessionRequest.kt index 73587b2..641503f 100644 --- a/session-manager-android/src/main/java/com/web3auth/session_manager_android/models/AuthorizeSessionRequest.kt +++ b/session-manager-android/src/main/java/com/web3auth/session_manager_android/models/AuthorizeSessionRequest.kt @@ -4,5 +4,6 @@ import androidx.annotation.Keep @Keep data class AuthorizeSessionRequest( - val key: String + val key: String, + val namespace: String ) \ No newline at end of file diff --git a/session-manager-android/src/main/java/com/web3auth/session_manager_android/models/SessionRequestBody.kt b/session-manager-android/src/main/java/com/web3auth/session_manager_android/models/SessionRequestBody.kt index 8e26842..e0c8241 100644 --- a/session-manager-android/src/main/java/com/web3auth/session_manager_android/models/SessionRequestBody.kt +++ b/session-manager-android/src/main/java/com/web3auth/session_manager_android/models/SessionRequestBody.kt @@ -8,5 +8,6 @@ data class SessionRequestBody( val data: String, val signature: String, val timeout: Int = 0, - val allowedOrigin: String? = null + val allowedOrigin: String? = null, + val namespace: String? = null ) \ No newline at end of file