import { NostrLink, type ToNostrEventTag } from "./nostr-link"; import EventKind from "./event-kind"; import { type EventSigner, type FullRelaySettings, type RelaySettings, type SystemInterface, type UserMetadata } from "."; import EventEmitter from "eventemitter3"; export interface UserStateOptions { appdataId: string; initAppdata: T; encryptAppdata: boolean; } /** * Data which can be stored locally to quickly resume the state at startup */ export interface UserStateObject { profile?: UserMetadata; follows?: Array; relays?: Array; appdata?: TAppData; } export declare enum UserStateChangeType { Profile = 0, Contacts = 1, Relays = 2, AppData = 3, MuteList = 4, GenericList = 5 } export interface UserStateEvents { change: (t: UserStateChangeType) => void; } /** * Manages a users state, mostly to improve safe syncing */ export declare class UserState extends EventEmitter { #private; readonly pubkey: string; static isInstance(obj: unknown): obj is UserState; constructor(pubkey: string, options?: Partial>, stateObj?: UserStateObject); get didInit(): boolean; destroy(): void; /** * Initialize and sync user state from Nostr relays. * This method is idempotent - calling it multiple times will only initialize once. */ init(signer: EventSigner | undefined, system: SystemInterface): Promise; get signer(): EventSigner | undefined; get version(): number; /** * Get the number of pending changes that haven't been saved to Nostr yet */ get pendingChanges(): number; /** * Users profile */ get profile(): UserMetadata | undefined; /** * Users configured relays */ get relays(): FullRelaySettings[] | undefined; /** * Followed pubkeys */ get follows(): string[] | undefined; /** * App specific data */ get appdata(): TAppData | undefined; /** * Get the standard mute list */ get muted(): ToNostrEventTag[]; /** * Follow a user */ follow(link: NostrLink): void; /** * Unfollow a user */ unfollow(link: NostrLink): void; /** * Replace the entire follow list */ replaceFollows(links: Array): void; /** * Save all pending contact list changes to Nostr */ saveContacts(): Promise; /** * Save all pending changes (contacts + relays + app data + all lists) to Nostr * This is a convenience method for saving everything at once */ saveAll(): Promise; /** * Add a relay to the relay list */ addRelay(addr: string, settings: RelaySettings): void; /** * Remove a relay from the relay list */ removeRelay(addr: string): void; /** * Update relay settings */ updateRelay(addr: string, settings: RelaySettings): void; /** * Save all pending relay changes to Nostr */ saveRelays(): Promise; /** * Update app-specific data locally without saving to Nostr * Call saveAppData() to persist changes */ setAppData(data: TAppData): void; /** * Save pending app data changes to Nostr */ saveAppData(): Promise; /** * Add an item to a list * @param kind List kind (must be 10000-19999 range for standard lists) * @param links Tag(s) to add * @param encrypted Whether the tag should be encrypted in the content */ addToList(kind: EventKind, links: ToNostrEventTag | Array, encrypted?: boolean): void; /** * Remove an item from a list * @param kind List kind (must be 10000-19999 range for standard lists) * @param links Tag(s) to remove * @param encrypted Whether the tag is encrypted in the content */ removeFromList(kind: EventKind, links: ToNostrEventTag | Array, encrypted?: boolean): void; /** * Save pending changes to a specific list */ saveList(kind: EventKind, content?: string): Promise; /** * Mute a user, event, or other item (added to encrypted mute list) */ mute(link: NostrLink): void; /** * Unmute a user, event, or other item (removed from encrypted mute list) */ unmute(link: NostrLink): void; isOnList(kind: EventKind, link: ToNostrEventTag): boolean; getList(kind: EventKind): Array; serialize(): UserStateObject; checkIsStandardList(kind: EventKind): void; } //# sourceMappingURL=user-state.d.ts.map