The type of the history store to use for the group, must implement the BaseGroupHistory interface. (Default is no history store)
The type of the history store to use for the group, must implement the BaseGroupHistory interface. (Default is no history store)
ReadonlyciphersuiteThe ciphersuite implementation to use for the group
Whether group state has been modified
ReadonlyhistoryThe storage interface for the groups application message history
The group id as a hex string
ReadonlymediaThe storage interface for the groups media
ReadonlynetworkThe nostr relay pool to use for the group
ReadonlysignerThe signer used for the clients identity
ReadonlystoreThe key-value backend where serialized group state bytes are persisted
Read the current group state
Creates a commit from proposals and sends it to the group.
Proposal sources (can be combined):
extraProposals — inline Proposal values and/or ProposalAction
factories (each factory receives ProposalContext).proposalRefs — keys into state.unappliedProposals for proposals already
held in state.If extraProposals or proposalRefs is present on options (including as
an empty array), the commit uses exactly the merged, resolved list in array order
(extraProposals first, then each ref in proposalRefs). Two empty arrays means a
no-proposal commit. If neither property is set, the MLS layer commits every proposal
currently in state.unappliedProposals.
Requires a group admin. Publishes the commit to group relays and updates local state
after an ACK. When MLS returns a welcome and welcomeRecipients is non-empty,
sends gift-wrapped Welcome rumors (only after the commit ACK, per MIP-02).
Optionaloptions: {OptionalextraProposals?: (Proposal | ProposalAction<Proposal> | (Proposal | ProposalAction<Proposal>)[])[]Flattened in order; function entries are async factories;
resolved proposals are ordered before any from proposalRefs.
OptionalproposalRefs?: string[]Lookup keys on state.unappliedProposals; an unknown key throws.
OptionalwelcomeRecipients?: WelcomeRecipient[]Per-recipient key-package metadata for MLS Welcome delivery after adds; see WelcomeRecipient.
Per-relay publish responses for the commit group event
Decrypts a MIP-04 v2 media attachment downloaded from Blossom.
On the first call for a given file the plaintext bytes are derived via
key-derivation + ChaCha20-Poly1305 decryption and stored in
{@link media}. Subsequent calls for the same attachment.sha256
are served directly from the cache, skipping key-derivation entirely.
Destroys the group and purges the group history
Encrypts a media file for sharing in a group message (MIP-04 v2).
Derives the per-file key from the current MLS epoch, encrypts with
ChaCha20-Poly1305, and returns the ciphertext alongside a fully
populated MediaAttachment ready to be serialised into an
imeta tag via createImetaTagForAttachment from applesauce.
Caller responsibilities:
encrypted to Blossom (or any content-addressed store).attachment.url to the resulting upload URL.attachment (with url) to createImetaTagForAttachment and
include the resulting tag on the group message rumor.ingests an array of group messages and applies commits to the group state.
Processing happens in two stages:
After both stages, recursively retry unreadable messages until no more can be read. Events that can never be processed are yielded as UnreadableIngestResult.
Array of Nostr events containing encrypted MLS messages
Optionaloptions: {Optional Internal_errors?: { error: unknown; eventId: string }[]Flat list of { eventId, error } entries accumulated across
all retry rounds. Passed by reference so every recursive call appends
to the same array, giving the final unreadable yield the full history.
OptionalmaxRetries?: numberMaximum number of retry attempts (default: 5)
OptionalretryCount?: numberCurrent retry attempt count (internal use)
Invites a user to the group using their KeyPackage event (kind 443).
This method:
The KeyPackage event (kind 443 or kind 30443) for the user to invite
Promise resolving to the publish response from the relays
Leaves the group by publishing a self-remove proposal for each of the caller's leaf nodes, then purging all local group data from storage.
Per RFC 9420 §12.4 a member cannot commit a Remove targeting their own leaf. Instead, a Remove proposal is sent so that the next committer (e.g. an admin calling commit) can include it and finalise the departure. At least one relay must acknowledge the proposals before local state is destroyed; if no relay acks, an error is thrown and local state is preserved so the caller can retry.
Unlike commit, this operation is allowed for non-admin members.
The relay publish responses for the leave proposal event(s).
Creates and publishes a proposal as a private MLS message.
Promise resolving to the publish response from the relays
Creates and publishes a proposal as a private MLS message.
Promise resolving to the publish response from the relays
Persists any pending changes to the group state in the store.
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.
Performs a self-update commit (no proposals) to rotate this member's leaf key material.
This is required by MIP-02 for forward secrecy after joining from a Welcome.
Unlike commit, this operation is allowed for non-admin members.
Creates and sends an application message to the group.
Application messages contain actual content shared within the group (e.g., chat messages, reactions, etc.). The inner Nostr event (rumor) must be unsigned and will be serialized according to the Marmot spec.
The unsigned Nostr event (rumor) to send as an application message
Promise resolving to the publish response from the relays
Creates and sends a kind 9 chat message to the group.
This is a convenience wrapper around sendApplicationRumor that constructs the rumor for you. The message is encrypted via MLS and published as a kind 445 group event to the group's relays.
The text content of the chat message
Optional Nostr tags to include on the rumor
Promise resolving to the publish response from the relays
Sends a proposal to the group relays
StaticfromCreates a new MarmotGroup instance from a ClientState object
StaticprefixedOptionalcontext: anyCalls each of the listeners registered for a given event.
Return an array listing the events for which the emitter has registered listeners.
Return the number of listeners listening to a given event.
Return the listeners registered for a given event.
Optionalfn: (Optionalcontext: anyOptionalonce: booleanAdd a listener for a given event.
Optionalcontext: anyAdd a one-time listener for a given event.
Optionalcontext: anyRemove all listeners, or those of the specified event.
Optionalevent: keyof MarmotGroupEvents<THistory, TMedia>Remove the listeners of a given event.
Optionalfn: (Optionalcontext: anyOptionalonce: boolean
The main class for interacting with a MLS group