Skip to content

Commit

Permalink
feat: allowedOrigin Support added
Browse files Browse the repository at this point in the history
Signed-off-by: Gaurav Goel <[email protected]>
  • Loading branch information
grvgoel81 authored and Gaurav Goel committed Sep 4, 2024
1 parent b1f60de commit 44d8244
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@ class SessionManager(context: Context) {
}.exceptionally { throw it }
}

fun invalidateSession(context: Context): CompletableFuture<Boolean> {
fun invalidateSession(
context: Context,
allowedOrigin: String = "*"
): CompletableFuture<Boolean> {
return CompletableFuture.supplyAsync {
if (!ApiHelper.isNetworkAvailable(context)) {
throw Exception(
Expand Down Expand Up @@ -147,7 +150,8 @@ class SessionManager(context: Context) {
signature = KeyStoreManager.getECDSASignature(
BigInteger(sessionId, 16), gsonData
),
timeout = 1
timeout = 1,
allowedOrigin = allowedOrigin ?: "*"
)
)
}
Expand All @@ -169,7 +173,8 @@ class SessionManager(context: Context) {
fun createSession(
data: String,
sessionTime: Long,
context: Context
context: Context,
allowedOrigin: String = "*",
): CompletableFuture<String> {
return CompletableFuture.supplyAsync {
val newSessionKey = generateRandomSessionKey()
Expand Down Expand Up @@ -204,7 +209,8 @@ class SessionManager(context: Context) {
signature = KeyStoreManager.getECDSASignature(
BigInteger(newSessionKey, 16), gsonData
),
timeout = min(sessionTime, 7 * 86400)
timeout = min(sessionTime, 7 * 86400),
allowedOrigin = allowedOrigin
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import retrofit2.http.Query

interface Web3AuthApi {

@POST("/store/set")
@POST("/v2/store/set")
suspend fun createSession(@Body sessionRequestBody: SessionRequestBody): Response<JSONObject>

@GET("/store/get")
@GET("/v2/store/get")
suspend fun authorizeSession(@Query("key") key: String): Response<StoreApiResponse>

@POST("/store/set")
@POST("/v2/store/set")
suspend fun invalidateSession(@Body sessionRequestBody: SessionRequestBody): Response<JSONObject>
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ data class SessionRequestBody(
val key: String,
val data: String,
val signature: String,
val timeout: Long = 0L
val timeout: Long = 0L,
val allowedOrigin: String
)

0 comments on commit 44d8244

Please sign in to comment.