x402-trust-layer 5.1.0

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.
Files changed (293) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/DEPLOY.md +53 -0
  3. package/Dockerfile +30 -0
  4. package/LICENSE +21 -0
  5. package/README.md +294 -0
  6. package/dist/agents/a2a-payment.d.ts +37 -0
  7. package/dist/agents/a2a-payment.js +105 -0
  8. package/dist/agents/agent-escrow.d.ts +30 -0
  9. package/dist/agents/agent-escrow.js +23 -0
  10. package/dist/agents/agent-verify.d.ts +15 -0
  11. package/dist/agents/agent-verify.js +112 -0
  12. package/dist/agents/api-router.d.ts +32 -0
  13. package/dist/agents/api-router.js +228 -0
  14. package/dist/agents/attestation-registry.d.ts +35 -0
  15. package/dist/agents/attestation-registry.js +76 -0
  16. package/dist/agents/audition-coach.d.ts +45 -0
  17. package/dist/agents/audition-coach.js +257 -0
  18. package/dist/agents/bedrock-bridge.d.ts +3 -0
  19. package/dist/agents/bedrock-bridge.js +60 -0
  20. package/dist/agents/budget-allocator.d.ts +24 -0
  21. package/dist/agents/budget-allocator.js +31 -0
  22. package/dist/agents/compliance-ledger.d.ts +66 -0
  23. package/dist/agents/compliance-ledger.js +80 -0
  24. package/dist/agents/dispute-resolver.d.ts +62 -0
  25. package/dist/agents/dispute-resolver.js +124 -0
  26. package/dist/agents/evidence-locker.d.ts +30 -0
  27. package/dist/agents/evidence-locker.js +47 -0
  28. package/dist/agents/facilitator-failover.d.ts +15 -0
  29. package/dist/agents/facilitator-failover.js +18 -0
  30. package/dist/agents/identity-gate.d.ts +20 -0
  31. package/dist/agents/identity-gate.js +79 -0
  32. package/dist/agents/mandate-compiler.d.ts +51 -0
  33. package/dist/agents/mandate-compiler.js +73 -0
  34. package/dist/agents/mandate-diff.d.ts +41 -0
  35. package/dist/agents/mandate-diff.js +170 -0
  36. package/dist/agents/market-buy-advisor.d.ts +65 -0
  37. package/dist/agents/market-buy-advisor.js +234 -0
  38. package/dist/agents/merchant-trust.d.ts +38 -0
  39. package/dist/agents/merchant-trust.js +171 -0
  40. package/dist/agents/mpp-session-broker.d.ts +27 -0
  41. package/dist/agents/mpp-session-broker.js +29 -0
  42. package/dist/agents/mpp-session-v2.d.ts +76 -0
  43. package/dist/agents/mpp-session-v2.js +269 -0
  44. package/dist/agents/payment-intent-compiler.d.ts +21 -0
  45. package/dist/agents/payment-intent-compiler.js +45 -0
  46. package/dist/agents/pipeline-execute.d.ts +40 -0
  47. package/dist/agents/pipeline-execute.js +100 -0
  48. package/dist/agents/pipeline-trust-v2.d.ts +31 -0
  49. package/dist/agents/pipeline-trust-v2.js +111 -0
  50. package/dist/agents/pre-x402-guard.d.ts +35 -0
  51. package/dist/agents/pre-x402-guard.js +84 -0
  52. package/dist/agents/quality-escrow-semantic.d.ts +88 -0
  53. package/dist/agents/quality-escrow-semantic.js +137 -0
  54. package/dist/agents/quality-escrow.d.ts +65 -0
  55. package/dist/agents/quality-escrow.js +104 -0
  56. package/dist/agents/quality-monitor.d.ts +32 -0
  57. package/dist/agents/quality-monitor.js +77 -0
  58. package/dist/agents/rail-optimizer.d.ts +33 -0
  59. package/dist/agents/rail-optimizer.js +133 -0
  60. package/dist/agents/receipt-auditor.d.ts +14 -0
  61. package/dist/agents/receipt-auditor.js +145 -0
  62. package/dist/agents/refund-arbiter.d.ts +24 -0
  63. package/dist/agents/refund-arbiter.js +70 -0
  64. package/dist/agents/research-brief.d.ts +14 -0
  65. package/dist/agents/research-brief.js +66 -0
  66. package/dist/agents/risk-gate.d.ts +11 -0
  67. package/dist/agents/risk-gate.js +78 -0
  68. package/dist/agents/settlement-graph.d.ts +16 -0
  69. package/dist/agents/settlement-graph.js +38 -0
  70. package/dist/agents/spend-governor.d.ts +2 -0
  71. package/dist/agents/spend-governor.js +70 -0
  72. package/dist/agents/trust-network.d.ts +138 -0
  73. package/dist/agents/trust-network.js +244 -0
  74. package/dist/agents/x402-proxy.d.ts +32 -0
  75. package/dist/agents/x402-proxy.js +90 -0
  76. package/dist/client/demo-alchemy-live.d.ts +1 -0
  77. package/dist/client/demo-alchemy-live.js +226 -0
  78. package/dist/client/demo-tail.d.ts +1 -0
  79. package/dist/client/demo-tail.js +100 -0
  80. package/dist/client/demo.d.ts +1 -0
  81. package/dist/client/demo.js +293 -0
  82. package/dist/config.d.ts +94 -0
  83. package/dist/config.js +223 -0
  84. package/dist/index.d.ts +1 -0
  85. package/dist/index.js +389 -0
  86. package/dist/lib/agent-response.d.ts +14 -0
  87. package/dist/lib/agent-response.js +13 -0
  88. package/dist/lib/agentic-gateways.d.ts +5 -0
  89. package/dist/lib/agentic-gateways.js +15 -0
  90. package/dist/lib/agentic-probes.d.ts +10 -0
  91. package/dist/lib/agentic-probes.js +49 -0
  92. package/dist/lib/alchemy-x402-fetch.d.ts +16 -0
  93. package/dist/lib/alchemy-x402-fetch.js +95 -0
  94. package/dist/lib/apply-verifier-body.d.ts +7 -0
  95. package/dist/lib/apply-verifier-body.js +179 -0
  96. package/dist/lib/attestation.d.ts +30 -0
  97. package/dist/lib/attestation.js +107 -0
  98. package/dist/lib/bazaar-extension.d.ts +15 -0
  99. package/dist/lib/bazaar-extension.js +265 -0
  100. package/dist/lib/bazaar.d.ts +100 -0
  101. package/dist/lib/bazaar.js +341 -0
  102. package/dist/lib/certified-sellers.d.ts +41 -0
  103. package/dist/lib/certified-sellers.js +129 -0
  104. package/dist/lib/chains.d.ts +20 -0
  105. package/dist/lib/chains.js +78 -0
  106. package/dist/lib/db-persistence.d.ts +7 -0
  107. package/dist/lib/db-persistence.js +65 -0
  108. package/dist/lib/db.d.ts +5 -0
  109. package/dist/lib/db.js +113 -0
  110. package/dist/lib/discovery-page.d.ts +2 -0
  111. package/dist/lib/discovery-page.js +71 -0
  112. package/dist/lib/ecosystem-telemetry.d.ts +20 -0
  113. package/dist/lib/ecosystem-telemetry.js +80 -0
  114. package/dist/lib/erc8004/agent-card.d.ts +34 -0
  115. package/dist/lib/erc8004/agent-card.js +151 -0
  116. package/dist/lib/erc8004/cache.d.ts +3 -0
  117. package/dist/lib/erc8004/cache.js +17 -0
  118. package/dist/lib/erc8004/constants.d.ts +22 -0
  119. package/dist/lib/erc8004/constants.js +35 -0
  120. package/dist/lib/erc8004/registry.d.ts +19 -0
  121. package/dist/lib/erc8004/registry.js +171 -0
  122. package/dist/lib/erc8004/resolve-agent.d.ts +7 -0
  123. package/dist/lib/erc8004/resolve-agent.js +70 -0
  124. package/dist/lib/erc8004/trust-score.d.ts +33 -0
  125. package/dist/lib/erc8004/trust-score.js +136 -0
  126. package/dist/lib/escrow-ledger.d.ts +14 -0
  127. package/dist/lib/escrow-ledger.js +54 -0
  128. package/dist/lib/escrow-unified.d.ts +15 -0
  129. package/dist/lib/escrow-unified.js +28 -0
  130. package/dist/lib/facilitator-extra.d.ts +13 -0
  131. package/dist/lib/facilitator-extra.js +52 -0
  132. package/dist/lib/facilitators.d.ts +20 -0
  133. package/dist/lib/facilitators.js +89 -0
  134. package/dist/lib/host-policy.d.ts +4 -0
  135. package/dist/lib/host-policy.js +20 -0
  136. package/dist/lib/idempotency.d.ts +4 -0
  137. package/dist/lib/idempotency.js +120 -0
  138. package/dist/lib/ledger.d.ts +2 -0
  139. package/dist/lib/ledger.js +17 -0
  140. package/dist/lib/logger.d.ts +6 -0
  141. package/dist/lib/logger.js +24 -0
  142. package/dist/lib/mandate-vc.d.ts +20 -0
  143. package/dist/lib/mandate-vc.js +25 -0
  144. package/dist/lib/mandate.d.ts +44 -0
  145. package/dist/lib/mandate.js +190 -0
  146. package/dist/lib/marketplace.d.ts +7 -0
  147. package/dist/lib/marketplace.js +127 -0
  148. package/dist/lib/migrations.d.ts +2 -0
  149. package/dist/lib/migrations.js +130 -0
  150. package/dist/lib/nonce-store.d.ts +6 -0
  151. package/dist/lib/nonce-store.js +109 -0
  152. package/dist/lib/openapi-agentcash.d.ts +5 -0
  153. package/dist/lib/openapi-agentcash.js +288 -0
  154. package/dist/lib/openapi-meta.d.ts +5 -0
  155. package/dist/lib/openapi-meta.js +235 -0
  156. package/dist/lib/otel.d.ts +2 -0
  157. package/dist/lib/otel.js +25 -0
  158. package/dist/lib/paid-resource-url.d.ts +6 -0
  159. package/dist/lib/paid-resource-url.js +47 -0
  160. package/dist/lib/parse-with-verifier-fallback.d.ts +3 -0
  161. package/dist/lib/parse-with-verifier-fallback.js +13 -0
  162. package/dist/lib/payment-request-context.d.ts +10 -0
  163. package/dist/lib/payment-request-context.js +5 -0
  164. package/dist/lib/payment-response.d.ts +13 -0
  165. package/dist/lib/payment-response.js +39 -0
  166. package/dist/lib/payto-guard.d.ts +10 -0
  167. package/dist/lib/payto-guard.js +20 -0
  168. package/dist/lib/probe.d.ts +29 -0
  169. package/dist/lib/probe.js +157 -0
  170. package/dist/lib/problem-detail.d.ts +10 -0
  171. package/dist/lib/problem-detail.js +14 -0
  172. package/dist/lib/rate-limit.d.ts +12 -0
  173. package/dist/lib/rate-limit.js +126 -0
  174. package/dist/lib/replay-middleware.d.ts +3 -0
  175. package/dist/lib/replay-middleware.js +27 -0
  176. package/dist/lib/response-guard.d.ts +5 -0
  177. package/dist/lib/response-guard.js +40 -0
  178. package/dist/lib/safe-fetch.d.ts +5 -0
  179. package/dist/lib/safe-fetch.js +19 -0
  180. package/dist/lib/security.d.ts +13 -0
  181. package/dist/lib/security.js +61 -0
  182. package/dist/lib/semantic-judge.d.ts +14 -0
  183. package/dist/lib/semantic-judge.js +107 -0
  184. package/dist/lib/semantic-judge.test.d.ts +1 -0
  185. package/dist/lib/semantic-judge.test.js +11 -0
  186. package/dist/lib/ssrf.d.ts +10 -0
  187. package/dist/lib/ssrf.js +130 -0
  188. package/dist/lib/ssrf.test.d.ts +1 -0
  189. package/dist/lib/ssrf.test.js +16 -0
  190. package/dist/lib/suite-catalog.d.ts +83 -0
  191. package/dist/lib/suite-catalog.js +131 -0
  192. package/dist/lib/telemetry.d.ts +5 -0
  193. package/dist/lib/telemetry.js +37 -0
  194. package/dist/lib/verifier-fast-path.d.ts +10 -0
  195. package/dist/lib/verifier-fast-path.js +44 -0
  196. package/dist/lib/verifier-probe-protocol.d.ts +7 -0
  197. package/dist/lib/verifier-probe-protocol.js +115 -0
  198. package/dist/lib/verify-examples.d.ts +2 -0
  199. package/dist/lib/verify-examples.js +438 -0
  200. package/dist/lib/version.d.ts +2 -0
  201. package/dist/lib/version.js +2 -0
  202. package/dist/lib/webhook-auth.d.ts +3 -0
  203. package/dist/lib/webhook-auth.js +34 -0
  204. package/dist/lib/webhook-routes.d.ts +2 -0
  205. package/dist/lib/webhook-routes.js +112 -0
  206. package/dist/lib/webhooks.d.ts +23 -0
  207. package/dist/lib/webhooks.js +123 -0
  208. package/dist/lib/webhooks.test.d.ts +1 -0
  209. package/dist/lib/webhooks.test.js +16 -0
  210. package/dist/lib/x402-client-options.d.ts +28 -0
  211. package/dist/lib/x402-client-options.js +138 -0
  212. package/dist/lib/x402-headers.d.ts +10 -0
  213. package/dist/lib/x402-headers.js +27 -0
  214. package/dist/lib/x402-paid.d.ts +5 -0
  215. package/dist/lib/x402-paid.js +252 -0
  216. package/dist/lib/x402-payment-replay.d.ts +22 -0
  217. package/dist/lib/x402-payment-replay.js +57 -0
  218. package/dist/lib/x402gle-host-verify.d.ts +3 -0
  219. package/dist/lib/x402gle-host-verify.js +27 -0
  220. package/dist/protocol/agent-passport.d.ts +34 -0
  221. package/dist/protocol/agent-passport.js +44 -0
  222. package/dist/protocol/compliance-v2.d.ts +21 -0
  223. package/dist/protocol/compliance-v2.js +19 -0
  224. package/dist/protocol/credit-bureau.d.ts +18 -0
  225. package/dist/protocol/credit-bureau.js +44 -0
  226. package/dist/protocol/crypto.d.ts +6 -0
  227. package/dist/protocol/crypto.js +41 -0
  228. package/dist/protocol/escrow-fsm.d.ts +33 -0
  229. package/dist/protocol/escrow-fsm.js +99 -0
  230. package/dist/protocol/fraud-engine.d.ts +28 -0
  231. package/dist/protocol/fraud-engine.js +77 -0
  232. package/dist/protocol/observability.d.ts +14 -0
  233. package/dist/protocol/observability.js +21 -0
  234. package/dist/protocol/pipeline-full-trust.d.ts +40 -0
  235. package/dist/protocol/pipeline-full-trust.js +96 -0
  236. package/dist/protocol/proof-of-execution.d.ts +36 -0
  237. package/dist/protocol/proof-of-execution.js +48 -0
  238. package/dist/protocol/reasoning-audit.d.ts +27 -0
  239. package/dist/protocol/reasoning-audit.js +51 -0
  240. package/dist/protocol/replay-guard.d.ts +28 -0
  241. package/dist/protocol/replay-guard.js +76 -0
  242. package/dist/protocol/replay-guard.test.d.ts +1 -0
  243. package/dist/protocol/replay-guard.test.js +10 -0
  244. package/dist/protocol/security-audit.d.ts +18 -0
  245. package/dist/protocol/security-audit.js +45 -0
  246. package/dist/protocol/store.d.ts +5 -0
  247. package/dist/protocol/store.js +59 -0
  248. package/dist/protocol/threat-catalog.d.ts +13 -0
  249. package/dist/protocol/threat-catalog.js +75 -0
  250. package/dist/protocol/trust-oracle.d.ts +23 -0
  251. package/dist/protocol/trust-oracle.js +30 -0
  252. package/dist/protocol/trust-score-v2.d.ts +33 -0
  253. package/dist/protocol/trust-score-v2.js +78 -0
  254. package/dist/protocol/zk-proofs.d.ts +24 -0
  255. package/dist/protocol/zk-proofs.js +32 -0
  256. package/dist/routes/a2a-agent-card.d.ts +3 -0
  257. package/dist/routes/a2a-agent-card.js +28 -0
  258. package/dist/routes/catalog.d.ts +5 -0
  259. package/dist/routes/catalog.js +47 -0
  260. package/dist/routes/register-all.d.ts +3 -0
  261. package/dist/routes/register-all.js +1240 -0
  262. package/dist/routes/schemas.d.ts +83 -0
  263. package/dist/routes/schemas.js +38 -0
  264. package/dist/routes/shared.d.ts +16 -0
  265. package/dist/routes/shared.js +27 -0
  266. package/dist/routes-protocol.d.ts +10 -0
  267. package/dist/routes-protocol.js +322 -0
  268. package/dist/routes.d.ts +2 -0
  269. package/dist/routes.js +2 -0
  270. package/dist/types.d.ts +66 -0
  271. package/dist/types.js +1 -0
  272. package/openapi.json +7940 -0
  273. package/package.json +124 -0
  274. package/public/.well-known/ai-plugin.json +12 -0
  275. package/public/assets/aegis-logo-blue.png +0 -0
  276. package/public/assets/aegis-logo-gold.png +0 -0
  277. package/public/assets/aegis-logo-green.png +0 -0
  278. package/public/assets/aegis-logo-purple.png +0 -0
  279. package/public/assets/aegis-logo-red.png +0 -0
  280. package/public/assets/aegis-logo-white.png +0 -0
  281. package/public/assets/aegis-logo.png +0 -0
  282. package/public/assets/x402-trustlayer-logo.png +0 -0
  283. package/public/assets/x402-trustlayer-logo.svg +5 -0
  284. package/public/data/agents.json +1528 -0
  285. package/public/index.html +198 -0
  286. package/public/landing.css +342 -0
  287. package/public/landing.js +405 -0
  288. package/public/llms-full.txt +582 -0
  289. package/public/llms.txt +132 -0
  290. package/public/skill.md +135 -0
  291. package/railway.toml +9 -0
  292. package/scripts/docker-entrypoint.sh +7 -0
  293. package/scripts/patch-facilitator-timeout.mjs +61 -0
@@ -0,0 +1,235 @@
1
+ /** OpenAPI / Bazaar summaries per route */
2
+ export const ENDPOINT_META = {
3
+ "/api/x402/proxy": {
4
+ summary: "x402 proxy: guard + security + attestation in one call",
5
+ tags: ["x402", "proxy", "preflight", "guard"],
6
+ },
7
+ "/api/mpp/session": {
8
+ summary: "MPP session v2: open, voucher, close",
9
+ tags: ["mpp", "batch", "solana"],
10
+ },
11
+ "/api/attestation/issue": {
12
+ summary: "Issue signed preflight attestation",
13
+ tags: ["attestation", "trust", "security"],
14
+ },
15
+ "/api/attestation/verify": {
16
+ summary: "Verify attestation signature",
17
+ tags: ["attestation", "verify"],
18
+ },
19
+ "/api/attestation/registry": {
20
+ summary: "Query attestation registry",
21
+ tags: ["attestation", "registry"],
22
+ },
23
+ "/api/guard/pre-x402": {
24
+ summary: "Pre-x402 guard: spend + identity + risk in one call",
25
+ tags: ["guard", "preflight", "policy"],
26
+ },
27
+ "/api/agent/verify": {
28
+ summary: "ERC-8004 TrustScore on Base mainnet",
29
+ tags: ["erc-8004", "identity", "trust-score"],
30
+ },
31
+ "/api/pipeline/execute": {
32
+ summary: "One-shot pipeline: guard, plan, facilitator, marketplace routing",
33
+ tags: ["pipeline", "orchestration"],
34
+ },
35
+ "/api/payment-intent/compile": {
36
+ summary: "Compile multi-step x402 execution plan from natural language",
37
+ tags: ["plan", "compiler"],
38
+ },
39
+ "/api/facilitator/failover": {
40
+ summary: "Rank facilitators and recommend failover path",
41
+ tags: ["facilitator", "failover"],
42
+ },
43
+ "/api/mpp/session-plan": {
44
+ summary: "Estimate MPP session vs per-call settlement savings",
45
+ tags: ["mpp", "estimate"],
46
+ },
47
+ "/api/spend-governor/check": {
48
+ summary: "Enforce agent daily and per-call spend caps",
49
+ tags: ["spend", "budget", "policy"],
50
+ },
51
+ "/api/identity-gate/check": {
52
+ summary: "Wallet identity tier and risk scoring",
53
+ tags: ["identity", "wallet"],
54
+ },
55
+ "/api/risk-gate/scan": {
56
+ summary: "Probe URL security, HTTPS, and x402 payment requirements",
57
+ tags: ["risk", "scan", "security"],
58
+ },
59
+ "/api/router/route": {
60
+ summary: "Route capability query to best x402 API",
61
+ tags: ["router", "marketplace"],
62
+ },
63
+ "/api/research/brief": {
64
+ summary: "Research pipeline plan and cost estimate",
65
+ tags: ["research", "brief"],
66
+ },
67
+ "/api/receipt-auditor/verify": {
68
+ summary: "Verify x402 settlement receipt on-chain",
69
+ tags: ["receipt", "audit", "settlement"],
70
+ },
71
+ "/api/refund-arbiter/evaluate": {
72
+ summary: "Evaluate refund eligibility from verification signals",
73
+ tags: ["refund", "arbiter"],
74
+ },
75
+ "/api/budget-allocator/run": {
76
+ summary: "Allocate shared USDC pool across agent fleet",
77
+ tags: ["budget", "fleet"],
78
+ },
79
+ "/api/settlement-graph/next": {
80
+ summary: "Recommend next paid APIs after a settlement",
81
+ tags: ["graph", "recommendations"],
82
+ },
83
+ "/api/quality-monitor/probe": {
84
+ summary: "Regression probe up to 10 x402 endpoints",
85
+ tags: ["monitor", "quality"],
86
+ },
87
+ "/api/evidence-locker/export": {
88
+ summary: "Export compliance audit bundle for settlements",
89
+ tags: ["compliance", "audit"],
90
+ },
91
+ "/api/agent-escrow": {
92
+ summary: "Create, status, or release agent-to-agent USDC escrow",
93
+ tags: ["escrow", "agents"],
94
+ },
95
+ "/api/a2a/execute": {
96
+ summary: "Agent-to-agent x402 orchestration: trust preflight then paid call to seller endpoint",
97
+ tags: ["a2a", "agents", "orchestration"],
98
+ },
99
+ "/api/bedrock/preflight": {
100
+ summary: "AWS Bedrock / enterprise agent preflight: guard, mandate, and trust bundle before x402 pay",
101
+ tags: ["bedrock", "enterprise", "preflight"],
102
+ },
103
+ "/api/market/buy-advisor": {
104
+ summary: "x402 buy quote: rank paid APIs, policy, chain, MPP before you pay",
105
+ tags: ["marketplace", "quote", "discovery", "jupiter-like"],
106
+ },
107
+ "/api/seller/audition-coach": {
108
+ summary: "Seller audition coach: OpenAPI, 402 probes, Bazaar fixes before Dexter ingest",
109
+ tags: ["seller", "audition", "discovery", "quality"],
110
+ },
111
+ "/api/merchant-trust/score": {
112
+ summary: "Know-Your-Merchant trust + wash-trading score before payment",
113
+ tags: ["trust", "kym", "wash-trade", "preflight"],
114
+ },
115
+ "/api/mandate/compile": {
116
+ summary: "Compile a signed, scoped AP2-style payment mandate from intent",
117
+ tags: ["mandate", "ap2", "intent", "governance"],
118
+ },
119
+ "/api/mandate/verify": {
120
+ summary: "Verify mandate signature and scope a proposed payment",
121
+ tags: ["mandate", "verify", "governance"],
122
+ },
123
+ "/api/rail-optimizer/route": {
124
+ summary: "Choose best rail: Visa CLI, Stripe MPP, Circle, Base, Solana",
125
+ tags: ["rail", "router", "visa-cli", "mpp", "cost"],
126
+ },
127
+ "/api/compliance/ledger": {
128
+ summary: "CFO/SOC2-grade spend reconciliation with policy flags and tamper hash",
129
+ tags: ["compliance", "audit", "cfo", "ledger"],
130
+ },
131
+ "/api/dispute/resolve": {
132
+ summary: "Visa chargeback dossier or on-chain refund claim builder",
133
+ tags: ["dispute", "chargeback", "visa", "refund"],
134
+ },
135
+ "/api/quality-escrow/settle": {
136
+ summary: "Quality-gated escrow with response verification and auto-refund",
137
+ tags: ["escrow", "quality", "refund", "trust"],
138
+ },
139
+ "/api/quality-escrow/semantic-settle": {
140
+ summary: "Semantic delivery escrow: intent rubric + schema before release/refund",
141
+ tags: ["escrow", "semantic", "delivery"],
142
+ },
143
+ "/api/mandate/diff": {
144
+ summary: "Compare mandate scope to MCP tool trace before x402 payment",
145
+ tags: ["mandate", "intent", "diff"],
146
+ },
147
+ "/api/merchant-trust/certify": {
148
+ summary: "Certify seller: KYM pass, signed badge, buyer policy",
149
+ tags: ["certification", "seller", "trust-network"],
150
+ },
151
+ "/api/trust-network/buyer-gate": {
152
+ summary: "Certified seller buyer gate before payment",
153
+ tags: ["trust-network", "attestation", "gate"],
154
+ },
155
+ "/api/pipeline/trust-v2": {
156
+ summary: "Trust v2 bundle: mandate diff + KYM + guard + buyer gate",
157
+ tags: ["pipeline", "trust-v2", "orchestration"],
158
+ },
159
+ "/api/trust-network/bond/slash": {
160
+ summary: "Slash seller virtual bond after failed delivery",
161
+ tags: ["bond", "slash", "trust-network"],
162
+ },
163
+ "/api/protocol/pipeline/full-trust": {
164
+ summary: "Agent Trust Protocol v4 full pipeline before x402 payment",
165
+ tags: ["protocol", "trust", "pipeline"],
166
+ },
167
+ "/api/protocol/passport/issue": {
168
+ summary: "Issue Agent Passport DID verifiable credential",
169
+ tags: ["protocol", "did", "identity"],
170
+ },
171
+ "/api/protocol/passport/verify": {
172
+ summary: "Verify Agent Passport credential signature",
173
+ tags: ["protocol", "did", "verify"],
174
+ },
175
+ "/api/protocol/trust-score/v2": {
176
+ summary: "TrustScore v2 with tamper-resistant HMAC proof",
177
+ tags: ["protocol", "trust-score"],
178
+ },
179
+ "/api/protocol/fraud/scan": {
180
+ summary: "Graph fraud scan for Sybil and wash trading",
181
+ tags: ["protocol", "fraud"],
182
+ },
183
+ "/api/protocol/oracle/consensus": {
184
+ summary: "Trust oracle quorum consensus",
185
+ tags: ["protocol", "oracle"],
186
+ },
187
+ "/api/protocol/execution/issue": {
188
+ summary: "Proof of Execution task receipt",
189
+ tags: ["protocol", "poe"],
190
+ },
191
+ "/api/protocol/execution/verify": {
192
+ summary: "Verify Proof of Execution receipt",
193
+ tags: ["protocol", "poe", "verify"],
194
+ },
195
+ "/api/protocol/reasoning/commit": {
196
+ summary: "Commit reasoning audit Merkle tree",
197
+ tags: ["protocol", "audit", "merkle"],
198
+ },
199
+ "/api/protocol/reasoning/disclose": {
200
+ summary: "Selective disclosure of reasoning audit leaves",
201
+ tags: ["protocol", "zk", "disclosure"],
202
+ },
203
+ "/api/protocol/escrow/create": {
204
+ summary: "Create escrow FSM (CREATED)",
205
+ tags: ["protocol", "escrow"],
206
+ },
207
+ "/api/protocol/escrow/transition": {
208
+ summary: "Transition escrow FSM state",
209
+ tags: ["protocol", "escrow"],
210
+ },
211
+ "/api/protocol/escrow/status": {
212
+ summary: "Query escrow FSM status",
213
+ tags: ["protocol", "escrow"],
214
+ },
215
+ "/api/protocol/replay/bind": {
216
+ summary: "Replay-safe payment binding",
217
+ tags: ["protocol", "replay", "security"],
218
+ },
219
+ "/api/protocol/replay/verify": {
220
+ summary: "Verify and consume replay binding",
221
+ tags: ["protocol", "replay"],
222
+ },
223
+ "/api/protocol/zk/prove": {
224
+ summary: "ZK-style proof of budget, reputation, or compliance",
225
+ tags: ["protocol", "zk"],
226
+ },
227
+ "/api/protocol/credit/score": {
228
+ summary: "AI Agent Credit Bureau 300-900",
229
+ tags: ["protocol", "credit"],
230
+ },
231
+ "/api/protocol/compliance/assess": {
232
+ summary: "Enterprise AML/KYC compliance assess",
233
+ tags: ["protocol", "compliance"],
234
+ },
235
+ };
@@ -0,0 +1,2 @@
1
+ /** Start OpenTelemetry when OTEL_ENABLED=1 and packages are installed. */
2
+ export declare function startOtelIfEnabled(): Promise<void>;
@@ -0,0 +1,25 @@
1
+ import { logger } from "./logger.js";
2
+ let started = false;
3
+ /** Start OpenTelemetry when OTEL_ENABLED=1 and packages are installed. */
4
+ export async function startOtelIfEnabled() {
5
+ if (started || process.env.OTEL_ENABLED !== "1")
6
+ return;
7
+ try {
8
+ const spec = "@opentelemetry/sdk-node";
9
+ const mod = await import(/* webpackIgnore: true */ spec);
10
+ const autoSpec = "@opentelemetry/auto-instrumentations-node";
11
+ const auto = await import(/* webpackIgnore: true */ autoSpec);
12
+ const sdk = new mod.NodeSDK({
13
+ instrumentations: [auto.getNodeAutoInstrumentations()],
14
+ });
15
+ await sdk.start();
16
+ started = true;
17
+ logger.info({}, "OpenTelemetry SDK started");
18
+ }
19
+ catch (err) {
20
+ logger.warn({
21
+ err: err instanceof Error ? err.message : String(err),
22
+ hint: "npm install @opentelemetry/sdk-node @opentelemetry/auto-instrumentations-node",
23
+ }, "OpenTelemetry not started");
24
+ }
25
+ }
@@ -0,0 +1,6 @@
1
+ import type { Request } from "express";
2
+ /**
3
+ * Canonical x402 resource URL for the request being paid.
4
+ * Local dev: use request Host. Production: reject foreign Host headers (SSRF/metadata injection).
5
+ */
6
+ export declare function resolvePaidResourceUrl(req: Request): string;
@@ -0,0 +1,47 @@
1
+ import { config } from "../config.js";
2
+ function isLocalHost(host) {
3
+ const h = host.toLowerCase().split(":")[0] ?? host;
4
+ return h === "localhost" || h === "127.0.0.1" || h === "::1";
5
+ }
6
+ function canonicalPublicHost() {
7
+ try {
8
+ return new URL(config.publicBaseUrl).host.toLowerCase();
9
+ }
10
+ catch {
11
+ return null;
12
+ }
13
+ }
14
+ /**
15
+ * Canonical x402 resource URL for the request being paid.
16
+ * Local dev: use request Host. Production: reject foreign Host headers (SSRF/metadata injection).
17
+ */
18
+ export function resolvePaidResourceUrl(req) {
19
+ const pathOnly = (req.originalUrl ?? req.url ?? req.path).split("?")[0] || req.path;
20
+ const path = pathOnly.startsWith("/") ? pathOnly : `/${pathOnly}`;
21
+ const base = config.publicBaseUrl.replace(/\/$/, "");
22
+ const fallback = `${base}${path}`;
23
+ const hostHeader = req.get("host")?.trim();
24
+ if (!hostHeader)
25
+ return fallback;
26
+ const reqHost = hostHeader.split(":")[0]?.toLowerCase() ?? "";
27
+ const publicHost = canonicalPublicHost();
28
+ if (isLocalHost(reqHost)) {
29
+ const forwarded = req.get("x-forwarded-proto")?.split(",")[0]?.trim();
30
+ const proto = forwarded === "https" || forwarded === "http"
31
+ ? forwarded
32
+ : req.protocol === "https"
33
+ ? "https"
34
+ : "http";
35
+ return `${proto}://${hostHeader}${path}`;
36
+ }
37
+ if (publicHost && reqHost !== publicHost) {
38
+ return fallback;
39
+ }
40
+ const forwarded = req.get("x-forwarded-proto")?.split(",")[0]?.trim();
41
+ const proto = forwarded === "https" || forwarded === "http"
42
+ ? forwarded
43
+ : req.protocol === "https"
44
+ ? "https"
45
+ : "http";
46
+ return `${proto}://${hostHeader}${path}`;
47
+ }
@@ -0,0 +1,3 @@
1
+ import { z } from "zod";
2
+ /** Zod safeParse with canonical VERIFY_EXAMPLES merge (x402gle partial bodies). */
3
+ export declare function parseWithVerifierFallback<T extends z.ZodTypeAny>(path: string, schema: T, body: unknown): z.SafeParseReturnType<z.infer<T>, z.infer<T>>;
@@ -0,0 +1,13 @@
1
+ import { mergeCompatibleProbeInput } from "./apply-verifier-body.js";
2
+ import { VERIFY_EXAMPLES } from "./verify-examples.js";
3
+ /** Zod safeParse with canonical VERIFY_EXAMPLES merge (x402gle partial bodies). */
4
+ export function parseWithVerifierFallback(path, schema, body) {
5
+ const ex = VERIFY_EXAMPLES[path];
6
+ const raw = body && typeof body === "object" && !Array.isArray(body)
7
+ ? body
8
+ : {};
9
+ if (ex && typeof ex === "object" && !Array.isArray(ex)) {
10
+ return schema.safeParse(mergeCompatibleProbeInput(ex, raw));
11
+ }
12
+ return schema.safeParse(body);
13
+ }
@@ -0,0 +1,10 @@
1
+ import { AsyncLocalStorage } from "node:async_hooks";
2
+ import type { Request } from "express";
3
+ export type PaymentRequestStore = Request & {
4
+ x402PendingNonce?: {
5
+ nonce: string;
6
+ network: string;
7
+ };
8
+ };
9
+ export declare const paymentRequestAls: AsyncLocalStorage<PaymentRequestStore>;
10
+ export declare function getPaymentRequestStore(): PaymentRequestStore | undefined;
@@ -0,0 +1,5 @@
1
+ import { AsyncLocalStorage } from "node:async_hooks";
2
+ export const paymentRequestAls = new AsyncLocalStorage();
3
+ export function getPaymentRequestStore() {
4
+ return paymentRequestAls.getStore();
5
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Parse x402 v2 PAYMENT-RESPONSE header (base64 JSON).
3
+ */
4
+ export type ParsedPaymentResponse = {
5
+ transaction?: string;
6
+ txHash?: string;
7
+ payer?: string;
8
+ network?: string;
9
+ amountUsdc?: number;
10
+ raw: Record<string, unknown>;
11
+ };
12
+ export declare function parsePaymentResponseHeader(headerValue: string | null): ParsedPaymentResponse | null;
13
+ export declare function paymentResponseFromHeaders(headers: Headers): ParsedPaymentResponse | null;
@@ -0,0 +1,39 @@
1
+ export function parsePaymentResponseHeader(headerValue) {
2
+ if (!headerValue?.trim())
3
+ return null;
4
+ try {
5
+ const json = Buffer.from(headerValue.trim(), "base64").toString("utf8");
6
+ const raw = JSON.parse(json);
7
+ const tx = (typeof raw.transaction === "string" && raw.transaction) ||
8
+ (typeof raw.txHash === "string" && raw.txHash) ||
9
+ undefined;
10
+ let amountUsdc;
11
+ if (typeof raw.amount === "number")
12
+ amountUsdc = raw.amount;
13
+ else if (typeof raw.amountUsdc === "number")
14
+ amountUsdc = raw.amountUsdc;
15
+ else if (typeof raw.amount === "string") {
16
+ amountUsdc = Number(raw.amount) / 1_000_000;
17
+ }
18
+ else if (typeof raw.maxAmountRequired === "string") {
19
+ amountUsdc = Number(raw.maxAmountRequired) / 1_000_000;
20
+ }
21
+ if (raw.success === true && !amountUsdc)
22
+ amountUsdc = 1;
23
+ return {
24
+ transaction: tx,
25
+ txHash: tx,
26
+ payer: typeof raw.payer === "string" ? raw.payer : undefined,
27
+ network: typeof raw.network === "string" ? raw.network : undefined,
28
+ amountUsdc,
29
+ raw,
30
+ };
31
+ }
32
+ catch {
33
+ return null;
34
+ }
35
+ }
36
+ export function paymentResponseFromHeaders(headers) {
37
+ const h = headers.get("PAYMENT-RESPONSE") ?? headers.get("payment-response");
38
+ return parsePaymentResponseHeader(h);
39
+ }
@@ -0,0 +1,10 @@
1
+ export declare function isTrustedPayTo(payTo: string | undefined): boolean;
2
+ export declare function validateIncomingPaymentRequirements(requirements: {
3
+ payTo?: string;
4
+ network?: string;
5
+ }): {
6
+ ok: true;
7
+ } | {
8
+ ok: false;
9
+ error: string;
10
+ };
@@ -0,0 +1,20 @@
1
+ import { config, isAllowedNetwork } from "../config.js";
2
+ export function isTrustedPayTo(payTo) {
3
+ if (!payTo)
4
+ return false;
5
+ const lower = payTo.toLowerCase();
6
+ return (lower === config.payTo.toLowerCase() ||
7
+ (!!config.payToEvm && lower === config.payToEvm.toLowerCase()));
8
+ }
9
+ export function validateIncomingPaymentRequirements(requirements) {
10
+ if (requirements.network && !isAllowedNetwork(requirements.network)) {
11
+ return { ok: false, error: `Network not allowed: ${requirements.network}` };
12
+ }
13
+ if (requirements.payTo && !isTrustedPayTo(requirements.payTo)) {
14
+ return {
15
+ ok: false,
16
+ error: "Payment address mismatch — possible payTo redirect attack",
17
+ };
18
+ }
19
+ return { ok: true };
20
+ }
@@ -0,0 +1,29 @@
1
+ export type PaymentOption = {
2
+ priceUsdc: number;
3
+ network: string;
4
+ payTo: string | null;
5
+ scheme: string | null;
6
+ };
7
+ export type ProbeResult = {
8
+ url: string;
9
+ status: number;
10
+ requiresPayment: boolean;
11
+ authMode: "paid" | "unprotected" | "unknown";
12
+ priceUsdc: number | null;
13
+ network: string | null;
14
+ payTo: string | null;
15
+ paymentOptions: PaymentOption[];
16
+ warnings: string[];
17
+ };
18
+ export type ProbeOptions = {
19
+ method?: "GET" | "POST" | "HEAD";
20
+ body?: string;
21
+ contentType?: string;
22
+ /** Skip network I/O — used for Dexter/x402gle verifier audits */
23
+ fastSynthetic?: boolean;
24
+ timeoutMs?: number;
25
+ };
26
+ export declare function probeEndpoint(targetUrl: string, options?: ProbeOptions): Promise<ProbeResult>;
27
+ /** Pick cheapest payment rail; prefer eip155:8453 when within 5% of minimum. */
28
+ export declare function pickCheapestRail(options: PaymentOption[], preferNetwork?: string): PaymentOption | null;
29
+ export declare function hostOf(url: string): string | null;
@@ -0,0 +1,157 @@
1
+ import { assertSafeOutboundUrl, UnsafeUrlError } from "./ssrf.js";
2
+ function parsePaymentOptions(body) {
3
+ if (!body || typeof body !== "object")
4
+ return [];
5
+ const record = body;
6
+ const raw = Array.isArray(record.paymentOptions)
7
+ ? record.paymentOptions
8
+ : Array.isArray(record.accepts)
9
+ ? record.accepts
10
+ : [];
11
+ const out = [];
12
+ for (const item of raw) {
13
+ if (!item || typeof item !== "object")
14
+ continue;
15
+ const o = item;
16
+ const raw = typeof o.price === "number"
17
+ ? o.price
18
+ : Number(o.maxAmountRequired ?? o.price ?? 0);
19
+ const price = raw >= 1000 ? raw / 1_000_000 : raw > 0 ? raw : null;
20
+ const network = typeof o.network === "string" ? o.network : null;
21
+ if (price == null || !network)
22
+ continue;
23
+ out.push({
24
+ priceUsdc: price,
25
+ network,
26
+ payTo: typeof o.payTo === "string" ? o.payTo : null,
27
+ scheme: typeof o.scheme === "string" ? o.scheme : null,
28
+ });
29
+ }
30
+ return out;
31
+ }
32
+ function firstOption(options) {
33
+ const first = options[0];
34
+ if (!first)
35
+ return { priceUsdc: null, network: null, payTo: null };
36
+ return {
37
+ priceUsdc: first.priceUsdc,
38
+ network: first.network,
39
+ payTo: first.payTo,
40
+ };
41
+ }
42
+ export async function probeEndpoint(targetUrl, options = {}) {
43
+ if (options.fastSynthetic) {
44
+ const { syntheticPaidProbe } = await import("./verifier-fast-path.js");
45
+ return syntheticPaidProbe(targetUrl);
46
+ }
47
+ const warnings = [];
48
+ let status = 0;
49
+ let body = null;
50
+ try {
51
+ assertSafeOutboundUrl(targetUrl);
52
+ }
53
+ catch (err) {
54
+ const msg = err instanceof UnsafeUrlError ? err.message : "URL blocked by policy";
55
+ warnings.push(msg);
56
+ return {
57
+ url: targetUrl,
58
+ status: 0,
59
+ requiresPayment: false,
60
+ authMode: "unknown",
61
+ priceUsdc: null,
62
+ network: null,
63
+ payTo: null,
64
+ paymentOptions: [],
65
+ warnings,
66
+ };
67
+ }
68
+ try {
69
+ const controller = new AbortController();
70
+ const timer = setTimeout(() => controller.abort(), options.timeoutMs ?? 6_000);
71
+ const method = options.method ?? "GET";
72
+ const headers = { accept: "application/json" };
73
+ const init = { method, redirect: "manual", signal: controller.signal, headers };
74
+ if (method === "POST") {
75
+ headers["content-type"] = options.contentType ?? "application/json";
76
+ init.body = options.body ?? "{}";
77
+ }
78
+ const res = await fetch(targetUrl, init);
79
+ clearTimeout(timer);
80
+ if (res.status >= 300 && res.status < 400) {
81
+ warnings.push(`Redirects not followed (HTTP ${res.status}) — supply final URL directly`);
82
+ status = res.status;
83
+ return {
84
+ url: targetUrl,
85
+ status,
86
+ requiresPayment: false,
87
+ authMode: "unknown",
88
+ priceUsdc: null,
89
+ network: null,
90
+ payTo: null,
91
+ paymentOptions: [],
92
+ warnings,
93
+ };
94
+ }
95
+ status = res.status;
96
+ const text = await res.text();
97
+ try {
98
+ body = text ? JSON.parse(text) : null;
99
+ }
100
+ catch {
101
+ body = { raw: text.slice(0, 500) };
102
+ }
103
+ }
104
+ catch (err) {
105
+ warnings.push(`Probe failed: ${err instanceof Error ? err.message : String(err)}`);
106
+ return {
107
+ url: targetUrl,
108
+ status: 0,
109
+ requiresPayment: false,
110
+ authMode: "unknown",
111
+ priceUsdc: null,
112
+ network: null,
113
+ payTo: null,
114
+ paymentOptions: [],
115
+ warnings,
116
+ };
117
+ }
118
+ const paymentOptions = parsePaymentOptions(body);
119
+ const parsed = firstOption(paymentOptions);
120
+ const requiresPayment = status === 402;
121
+ if (requiresPayment && paymentOptions.length === 0) {
122
+ warnings.push("402 without parseable paymentOptions/accepts");
123
+ }
124
+ return {
125
+ url: targetUrl,
126
+ status,
127
+ requiresPayment,
128
+ authMode: requiresPayment ? "paid" : status === 200 ? "unprotected" : "unknown",
129
+ priceUsdc: parsed.priceUsdc,
130
+ network: parsed.network,
131
+ payTo: parsed.payTo,
132
+ paymentOptions,
133
+ warnings,
134
+ };
135
+ }
136
+ /** Pick cheapest payment rail; prefer eip155:8453 when within 5% of minimum. */
137
+ export function pickCheapestRail(options, preferNetwork) {
138
+ if (options.length === 0)
139
+ return null;
140
+ const sorted = [...options].sort((a, b) => a.priceUsdc - b.priceUsdc);
141
+ const min = sorted[0];
142
+ if (!preferNetwork)
143
+ return min;
144
+ const pref = preferNetwork.toLowerCase();
145
+ const preferred = sorted.find((o) => o.network.toLowerCase().includes(pref));
146
+ if (preferred && preferred.priceUsdc <= min.priceUsdc * 1.05)
147
+ return preferred;
148
+ return min;
149
+ }
150
+ export function hostOf(url) {
151
+ try {
152
+ return new URL(url).hostname.toLowerCase();
153
+ }
154
+ catch {
155
+ return null;
156
+ }
157
+ }
@@ -0,0 +1,10 @@
1
+ export type ProblemDetail = {
2
+ type: string;
3
+ title: string;
4
+ status: number;
5
+ detail?: string;
6
+ instance?: string;
7
+ suggestion?: string;
8
+ };
9
+ export declare function problemDetail(status: number, title: string, detail?: string, suggestion?: string): ProblemDetail;
10
+ export declare function sendProblem(res: import("express").Response, status: number, title: string, detail?: string, suggestion?: string): void;
@@ -0,0 +1,14 @@
1
+ export function problemDetail(status, title, detail, suggestion) {
2
+ return {
3
+ type: `https://x402trustlayer.xyz/errors/${title.toLowerCase().replace(/\s+/g, "-")}`,
4
+ title,
5
+ status,
6
+ detail,
7
+ instance: undefined,
8
+ suggestion,
9
+ };
10
+ }
11
+ export function sendProblem(res, status, title, detail, suggestion) {
12
+ const body = problemDetail(status, title, detail, suggestion);
13
+ res.status(status).type("application/problem+json").json(body);
14
+ }