Marmot-TS
    Preparing search index...

    Class MarmotGroup<THistory, TMedia>

    The main class for interacting with a MLS group

    Type Parameters

    • THistory extends BaseGroupHistory | undefined = undefined

      The type of the history store to use for the group, must implement the BaseGroupHistory interface. (Default is no history store)

    • TMedia extends BaseGroupMedia | undefined = undefined

    Hierarchy

    Index

    Client - Group

    ciphersuite: CiphersuiteImpl

    The ciphersuite implementation to use for the group

    history: THistory

    The storage interface for the groups application message history

    idStr: string

    The group id as a hex string

    media: TMedia

    The storage interface for the groups media

    mediaService: GroupMediaService<TMedia>

    Optional media helper for group encrypted attachments.

    The nostr relay pool to use for the group

    runtime: GroupRuntime

    Runtime publisher for driving session effects through transport.

    Protocol state owner for this group. Prefer this over convenience methods.

    signer: EventSigner

    The signer used for the clients identity

    The key-value backend where serialized group state bytes are persisted

    • get convergenceStatus(): ConvergenceStatus

      The group's derived convergence status (group-state.md §Convergence status, B5): Syncing / Resolving / Settled / Blocked. Recomputed on read against the clock, so it advances to Settled once the quiescence window elapses with no further convergence-relevant input.

      Returns ConvergenceStatus

    • Decrypts an encrypted-media-v1 attachment downloaded from a blob store.

      On the first call for a given file the plaintext bytes are derived via key-derivation + ChaCha20-Poly1305 decryption (after verifying the ciphertext and plaintext hashes) and stored in {@link media}. Subsequent calls for the same attachment.ciphertextSha256 are served directly from the cache, skipping key-derivation entirely.

      Parameters

      Returns Promise<StoredMedia>

    • Encrypts a media file for sharing in a group message (encrypted-media-v1).

      Derives the per-file key from the current MLS epoch, encrypts with ChaCha20-Poly1305, and returns the ciphertext alongside a populated MediaAttachment (hashes, nonce, media type, filename) with no locators yet.

      Caller responsibilities:

      1. Upload encrypted to a blob store (ciphertextSha256 is the content id).
      2. Push a locator ({ kind, value }) onto attachment.locators.
      3. Serialize with encodeMediaImetaTag and include the tag on the rumor.

      Parameters

      Returns Promise<{ attachment: MediaAttachment; encrypted: Uint8Array }>

    • ingests an array of group messages and applies commits to the group state.

      Processing happens in two stages:

      1. Process all non-commit messages (proposals, application messages)
        • If a message fails to process, it's added to unreadable for retry
      2. Process commits according to MIP-03 (sorted by epoch, timestamp, event id)
        • Commits advance the epoch and update the group state

      After both stages, recursively retry unreadable messages until no more can be read. Events that can never be processed are yielded as UnreadableIngestResult.

      Parameters

      • events: NostrEvent[]

        Array of Nostr events containing encrypted MLS messages

      • Optionaloptions: { maxRetries?: number }

      Returns AsyncGenerator<DispositionedIngestResult>

      DispositionedIngestResult - The processing result plus its inbound-processing Disposition.

    • Persists any pending changes to the group state in the store.

      Parameters

      • force: boolean = false

        When true, writes the current state even if dirty is false. Useful for persisting the initial state of a freshly constructed group (e.g. after createGroup / joinGroupFromWelcome / import) without having to mutate dirty externally.

      Returns Promise<void>

    Other

    prefixed: string | boolean
    • Return an array listing the events for which the emitter has registered listeners.

      Returns (keyof MarmotGroupEvents<THistory, TMedia>)[]

    • Return the number of listeners listening to a given event.

      Parameters

      Returns number

    • Remove all listeners, or those of the specified event.

      Parameters

      • Optionalevent: keyof MarmotGroupEvents<THistory, TMedia>

      Returns this