/** * JSON Canonicalization Scheme (RFC 8785). * * `canonicalize` turns a JSON value into its canonical text: object members * sorted by the UTF-16 code units of their names, no insignificant * whitespace, strings escaped as `JSON.stringify` escapes them and numbers in * the ECMAScript `Number` format. Two values that differ only in member order, * whitespace or number spelling canonicalise to the same text. * * The input must be I-JSON (RFC 7493). Anything without a single canonical * form throws `CanonicalizationError` instead of being coerced or dropped: * `NaN` and infinities; strings or member names with an unpaired surrogate; * `undefined`, functions, symbols, bigints, sparse arrays and objects that * are not plain objects (such as `Date` or `Map`, whose `toJSON` is not * consulted); nesting deeper than `MAX_DEPTH`. * * The Python SDK implements the same rules in `grantex.canonical`; both are * tested against the RFC 8785 test vectors and the shared fixtures in * `spec/examples/canonicalization/`. Python additionally refuses integers * whose digits are not the canonical form of a double (such as 2^53 + 1); * a JavaScript number has already been rounded by the parser. */ /** Deepest nesting of arrays and objects accepted. */ export declare const MAX_DEPTH = 64; /** The value has no RFC 8785 canonical form. */ export declare class CanonicalizationError extends Error { constructor(message: string); } /** Returns the RFC 8785 canonical JSON text of `value`. */ export declare function canonicalize(value: unknown): string; /** Returns the RFC 8785 canonical JSON of `value` as UTF-8 bytes. */ export declare function canonicalizeToBytes(value: unknown): Uint8Array; /** Serialises a finite number as `Number.prototype.toString` does (`-0` as `0`). */ export declare function serializeNumber(value: number): string; /** A JSON text repeats a member name within one object. */ export declare class DuplicateKeyError extends CanonicalizationError { readonly key: string; constructor(key: string); } /** * Parses JSON text like `JSON.parse`, but throws `DuplicateKeyError` when an * object repeats a member name (after unescaping), instead of silently keeping * the last value. Use it wherever the raw text of a value to canonicalise is * available. */ export declare function parseJsonRejectingDuplicates(text: string): unknown; //# sourceMappingURL=canonical.d.ts.map