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,75 +0,0 @@
1
- "use strict";
2
-
3
- const {
4
- buildPhase7EventSystemPack,
5
- summarizePhase7EventSystemPack
6
- } = require("./phase_7_event_system_pack");
7
- const {
8
- buildPhase7NatsRuntimePack,
9
- summarizePhase7NatsRuntimePack
10
- } = require("./phase_7_nats_runtime_pack");
11
-
12
- function buildEventSystemLanePack() {
13
- const phasePack = buildPhase7EventSystemPack();
14
- const natsPack = buildPhase7NatsRuntimePack();
15
- return {
16
- product: "xytara",
17
- category: "machine-commerce-event-system-lane-pack",
18
- pack_version: "xytara-event-system-lane-pack-v1",
19
- lane_state: "first_party_event_system_family_present",
20
- posture: "event_and_system_integration_runtime_lane",
21
- phase_alignment: {
22
- phase_ref: phasePack.phase_ref,
23
- phase_pack: phasePack,
24
- phase_summary: summarizePhase7EventSystemPack(),
25
- featured_lane: {
26
- pack: natsPack,
27
- summary: summarizePhase7NatsRuntimePack()
28
- }
29
- },
30
- supported_surfaces: {
31
- phase_summary_ref: "/v1/phases/phase-7/summary",
32
- nats_runtime_summary_ref: "/v1/phases/phase-7/nats/summary",
33
- kafka_runtime_summary_ref: "/v1/phases/phase-7/kafka/summary",
34
- mqtt_runtime_summary_ref: "/v1/phases/phase-7/mqtt/summary",
35
- webhook_runtime_summary_ref: "/v1/phases/phase-7/webhook-event-bus/summary",
36
- continuity_summary_ref: "/v1/phases/phase-7/event-system-continuity/summary",
37
- asyncapi_ref: "/asyncapi.json",
38
- cloudevents_ref: "/cloudevents.json"
39
- },
40
- first_run_flows: [
41
- {
42
- flow_ref: "nats_subject_mesh_runtime",
43
- recommended_reason: "best first durable event/system lane for subject-oriented machine coordination with NATS plus JetStream-style persistence posture",
44
- sequence: [
45
- "inspect_event_system_lane_summary",
46
- "inspect_nats_runtime_summary",
47
- "inspect_asyncapi_and_cloudevents_contracts",
48
- "choose_broker_or_callback_family_for_the_integration"
49
- ]
50
- }
51
- ],
52
- guardrails: [
53
- "event-system lanes extend runtime coordination rather than replace the default transaction flow",
54
- "nats and jetstream style durability should improve integration fit without widening the public runtime core into a generic bus platform"
55
- ]
56
- };
57
- }
58
-
59
- function summarizeEventSystemLanePack() {
60
- const pack = buildEventSystemLanePack();
61
- return {
62
- product: "xytara",
63
- category: "machine-commerce-event-system-lane-pack-summary",
64
- summary_version: "xytara-event-system-lane-pack-summary-v1",
65
- lane_state: pack.lane_state,
66
- posture: pack.posture,
67
- first_run_flow_count: pack.first_run_flows.length,
68
- linked_surfaces: pack.supported_surfaces
69
- };
70
- }
71
-
72
- module.exports = {
73
- buildEventSystemLanePack,
74
- summarizeEventSystemLanePack
75
- };
@@ -1,86 +0,0 @@
1
- "use strict";
2
-
3
- // Concurrency guard for the deferred (x402) verify -> execute -> settle path.
4
- //
5
- // Deferring settlement until after execution opened a narrow window: two in-flight
6
- // requests carrying the SAME signed EIP-3009 authorization (a genuine replay, or two
7
- // concurrent copies of one request) would both pass verification and both EXECUTE the
8
- // external target before the second /settle fails on the now-spent on-chain nonce. No
9
- // double-CHARGE can occur (the on-chain nonce is single-use), but the external work —
10
- // which may be billable, side-effecting seller cost — would run twice.
11
- //
12
- // This guard reserves an in-flight slot keyed on the authorization so a duplicate is
13
- // rejected with 409 BEFORE it executes. It is deliberately minimal:
14
- // - it guards only the in-flight window (a post-success replay is already rejected
15
- // upstream: the facilitator's verify simulates the transfer and a spent nonce
16
- // reverts, so a consumed authorization never reaches execution again);
17
- // - it FAILS OPEN — if the store is missing it allows the request, because wrongly
18
- // blocking a paid request is worse than a rare duplicate execution, and the
19
- // on-chain nonce still guarantees no double-charge;
20
- // - slots carry a TTL well beyond the EIP-3009 window and are pruned on each claim,
21
- // so a crash mid-execution cannot wedge an authorization permanently.
22
-
23
- const DEDUPE_TTL_MS = 180000; // ~3x the ~60s EIP-3009 authorization validity window
24
-
25
- // The globally-unique fingerprint of a deferred x402 authorization: the signer address
26
- // plus the 32-byte EIP-3009 nonce. Returns null for anything we do not defer (native,
27
- // credits, L402/BOLT/MPP) or if the nonce is absent — callers treat null as "nothing to
28
- // dedupe".
29
- function deferredAuthorizationKey(verification) {
30
- const deferred = verification && verification.deferred_settlement;
31
- if (!deferred || deferred.protocol !== "x402_facilitator") return null;
32
- const paymentPayload = deferred.authorization && deferred.authorization.paymentPayload;
33
- const auth = paymentPayload && paymentPayload.payload && paymentPayload.payload.authorization;
34
- if (!auth) return null;
35
- const nonce = typeof auth.nonce === "string" ? auth.nonce.trim().toLowerCase() : "";
36
- if (!nonce) return null;
37
- const from = typeof auth.from === "string" ? auth.from.trim().toLowerCase() : "";
38
- return `x402:${from}:${nonce}`;
39
- }
40
-
41
- function pruneExpired(store, now) {
42
- for (const [key, entry] of store) {
43
- const expiresAt = entry && Number.isFinite(entry.expires_at) ? entry.expires_at : 0;
44
- if (expiresAt <= now) store.delete(key);
45
- }
46
- }
47
-
48
- // Reserve an execution slot for a deferred x402 authorization. Returns
49
- // { ok:true, key } on a fresh claim (key is null when there is nothing to dedupe, which
50
- // is still a success), or { ok:false, status:409, reason, detail } when the same
51
- // authorization is already executing. The check-and-set is synchronous (no await
52
- // between get and set), so two concurrent requests cannot both claim the same key.
53
- function claimDeferredExecution(state, verification) {
54
- const key = deferredAuthorizationKey(verification);
55
- if (!key) return { ok: true, key: null };
56
- const store = state && state.inFlightPaymentAuthorizations instanceof Map ? state.inFlightPaymentAuthorizations : null;
57
- if (!store) return { ok: true, key: null }; // fail open; on-chain nonce still prevents double-charge
58
- const now = Date.now();
59
- pruneExpired(store, now);
60
- if (store.has(key)) {
61
- return {
62
- ok: false,
63
- status: 409,
64
- reason: "payment_authorization_in_progress",
65
- detail: "a command for this x402 authorization is already executing; wait for it or sign a fresh authorization"
66
- };
67
- }
68
- store.set(key, { status: "in_flight", claimed_at: now, expires_at: now + DEDUPE_TTL_MS });
69
- return { ok: true, key };
70
- }
71
-
72
- // Release a reserved slot once execution+settlement has resolved (success or failure).
73
- // Always removes the slot so a legitimate retry with the same still-unspent nonce can
74
- // proceed; a replay of an already-settled nonce is stopped upstream at verify.
75
- function releaseDeferredExecution(state, key) {
76
- if (!key) return;
77
- const store = state && state.inFlightPaymentAuthorizations instanceof Map ? state.inFlightPaymentAuthorizations : null;
78
- if (store) store.delete(key);
79
- }
80
-
81
- module.exports = {
82
- DEDUPE_TTL_MS,
83
- claimDeferredExecution,
84
- deferredAuthorizationKey,
85
- releaseDeferredExecution
86
- };
@@ -1,234 +0,0 @@
1
- "use strict";
2
-
3
- const packageJson = require("../package.json");
4
- const { summarizeCapabilityExecutionTruthBundle } = require("./capability_execution_truth");
5
- const { summarizeLifecycleContinuityPack } = require("./lifecycle_continuity_contract");
6
- const { summarizeDeliveryState } = require("./delivery_summary_contract");
7
- const { summarizeRevenueLaunchPathPack } = require("./revenue_launch_path_contract");
8
- const { summarizeProviderRuntimeJourneyPack } = require("./provider_runtime_journey_contract");
9
-
10
- function buildExecutionTruthModelPack() {
11
- const capabilityExecutionTruth = summarizeCapabilityExecutionTruthBundle();
12
- const lifecycleContinuity = summarizeLifecycleContinuityPack();
13
- const deliverySummary = summarizeDeliveryState();
14
- const revenueLaunchPathSummary = summarizeRevenueLaunchPathPack();
15
- const providerJourneySummary = summarizeProviderRuntimeJourneyPack();
16
-
17
- return {
18
- ok: true,
19
- product: packageJson.name,
20
- category: "machine-commerce-execution-truth-model",
21
- pack_version: "xytara-execution-truth-model-v1",
22
- coined_standard: {
23
- id: "XT1",
24
- name: "xytara execution truth standard",
25
- version: "xt1/v1",
26
- role: "canonical_runtime_side_execution_transcript_and_fact_spine",
27
- boundary: "xt1_names_the_xytara_runtime_truth_standard_without_claiming_xoonya_proof_validity_or_external_chain_truth"
28
- },
29
- doctrine: "xytara_owns_hot_state_execution_truth_and_emits_proof_compatible_facts_without_collapsing_into_xoonya_proof_semantics",
30
- model_state: "frozen_for_3_0_0_closeout",
31
- core_claim: "XT1 is the canonical xytara runtime-side fact model linking quote, payment, execution, delivery, settlement, and proof handoff",
32
- canonical_objects: [
33
- {
34
- object_id: "quote",
35
- role: "priced_pre_execution_offer",
36
- required_fields: [
37
- "quote_id",
38
- "account_id",
39
- "amount_minor",
40
- "currency",
41
- "capabilities",
42
- "adapters",
43
- "settlement_mode"
44
- ],
45
- primary_surfaces: ["/v1/payment-quotes", "/v1/payment-quotes/:quote_id"]
46
- },
47
- {
48
- object_id: "transaction",
49
- role: "hot_state_execution_record",
50
- required_fields: [
51
- "transaction_id",
52
- "account_id",
53
- "status",
54
- "quote_id",
55
- "payment",
56
- "settlement",
57
- "treasury",
58
- "default_path",
59
- "execution",
60
- "timing",
61
- "remediation"
62
- ],
63
- primary_surfaces: ["/v1/transactions", "/v1/transactions/:transaction_id"]
64
- },
65
- {
66
- object_id: "receipt",
67
- role: "runtime_completion_record_with_proof_pointer",
68
- required_fields: [
69
- "receipt_id",
70
- "transaction_id",
71
- "status",
72
- "payment",
73
- "settlement",
74
- "treasury",
75
- "default_path",
76
- "proof_ref",
77
- "execution_summary",
78
- "timing",
79
- "remediation"
80
- ],
81
- primary_surfaces: ["/v1/receipts", "/v1/receipts/:receipt_id"]
82
- },
83
- {
84
- object_id: "delivery",
85
- role: "deliverable_and_callback_state_record",
86
- required_fields: [
87
- "delivery_id",
88
- "transaction_id",
89
- "receipt_id",
90
- "status",
91
- "output_ref",
92
- "proof_ref",
93
- "delivery_target_kind"
94
- ],
95
- primary_surfaces: ["/v1/deliveries", "/v1/deliveries/:delivery_id"]
96
- },
97
- {
98
- object_id: "settlement",
99
- role: "external_finality_and_reconciliation_binding",
100
- required_fields: [
101
- "settlement_id",
102
- "mode",
103
- "adapter",
104
- "binding_hash",
105
- "status"
106
- ],
107
- primary_surfaces: ["/v1/settlement/bsv-teranode", "/v1/settlement/bsv-teranode/:settlement_id"]
108
- },
109
- {
110
- object_id: "proof_handoff",
111
- role: "xytara_to_xoonya_followthrough_boundary",
112
- required_fields: [
113
- "receipt.proof_ref",
114
- "receipt.execution_summary",
115
- "transaction.execution.results_by_task_id",
116
- "delivery.proof_ref"
117
- ],
118
- primary_surfaces: [
119
- "/v1/transaction-center/result-packages/export",
120
- "https://xoonya.onrender.com/v1/proof-center/result-package-handoff/run"
121
- ]
122
- }
123
- ],
124
- layer_model: [
125
- {
126
- layer_id: "priced_intent",
127
- order_index: 1,
128
- objects: ["quote"],
129
- invariants: [
130
- "quote_must_exist_before_irreversible_paid_execution",
131
- "quote_must_bind_amount_currency_and_settlement_posture"
132
- ]
133
- },
134
- {
135
- layer_id: "runtime_execution",
136
- order_index: 2,
137
- objects: ["transaction"],
138
- invariants: [
139
- "transaction_is_the_primary_hot_state_execution_record",
140
- "execution_success_and_settlement_finality_must_remain_distinct"
141
- ]
142
- },
143
- {
144
- layer_id: "runtime_completion",
145
- order_index: 3,
146
- objects: ["receipt"],
147
- invariants: [
148
- "receipt_carries_execution_summary_and_proof_pointer",
149
- "receipt_must_not_redefine_xoonya_proof_validity"
150
- ]
151
- },
152
- {
153
- layer_id: "deliverable_state",
154
- order_index: 4,
155
- objects: ["delivery"],
156
- invariants: [
157
- "delivery_tracks_where_the_result_went",
158
- "callback_state_is_runtime_truth_not_external_proof_semantics"
159
- ]
160
- },
161
- {
162
- layer_id: "settlement_and_treasury",
163
- order_index: 5,
164
- objects: ["settlement"],
165
- invariants: [
166
- "settlement_records_external_finality_posture_without_becoming_execution_truth",
167
- "treasury_and_settlement_must_stay_reconcilable_from_runtime_artifacts"
168
- ]
169
- },
170
- {
171
- layer_id: "proof_followthrough",
172
- order_index: 6,
173
- objects: ["proof_handoff"],
174
- invariants: [
175
- "xytara_emits_proof_compatible_facts_and_handoff_refs",
176
- "xoonya_owns_proof_semantics_and_verification_truth"
177
- ]
178
- }
179
- ],
180
- execution_truth_invariants: [
181
- "quote_precedes_paid_execution",
182
- "transaction_is_the_canonical_hot_state_execution_record",
183
- "receipt_is_the_runtime_completion_record_not_the_proof_core",
184
- "delivery_truth_and_callback_truth_remain_first_class_runtime_artifacts",
185
- "settlement_truth_is_linked_but_not_collapsed_into_execution_success",
186
- "treasury_consequence_remains_reconstructible_from_runtime_artifacts",
187
- "xytara_emits_proof_compatible_facts_without_redefining_xoonya_proof_semantics"
188
- ],
189
- linked_summaries: {
190
- capability_execution_truth: capabilityExecutionTruth,
191
- lifecycle_continuity: lifecycleContinuity,
192
- delivery_summary: deliverySummary,
193
- revenue_launch_path_summary: revenueLaunchPathSummary,
194
- provider_runtime_journey_summary: providerJourneySummary
195
- },
196
- linked_surfaces: {
197
- xt1_ref: "/v1/xt1",
198
- xt1_summary_ref: "/v1/xt1/summary",
199
- capability_execution_truth_ref: "/v1/capability-registry/execution-truth",
200
- execution_truth_ref: "/v1/execution-truth",
201
- execution_truth_summary_ref: "/v1/execution-truth/summary",
202
- lifecycle_continuity_ref: "/v1/lifecycle-continuity",
203
- deliveries_ref: "/v1/deliveries",
204
- revenue_launch_paths_ref: "/v1/revenue-launch/paths",
205
- providers_journeys_ref: "/v1/providers/journeys",
206
- result_package_export_ref: "/v1/transaction-center/result-packages/export",
207
- xoonya_result_package_handoff_ref: "https://xoonya.onrender.com/v1/proof-center/result-package-handoff/run"
208
- },
209
- claim_boundary: "claim_the_runtime_side_fact_model_and_handoff_boundary_only_without_claiming_xoonya_proof_validity_or_external_chain_truth_inside_xytara"
210
- };
211
- }
212
-
213
- function summarizeExecutionTruthModelPack() {
214
- const pack = buildExecutionTruthModelPack();
215
- return {
216
- ok: true,
217
- product: pack.product,
218
- category: pack.category,
219
- summary_version: "xytara-execution-truth-model-summary-v1",
220
- pack_version: pack.pack_version,
221
- coined_standard_id: pack.coined_standard.id,
222
- coined_standard_version: pack.coined_standard.version,
223
- model_state: pack.model_state,
224
- canonical_object_count: pack.canonical_objects.length,
225
- layer_count: pack.layer_model.length,
226
- invariant_count: pack.execution_truth_invariants.length,
227
- linked_surfaces: pack.linked_surfaces
228
- };
229
- }
230
-
231
- module.exports = {
232
- buildExecutionTruthModelPack,
233
- summarizeExecutionTruthModelPack
234
- };
@@ -1,142 +0,0 @@
1
- "use strict";
2
-
3
- const { applyRailCredits, upsertEntitlementPool } = require("./commerce_economics");
4
- const { findCreditPack } = require("../fixtures/catalog");
5
-
6
- function normalizeString(value, fallback) {
7
- const trimmed = typeof value === "string" ? value.trim() : "";
8
- return trimmed || fallback || null;
9
- }
10
-
11
- function ensureObject(value) {
12
- return value && typeof value === "object" && !Array.isArray(value) ? value : {};
13
- }
14
-
15
- function nowIso() {
16
- return new Date().toISOString();
17
- }
18
-
19
- function listExternalCreditGrants(state, accountId) {
20
- const grants = Array.from(state.externalCreditGrants.values());
21
- if (!accountId) return grants;
22
- return grants.filter((grant) => grant && grant.account_id === accountId);
23
- }
24
-
25
- function getExternalCreditGrant(state, grantId) {
26
- return state.externalCreditGrants.get(grantId) || null;
27
- }
28
-
29
- function findExternalCreditGrantByIdempotencyKey(state, idempotencyKey) {
30
- if (!idempotencyKey) return null;
31
- return Array.from(state.externalCreditGrants.values()).find((grant) => grant && grant.idempotency_key === idempotencyKey) || null;
32
- }
33
-
34
- function createExternalCreditGrant(state, body) {
35
- const payload = ensureObject(body);
36
- const grantId = normalizeString(payload.grant_id, null);
37
- const idempotencyKey = normalizeString(payload.idempotency_key, null);
38
-
39
- if (grantId && state.externalCreditGrants.has(grantId)) {
40
- return state.externalCreditGrants.get(grantId);
41
- }
42
- const existingByIdempotency = findExternalCreditGrantByIdempotencyKey(state, idempotencyKey);
43
- if (existingByIdempotency) {
44
- return existingByIdempotency;
45
- }
46
-
47
- const createdAt = nowIso();
48
- const nextGrantId = grantId || `external_credit_grant_${state.externalCreditGrants.size + 1}`;
49
- const accountId = normalizeString(payload.account_id, "acct_demo");
50
- const packId = normalizeString(payload.pack_id, normalizeString(payload.package_id, null));
51
- const creditPack = packId ? findCreditPack(packId) : null;
52
- if (packId && !creditPack) {
53
- return {
54
- ok: false,
55
- reason: "credit_pack_not_found",
56
- pack_id: packId
57
- };
58
- }
59
- const units = Number.isFinite(Number(payload.units))
60
- ? Number(payload.units)
61
- : creditPack
62
- ? Number(creditPack.issued_units || 0)
63
- : 0;
64
- const amountMinor = Number.isFinite(Number(payload.amount_minor))
65
- ? Number(payload.amount_minor)
66
- : creditPack && Number.isFinite(Number(creditPack.nominal_amount_minor))
67
- ? Number(creditPack.nominal_amount_minor)
68
- : null;
69
- const currency = normalizeString(
70
- payload.currency,
71
- creditPack
72
- ? normalizeString(creditPack.nominal_currency, amountMinor != null ? "USD" : null)
73
- : amountMinor != null
74
- ? "USD"
75
- : null
76
- );
77
- const source = normalizeString(payload.source, "external_checkout");
78
- const providerReference = normalizeString(payload.provider_reference, null);
79
- const purchaseReference = normalizeString(payload.purchase_reference, null);
80
- const metadata = ensureObject(payload.metadata);
81
- const creditEventId = normalizeString(payload.credit_event_id, `credit_${nextGrantId}`);
82
-
83
- const creditEvent = applyRailCredits(state, {
84
- account_id: accountId,
85
- credit_event_id: creditEventId,
86
- rail_kind: normalizeString(payload.rail_kind, "external_checkout_bridge"),
87
- units,
88
- amount_minor: amountMinor,
89
- currency,
90
- provider_reference: providerReference,
91
- reason: normalizeString(payload.reason, "external_credit_grant"),
92
- metadata: {
93
- source,
94
- purchase_reference: purchaseReference,
95
- pack_id: packId,
96
- ...metadata
97
- }
98
- });
99
-
100
- const grant = {
101
- grant_id: nextGrantId,
102
- account_id: accountId,
103
- units,
104
- amount_minor: amountMinor,
105
- currency,
106
- source,
107
- provider_reference: providerReference,
108
- purchase_reference: purchaseReference,
109
- pack_id: packId,
110
- credit_pack: creditPack ? {
111
- pack_id: creditPack.pack_id,
112
- title: creditPack.title,
113
- category: creditPack.category,
114
- intended_usage_posture: creditPack.intended_usage_posture
115
- } : null,
116
- idempotency_key: idempotencyKey || nextGrantId,
117
- metadata,
118
- entitlement_id: normalizeString(payload.entitlement_id, `entitlement_${nextGrantId}`),
119
- credit_event_id: creditEvent.credit_event_id,
120
- credit_event: creditEvent,
121
- status: "recorded",
122
- created_at_iso: createdAt,
123
- updated_at_iso: createdAt
124
- };
125
-
126
- grant.entitlement = upsertEntitlementPool(state, {
127
- entitlement_id: grant.entitlement_id,
128
- account_id: accountId,
129
- pack_id: packId,
130
- source_ref: grant.grant_id,
131
- issued_units: units
132
- });
133
-
134
- state.externalCreditGrants.set(grant.grant_id, grant);
135
- return grant;
136
- }
137
-
138
- module.exports = {
139
- createExternalCreditGrant,
140
- getExternalCreditGrant,
141
- listExternalCreditGrants
142
- };
@@ -1,143 +0,0 @@
1
- "use strict";
2
-
3
- const dns = require("dns").promises;
4
- const net = require("net");
5
-
6
- // Upper bound on a single provider call. The x402 (EIP-3009) authorization a buyer signs is valid
7
- // for roughly a minute, so a provider allowed to run longer than this could do real work for a
8
- // payment that then fails to settle (nobody pays). Applies to env targets and registered providers.
9
- const MAX_TARGET_TIMEOUT_MS = 30000;
10
- const DEFAULT_TARGET_TIMEOUT_MS = 10000;
11
- const MIN_TARGET_TIMEOUT_MS = 500;
12
-
13
- // Total wall-clock budget for ONE buyer call across cold-start ride-out retries AND failover
14
- // candidates, shared so three candidates can never each consume a full window. Kept inside the
15
- // x402 settlement window (~60s) with headroom for the settle call itself.
16
- const DEFAULT_EXECUTION_BUDGET_MS = 50000;
17
- const MAX_EXECUTION_BUDGET_MS = 55000;
18
-
19
- function clampTargetTimeoutMs(value) {
20
- const n = Number(value || DEFAULT_TARGET_TIMEOUT_MS) || DEFAULT_TARGET_TIMEOUT_MS;
21
- return Math.min(MAX_TARGET_TIMEOUT_MS, Math.max(MIN_TARGET_TIMEOUT_MS, Math.round(n)));
22
- }
23
-
24
- function externalExecutionBudgetMs() {
25
- const raw = process.env.XYTARA_EXTERNAL_EXECUTION_BUDGET_MS;
26
- if (raw === undefined || raw === "") return DEFAULT_EXECUTION_BUDGET_MS;
27
- const n = Number(raw);
28
- if (!Number.isFinite(n) || n <= 0) return DEFAULT_EXECUTION_BUDGET_MS;
29
- return Math.min(MAX_EXECUTION_BUDGET_MS, Math.max(1000, Math.round(n)));
30
- }
31
-
32
- // Endpoint policy. "strict" (default on a hosted deploy, i.e. when RENDER is set) requires https
33
- // and refuses endpoints at loopback / private / link-local / metadata addresses, so a registered
34
- // provider cannot turn the runtime into a request proxy into its own network (SSRF). "permissive"
35
- // (default locally) keeps http://127.0.0.1-style endpoints usable for tests and development.
36
- function endpointPolicyMode() {
37
- const raw = String(process.env.XYTARA_PROVIDER_ENDPOINT_POLICY || "").trim().toLowerCase();
38
- if (raw === "strict" || raw === "permissive") return raw;
39
- return process.env.RENDER ? "strict" : "permissive";
40
- }
41
-
42
- function isPrivateIp(ip) {
43
- const family = net.isIP(ip);
44
- if (family === 4) {
45
- const p = ip.split(".").map(Number);
46
- if (p[0] === 10 || p[0] === 127 || p[0] === 0) return true;
47
- if (p[0] === 169 && p[1] === 254) return true; // link-local + cloud metadata
48
- if (p[0] === 172 && p[1] >= 16 && p[1] <= 31) return true;
49
- if (p[0] === 192 && p[1] === 168) return true;
50
- if (p[0] === 100 && p[1] >= 64 && p[1] <= 127) return true; // carrier-grade NAT
51
- if (p[0] >= 224) return true; // multicast / reserved / broadcast
52
- return false;
53
- }
54
- if (family === 6) {
55
- const lower = ip.toLowerCase();
56
- if (lower === "::" || lower === "::1") return true;
57
- if (lower.startsWith("fe80:") || lower.startsWith("fc") || lower.startsWith("fd")) return true; // link-local, ULA
58
- if (lower.startsWith("::ffff:")) return isPrivateIp(lower.slice(7)); // v4-mapped
59
- if (lower.startsWith("ff")) return true; // multicast
60
- return false;
61
- }
62
- return false;
63
- }
64
-
65
- function isBlockedHostname(hostname) {
66
- const h = String(hostname || "").toLowerCase().replace(/\.$/, "");
67
- if (!h || h === "localhost" || h.endsWith(".localhost")) return true;
68
- if (h.endsWith(".local") || h.endsWith(".internal") || h.endsWith(".localdomain")) return true;
69
- if (h === "metadata" || h === "metadata.google.internal") return true;
70
- return false;
71
- }
72
-
73
- function hostOf(parsedUrl) {
74
- return String(parsedUrl.hostname || "").replace(/^\[|\]$/g, "");
75
- }
76
-
77
- // Synchronous shape check (used at registration): protocol + literal-host rules. No DNS here.
78
- function checkEndpointUrlShape(endpointUrl) {
79
- const policy = endpointPolicyMode();
80
- let parsed;
81
- try {
82
- parsed = new URL(String(endpointUrl || ""));
83
- } catch (_) {
84
- return { ok: false, reason: "endpoint_url_invalid", policy };
85
- }
86
- if (parsed.username || parsed.password) {
87
- return { ok: false, reason: "endpoint_url_credentials_not_allowed", policy };
88
- }
89
- if (policy !== "strict") return { ok: true, policy };
90
- if (parsed.protocol !== "https:") {
91
- return { ok: false, reason: "endpoint_url_insecure", detail: "https:// is required for provider endpoints", policy };
92
- }
93
- const host = hostOf(parsed);
94
- if (isBlockedHostname(host) || (net.isIP(host) && isPrivateIp(host))) {
95
- return { ok: false, reason: "endpoint_url_not_public", detail: "loopback, private, link-local and metadata hosts are refused", policy };
96
- }
97
- return { ok: true, policy };
98
- }
99
-
100
- // Dispatch-time check: re-validates the shape AND resolves the host, refusing any address in a
101
- // private range (defeats DNS rebinding to an internal address after registration). Results are
102
- // cached briefly so the hot path adds at most one lookup per host per minute.
103
- const resolveCache = new Map();
104
- const RESOLVE_CACHE_TTL_MS = 60000;
105
-
106
- async function checkEndpointBeforeDispatch(endpointUrl) {
107
- const shape = checkEndpointUrlShape(endpointUrl);
108
- if (!shape.ok || shape.policy !== "strict") return shape;
109
- let host;
110
- try {
111
- host = hostOf(new URL(String(endpointUrl)));
112
- } catch (_) {
113
- return { ok: false, reason: "endpoint_url_invalid", policy: shape.policy };
114
- }
115
- if (net.isIP(host)) return shape; // literal already checked above
116
- const cached = resolveCache.get(host);
117
- if (cached && cached.expires_at > Date.now()) return cached.result;
118
- let result;
119
- try {
120
- const addresses = await dns.lookup(host, { all: true, verbatim: true });
121
- const bad = addresses.find((entry) => isPrivateIp(entry.address));
122
- result = bad
123
- ? { ok: false, reason: "endpoint_url_not_public", detail: "endpoint resolves to a non-public address", policy: shape.policy }
124
- : { ok: true, policy: shape.policy };
125
- } catch (_) {
126
- // Unresolvable host: let the fetch surface ENOTFOUND (a not-processed, failover-safe signal).
127
- result = { ok: true, policy: shape.policy, unresolved: true };
128
- }
129
- resolveCache.set(host, { result, expires_at: Date.now() + RESOLVE_CACHE_TTL_MS });
130
- return result;
131
- }
132
-
133
- module.exports = {
134
- MAX_TARGET_TIMEOUT_MS,
135
- DEFAULT_TARGET_TIMEOUT_MS,
136
- DEFAULT_EXECUTION_BUDGET_MS,
137
- clampTargetTimeoutMs,
138
- externalExecutionBudgetMs,
139
- endpointPolicyMode,
140
- isPrivateIp,
141
- checkEndpointUrlShape,
142
- checkEndpointBeforeDispatch
143
- };