/*! * Copyright (c) 2026 Interop Alliance. All rights reserved. */ /** * The mender runner: one try, warn, and skip discipline over the * registrations listed under one chain trigger. `runMenderBlock` runs them * in list order, since registration order is execution order and there is * no dependency graph. A seed step's failure aborts the block; a * registration's failure warns through the wallet's own `Logger` and the * block continues. Beside it sits `mendReportAccumulator`, the report * collector a wallet creates before a `Session` exists, so the entries a * routing site reports and the entries this runner reports assemble into * one `MendReport`. */ import type { Logger } from '../log.js'; import type { MenderRegistry } from './registry.js'; import type { LoginRoute, MendReport, MendReportEntry, Registration, RegistrationSite } from './types.js'; import type { Authority, ChainTrigger } from './vocabulary.js'; /** * The `errorName` a normalized entry carries when a registration resolves * with entries that do not match the invariants it reports. */ export declare const MEND_REPORT_SHAPE_ERROR = "MendReportShapeError"; /** * The report collector a wallet creates ahead of session assembly. A * routing entry reports into it from its own call site before a `Session` * exists, {@link runMenderBlock} reports the chain's entries into it * through `onOutcome`, and the wallet hands `settled` to the session as its * mend report. */ export interface MendReportAccumulator { /** * Records one entry. Bound to the accumulator, so it can be passed * directly as {@link runMenderBlock}'s `onOutcome`. */ report(entry: MendReportEntry): void; /** * Every entry recorded so far, in report order. */ entries(): MendReport; /** * Resolves {@link MendReportAccumulator.settled} with the entries * recorded so far. Idempotent: the first call fixes the resolved report, * and a later `report` call still lands in `entries()`. */ settle(): MendReport; /** * The assembled report, resolved by `settle`. It never rejects. */ readonly settled: Promise>; } /** * Creates a report accumulator. Generic over the wallet's ceremony-id * union, which defaults to `string`. * * @returns {MendReportAccumulator} */ export declare function mendReportAccumulator(): MendReportAccumulator; /** * Runs one registration block: the registrations listed under `trigger` * whose every reported invariant declares an authority the session holds * and admits this login route, in list order. * * The discipline, in one place. An optional `seed` registration runs first, * and its failure aborts the block: nothing behind it runs, which is what a * rejected chain seed does today. Past the seed, a registration that throws * warns once per reported invariant with that declaration's own `warn` * string, reports `failed` for each of them, and the block carries on to * the next registration. Only `err.name` rides a report: a thrown error's * message routinely carries a DID or a Space id, so the error itself goes * to the logger alone. * * A registration that resolves with the wrong number of entries, or with an * entry whose `invariant` is not the id it reports at that position, is a * programming error. It warns and is normalized to `failed` entries * carrying {@link MEND_REPORT_SHAPE_ERROR} rather than throwing, so a * mismatched adapter cannot tear a login. * * `trigger` is one of the two chain values, so a `ceremony-tail` entry is * out of reach here. Such an entry has no registration at all: its body * stays inside its ceremony's sequenced code and it reports from there. * * `Deps` is the wallet's own type, one object per registration block, * handed to the seed and to every `converge` unread. This runner never * inspects it, and the raw passphrase does not cross into this package. * * `registrations` overrides which registrations the block runs, for a wallet * that runs one trigger's list in parts (a settle point partway through, say). * The same authority and route tests still admit each one, and one listed * under another trigger is refused, so the override narrows the block and * never widens it. * * A registry may index converge-free sites beside its registrations -- a * wallet's routing entries, or an entry whose own call site fires it -- and * such a site is never executed here, whichever list the block runs from. * * @param options {object} * @param options.registry {MenderRegistry} the wallet's declarations and * its registrations * @param options.trigger {ChainTrigger} which chain is running * @param options.held {ReadonlyArray} the session's held * authorities, from `heldAuthorities` * @param options.route {LoginRoute} the login route each declaration's * `when` predicate reads * @param options.deps {Deps} passed to the seed and to every `converge` * @param options.logger {Logger} the wallet's own sink, so its warn * copy keeps the wallet's namespace * @param [options.registrations] {ReadonlyArray} the * registrations to run, in place of the ones the registry lists under * `trigger`. Each is admitted by the same authority and route tests * @param [options.seed] {Registration} the step whose failure aborts the * block. Admitted by the same authority and route tests as any other * registration; one it does not pass is skipped rather than failed * @param [options.onOutcome] {(entry: MendReportEntry) => void} called * once per reported entry, in order. The single place a chain entry's * outcome is reported * @returns {Promise} the block's entries in order. It never * rejects; a seed failure resolves with the seed's `failed` entries alone * @throws {TypeError} when the seed or an override registration is listed * under a trigger other than `trigger`, a programming error */ export declare function runMenderBlock>({ registry, trigger, held, route, deps, logger, registrations, seed, onOutcome }: { registry: MenderRegistry; trigger: ChainTrigger; held: ReadonlyArray; route: LoginRoute; deps: Deps; logger: Logger; registrations?: ReadonlyArray>; seed?: Registration; onOutcome?: (entry: MendReportEntry) => void; }): Promise>; /** * The thrown value's class name alone. Its message may carry a DID or a * Space id, so a report keeps the name and the logger keeps the error. A * value that is not an `Error` still yields a name, so a report site never * carries `undefined` where a name belongs. * * @param err {unknown} * @returns {string} */ export declare function errorNameOf(err: unknown): string; //# sourceMappingURL=runner.d.ts.map