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 method prompts the user via signer for decryption.
The gift wrap event ID to decrypt, or the gift wrap event itself
The decrypted welcome rumor, or null if failed to decrypt
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
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 'ReceivedGiftWrap' or 'receivedProcessed' events).
Watch for unread invites.
Yields the current array of unread invites, then yields again whenever the unread list changes (via 'newInvite' or 'inviteRead' events).
This does NOT automatically mark invites as read - the app must call markAsRead() after processing each invite.
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 undecrypted gift wrapsunread:<rumorId>keys hold decrypted welcome rumors