//#region src/types.d.ts type JsonValue = null | boolean | number | string | JsonValue[] | { [key: string]: JsonValue; }; type Options = { /** * Called after the optional toJSON hook and before the type dispatch step. * The signature matches the replacer that JSON.stringify accepts. */ replacer?: (this: unknown, key: string, value: unknown) => unknown; }; //#endregion //#region src/errors.d.ts type CanonicalizeErrorCode = 'UNSUPPORTED_TYPE' | 'NON_FINITE_NUMBER' | 'CIRCULAR_REFERENCE' | 'DUPLICATE_KEY'; declare class CanonicalizeError extends Error { readonly name = "CanonicalizeError"; readonly code: CanonicalizeErrorCode; readonly path: readonly string[]; constructor(code: CanonicalizeErrorCode, message: string, path: readonly string[]); } //#endregion //#region src/index.d.ts /** * Canonicalize a JavaScript value into a single deterministic string form * that complies with RFC 8785 (JCS). * * Semantics match JSON.stringify where the spec is silent: * 1. If a value exposes a toJSON method, that method is called before * type dispatch. * 2. An optional replacer callback runs on every key and value and can * transform the value or omit it. * 3. undefined inside an object causes the key to be dropped, undefined * inside an array emits null, and undefined at the root throws. * 4. A circular reference throws CIRCULAR_REFERENCE. The cycle detector * uses a per call ancestor set with delete on ascent, so a shared * descendant reached from sibling positions is not flagged. */ declare function canonicalize(value: unknown, options?: Options): string; /** * Canonicalize a value and return the UTF-8 byte sequence of the canonical * string. Most callers want bytes because the next step is usually a hash or * signature, both of which operate on bytes. Uses the platform TextEncoder, * which is available in every modern JavaScript runtime (Node, Bun, Deno, * browsers, and Workers). */ declare function canonicalizeBytes(value: unknown, options?: Options): Uint8Array; //#endregion export { CanonicalizeError, type CanonicalizeErrorCode, type JsonValue, type Options, canonicalize, canonicalizeBytes }; //# sourceMappingURL=index.d.ts.map