/**
* Hand-authored declarations for the "./chat" export of ardegazu-rooms-kit —
* the compiled dist/chat/index.js (ClojureScript). Mirrors the v1.0.0
* TypeScript API surface exactly.
*/
import { EventEmitter } from "node:events";
import type { Identity, Fingerprint } from "ardegazu-id-kit";
import type { Net, RoomLog, PeerConnState, RelayConfig } from "../index.js";
export const CHAT_SALT: "chat.ardegazu.ro/v2";
/** 32 random bytes, base64url unpadded (43 chars) — the room capability. */
export declare function newRoomSecret(): string;
export interface ChatMessage {
id: string; // log entry hash
from: string; // durable author id (b64url Ed25519 pub) or ""
name: string;
ts: number;
text?: string;
img?: { cid: string; mime: string; bytes: number; w: number; h: number };
thread?: string;
reactions: Map<string, Set<string>>; // emoji → author ids
}
export interface ChatPeer {
state: PeerConnState;
name?: string;
ident?: { pub: string; fp: Fingerprint };
}
export interface ChatOptions {
roomSecret: string;
name: string;
/** State directory for the blockstore/log (one per room works fine). */
dataDir: string;
/** Suite identity for durable authorship + the identity badge; optional. */
identity?: Identity | null;
appSalt?: string;
origin?: string;
relay?: Partial<RelayConfig>;
}
export interface ChatEvents {
/** Every message: local-replay first (oldest→newest), then live. */
message: [m: ChatMessage];
reaction: [target: string, emoji: string, by: string, op: "add" | "remove"];
peer: [id: string, p: ChatPeer];
peerGone: [id: string];
ready: [];
status: [relayUp: boolean];
}
export declare class ChatClient extends EventEmitter<ChatEvents> {
readonly net: Net;
readonly log: RoomLog;
readonly roomId: string;
get myAuthorId(): string;
static join(opts: ChatOptions): Promise<ChatClient>;
peers(): ReadonlyMap<string, ChatPeer>;
/** Folded history, ordered by (ts, entry hash) — the same on every replica. */
history(): ChatMessage[];
send(text: string, thread?: string): Promise<string>;
react(target: string, emoji: string, op?: "add" | "remove"): Promise<string>;
setName(name: string): Promise<void>;
close(): Promise<void>;
private constructor();
}