/** * NIP-XX Nostr transport builders for Simple Shared Secret (SSG) groups. * * Three event kinds are used: * * - **kind 30078** (parameterised replaceable) — group state and stored signals. * The d-tag uses the `ssg/` namespace prefix. * - **kind 20078** (ephemeral) — real-time signals between group members. * - **kind 14** (rumour / unsigned inner event) — NIP-17 gift-wrapped DMs carrying * seed distribution, reseed, and other private payloads. * * Builders return unsigned events (`UnsignedEvent`). The consumer is responsible for * signing (NIP-01), encrypting content (NIP-44), and wrapping (NIP-59) as needed. */ /** NIP-XX event kinds used by SSG groups. */ export declare const KINDS: { readonly groupState: 30078; readonly signal: 20078; readonly giftWrap: 1059; }; /** Unsigned Nostr event (consumer signs with their own library). */ export interface UnsignedEvent { kind: number; content: string; tags: string[][]; created_at: number; } export interface GroupStateEventParams { groupId: string; members: string[]; encryptedContent: string; rotationInterval?: number; tolerance?: number; expiration?: number; } export interface StoredSignalEventParams { groupId: string; signalType: string; encryptedContent: string; } export interface SignalEventParams { groupId: string; signalType: string; encryptedContent: string; } export interface RumourEventParams { recipientPubkey: string; subject: string; encryptedContent: string; groupEventId?: string; } /** Plaintext payload for group configuration (kind 30078 encrypted content). */ export interface GroupConfigPayload { description: string; policies: { invite_by: 'admin' | 'any_member'; reseed_by: 'admin' | 'any_admin'; }; } /** Plaintext payload for seed distribution (kind 14 rumour). */ export interface SeedDistributionPayload { seed: string; /** Allows re-seeding mid-window without waiting for the next natural time rotation. */ counter_offset: number; /** The group's d-tag value (group identifier). */ group_d: string; } /** Plaintext payload for reseed notification (kind 14 rumour). */ export interface ReseedPayload { seed: string; reason: 'member_removed' | 'compromise' | 'scheduled' | 'duress'; } /** Plaintext payload for member update (kind 14 rumour). */ export interface MemberUpdatePayload { action: 'add' | 'remove'; member: string; reseed: boolean; } /** Plaintext payload for counter advance (kind 20078 signal). */ export interface CounterAdvancePayload { new_counter: number; } /** Plaintext payload for word-used / burn-after-use (kind 20078 signal). */ export interface WordUsedPayload { new_counter: number; used_by: string; duress: boolean; } export declare function validatePubkey(pubkey: string, label: string): void; export declare function validateTagString(value: string, label: string): void; export declare function validateExpiration(expiration: number): void; export declare function validateEventId(eventId: string, label: string): void; /** * SHA-256 hash a group ID for use in d-tags where privacy matters. * * Duplicates hashGroupTag from sync-crypto.ts — kept independent to avoid * coupling builders to sync layer. */ export declare function hashGroupId(groupId: string): string; /** * Build an unsigned kind 30078 group state event. * * The d-tag uses plaintext `ssg/` since content is NIP-44 encrypted. * Includes NIP-32 labels for SSG namespace and p-tags for each member. * * @param params - Group state parameters. * @returns An {@link UnsignedEvent} ready to be signed and published. * @throws {Error} If groupId is invalid, member pubkeys are malformed, or optional * numeric fields are out of range. */ export declare function buildGroupStateEvent(params: GroupStateEventParams): UnsignedEvent; /** * Build an unsigned kind 30078 stored signal event. * * The d-tag uses a SHA-256 hash of the group ID (for privacy) scoped by signal type: * `ssg/:`. * * Includes a 7-day NIP-40 expiration tag. * * @param params - Stored signal parameters. * @returns An {@link UnsignedEvent} ready to be signed and published. * @throws {Error} If groupId or signalType are empty. */ export declare function buildStoredSignalEvent(params: StoredSignalEventParams): UnsignedEvent; /** * Build an unsigned kind 20078 ephemeral signal event. * * The d-tag uses a SHA-256 hash of the group ID (for privacy): * `ssg/`. A t-tag carries the signal type. * * No expiration tag — ephemeral events are not stored by relays. * * @param params - Signal parameters. * @returns An {@link UnsignedEvent} ready to be signed and published. * @throws {Error} If groupId or signalType are empty. */ export declare function buildSignalEvent(params: SignalEventParams): UnsignedEvent; /** * Build an unsigned kind 14 rumour event for NIP-17 gift wrapping. * * The consumer must set the `pubkey` field before computing the event ID. * The rumour is then sealed (NIP-44 encrypt + kind 13) and gift-wrapped * (kind 1059) by the caller. * * @param params - Rumour parameters including recipient and subject. * @returns An {@link UnsignedEvent} ready for NIP-59 wrapping. * @throws {Error} If recipientPubkey is invalid, subject is empty, or groupEventId is invalid. */ export declare function buildRumourEvent(params: RumourEventParams): UnsignedEvent; //# sourceMappingURL=nostr.d.ts.map