import { AppKeys, type DeviceEntry } from "./AppKeys"; import { AppKeysManager, DelegateManager } from "./AppKeysManager"; import { Invite } from "./Invite"; import { GroupManager, type GroupData, type GroupDecryptedEvent } from "./Group"; import { type DeviceRegistrationState, type SessionUserRecordsLike } from "./multiDevice"; import { SessionManager, type AcceptInviteOptions, type AcceptInviteResult, type OnEventCallback, type QueuedMessageDiagnostic, type SendMessageOptions } from "./SessionManager"; import { type StorageAdapter } from "./StorageAdapter"; import { type ChatSettingsPayloadV1, type ExpirationOptions, type NostrFetch, type NostrPublish, type NostrSubscribe, type ReceiptType, type Rumor, type Unsubscribe } from "./types"; import { type VerifiedEvent } from "nostr-tools"; import { type RuntimeGroupEvent, type SendGroupEventOptions } from "./RuntimeGroupController"; export type { QueuedMessageDiagnostic } from "./SessionManager"; export type { RuntimeGroupEvent, SendGroupEventOptions } from "./RuntimeGroupController"; export interface NdrRuntimeOptions { nostrSubscribe: NostrSubscribe; nostrPublish: NostrPublish; nostrFetch?: NostrFetch; storage?: StorageAdapter; sessionStorage?: StorageAdapter; groupStorage?: StorageAdapter; ownerIdentityKey?: Uint8Array; appKeysFetchTimeoutMs?: number; appKeysFastTimeoutMs?: number; } export interface NdrRuntimeState extends DeviceRegistrationState { ownerPubkey: string | null; currentDevicePubkey: string | null; registeredDevices: DeviceEntry[]; hasLocalAppKeys: boolean; lastAppKeysCreatedAt: number; appKeysManagerReady: boolean; delegateManagerReady: boolean; sessionManagerReady: boolean; groupManagerReady: boolean; appKeysSubscriptionActive: boolean; } export interface PrepareRegistrationOptions { ownerPubkey: string; timeoutMs?: number; deviceLabel?: string; clientLabel?: string; } export interface PrepareRegistrationForIdentityOptions extends PrepareRegistrationOptions { identityPubkey: string; } export interface PreparedRegistration { appKeys: AppKeys; devices: DeviceEntry[]; baseDevices: DeviceEntry[]; newDeviceIdentity: string; } export interface PublishPreparedRegistrationResult { createdAt: number; relayConfirmationRequired: boolean; } export interface PrepareRevocationOptions { ownerPubkey: string; identityPubkey: string; timeoutMs?: number; } export interface PreparedRevocation { appKeys: AppKeys; devices: DeviceEntry[]; revokedIdentity: string; } export interface RegisterCurrentDeviceOptions extends PrepareRegistrationOptions { } export interface RegisterDeviceIdentityOptions extends PrepareRegistrationForIdentityOptions { } export interface RevokeDeviceOptions extends PrepareRevocationOptions { } export declare class NdrRuntime { private readonly nostrSubscribe; private readonly nostrPublish; private readonly nostrFetch?; private readonly storage; private readonly sessionStorage; private readonly groupStorage; private readonly groupController; private readonly ownerIdentityKey?; private readonly appKeysFetchTimeoutMs; private readonly appKeysFastTimeoutMs; private appKeysManager; private delegateManager; private sessionManager; private appKeysInitPromise; private delegateInitPromise; private sessionManagerInitPromise; private appKeysSubscriptionCleanup; private appKeysSubscriptionOwnerPubkey; private directMessageSubscriptionCleanup; private directMessageSubscriptionAuthors; private directMessageSubscriptionLastChangeMs; private directMessageSubscriptionThrottleTimer; private messagePushAuthorCleanup; private sessionManagerEventsAvailableCleanup; private sessionManagerEventFlushPromise; private readonly sessionManagerEmittedSubscriptions; private readonly stateListeners; private readonly sessionEventCallbacks; private state; constructor(options: NdrRuntimeOptions); getState(): NdrRuntimeState; onStateChange(listener: (state: NdrRuntimeState) => void): Unsubscribe; onSessionEvent(callback: OnEventCallback): Unsubscribe; getAppKeysManager(): AppKeysManager | null; getDelegateManager(): DelegateManager | null; getSessionManager(): SessionManager | null; getGroupManager(): GroupManager | null; getDirectMessageSubscriptionAuthors(): string[]; getSessionUserRecords(): SessionUserRecordsLike; getSessionMessagePushAuthorPubkeys(peerPubkey: string): string[]; getKnownDeviceIdentityPubkeysForOwner(ownerPubkey: string): string[]; feedEvent(event: VerifiedEvent): boolean; processReceivedEvent(event: VerifiedEvent): boolean; initManagers(): Promise; initForOwner(ownerPubkey: string): Promise; waitForSessionManager(ownerPubkey?: string): Promise; waitForGroupManager(ownerPubkey?: string): Promise; initAppKeysManager(): Promise; initDelegateManager(): Promise; initSessionManager(ownerPubkey: string): Promise; initGroupManager(ownerPubkey?: string): Promise; onGroupEvent(callback: (event: GroupDecryptedEvent) => void): Unsubscribe; setupUser(userPubkey: string, ownerPubkey?: string): Promise; sendEvent(recipientPubkey: string, event: Partial, ownerPubkey?: string): Promise; queuedMessageDiagnostics(innerEventId?: string, ownerPubkey?: string): Promise; sendMessage(recipientPubkey: string, content: string, options?: SendMessageOptions, ownerPubkey?: string): Promise; sendChatSettings(recipientPubkey: string, messageTtlSeconds: ChatSettingsPayloadV1["messageTtlSeconds"], ownerPubkey?: string): Promise; setChatSettingsForPeer(peerPubkey: string, messageTtlSeconds: ChatSettingsPayloadV1["messageTtlSeconds"], ownerPubkey?: string): Promise; sendReceipt(recipientPubkey: string, receiptType: ReceiptType, messageIds: string[], ownerPubkey?: string): Promise; sendTyping(recipientPubkey: string, ownerPubkey?: string): Promise; setDefaultExpiration(options: ExpirationOptions | undefined, ownerPubkey?: string): Promise; setExpirationForPeer(peerPubkey: string, options: ExpirationOptions | null | undefined, ownerPubkey?: string): Promise; setExpirationForGroup(groupId: string, options: ExpirationOptions | null | undefined, ownerPubkey?: string): Promise; deleteChat(userPubkey: string, ownerPubkey?: string): Promise; resolveBaseAppKeys(ownerPubkey: string, timeoutMs?: number): Promise; startAppKeysSubscription(ownerPubkey: string): void; stopAppKeysSubscription(): void; private syncDirectMessageSubscription; refreshOwnAppKeysFromRelay(ownerPubkey: string, timeoutMs?: number): Promise; prepareRegistration(options: PrepareRegistrationOptions): Promise; prepareRegistrationForIdentity(options: PrepareRegistrationForIdentityOptions): Promise; publishPreparedRegistration(prepared: PreparedRegistration): Promise; prepareRevocation(options: PrepareRevocationOptions): Promise; publishPreparedRevocation(prepared: PreparedRevocation): Promise; registerCurrentDevice(options: RegisterCurrentDeviceOptions): Promise; registerDeviceIdentity(options: RegisterDeviceIdentityOptions): Promise; revokeDevice(options: RevokeDeviceOptions): Promise; ensureCurrentDeviceRegistered(ownerPubkey: string, timeoutMs?: number): Promise; republishInvite(): Promise; rotateInvite(): Promise; createLinkInvite(ownerPubkey?: string): Promise; acceptInvite(invite: Invite, options?: AcceptInviteOptions): Promise; acceptLinkInvite(invite: Invite, ownerPubkey: string): Promise; upsertGroup(group: GroupData, ownerPubkey?: string): Promise; syncGroups(groups: GroupData[], ownerPubkey?: string): Promise; removeGroup(groupId: string): void; createGroup(name: string, memberOwnerPubkeys: string[], opts?: { fanoutMetadata?: boolean; nowMs?: number; }): Promise; sendGroupEvent(groupId: string, event: RuntimeGroupEvent, opts?: SendGroupEventOptions): Promise<{ outer: VerifiedEvent; inner: Rumor; }>; sendGroupMessage(groupId: string, message: string, opts?: SendGroupEventOptions): Promise<{ outer: VerifiedEvent; inner: Rumor; }>; close(): void; private attachSessionManagerEvents; private flushSessionManagerEvents; private handleSessionManagerEvent; private feedSessionManagerEvent; private feedLocalAppKeysSnapshotToSessionManager; private clearSessionManagerEvents; private resolveActiveOwnerPubkey; private buildRegistrationPayload; private applyIncomingAppKeys; private publishAppKeys; private waitForDeviceRegistrationOnRelay; private syncState; } //# sourceMappingURL=NdrRuntime.d.ts.map