/** * TypedRef -- payload references hashed for the receipt/mutation chain. * * THE RECEIPT BYTE LAW. `canonicalize` here encodes via `cborg` (deterministic, * smallest-float canonical CBOR) and `hash` digests those bytes with SHA-256 * (`crypto.subtle`) into a `sha256:` content hash. Every consumer feeds * canonicalize → SHA-256: TypedRef.create, Receipt.hashEnvelope/createEnvelope, * LiveCell.make/makeBoundary. * * This is DELIBERATELY NOT the `fnv1a:` identity byte law. Internal `fnv1a:` * content addresses are minted only through `CanonicalCbor` (ADR-0003, * always-float64, cross-payload agreement; CUT B1). The two byte laws are * distinct on purpose: * * - IDENTITY (`fnv1a:`): CanonicalCbor, always-float64. Needs cross-payload * agreement — two structurally-equal payloads must mint the same address, * so it normalizes float width. * - RECEIPT (`sha256:`): TypedRef.canonicalize (cborg). Needs only * intra-chain determinism + permanence. A receipt chain only ever compares * its own cborg→sha256 bytes against its own; it never cross-compares the * two encoders, so cborg's smallest-float form is harmless here. cborg is * retained (not migrated to CanonicalCbor) because migrating would invalidate * persisted sha256 receipts for zero correctness gain — and cborg is needed * for decode regardless (CanonicalCbor is encode-only). * * See `tests/unit/core/receipt-byte-law.test.ts` for the cage and the pinned, * intentional cborg-vs-CanonicalCbor float divergence. * * @module */ import { Effect } from 'effect'; interface TypedRefShape { readonly schema_hash: string; readonly content_hash: string; } /** * Canonicalize a value to deterministic CBOR bytes via `cborg` — the input to * SHA-256 receipt/mutation hashing. NOT the `fnv1a:` identity encoder: identity * addresses use `CanonicalCbor` (always-float64). See the module header. */ export declare const canonicalize: (value: unknown) => Uint8Array; /** * Hash data using SHA-256. Returns "sha256:hex" formatted hash. * * The `bytes as BufferSource` assertion is the single sanctioned cast in this * file. `Uint8Array` is structurally a BufferSource, but TS's DOM lib types * `bytes.buffer` as potentially-SharedArrayBuffer, preventing direct assignment. * Safe: cborg encodes into fresh ArrayBuffer and TextEncoder.encode returns * ArrayBuffer-backed views. No data copy. * * Hash-primitive failures are unrecoverable in practice (crypto.subtle errors * are environment-level, not user-recoverable), so we `Effect.orDie` to fold * the Error channel into a defect and keep the `Effect` signature that * the content-addressing pipeline relies on. */ export declare const hash: (data: string | Uint8Array) => Effect.Effect; /** * TypedRef — schema-plus-content-hash pointer used by the receipt pipeline. * Lets a receipt reference a payload by its content address without embedding * the payload itself, while still binding it to a schema identity. */ export declare const TypedRef: { /** Build a {@link TypedRef} from a schema hash and an arbitrary payload. */ create: (schemaHash: string, payload: unknown) => Effect.Effect; /** Structural equality over schema + content hashes. */ equals: (a: TypedRefShape, b: TypedRefShape) => boolean; /** cborg deterministic-CBOR serialization feeding the SHA-256 content hash (the receipt byte law). */ canonicalize: (value: unknown) => Uint8Array; /** Hash a canonicalized payload to its content address. */ hash: (data: string | Uint8Array) => Effect.Effect; }; export declare namespace TypedRef { /** Structural shape of a typed reference: schema hash + content hash. */ type Shape = TypedRefShape; } export {}; //# sourceMappingURL=typed-ref.d.ts.map