/** * Delegation request handling and delegated-event approval workflow support. * * KERIpy correspondence: * - `DelegateRequestHandler` mirrors the notification-facing exchange handler * in `keri.app.delegating` * - `Anchorer` mirrors the approval workflow role of KERIpy's `Anchorer` * * `keri-ts` difference: * - workflow progress is explicit turn-based escrow processing instead of a * long-lived HIO doer * - proxy communication is a selected local habitat, not an implicit runtime * side effect */ import { type Operation } from "effection"; import { type SerderKERI } from "../../../cesr/mod.js"; import type { ExchangeAttachment, Exchanger, ExchangeRouteHandler } from "./exchanging.js"; import { type Poster } from "./forwarding.js"; import { type Hab, type Habery } from "./habbing.js"; import type { Notifier } from "./notifying.js"; import type { QueryCoordinator } from "./querying.js"; export declare const DELEGATE_REQUEST_ROUTE = "/delegate/request"; /** Durable phase for one delegated event as it moves through approval. */ export type DelegationPhase = "waitingWitnessReceipts" | "waitingDelegatorAnchor" | "waitingWitnessPublication"; /** One turn-level workflow outcome emitted by `Anchorer.processAllOnce()`. */ export type DelegationWorkflowResult = { kind: "keep"; phase: DelegationPhase; pre: string; said: string; reason: string; } | { kind: "advance"; pre: string; said: string; from: DelegationPhase; to: DelegationPhase; reason: string; } | { kind: "complete"; pre: string; said: string; phase: DelegationPhase; reason: string; } | { kind: "fail"; pre: string; said: string; phase: DelegationPhase; reason: string; }; export interface DelegationWorkflowStatus { phase: DelegationPhase | null; proxyDependent: boolean; complete: boolean; } export declare function resolveDelegationCommunicationHab(hby: Habery, alias?: string): Hab | undefined; /** Install delegation-specific EXN handlers into one exchange router. */ export declare function loadDelegationHandlers(hby: Habery, exchanger: Exchanger, notifier?: Notifier | null): void; /** * Peer-to-peer delegation request handler for `/delegate/request` exchange messages. * * KERIpy correspondence: * - this is the local analogue of `keri.app.delegating.DelegateRequestHandler` * - the Python handler exists to translate an incoming delegation request EXN * into controller-facing notification data for the local delegator * - it does not approve the delegated event itself; approval still happens * later when the local controller anchors the embedded event in its own KEL * * Local `keri-ts` adaptation: * - the handler accepts an EXN that carries `delpre` in the payload and the * delegated event bytes in the `evt` embed * - if `delpre` does not belong to a local habitat, the message is ignored * because there is no local delegator controller for the request * - on success, the handler only emits notifier state; durable delegation * workflow progression remains the responsibility of `Anchorer` and the * normal event-parsing/approval path */ export declare class DelegateRequestHandler implements ExchangeRouteHandler { static readonly resource = "/delegate/request"; readonly resource = "/delegate/request"; readonly hby: Habery; readonly notifier: Notifier | null; constructor(hby: Habery, notifier?: Notifier | null); verify(args: { serder: SerderKERI; attachments: ExchangeAttachment[]; }): boolean; /** Store a signed controller notification when this request targets a local delegator. */ handle(args: { serder: SerderKERI; attachments: ExchangeAttachment[]; }): void; } /** * Delegation workflow coordinator for delegated inception and rotation events. * * KERIpy correspondence: * - this class ports the protocol role of `keri.app.delegating.Anchorer` * - the Python `Anchorer` is a `DoDoer` that drives three escrow phases: * waiting for delegate witness receipts, waiting for the delegator's anchor, * and, when needed, waiting for post-approval witness publication * - it is the component that turns "delegated event exists locally" into * "delegated event has been presented to the delegator, approved, and * finalized for local completion" * * Local `keri-ts` adaptation: * - this class is not a long-lived DoDoer; it is a deterministic workflow * component run by the shared `AgentRuntime` turn * - protocol state still lives in the same durable escrow families used by the * rest of the runtime: * - `dpwe.` for waiting on delegate witness receipts * - `dune.` for waiting on the delegator's authorizing anchor * - `dpub.` for waiting on witness republication after approval * - `cdel.` for completed delegation workflows * - outbound correspondence is delegated to `Poster` * - delegation-specific anchor discovery stays explicit here and uses * `QueryCoordinator` only as the queued query-delivery seam * - witness republication sends the resolved delegator chain directly to the * delegate's witnesses so the flow stays readable against KERIpy * * Maintainer mental model: * - `Anchorer` owns workflow progression, not generic cue delivery and not * low-level event parsing * - each call to `processAllOnce()` advances the durable escrows at most one * phase per workflow based on currently known local state * - approval becomes authoritative only when the delegator's sealing event is * learned locally and pinned into `aess.` */ export declare class Anchorer { readonly hby: Habery; readonly poster: Poster; readonly querying: QueryCoordinator; readonly communicationHabPins: Map; readonly anchorQueryRetryPasses: Map; constructor(hby: Habery, { poster, querying }: { poster: Poster; querying: QueryCoordinator; }); begin(serder: SerderKERI, options?: { communicationHab?: Hab; }): void; /** Begin workflow processing from the currently accepted event for an AID. */ beginLatest(pre: string, sn?: number, options?: { communicationHab?: Hab; }): SerderKERI; /** Return the current durable workflow phase without mutating escrow state. */ workflowStatus(pre: string, snh: string): DelegationWorkflowStatus; /** Return true after the delegated event has been durably completed. */ complete(pre: string, sn: number | string): boolean; /** Process all delegation escrow families once in KERIpy-compatible order. */ processAllOnce(): Operation; private processPartialWitnessEscrow; private processUnanchoredEscrow; private processWitnessPublication; private communicationHab; private queueDelegatorWitnessQueryNow; /** Retry bounded delegator-witness queries while waiting for the anchor. */ private retryDelegatorWitnessQuery; private clearWorkflowPins; private publicationTransportHab; private publishDelegator; } //# sourceMappingURL=delegating.d.ts.map