import type { JsonObject, JsonValue } from '../types/data-contract.js'; /** The request `_meta` key a view's proof rides at. The value is one string. */ export declare const MCP_APP_AI_GGUI_VIEW_META_KEY: "ai.ggui/view"; /** * The longest proof a relay door admits, for every version. A v1 proof is * at most {@link VIEW_PROOF_V1_MAX_CHARS} characters; the rest is headroom. */ export declare const VIEW_PROOF_MAX_CHARS = 1024; /** * The relay door shape, fixed for every version: ASCII, no escaping needed * in JSON, a URL, a header or a log line. A relay MAY check it and MAY log * the value; it MUST NOT alter, trim, case-fold, re-encode or truncate it. * The version tag and the fields belong to the verifier, not to this shape. */ export declare const VIEW_PROOF_RELAY_SHAPE: RegExp; /** The v1 grammar: `v1.root.nonce.vtime.flags.argmac.callmac`. */ export declare const VIEW_PROOF_V1_PATTERN: RegExp; /** The longest v1 proof: 2+1+768+1+22+1+15+1+2+1+43+1+43. */ export declare const VIEW_PROOF_V1_MAX_CHARS = 901; /** * The longest root `P` (the ws envelope's payload segment) a proof can * carry. `P` grows with `sessionId` and `appId`, neither of which protocol * caps, so a minting door issues no view key for a longer `P`. */ export declare const VIEW_PROOF_ROOT_MAX_CHARS = 768; /** Bit 0 of `flags`: the gesture carried transient user activation (dispatch). */ export declare const VIEW_PROOF_FLAG_USER_ACTIVATION = 1; /** The label a view key is derived under: `HMAC(secret, label ‖ 0x00 ‖ P)`. */ export declare const VIEW_KEY_LABEL_V1 = "ai.ggui/view-key/v1"; /** The label a secret's default key id is derived under. */ export declare const VIEW_KID_LABEL_V1 = "ai.ggui/kid/v1"; /** The label the bound arguments are MACed under. */ export declare const VIEW_ARGS_LABEL_V1 = "ai.ggui/view-args/v1"; /** The label the call is MACed under. */ export declare const VIEW_CALL_LABEL_V1 = "ai.ggui/view-call/v1"; /** * The Plane-3 result code a runtime tool answers when a proof is required * and not valid (SPEC §7.9: a result field on the tool's closed output, * never thrown). Declared on `ggui_runtime_submit_action` and * `ggui_runtime_sync_context` one release before any server emits it. It * is not an auth-class refusal: the caller owns the session, and the * runtime acts on it by re-mounting. */ export declare const VIEW_ORIGIN_UNPROVEN: "VIEW_ORIGIN_UNPROVEN"; /** * The arguments each tool's proof binds, frozen for v1. `bound(tool, args)` * is the object of the listed keys that are present and not `undefined`. * Bound: every field the protocol forbids a relay to change. Left out: * `ggui_runtime_pull`'s `wait`, which a relay MUST clamp to its own * timeout. Changing a tool's row is a new label (`/v2`): its signed bytes * change. Adding a row for a NEW tool is not (ggui#1609): no earlier signer * sends that tool and no earlier verifier accepts it, so no existing proof's * bytes move and the known-answer vectors stand. */ export declare const VIEW_PROOF_V1_BOUND_ARGS: { readonly ggui_runtime_submit_action: readonly ["kind", "payload", "sessionId", "appId", "actionId", "firedAt"]; readonly ggui_runtime_sync_context: readonly ["sessionId", "appId", "snapshot"]; readonly ggui_runtime_pull: readonly ["sessionId", "sinceSequence", "limit"]; readonly ggui_runtime_report_render_failure: readonly ["sessionId", "appId", "phase", "errorName", "catches"]; }; /** A tool whose calls carry a view proof. */ export type ViewProofTool = keyof typeof VIEW_PROOF_V1_BOUND_ARGS; /** Whether `name` is a tool whose calls carry a view proof. */ export declare function isViewProofTool(name: string): name is ViewProofTool; /** The bound arguments: the listed keys of `args` that are present and not `undefined`. */ export declare function viewProofBoundArgs(tool: ViewProofTool, args: JsonObject): JsonObject; /** * The message a view key is the HMAC of: `label ‖ 0x00 ‖ P`, keyed by the * UTF-8 secret that signed `P`. */ export declare function viewKeyInputBytes(root: string): Uint8Array; /** * `A`, the bytes `argmac` MACs: `label ‖ LF ‖ JCS(bound(tool, args))`, * over the arguments' JSON values (RFC 8785 canonical JSON). A signer * normalizes first (`JSON.parse(JSON.stringify(...))`) and sends the * normalized arguments. Throws on a value JCS cannot encode. */ export declare function viewProofArgsBytes(tool: ViewProofTool, args: JsonObject): Uint8Array; /** The fields of a call `callmac` covers, besides the tool name. */ export interface ViewProofCallFields { readonly toolName: string; readonly nonce: string; readonly vtime: string; readonly flags: string; readonly argmac: string; } /** * `M`, the bytes `callmac` MACs: * `label ‖ LF ‖ toolName ‖ LF ‖ nonce ‖ LF ‖ vtime ‖ LF ‖ flags ‖ LF ‖ argmac`. */ export declare function viewProofCallBytes(call: ViewProofCallFields): Uint8Array; /** * The key-issuing doors a root can name in its `src` claim: `result` (a * render or update tool result) and `read` (a view's `resources/read`). * The only list of them. A closed set: a root naming any other value is * refused (`parseViewProof` reads it `malformed`, the ws token verifier * `malformed_claims`). So a new door's value is added here one release * BEFORE any door mints with it, and a door mints it only once no replica * that refuses it is left in the roll (VERSION-POLICY §3.6, the sender * obligation). Adding a value and minting with it in one release makes * every older replica in a roll refuse that door's tokens. */ export declare const VIEW_ROOT_SRC: readonly ["result", "read"]; export type ViewRootSrc = (typeof VIEW_ROOT_SRC)[number]; /** Whether a value is one of {@link VIEW_ROOT_SRC}. */ export declare function isViewRootSrc(value: unknown): value is ViewRootSrc; /** The claims a proof's root `P` carries, as the verifier reads them. */ export interface ViewRootClaims { readonly sessionId: string; readonly appId: string; readonly kind: 'ws'; readonly iat: number; readonly exp: number; readonly jti: string; readonly kid: string; /** The key-issuing door: one of {@link VIEW_ROOT_SRC}, a closed set (read its rule before widening it). */ readonly src?: ViewRootSrc; } /** A parsed v1 proof: its fields, and the claims its root decodes to (not yet authenticated). */ export interface ParsedViewProofV1 { readonly version: 'v1'; readonly root: string; readonly nonce: string; readonly vtime: string; readonly flags: string; readonly argmac: string; readonly callmac: string; readonly claims: ViewRootClaims; } /** * Why a proof could not be parsed. `malformed`: not a string, longer than * the door admits, off the door shape or the v1 grammar, or a root that is * not a claims object. `version_unknown`: door-shaped with a version tag * other than `v1`. `wrong_kind`: a root whose `kind` is not `ws`. */ export type ViewProofParseFailure = 'malformed' | 'version_unknown' | 'wrong_kind'; export type ViewProofParse = { readonly ok: true; readonly proof: ParsedViewProofV1; } | { readonly ok: false; readonly reason: ViewProofParseFailure; }; /** * Decode a root `P` to the claims it carries, unauthenticated: what * {@link parseViewProof} reads from a proof's root, and what a view reads * from its own root before it signs with it. `malformed`: not a root the v1 * grammar can carry (base64url, 16 to {@link VIEW_PROOF_ROOT_MAX_CHARS} * characters), or not a claims object; `wrong_kind`: a root whose `kind` * is not `ws`. Never throws. */ export declare function decodeViewRootClaims(root: string): ViewRootClaims | ViewProofParseFailure; /** * Parse a proof value without authenticating it. The root's claims are * decoded only so a verifier can pick a secret and name a reason; nothing * here is trusted until `callmac` checks. */ export declare function parseViewProof(value: JsonValue | undefined): ViewProofParse; /** Assemble a v1 proof string from its fields. */ export declare function formatViewProofV1(fields: Omit): string; /** * Known-answer vectors for v1, derived with `node:crypto` from the byte * builders above. A signer and a verifier each reproduce them: the key, * both tags and the proof. */ export declare const VIEW_PROOF_V1_VECTORS: readonly [{ readonly name: "submit_action dispatch, render_ session"; readonly secret: "test-secret-do-not-use"; readonly kid: "a_lK9Gzz"; readonly root: "eyJzZXNzaW9uSWQiOiJyZW5kZXJfM2YyYTljMWUtN2I0ZC00ZThhLTljMmYtMGQxZTJmM2E0YjVjIiwiYXBwSWQiOiJhcHBfZGVtbyIsImtpbmQiOiJ3cyIsImlhdCI6MTc5MDAwMDAwMCwiZXhwIjoxNzkwMDAwMTgwLCJqdGkiOiJBQUVDQXdRRkJnY0lDUW9MIiwia2lkIjoiYV9sSzlHenoiLCJzcmMiOiJyZXN1bHQifQ"; readonly toolName: "ggui_runtime_submit_action"; readonly args: { readonly kind: "dispatch"; readonly payload: { readonly intent: "submit"; readonly actionData: { readonly answer: "yes"; }; readonly uiContext: { readonly draft: ""; }; }; readonly sessionId: "render_3f2a9c1e-7b4d-4e8a-9c2f-0d1e2f3a4b5c"; readonly appId: "app_demo"; readonly actionId: "a3f2b1d4"; readonly firedAt: "2026-09-28T10:00:00.000Z"; }; readonly canonicalArgs: "{\"actionId\":\"a3f2b1d4\",\"appId\":\"app_demo\",\"firedAt\":\"2026-09-28T10:00:00.000Z\",\"kind\":\"dispatch\",\"payload\":{\"actionData\":{\"answer\":\"yes\"},\"intent\":\"submit\",\"uiContext\":{\"draft\":\"\"}},\"sessionId\":\"render_3f2a9c1e-7b4d-4e8a-9c2f-0d1e2f3a4b5c\"}"; readonly nonce: "AAECAwQFBgcICQoLDA0ODw"; readonly vtime: "1790000123456"; readonly flags: "1"; readonly viewKey: "K-7dUBMeCtprxv4DED-VUuAjEBHGqoaWA-hHgh5t12A"; readonly argmac: "UfHB9A4ceFnIrNTe9E7ZS8rMsbyxreQ2RpNLAyWFJeI"; readonly callmac: "_6gyTylA8UEEKcv6e9DYZKKwtUf_0GDJ0NyEYu5hqkE"; readonly proof: "v1.eyJzZXNzaW9uSWQiOiJyZW5kZXJfM2YyYTljMWUtN2I0ZC00ZThhLTljMmYtMGQxZTJmM2E0YjVjIiwiYXBwSWQiOiJhcHBfZGVtbyIsImtpbmQiOiJ3cyIsImlhdCI6MTc5MDAwMDAwMCwiZXhwIjoxNzkwMDAwMTgwLCJqdGkiOiJBQUVDQXdRRkJnY0lDUW9MIiwia2lkIjoiYV9sSzlHenoiLCJzcmMiOiJyZXN1bHQifQ.AAECAwQFBgcICQoLDA0ODw.1790000123456.1.UfHB9A4ceFnIrNTe9E7ZS8rMsbyxreQ2RpNLAyWFJeI._6gyTylA8UEEKcv6e9DYZKKwtUf_0GDJ0NyEYu5hqkE"; }]; //# sourceMappingURL=view-proof.d.ts.map