ClientInterface

interface ClientInterface

A connected client: one signed-in user on one device. Every call is async. The calls take turns on the client, but a pending receive waits for mail outside that turn, so a send on the same client from another task goes through meanwhile. The Config/AccountConfig constructors below are the address layer under the `Tenant` handle, for callers that know their addresses.

Inheritors

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
abstract fun address(): Address

This client's own address.

Link copied to clipboard
abstract suspend fun attachSecureStore(store: SecureStore)

Turn on per-send rollback protection: hold store so every send and every ratchet-advancing receive commits a monotonic counter to it, and exportStateSealed binds that counter. Call once, before sending, on a client made by connect / signIn; the sealed restore constructors attach the store themselves. This is what closes EX-03's per-send window — use the same platform store across restarts so the counter is monotone.

Link copied to clipboard
abstract suspend fun exportIdentity(): ByteArray

The device identity secret, to persist and reuse via signInWithIdentity (and connectWithIdentity) on later runs. Carries a private key — store it as a secret.

Link copied to clipboard
abstract suspend fun exportState(): ByteArray

The resumable session state: the device identity, every live ratchet session with a peer this device already talks to, and the published prekey secrets. Restore it with signInWithState or connectWithState.

Link copied to clipboard
abstract suspend fun exportStateSealed(): ByteArray

The sealed resumable state (decision 0078, anchor B): the same bytes as exportState, authenticated under the attached SecureStore key so that an attacker who can rewrite the state file cannot forge the anti-rollback generation, with the store's rollback counter bound alongside. Restore with connectWithStateSealed or signInWithStateSealed. Requires attachSecureStore first (or a sealed restore, which attaches it); errors otherwise. Against a file-rewriter this refuses a forged generation and, via the per-send counter, a state older than the latest send.

Link copied to clipboard
abstract suspend fun find(username: String): Contact?

Resolve a username within this client's tenant to a contact, or None if no such user is registered. Exact resolution only.

Link copied to clipboard
abstract fun inbound(): Inbound

Inbound messages one at a time, as they arrive: see `Inbound`.

Link copied to clipboard
abstract suspend fun receive(): List<Message>

Await the next mail, then return every pending message decrypted and attributed to its sender.

Link copied to clipboard
abstract suspend fun restoreOutcome(): RestoreOutcome

What the sign-in found: whether restored sessions are in use or were discarded as a rollback; see `RestoreOutcome`.

Link copied to clipboard
abstract suspend fun send(to: Address, message: ByteArray)

Encrypt and send a message to a peer; returns once routed.