/**
 * @fileoverview CBOR Codec with Canonical/Deterministic Encoding.
 *
 * This module wraps the `cbor-x` library to provide **canonical CBOR encoding**
 * for WARP graph patches. Canonical encoding is critical for WARP's content-addressed
 * storage model: the same logical patch must always produce identical bytes so that
 * Git SHA comparisons work correctly.
 *
 * ## Why Canonical Encoding Matters
 *
 * WARP stores patches as Git commits where the commit message contains CBOR-encoded
 * patch data. Git identifies commits by SHA-256 hash of their content. If the same
 * logical patch could encode to different byte sequences (e.g., due to non-deterministic
 * object key ordering), then:
 *
 * 1. **Duplicate patches** could exist with different SHAs
 * 2. **Deduplication** would fail - the same operation stored multiple times
 * 3. **Causality tracking** would break - version vectors rely on exact SHA matching
 * 4. **Sync protocols** would transfer redundant data
 *
 * ## The cbor-x Limitation
 *
 * Unlike some CBOR libraries, `cbor-x` does not provide built-in canonical/deterministic
 * encoding. JavaScript object key enumeration order is insertion-order (per ES2015+),
 * which means `{ b: 1, a: 2 }` and `{ a: 2, b: 1 }` would encode differently despite
 * being logically equivalent.
 *
 * ## Our Solution: Pre-encoding Key Sorting
 *
 * Before encoding, we recursively sort all object keys using JavaScript's default
 * lexicographic sort (via {@link sortKeys}). This produces deterministic,
 * lexicographically-sorted CBOR for WARP patches.
 *
 * **Important**: This is NOT RFC 7049 Section 3.9 canonical CBOR, which requires
 * byte-length-first ordering (shorter keys before longer keys, then lexicographic
 * within same length). Our approach uses simple lexicographic ordering, which is
 * sufficient for WARP's content-addressing needs but not interoperable with systems
 * expecting strict RFC 7049 canonical form.
 *
 * This ensures:
 *
 * - **Determinism**: Same input always produces identical bytes
 * - **Verifiability**: Patches can be re-encoded and compared byte-for-byte
 *
 * @module infrastructure/codecs/CborCodec
 * @see {@link https://cbor.io/} for CBOR specification
 * @see {@link https://tools.ietf.org/html/rfc7049#section-3.9} for Canonical CBOR
 * @see {@link https://github.com/kriszyp/cbor-x} for cbor-x library
 */
import CodecPort from '../../ports/CodecPort.ts';
/**
 * Encodes data to canonical CBOR bytes with deterministic output.
 *
 * This function guarantees that logically equivalent inputs always produce
 * byte-identical outputs. It achieves this by recursively sorting all object
 * keys before encoding, ensuring consistent key ordering regardless of how
 * the input object was constructed.
 */
export declare function encode(data: unknown): Uint8Array;
/**
 * Decodes CBOR bytes to a JavaScript value.
 *
 * This function deserializes CBOR-encoded data back into JavaScript values.
 * It uses cbor-x's native decoder which is optimized for performance.
 */
export declare function decode(buffer: Uint8Array): unknown;
/**
 * CBOR codec implementing CodecPort with canonical/deterministic encoding.
 */
export declare class CborCodec extends CodecPort {
    /**
     * Encodes data to canonical CBOR bytes with sorted keys.
     */
    encode<TEncoded = unknown>(data: TEncoded): Uint8Array;
    /**
     * Decodes CBOR bytes to a typed JavaScript value. The caller
     * supplies the expected `TDecoded` at the call site; the
     * adapter's cbor-x round-trip returns whatever shape the bytes
     * encoded to, cast to the caller's declared type.
     */
    decode<TDecoded = unknown>(buffer: Uint8Array): TDecoded;
}
declare const _default: CborCodec;
export default _default;
