Marmot-TS
    Preparing search index...

    Class GroupsManager<THistory, TMedia>

    Orchestrates the lifecycle of MarmotGroup instances. Delegates in-memory caching and store hydration to a GroupRegistry and group construction to a GroupFactory, layering the public lifecycle events (created/imported/joined/destroyed/left) and the send/ingest facade on top.

    Type Parameters

    Hierarchy

    Index

    Client - Group Manager

    accountProofSigner?: AccountIdentityProofSigner

    Signs the account identity proof on the group creator's own leaf

    cryptoProvider: CryptoProvider

    Crypto provider for cryptographic operations

    The nostr relay pool to use for the client

    signer: EventSigner

    The signer used for the clients identity

    The backend storing serialized group state bytes

    • Creates a commit from proposals and publishes it to the group.

      Resolves the committing member from the manager's signer, builds a commit intent, and drives it through the group session/runtime. See GroupSessionSendIntent for how extraProposals, proposalRefs, and welcomeRecipients are interpreted. Requires a group admin.

      Parameters

      • groupId: string | Uint8Array<ArrayBufferLike>
      • Optionaloptions: Omit<
            {
                actorPubkey: string;
                extraProposals?: (
                    | Proposal
                    | ProposalAction<Proposal>
                    | (Proposal | ProposalAction<Proposal>)[]
                )[];
                kind: "commit";
                proposalRefs?: string[];
                welcomeRecipients?: WelcomeRecipient[];
            },
            "kind"
            | "actorPubkey",
        >

      Returns Promise<Record<string, PublishResponse>>

      Per-relay publish responses for the commit group event.

    • Connects a single group to its relays: backfills its kind-445 transport events (by #h routing tag) and drains them through MarmotGroup.ingest, then opens a live subscription that ingests each subsequent event. Inbound events are de-duplicated, and unreadable ones surface via the unreadable event. Call .unsubscribe() on the result to disconnect.

      This is the inbound counterpart to the library's outbound publishing — the relay-subscription/backfill/drain loop an app would otherwise hand-write.

      Parameters

      • groupId: string | Uint8Array<ArrayBufferLike>
      • Optionaloptions: ConnectOptions

      Returns Promise<Unsubscribable>

    • Invites a user to a group from their KeyPackage event (kind 30443).

      Resolves the committing member from the manager's signer, builds an Add commit intent via createInviteIntent, and drives it through the group session/runtime. After the commit acks, the runtime delivers a Welcome to the invitee via NIP-59 gift wrap.

      Parameters

      • groupId: string | Uint8Array<ArrayBufferLike>
      • keyPackageEvent: NostrEvent

      Returns Promise<Record<string, PublishResponse>>

      Per-relay publish responses for the commit group event.

      Error if the event is not a KeyPackage kind or the credential identity does not match the event author.

    • Joins a group from a decoded MLS Welcome using locally held key package candidates (produced by KeyPackageManager.selectForWelcome).

      Mirrors the darkmatter engine do_join_welcome: the KeyPackageRef→private bundle match and the MLS join happen here, in the group layer, not in the composition root. Tries candidates in priority order, validates every leaf carries a valid account identity proof, then adopts the resulting state and emits joined.

      Parameters

      Returns Promise<
          {
              consumedKeyPackageRef: Uint8Array<ArrayBufferLike>
              | null;
              group: MarmotGroup<THistory, TMedia>;
          },
      >

      The joined group and the KeyPackageRef that was consumed (so the caller can mark it used), or consumedKeyPackageRef: null if none matched.

    • Leaves a group by publishing a self-remove proposal and purging all local group data from storage.

      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.

      Parameters

      • groupId: string | Uint8Array<ArrayBufferLike>

        The group ID as a hex string or Uint8Array.

      Returns Promise<Record<string, PublishResponse>>

      The relay publish responses for the leave proposal event(s).

    Other

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

      Returns (keyof GroupsManagerEvents<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 GroupsManagerEvents<THistory, TMedia>

      Returns this