Skip to content

Commit

Permalink
Merge pull request #157 from stytchauth/jordan/SDK-1456-b2c-session
Browse files Browse the repository at this point in the history
SDK-1456 Add missing session method
  • Loading branch information
jhaven-stytch authored Apr 29, 2024
2 parents a00ba22 + 4ffcd80 commit 0d56461
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.stytch.sdk.consumer.sessions
import com.stytch.sdk.common.BaseResponse
import com.stytch.sdk.common.errors.StytchFailedToDecryptDataError
import com.stytch.sdk.consumer.AuthResponse
import com.stytch.sdk.consumer.network.models.SessionData

/**
* The Sessions interface provides methods for authenticating, updating, or revoking sessions, and properties to
Expand All @@ -19,6 +20,11 @@ public interface Sessions {
*/
public val sessionJwt: String?

/**
* Get the locally persisted session
*/
public fun getSync(): SessionData?

/**
* Data class used for wrapping parameters used with Sessions authentication
* @property sessionDurationMinutes indicates how long the session should last before it expires
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.stytch.sdk.common.errors.StytchInternalError
import com.stytch.sdk.consumer.AuthResponse
import com.stytch.sdk.consumer.extensions.launchSessionUpdater
import com.stytch.sdk.consumer.network.StytchApi
import com.stytch.sdk.consumer.network.models.SessionData
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
Expand Down Expand Up @@ -36,6 +37,10 @@ internal class SessionsImpl internal constructor(
}
}

override fun getSync(): SessionData? {
return sessionStorage.session
}

override suspend fun authenticate(authParams: Sessions.AuthParams): AuthResponse {
val result: AuthResponse
withContext(dispatchers.io) {
Expand Down

0 comments on commit 0d56461

Please sign in to comment.