Skip to content

SqlEventLogServerEncrypted

Stores encrypted event-log server state in SQL.

This module provides the durable Storage implementation used by EventLogServerEncrypted when entries should be stored without exposing plaintext event data to the database. It persists the server remote id, session authentication bindings, and encrypted entry tables, assigns stable sequence numbers, and streams changes. Clients remain responsible for encrypting writes and decrypting reads.

3 exports Added in v4.0.0 Source

Constructors

makeStorage

Added in v4.0.0 Source

Creates encrypted event-log server Storage backed by SQL.

Details

It persists the server remote id, session authentication bindings, and encrypted entries in dialect-specific tables, creating per-identity/store entry tables as needed.

Signature

declare function makeStorage(options?: {
  readonly entryTablePrefix?: string;
  readonly insertBatchSize?: number;
  readonly remoteIdTable?: string;
}): Effect<{
  readonly changes: (publicKey: string, storeId: StoreId, startSequence: number) => Stream<EncryptedRemoteEntry>;
  readonly getId: Effect<RemoteId>;
  readonly getOrCreateSessionAuthBinding: (publicKey: string, signingPublicKey: Uint8Array<ArrayBuffer>) => Effect<Uint8Array<ArrayBuffer>>;
  readonly write: (publicKey: string, storeId: StoreId, entries: readonly Array<PersistedEntry>) => Effect<readonly Array<EncryptedRemoteEntry>>;
}, SqlError, Scope | SqlClient | EventLogEncryption>

Layers

layerStorage

Added in v4.0.0 Source

Provides encrypted server Storage using the SQL-backed implementation.

Signature

declare function layerStorage(options?: {
  readonly entryTablePrefix?: string;
  readonly insertBatchSize?: number;
  readonly remoteIdTable?: string;
}): Layer<Storage, SqlError, SqlClient | EventLogEncryption>;

Provides SQL-backed encrypted server Storage and supplies the default Web Crypto EventLogEncryption layer.

Signature

declare function layerStorageSubtle(options?: {
  readonly entryTablePrefix?: string;
  readonly insertBatchSize?: number;
  readonly remoteIdTable?: string;
}): Layer<Storage, SqlError, SqlClient>;