MainViewModel

open class MainViewModel(defaultRepository: ERROR CLASS: Symbol not found for DefaultRepository, credentialStorage: CredentialStorage, settings: ERROR CLASS: Symbol not found for Settings, dispatchers: DispatcherProvider, sampleConfig: SampleConfig) : <ERROR CLASS> ERROR CLASS: Symbol not found for ViewModel

ViewModel that bootstraps authentication on first launch.

Responsible for the one-time credential provisioning sequence:

  1. Check/create API user — verifies the sandbox user exists; creates it if not.

  2. Create API key — skipped if one is already stored in CredentialStorage.

  3. Fetch access token — skipped if a non-expired token is already stored.

  4. Fetch OAuth2 token — skipped if a non-expired token is already stored.

All credentials are written to CredentialStorage (EncryptedSharedPreferences) and then read back on every SDK request via io.rekast.sdk.network.interfaces.CredentialProvider. Expired tokens are refreshed automatically by io.rekast.sdk.app.network.TokenAuthenticator on 401 — no manual re-bootstrap is needed after first launch.

Each step uses a cold kotlinx.coroutines.flow.Flow from io.rekast.sdk.repository.DefaultRepository. Flows emit io.rekast.sdk.repository.data.NetworkResult.Loading first, then a terminal io.rekast.sdk.repository.data.NetworkResult.Success or io.rekast.sdk.repository.data.NetworkResult.Error.

isBootstrapComplete is a StateFlow that becomes true when the bootstrap chain terminates — either because all steps succeeded or because a step failed with no further retry. Observers (such as io.rekast.sdk.sample.views.home.HomeScreenFragment) should wait for the first true emission before making API calls, ensuring they never race against credential provisioning.

Constructors

Link copied to clipboard
constructor(defaultRepository: ERROR CLASS: Symbol not found for DefaultRepository, credentialStorage: CredentialStorage, settings: ERROR CLASS: Symbol not found for Settings, dispatchers: DispatcherProvider, sampleConfig: SampleConfig)

Properties

Link copied to clipboard
val isBootstrapComplete: ERROR CLASS: Symbol not found for StateFlow<kotlin/Boolean>

Becomes true when the bootstrap chain initiated by checkUser reaches any terminal state — success or failure. Reset to false at the start of each checkUser call.

Functions

Link copied to clipboard

Initiates a backchannel (CIBA) authorization request and stores the resulting auth_req_id and loginHint for use by getOauthAccessToken.

Link copied to clipboard
fun checkUser()

Checks whether the API user exists and, if not, creates it — then advances to createApiKey.