AuthSessionInitializer

class AuthSessionInitializer(authRepository: AuthStateProvider, authTokenProvider: AuthTokenProvider, sessionStore: AuthSessionStore, logger: KommonLogger = NoOpLogger, scope: CoroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.Default))

Warms the auth session at cold start: mints/refreshes a token before the first API request can race an unauthenticated call, then keeps sessionStore updated as AuthStateProvider.authStateFlow changes. Call start early in app startup and stop when its owning app scope is torn down.

Failures from the token provider or the auth-state flow are logged and contained: they never escape into scope (where an uncaught exception would crash the process). A failed warm-up still proceeds to observing auth changes, so the session hint keeps tracking the real state.

Constructors

Link copied to clipboard
constructor(authRepository: AuthStateProvider, authTokenProvider: AuthTokenProvider, sessionStore: AuthSessionStore, logger: KommonLogger = NoOpLogger, scope: CoroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.Default))

Functions

Link copied to clipboard

Starts session warming and observation. Repeated calls while running are ignored.

Link copied to clipboard

Stops this initializer's work without cancelling the caller-owned scope.