Skip to main content

Secure sessions

SecureSessionStorage is a drop-in, encrypted-at-rest alternative to HiveSessionStorage with the same API and the same JSON wire shape — back it with flutter_secure_storage when conversations may carry PII.

import 'package:koel/koel.dart' show KoelClient;
import 'package:koel_flutter/koel_flutter.dart' show SecureSessionStorage;

final client = KoelClient(
agent: myAgent,
sessionStorage: SecureSessionStorage(), // or inject a tuned instance
);

Save and resume are identical to Persist sessionspersist(), load(), clear(), and seeding a resumed session via initial. A state written by Hive can be read by the secure store and vice versa: one wire shape across all three storages.

Namespacing

Keys are namespaced under a reserved koel_session. prefix. If you inject a FlutterSecureStorage that also holds your app's own secrets, koel enumerates and deletes only its own keys — reserved cuts both ways, so do not store your own keys under that prefix.

Platform setup is yours

Unlike Hive there is no koel-side init; what secure storage needs is platform setup:

PlatformBacking storeYou must
iOS / macOSKeychainAdd the Keychain Sharing entitlement; mind accessibility before first unlock.
AndroidKeyStoreminSdkVersion 23; disable auto-backup for the keys.
WebWebCrypto over localStorageHTTPS or localhost only. Not hardware-backed.
WindowsDPAPIShip the VC++ build tools at build time.
LinuxlibsecretRequires an active keyring (GNOME Keyring, KDE Wallet, …).

See the flutter_secure_storage docs for per-platform options.