SecureVault

interface SecureVault

A small, coroutine-first façade over the platform's native secure storage:

  • AndroidEncryptedSharedPreferences backed by an Android Keystore master key (AES-256 GCM for values, AES-256 SIV for keys).

  • iOS — Keychain Services (kSecClassGenericPassword).

Instances are obtained from SecureVaultFactory and are safe to share across coroutines. All suspending functions are I/O bound and dispatch onto an appropriate background dispatcher; callers do not need to switch contexts.

Every method that interacts with the backend declares VaultException; callers should treat any other Throwable as a programming error.

Since

0.1.0

Types

Link copied to clipboard
object Companion

Companion namespace for platform-specific initialisation hooks.

Functions

Link copied to clipboard
abstract suspend fun clear()

Removes every entry inside this vault's namespace.

Link copied to clipboard
abstract suspend fun contains(key: String): Boolean

Returns true iff a value is currently stored under key.

Link copied to clipboard
abstract suspend fun get(key: String): String?

Returns the value previously stored under key, or null if absent.

Link copied to clipboard
abstract suspend fun keys(): Set<String>

Returns a snapshot of every key currently stored in this vault's namespace.

Link copied to clipboard
abstract fun observe(key: String): Flow<String?>

Returns a cold Flow that emits the current value of key and then re-emits whenever that key is written, removed, or the vault is cleared.

Link copied to clipboard
abstract fun observeKeys(): Flow<Set<String>>

Returns a cold Flow that emits the current key set and then re-emits a fresh snapshot whenever the set changes (write of a new key, remove, or clear).

Link copied to clipboard
abstract suspend fun put(key: String, value: String)

Stores value under key, overwriting any previous value.

Link copied to clipboard
abstract suspend fun remove(key: String)

Removes the entry associated with key. No-op if absent.