Per-channel session — owns the monotonic sequence counter and applies the four invariants from §8.3.3 / §8.12 on every message:

  1. signature verifies under sender's CCI key
  2. sender ∈ members (CH-1)
  3. sequence is monotonic per channel (anti-replay)
  4. channelId matches the session's channelId

A single counter is shared across senders, as the brief specifies (sequence: number // monotonic per channel, starts at 1). Outgoing messages get current + 1; incoming messages must use a sequence strictly greater than every value already seen.

Constructors

Properties

channelId: string
me: `${string}:${string}`
members: readonly `${string}:${string}`[]

Methods

  • Register the channelId (CH-6) and prepare for messaging. Idempotent within a session — calling twice throws via the registry.

    Returns Promise<void>

  • Validate an incoming ChannelMessage. Throws with a precise reason on any failure — caller should treat throw as channel-fatal per §8.12 (a single tampered message invalidates the session's record).

    Parameters

    Returns Promise<void>

  • Build, sign, append-to-local-transcript, and return the next outgoing ChannelMessage. Sequence is highestSeen + 1 so it is monotonic across both directions.

    Parameters

    • opts: {
          body: unknown;
          repliesTo?: number;
          sentAt?: number;
          type: ChannelMessageType;
      }

    Returns Promise<ChannelMessage>