SessionManager

class SessionManager(sessionId: SessionId?, storage: SessionStorage, identify: suspend () -> FingerprintIdentification?)

Manages the lifecycle of a Sonar fraud-detection session: creation, refresh, keep-alive, and per-account local persistence.

A session only backs a payment once it has been associated with a Frame account, and sessions go stale — the server requires the session's latest device event to be recent, and only a create or update call records one. Call ensureSession before taking a payment.

Constructors

Link copied to clipboard
constructor(sessionId: SessionId?, storage: SessionStorage, identify: suspend () -> FingerprintIdentification?)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
suspend fun ensureSession(accountId: String): SessionId

Returns a session for accountId that is fresh enough to back a payment, creating or refreshing one if necessary. Idempotent, and coalesces concurrent callers for the same account onto a single round trip.

Link copied to clipboard
Link copied to clipboard
suspend fun initialize(): SessionId

Establishes a session for the legacy, pre-account flow this class originally supported. Preserved for existing callers; ensureSession is the account-scoped equivalent.

Link copied to clipboard
fun pause()

Stops the keep-alive while the app is backgrounded.

Link copied to clipboard
suspend fun refreshOnFlowEntry(accountId: String? = null)

Records a Sonar device event when an SDK entry-point view is presented. Mirrors iOS refreshOnFlowEntry(accountId:): opportunistic, never blocks presentation, and refreshes the pre-account session when accountId is null so adoption later preserves device history.

Link copied to clipboard
suspend fun resume()

Re-touches the live session after the app returns to the foreground and restarts the keep-alive. Backgrounding is the most common way a session goes stale, since timers don't fire while suspended.