VaultState

sealed interface VaultState

Lifecycle of a process-wide SecureVault, surfaced as state your Compose UI is expected to render explicitly.

Why a state machine? Both Android (Keystore handshake) and iOS (Keychain cold start) can do tens to thousands of milliseconds of work the first time a vault is touched, and can fail terminally (e.g. Keystore wipe after a factory reset). Surfacing those as distinct UI states — rather than hiding them behind an optimistic "always Ready" view — is the difference between a polished app and one that races against itself on cold start.

Get one via rememberSecureVault; render via:

when (val s = state) {
VaultState.Initializing -> SplashScreen()
is VaultState.Failed -> ErrorScreen(s.reason)
is VaultState.Ready -> ProvideSecureVault(s.vault) { HomeScreen() }
}

Since

0.1.0

Inheritors

Types

Link copied to clipboard
data class Failed(val reason: String) : VaultState

Backend rejected the handshake (e.g. Keystore wipe). Terminal for this process — reason is a short, log-friendly string. Recovering usually means reinstalling the app or clearing its data.

Link copied to clipboard
data object Initializing : VaultState

Pre-warm in progress on a background dispatcher. Show a splash.

Link copied to clipboard
data class Ready(val vault: <Error class: unknown class>) : VaultState

Vault is usable. Stable: a Ready instance is never reset back to Initializing.