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, current KeyPackage published,
so peers can always invite it. A no-op (returning the existing unused
current KeyPackage) when one already exists; otherwise creates and
publishes a fresh one to options.relays via create. Idempotent —
safe to call on every startup.
Stored entries flagged nonCurrent (D-09) — for example a KeyPackage
published by a pre-v2 release that lacks a valid 0x8009 proof — are
skipped and left stored as-is; nothing is deleted and no relay deletion
event is published. Their kind-30443 events therefore stay discoverable on
relays, and a peer's invite that picks one will fail, until purge
publishes a NIP-09 deletion for them — call it explicitly when migrating.
The existing unused current 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. Entries lacking a valid current account identity proof
(0x8009) carry nonCurrent: true (D-09) — see ensurePublished.
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: RotateKeyPackageOptions
Options 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 that
passes the trust boundary (SEC-01/WIRE-01/WIRE-02), records it in the
store. Non-key-package events are silently ignored. Events that fail the
boundary — invalid signature, non-singleton/invalid d/i/
mls_protocol_version, an over-long or not-current KeyPackage Lifetime,
an undecodable body, or an i tag that does not match the recomputed
ref — are rejected: a rejected event is emitted with a typed
RejectReason (except for the last two, which the underlying
KeyPackageStore.addPublished chokepoint throws on and this
method converts to a false return without an emit).
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).