import { type JsonValue } from "@decionis/agent-safe-pipeline"; /** A digest in the one form every wire field in this repository uses. */ export type Sha256 = `sha256:${string}`; export declare class JcsError extends Error { readonly code: "JCS_NOT_I_JSON" | "JCS_NUMBER_NOT_FINITE"; constructor(code: "JCS_NOT_I_JSON" | "JCS_NUMBER_NOT_FINITE"); } /** * The canonical digest BEAP asks for: SHA-256 over the RFC 8785 canonical * form of the value. The canonicaliser is the pipeline's `Rfc8785`, which * sorts every key by UTF-16 code unit and serialises numbers and strings the * way ECMAScript does; for I-JSON input those are RFC 8785's rules, and the * authority's payload digest and every verifier in another language apply * them. It is not the intent's canonical form, which puts array-index keys * first (spec/intent/v1 §4), so `{"10":…,"9":…}` keeps that order here. * * What the canonicaliser does not do is refuse input that is not I-JSON, so * this adds that gate: a lone surrogate would serialise differently in * another language's JSON writer, and a non-finite number has no JSON form * at all. Both are refused here rather than producing a digest two * implementations would disagree about. */ export declare function jcsDigest(value: JsonValue): Sha256; /** The canonical text itself, for a caller that wants to see what was hashed. */ export declare function jcsCanonical(value: JsonValue): string; /** * Whether a string is well-formed UTF-16: every surrogate paired. Written * out rather than taken from `String.prototype.isWellFormed`, which this * repository's ES2022 target does not declare, and small enough that * depending on the newer library for it would be the larger change. * * The string iterator does the pairing: it yields a well-formed pair as one * two-unit character, and anything unpaired as a single unit. So a lone * surrogate is exactly a one-unit character whose code is in the surrogate * range, and there is no index arithmetic to get wrong. */ export declare function isWellFormedUtf16(value: string): boolean; /** * Every string well-formed UTF-16, every number finite. Recurses through * arrays and objects, and checks keys as well as values, because a key is * as much of the canonical form as a value is. */ export declare function assertIJson(value: JsonValue): void; //# sourceMappingURL=JcsDigest.d.ts.map