import { EventTemplate, NostrEvent, NostrFilter, RelayEventResult, Subscription } from '@napplet/core'; /** * Napplet NAP relay sdk entrypoint. * * @module */ /** * @napplet/nap/relay -- SDK helpers wrapping window.napplet.relay. * * These convenience functions delegate to `window.napplet.relay.*` at call time. * The shim must be imported somewhere to install the global. */ /** * Open a live NIP-01 subscription through the shell's relay pool. * * @param filters One or more NIP-01 subscription filters * @param onEvent Called for each matching event result * @param onEose Called when the shell signals end of stored events (EOSE) * @param options Optional: `{ relay, group }` for NIP-29 scoped relay subscriptions * @returns A Subscription handle with a `close()` method * * @example * ```ts * import { relaySubscribe } from '@napplet/nap/relay'; * * const sub = relaySubscribe( * { kinds: [1], limit: 10 }, * (event) => console.log(event), * () => console.log('EOSE'), * ); * ``` */ declare function relaySubscribe(filters: NostrFilter | NostrFilter[], onEvent: (result: RelayEventResult) => void, onEose: () => void, options?: { relay?: string; group?: string; }): Subscription; /** * Sign and publish a Nostr event through the shell. * * @param template Unsigned event template * @param options Optional: `{ relay: true }` to publish via scoped relay * @returns The signed NostrEvent after successful publication * * @example * ```ts * import { relayPublish } from '@napplet/nap/relay'; * * const signed = await relayPublish({ * kind: 1, content: 'Hello!', tags: [], * created_at: Math.floor(Date.now() / 1000), * }); * ``` */ declare function relayPublish(template: EventTemplate, options?: { relay?: boolean; }): Promise; /** * One-shot query: subscribe, collect events until EOSE, then resolve. * * @param filters NIP-01 subscription filters * @returns Promise resolving to array of matching event results * * @example * ```ts * import { relayQuery } from '@napplet/nap/relay'; * * const profiles = await relayQuery({ kinds: [0], authors: [pubkey] }); * ``` */ declare function relayQuery(filters: NostrFilter | NostrFilter[]): Promise; /** * Publish an encrypted Nostr event through the shell. * * @param template Unsigned event template * @param recipient Hex-encoded recipient public key * @param encryption Encryption scheme: 'nip44' (default) or 'nip04' * @returns The signed encrypted NostrEvent after successful publication * * @example * ```ts * import { relayPublishEncrypted } from '@napplet/nap/relay'; * * const signed = await relayPublishEncrypted( * { kind: 4, content: 'secret', tags: [], created_at: now }, * 'recipientPubkey...', * ); * ``` */ declare function relayPublishEncrypted(template: EventTemplate, recipient: string, encryption?: 'nip44' | 'nip04'): Promise; export { relayPublish, relayPublishEncrypted, relayQuery, relaySubscribe };