import { Cigar, Dater, Diger, SerderKERI, Siger } from "../../../cesr/mod.js"; import { TransIdxSigGroup } from "../core/dispatch.js"; import { type EscrowProcessDecision } from "../core/kever-decisions.js"; import { type Logger } from "../core/logger.js"; import type { VerferCigarCouple } from "../core/records.js"; import { LMDBer } from "./core/lmdber.js"; import { CatCesrIoSetSuber, CesrIoSetSuber, CesrSuber, SerderSuber } from "./subing.js"; /** Callback shape used when `Broker` retries one escrowed state notice. */ export interface BrokerProcessReplyArgs { serder: SerderKERI; diger: Diger; route: string; cigars: Cigar[]; tsgs: TransIdxSigGroup[]; aid: string; } /** Constructor options for one escrow `Broker`. */ export interface BrokerOptions { timeout?: number; logger?: Logger; } /** * Collection of databases for transaction state notices (TSNs) and TSN escrow * handling. * * KERIpy correspondence: * - mirrors `keri.db.escrowing.Broker` * * Current `keri-ts` difference: * - this is a DB substrate only in the current phase; it is exported and * tested, but not yet wired into a TEL runtime or `Reger` owner * * Escrow model: * - `escrowStateNotice()` stores one reply body plus its detached endorsement * artifacts * - `processEscrowState()` walks one escrow family and maps replay into * `accept/keep/drop` * - successful replay updates the accepted-state pointer, while terminal drop * removes the escrow row and may remove the stored artifacts as well */ export declare class Broker { readonly db: LMDBer; readonly timeout: number; readonly logger: Logger; readonly daterdb: CesrSuber; readonly serderdb: SerderSuber; readonly tigerdb: CesrIoSetSuber; readonly cigardb: CatCesrIoSetSuber; readonly escrowdb: CesrIoSetSuber; readonly saiderdb: CesrSuber; constructor(db: LMDBer, subkey: string, { timeout, logger }?: BrokerOptions); /** Return the currently saved transaction-state SAID for `(prefix, aid)`. */ current(keys: [string, string]): Diger | null; /** * Process escrowed transaction-state notices for one escrow type. * * Typed escrow decisions make Broker recovery explicit: * - `keep` mirrors recoverable retry errors of `extype` * - `drop` mirrors stale/corrupt escrow rows that should be unindexed * - `accept` mirrors successful processing through the callback * * Pass outline: * - walk escrow rows for one broker type * - load and rebuild the stored reply artifacts * - hand the reconstructed message to the caller-supplied reply processor * - remove, keep, or purge based on the explicit escrow decision */ processEscrowState(typ: string, processReply: (args: BrokerProcessReplyArgs) => void, extype: new (...args: any[]) => Error): void; /** * Persist one escrowed transaction-state notice and its attachments. * * This stores the escrow artifacts idempotently before indexing the escrow * route bucket. * * Stored artifacts: * - `daterdb` for timeout handling * - `serderdb` for the escrowed reply body * - `tigerdb` for transferable endorsement groups * - `cigardb` for non-transferable endorsement couples * - `escrowdb` for the broker-specific `(typ, pre, aid)` index */ escrowStateNotice({ typ, pre, aid, serder, diger, dater, cigars, tsgs, }: { typ: string; pre: string; aid: string; serder: SerderKERI; diger: Diger; dater: Dater; cigars?: readonly Cigar[]; tsgs?: readonly TransIdxSigGroup[]; }): boolean; /** * Update the accepted reply record and current-state index for one TSN. * * Overwrites any existing accepted reply for the same SAID and current-state * pointer for the `(prefix, aid)` tuple. */ updateReply(aid: string, serder: SerderKERI, diger: Diger, dater: Dater): void; /** Remove all persisted state associated with one escrowed TSN SAID. */ removeState(diger: Diger | null | undefined): void; /** * Rebuild transferable signature groups for one stored state notice. * * This intentionally stays private to `Broker` for now so the generic * `fetchTsgs` parity row can remain tracked separately. * * Reconstruction steps: * - walk the stored signer rows grouped under one reply SAID * - regroup them by `(pre, snh, dig)` * - rebuild `TransIdxSigGroup` values in insertion order per group */ private fetchTsgs; /** * Process one escrowed transaction-state notice through the supplied callback. * * KERIpy translation: * - recoverable callback failures stay in escrow via `keep` * - malformed/stale artifact failures drop the escrow row * - outer corruption while rebuilding signer groups drops the row and tells * the caller to purge the stored artifacts * * Steps: * - rebuild transferable groups first * - load the reply body, timestamp, and non-transferable couples * - reject stale or malformed escrow rows * - replay the reconstructed reply through the supplied processor */ processEscrowedStateNotice(args: { aid: string; diger: Diger; processReply: (args: BrokerProcessReplyArgs) => void; extype: new (...args: any[]) => Error; }): EscrowProcessDecision; } //# sourceMappingURL=escrowing.d.ts.map