Clear all stored invites (received and unread).
Note: This does NOT clear the seen index to maintain deduplication history. If you need to clear seen events, use clearSeen() or create a fresh store.
Clear the seen event IDs. Warning: This will allow previously processed events to be re-ingested.
Process a single received (undecrypted) gift wrap by event ID.
Attempts to decrypt and parse the specified event.
This is an explicit retry, which may prompt the signer again. A journaled rumor is resumed without prompting or emitting a duplicate 'decrypted' event.
The gift wrap event ID to decrypt, or the gift wrap event itself
A newly persisted unread rumor, or null on failure/already delivered
Decrypts all received gift wraps.
Attempts to decrypt and parse each received gift wrap.
This method prompts the user via signer for each decryption, so it should be called deliberately by the app (not automatically).
Array of successfully decrypted welcome rumors
Get all received (encrypted) invites.
Array of received invites awaiting decryption
Ingest a gift wrap event (kind 1059).
The event is checked against the seen index for deduplication. If new, it's stored in the 'received' state awaiting decryption.
Gift wrap event (kind 1059)
true if event was new and stored, false if already seen
Ingest multiple gift wrap events in batch.
Array of gift wrap events
Count of new events stored
Subscribes for gift-wrapped invites (kind 1059) addressed to this account on
the given relays — the inbound counterpart the app would otherwise hand-wire.
Each new gift wrap is ingested (de-duplicated) and then
decrypted, so watchUnread / the decrypted event
update on their own. Previously unattempted gift wraps are tried once on
start. Failed/interrupted attempts require an explicit decrypt call, even
after reconnect or restart; journaled transitions resume without prompting.
Call .unsubscribe() on the result to stop listening.
relays should be the account's advertised kind-10050 inbox relays — where
inviters deliver Welcomes. Subscribing elsewhere silently misses invites.
Mark an invite as read and remove it from storage.
Emits 'inviteRead' event after removal.
The rumor ID (from the welcome rumor)
Watch for received (encrypted) invites.
Yields the current list of received gift wraps, then yields again whenever the received list changes (via 'received' or 'processed' events).
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.
Watch for unread invites.
Yields the current array of unread invites, then yields again whenever the unread list changes or a recovery confirms persisted unread.
This does NOT automatically mark invites as read - the app must call markAsRead() after processing each invite.
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.
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 InviteManagerEventsRemove the listeners of a given event.
Optionalfn: (Optionalcontext: anyOptionalonce: boolean
InviteManager orchestrates the lifecycle of reading Welcome invites.
It takes gift-wrapped events from the app, handles decryption/parsing, persists invites to storage, and provides interfaces for consumption.
The app is responsible for:
State lifecycle:
Store layout:
__seenkey holds a serialized set of all seen event IDsreceived:<eventId>keys hold gift wraps and optional retry/transition stateunread:<rumorId>keys hold decrypted welcome rumors