@qed-proof/sdk 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/LICENSE +202 -0
- package/README.md +83 -0
- package/dist/index.cjs +1074 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +317 -0
- package/dist/index.d.ts +317 -0
- package/dist/index.js +1047 -0
- package/dist/index.js.map +1 -0
- package/package.json +67 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/errors.ts","../src/primitives.ts","../src/schema.ts","../src/generated/receipt-schema.ts","../src/anchor.ts","../src/abi.ts","../src/verify.ts","../src/client.ts","../src/actions.ts"],"sourcesContent":["export { QedProof } from \"./client.js\";\nexport type {\n QedProofOptions,\n SubmitClaimOptions,\n ClaimStatus,\n WaitOptions,\n Receipt,\n ClaimSummary,\n ListClaimsOptions,\n ClaimPage,\n} from \"./client.js\";\nexport { QedProofError, RateLimitError } from \"./errors.js\";\nexport { verifyReceipt } from \"./verify.js\";\nexport type { VerifyReport, VerifyChecks, VerifyOptions } from \"./verify.js\";\nexport type { Keyset, Proof, AnchorResult } from \"./anchor.js\";\nexport * as actions from \"./actions.js\";\nexport type { ClaimAction } from \"./actions.js\";\nexport {\n b64u,\n b64uDecode,\n jcs,\n sha256,\n keyId,\n claimDigest,\n leafHash,\n rootFromInclusion,\n verifySignature,\n hasFloatValue,\n hasFloatText,\n SPEC_VERSION,\n SIG_DOMAIN,\n} from \"./primitives.js\";\nexport type { PoAWReceiptPoaw01 as GeneratedReceipt } from \"./generated/receipt.js\";\n","export class QedProofError extends Error {\n status: number;\n detail: string;\n\n constructor(status: number, detail: string) {\n super(`QedProof API error ${status}: ${detail}`);\n this.name = \"QedProofError\";\n this.status = status;\n this.detail = detail;\n }\n}\n\nexport class RateLimitError extends QedProofError {\n retryAfter: number | undefined;\n\n constructor(detail: string, retryAfter: number | undefined) {\n super(429, detail);\n this.name = \"RateLimitError\";\n this.retryAfter = retryAfter;\n }\n}\n","/**\n * poaw_core, ported (SPEC.md §3, §5, §8). Deliberately small and dependency-light, mirroring\n * `oss/core-python/src/poaw_core/__init__.py` byte for byte in intent. No Node built-ins: only\n * Web Crypto-free pure JS (`@noble/curves`, `@noble/hashes`, `canonicalize`) so this runs on\n * Node, Deno and in browsers.\n */\nimport { ed25519 } from \"@noble/curves/ed25519\";\nimport { sha256 as nobleSha256 } from \"@noble/hashes/sha2\";\nimport canonicalizeJcs from \"canonicalize\";\n\nexport const SPEC_VERSION = \"poaw/0.1\";\nexport const SIG_DOMAIN = new TextEncoder().encode(\"POAW-RECEIPT-V0\\n\");\n\n// --- encoding (§3) -----------------------------------------------------------------------------\n\nexport function b64u(data: Uint8Array): string {\n let binary = \"\";\n for (let i = 0; i < data.length; i++) binary += String.fromCharCode(data[i]);\n const base64 = btoa(binary);\n return base64.replace(/\\+/g, \"-\").replace(/\\//g, \"_\").replace(/=+$/, \"\");\n}\n\nexport function b64uDecode(text: string): Uint8Array {\n const padded = text + \"=\".repeat((4 - (text.length % 4)) % 4);\n const base64 = padded.replace(/-/g, \"+\").replace(/_/g, \"/\");\n const binary = atob(base64);\n const out = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i++) out[i] = binary.charCodeAt(i);\n return out;\n}\n\n/** RFC 8785 JCS, as UTF-8 bytes (matches Python's `rfc8785.dumps`, which returns bytes). */\nexport function jcs(obj: unknown): Uint8Array {\n const text = canonicalizeJcs(obj as object);\n if (text === undefined) {\n throw new TypeError(\"jcs: value is not JSON-serializable\");\n }\n return new TextEncoder().encode(text);\n}\n\nexport function sha256(data: Uint8Array): Uint8Array {\n return nobleSha256(data);\n}\n\nfunction concatBytes(...parts: Uint8Array[]): Uint8Array {\n const total = parts.reduce((n, p) => n + p.length, 0);\n const out = new Uint8Array(total);\n let offset = 0;\n for (const p of parts) {\n out.set(p, offset);\n offset += p.length;\n }\n return out;\n}\n\n/**\n * §3: receipts carry integers only. JSON.parse collapses the int/float distinction Python's\n * `json.loads` preserves (e.g. `1.0` parses to the same JS number as `1`), so this checks two\n * ways:\n * - `hasFloatValue`: any value that is a non-integer finite number (catches every float that\n * actually matters, e.g. `0.5` in vector 014-float-in-body.json).\n * - `hasFloatText`: scans the raw JSON text (outside string literals) for a numeric token\n * containing `.`, `e` or `E` — the same signal Python's tokenizer used to decide `float` vs\n * `int`, for callers that still have the original text (files, HTTP bodies).\n * `verifyReceipt` OR's both when raw text is available, so nothing is hidden by `JSON.parse`.\n */\nexport function hasFloatValue(value: unknown): boolean {\n if (typeof value === \"boolean\") return false;\n if (typeof value === \"number\") return !Number.isInteger(value);\n if (Array.isArray(value)) return value.some(hasFloatValue);\n if (value !== null && typeof value === \"object\") {\n return Object.values(value as Record<string, unknown>).some(hasFloatValue);\n }\n return false;\n}\n\nexport function hasFloatText(text: string): boolean {\n let i = 0;\n const n = text.length;\n while (i < n) {\n const ch = text[i];\n if (ch === '\"') {\n i++;\n while (i < n) {\n if (text[i] === \"\\\\\") {\n i += 2;\n continue;\n }\n if (text[i] === '\"') {\n i++;\n break;\n }\n i++;\n }\n continue;\n }\n if (ch === \"-\" || (ch >= \"0\" && ch <= \"9\")) {\n const start = i;\n if (ch === \"-\") i++;\n let sawFloatChar = false;\n while (i < n && text[i] >= \"0\" && text[i] <= \"9\") i++;\n if (text[i] === \".\") {\n sawFloatChar = true;\n i++;\n while (i < n && text[i] >= \"0\" && text[i] <= \"9\") i++;\n }\n if (text[i] === \"e\" || text[i] === \"E\") {\n sawFloatChar = true;\n i++;\n if (text[i] === \"+\" || text[i] === \"-\") i++;\n while (i < n && text[i] >= \"0\" && text[i] <= \"9\") i++;\n }\n if (i === start) i++; // safety, should not happen\n if (sawFloatChar) return true;\n continue;\n }\n i++;\n }\n return false;\n}\n\n// --- keys + signatures (§5) ---------------------------------------------------------------------\n\nexport function keyId(pkRaw: Uint8Array): string {\n return \"ed25519:\" + b64u(sha256(pkRaw));\n}\n\nexport function verifySignature(pkRaw: Uint8Array, body: unknown, sigValue: string): boolean {\n try {\n const sig = b64uDecode(sigValue);\n const message = concatBytes(SIG_DOMAIN, jcs(body));\n return ed25519.verify(sig, message, pkRaw);\n } catch {\n return false;\n }\n}\n\nexport function claimDigest(claim: Record<string, unknown>): string {\n const stripped: Record<string, unknown> = {};\n for (const k of Object.keys(claim)) {\n if (k !== \"claim_digest\") stripped[k] = claim[k];\n }\n return b64u(sha256(jcs(stripped)));\n}\n\n// --- Merkle log, RFC 6962 (§8) ------------------------------------------------------------------\n\nexport function leafHash(receipt: { body: unknown; signature: unknown }): Uint8Array {\n return sha256(concatBytes(new Uint8Array([0x00]), jcs({ body: receipt.body, signature: receipt.signature })));\n}\n\nfunction nodeHash(left: Uint8Array, right: Uint8Array): Uint8Array {\n return sha256(concatBytes(new Uint8Array([0x01]), left, right));\n}\n\n/** Largest power of two strictly less than n (RFC 6962 §2.1). */\nfunction split(n: number): number {\n let k = 1;\n while (k << 1 < n) k <<= 1;\n return k;\n}\n\nfunction bytesEqual(a: Uint8Array, b: Uint8Array): boolean {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;\n return true;\n}\n\n/**\n * RFC 9162 §2.1.3.2 audit-path verification. Returns the computed root, or null if the path is\n * malformed. Ported line for line from `poaw_core.root_from_inclusion`.\n */\nexport function rootFromInclusion(\n index: number,\n size: number,\n leaf: Uint8Array,\n path: Uint8Array[],\n): Uint8Array | null {\n if (index >= size) return null;\n let fn = index;\n let sn = size - 1;\n let r = leaf;\n for (const p of path) {\n if (sn === 0) return null;\n if ((fn & 1) === 1 || fn === sn) {\n r = nodeHash(p, r);\n if ((fn & 1) === 0) {\n while (fn !== 0 && (fn & 1) === 0) {\n fn >>= 1;\n sn >>= 1;\n }\n }\n } else {\n r = nodeHash(r, p);\n }\n fn >>= 1;\n sn >>= 1;\n }\n return sn === 0 ? r : null;\n}\n\nexport { bytesEqual };\n","/**\n * Structural validation against the vendored receipt schema (Draft 2020-12), matching\n * `oss/spec/tools/check.py`'s use of `jsonschema.Draft202012Validator`.\n */\nimport Ajv2020 from \"ajv/dist/2020.js\";\nimport addFormats from \"ajv-formats\";\nimport { receiptSchema } from \"./generated/receipt-schema.js\";\n\nconst ajv = new Ajv2020({ allErrors: false, strict: false });\naddFormats(ajv);\nconst validate = ajv.compile(receiptSchema);\n\nexport function schemaValid(receipt: unknown): boolean {\n return Boolean(validate(receipt));\n}\n","/**\n * This file is generated by scripts/copy-schema.mjs from ../../../src/receipt.schema.json\n * (the vendored PoAW receipt schema, synced from oss/spec). Do not edit by hand.\n */\nexport const receiptSchema = {\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n \"$id\": \"urn:poaw:schema:0.1:receipt\",\n \"title\": \"PoAW receipt (poaw/0.1)\",\n \"description\": \"Structural schema for a Proof of Agent Work receipt. Signature, inclusion and anchor checks are defined in SPEC.md and are not expressible in JSON Schema.\",\n \"type\": \"object\",\n \"required\": [\n \"body\",\n \"signature\"\n ],\n \"additionalProperties\": false,\n \"properties\": {\n \"body\": {\n \"$ref\": \"#/$defs/body\"\n },\n \"signature\": {\n \"$ref\": \"#/$defs/signature\"\n },\n \"proof\": {\n \"$ref\": \"#/$defs/proof\"\n }\n },\n \"$defs\": {\n \"timestamp\": {\n \"type\": \"string\",\n \"pattern\": \"^\\\\d{4}-\\\\d{2}-\\\\d{2}T\\\\d{2}:\\\\d{2}:\\\\d{2}(\\\\.\\\\d{1,3})?Z$\"\n },\n \"b64url\": {\n \"type\": \"string\",\n \"pattern\": \"^[A-Za-z0-9_-]+$\"\n },\n \"keyId\": {\n \"type\": \"string\",\n \"pattern\": \"^ed25519:[A-Za-z0-9_-]{43}$\"\n },\n \"fingerprint\": {\n \"type\": \"string\",\n \"pattern\": \"^sha256:[A-Za-z0-9_-]{43}$\"\n },\n \"action\": {\n \"type\": \"string\",\n \"pattern\": \"^[a-z0-9]+(\\\\.[a-z0-9_]+){2}$\"\n },\n \"verdictValue\": {\n \"enum\": [\n \"verified\",\n \"late\",\n \"mismatch\",\n \"failed\",\n \"unverifiable\"\n ]\n },\n \"reasonCode\": {\n \"enum\": [\n \"not_found\",\n \"content_mismatch\",\n \"target_mismatch\",\n \"observed_after_tolerance\",\n \"no_connection\",\n \"permission_denied\",\n \"rate_limited\",\n \"destination_unavailable\",\n \"unsupported_action\",\n \"claim_ambiguous\",\n \"verifier_error\"\n ]\n },\n \"body\": {\n \"type\": \"object\",\n \"required\": [\n \"spec_version\",\n \"receipt_id\",\n \"issued_at\",\n \"issuer\",\n \"agent\",\n \"claim\",\n \"observation\",\n \"verdict\",\n \"trust_level\"\n ],\n \"properties\": {\n \"spec_version\": {\n \"const\": \"poaw/0.1\"\n },\n \"receipt_id\": {\n \"type\": \"string\",\n \"minLength\": 1,\n \"maxLength\": 128\n },\n \"issued_at\": {\n \"$ref\": \"#/$defs/timestamp\"\n },\n \"issuer\": {\n \"type\": \"object\",\n \"required\": [\n \"key_id\"\n ],\n \"properties\": {\n \"key_id\": {\n \"$ref\": \"#/$defs/keyId\"\n },\n \"name\": {\n \"type\": \"string\",\n \"maxLength\": 128\n }\n }\n },\n \"agent\": {\n \"type\": \"object\",\n \"required\": [\n \"id\"\n ],\n \"properties\": {\n \"id\": {\n \"type\": \"string\",\n \"minLength\": 1,\n \"maxLength\": 256\n },\n \"erc8004\": {\n \"type\": \"object\",\n \"required\": [\n \"chain\",\n \"registry\",\n \"agent_id\"\n ],\n \"properties\": {\n \"chain\": {\n \"type\": \"string\",\n \"pattern\": \"^[-a-z0-9]{3,8}:[-_a-zA-Z0-9]{1,32}$\"\n },\n \"registry\": {\n \"type\": \"string\"\n },\n \"agent_id\": {\n \"type\": \"string\"\n }\n }\n }\n }\n },\n \"operator\": {\n \"type\": \"string\",\n \"maxLength\": 256\n },\n \"claim\": {\n \"type\": \"object\",\n \"required\": [\n \"action\",\n \"target\",\n \"params\",\n \"claimed_at\",\n \"claim_digest\"\n ],\n \"properties\": {\n \"action\": {\n \"$ref\": \"#/$defs/action\"\n },\n \"target\": {\n \"type\": \"string\",\n \"minLength\": 1,\n \"maxLength\": 512\n },\n \"params\": {\n \"type\": \"object\"\n },\n \"claimed_at\": {\n \"$ref\": \"#/$defs/timestamp\"\n },\n \"client_claim_id\": {\n \"type\": \"string\",\n \"maxLength\": 256\n },\n \"claim_digest\": {\n \"$ref\": \"#/$defs/b64url\"\n }\n }\n },\n \"observation\": {\n \"type\": \"object\",\n \"required\": [\n \"verifier\",\n \"observed_at\",\n \"deadline_at\",\n \"attempts\",\n \"facts\"\n ],\n \"properties\": {\n \"verifier\": {\n \"type\": \"object\",\n \"required\": [\n \"id\",\n \"version\"\n ],\n \"properties\": {\n \"id\": {\n \"$ref\": \"#/$defs/action\"\n },\n \"version\": {\n \"type\": \"string\",\n \"pattern\": \"^\\\\d+$\"\n },\n \"code_hash\": {\n \"$ref\": \"#/$defs/fingerprint\"\n }\n }\n },\n \"observed_at\": {\n \"$ref\": \"#/$defs/timestamp\"\n },\n \"deadline_at\": {\n \"$ref\": \"#/$defs/timestamp\"\n },\n \"attempts\": {\n \"type\": \"integer\",\n \"minimum\": 1\n },\n \"facts\": {\n \"type\": \"object\"\n }\n }\n },\n \"verdict\": {\n \"type\": \"object\",\n \"required\": [\n \"value\"\n ],\n \"properties\": {\n \"value\": {\n \"$ref\": \"#/$defs/verdictValue\"\n },\n \"reason_code\": {\n \"$ref\": \"#/$defs/reasonCode\"\n }\n },\n \"if\": {\n \"properties\": {\n \"value\": {\n \"const\": \"unverifiable\"\n }\n }\n },\n \"then\": {\n \"required\": [\n \"value\",\n \"reason_code\"\n ]\n }\n },\n \"trust_level\": {\n \"type\": \"integer\",\n \"minimum\": 1,\n \"maximum\": 4\n },\n \"attestation\": {\n \"type\": \"object\",\n \"required\": [\n \"type\",\n \"document\"\n ],\n \"properties\": {\n \"type\": {\n \"type\": \"string\"\n },\n \"document\": {\n \"$ref\": \"#/$defs/b64url\"\n }\n }\n },\n \"supersedes\": {\n \"type\": \"string\"\n }\n },\n \"if\": {\n \"properties\": {\n \"trust_level\": {\n \"minimum\": 3\n }\n }\n },\n \"then\": {\n \"required\": [\n \"attestation\"\n ],\n \"properties\": {\n \"observation\": {\n \"properties\": {\n \"verifier\": {\n \"required\": [\n \"id\",\n \"version\",\n \"code_hash\"\n ]\n }\n }\n }\n }\n }\n },\n \"signature\": {\n \"type\": \"object\",\n \"required\": [\n \"alg\",\n \"key_id\",\n \"value\"\n ],\n \"additionalProperties\": false,\n \"properties\": {\n \"alg\": {\n \"const\": \"Ed25519\"\n },\n \"key_id\": {\n \"$ref\": \"#/$defs/keyId\"\n },\n \"value\": {\n \"type\": \"string\",\n \"pattern\": \"^[A-Za-z0-9_-]{86}$\"\n }\n }\n },\n \"proof\": {\n \"type\": \"object\",\n \"required\": [\n \"log_id\",\n \"leaf_index\",\n \"tree_size\",\n \"root_hash\",\n \"inclusion\"\n ],\n \"properties\": {\n \"log_id\": {\n \"$ref\": \"#/$defs/b64url\"\n },\n \"leaf_index\": {\n \"type\": \"integer\",\n \"minimum\": 0\n },\n \"tree_size\": {\n \"type\": \"integer\",\n \"minimum\": 1\n },\n \"root_hash\": {\n \"$ref\": \"#/$defs/b64url\"\n },\n \"inclusion\": {\n \"type\": \"array\",\n \"items\": {\n \"$ref\": \"#/$defs/b64url\"\n }\n },\n \"anchor\": {\n \"type\": \"object\",\n \"required\": [\n \"chain\",\n \"scheme\",\n \"uid\",\n \"tx_hash\",\n \"tree_size\"\n ],\n \"properties\": {\n \"chain\": {\n \"type\": \"string\"\n },\n \"scheme\": {\n \"const\": \"eas\"\n },\n \"uid\": {\n \"type\": \"string\",\n \"pattern\": \"^0x[0-9a-fA-F]{64}$\"\n },\n \"tx_hash\": {\n \"type\": \"string\",\n \"pattern\": \"^0x[0-9a-fA-F]{64}$\"\n },\n \"tree_size\": {\n \"type\": \"integer\",\n \"minimum\": 1\n }\n }\n }\n }\n }\n }\n} as const;\n","/**\n * SPEC §8.4: check a receipt's `proof.anchor` (scheme `eas`) against a public JSON-RPC endpoint.\n * Ported from `oss/spec/tools/anchor_check.py`. Any doubt gives `ok: false` — never a pass.\n */\nimport { keccak_256 } from \"@noble/hashes/sha3\";\nimport { b64uDecode, b64u, bytesEqual } from \"./primitives.js\";\nimport { decodeSingleDynamicTupleReturn, decodeTupleWithTrailingDynamic, bytesToHex0x, hexToBytes } from \"./abi.js\";\n\nconst EAS = \"0x4200000000000000000000000000000000000021\"; // OP-stack predeploy (Base mainnet + Base Sepolia)\n\nfunction selector(signature: string): Uint8Array {\n return keccak_256(new TextEncoder().encode(signature)).slice(0, 4);\n}\n\nconst GET_SELECTOR = selector(\"getAttestation(bytes32)\");\nconst ATT_STATIC_KINDS = [\"bytes32\", \"bytes32\", \"uint64\", \"uint64\", \"uint64\", \"bytes32\", \"address\", \"address\", \"bool\"] as const;\nconst DATA_STATIC_KINDS = [\"bytes32\", \"uint64\", \"bytes32\", \"uint64\", \"bytes32\"] as const;\n\nexport interface Proof {\n log_id: string;\n leaf_index: number;\n tree_size: number;\n root_hash: string;\n inclusion: string[];\n anchor?: {\n chain: string;\n scheme: string;\n uid: string;\n tx_hash: string;\n tree_size: number;\n };\n}\n\nexport interface Keyset {\n keys?: Array<{ key_id: string; public_key: string; valid_from: string; revoked_at: string | null }>;\n anchor_addresses?: string[];\n anchor_schemas?: string[];\n}\n\nexport interface AnchorResult {\n ok: boolean;\n reason: string;\n proven_by: number | null;\n}\n\nasync function rpc(url: string, method: string, ...params: unknown[]): Promise<unknown> {\n const res = await fetch(url, {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\", \"user-agent\": \"qed-proof-sdk-js/0.1\" },\n body: JSON.stringify({ jsonrpc: \"2.0\", id: 1, method, params }),\n });\n const body = (await res.json()) as { error?: { message?: string }; result?: unknown };\n if (body && body.error) {\n throw new Error(`${method}: ${body.error.message ?? \"rpc error\"}`);\n }\n return body.result;\n}\n\n/** Return {ok, reason, proven_by}. Any doubt → ok false, never a pass. */\nexport async function checkAnchor(proof: Proof, keyset: Keyset, rpcUrl: string): Promise<AnchorResult> {\n const a = proof.anchor;\n if (!a) return { ok: false, reason: \"unknown_scheme\", proven_by: null };\n try {\n if (a.scheme !== \"eas\") return { ok: false, reason: \"unknown_scheme\", proven_by: null };\n\n const chainIdHex = (await rpc(rpcUrl, \"eth_chainId\")) as string;\n const wantChainId = a.chain.split(\":\")[1];\n if (BigInt(chainIdHex) !== BigInt(wantChainId)) {\n return { ok: false, reason: \"rpc_chain_mismatch\", proven_by: null };\n }\n\n const uid = hexToBytes(a.uid);\n const callData = new Uint8Array([...GET_SELECTOR, ...uid]);\n const out = (await rpc(rpcUrl, \"eth_call\", { to: EAS, data: bytesToHex0x(callData) }, \"latest\")) as string;\n const returnData = hexToBytes(out);\n const { statics, dynamic } = decodeSingleDynamicTupleReturn(returnData, [...ATT_STATIC_KINDS], \"bytes\");\n const [uid_, schema, time_, _exp, revokedAt, _ref, _recipient, attester, _revocable] = statics as [\n Uint8Array,\n Uint8Array,\n bigint,\n bigint,\n bigint,\n Uint8Array,\n Uint8Array,\n string,\n boolean,\n ];\n const data = dynamic as Uint8Array;\n\n if (!bytesEqual(uid_, uid) || time_ === 0n) {\n return { ok: false, reason: \"attestation_not_found\", proven_by: null };\n }\n if (revokedAt !== 0n) {\n return { ok: false, reason: \"attestation_revoked\", proven_by: null };\n }\n const attesterLower = (attester as string).toLowerCase();\n const publishedAttesters = new Set((keyset.anchor_addresses ?? []).map((x) => x.toLowerCase()));\n if (!publishedAttesters.has(attesterLower)) {\n return { ok: false, reason: \"attester_not_published\", proven_by: null };\n }\n const schemaHex = \"0x\" + bytesToHex0x(schema).slice(2);\n const publishedSchemas = new Set((keyset.anchor_schemas ?? []).map((x) => x.toLowerCase()));\n if (!publishedSchemas.has(schemaHex.toLowerCase())) {\n return { ok: false, reason: \"schema_not_published\", proven_by: null };\n }\n\n let decodedData: { statics: unknown[]; dynamic: unknown };\n try {\n decodedData = decodeTupleWithTrailingDynamic(data, [...DATA_STATIC_KINDS], \"string\");\n } catch {\n return { ok: false, reason: \"data_undecodable\", proven_by: null };\n }\n const [logId, size, root, _prevSize, _prevRoot] = decodedData.statics as [Uint8Array, bigint, Uint8Array, bigint, Uint8Array];\n\n if (!bytesEqual(logId, b64uDecode(proof.log_id)) || size !== BigInt(a.tree_size)) {\n return { ok: false, reason: \"log_or_size_mismatch\", proven_by: null };\n }\n if (a.tree_size !== proof.tree_size) {\n // this issuer proves at the anchored size\n return { ok: false, reason: \"consistency_proof_required\", proven_by: null };\n }\n if (!bytesEqual(root, b64uDecode(proof.root_hash))) {\n return { ok: false, reason: \"root_mismatch\", proven_by: null };\n }\n return { ok: true, reason: \"anchored\", proven_by: Number(time_) };\n } catch (exc) {\n const name = exc instanceof Error ? exc.constructor.name : \"Error\";\n return { ok: false, reason: `unreadable:${name}`, proven_by: null };\n }\n}\n","/**\n * A tiny hand-written ABI decoder for exactly the two structs SPEC §8.4 needs (ported from\n * `oss/spec/tools/anchor_check.py`, which uses `eth_abi.decode`). Not a general ABI library:\n * it only decodes a tuple of N-1 static 32-byte-word fields followed by one trailing dynamic\n * field (`bytes` or `string`), which is exactly the shape of the EAS `Attestation` struct and\n * its decoded `data` payload.\n */\n\nexport type StaticFieldKind = \"bytes32\" | \"uint64\" | \"address\" | \"bool\";\n\nfunction readWord(data: Uint8Array, wordIndex: number): Uint8Array {\n const start = wordIndex * 32;\n return data.subarray(start, start + 32);\n}\n\nfunction decodeStaticField(word: Uint8Array, kind: StaticFieldKind): Uint8Array | bigint | string | boolean {\n switch (kind) {\n case \"bytes32\":\n return word.slice();\n case \"uint64\": {\n let v = 0n;\n for (let i = 24; i < 32; i++) v = (v << 8n) | BigInt(word[i]);\n return v;\n }\n case \"address\": {\n const bytes = word.subarray(12, 32);\n return \"0x\" + Buffer_toHex(bytes);\n }\n case \"bool\":\n return word[31] !== 0;\n }\n}\n\nfunction Buffer_toHex(bytes: Uint8Array): string {\n let s = \"\";\n for (const b of bytes) s += b.toString(16).padStart(2, \"0\");\n return s;\n}\n\n/**\n * Decodes a tuple made of `staticKinds` (each one 32-byte word), followed by exactly one\n * trailing dynamic field of type `bytes` or `string`. `data` is the tuple's own encoding region\n * (offsets inside it are relative to its start), matching how `eth_abi.decode([_ATT], ...)` and\n * the nested `abi_decode(_DATA, data)` call are used in `anchor_check.py`.\n */\nexport function decodeTupleWithTrailingDynamic(\n data: Uint8Array,\n staticKinds: StaticFieldKind[],\n dynamicKind: \"bytes\" | \"string\",\n): { statics: Array<Uint8Array | bigint | string | boolean>; dynamic: Uint8Array | string } {\n const statics = staticKinds.map((kind, i) => decodeStaticField(readWord(data, i), kind));\n const offsetWord = readWord(data, staticKinds.length);\n let offset = 0n;\n for (const b of offsetWord) offset = (offset << 8n) | BigInt(b);\n const off = Number(offset);\n const lenWord = data.subarray(off, off + 32);\n let len = 0n;\n for (const b of lenWord) len = (len << 8n) | BigInt(b);\n const length = Number(len);\n const raw = data.subarray(off + 32, off + 32 + length);\n const dynamic = dynamicKind === \"string\" ? new TextDecoder().decode(raw) : raw.slice();\n return { statics, dynamic };\n}\n\n/**\n * Decodes the return value of a function whose Solidity signature returns a single dynamic\n * tuple (as `getAttestation(bytes32) returns (Attestation memory)` does): the outer word is an\n * offset to where the tuple's own head+tail encoding begins.\n */\nexport function decodeSingleDynamicTupleReturn(\n returnData: Uint8Array,\n staticKinds: StaticFieldKind[],\n dynamicKind: \"bytes\" | \"string\",\n) {\n const outerOffsetWord = readWord(returnData, 0);\n let outerOffset = 0n;\n for (const b of outerOffsetWord) outerOffset = (outerOffset << 8n) | BigInt(b);\n const tupleStart = Number(outerOffset);\n return decodeTupleWithTrailingDynamic(returnData.subarray(tupleStart), staticKinds, dynamicKind);\n}\n\nexport function bytesToHex0x(bytes: Uint8Array): string {\n return \"0x\" + Buffer_toHex(bytes);\n}\n\nexport function hexToBytes(hex: string): Uint8Array {\n const clean = hex.startsWith(\"0x\") ? hex.slice(2) : hex;\n const out = new Uint8Array(clean.length / 2);\n for (let i = 0; i < out.length; i++) out[i] = parseInt(clean.substr(i * 2, 2), 16);\n return out;\n}\n","/**\n * Reference checker for PoAW receipts (SPEC.md §10), ported from `oss/spec/tools/check.py` and\n * `oss/spec/tools/anchor_check.py`. Offline it checks steps 1-4. With `rpcUrl` it also checks the\n * anchor against the chain (§8.4). Any doubt gives a failing check, never a pass.\n */\nimport {\n b64uDecode,\n claimDigest,\n hasFloatValue,\n hasFloatText,\n keyId,\n leafHash,\n rootFromInclusion,\n verifySignature,\n b64u,\n} from \"./primitives.js\";\nimport { schemaValid } from \"./schema.js\";\nimport { checkAnchor, type Keyset, type Proof } from \"./anchor.js\";\n\nexport interface VerifyChecks {\n spec_version: boolean;\n schema: boolean;\n integers_only: boolean;\n key: boolean;\n signature: boolean;\n claim_digest: boolean;\n inclusion: boolean | \"absent\";\n anchor: boolean | \"absent\" | \"not_checked_offline\" | string;\n}\n\nexport interface VerifyReport {\n checks: VerifyChecks;\n valid: boolean;\n verdict: string | null;\n achieved_trust_level: number;\n proven_by?: number | null;\n}\n\nexport interface VerifyOptions {\n keys: Keyset;\n rpcUrl?: string;\n}\n\ninterface ReceiptLike {\n body?: Record<string, unknown>;\n signature?: { key_id?: string; value?: string };\n proof?: Proof;\n [key: string]: unknown;\n}\n\n/**\n * Verify a PoAW receipt. `receipt` may be a parsed object or the raw JSON text — passing the raw\n * text lets the integers-only check catch a float written as e.g. `1.0` (indistinguishable from\n * the integer `1` after `JSON.parse`), matching Python's `json.loads` int/float distinction\n * exactly; a non-integer value like `0.5` is caught either way.\n */\n/**\n * The JSON text each receipt object was parsed from, when the SDK fetched it (`QedProof.getReceipt`). JSON.parse turns\n * `1.0` into `1`, which would hide a float SPEC §3 forbids, so verification reads the original text when it has it.\n * That way a fetched receipt verifies exactly as it does in the Python SDK and the reference checker.\n */\nexport const RECEIPT_TEXT = new WeakMap<object, string>();\n\nexport async function verifyReceipt(receipt: unknown | string, options: VerifyOptions): Promise<VerifyReport> {\n const raw = typeof receipt === \"string\" ? receipt\n : receipt && typeof receipt === \"object\" ? RECEIPT_TEXT.get(receipt as object) : undefined;\n const parsed: ReceiptLike = typeof receipt === \"string\" ? JSON.parse(receipt) : ((receipt as ReceiptLike) ?? {});\n const keyset = options.keys ?? {};\n\n const checks = {} as VerifyChecks;\n\n const body = (parsed && typeof parsed === \"object\" ? parsed.body : undefined) ?? {};\n const version = String((body as Record<string, unknown>).spec_version ?? \"\");\n const parts = version.split(\"/\");\n checks.spec_version = parts[0] === \"poaw\" && (parts[parts.length - 1] ?? \"\").split(\".\")[0] === \"0\";\n\n checks.schema = schemaValid(parsed);\n\n const integerFail = raw !== undefined ? hasFloatText(raw) : hasFloatValue(parsed);\n checks.integers_only = !integerFail;\n\n const sig = (parsed && typeof parsed === \"object\" ? parsed.signature : undefined) ?? ({} as ReceiptLike[\"signature\"]);\n const keys = keyset.keys ?? [];\n const key = keys.find((k) => k.key_id === sig?.key_id);\n const issued = String((body as Record<string, unknown>).issued_at ?? \"\");\n const issuer = (body as Record<string, unknown>).issuer as { key_id?: string } | undefined;\n\n let keyOk = false;\n if (key && sig?.key_id === issuer?.key_id) {\n try {\n const computedKeyId = keyId(b64uDecode(key.public_key));\n keyOk =\n computedKeyId === key.key_id &&\n key.valid_from <= issued &&\n (key.revoked_at === null || key.revoked_at === undefined || issued < key.revoked_at);\n } catch {\n keyOk = false;\n }\n }\n checks.key = keyOk;\n\n let sigOk = false;\n if (keyOk && key) {\n try {\n sigOk = verifySignature(b64uDecode(key.public_key), body, sig?.value ?? \"\");\n } catch {\n sigOk = false;\n }\n }\n checks.signature = sigOk;\n\n const claim = (body as Record<string, unknown>).claim;\n checks.claim_digest =\n Boolean(claim) &&\n typeof claim === \"object\" &&\n (claim as Record<string, unknown>).claim_digest === claimDigest(claim as Record<string, unknown>);\n\n const proof = parsed && typeof parsed === \"object\" ? parsed.proof : undefined;\n let provenBy: number | null | undefined;\n if (!proof) {\n checks.inclusion = \"absent\";\n } else {\n const root = rootFromInclusion(\n proof.leaf_index,\n proof.tree_size,\n leafHash({ body: (parsed as ReceiptLike).body, signature: (parsed as ReceiptLike).signature }),\n proof.inclusion.map((h) => b64uDecode(h)),\n );\n checks.inclusion = root !== null && b64u(root) === proof.root_hash;\n }\n\n if (!(proof && proof.anchor)) {\n checks.anchor = \"absent\";\n } else if (!options.rpcUrl) {\n checks.anchor = \"not_checked_offline\";\n } else {\n const a = await checkAnchor(proof, keyset, options.rpcUrl);\n checks.anchor = a.ok ? true : a.reason;\n provenBy = a.proven_by;\n }\n\n const required: Array<keyof VerifyChecks> = [\n \"spec_version\",\n \"schema\",\n \"integers_only\",\n \"key\",\n \"signature\",\n \"claim_digest\",\n ];\n const valid = required.every((k) => checks[k] === true) && (checks.inclusion === true || checks.inclusion === \"absent\");\n\n const achievedTrustLevel = valid ? (checks.inclusion === true && checks.anchor === true ? 2 : 1) : 0;\n const verdictValue = (body as Record<string, unknown>).verdict as { value?: string } | undefined;\n const verdict = valid ? (verdictValue?.value ?? null) : null;\n\n const report: VerifyReport = {\n checks,\n valid,\n verdict: verdict ?? null,\n achieved_trust_level: achievedTrustLevel,\n };\n if (provenBy !== undefined) {\n report.proven_by = provenBy;\n }\n return report;\n}\n","/**\n * The HTTP client. Shapes follow `oss/node/src/poaw_node/app.py`, `models.py` (`ClaimIn`) and\n * `store.py` (`claim_status`). Uses only `fetch` — no Node built-ins — so it runs on Node, Deno\n * and in browsers.\n */\nimport type { ClaimAction } from \"./actions.js\";\nimport { QedProofError, RateLimitError } from \"./errors.js\";\nimport { RECEIPT_TEXT, verifyReceipt, type VerifyReport } from \"./verify.js\";\nimport type { Keyset } from \"./anchor.js\";\n\nexport interface QedProofOptions {\n apiKey?: string;\n baseUrl?: string;\n fetch?: typeof fetch;\n}\n\nexport interface SubmitClaimOptions {\n agentId: string;\n clientClaimId?: string;\n claimedAt?: string | Date;\n}\n\nexport interface ClaimStatus {\n claim_id: string;\n created?: boolean;\n state: \"queued\" | \"decided\";\n attempts: number;\n receipt_id: string | null;\n verdict: string | null;\n}\n\nexport interface WaitOptions {\n timeoutMs?: number;\n pollIntervalMs?: number;\n}\n\nexport interface Receipt {\n body: Record<string, unknown>;\n signature: Record<string, unknown>;\n proof?: Record<string, unknown>;\n [key: string]: unknown;\n}\n\nexport interface ClaimSummary {\n claim_id: string;\n state: string;\n attempts: number;\n receipt_id: string | null;\n verdict: string | null;\n}\n\nexport interface ListClaimsOptions {\n limit?: number;\n cursor?: string;\n agentId?: string;\n action?: string;\n verdict?: string;\n state?: string;\n}\n\nexport interface ClaimPage {\n claims: ClaimSummary[];\n nextCursor: string | null;\n}\n\nconst LIST_CLAIMS_DEFAULT_LIMIT = 50;\nconst LIST_CLAIMS_MIN_LIMIT = 1;\nconst LIST_CLAIMS_MAX_LIMIT = 200;\n\nconst DEFAULT_BASE_URL = \"https://api.qedproof.site\";\n\nfunction isoNow(): string {\n return new Date().toISOString();\n}\n\nexport class QedProof {\n private readonly apiKey?: string;\n private readonly baseUrl: string;\n private readonly fetchImpl: typeof fetch;\n\n constructor(options: QedProofOptions = {}) {\n this.apiKey = options.apiKey;\n this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/+$/, \"\");\n this.fetchImpl = options.fetch ?? globalThis.fetch;\n if (!this.fetchImpl) {\n throw new Error(\"QedProof: no fetch implementation available; pass { fetch } explicitly\");\n }\n }\n\n private async request(\n method: string,\n path: string,\n { auth = true, body, text = false }: { auth?: boolean; body?: unknown; text?: boolean } = {},\n ): Promise<unknown> {\n const headers: Record<string, string> = { accept: \"application/json\" };\n if (body !== undefined) headers[\"content-type\"] = \"application/json\";\n if (auth) {\n if (!this.apiKey) {\n throw new QedProofError(401, \"no API key configured\");\n }\n headers[\"authorization\"] = `Bearer ${this.apiKey}`;\n }\n let res: Response;\n try {\n res = await this.fetchImpl(`${this.baseUrl}${path}`, {\n method,\n headers,\n body: body !== undefined ? JSON.stringify(body) : undefined,\n });\n } catch (exc) {\n // Never let a network failure leak the key: the message here never includes `this.apiKey`.\n throw new QedProofError(0, `network error: ${exc instanceof Error ? exc.message : String(exc)}`);\n }\n\n if (res.status === 429) {\n const retryAfterHeader = res.headers.get(\"retry-after\");\n const retryAfter = retryAfterHeader ? Number(retryAfterHeader) : undefined;\n let detail = \"rate limit exceeded\";\n try {\n const parsed = (await res.json()) as { detail?: string };\n if (parsed?.detail) detail = parsed.detail;\n } catch {\n // ignore body parse failure, keep default detail\n }\n throw new RateLimitError(detail, Number.isFinite(retryAfter) ? retryAfter : undefined);\n }\n\n if (!res.ok) {\n let detail = res.statusText;\n try {\n const parsed = (await res.json()) as { detail?: string };\n if (parsed?.detail) detail = parsed.detail;\n } catch {\n // ignore body parse failure, keep statusText\n }\n throw new QedProofError(res.status, detail);\n }\n\n if (res.status === 204) return undefined;\n if (text) return res.text();\n return res.json();\n }\n\n async submitClaim(claim: ClaimAction, options: SubmitClaimOptions): Promise<ClaimStatus> {\n const claimedAt = options.claimedAt instanceof Date ? options.claimedAt.toISOString() : (options.claimedAt ?? isoNow());\n const body = {\n client_claim_id: options.clientClaimId ?? cryptoRandomId(),\n agent_id: options.agentId,\n action: claim.action,\n target: claim.target,\n params: claim.params,\n claimed_at: claimedAt,\n };\n return (await this.request(\"POST\", \"/v1/claims\", { body })) as ClaimStatus;\n }\n\n async getClaim(claimId: string): Promise<ClaimStatus> {\n return (await this.request(\"GET\", `/v1/claims/${encodeURIComponent(claimId)}`)) as ClaimStatus;\n }\n\n async waitForVerdict(claimId: string, options: WaitOptions = {}): Promise<ClaimStatus> {\n const timeoutMs = options.timeoutMs ?? 120_000;\n const pollIntervalMs = options.pollIntervalMs ?? 2_000;\n const deadline = Date.now() + timeoutMs;\n for (;;) {\n let wait = pollIntervalMs;\n try {\n const status = await this.getClaim(claimId);\n if (status.state === \"decided\") return status;\n } catch (exc) {\n if (exc instanceof RateLimitError && exc.retryAfter !== undefined) {\n wait = Math.max(wait, exc.retryAfter * 1000);\n } else {\n throw exc;\n }\n }\n if (Date.now() >= deadline) {\n throw new QedProofError(408, `timed out after ${timeoutMs}ms waiting for claim ${claimId} to decide`);\n }\n await sleep(Math.min(wait, Math.max(0, deadline - Date.now())));\n }\n }\n\n /**\n * `GET /v1/claims`, newest first. `options.limit` (1-200, default 50) is validated locally —\n * out of range throws a `RangeError` before any request is made.\n */\n async listClaims(options: ListClaimsOptions = {}): Promise<ClaimPage> {\n const limit = options.limit ?? LIST_CLAIMS_DEFAULT_LIMIT;\n if (limit < LIST_CLAIMS_MIN_LIMIT || limit > LIST_CLAIMS_MAX_LIMIT) {\n throw new RangeError(`limit must be between ${LIST_CLAIMS_MIN_LIMIT} and ${LIST_CLAIMS_MAX_LIMIT}, got ${limit}`);\n }\n const query: Record<string, string> = { limit: String(limit) };\n if (options.cursor !== undefined) query.cursor = options.cursor;\n if (options.agentId !== undefined) query.agent_id = options.agentId;\n if (options.action !== undefined) query.action = options.action;\n if (options.verdict !== undefined) query.verdict = options.verdict;\n if (options.state !== undefined) query.state = options.state;\n const qs = new URLSearchParams(query).toString();\n const data = (await this.request(\"GET\", `/v1/claims?${qs}`)) as { claims: ClaimSummary[]; next_cursor: string | null };\n return { claims: data.claims, nextCursor: data.next_cursor };\n }\n\n /** Yields every claim matching the filters, following `nextCursor` until exhausted. */\n async *iterClaims(options: Omit<ListClaimsOptions, \"cursor\" | \"limit\"> & { pageSize?: number } = {}): AsyncGenerator<ClaimSummary> {\n const { pageSize, ...filters } = options;\n let cursor: string | undefined;\n for (;;) {\n const page = await this.listClaims({ ...filters, limit: pageSize, cursor });\n yield* page.claims;\n if (page.nextCursor === null) return;\n cursor = page.nextCursor;\n }\n }\n\n /** Receipts are designed to be shared and checked by anyone (SPEC §1): no Authorization header. */\n async getReceipt(receiptId: string): Promise<Receipt> {\n const text = (await this.request(\"GET\", `/v1/receipts/${encodeURIComponent(receiptId)}`, { auth: false, text: true })) as string;\n const receipt = JSON.parse(text) as Receipt;\n RECEIPT_TEXT.set(receipt as object, text);\n return receipt;\n }\n\n /** Public by design: `/.well-known/poaw-keys.json` (SPEC §5.2, §8.4). */\n async getKeys(): Promise<Keyset> {\n return (await this.request(\"GET\", \"/.well-known/poaw-keys.json\", { auth: false })) as Keyset;\n }\n\n async verify(receipt: unknown | string, options: { keys?: Keyset; rpcUrl?: string } = {}): Promise<VerifyReport> {\n const keys = options.keys ?? (await this.getKeys());\n return verifyReceipt(receipt, { keys, rpcUrl: options.rpcUrl });\n }\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nfunction cryptoRandomId(): string {\n const g = globalThis as { crypto?: { randomUUID?: () => string } };\n if (g.crypto?.randomUUID) return g.crypto.randomUUID();\n return `claim-${Date.now()}-${Math.random().toString(36).slice(2)}`;\n}\n","/**\n * Typed helpers for the five live actions plus `http.url.status`, matching the wire shape the\n * node's verifiers expect (`oss/spec/profiles/*.md`, `oss/node/src/poaw_node/verifiers/*.py`).\n * Validation here is cheap and local — it never calls the network — but it fails fast with a\n * clear message before the claim is submitted, since params are copied into public receipts.\n */\n\nexport interface ClaimAction {\n action: string;\n target: string;\n params: Record<string, unknown>;\n}\n\nconst REPO_RE = /^[A-Za-z0-9_.-]+\\/[A-Za-z0-9_.-]+$/;\nconst SHA_RE = /^[0-9a-f]{40}$/;\nconst HANDLE_RE = /^@[A-Za-z0-9_]{1,15}$/;\nconst POST_ID_RE = /^[0-9]{1,20}$/;\nconst HEX64_RE = /^[0-9a-f]{64}$/;\nconst SLACK_TARGET_RE = /^slack:\\/\\/(T[A-Z0-9]{2,20})\\/([CG][A-Z0-9]{2,20})$/;\nconst SLACK_TS_RE = /^[0-9]{10}\\.[0-9]{6}$/;\n\nfunction assert(condition: unknown, message: string): asserts condition {\n if (!condition) throw new TypeError(message);\n}\n\nexport function githubCommitPush(input: { target: string; sha: string; branch: string }): ClaimAction {\n assert(REPO_RE.test(input.target), \"githubCommitPush: target must be 'owner/repo'\");\n assert(SHA_RE.test(input.sha), \"githubCommitPush: sha must be 40 lowercase hex characters\");\n assert(input.branch && input.branch.length > 0, \"githubCommitPush: branch is required\");\n return { action: \"github.commit.push\", target: input.target, params: { sha: input.sha, branch: input.branch } };\n}\n\nexport function githubPrOpen(input: { target: string; number: number; base?: string; headSha?: string }): ClaimAction {\n assert(REPO_RE.test(input.target), \"githubPrOpen: target must be 'owner/repo'\");\n assert(Number.isInteger(input.number) && input.number >= 1, \"githubPrOpen: number must be a positive integer\");\n if (input.headSha !== undefined) {\n assert(SHA_RE.test(input.headSha), \"githubPrOpen: headSha must be 40 lowercase hex characters\");\n }\n const params: Record<string, unknown> = { number: input.number };\n if (input.base !== undefined) params.base = input.base;\n if (input.headSha !== undefined) params.head_sha = input.headSha;\n return { action: \"github.pr.open\", target: input.target, params };\n}\n\nexport function githubChecksPass(input: { target: string; sha: string }): ClaimAction {\n assert(REPO_RE.test(input.target), \"githubChecksPass: target must be 'owner/repo'\");\n assert(SHA_RE.test(input.sha), \"githubChecksPass: sha must be 40 lowercase hex characters\");\n return { action: \"github.checks.pass\", target: input.target, params: { sha: input.sha } };\n}\n\nexport function xPostPublish(input: { target: string; postId: string; textSha256?: string }): ClaimAction {\n assert(HANDLE_RE.test(input.target), \"xPostPublish: target must be an @handle\");\n assert(POST_ID_RE.test(input.postId), \"xPostPublish: postId must be digits\");\n if (input.textSha256 !== undefined) {\n assert(HEX64_RE.test(input.textSha256), \"xPostPublish: textSha256 must be 64 lowercase hex characters\");\n }\n const params: Record<string, unknown> = { post_id: input.postId };\n if (input.textSha256 !== undefined) params.text_sha256 = input.textSha256;\n return { action: \"x.post.publish\", target: input.target, params };\n}\n\nexport function slackMessagePost(input: { target: string; ts: string; textSha256?: string }): ClaimAction {\n assert(SLACK_TARGET_RE.test(input.target), \"slackMessagePost: target must be slack://<team_id>/<channel_id>\");\n assert(SLACK_TS_RE.test(input.ts), \"slackMessagePost: ts must match ^[0-9]{10}\\\\.[0-9]{6}$\");\n if (input.textSha256 !== undefined) {\n assert(HEX64_RE.test(input.textSha256), \"slackMessagePost: textSha256 must be 64 lowercase hex characters\");\n }\n const params: Record<string, unknown> = { ts: input.ts };\n if (input.textSha256 !== undefined) params.text_sha256 = input.textSha256;\n return { action: \"slack.message.post\", target: input.target, params };\n}\n\nexport function httpUrlStatus(input: { target: string; status?: number; contentFingerprint?: string }): ClaimAction {\n let url: URL;\n try {\n url = new URL(input.target);\n } catch {\n throw new TypeError(\"httpUrlStatus: target must be a valid URL\");\n }\n assert(url.protocol === \"https:\", \"httpUrlStatus: target must be an https:// URL\");\n const params: Record<string, unknown> = {};\n if (input.status !== undefined) {\n assert(Number.isInteger(input.status), \"httpUrlStatus: status must be an integer\");\n params.status = input.status;\n }\n if (input.contentFingerprint !== undefined) params.content_fingerprint = input.contentFingerprint;\n return { action: \"http.url.status\", target: input.target, params };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,gBAAN,cAA4B,MAAM;AAAA,EACvC;AAAA,EACA;AAAA,EAEA,YAAY,QAAgB,QAAgB;AAC1C,UAAM,sBAAsB,MAAM,KAAK,MAAM,EAAE;AAC/C,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,SAAS;AAAA,EAChB;AACF;AAEO,IAAM,iBAAN,cAA6B,cAAc;AAAA,EAChD;AAAA,EAEA,YAAY,QAAgB,YAAgC;AAC1D,UAAM,KAAK,MAAM;AACjB,SAAK,OAAO;AACZ,SAAK,aAAa;AAAA,EACpB;AACF;;;ACdA,qBAAwB;AACxB,kBAAsC;AACtC,0BAA4B;AAErB,IAAM,eAAe;AACrB,IAAM,aAAa,IAAI,YAAY,EAAE,OAAO,mBAAmB;AAI/D,SAAS,KAAK,MAA0B;AAC7C,MAAI,SAAS;AACb,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,IAAK,WAAU,OAAO,a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
* Typed helpers for the five live actions plus `http.url.status`, matching the wire shape the
|
|
3
|
+
* node's verifiers expect (`oss/spec/profiles/*.md`, `oss/node/src/poaw_node/verifiers/*.py`).
|
|
4
|
+
* Validation here is cheap and local — it never calls the network — but it fails fast with a
|
|
5
|
+
* clear message before the claim is submitted, since params are copied into public receipts.
|
|
6
|
+
*/
|
|
7
|
+
interface ClaimAction {
|
|
8
|
+
action: string;
|
|
9
|
+
target: string;
|
|
10
|
+
params: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
declare function githubCommitPush(input: {
|
|
13
|
+
target: string;
|
|
14
|
+
sha: string;
|
|
15
|
+
branch: string;
|
|
16
|
+
}): ClaimAction;
|
|
17
|
+
declare function githubPrOpen(input: {
|
|
18
|
+
target: string;
|
|
19
|
+
number: number;
|
|
20
|
+
base?: string;
|
|
21
|
+
headSha?: string;
|
|
22
|
+
}): ClaimAction;
|
|
23
|
+
declare function githubChecksPass(input: {
|
|
24
|
+
target: string;
|
|
25
|
+
sha: string;
|
|
26
|
+
}): ClaimAction;
|
|
27
|
+
declare function xPostPublish(input: {
|
|
28
|
+
target: string;
|
|
29
|
+
postId: string;
|
|
30
|
+
textSha256?: string;
|
|
31
|
+
}): ClaimAction;
|
|
32
|
+
declare function slackMessagePost(input: {
|
|
33
|
+
target: string;
|
|
34
|
+
ts: string;
|
|
35
|
+
textSha256?: string;
|
|
36
|
+
}): ClaimAction;
|
|
37
|
+
declare function httpUrlStatus(input: {
|
|
38
|
+
target: string;
|
|
39
|
+
status?: number;
|
|
40
|
+
contentFingerprint?: string;
|
|
41
|
+
}): ClaimAction;
|
|
42
|
+
|
|
43
|
+
type actions_ClaimAction = ClaimAction;
|
|
44
|
+
declare const actions_githubChecksPass: typeof githubChecksPass;
|
|
45
|
+
declare const actions_githubCommitPush: typeof githubCommitPush;
|
|
46
|
+
declare const actions_githubPrOpen: typeof githubPrOpen;
|
|
47
|
+
declare const actions_httpUrlStatus: typeof httpUrlStatus;
|
|
48
|
+
declare const actions_slackMessagePost: typeof slackMessagePost;
|
|
49
|
+
declare const actions_xPostPublish: typeof xPostPublish;
|
|
50
|
+
declare namespace actions {
|
|
51
|
+
export { type actions_ClaimAction as ClaimAction, actions_githubChecksPass as githubChecksPass, actions_githubCommitPush as githubCommitPush, actions_githubPrOpen as githubPrOpen, actions_httpUrlStatus as httpUrlStatus, actions_slackMessagePost as slackMessagePost, actions_xPostPublish as xPostPublish };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
interface Proof$1 {
|
|
55
|
+
log_id: string;
|
|
56
|
+
leaf_index: number;
|
|
57
|
+
tree_size: number;
|
|
58
|
+
root_hash: string;
|
|
59
|
+
inclusion: string[];
|
|
60
|
+
anchor?: {
|
|
61
|
+
chain: string;
|
|
62
|
+
scheme: string;
|
|
63
|
+
uid: string;
|
|
64
|
+
tx_hash: string;
|
|
65
|
+
tree_size: number;
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
interface Keyset {
|
|
69
|
+
keys?: Array<{
|
|
70
|
+
key_id: string;
|
|
71
|
+
public_key: string;
|
|
72
|
+
valid_from: string;
|
|
73
|
+
revoked_at: string | null;
|
|
74
|
+
}>;
|
|
75
|
+
anchor_addresses?: string[];
|
|
76
|
+
anchor_schemas?: string[];
|
|
77
|
+
}
|
|
78
|
+
interface AnchorResult {
|
|
79
|
+
ok: boolean;
|
|
80
|
+
reason: string;
|
|
81
|
+
proven_by: number | null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
interface VerifyChecks {
|
|
85
|
+
spec_version: boolean;
|
|
86
|
+
schema: boolean;
|
|
87
|
+
integers_only: boolean;
|
|
88
|
+
key: boolean;
|
|
89
|
+
signature: boolean;
|
|
90
|
+
claim_digest: boolean;
|
|
91
|
+
inclusion: boolean | "absent";
|
|
92
|
+
anchor: boolean | "absent" | "not_checked_offline" | string;
|
|
93
|
+
}
|
|
94
|
+
interface VerifyReport {
|
|
95
|
+
checks: VerifyChecks;
|
|
96
|
+
valid: boolean;
|
|
97
|
+
verdict: string | null;
|
|
98
|
+
achieved_trust_level: number;
|
|
99
|
+
proven_by?: number | null;
|
|
100
|
+
}
|
|
101
|
+
interface VerifyOptions {
|
|
102
|
+
keys: Keyset;
|
|
103
|
+
rpcUrl?: string;
|
|
104
|
+
}
|
|
105
|
+
declare function verifyReceipt(receipt: unknown | string, options: VerifyOptions): Promise<VerifyReport>;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The HTTP client. Shapes follow `oss/node/src/poaw_node/app.py`, `models.py` (`ClaimIn`) and
|
|
109
|
+
* `store.py` (`claim_status`). Uses only `fetch` — no Node built-ins — so it runs on Node, Deno
|
|
110
|
+
* and in browsers.
|
|
111
|
+
*/
|
|
112
|
+
|
|
113
|
+
interface QedProofOptions {
|
|
114
|
+
apiKey?: string;
|
|
115
|
+
baseUrl?: string;
|
|
116
|
+
fetch?: typeof fetch;
|
|
117
|
+
}
|
|
118
|
+
interface SubmitClaimOptions {
|
|
119
|
+
agentId: string;
|
|
120
|
+
clientClaimId?: string;
|
|
121
|
+
claimedAt?: string | Date;
|
|
122
|
+
}
|
|
123
|
+
interface ClaimStatus {
|
|
124
|
+
claim_id: string;
|
|
125
|
+
created?: boolean;
|
|
126
|
+
state: "queued" | "decided";
|
|
127
|
+
attempts: number;
|
|
128
|
+
receipt_id: string | null;
|
|
129
|
+
verdict: string | null;
|
|
130
|
+
}
|
|
131
|
+
interface WaitOptions {
|
|
132
|
+
timeoutMs?: number;
|
|
133
|
+
pollIntervalMs?: number;
|
|
134
|
+
}
|
|
135
|
+
interface Receipt {
|
|
136
|
+
body: Record<string, unknown>;
|
|
137
|
+
signature: Record<string, unknown>;
|
|
138
|
+
proof?: Record<string, unknown>;
|
|
139
|
+
[key: string]: unknown;
|
|
140
|
+
}
|
|
141
|
+
interface ClaimSummary {
|
|
142
|
+
claim_id: string;
|
|
143
|
+
state: string;
|
|
144
|
+
attempts: number;
|
|
145
|
+
receipt_id: string | null;
|
|
146
|
+
verdict: string | null;
|
|
147
|
+
}
|
|
148
|
+
interface ListClaimsOptions {
|
|
149
|
+
limit?: number;
|
|
150
|
+
cursor?: string;
|
|
151
|
+
agentId?: string;
|
|
152
|
+
action?: string;
|
|
153
|
+
verdict?: string;
|
|
154
|
+
state?: string;
|
|
155
|
+
}
|
|
156
|
+
interface ClaimPage {
|
|
157
|
+
claims: ClaimSummary[];
|
|
158
|
+
nextCursor: string | null;
|
|
159
|
+
}
|
|
160
|
+
declare class QedProof {
|
|
161
|
+
private readonly apiKey?;
|
|
162
|
+
private readonly baseUrl;
|
|
163
|
+
private readonly fetchImpl;
|
|
164
|
+
constructor(options?: QedProofOptions);
|
|
165
|
+
private request;
|
|
166
|
+
submitClaim(claim: ClaimAction, options: SubmitClaimOptions): Promise<ClaimStatus>;
|
|
167
|
+
getClaim(claimId: string): Promise<ClaimStatus>;
|
|
168
|
+
waitForVerdict(claimId: string, options?: WaitOptions): Promise<ClaimStatus>;
|
|
169
|
+
/**
|
|
170
|
+
* `GET /v1/claims`, newest first. `options.limit` (1-200, default 50) is validated locally —
|
|
171
|
+
* out of range throws a `RangeError` before any request is made.
|
|
172
|
+
*/
|
|
173
|
+
listClaims(options?: ListClaimsOptions): Promise<ClaimPage>;
|
|
174
|
+
/** Yields every claim matching the filters, following `nextCursor` until exhausted. */
|
|
175
|
+
iterClaims(options?: Omit<ListClaimsOptions, "cursor" | "limit"> & {
|
|
176
|
+
pageSize?: number;
|
|
177
|
+
}): AsyncGenerator<ClaimSummary>;
|
|
178
|
+
/** Receipts are designed to be shared and checked by anyone (SPEC §1): no Authorization header. */
|
|
179
|
+
getReceipt(receiptId: string): Promise<Receipt>;
|
|
180
|
+
/** Public by design: `/.well-known/poaw-keys.json` (SPEC §5.2, §8.4). */
|
|
181
|
+
getKeys(): Promise<Keyset>;
|
|
182
|
+
verify(receipt: unknown | string, options?: {
|
|
183
|
+
keys?: Keyset;
|
|
184
|
+
rpcUrl?: string;
|
|
185
|
+
}): Promise<VerifyReport>;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
declare class QedProofError extends Error {
|
|
189
|
+
status: number;
|
|
190
|
+
detail: string;
|
|
191
|
+
constructor(status: number, detail: string);
|
|
192
|
+
}
|
|
193
|
+
declare class RateLimitError extends QedProofError {
|
|
194
|
+
retryAfter: number | undefined;
|
|
195
|
+
constructor(detail: string, retryAfter: number | undefined);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
declare const SPEC_VERSION = "poaw/0.1";
|
|
199
|
+
declare const SIG_DOMAIN: Uint8Array<ArrayBuffer>;
|
|
200
|
+
declare function b64u(data: Uint8Array): string;
|
|
201
|
+
declare function b64uDecode(text: string): Uint8Array;
|
|
202
|
+
/** RFC 8785 JCS, as UTF-8 bytes (matches Python's `rfc8785.dumps`, which returns bytes). */
|
|
203
|
+
declare function jcs(obj: unknown): Uint8Array;
|
|
204
|
+
declare function sha256(data: Uint8Array): Uint8Array;
|
|
205
|
+
/**
|
|
206
|
+
* §3: receipts carry integers only. JSON.parse collapses the int/float distinction Python's
|
|
207
|
+
* `json.loads` preserves (e.g. `1.0` parses to the same JS number as `1`), so this checks two
|
|
208
|
+
* ways:
|
|
209
|
+
* - `hasFloatValue`: any value that is a non-integer finite number (catches every float that
|
|
210
|
+
* actually matters, e.g. `0.5` in vector 014-float-in-body.json).
|
|
211
|
+
* - `hasFloatText`: scans the raw JSON text (outside string literals) for a numeric token
|
|
212
|
+
* containing `.`, `e` or `E` — the same signal Python's tokenizer used to decide `float` vs
|
|
213
|
+
* `int`, for callers that still have the original text (files, HTTP bodies).
|
|
214
|
+
* `verifyReceipt` OR's both when raw text is available, so nothing is hidden by `JSON.parse`.
|
|
215
|
+
*/
|
|
216
|
+
declare function hasFloatValue(value: unknown): boolean;
|
|
217
|
+
declare function hasFloatText(text: string): boolean;
|
|
218
|
+
declare function keyId(pkRaw: Uint8Array): string;
|
|
219
|
+
declare function verifySignature(pkRaw: Uint8Array, body: unknown, sigValue: string): boolean;
|
|
220
|
+
declare function claimDigest(claim: Record<string, unknown>): string;
|
|
221
|
+
declare function leafHash(receipt: {
|
|
222
|
+
body: unknown;
|
|
223
|
+
signature: unknown;
|
|
224
|
+
}): Uint8Array;
|
|
225
|
+
/**
|
|
226
|
+
* RFC 9162 §2.1.3.2 audit-path verification. Returns the computed root, or null if the path is
|
|
227
|
+
* malformed. Ported line for line from `poaw_core.root_from_inclusion`.
|
|
228
|
+
*/
|
|
229
|
+
declare function rootFromInclusion(index: number, size: number, leaf: Uint8Array, path: Uint8Array[]): Uint8Array | null;
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* This file was automatically generated by `npm run gen:types` from
|
|
233
|
+
* ../../../src/receipt.schema.json (the vendored PoAW receipt schema). Do not edit by hand.
|
|
234
|
+
*/
|
|
235
|
+
type Timestamp = string;
|
|
236
|
+
type KeyId = string;
|
|
237
|
+
type Action = string;
|
|
238
|
+
type B64Url = string;
|
|
239
|
+
type Fingerprint = string;
|
|
240
|
+
type VerdictValue = "verified" | "late" | "mismatch" | "failed" | "unverifiable";
|
|
241
|
+
type ReasonCode = "not_found" | "content_mismatch" | "target_mismatch" | "observed_after_tolerance" | "no_connection" | "permission_denied" | "rate_limited" | "destination_unavailable" | "unsupported_action" | "claim_ambiguous" | "verifier_error";
|
|
242
|
+
/**
|
|
243
|
+
* Structural schema for a Proof of Agent Work receipt. Signature, inclusion and anchor checks are defined in SPEC.md and are not expressible in JSON Schema.
|
|
244
|
+
*/
|
|
245
|
+
interface PoAWReceiptPoaw01 {
|
|
246
|
+
body: Body;
|
|
247
|
+
signature: Signature;
|
|
248
|
+
proof?: Proof;
|
|
249
|
+
}
|
|
250
|
+
interface Body {
|
|
251
|
+
spec_version: "poaw/0.1";
|
|
252
|
+
receipt_id: string;
|
|
253
|
+
issued_at: Timestamp;
|
|
254
|
+
issuer: {
|
|
255
|
+
key_id: KeyId;
|
|
256
|
+
name?: string;
|
|
257
|
+
};
|
|
258
|
+
agent: {
|
|
259
|
+
id: string;
|
|
260
|
+
erc8004?: {
|
|
261
|
+
chain: string;
|
|
262
|
+
registry: string;
|
|
263
|
+
agent_id: string;
|
|
264
|
+
};
|
|
265
|
+
};
|
|
266
|
+
operator?: string;
|
|
267
|
+
claim: {
|
|
268
|
+
action: Action;
|
|
269
|
+
target: string;
|
|
270
|
+
params: {};
|
|
271
|
+
claimed_at: Timestamp;
|
|
272
|
+
client_claim_id?: string;
|
|
273
|
+
claim_digest: B64Url;
|
|
274
|
+
};
|
|
275
|
+
observation: {
|
|
276
|
+
verifier: {
|
|
277
|
+
id: Action;
|
|
278
|
+
version: string;
|
|
279
|
+
code_hash?: Fingerprint;
|
|
280
|
+
};
|
|
281
|
+
observed_at: Timestamp;
|
|
282
|
+
deadline_at: Timestamp;
|
|
283
|
+
attempts: number;
|
|
284
|
+
facts: {};
|
|
285
|
+
};
|
|
286
|
+
verdict: {
|
|
287
|
+
value: VerdictValue;
|
|
288
|
+
reason_code?: ReasonCode;
|
|
289
|
+
};
|
|
290
|
+
trust_level: number;
|
|
291
|
+
attestation?: {
|
|
292
|
+
type: string;
|
|
293
|
+
document: B64Url;
|
|
294
|
+
};
|
|
295
|
+
supersedes?: string;
|
|
296
|
+
}
|
|
297
|
+
interface Signature {
|
|
298
|
+
alg: "Ed25519";
|
|
299
|
+
key_id: KeyId;
|
|
300
|
+
value: string;
|
|
301
|
+
}
|
|
302
|
+
interface Proof {
|
|
303
|
+
log_id: B64Url;
|
|
304
|
+
leaf_index: number;
|
|
305
|
+
tree_size: number;
|
|
306
|
+
root_hash: B64Url;
|
|
307
|
+
inclusion: B64Url[];
|
|
308
|
+
anchor?: {
|
|
309
|
+
chain: string;
|
|
310
|
+
scheme: "eas";
|
|
311
|
+
uid: string;
|
|
312
|
+
tx_hash: string;
|
|
313
|
+
tree_size: number;
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
export { type AnchorResult, type ClaimAction, type ClaimPage, type ClaimStatus, type ClaimSummary, type PoAWReceiptPoaw01 as GeneratedReceipt, type Keyset, type ListClaimsOptions, type Proof$1 as Proof, QedProof, QedProofError, type QedProofOptions, RateLimitError, type Receipt, SIG_DOMAIN, SPEC_VERSION, type SubmitClaimOptions, type VerifyChecks, type VerifyOptions, type VerifyReport, type WaitOptions, actions, b64u, b64uDecode, claimDigest, hasFloatText, hasFloatValue, jcs, keyId, leafHash, rootFromInclusion, sha256, verifyReceipt, verifySignature };
|