import { type RosterEntryLike, type SignedMessage, type VerifyResult } from "./verify.js"; import { type EkhoIdentity } from "./store.js"; export interface OperatorKeyEntryLike { key_id?: string; public_key?: string; revoked?: boolean; endorsed_by_key_id?: string | null; endorsement_sig?: string | null; /** #27: signature over revocationPayload(fleet, key_id, revoked_at) by a * currently pinned operator key. WITHOUT it, `revoked` is advisory only. */ revocation_sig?: string | null; /** #27: the revocation time, inside the signed bytes (so the relay cannot * restate when a key died under a still-valid signature). */ revoked_at?: string | null; /** #27 / #48: signature over unrevokePayload(fleet, key, revoked_at, issued_at, nonce). */ unrevoke_sig?: string | null; unrevoke_revoked_at?: string | null; unrevoke_issued_at?: string | null; unrevoke_nonce?: string | null; } /** Where the sync reports trust-root decisions. Defaults to the console, because * a relay claiming a revocation it can't prove must never pass in silence. */ export interface SyncLog { info?: (...a: unknown[]) => void; warn?: (...a: unknown[]) => void; } /** How many identical advisory polls to swallow before a reminder. ~5s poll * → a reminder about every 10 minutes, not 150k lines in a day and a half. */ export declare const ADVISORY_REVOCATION_WARNING_SUMMARY_EVERY = 120; /** Process-local cap on identity+fleet throttle scopes. Eviction re-emits that * scope's next first-seen warning; it cannot mute a different live scope. */ export declare const ADVISORY_REVOCATION_WARNING_MAX_SCOPES = 64; /** Test-only isolation for the process-local Map. Not plugin runtime API. */ export declare function resetAdvisoryRevocationWarningStateForTests(): void; /** Update pinned operator keys from the inbox. Adds a new key ONLY if endorsed by * an already-pinned key; removes one ONLY on a SIGNED revocation. Returns true * if the identity changed (and so must be persisted). * * Trust mutates in one direction only, and never on the relay's say-so (#27). * An unsigned `revoked: true` is a HINT: the key is skipped for new adoption * and the claim is logged, but nothing is written and nothing is unpinned. * Treating it as authoritative (the #14 regression) meant one poll from a * compromised relay could tombstone and unpin an entire fleet's trust root, * permanently — the tombstone survives restarts by design, so the damage was * not even recoverable by restarting against an honest relay. * * One deliberate exception to "no relay TOFU" (#5): an identity that has never * pinned ANY key can't grow a chain — endorsements need an already-pinned root, * so verification stayed dormant forever on every agent nobody hand-configured * (the Aug 2026 silent-drop incident). First contact with an empty pin set * adopts the relay's current non-revoked keys as the trust root, exactly once * (tofuAt latches). Enrollment already trusts the relay this much — it accepts * the shared secret over the same channel. Pre-pinning via config/env skips * TOFU entirely and stays the stronger option. */ export declare function syncPinnedOperatorKeys(identity: EkhoIdentity, operatorKeys: OperatorKeyEntryLike[], fleetId: string | null | undefined, log?: SyncLog): boolean; export declare function verifyBatch(messages: SignedMessage[], opts: { identity: EkhoIdentity; selfAgentId: string; fleetId: string | null | undefined; roster: RosterEntryLike[]; seenNonces: Set; now: Date; }): Record; /** How strictly peer messages must prove themselves before waking a turn (#5). * - "warn" (default): unsigned/unverifiable peers still wake, but are rendered * untrusted — the graceful relay-attested fallback, named for what it is. * - "require": a peer message wakes ONLY when signed and verified; anything * else is dead-lettered by the tick. Operator messages keep the explicit * relay-attested operator_trusted toggle as their unsigned fallback — that * flag is operator-set, not relay-implied, so "require" doesn't cut the * operator off on consoles that don't sign yet. * - "off": same wake behavior as "warn" (kept distinct for config clarity). */ export type RequireSignedMode = "off" | "warn" | "require"; export declare function parseRequireSignedMode(raw: string | undefined | null): RequireSignedMode; /** The execution-authority gate. Signed → act iff verified; signed-but-invalid → * blocked; unsigned → per requireSigned mode (see above). */ export declare function shouldAutowake(msg: SignedMessage, verification: VerifyResult | null | undefined, operatorTrusted: boolean, peerEnabled: boolean, requireSigned?: RequireSignedMode): boolean; /** Sign an outbound peer message so recipients can verify it came from us. * * v2 (#9) extends coverage to message_type, priority and the attachment ids — * previously a compromised relay could relabel a message (direct → alert) or * swap its attachments under a still-valid signature. Compatibility is free in * both directions: verifiers check the signature over the WHOLE canonical and * only bind the fields they know, so old verifiers accept v2 envelopes and new * verifiers enforce the extra bindings only when the envelope declares v>=2. */ export declare function buildSignedSendFields(opts: { identity: EkhoIdentity; fleetId: string; selfAgentId: string; recipient: Record; conversationId: string; bodyText: string; nonce: string; sentAt: string; messageType: string; priority: string; attachments?: string[]; }): { agent_sig: string; key_id: string; sig_canonical: Record; }; /** A quoted snapshot of another message — a reply target (`reply_to`) or a * conversation-history / floor-tail entry. Since #43 the relay copies the * signature fields of the message it quotes onto the snapshot, so a snapshot * can be checked rather than merely inspected. Note the shape difference from * an inbox message: a snapshot carries `text` at the top level, not `body.text`. */ export interface MsgSnapshotLike { message_id?: string; sender_agent_id?: string; sender_kind?: "operator" | "agent"; text?: string; message_type?: string; priority?: string; attachments?: string[]; operator_sig?: string | null; agent_sig?: string | null; key_id?: string | null; sig_canonical?: Record | null; } /** Verdict for one quoted snapshot: did its signature actually check out? */ export type SnapshotVerifier = (snapshot: MsgSnapshotLike | null | undefined) => boolean; /** The fail-closed default (#20): when verification cannot run — no pinned * operator keys, no fleet id, no identity — every snapshot is UNVERIFIED. * Never "it has a signature field, so call it signed". */ export declare const NO_SNAPSHOT_VERIFICATION: SnapshotVerifier; /** * Build the snapshot verifier for one turn, from the same trust root the * autowake path uses: this agent's pinned operator keys plus the batch roster. * * Runs the ordinary inbound verifier (`verifyInbound`) over a snapshot mapped * into its `SignedMessage` shape — there is deliberately no second, laxer * verifier for quoted text. Two consequences worth naming: * * - An older relay that omits `sig_canonical` (or the v2-bound `message_type` / * `priority` / `attachments`) simply fails the checks, so its snapshots read * UNVERIFIED. That is the intended direction to fail in. * - The nonce set is fresh per turn rather than the live seen-nonce set. A * quote is by definition a re-presentation of a message that may already * have been delivered and had its nonce burned; the burn exists to stop a * replayed message WAKING a turn, and a snapshot can never wake one. The * staleness window is left at the verifier's default, so a snapshot replayed * from beyond it still reads UNVERIFIED. */ export declare function makeSnapshotVerifier(opts: { identity?: EkhoIdentity | null; selfAgentId: string; fleetId: string | null | undefined; roster: RosterEntryLike[]; now: Date; }): SnapshotVerifier; //# sourceMappingURL=verification.d.ts.map