import { type HistoryChunkEntry, type HistoryRecord } from "@gryt/crypto"; import type { MlsOwnDeviceAdd } from "../mls/interfaces.js"; import type { HistoryArchive, HistoryNotedMessage, HistoryProgress, PairingClock } from "./interfaces.js"; import { type PairingRelay } from "./relayClient.ts.js"; /** The relay's 256 MiB per session, less room for the tail. */ export declare const HISTORY_SNAPSHOT_MAX_BYTES: number; /** Entries in the envelope's manifest and in each later message, which keep under 256 and 64 KiB. */ export declare const HISTORY_ENVELOPE_ENTRIES = 400; export declare const HISTORY_PAGE_ENTRIES = 180; /** One chunk as a history message lists it: its relay slot and its manifest entry. */ export interface ListedChunk extends HistoryChunkEntry { n: number; } /** What A posts after the envelope, sealed. `final` says nothing more is coming. */ export interface HistoryMessage { t: "history"; chunks: ListedChunk[]; total?: number; truncated?: boolean; final?: boolean; } export declare const emptyProgress: () => HistoryProgress; export interface HistorySenderOptions { relay: PairingRelay; id: string; token: string; archive: HistoryArchive; clock: PairingClock; signal: AbortSignal; /** Seals and posts one message. The sender calls it one at a time, in order. */ post(message: HistoryMessage): Promise; onProgress(progress: HistoryProgress): void; maxBytes?: number; } /** A: seals the archive into chunks newest first, uploads each, then lists it to N. */ export declare function createHistorySender(options: HistorySenderOptions): { key: Uint8Array; progress: () => { messages: number; total: number | null; chunks: number; listed: number; missing: number; refused: number; truncated: boolean; oldest: number | null; complete: boolean; }; /** Waits until `until` or the end of the snapshot, whichever is first, and hands over what's up. */ forEnvelope(until: number): Promise; /** After N's "ready": list what's waiting, and keep listing as pages fill. */ startPaging(): void; /** The tail: records past the snapshot. `final` waits for the snapshot and says that's all. */ send(records: HistoryRecord[], final: boolean): Promise; }; /** * A's record of MLS messages it archived during the transfer. The tail is every one past the * snapshot that N can't read: before N's add, or sent in an older epoch that landed after it. */ export declare function createTailRecorder(): { start: () => undefined; note(message: HistoryNotedMessage): void; /** Everything noted since the last call that N needs. `snap` and `added` are per host. */ take(snap: Map>, added: Record): HistoryRecord[]; };