import { O as OnchainProofJson } from '../bundle-CKS7FPC4.js'; /** * Minimal stored-method ZIP reader. * * `.dpiv-bundle` files are produced by the M05 bundle Lambda using * the stored (uncompressed) method per ARCHITECTURE.md §8 D.4 — the * payloads are already entropy-dense (sigs, hex digests, signed * timestamps) and storing uncompressed lets verifiers operate * without a deflate implementation. That choice keeps this SDK at * zero runtime deps. * * This reader supports STORED (method=0) only. If the registry ever * starts emitting DEFLATE bundles, this function throws a clear * "unsupported compression method" error rather than silently * misverifying. The intent is documented in the bundle builder, the * verify.sh script, and ARCHITECTURE.md — coordinated change only. * * No symlink, no zip-slip, no UTF-8 surprises. Path entries are * checked against backslashes and `..` segments before being added * to the output map. */ interface UnzipResult { /** Bundle-relative path → file bytes. POSIX forward slashes only. */ files: Record; } /** * Parse a stored-method ZIP buffer into a flat path → bytes map. * * Reads the End Of Central Directory record at the tail, walks the * central directory forward, and extracts each entry from its local * file header position. Refuses entries with backslashes, leading * slashes, or `..` segments. */ declare function unzipBundle(input: ArrayBuffer | Uint8Array): UnzipResult; /** * Partial in-process bundle verifier — 5 of 6 checks per * ARCHITECTURE.md §8 D.5. * * ⚠ DELIBERATE PARTIAL VERIFIER ⚠ * * This SDK performs FIVE of the six checks defined in * ARCHITECTURE.md §8 D.5. Step 3 — RFC 3161 timestamp token * verification against the DigiCert and Sectigo TSA CA chains — is * **deliberately skipped**. Pulling a full ASN.1 + RFC 3161 verifier * into a zero-dependency SDK would add ~200 KB of transitive deps; * any caller that needs the canonical TSA check should run the * bundle's own `verify.sh` script (which uses `openssl ts -verify` * and is the canonical TSA verifier by design). * * Step 3 status is reported as the literal string `"skipped"` * rather than a boolean — callers MUST handle that case explicitly. * We do not silently treat unverified TSA tokens as valid. * * # Checks performed * * 1. envelope_hash: SHA-256(JCS(envelope.json)) == * envelope.hash content * 2. issuer_signature: ECDSA P-256 / SHA-256 verify of * signature.bin against the canonical * envelope bytes using issuer.pem * 3. tsa_tokens: SKIPPED — see above * 4. merkle_inclusion: audit_path walk closes to * sth.json.root via RFC 6962 leaf/node * prefixes * 5. master_sth_signature: ECDSA P-256 / SHA-256 verify of * base64-decoded master_sig against the * JCS-canonical STH preimage using * master.pem * 6. onchain_anchor: presence + structural validity of * onchain.json (or "absent" when the * file isn't in the bundle). * INFORMATIONAL ONLY — we do NOT call * an RPC. Live tx existence is a * verify.sh / SDK-RPC concern. * * # Cross-check requirements (defense in depth) * * - merkle.json.segment must equal sth.json.segment * - merkle.json.leaf_index must be < sth.json.tree_size * - audit_path verification uses sth.json.root as the expected * root * - When onchain.json is present, its (segment, tree_size, root) * must equal sth.json's * * # Privacy * * verifyBundle MUST NOT log salt values. Any salt in * `labels.json::RevealedLabel` is recomputed against `commit` and * cross-checked, then discarded. Callers building UIs that surface * the salt do so explicitly via `parseLabels` — never via the * verifier. */ /** * Per-check result. * * - Boolean for the four cryptographic checks plus the structural * on-chain check. * - Literal `"skipped"` for the deliberately-unimplemented TSA step. * - Literal `"absent"` for the optional `onchain.json` when missing. */ interface VerifyChecks { envelope_hash: boolean; issuer_signature: boolean; tsa_tokens: "skipped"; merkle_inclusion: boolean; master_sth_signature: boolean; onchain_anchor: boolean | "absent"; } interface VerifyResult { /** * `true` iff every PERFORMED check passed. The deliberately- * skipped TSA step is not counted toward `ok`. Callers requiring * full six-of-six verification must run `verify.sh` separately. */ ok: boolean; checks: VerifyChecks; /** * The list of explicitly skipped checks. Always contains * `"tsa_tokens"` so consumers can present a "5 of 6 verified" * disclaimer without re-deriving it. */ skipped: ReadonlyArray; /** * Short human-readable explanation when `ok === false`. Names the * first failing check (in declaration order). Absent on success. */ reason?: string; /** * On-chain reference, when `onchain.json` was present in the * bundle and structurally valid. Informational only — no RPC was * called. Surfaces so consumers can render the explorer link * without re-parsing the bundle. */ onchainReference?: { chain: OnchainProofJson["chain"]; contract: string; tx: string; block: number; segment: number; treeSize: number; root: string; }; } /** Map of bundle-relative path → file bytes. */ type BundleFiles = Record; /** * Verify a `.dpiv-bundle` (sans TSA). * * Accepts either: * - the raw `.dpiv-bundle` zip as `ArrayBuffer | Uint8Array` * (most common — what `client.downloadBundle()` returns), * - or a pre-unzipped `BundleFiles` map (useful for tests and for * callers that already have the bundle in memory). * * Promise-returning for symmetry with the Python SDK, but the * implementation is fully synchronous; awaiting it adds a single * microtask. */ declare function verifyBundle(bundle: ArrayBuffer | Uint8Array | BundleFiles): Promise; export { type BundleFiles, type VerifyChecks, type VerifyResult, unzipBundle, verifyBundle };