codec_jcs/lib.rs
1// SPDX-FileCopyrightText: Copyright © 2026 ReallyMe LLC. All rights reserved
2//
3// SPDX-License-Identifier: Apache-2.0
4
5//! JSON Canonicalization Scheme helpers.
6//!
7//! Object member ordering and finite floating-point formatting follow RFC
8//! 8785. The raw-text API rejects duplicate object member names and malformed
9//! JSON. Integer tokens that `serde_json` retains exactly as `i64` or `u64`
10//! are additionally rejected outside `[-(2^53)+1, (2^53)-1]`; numbers parsed
11//! through binary64, including decimal/exponent forms and magnitudes above
12//! `u64::MAX`, follow RFC 8785's ECMAScript rounding semantics.
13
14mod canonicalize;
15mod error;
16mod parse_json;
17
18// Preserve the pre-0.2 symbol for downstream migration while ensuring every
19// new call site sees the deprecation on use. The allowance is intentionally
20// scoped to this compatibility re-export.
21#[allow(deprecated)]
22pub use canonicalize::canonicalize_json;
23pub use canonicalize::{canonicalize_json_text, canonicalize_trusted_json_value};
24pub use error::JcsError;
25
26/// Maximum array/object nesting depth accepted by [`canonicalize_trusted_json_value`].
27///
28/// Defense in depth: `serde_json`'s parser already caps nesting, but a
29/// caller may hand in a `Value` built by other means, so canonicalization
30/// enforces its own bound rather than trusting the input's provenance.
31pub const MAX_NESTING_DEPTH: usize = 128;