xytara 3.1.16 → 3.2.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 (390) hide show
  1. package/README.md +120 -92
  2. package/RELEASE_NOTES.md +7 -3
  3. package/START_HERE.md +56 -224
  4. package/bin/xytara.js +21 -8
  5. package/client.js +79 -1
  6. package/lib/{delivery_receipt.js → delivery_receipt_verify.js} +14 -100
  7. package/package.json +25 -35
  8. package/scripts/verify_client.js +418 -0
  9. package/scripts/verify_release_candidate.js +146 -45
  10. package/.env.example +0 -173
  11. package/ADAPTER_START_HERE.md +0 -56
  12. package/BSV_TERANODE_PLATFORM_DISCONTINUITY_RUNBOOK.md +0 -126
  13. package/CARRIED_HANDOFF_DEMO.md +0 -60
  14. package/EXAMPLE_PATHS.md +0 -53
  15. package/FINAL_CONTRACT.md +0 -498
  16. package/PARTNER_READY_PATH.md +0 -71
  17. package/PUBLIC_DEMO_SCRIPT.md +0 -78
  18. package/REAL_PAYMENT_SETUP.md +0 -320
  19. package/SERVICE_CONTRACT.md +0 -419
  20. package/SUPABASE_RUNTIME_STATE_SETUP.md +0 -61
  21. package/TERMINOLOGY.md +0 -50
  22. package/WHY_XYTARA_XOONYA.md +0 -63
  23. package/XT1_EXECUTION_TRUTH_STANDARD.md +0 -78
  24. package/XYTARA_ADAPTER_PROTOCOL_TRUTH_MODEL.md +0 -75
  25. package/XYTARA_AUTONOMOUS_ENTRY_MODEL.md +0 -124
  26. package/XYTARA_DEFAULT_PATH_MODEL.md +0 -84
  27. package/XYTARA_EXECUTION_TRUTH_MODEL.md +0 -171
  28. package/XYTARA_PAYMENT_RAIL_TRUTH_MODEL.md +0 -68
  29. package/adapters/AUTHORING_GUIDE.md +0 -244
  30. package/adapters/ONBOARDING_POSTURE.md +0 -61
  31. package/adapters/THIRD_PARTY_SUBMISSION_PROCESS.md +0 -84
  32. package/adapters/adapter-manifest.schema.json +0 -283
  33. package/adapters/examples/example-execution-adapter.js +0 -61
  34. package/adapters/examples/example-execution-adapter.manifest.json +0 -81
  35. package/adapters/examples/example-settlement-adapter.js +0 -55
  36. package/adapters/examples/example-settlement-adapter.manifest.json +0 -78
  37. package/adapters/examples/example-third-party-acp-registration.submission-bundle.json +0 -124
  38. package/adapters/examples/example-third-party-erc8004-registration.submission-bundle.json +0 -121
  39. package/adapters/examples/example-third-party-identity-registration.certification-pack.json +0 -22
  40. package/adapters/examples/example-third-party-identity-registration.record.json +0 -26
  41. package/adapters/examples/example-third-party-identity-registration.submission-bundle.json +0 -126
  42. package/adapters/examples/example-third-party-langchain-registration.submission-bundle.json +0 -124
  43. package/adapters/examples/example-third-party-mpp-registration.submission-bundle.json +0 -120
  44. package/adapters/examples/example-third-party-registration.certification-pack.json +0 -22
  45. package/adapters/examples/example-third-party-registration.record.json +0 -28
  46. package/adapters/examples/example-third-party-registration.submission-bundle.json +0 -126
  47. package/adapters/examples/example-third-party-settlement-registration.certification-pack.json +0 -22
  48. package/adapters/examples/example-third-party-settlement-registration.record.json +0 -26
  49. package/adapters/examples/example-third-party-settlement-registration.submission-bundle.json +0 -127
  50. package/adapters/examples/langchain-reference-execution-adapter.js +0 -81
  51. package/adapters/examples/langchain-reference-execution-adapter.manifest.json +0 -79
  52. package/adapters/examples/langgraph-reference-execution-adapter.js +0 -81
  53. package/adapters/examples/langgraph-reference-execution-adapter.manifest.json +0 -79
  54. package/adapters/examples/minimal-third-party-execution-adapter.js +0 -61
  55. package/adapters/examples/minimal-third-party-execution-adapter.manifest.json +0 -79
  56. package/adapters/examples/minimal-third-party-execution-registration.record.json +0 -26
  57. package/adapters/examples/minimal-third-party-execution.certification-pack.json +0 -22
  58. package/adapters/examples/minimal-third-party-execution.submission-bundle.json +0 -126
  59. package/adapters/integration-certification-pack.schema.json +0 -82
  60. package/adapters/integration-registration-record.schema.json +0 -114
  61. package/adapters/integration-submission-bundle-set.schema.json +0 -39
  62. package/adapters/integration-submission-bundle.schema.json +0 -34
  63. package/adapters/interfaces.js +0 -56
  64. package/bin/xytara-release.js +0 -1429
  65. package/examples/_demo_env.js +0 -40
  66. package/examples/adapter_review_walkthrough.js +0 -54
  67. package/examples/export_carried_handoff.js +0 -81
  68. package/examples/funded_runtime_walkthrough.js +0 -71
  69. package/examples/partner_launch_walkthrough.js +0 -44
  70. package/examples/quickstart.js +0 -3256
  71. package/fixtures/catalog.js +0 -1156
  72. package/index.js +0 -395
  73. package/integrations/dispatch.js +0 -276
  74. package/integrations/registry-snapshot.schema.json +0 -36
  75. package/integrations/registry.js +0 -2261
  76. package/integrations/views.js +0 -28
  77. package/lib/a2a_lane_contract.js +0 -104
  78. package/lib/a2a_rpc.js +0 -287
  79. package/lib/a2c_lane_contract.js +0 -111
  80. package/lib/account_auth.js +0 -585
  81. package/lib/acp_lane_contract.js +0 -54
  82. package/lib/activity_audit_contract.js +0 -322
  83. package/lib/adapter_certification_contract.js +0 -130
  84. package/lib/adapter_depth_contract.js +0 -218
  85. package/lib/adapter_pack.js +0 -118
  86. package/lib/adapter_partner_pack.js +0 -89
  87. package/lib/adapter_promotion_pack.js +0 -89
  88. package/lib/adapter_protocol_truth_contract.js +0 -229
  89. package/lib/agent_identity.js +0 -162
  90. package/lib/announcement_pack.js +0 -61
  91. package/lib/artifact_distribution_lane_contract.js +0 -54
  92. package/lib/asyncapi_contract.js +0 -150
  93. package/lib/auth_interop_contract.js +0 -80
  94. package/lib/authority_binding_lifecycle_contract.js +0 -182
  95. package/lib/autonomous_entry_contract.js +0 -409
  96. package/lib/bolt_adapter.js +0 -187
  97. package/lib/bolt_lane_contract.js +0 -55
  98. package/lib/bolt_payment_front.js +0 -224
  99. package/lib/business_cockpit.js +0 -378
  100. package/lib/buyer_event_log.js +0 -230
  101. package/lib/buyer_safety_policy.js +0 -132
  102. package/lib/capability_execution_truth.js +0 -276
  103. package/lib/capability_registry.js +0 -633
  104. package/lib/catalog_contract.js +0 -966
  105. package/lib/catalog_family_model.js +0 -193
  106. package/lib/catalog_views.js +0 -55
  107. package/lib/cdp_jwt.js +0 -57
  108. package/lib/checkout_event_security.js +0 -142
  109. package/lib/checkout_processor_adapter.js +0 -217
  110. package/lib/cloudevents_contract.js +0 -80
  111. package/lib/command_flow.js +0 -911
  112. package/lib/commerce_artifacts.js +0 -591
  113. package/lib/commerce_authority.js +0 -449
  114. package/lib/commerce_bridge.js +0 -274
  115. package/lib/commerce_cases.js +0 -399
  116. package/lib/commerce_checkout.js +0 -509
  117. package/lib/commerce_coordination.js +0 -346
  118. package/lib/commerce_economics.js +0 -4017
  119. package/lib/commerce_identity.js +0 -578
  120. package/lib/commerce_quotes.js +0 -266
  121. package/lib/commerce_reports.js +0 -14461
  122. package/lib/commerce_runtime.js +0 -322
  123. package/lib/commerce_shell.js +0 -257
  124. package/lib/crypto_agility_matrix.js +0 -125
  125. package/lib/default_path_contract.js +0 -412
  126. package/lib/delivery_summary_contract.js +0 -95
  127. package/lib/ecosystem_entry.js +0 -64
  128. package/lib/erc8004_lane_contract.js +0 -65
  129. package/lib/event_system_lane_contract.js +0 -75
  130. package/lib/execution_dedupe.js +0 -86
  131. package/lib/execution_truth_contract.js +0 -234
  132. package/lib/external_credit_bridge.js +0 -142
  133. package/lib/external_execution_policy.js +0 -143
  134. package/lib/external_execution_runtime.js +0 -238
  135. package/lib/feature_control_lane_contract.js +0 -54
  136. package/lib/first_run_conversion_contract.js +0 -290
  137. package/lib/framework_lane_contract.js +0 -89
  138. package/lib/framework_provider_promotion.js +0 -235
  139. package/lib/full_catalog_contract.js +0 -525
  140. package/lib/go_live_operator_pack.js +0 -391
  141. package/lib/http_transport.js +0 -99
  142. package/lib/identity_auth.js +0 -175
  143. package/lib/identity_interop_contract.js +0 -82
  144. package/lib/integration_matrix_contract.js +0 -102
  145. package/lib/l402_adapter.js +0 -241
  146. package/lib/l402_lane_contract.js +0 -55
  147. package/lib/l402_payment_front.js +0 -265
  148. package/lib/launch_narrative.js +0 -53
  149. package/lib/lifecycle_continuity_contract.js +0 -115
  150. package/lib/machine_identity_registry_contract.js +0 -199
  151. package/lib/major_rails_lane_contract.js +0 -150
  152. package/lib/market_lane_contract.js +0 -467
  153. package/lib/market_lane_depth_contract.js +0 -182
  154. package/lib/market_lane_promotion_contract.js +0 -210
  155. package/lib/market_lane_trace_contract.js +0 -278
  156. package/lib/mcp_lane_contract.js +0 -137
  157. package/lib/mpp_adapter.js +0 -237
  158. package/lib/network_transport.js +0 -110
  159. package/lib/offline_verifiability_recovery_contract.js +0 -155
  160. package/lib/openapi_contract.js +0 -300
  161. package/lib/operational_receipt_contract.js +0 -165
  162. package/lib/operator_intelligence.js +0 -407
  163. package/lib/outreach_copy_pack.js +0 -51
  164. package/lib/outreach_message_pack.js +0 -71
  165. package/lib/outreach_proof.js +0 -71
  166. package/lib/outreach_target_pack.js +0 -60
  167. package/lib/partner_intelligence.js +0 -105
  168. package/lib/payment_config.js +0 -257
  169. package/lib/payment_front_registry.js +0 -53
  170. package/lib/payment_protocol_contract.js +0 -165
  171. package/lib/payment_rail_truth_contract.js +0 -324
  172. package/lib/payment_verification.js +0 -357
  173. package/lib/phase_10_closeout_pack.js +0 -45
  174. package/lib/phase_10_completion_pack.js +0 -76
  175. package/lib/phase_10_decision_record_pack.js +0 -54
  176. package/lib/phase_10_decision_resolution_pack.js +0 -53
  177. package/lib/phase_10_demand_signal_adapters_runtime_pack.js +0 -74
  178. package/lib/phase_10_ecosystem_backlog_triage_runtime_pack.js +0 -74
  179. package/lib/phase_10_freeze_baseline_pack.js +0 -67
  180. package/lib/phase_10_freeze_review_pack.js +0 -64
  181. package/lib/phase_10_gate_pack.js +0 -57
  182. package/lib/phase_10_long_tail_continuity_pack.js +0 -80
  183. package/lib/phase_10_long_tail_ecosystem_pack.js +0 -66
  184. package/lib/phase_10_niche_extension_registry_runtime_pack.js +0 -74
  185. package/lib/phase_1_claude_mcp_pack.js +0 -60
  186. package/lib/phase_1_claude_mcp_runtime_pack.js +0 -52
  187. package/lib/phase_1_ecosystem_pack.js +0 -67
  188. package/lib/phase_1_openai_codex_pack.js +0 -60
  189. package/lib/phase_1_openai_codex_runtime_pack.js +0 -52
  190. package/lib/phase_2_base_runtime_pack.js +0 -71
  191. package/lib/phase_2_base_usdc_runtime_pack.js +0 -72
  192. package/lib/phase_2_closeout_pack.js +0 -65
  193. package/lib/phase_2_completion_pack.js +0 -113
  194. package/lib/phase_2_decision_record_pack.js +0 -66
  195. package/lib/phase_2_decision_resolution_pack.js +0 -69
  196. package/lib/phase_2_eth_runtime_pack.js +0 -70
  197. package/lib/phase_2_evm_base_runtime_pack.js +0 -73
  198. package/lib/phase_2_evm_runtime_pack.js +0 -71
  199. package/lib/phase_2_flip_preview_pack.js +0 -60
  200. package/lib/phase_2_freeze_review_pack.js +0 -99
  201. package/lib/phase_2_gate_pack.js +0 -77
  202. package/lib/phase_2_payment_rails_pack.js +0 -71
  203. package/lib/phase_2_usdc_runtime_pack.js +0 -71
  204. package/lib/phase_3_brc_runtime_pack.js +0 -81
  205. package/lib/phase_3_bsv_teranode_runtime_pack.js +0 -83
  206. package/lib/phase_3_closeout_pack.js +0 -62
  207. package/lib/phase_3_completion_pack.js +0 -94
  208. package/lib/phase_3_decision_record_pack.js +0 -64
  209. package/lib/phase_3_decision_resolution_pack.js +0 -69
  210. package/lib/phase_3_freeze_baseline_pack.js +0 -67
  211. package/lib/phase_3_freeze_review_pack.js +0 -80
  212. package/lib/phase_3_gate_pack.js +0 -76
  213. package/lib/phase_3_metanet_runtime_pack.js +0 -81
  214. package/lib/phase_3_native_bsv_pack.js +0 -91
  215. package/lib/phase_3_native_continuity_pack.js +0 -82
  216. package/lib/phase_4_attestation_runtime_pack.js +0 -75
  217. package/lib/phase_4_closeout_pack.js +0 -45
  218. package/lib/phase_4_completion_pack.js +0 -94
  219. package/lib/phase_4_decision_record_pack.js +0 -54
  220. package/lib/phase_4_decision_resolution_pack.js +0 -45
  221. package/lib/phase_4_erc8004_runtime_pack.js +0 -76
  222. package/lib/phase_4_freeze_baseline_pack.js +0 -67
  223. package/lib/phase_4_freeze_review_pack.js +0 -68
  224. package/lib/phase_4_gate_pack.js +0 -58
  225. package/lib/phase_4_identity_registry_runtime_pack.js +0 -75
  226. package/lib/phase_4_identity_trust_pack.js +0 -73
  227. package/lib/phase_4_trust_continuity_pack.js +0 -86
  228. package/lib/phase_5_antelope_runtime_pack.js +0 -76
  229. package/lib/phase_5_closeout_pack.js +0 -44
  230. package/lib/phase_5_completion_pack.js +0 -82
  231. package/lib/phase_5_constellation_dag_runtime_pack.js +0 -76
  232. package/lib/phase_5_decision_record_pack.js +0 -54
  233. package/lib/phase_5_decision_resolution_pack.js +0 -45
  234. package/lib/phase_5_digibyte_dgb_runtime_pack.js +0 -76
  235. package/lib/phase_5_freeze_baseline_pack.js +0 -67
  236. package/lib/phase_5_freeze_review_pack.js +0 -68
  237. package/lib/phase_5_gate_pack.js +0 -58
  238. package/lib/phase_5_hedera_hbar_runtime_pack.js +0 -76
  239. package/lib/phase_5_kaspa_kas_runtime_pack.js +0 -76
  240. package/lib/phase_5_major_rails_continuity_pack.js +0 -86
  241. package/lib/phase_5_major_rails_pack.js +0 -110
  242. package/lib/phase_5_metal_runtime_pack.js +0 -76
  243. package/lib/phase_5_polkadot_dot_runtime_pack.js +0 -76
  244. package/lib/phase_5_proton_xpr_runtime_pack.js +0 -76
  245. package/lib/phase_5_solana_runtime_pack.js +0 -76
  246. package/lib/phase_6_autogen_runtime_pack.js +0 -72
  247. package/lib/phase_6_closeout_pack.js +0 -46
  248. package/lib/phase_6_completion_pack.js +0 -77
  249. package/lib/phase_6_decision_record_pack.js +0 -54
  250. package/lib/phase_6_decision_resolution_pack.js +0 -53
  251. package/lib/phase_6_framework_continuity_pack.js +0 -81
  252. package/lib/phase_6_framework_runtime_pack.js +0 -68
  253. package/lib/phase_6_freeze_baseline_pack.js +0 -68
  254. package/lib/phase_6_freeze_review_pack.js +0 -65
  255. package/lib/phase_6_gate_pack.js +0 -59
  256. package/lib/phase_6_langchain_runtime_pack.js +0 -72
  257. package/lib/phase_6_langgraph_runtime_pack.js +0 -72
  258. package/lib/phase_6_semantic_kernel_runtime_pack.js +0 -72
  259. package/lib/phase_7_closeout_pack.js +0 -45
  260. package/lib/phase_7_completion_pack.js +0 -85
  261. package/lib/phase_7_decision_record_pack.js +0 -53
  262. package/lib/phase_7_decision_resolution_pack.js +0 -53
  263. package/lib/phase_7_event_system_continuity_pack.js +0 -89
  264. package/lib/phase_7_event_system_pack.js +0 -76
  265. package/lib/phase_7_freeze_baseline_pack.js +0 -74
  266. package/lib/phase_7_freeze_review_pack.js +0 -65
  267. package/lib/phase_7_gate_pack.js +0 -58
  268. package/lib/phase_7_kafka_runtime_pack.js +0 -74
  269. package/lib/phase_7_mqtt_runtime_pack.js +0 -74
  270. package/lib/phase_7_nats_runtime_pack.js +0 -74
  271. package/lib/phase_7_webhook_event_bus_runtime_pack.js +0 -74
  272. package/lib/phase_8_closeout_pack.js +0 -46
  273. package/lib/phase_8_completion_pack.js +0 -82
  274. package/lib/phase_8_decision_record_pack.js +0 -54
  275. package/lib/phase_8_decision_resolution_pack.js +0 -53
  276. package/lib/phase_8_external_receipt_import_runtime_pack.js +0 -74
  277. package/lib/phase_8_external_result_import_runtime_pack.js +0 -74
  278. package/lib/phase_8_freeze_baseline_pack.js +0 -71
  279. package/lib/phase_8_freeze_review_pack.js +0 -64
  280. package/lib/phase_8_gate_pack.js +0 -58
  281. package/lib/phase_8_proof_bridge_continuity_pack.js +0 -86
  282. package/lib/phase_8_proof_bridges_pack.js +0 -72
  283. package/lib/phase_8_proof_bundle_normalization_runtime_pack.js +0 -74
  284. package/lib/phase_9_closeout_pack.js +0 -46
  285. package/lib/phase_9_completion_pack.js +0 -82
  286. package/lib/phase_9_custody_refs_runtime_pack.js +0 -74
  287. package/lib/phase_9_decision_record_pack.js +0 -54
  288. package/lib/phase_9_decision_resolution_pack.js +0 -53
  289. package/lib/phase_9_freeze_baseline_pack.js +0 -71
  290. package/lib/phase_9_freeze_review_pack.js +0 -64
  291. package/lib/phase_9_gate_pack.js +0 -58
  292. package/lib/phase_9_operator_accounting_bridges_runtime_pack.js +0 -74
  293. package/lib/phase_9_treasury_connectivity_pack.js +0 -72
  294. package/lib/phase_9_treasury_continuity_pack.js +0 -86
  295. package/lib/phase_9_treasury_destinations_runtime_pack.js +0 -74
  296. package/lib/phase_program_pack.js +0 -120
  297. package/lib/pricing_optimization_contract.js +0 -775
  298. package/lib/protocol_lane_contract.js +0 -117
  299. package/lib/provenance_lane_contract.js +0 -54
  300. package/lib/provider_lane_contract.js +0 -240
  301. package/lib/provider_network_contract.js +0 -149
  302. package/lib/provider_payout_execution.js +0 -155
  303. package/lib/provider_registry.js +0 -852
  304. package/lib/provider_runtime_journey_contract.js +0 -183
  305. package/lib/public_surface_policy_contract.js +0 -111
  306. package/lib/publish_plan.js +0 -51
  307. package/lib/rate_limiter.js +0 -81
  308. package/lib/record_queries.js +0 -48
  309. package/lib/release_candidate.js +0 -50
  310. package/lib/release_center.js +0 -1093
  311. package/lib/release_history.js +0 -205
  312. package/lib/release_manifest.js +0 -113
  313. package/lib/release_pack.js +0 -453
  314. package/lib/request_rate_limit.js +0 -144
  315. package/lib/resource_views.js +0 -31
  316. package/lib/revenue_launch_path_contract.js +0 -326
  317. package/lib/route_matchers.js +0 -34
  318. package/lib/route_params.js +0 -19
  319. package/lib/runtime_bridge.js +0 -124
  320. package/lib/runtime_operations_worker.js +0 -282
  321. package/lib/runtime_state_store.js +0 -495
  322. package/lib/settlement_bsv_live.js +0 -600
  323. package/lib/settlement_bsv_teranode.js +0 -117
  324. package/lib/settlement_lane_contract.js +0 -111
  325. package/lib/shared_signals_lane_contract.js +0 -54
  326. package/lib/signed_audit_provenance_contract.js +0 -83
  327. package/lib/soft_launch_pack.js +0 -78
  328. package/lib/stablecoin_lane_contract.js +0 -76
  329. package/lib/stripe_mpp_lane_contract.js +0 -96
  330. package/lib/stripe_mpp_payment_front.js +0 -258
  331. package/lib/telemetry_lane_contract.js +0 -54
  332. package/lib/treasury_destinations_contract.js +0 -764
  333. package/lib/treasury_egress_policy_contract.js +0 -91
  334. package/lib/treasury_lane_contract.js +0 -84
  335. package/lib/trust_portability_boundary_contract.js +0 -72
  336. package/lib/x402_facilitator.js +0 -198
  337. package/lib/x402_lane_contract.js +0 -136
  338. package/lib/x402_settlement_recovery.js +0 -175
  339. package/scripts/buyer_events_daily_report.js +0 -79
  340. package/scripts/registry_cli.js +0 -275
  341. package/scripts/state_backup_offsite.js +0 -196
  342. package/scripts/verify_a2a_rpc.js +0 -131
  343. package/scripts/verify_adapters.js +0 -554
  344. package/scripts/verify_agent_identity.js +0 -153
  345. package/scripts/verify_all.js +0 -4963
  346. package/scripts/verify_bolt_adapter.js +0 -128
  347. package/scripts/verify_buyer_event_log.js +0 -128
  348. package/scripts/verify_buyer_safety.js +0 -141
  349. package/scripts/verify_cdp_facilitator.js +0 -110
  350. package/scripts/verify_checkout_processor.js +0 -109
  351. package/scripts/verify_commerce_bridge.js +0 -177
  352. package/scripts/verify_control_plane_contracts.js +0 -34
  353. package/scripts/verify_control_plane_routes.js +0 -70
  354. package/scripts/verify_delivery_summary.js +0 -112
  355. package/scripts/verify_examples.js +0 -19
  356. package/scripts/verify_execution_dedupe.js +0 -189
  357. package/scripts/verify_execution_surfacing.js +0 -76
  358. package/scripts/verify_external_execution_retry.js +0 -140
  359. package/scripts/verify_final_activation.js +0 -191
  360. package/scripts/verify_first_run_conversions.js +0 -81
  361. package/scripts/verify_framework_provider_promotion.js +0 -152
  362. package/scripts/verify_full_catalog.js +0 -174
  363. package/scripts/verify_integrations.js +0 -620
  364. package/scripts/verify_l402_adapter.js +0 -86
  365. package/scripts/verify_lifecycle_continuity.js +0 -96
  366. package/scripts/verify_lifecycle_spend_binding.js +0 -88
  367. package/scripts/verify_market_lane_depth.js +0 -94
  368. package/scripts/verify_market_lane_promotion.js +0 -103
  369. package/scripts/verify_market_lane_traces.js +0 -98
  370. package/scripts/verify_market_lanes.js +0 -102
  371. package/scripts/verify_mpp_adapter.js +0 -128
  372. package/scripts/verify_operator_observability_boundary.js +0 -83
  373. package/scripts/verify_pricing_experiment_plan.js +0 -124
  374. package/scripts/verify_production_readiness.js +0 -268
  375. package/scripts/verify_provider_network.js +0 -819
  376. package/scripts/verify_provider_runtime_breadth.js +0 -109
  377. package/scripts/verify_provider_runtime_journeys.js +0 -111
  378. package/scripts/verify_rate_limiter.js +0 -52
  379. package/scripts/verify_refund_credit.js +0 -106
  380. package/scripts/verify_revenue_launch_paths.js +0 -105
  381. package/scripts/verify_runtime_durability.js +0 -52
  382. package/scripts/verify_runtime_state_guard.js +0 -117
  383. package/scripts/verify_service.js +0 -15421
  384. package/scripts/verify_settlement.js +0 -116
  385. package/scripts/verify_tooling.js +0 -1412
  386. package/scripts/verify_treasury_public_boundary.js +0 -97
  387. package/scripts/verify_verify_execute_settle.js +0 -209
  388. package/scripts/verify_x402_facilitator.js +0 -307
  389. package/scripts/verify_x402_settlement_recovery.js +0 -153
  390. package/server.js +0 -12245
@@ -1,128 +0,0 @@
1
- "use strict";
2
-
3
- // Verifies the BSV/UTXO (BOLT) adapter (lib/bolt_adapter.js). Offline: the chain
4
- // fetch is injected as a mock, so no network. Exercises config gating, header
5
- // parsing, and the on-chain amount/address verification + confirmations logic.
6
-
7
- const assert = require("assert");
8
- const m = require("../lib/bolt_adapter");
9
-
10
- function setEnv(env) {
11
- const saved = {};
12
- for (const k in env) {
13
- saved[k] = process.env[k];
14
- if (env[k] === undefined) delete process.env[k];
15
- else process.env[k] = env[k];
16
- }
17
- return () => {
18
- for (const k in saved) {
19
- if (saved[k] === undefined) delete process.env[k];
20
- else process.env[k] = saved[k];
21
- }
22
- };
23
- }
24
-
25
- const PAYTO = "1NaxytraPayToAddressExampleXXXXXXXXXX";
26
- const TXID = "a".repeat(64);
27
-
28
- function mockTx(voutValueBsv, address, confirmations) {
29
- return async () => ({ status: 200, json: { confirmations, vout: [{ value: voutValueBsv, scriptPubKey: { addresses: [address] } }] } });
30
- }
31
-
32
- async function main() {
33
- // 1. Not configured.
34
- let restore = setEnv({ XYTARA_BOLT_PROVIDER: undefined });
35
- let cfg = m.loadBoltConfig();
36
- assert.strictEqual(cfg.provider, null);
37
- assert.strictEqual(m.isConfigured(cfg), false);
38
- assert.strictEqual((await m.verifyBsvPayment(cfg, TXID)).reason, "bolt_provider_not_configured");
39
- restore();
40
-
41
- // 2. Configured (whatsonchain).
42
- restore = setEnv({
43
- XYTARA_BOLT_PROVIDER: "whatsonchain",
44
- XYTARA_BOLT_PAYTO_ADDRESS: PAYTO,
45
- XYTARA_BOLT_PRICE_SATS: "1000",
46
- XYTARA_BOLT_MIN_CONFIRMATIONS: "1",
47
- XYTARA_BOLT_NETWORK: "main"
48
- });
49
- cfg = m.loadBoltConfig();
50
- assert.strictEqual(cfg.provider, "whatsonchain");
51
- assert.ok(cfg.apiUrl.includes("whatsonchain.com"));
52
-
53
- // Header parsing.
54
- assert.deepStrictEqual(m.parseBoltHeader(`BOLT ${TXID}`), { txid: TXID });
55
- assert.strictEqual(m.parseBoltHeader("BOLT not-a-txid"), null);
56
- assert.strictEqual(m.parseBoltHeader("Bearer x"), null);
57
-
58
- // Challenge shape.
59
- const ch = m.buildBoltChallenge(cfg);
60
- assert.strictEqual(ch.address, PAYTO);
61
- assert.strictEqual(ch.amount_sats, 1000);
62
-
63
- // Invalid txid -> rejected before any fetch.
64
- assert.strictEqual((await m.verifyBsvPayment(cfg, "xyz")).reason, "bolt_txid_invalid");
65
-
66
- // Sufficient payment (0.00002 BSV = 2000 sats to PAYTO, 3 confs) -> ok.
67
- let r = await m.verifyBsvPayment(cfg, TXID, mockTx(0.00002, PAYTO, 3));
68
- assert.strictEqual(r.ok, true);
69
- assert.strictEqual(r.paid_sats, 2000);
70
- assert.strictEqual(r.confirmations, 3);
71
-
72
- // --- Per-quote binding: unique exact amount ---
73
- const reqSats = m.computeRequiredSats(cfg, { quote_id: "quote_x" });
74
- assert.ok(reqSats >= 1000 && reqSats < 1000 + cfg.bindingWindowSats, "required = price + bounded offset");
75
- assert.strictEqual(reqSats, m.computeRequiredSats(cfg, { quote_id: "quote_x" }), "deterministic");
76
- // Paying the EXACT bound amount -> ok.
77
- r = await m.verifyBsvPayment(cfg, TXID, mockTx(reqSats / 1e8, PAYTO, 3), { requiredSats: reqSats });
78
- assert.strictEqual(r.ok, true);
79
- assert.strictEqual(r.paid_sats, reqSats);
80
- assert.strictEqual(r.required_sats, reqSats);
81
- // Paying a DIFFERENT amount (even to the right address) -> mismatch, so an
82
- // unrelated payment cannot be reused to satisfy this quote.
83
- r = await m.verifyBsvPayment(cfg, TXID, mockTx((reqSats + 1) / 1e8, PAYTO, 3), { requiredSats: reqSats });
84
- assert.strictEqual(r.reason, "bolt_amount_mismatch");
85
- // Challenge advertises the exact amount.
86
- const boundChallenge = m.buildBoltChallenge(cfg, { requiredSats: reqSats });
87
- assert.strictEqual(boundChallenge.amount_sats, reqSats);
88
- assert.strictEqual(boundChallenge.exact, true);
89
-
90
- // Insufficient amount (500 sats < 1000) -> rejected.
91
- r = await m.verifyBsvPayment(cfg, TXID, mockTx(0.000005, PAYTO, 3));
92
- assert.strictEqual(r.ok, false);
93
- assert.strictEqual(r.reason, "bolt_amount_insufficient");
94
-
95
- // Paid to the wrong address -> counts as zero -> insufficient.
96
- r = await m.verifyBsvPayment(cfg, TXID, mockTx(0.001, "1SomeOtherAddressXXXXXXXXXXXXXXXXXXX", 3));
97
- assert.strictEqual(r.reason, "bolt_amount_insufficient");
98
-
99
- // Too few confirmations -> rejected.
100
- r = await m.verifyBsvPayment(cfg, TXID, mockTx(0.00002, PAYTO, 0));
101
- assert.strictEqual(r.reason, "bolt_insufficient_confirmations");
102
-
103
- // Default min_confirmations is 1 (not 0) when unset -> mempool (0-conf) rejected.
104
- const dflt = setEnv({ XYTARA_BOLT_PROVIDER: "whatsonchain", XYTARA_BOLT_PAYTO_ADDRESS: PAYTO, XYTARA_BOLT_PRICE_SATS: "1000", XYTARA_BOLT_MIN_CONFIRMATIONS: undefined });
105
- const dcfg = m.loadBoltConfig();
106
- assert.strictEqual(dcfg.minConfirmations, 1);
107
- r = await m.verifyBsvPayment(dcfg, TXID, mockTx(0.00002, PAYTO, 0));
108
- assert.strictEqual(r.reason, "bolt_insufficient_confirmations");
109
- dflt();
110
-
111
- // Tx not found (404) -> rejected.
112
- r = await m.verifyBsvPayment(cfg, TXID, async () => ({ status: 404, json: null }));
113
- assert.strictEqual(r.reason, "bolt_tx_not_found");
114
- restore();
115
-
116
- // 3. Configured but missing payto/price -> explicit reason (no fetch).
117
- restore = setEnv({ XYTARA_BOLT_PROVIDER: "whatsonchain", XYTARA_BOLT_PAYTO_ADDRESS: undefined, XYTARA_BOLT_PRICE_SATS: undefined });
118
- cfg = m.loadBoltConfig();
119
- assert.strictEqual((await m.verifyBsvPayment(cfg, TXID)).reason, "bolt_payto_or_price_missing");
120
- restore();
121
-
122
- console.log("verify_bolt_adapter: all BSV/UTXO (BOLT) adapter checks passed");
123
- }
124
-
125
- main().catch((error) => {
126
- console.error("verify_bolt_adapter failed:", error && error.message ? error.message : error);
127
- process.exitCode = 1;
128
- });
@@ -1,128 +0,0 @@
1
- "use strict";
2
-
3
- // End-to-end check (real local server) of the buyer event log: failed buyer attempts are recorded
4
- // with a stage/reason/fault and a request id the buyer also receives; normal 402 challenges are
5
- // counted, not logged; malformed JSON is a 400 (not a 500); executor events can be ingested with
6
- // the dedicated token only; reads are operator-only; nothing sensitive (payment signature, full
7
- // payer address) is ever stored.
8
-
9
- const assert = require("assert");
10
-
11
- const PAYER = "0x1111111111111111111111111111111111111111";
12
- const ACCEPTS = [{
13
- scheme: "exact",
14
- network: "eip155:8453",
15
- asset: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
16
- amount: "10000",
17
- payTo: "0x7cd2E0Ed2721319B20FAac4109774d030833F84D",
18
- extra: { name: "USD Coin", version: "2" },
19
- maxTimeoutSeconds: 60
20
- }];
21
- const FAKE_SIGNATURE = `0x${"9f".repeat(65)}`;
22
-
23
- async function request(baseUrl, method, path, { body, raw, headers = {} } = {}) {
24
- const res = await fetch(`${baseUrl}${path}`, {
25
- method,
26
- headers: { "content-type": "application/json", ...headers },
27
- body: raw !== undefined ? raw : body !== undefined ? JSON.stringify(body) : undefined
28
- });
29
- let json = null;
30
- try { json = await res.json(); } catch (_) { json = null; }
31
- return { status: res.status, json, headers: res.headers };
32
- }
33
-
34
- async function main() {
35
- const OP = "event-log-operator-token";
36
- const INGEST = "event-log-ingest-token";
37
- const keys = ["XYTARA_ACCOUNT_AUTH_BEARER_TOKEN", "XYTARA_EVENT_INGEST_TOKEN", "XYTARA_PAID_EXECUTION_POLICY", "XYTARA_PAYMENT_VERIFICATION_MODE", "XYTARA_X402_ACCEPTS_JSON", "XYTARA_X402_FACILITATOR_URL"];
38
- const previous = Object.fromEntries(keys.map((key) => [key, process.env[key]]));
39
- process.env.XYTARA_ACCOUNT_AUTH_BEARER_TOKEN = OP;
40
- process.env.XYTARA_EVENT_INGEST_TOKEN = INGEST;
41
- process.env.XYTARA_PAID_EXECUTION_POLICY = "strict";
42
- process.env.XYTARA_PAYMENT_VERIFICATION_MODE = "x402_facilitator";
43
- process.env.XYTARA_X402_ACCEPTS_JSON = JSON.stringify(ACCEPTS);
44
- process.env.XYTARA_X402_FACILITATOR_URL = "http://127.0.0.1:9";
45
-
46
- delete require.cache[require.resolve("../server")];
47
- const { createServer } = require("../server");
48
- const server = createServer();
49
- await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve));
50
- const baseUrl = `http://127.0.0.1:${server.address().port}`;
51
- const operator = { authorization: `Bearer ${OP}` };
52
- try {
53
- // 1. Malformed JSON is the buyer's error (400 invalid_json), with a request id, and is logged.
54
- const malformed = await request(baseUrl, "POST", "/x402/commands/execute", { raw: "{not json" });
55
- assert.strictEqual(malformed.status, 400, "malformed JSON must be a 400, not a 500");
56
- assert.strictEqual(malformed.json.reason, "invalid_json");
57
- assert.ok(/^req_[0-9a-f]{16}$/.test(malformed.headers.get("x-request-id") || ""), "every response carries X-Request-Id");
58
-
59
- // 2. A non-executable task (strict) is refused and logged as a route failure.
60
- const refused = await request(baseUrl, "POST", "/x402/commands/execute", { body: { task_ref: "trust.verify" } });
61
- assert.strictEqual(refused.status, 501);
62
-
63
- // 3. A payment attempt with a fake signature: logged with network/amount and a payer HASH only.
64
- const header = Buffer.from(JSON.stringify({
65
- x402Version: 2,
66
- accepted: ACCEPTS[0],
67
- payload: { signature: FAKE_SIGNATURE, authorization: { from: PAYER, to: ACCEPTS[0].payTo, value: "10000", validAfter: "0", validBefore: String(Math.floor(Date.now() / 1000) + 600), nonce: `0x${"ab".repeat(32)}` } }
68
- })).toString("base64");
69
- const executable = { task_ref: "adapter.mcp.invoke", body: { tool_name: "keccak256", arguments: { data: "abc" } } };
70
- // No executable target here, so register nothing: the strict gate refuses before payment -> still an event.
71
- await request(baseUrl, "POST", "/x402/commands/execute", { body: executable, headers: { "payment-signature": header } });
72
-
73
- // 4. Reads are operator-only.
74
- const anonymous = await request(baseUrl, "GET", "/v1/operator/buyer-events");
75
- assert.strictEqual(anonymous.status, 403, "buyer events are operator-only");
76
- const listed = await request(baseUrl, "GET", "/v1/operator/buyer-events?limit=50", { headers: operator });
77
- assert.strictEqual(listed.status, 200);
78
- const events = listed.json.events;
79
- assert.ok(events.some((event) => event.reason === "invalid_json" && event.stage === "parse" && event.fault === "buyer" && event.request_id === malformed.headers.get("x-request-id")), "malformed JSON event recorded with the buyer's request id");
80
- assert.ok(events.some((event) => event.reason === "capability_not_executable" && event.task_or_tool === "trust.verify"), "non-executable attempt recorded with its task");
81
- const paid = events.find((event) => event.task_or_tool === "keccak256");
82
- assert.ok(paid && paid.network === "eip155:8453" && paid.amount_atomic === "10000" && /^[0-9a-f]{12}$/.test(paid.payer_hash), "payment attempt recorded with network, amount and payer hash");
83
- const serialized = JSON.stringify(listed.json);
84
- assert.ok(!serialized.includes(PAYER.slice(2)) && !serialized.includes("9f9f9f9f9f"), "no full payer address or signature is ever stored");
85
-
86
- // 5. Executor events: dedicated ingest token only.
87
- const forbidden = await request(baseUrl, "POST", "/v1/operator/buyer-events/ingest", { body: { source: "xytara-mcp-executor", events: [] }, headers: operator });
88
- assert.strictEqual(forbidden.status, 403, "the operator token cannot ingest; only the ingest token");
89
- const ingested = await request(baseUrl, "POST", "/v1/operator/buyer-events/ingest", {
90
- headers: { authorization: `Bearer ${INGEST}` },
91
- body: {
92
- source: "xytara-mcp-executor",
93
- events: [
94
- { stage: "challenge_issued", tool: "keccak256" },
95
- { stage: "paid_ok", tool: "keccak256" },
96
- // Normal steps the executor sends with no fault: counted, never failures.
97
- { stage: "free_ok", reason: "free_tool", fault: null, tool: "catalog" },
98
- { stage: "replay_served", reason: "settled_result_cache", fault: null, tool: "keccak256" },
99
- { stage: "payment_settle", reason: "settle_outcome_unknown", fault: "upstream", tool: "summarize", money_moved: true, http_status: 200 }
100
- ]
101
- }
102
- });
103
- assert.strictEqual(ingested.status, 200);
104
- assert.strictEqual(ingested.json.accepted, 5);
105
-
106
- // 6. Summary: denominators and the attention flag.
107
- const summary = await request(baseUrl, "GET", "/v1/operator/buyer-events/summary?days=7", { headers: operator });
108
- assert.strictEqual(summary.status, 200);
109
- assert.ok(summary.json.totals.failures >= 4, "failures counted");
110
- assert.ok(summary.json.totals.challenges_issued >= 1 && summary.json.totals.paid_ok >= 1, "steps counted as denominators");
111
- assert.strictEqual(summary.json.totals.money_moved, 1, "money moved without delivery is surfaced");
112
- assert.strictEqual(summary.json.attention, true, "attention raised");
113
- assert.strictEqual(summary.json.totals.ours, 0, "normal executor steps are never counted as our-fault failures");
114
- assert.ok(!summary.json.top_reasons.some((r) => r.reason === "free_tool"), "free_ok is not a failure reason");
115
-
116
- console.log("xytara verify:buyer-event-log passed");
117
- } finally {
118
- await new Promise((resolve) => server.close(resolve));
119
- for (const key of keys) {
120
- if (previous[key] === undefined) delete process.env[key]; else process.env[key] = previous[key];
121
- }
122
- }
123
- }
124
-
125
- main().catch((error) => {
126
- console.error(error && error.stack ? error.stack : error);
127
- process.exit(1);
128
- });
@@ -1,141 +0,0 @@
1
- "use strict";
2
-
3
- // End-to-end check (real local server) of the hosted-deploy money-safety policy:
4
- // - strict paid execution: a task nothing can execute is refused up front (501, no 402, no charge),
5
- // a missing task_ref is a 400, and an executable task still gets the normal 402 challenge;
6
- // - strict credit spend: a bare account_id can never spend credits; the account's spend credential can;
7
- // - credit spends accrue provider revenue on the units' purchase value, never on the catalog quote.
8
-
9
- const assert = require("assert");
10
- const { reconcileProviderSettlementAmount } = require("../lib/command_flow");
11
- const { buildTopupAccepts, topupUnitsForAccept } = require("../lib/buyer_safety_policy");
12
-
13
- const ACCEPTS = [
14
- {
15
- scheme: "exact",
16
- network: "eip155:8453",
17
- asset: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
18
- amount: "10000",
19
- payTo: "0x7cd2E0Ed2721319B20FAac4109774d030833F84D",
20
- extra: { name: "USD Coin", version: "2" },
21
- maxTimeoutSeconds: 60
22
- },
23
- {
24
- scheme: "exact",
25
- network: "eip155:84532",
26
- asset: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
27
- amount: "1000",
28
- payTo: "0x7cd2E0Ed2721319B20FAac4109774d030833F84D",
29
- extra: { name: "USDC", version: "2" },
30
- maxTimeoutSeconds: 60
31
- }
32
- ];
33
-
34
- async function post(baseUrl, path, body, headers = {}) {
35
- const res = await fetch(`${baseUrl}${path}`, { method: "POST", headers: { "content-type": "application/json", ...headers }, body: JSON.stringify(body) });
36
- let json = null;
37
- try { json = await res.json(); } catch (_) { json = null; }
38
- return { status: res.status, json };
39
- }
40
-
41
- async function main() {
42
- // Pure policy: top-up pricing and credit derivation.
43
- const previousTestnet = process.env.XYTARA_X402_TESTNET_TOPUP;
44
- delete process.env.XYTARA_X402_TESTNET_TOPUP;
45
- const topupAccepts = buildTopupAccepts(ACCEPTS);
46
- assert.deepStrictEqual(topupAccepts.map((a) => a.network), ["eip155:8453"], "testnet accepts cannot buy credits by default");
47
- assert.strictEqual(topupAccepts[0].amount, "1000000", "a top-up costs 100x the per-call price ($1.00)");
48
- assert.strictEqual(topupUnitsForAccept(topupAccepts[0]), 400, "$1.00 buys 400 credits at $0.0025");
49
- assert.strictEqual(topupUnitsForAccept({ ...topupAccepts[0], extra: { credits: 1000000 } }), 400, "extra.credits can never exceed the paid value");
50
- assert.strictEqual(topupUnitsForAccept({ ...topupAccepts[0], extra: { credits: 100 } }), 100, "extra.credits may lower the grant");
51
- if (previousTestnet === undefined) delete process.env.XYTARA_X402_TESTNET_TOPUP; else process.env.XYTARA_X402_TESTNET_TOPUP = previousTestnet;
52
-
53
- // Pure policy: credit-spend accrual basis.
54
- const quote = { amount_minor: 40, currency: "USD_CENTS" };
55
- const creditBasis = reconcileProviderSettlementAmount(quote, {
56
- verification_mode: "account_credits",
57
- payment_payload: { credit_spend_id: "cs_1", credit_units: 8, credit_unit_price_atomic: 2500 }
58
- });
59
- assert.strictEqual(creditBasis.settlement_basis, "credits_unit_value_min_quote");
60
- assert.strictEqual(creditBasis.amount_minor, 2, "8 credits x $0.0025 = 2 cents accrue, not the 40-cent quote");
61
-
62
- const OP = "buyer-safety-operator-token";
63
- const BRIDGE = "buyer-safety-bridge-token";
64
- const previous = {
65
- exec: process.env.XYTARA_PAID_EXECUTION_POLICY,
66
- credit: process.env.XYTARA_CREDIT_SPEND_POLICY,
67
- op: process.env.XYTARA_ACCOUNT_AUTH_BEARER_TOKEN,
68
- bridge: process.env.XYTARA_CREDIT_BRIDGE_BEARER_TOKEN,
69
- mode: process.env.XYTARA_PAYMENT_VERIFICATION_MODE,
70
- accepts: process.env.XYTARA_X402_ACCEPTS_JSON,
71
- targets: process.env.XYTARA_EXECUTION_TARGETS_JSON
72
- };
73
- process.env.XYTARA_PAID_EXECUTION_POLICY = "strict";
74
- process.env.XYTARA_CREDIT_SPEND_POLICY = "strict";
75
- process.env.XYTARA_ACCOUNT_AUTH_BEARER_TOKEN = OP;
76
- process.env.XYTARA_CREDIT_BRIDGE_BEARER_TOKEN = BRIDGE;
77
- process.env.XYTARA_PAYMENT_VERIFICATION_MODE = "x402_facilitator";
78
- process.env.XYTARA_X402_ACCEPTS_JSON = JSON.stringify(ACCEPTS);
79
- // One operator-pinned target makes exactly one task executable (no network call happens before 402).
80
- process.env.XYTARA_EXECUTION_TARGETS_JSON = JSON.stringify([
81
- { target_id: "safety_target", task_ref: "adapter.mcp.invoke", endpoint_url: "http://127.0.0.1:9/execute" }
82
- ]);
83
-
84
- delete require.cache[require.resolve("../server")];
85
- const { createServer } = require("../server");
86
- const server = createServer();
87
- await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve));
88
- const baseUrl = `http://127.0.0.1:${server.address().port}`;
89
- try {
90
- // 1. A catalog task with no execution target: refused before any payment is requested.
91
- const notExecutable = await post(baseUrl, "/x402/commands/execute", { task_ref: "trust.verify", body: { subject_id: "s-1" } });
92
- assert.strictEqual(notExecutable.status, 501, "non-executable task must be refused, not quoted");
93
- assert.strictEqual(notExecutable.json.reason, "capability_not_executable");
94
- assert.ok(notExecutable.json.executable_task_refs.includes("adapter.mcp.invoke"), "the refusal lists what IS executable");
95
-
96
- // 2. Unknown task and missing task_ref.
97
- const unknown = await post(baseUrl, "/x402/commands/execute", { task_ref: "nope.task" });
98
- assert.strictEqual(unknown.status, 501, "unknown task must not be payable");
99
- const missing = await post(baseUrl, "/x402/commands/execute", {});
100
- assert.strictEqual(missing.status, 400, "missing task_ref must be a 400");
101
- assert.strictEqual(missing.json.reason, "task_ref_required");
102
-
103
- // 3. An executable task still gets the normal x402 challenge.
104
- const executable = await post(baseUrl, "/x402/commands/execute", { task_ref: "adapter.mcp.invoke", body: { tool_name: "keccak256", arguments: { data: "abc" } } });
105
- assert.strictEqual(executable.status, 402, "executable task must be quoted for payment");
106
-
107
- // 4. Credits: a bare account_id can't spend, even with a balance.
108
- const account = "acct_safety_owner";
109
- const grant = await post(baseUrl, "/v1/credit-bridge/grants", { account_id: account, units: 50, source: "verify" }, { authorization: `Bearer ${BRIDGE}` });
110
- assert.strictEqual(grant.status, 200, "operator grant must succeed");
111
- const creditBody = { task_ref: "adapter.mcp.invoke", account_id: account, payment_preference: "credits_first", body: { tool_name: "keccak256", arguments: { data: "abc" } } };
112
- const theft = await post(baseUrl, "/v1/commands/execute", creditBody);
113
- assert.strictEqual(theft.status, 401, "spending another account's credits without its credential must be refused");
114
- assert.strictEqual(theft.json.reason, "credit_spend_credential_required");
115
-
116
- // 5. The account's own spend credential clears the credit gate (it then reaches execution,
117
- // which fails here because the pinned target is unreachable — and no credits are consumed).
118
- const created = await post(baseUrl, "/v1/account-auth/spend-credentials", { account_id: account }, { authorization: `Bearer ${OP}` });
119
- const cred = (created.json && created.json.spend_credential) || created.json;
120
- assert.ok(cred && cred.bearer_token, "spend credential created");
121
- const owned = await post(baseUrl, "/v1/commands/execute", creditBody, { authorization: `Bearer ${cred.bearer_token}` });
122
- assert.notStrictEqual(owned.status, 401, "the owner's credential must clear the credit gate");
123
- assert.strictEqual(owned.json && owned.json.credit_spend_status, "not_committed", "a failed execution must not consume credits");
124
-
125
- // 6. A credential for one account can't be aimed at another.
126
- const misaimed = await post(baseUrl, "/v1/commands/execute", { ...creditBody, account_id: "acct_someone_else" }, { authorization: `Bearer ${cred.bearer_token}` });
127
- assert.strictEqual(misaimed.status, 403, "credential pinned to its own account");
128
-
129
- console.log("xytara verify:buyer-safety passed");
130
- } finally {
131
- await new Promise((resolve) => server.close(resolve));
132
- for (const [key, env] of [["exec", "XYTARA_PAID_EXECUTION_POLICY"], ["credit", "XYTARA_CREDIT_SPEND_POLICY"], ["op", "XYTARA_ACCOUNT_AUTH_BEARER_TOKEN"], ["bridge", "XYTARA_CREDIT_BRIDGE_BEARER_TOKEN"], ["mode", "XYTARA_PAYMENT_VERIFICATION_MODE"], ["accepts", "XYTARA_X402_ACCEPTS_JSON"], ["targets", "XYTARA_EXECUTION_TARGETS_JSON"]]) {
133
- if (previous[key] === undefined) delete process.env[env]; else process.env[env] = previous[key];
134
- }
135
- }
136
- }
137
-
138
- main().catch((error) => {
139
- console.error(error && error.stack ? error.stack : error);
140
- process.exit(1);
141
- });
@@ -1,110 +0,0 @@
1
- "use strict";
2
-
3
- // Verifies the Coinbase CDP auth path for the x402 facilitator client: when a CDP Secret
4
- // API Key is configured, the client must mint a fresh, valid EdDSA Bearer JWT per request
5
- // (CDP rejects static tokens). A mock facilitator stands in for CDP and cryptographically
6
- // verifies the token's signature and claims before accepting the call. No real network/chain.
7
-
8
- const assert = require("assert");
9
- const http = require("http");
10
- const crypto = require("crypto");
11
-
12
- const { createFacilitatorClient } = require("../lib/x402_facilitator");
13
- const { loadPaymentConfig } = require("../lib/payment_config");
14
-
15
- // A throwaway Ed25519 key, exported as the base64 64-byte (seed||public) secret CDP uses.
16
- function makeCdpKey() {
17
- const { publicKey, privateKey } = crypto.generateKeyPairSync("ed25519");
18
- const seed = privateKey.export({ format: "der", type: "pkcs8" }).subarray(16); // last 32 bytes
19
- const pub = publicKey.export({ format: "der", type: "spki" }).subarray(12); // last 32 bytes
20
- return { publicKey, keySecret: Buffer.concat([seed, pub]).toString("base64") };
21
- }
22
-
23
- function startCdpMock(expectedPublicKey, seen) {
24
- const server = http.createServer((req, res) => {
25
- const chunks = [];
26
- req.on("data", (c) => chunks.push(c));
27
- req.on("end", () => {
28
- const reply = (code, payload) => {
29
- const text = JSON.stringify(payload);
30
- res.writeHead(code, { "content-type": "application/json", "content-length": Buffer.byteLength(text) });
31
- res.end(text);
32
- };
33
- const auth = String((req.headers.authorization || ""));
34
- if (!auth.startsWith("Bearer ")) return reply(401, { error: "missing_bearer" });
35
- const token = auth.slice("Bearer ".length);
36
- const parts = token.split(".");
37
- if (parts.length !== 3) return reply(401, { error: "malformed_jwt" });
38
- const header = JSON.parse(Buffer.from(parts[0], "base64").toString("utf8"));
39
- const claims = JSON.parse(Buffer.from(parts[1], "base64").toString("utf8"));
40
- const sig = Buffer.from(parts[2].replace(/-/g, "+").replace(/_/g, "/"), "base64");
41
- const signatureValid = crypto.verify(null, Buffer.from(`${parts[0]}.${parts[1]}`), expectedPublicKey, sig);
42
- // Record what the facilitator observed so the test can assert on it.
43
- seen.push({ header, claims, signatureValid, path: req.url, nonce: header.nonce });
44
- if (header.alg !== "EdDSA") return reply(401, { error: "bad_alg" });
45
- if (!signatureValid) return reply(401, { error: "bad_signature" });
46
- if (claims.iss !== "cdp") return reply(401, { error: "bad_iss" });
47
- if (!Array.isArray(claims.aud) || claims.aud[0] !== "cdp_service") return reply(401, { error: "bad_aud" });
48
- const now = Math.floor(Date.now() / 1000);
49
- if (!(claims.exp > now && claims.exp - claims.nbf <= 120)) return reply(401, { error: "bad_exp" });
50
- if (!(claims.uri.startsWith("POST 127.0.0.1:") && claims.uri.endsWith(req.url))) return reply(401, { error: "bad_uri", uri: claims.uri });
51
- if (req.url === "/verify") return reply(200, { isValid: true, payer: "0x2222222222222222222222222222222222222222" });
52
- if (req.url === "/settle") return reply(200, { success: true, transaction: "0xcdpmocktx", network: "eip155:8453" });
53
- return reply(404, { error: "not_found" });
54
- });
55
- });
56
- return new Promise((resolve) => server.listen(0, "127.0.0.1", () => resolve({ server, port: server.address().port })));
57
- }
58
-
59
- const PAYLOAD = { x402Version: 2, accepted: { scheme: "exact" }, payload: { signature: "ok", authorization: {} } };
60
- const REQS = { scheme: "exact", network: "eip155:8453", asset: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", amount: "10000", payTo: "0xabc", resource: "https://x/y" };
61
-
62
- async function main() {
63
- const { publicKey, keySecret } = makeCdpKey();
64
- const seen = [];
65
- const mock = await startCdpMock(publicKey, seen);
66
- const baseUrl = `http://127.0.0.1:${mock.port}`;
67
-
68
- try {
69
- // 1. Config loader picks up the CDP env into config.x402.cdp.
70
- const prev = { id: process.env.XYTARA_X402_CDP_KEY_ID, sec: process.env.XYTARA_X402_CDP_KEY_SECRET };
71
- process.env.XYTARA_X402_CDP_KEY_ID = "11111111-2222-3333-4444-555555555555";
72
- process.env.XYTARA_X402_CDP_KEY_SECRET = keySecret;
73
- const cfg = loadPaymentConfig();
74
- assert.ok(cfg.x402.cdp && cfg.x402.cdp.key_id === "11111111-2222-3333-4444-555555555555", "config must load CDP key id");
75
- assert.strictEqual(cfg.x402.cdp.key_secret, keySecret, "config must load CDP key secret");
76
-
77
- // 2. The client attaches a valid per-request Bearer that the mock CDP accepts.
78
- const client = createFacilitatorClient({ url: baseUrl, cdp: cfg.x402.cdp, timeoutMs: 5000 });
79
- const verify = await client.verify(PAYLOAD, REQS);
80
- assert.strictEqual(verify.ok, true, "verify must succeed with a valid CDP Bearer");
81
- assert.strictEqual(verify.json.isValid, true, "mock CDP must accept the token on /verify");
82
- const settle = await client.settle(PAYLOAD, REQS);
83
- assert.strictEqual(settle.ok, true, "settle must succeed with a valid CDP Bearer");
84
- assert.strictEqual(settle.json.transaction, "0xcdpmocktx", "settle must return the mock tx");
85
-
86
- // 3. Each request minted its own token (fresh nonce), signature valid, uri bound to the path.
87
- assert.strictEqual(seen.length, 2, "mock must have seen two authenticated calls");
88
- assert.ok(seen.every((e) => e.signatureValid), "every token signature must verify");
89
- assert.notStrictEqual(seen[0].nonce, seen[1].nonce, "each request must mint a fresh token (distinct nonce)");
90
- assert.ok(seen[0].claims.uri.endsWith("/verify") && seen[1].claims.uri.endsWith("/settle"), "uri claim must bind to each request path");
91
-
92
- // 4. Without CDP creds, no Authorization header is sent (static-facilitator path unaffected).
93
- const seen2 = [];
94
- const mock2 = await startCdpMock(publicKey, seen2);
95
- const plainClient = createFacilitatorClient({ url: `http://127.0.0.1:${mock2.port}`, timeoutMs: 5000 });
96
- const plain = await plainClient.verify(PAYLOAD, REQS);
97
- assert.strictEqual(plain.status, 401, "without CDP creds the mock sees no Bearer and rejects");
98
- assert.strictEqual(seen2.length, 0, "no JWT should be minted when CDP is not configured");
99
- await new Promise((r) => mock2.server.close(r));
100
-
101
- if (prev.id === undefined) delete process.env.XYTARA_X402_CDP_KEY_ID; else process.env.XYTARA_X402_CDP_KEY_ID = prev.id;
102
- if (prev.sec === undefined) delete process.env.XYTARA_X402_CDP_KEY_SECRET; else process.env.XYTARA_X402_CDP_KEY_SECRET = prev.sec;
103
-
104
- console.log("xytara verify:cdp-facilitator passed");
105
- } finally {
106
- await new Promise((r) => mock.server.close(r));
107
- }
108
- }
109
-
110
- main().catch((e) => { console.error(e && e.message ? e.message : e); process.exitCode = 1; });
@@ -1,109 +0,0 @@
1
- "use strict";
2
-
3
- // Verifies the provider-agnostic hosted-checkout processor adapter
4
- // (lib/checkout_processor_adapter.js). Offline: no network, no real Stripe
5
- // calls. Exercises config gating, webhook signature verify (round-trip),
6
- // event->grant mapping, and the not-configured safety behavior.
7
-
8
- const assert = require("assert");
9
-
10
- function withEnv(env, fn) {
11
- const saved = {};
12
- for (const k in env) {
13
- saved[k] = process.env[k];
14
- if (env[k] === undefined) delete process.env[k];
15
- else process.env[k] = env[k];
16
- }
17
- // Re-require fresh so env is read on load.
18
- delete require.cache[require.resolve("../lib/checkout_processor_adapter")];
19
- const mod = require("../lib/checkout_processor_adapter");
20
- try {
21
- return fn(mod);
22
- } finally {
23
- for (const k in saved) {
24
- if (saved[k] === undefined) delete process.env[k];
25
- else process.env[k] = saved[k];
26
- }
27
- delete require.cache[require.resolve("../lib/checkout_processor_adapter")];
28
- }
29
- }
30
-
31
- async function main() {
32
- // 1. Not configured => provider null, everything degrades safely.
33
- await withEnv({ XYTARA_CHECKOUT_PROCESSOR: undefined }, async (m) => {
34
- const cfg = m.loadCheckoutProcessorConfig();
35
- assert.strictEqual(cfg.provider, null);
36
- assert.strictEqual(m.isConfigured(cfg), false);
37
- const s = await m.createProcessorCheckoutSession(cfg, { amountMinor: 100 });
38
- assert.strictEqual(s.ok, false);
39
- assert.strictEqual(s.reason, "processor_not_configured");
40
- assert.strictEqual(m.verifyProcessorWebhook(cfg, {}, "{}").ok, false);
41
- assert.strictEqual(m.mapProcessorEventToGrant(cfg, { type: "checkout.session.completed" }), null);
42
- });
43
-
44
- // 2. Stripe configured => webhook verify round-trip + event mapping.
45
- await withEnv(
46
- { XYTARA_CHECKOUT_PROCESSOR: "stripe", STRIPE_SECRET_KEY: "sk_test_x", STRIPE_WEBHOOK_SECRET: "whsec_test" },
47
- async (m) => {
48
- const cfg = m.loadCheckoutProcessorConfig();
49
- assert.strictEqual(cfg.provider, "stripe");
50
- assert.strictEqual(m.isConfigured(cfg), true);
51
-
52
- const event = {
53
- id: "evt_1",
54
- type: "checkout.session.completed",
55
- data: {
56
- object: {
57
- id: "cs_1",
58
- payment_status: "paid",
59
- payment_intent: "pi_1",
60
- amount_total: 500,
61
- currency: "usd",
62
- metadata: { account_id: "acct_x", credits_units: "1000", purchase_intent_id: "pi_intent_1" }
63
- }
64
- }
65
- };
66
- const raw = JSON.stringify(event);
67
- const sig = m.buildStripeSignatureHeader(cfg.webhookSecret, raw);
68
-
69
- // Valid signature -> ok + parsed event.
70
- const okRes = m.verifyProcessorWebhook(cfg, { "Stripe-Signature": sig }, raw);
71
- assert.strictEqual(okRes.ok, true);
72
- assert.strictEqual(okRes.event.id, "evt_1");
73
-
74
- // Tampered body -> invalid.
75
- assert.strictEqual(m.verifyProcessorWebhook(cfg, { "Stripe-Signature": sig }, raw + " ").ok, false);
76
- // Missing signature header -> malformed.
77
- assert.strictEqual(m.verifyProcessorWebhook(cfg, {}, raw).reason, "stripe_signature_malformed");
78
- // Stale timestamp -> out of tolerance.
79
- const oldSig = m.buildStripeSignatureHeader(cfg.webhookSecret, raw, Math.floor(Date.now() / 1000) - 99999);
80
- assert.strictEqual(m.verifyProcessorWebhook(cfg, { "Stripe-Signature": oldSig }, raw).reason, "stripe_timestamp_out_of_tolerance");
81
-
82
- // Event -> grant mapping.
83
- const grant = m.mapProcessorEventToGrant(cfg, event);
84
- assert.strictEqual(grant.account_id, "acct_x");
85
- assert.strictEqual(grant.units, 1000);
86
- assert.strictEqual(grant.source, "stripe");
87
- assert.strictEqual(grant.provider_reference, "pi_1");
88
- assert.strictEqual(grant.idempotency_key, "stripe:evt_1");
89
- assert.strictEqual(grant.purchase_intent_id, "pi_intent_1");
90
-
91
- // Non-paid / wrong-type events -> null.
92
- assert.strictEqual(m.mapProcessorEventToGrant(cfg, { type: "checkout.session.completed", data: { object: { payment_status: "unpaid" } } }), null);
93
- assert.strictEqual(m.mapProcessorEventToGrant(cfg, { type: "payment_intent.created", data: { object: {} } }), null);
94
-
95
- // Session creation missing secret key -> explicit reason (no network).
96
- const noKeyCfg = Object.assign({}, cfg, { secretKey: "" });
97
- const s = await m.createProcessorCheckoutSession(noKeyCfg, { amountMinor: 500, currency: "usd", successUrl: "https://x", cancelUrl: "https://y" });
98
- assert.strictEqual(s.ok, false);
99
- assert.strictEqual(s.reason, "stripe_secret_key_missing");
100
- }
101
- );
102
-
103
- console.log("verify_checkout_processor: all hosted-checkout processor adapter checks passed");
104
- }
105
-
106
- main().catch((error) => {
107
- console.error("verify_checkout_processor failed:", error && error.message ? error.message : error);
108
- process.exitCode = 1;
109
- });