import { type Operation } from "effection"; import { type Cigar, type SerderKERI, type Texter } from "../../../cesr/mod.js"; import type { AgentCue } from "../core/cues.js"; import { Deck } from "../core/deck.js"; import { PathedMaterialGroup, TransIdxSigGroup } from "../core/dispatch.js"; import type { Hab, Habery } from "./habbing.js"; /** Delivery mode used when choosing a remote exchange transport endpoint. */ export type ExchangeTransport = "auto" | "direct" | "indirect"; /** Pathed attachment projection exposed to exchange-route handlers. */ export interface ExchangeAttachment { raw: Uint8Array; text: string; } /** Route-handler contract for accepted exchange messages. */ export interface ExchangeRouteHandler { readonly resource: string; verify?(args: { serder: SerderKERI; attachments: ExchangeAttachment[]; essrs: readonly Texter[]; }): boolean; handle(args: { serder: SerderKERI; attachments: ExchangeAttachment[]; essrs: readonly Texter[]; }): void; } /** Result of one `Exchanger` processing attempt. */ export type ExchangeDecision = { kind: "accept"; said: string; } | { kind: "escrow"; reason: string; said: string; } | { kind: "reject"; reason: string; said: string; }; /** * Peer-to-peer `exn` processor for one `Habery`. * * Responsibilities: * - verify exchange-message signatures against accepted sender state * - persist accepted exchange artifacts in the dedicated exchange stores * - escrow partially verifiable exchange traffic in `epse.` / `epsd.` * - dispatch accepted messages to route-specific handlers such as challenge * * TypeScript design rule: * - use typed `accept` / `escrow` / `reject` outcomes instead of KERIpy's * exception-only control flow for ordinary branch results */ export declare class Exchanger { readonly hby: Habery; readonly cues: Deck; readonly routes: Map; constructor(hby: Habery, { handlers, cues, }?: { handlers?: readonly ExchangeRouteHandler[]; cues?: Deck; }); /** Register one route handler for accepted exchange messages. */ addHandler(handler: ExchangeRouteHandler): void; /** * Verify, persist, and dispatch one inbound `exn`. * * Accepted messages are durably logged before any route-specific side * effects run so later reopen and verification paths can reuse the same * stored evidence. */ processEvent(args: { serder: SerderKERI; tsgs?: readonly TransIdxSigGroup[]; cigars?: readonly Cigar[]; ptds?: readonly PathedMaterialGroup[]; essrs?: readonly Texter[]; }): ExchangeDecision; /** Retry any partially signed exchange escrows that are still fresh enough to matter. */ processEscrows(): void; /** Return true once the named exchange SAID is durably stored as accepted. */ complete(said: string): boolean; /** * Return true when this local habitat is elected to externally send an EXN. * * KERIpy uses the lowest collected group-signature index as the lead for a * completed multisig business EXN. Single-sig habitats are always the lead. */ lead(hab: Hab, said: string): boolean; private verifySignatures; private escrowPartialSigned; private logAcceptedEvent; private rebuildEscrowedGroups; private removeEscrow; } /** * Create and deliver one signed exchange message through the selected * controller-to-controller transport path. */ export declare function sendSignedExchangeMessage(hab: Hab, args: { route: string; payload: Record; recipient: string; transport?: ExchangeTransport; modifiers?: Record; date?: string; dig?: string; }): Operation<{ serder: SerderKERI; url: string; }>; /** * Choose the remote URL that should receive one outbound exchange message. * * Current transport policy: * - `direct` sends to the recipient controller location * - `indirect` sends to an authorized mailbox endpoint, then falls back to * agent endpoints when no mailbox URL is available * - `auto` prefers direct delivery because this codebase has not yet landed * full witness-forwarding mailbox orchestration */ export declare function resolveExchangeTransportUrl(hab: Hab, recipient: string, transport: ExchangeTransport): string | null; //# sourceMappingURL=exchanging.d.ts.map