Marmot-TS
    Preparing search index...

    Class KeyPackageManager

    Manages the full lifecycle of MLS key packages — local private material and the Nostr kind-30443 events that advertise this client to potential inviters.

    Legacy kind-443 events are supported for reading and deletion only; new events are always published as kind 30443.

    Hierarchy

    Index

    Client - Key Package Manager

    clientId: string | undefined

    Default slot identifier (d tag value) used by create when no explicit d is passed in options. Set this to a stable string (e.g. "my-app-desktop") so all key packages from this manager share a single addressable slot on relays.

    • Retrieves the private key material for a key package. Used internally by MarmotClient when processing Welcome messages.

      Parameters

      • ref: string | Uint8Array<ArrayBufferLike>

        The key package reference

      Returns Promise<PrivateKeyPackage | null>

      The private key package, or null if not found

    • Marks a key package as used by setting used = true on the stored entry.

      Does nothing if no entry is found for the given ref.

      Parameters

      • ref: string | Uint8Array<ArrayBufferLike>

        The key package reference

      Returns Promise<void>

    • Completely purges one or more key packages: publishes a NIP-09 deletion for all known relay event IDs, removes local private key material, and clears the publish records.

      Parameters

      • refs: string | Uint8Array<ArrayBufferLike> | (string | Uint8Array<ArrayBufferLike>)[]

        One or more key package references (hex string or Uint8Array)

      Returns Promise<void>

    • Removes a key package from local private key storage only.

      Does not publish a relay deletion and does not touch publish records. Use when the key package was never published, or when relay cleanup has already been handled separately.

      Parameters

      • ref: string | Uint8Array<ArrayBufferLike>

        The key package reference to remove

      Returns Promise<void>

    • Rotates a key package: publishes a new kind 30443 event (reusing the same d slot so relays replace the old event automatically), then removes the old private key material.

      For legacy kind-443 published events on the entry, a NIP-09 deletion is sent before publishing the replacement. Kind-30443 published events do not need explicit deletion — the new event supersedes them on relays.

      Parameters

      • ref: string | Uint8Array<ArrayBufferLike>

        The key package reference of the key package to rotate

      • Optionaloptions: RotateKeyPackageOptions

        Options for the new key package

      Returns Promise<ListedKeyPackage>

      The new stored key package (without private material)

      if the key package ref is not found in the local store

      if no relay URLs can be determined for the new key package

    Other

    prefixed: string | boolean
    • Type Parameters

      Parameters

      Returns this

    • Return an array listing the events for which the emitter has registered listeners.

      Returns (keyof KeyPackageManagerEvents)[]

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

      Parameters

      Returns number

    • Return the listeners registered for a given event.

      Type Parameters

      Parameters

      • event: T

      Returns (
          (
              ...args: ArgumentMap<KeyPackageManagerEvents>[Extract<
                  T,
                  keyof KeyPackageManagerEvents,
              >],
          ) => void
      )[]

    • Type Parameters

      Parameters

      Returns this

    • Add a listener for a given event.

      Type Parameters

      Parameters

      Returns this

    • Add a one-time listener for a given event.

      Type Parameters

      Parameters

      Returns this

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

      Parameters

      • Optionalevent: keyof KeyPackageManagerEvents

      Returns this

    • Remove the listeners of a given event.

      Type Parameters

      Parameters

      Returns this