Marmot-TS
    Preparing search index...

    Class MarmotClient<THistory, TMedia>

    Type Parameters

    Index
    capabilities: Capabilities

    The capabilities to use for the client

    cryptoProvider: CryptoProvider

    Crypto provider for cryptographic operations

    Manages group lifecycle: persistence, caching, creation, loading, leaving

    ingestPersistence: IngestPersistenceCapability
    invites: InviteManager

    Manages invite lifecycle: ingestion, decryption, and storage

    keyPackages: KeyPackageManager

    Manages key package lifecycle: local storage, publishing, and rotation

    The nostr relay pool to use for the client

    signer: EventSigner

    The signer used for the clients identity

    • Whether we still hold the private KeyPackage a Welcome is addressed to — i.e. whether joinGroupFromWelcome can succeed for this invite. Accepting an invite whose KeyPackage we no longer hold (e.g. it rotated away) would fail with "No matching KeyPackage found". Never throws: an unparseable Welcome yields false.

      Parameters

      Returns Promise<boolean>

    • Joins a group from a Welcome message received via NIP-59 gift wrap.

      This method:

      1. Decodes the Welcome message from the kind 444 event
      2. Finds the matching local KeyPackage private material from the store
      3. Calls ts-mls joinGroup() to create a new ClientState
      4. Persists the resulting ClientState via this.groups.adoptClientState()
      5. Finalizes a durable consumption receipt: retires single-use private material and retains reusable packages marked as used
      6. Returns a MarmotGroup instance

      After joining, callers can list used key packages with (await client.keyPackages.list()).filter(p => p.used) and rotate them via client.keyPackages.rotate(ref) to publish fresh ones to relays.

      Parameters

      • options: { welcomeRumor: Rumor }
        • welcomeRumor: Rumor

          The unwrapped kind 444 rumor event containing the Welcome message

      Returns Promise<{ group: MarmotGroup<THistory, TMedia> }>

      Promise resolving to the joined group

      Error if no matching KeyPackage is found or if joining fails

    • Decodes everything showable about an invite before committing to join. Rumor-level fields (relays, KeyPackage event id, cipher suite, recipient count) decode without key material; the group block requires decrypting the Welcome with a held KeyPackage via readInviteGroupInfo and is null when we don't hold it. Never throws — a malformed Welcome or failed preview just yields the fields it could read.

      Parameters

      Returns Promise<WelcomePreview>

    • Reads the GroupInfo from a Welcome rumor without joining the group.

      Finds the local key package that matches one of the welcome's recipient slots, then decrypts the group info using that key package. Useful for previewing group metadata (name, relays, admins) before deciding to join.

      Parameters

      • welcomeRumor: Rumor | Welcome

        The decrypted kind 444 welcome rumor

      Returns Promise<GroupInfo | null>

      The decrypted GroupInfo, or null if no matching key package is found or decryption fails

    • Like InviteManager.watchUnread, but annotates each invite with whether it's joinable. Lets an app default to showing only acceptable invites while still being able to reveal the rest.

      Pass an AbortSignal to stop watching. Abort, return, throw, and async disposal release listeners and interrupt pending reads without another event. Abandoned reads may finish internally; their results are ignored.

      Parameters

      • options: { signal?: AbortSignal } = {}

      Returns AsyncGenerator<AnnotatedInvite[]>