Skip to content

miniproto.session.storage.EncryptedSQLiteSessionStorage

miniproto.session.storage.EncryptedSQLiteSessionStorage

Section titled “miniproto.session.storage.EncryptedSQLiteSessionStorage”
EncryptedSQLiteSessionStorage(path: str | os.PathLike[str], key: bytes | str | None = None) -> None

Thread-safe SQLite persistence with per-domain authenticated encryption.

Encryption and MAC keys derive from supplied key material. Reads and writes run on worker threads. SQLite BEGIN IMMEDIATE serializes mutations. Legacy single-record payloads migrate to separate encrypted domains on the next replacement or mutation.

Cancelling a direct async call can leave its worker running and a write may still commit. The client storage wrapper waits for backend completion and reconciles its cache before propagating cancellation.

Open a lazy encrypted database using explicit or environment key material.

Parameters:

  • path (str | PathLike[str]) – SQLite database path created lazily on first write.
  • key (bytes | str | None) – Secret bytes/text or None to read MINIPROTO_SESSION_KEY.

Raises:

  • ValueError – If no key is supplied or its material is under 16 bytes.