{"version":3,"sources":["../../src/types/bundle.ts"],"names":[],"mappings":";AA2HO,SAAS,gBAAgB,CAAA,EAAoC;AAClE,EAAA,OAAQ,EAAoB,IAAA,KAAS,MAAA;AACvC;AAiBO,IAAM,YAAA,GAAe;AAAA,EAC1B,QAAA,EAAU,cAAA;AAAA,EACV,QAAA,EAAU,eAAA;AAAA,EACV,aAAA,EAAe,eAAA;AAAA,EACf,UAAA,EAAY,YAAA;AAAA,EACZ,MAAA,EAAQ,aAAA;AAAA,EACR,UAAA,EAAY,YAAA;AAAA,EACZ,MAAA,EAAQ,aAAA;AAAA,EACR,OAAA,EAAS,cAAA;AAAA,EACT,SAAA,EAAW,eAAA;AAAA,EACX,GAAA,EAAK,UAAA;AAAA,EACL,aAAA,EAAe,WAAA;AAAA,EACf,kBAAA,EAAoB,aAAA;AAAA,EACpB,WAAA,EAAa,yBAAA;AAAA,EACb,cAAA,EAAgB,4BAAA;AAAA,EAChB,UAAA,EAAY,wBAAA;AAAA,EACZ,aAAA,EAAe;AACjB;AAEO,IAAM,aAAA,GAAgB","file":"index.mjs","sourcesContent":["/**\n * `.dpiv-bundle` JSON shapes.\n *\n * Mirrors `shared-deps/chain/bundle/bundle-types.ts`. Any drift\n * between this file and ARCHITECTURE.md §8 is a bug — the\n * architecture doc wins.\n *\n * The files documented here are the JSON payloads inside a bundle:\n *   - `merkle.json`   — `MerkleProofJson`\n *   - `sth.json`      — `STH` (re-exported from `./sth`)\n *   - `onchain.json`  — `OnchainProofJson`   (optional)\n *   - `labels.json`   — `LabelsJson`\n *   - `MANIFEST.txt`  — `ManifestEntry[]` (see `../crypto/manifest`)\n */\n\n/**\n * `merkle.json` — the inclusion proof for one leaf in one segment.\n *\n * Verifiers walk `audit_path` bottom-up using RFC 6962 domain\n * separation (`0x00 || leaf` for leaf hashes, `0x01 || left || right`\n * for nodes). The walk MUST close to the `root` field of the\n * bundle's `sth.json` for the segment — verifiers cross-check the\n * two files, not just `merkle.json` in isolation.\n *\n * `leaf_hash` is the RFC 6962 leaf hash:\n * `SHA-256(0x00 || envelope_canonical_bytes)`. It is NOT\n * `envelope_hash` (which omits the `0x00` prefix). A naive verifier\n * that checks `leaf_hash === envelope_hash` is wrong — they differ\n * by the prefix-and-rehash step.\n *\n * Hex fields are lowercase, no `0x` prefix. `audit_path` is ordered\n * leaf-to-root and its length equals `ceil(log2(tree_size))` for the\n * segment's tree at the STH used.\n */\nexport interface MerkleProofJson {\n  v: 1;\n  segment: number;\n  leaf_index: number;\n  leaf_hash: string;\n  audit_path: string[];\n}\n\n/**\n * `onchain.json` — optional. Present only when the segment has a\n * confirmed `anchor_checkpoint` row whose `tree_size` covers\n * `merkle.json.leaf_index` and whose `root` matches the bundle's\n * `sth.json.root`.\n *\n * The bundle service refuses to assemble a bundle if an attestation\n * has been logged as `onchain` or `dual` mode but no confirmed\n * receipt exists — i.e. this file is present iff the on-chain claim\n * is substantiated server-side at build time. Per\n * ARCHITECTURE.md §8 D.7, `verify.sh` step 6 is informational only;\n * absence of this file does NOT weaken the proof's off-chain checks.\n *\n * `chain` uses canonical short names matching the on-chain anchor\n * service. `contract` is the registry address as a 0x-prefixed\n * checksummed hex string. `tx` is the tx hash. `block` is the block\n * number containing the tx. `tree_size` and `root` MUST match the\n * corresponding fields of `sth.json`.\n */\nexport interface OnchainProofJson {\n  v: 1;\n  chain: \"base-mainnet\" | \"base-sepolia\";\n  contract: `0x${string}`;\n  tx: `0x${string}`;\n  block: number;\n  segment: number;\n  tree_size: number;\n  root: string;\n}\n\n/**\n * One label entry in `labels.json`.\n *\n * The discriminator is the presence of the `salt` field — `salt`\n * appears ONLY when the bundle was built with the matching label\n * name in the reveal-set query parameter. A verifier seeing a `salt`\n * field MUST compute\n *\n *   SHA-256(name + \":\" + String(value) + \":\" + salt)\n *\n * and check it equals `commit`. Mismatch = the bundle was tampered\n * with or the salt is for a different label.\n *\n * Unrevealed labels have NO `salt` and NO `value` field. Bundle\n * builders MUST default to unrevealed; salts only ship when\n * explicitly requested. SDK consumers MUST NOT render salt values\n * outside an explicit \"reveal\" UI; logging `salt` at any level is a\n * privacy bug.\n */\nexport interface RevealedLabel {\n  name: string;\n  value: boolean | string | number;\n  salt: string;\n  commit: string;\n  public_value?: boolean | string | number;\n}\n\nexport interface UnrevealedLabel {\n  name: string;\n  commit: string;\n  public_value?: boolean | string | number;\n}\n\nexport type BundleLabel = RevealedLabel | UnrevealedLabel;\n\n/**\n * `labels.json`. Always present, even when the envelope has zero\n * labels (in that case `labels` is the empty list). The empty-list\n * sentinel is non-negotiable so verifiers can unconditionally\n * attempt to read this file without first checking its existence.\n */\nexport interface LabelsJson {\n  v: 1;\n  labels: BundleLabel[];\n}\n\n/**\n * Type guard — narrow a `BundleLabel` to the revealed variant.\n * Use to gate any UI that needs to display the salt-recompute step\n * (and only that UI — never log the salt).\n */\nexport function isRevealedLabel(l: BundleLabel): l is RevealedLabel {\n  return (l as RevealedLabel).salt !== undefined;\n}\n\n/**\n * One row in `MANIFEST.txt`. `path` is the bundle-relative path\n * (POSIX forward-slashes); `sha256` is the lowercase hex digest of\n * the file's contents. The on-disk format is sha256sum-compatible.\n */\nexport interface ManifestEntry {\n  path: string;\n  sha256: string;\n}\n\n/**\n * Canonical bundle filenames. Renaming any of these is a breaking\n * change to every historical bundle's `verify.sh` script. Treat as\n * append-only.\n */\nexport const BUNDLE_FILES = {\n  MANIFEST: \"MANIFEST.txt\",\n  ENVELOPE: \"envelope.json\",\n  ENVELOPE_HASH: \"envelope.hash\",\n  ISSUER_PEM: \"issuer.pem\",\n  LABELS: \"labels.json\",\n  MASTER_PEM: \"master.pem\",\n  MERKLE: \"merkle.json\",\n  ONCHAIN: \"onchain.json\",\n  SIGNATURE: \"signature.bin\",\n  STH: \"sth.json\",\n  VERIFY_SCRIPT: \"verify.sh\",\n  MERKLE_WALK_HELPER: \"merkle-walk\",\n  TS_DIGICERT: \"timestamps/digicert.tsr\",\n  TS_DIGICERT_CA: \"timestamps/digicert-ca.pem\",\n  TS_SECTIGO: \"timestamps/sectigo.tsr\",\n  TS_SECTIGO_CA: \"timestamps/sectigo-ca.pem\",\n} as const;\n\nexport const BUNDLE_SUFFIX = \".dpiv-bundle\";\n"]}