Skip to content

3.2.0

Choose a tag to compare

@ioannisa ioannisa released this 06 Sep 20:35
· 25 commits to main since this release

Same call, no by: ksafe(default, key) now hands you a KSafeReference you can keep, pass around, and read or write through .value. Around fifty durability fixes underneath. Drop-in upgrade: existing data is untouched, nothing migrates.

implementation("eu.anifantakis:ksafe:3.2.0")
implementation("eu.anifantakis:ksafe-compose:3.2.0")     // optional
implementation("eu.anifantakis:ksafe-biometrics:3.2.0")  // optional

New

  • KSafeReference — direct access without property delegation. The call that backs by now returns a handle. Own section below. 👇
  • Two KSafe instances on one file now behave like one store (Android, iOS/macOS, JVM Desktop): a write, a clearAll() or a rotateKeys() through one instance is seen by every other live instance on that file.
  • A link-failed OS key vault on JVM Desktop no longer bricks the store. It degrades to the software vault and keeps working; keys minted meanwhile are provisional and yield to the OS key when it returns. 📖 docs/JVM_PROTECTION.md
  • Android API 28–34 without a lock screen: a requireUnlockedDevice write now succeeds with the unlock binding relaxed instead of failing, disclosed as android_lock_screen_absent in protectionInfo.notes. 📖 docs/PROTECTION_INFO.md

KSafeReference: ksafe(default, key) without by

So far there was only property delegation:

var counter by ksafe(0)
counter++

The same call, given an explicit key, now returns a handle you can hold in a val, hand to a class, and read or write through .value:

val counter = ksafe(0, key = "counter")   // KSafeReference<Int>
counter.value++

It works on the mode-typed views too — ksafe.plain(0, key = "theme"), vault("", key = "pin") — with their frozen write mode. value reads through the same hot cache as the delegate and writes fire-and-forget with the KSafeWriteMode captured when the handle was created. Delegate behaviour is unchanged; both forms share one store and one cache, so you can mix them freely.

Three honest boundaries:

  • The key is required for .value. A plain = carries no property name, so a key-less handle stays delegate-only and .value on it throws IllegalStateException.
  • The deprecated encrypted: Boolean overload still returns the delegate type — move it to mode first.
  • Don't read .value in composition. No snapshot state sits behind the handle, so a composable would not recompose; use :ksafe-compose or asStateFlow().collectAsState().

📖 docs/USAGE.md

Changed

  • kotlinx-coroutines-core and compose-runtime are now api dependencies. They were in the public surface all along; you now get them transitively.
  • rememberKSafeState is inline: its failed-write rollback fix reaches a call site only once that module is recompiled against 3.2.0.
  • protectionInfo on Android now performs one blocking store read per process on a device with a secure lock screen (API 35+ included) — read it off the main thread.
  • The Android public API now has an ABI baseline that apiCheck enforces.

Fixes

Around fifty; the ones you would notice:

  • Android: a transient Keystore fault no longer destroys every encrypted value — only a fault the Keystore proves permanent re-mints a key (Android 13+). iOS/macOS: a Secure Enclave unwrap failure no longer downgrades an alias to a plain Keychain key.
  • All platforms: a write at the edge of the coalesce window can no longer be lost; a failed clearAll() leaves the store exactly as it was; a cold read racing the startup sweep can no longer resurrect a swept entry; close() waits for a write already in flight.
  • Biometrics: a stopped Android Activity no longer hangs the prompt, a cancelled prompt stays cancelled, an empty reason no longer terminates the process, and a desktop bridge that fails to load no longer opens a strict gate.
  • Compose: rememberKSafeState no longer rewinds to the startup value after a failed write, and the cold-start self-heal no longer overwrites text the user is typing.
  • JVM appNamespace: clearAll() is no longer undone by the next launch; Windows symlinks and transient file locks are handled.
  • Web: losing IndexedDB no longer strands ciphertext forever; lazyLoad = true no longer makes every non-suspend read return its default.

Known, fixed in 3.2.1

  • JVM: a namespaced store whose one-time carry-forward copy fails runs on the shared un-namespaced store for that session (a warning is printed), so its clearAll() clears that store.
  • JVM: a key minted while the OS vault could not link can take an alias whose real OS key still sits under an older vault namespace.
  • Android: the android_lock_screen_absent note can outlive the relaxed key after an Auto Backup restore — rotateKeys() clears it.
  • JVM Desktop: a permissive biometric call that passes through because Windows Hello is unavailable still seeds the authorization cache.

Details: CHANGELOG.md

Full Changelog: 3.1.0...3.2.0