ReadonlyclientDefault 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.
Adds a LocalKeyPackage to local storage. Delegates to KeyPackageStore.add.
The storage key (hex ref string)
Clears all entries (local and tracked) from the store.
Returns the number of locally stored key packages.
Creates a new key package, stores the private material locally, signs and publishes a kind 30443 addressable event to the specified relays, and records the event.
The d (slot identifier) is resolved in order:
options.identifier (explicit)this.clientId (manager default)Creation options, including required relay URLs
The stored key package (without private material)
Ensures this client has at least one unused KeyPackage published, so peers
can always invite it. A no-op (returning the existing unused KeyPackage)
when one already exists; otherwise creates and publishes a fresh one to
options.relays via create. Idempotent — safe to call on every
startup.
The existing unused KeyPackage, or the freshly created one.
Retrieves the full key package from the store.
Retrieves the private key material for a key package. Used internally by MarmotClient when processing Welcome messages.
The key package reference
The private key package, or null if not found
Checks whether a key package exists in local private key storage.
Lists all locally stored key packages, each enriched with their published Nostr events.
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.
The key package reference
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.
One or more key package references (hex string or Uint8Array)
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.
The key package reference to remove
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.
Kind-30443 published events do not need explicit deletion — the new event supersedes them on relays.
The key package reference of the key package to rotate
Optionaloptions: RotateKeyPackageOptionsOptions for the new key package
The new stored key package (without private material)
Selects the locally-held key packages that could receive a given Welcome, ordered with the RFC 9420 KeyPackageRef matches first.
Filters to packages whose ciphersuite matches the Welcome and for which
local private material is held, computes whether each package's ref matches
one of the Welcome's encrypted secrets, and returns the matching packages
before the non-matching ones so GroupsManager.joinFromWelcome tries the
most likely candidate first. This is the TypeScript analog of the private
key-bundle lookup the darkmatter engine performs inside do_join_welcome.
The decoded MLS Welcome message.
Candidate key packages in priority order (may be empty).
Observes a Nostr event and, if it is a kind 30443 key package event whose
i tag (MIP-00 KeyPackageRef) matches its decoded body, records it in the
store. Events with no i tag, an undecodable body, or an i tag that does
not match the recomputed ref are rejected.
Any Nostr event; non-key-package events are silently ignored
true if the event was recorded, false if ignored or rejected
Watches for any change to key packages or their published events.
Yields the current snapshot on subscription, then re-yields on every subsequent change.
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 KeyPackageManagerEventsRemove the listeners of a given event.
Optionalfn: (Optionalcontext: anyOptionalonce: boolean
Manages the full lifecycle of MLS key packages — local private material and the Nostr kind-30443 events that advertise this client to potential inviters.
A thin coordinator over a KeyPackageStore (persistence) and a KeyPackagePublisher (the sign/publish boundary).