xytara 3.1.13 → 3.1.14

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 (55) hide show
  1. package/.env.example +8 -1
  2. package/BSV_TERANODE_PLATFORM_DISCONTINUITY_RUNBOOK.md +126 -126
  3. package/RELEASE_NOTES.md +6 -4
  4. package/lib/a2a_rpc.js +280 -280
  5. package/lib/account_auth.js +585 -585
  6. package/lib/agent_identity.js +162 -162
  7. package/lib/bolt_adapter.js +187 -187
  8. package/lib/bolt_payment_front.js +224 -224
  9. package/lib/checkout_processor_adapter.js +217 -217
  10. package/lib/command_flow.js +722 -722
  11. package/lib/commerce_artifacts.js +591 -591
  12. package/lib/commerce_bridge.js +274 -274
  13. package/lib/commerce_cases.js +399 -399
  14. package/lib/commerce_client.js +7694 -7694
  15. package/lib/commerce_quotes.js +29 -0
  16. package/lib/commerce_runtime.js +322 -322
  17. package/lib/execution_dedupe.js +86 -86
  18. package/lib/external_credit_bridge.js +142 -142
  19. package/lib/http_transport.js +81 -81
  20. package/lib/l402_adapter.js +241 -241
  21. package/lib/l402_payment_front.js +265 -265
  22. package/lib/mpp_adapter.js +237 -237
  23. package/lib/payment_config.js +253 -253
  24. package/lib/payment_verification.js +357 -357
  25. package/lib/provider_payout_execution.js +155 -155
  26. package/lib/provider_registry.js +842 -842
  27. package/lib/rate_limiter.js +81 -81
  28. package/lib/runtime_state_store.js +491 -369
  29. package/lib/settlement_bsv_live.js +600 -600
  30. package/lib/settlement_bsv_teranode.js +117 -117
  31. package/lib/stripe_mpp_payment_front.js +258 -258
  32. package/lib/x402_facilitator.js +191 -191
  33. package/package.json +5 -3
  34. package/scripts/state_backup_offsite.js +196 -0
  35. package/scripts/verify_a2a_rpc.js +105 -105
  36. package/scripts/verify_agent_identity.js +153 -153
  37. package/scripts/verify_all.js +1 -1
  38. package/scripts/verify_bolt_adapter.js +128 -128
  39. package/scripts/verify_cdp_facilitator.js +110 -110
  40. package/scripts/verify_checkout_processor.js +109 -109
  41. package/scripts/verify_commerce_bridge.js +177 -177
  42. package/scripts/verify_execution_dedupe.js +189 -189
  43. package/scripts/verify_execution_surfacing.js +76 -76
  44. package/scripts/verify_final_activation.js +191 -191
  45. package/scripts/verify_l402_adapter.js +86 -86
  46. package/scripts/verify_mpp_adapter.js +128 -128
  47. package/scripts/verify_production_readiness.js +268 -268
  48. package/scripts/verify_rate_limiter.js +52 -52
  49. package/scripts/verify_refund_credit.js +106 -106
  50. package/scripts/verify_release_candidate.js +81 -81
  51. package/scripts/verify_runtime_state_guard.js +117 -0
  52. package/scripts/verify_service.js +15421 -15421
  53. package/scripts/verify_verify_execute_settle.js +208 -208
  54. package/scripts/verify_x402_facilitator.js +286 -286
  55. package/server.js +11976 -11974
@@ -1,117 +1,117 @@
1
- "use strict";
2
-
3
- const DEFAULT_BSV_SETTLEMENT_MODE = "bsv_teranode";
4
- const BSV_SETTLEMENT_ALIASES = new Set([
5
- "bsv_teranode"
6
- ]);
7
-
8
- function firstEnv(...names) {
9
- for (const name of names) {
10
- const value = process.env[name];
11
- if (typeof value === "string" && value.trim().length > 0) {
12
- return value.trim();
13
- }
14
- }
15
- return null;
16
- }
17
-
18
- function normalizeSettlementMode(mode) {
19
- const normalized = String(mode || "").trim().toLowerCase();
20
- if (!normalized) return DEFAULT_BSV_SETTLEMENT_MODE;
21
- if (BSV_SETTLEMENT_ALIASES.has(normalized)) return DEFAULT_BSV_SETTLEMENT_MODE;
22
- return normalized;
23
- }
24
-
25
- function isBsvTeranodeSettlementMode(mode) {
26
- return normalizeSettlementMode(mode) === DEFAULT_BSV_SETTLEMENT_MODE;
27
- }
28
-
29
- function loadBsvTeranodeConfig() {
30
- const amountMultiplier = Number(
31
- firstEnv("XYTARA_BSV_SATS_PER_USD_CENT", "XYTARA_BSV_TERANODE_SATS_PER_USD_CENT") || 100
32
- );
33
- return {
34
- settlement_mode: DEFAULT_BSV_SETTLEMENT_MODE,
35
- rail: "bsv_teranode",
36
- network: String(firstEnv("XYTARA_BSV_NETWORK", "XYTARA_BSV_TERANODE_NETWORK") || "mainnet").trim() || "mainnet",
37
- rpc_url: firstEnv("XYTARA_BSV_ARC_RPC_URL", "XYTARA_BSV_ARC_URL", "XYTARA_BSV_TERANODE_RPC_URL"),
38
- mode: String(firstEnv("XYTARA_BSV_MODE", "XYTARA_BSV_TERANODE_MODE") || "opreturn").trim() || "opreturn",
39
- merchant_address: firstEnv("XYTARA_BSV_MERCHANT_ADDRESS", "XYTARA_BSV_TERANODE_MERCHANT_ADDRESS"),
40
- merchant_paymail: firstEnv("XYTARA_BSV_MERCHANT_PAYMAIL", "XYTARA_BSV_TERANODE_MERCHANT_PAYMAIL"),
41
- merchant_label: String(firstEnv("XYTARA_BSV_MERCHANT_LABEL", "XYTARA_BSV_TERANODE_MERCHANT_LABEL") || "naxytra-runtime").trim() || "naxytra-runtime",
42
- use_metanet: String(firstEnv("XYTARA_BSV_USE_METANET", "XYTARA_BSV_TERANODE_USE_METANET") || "").trim().toLowerCase() === "true",
43
- required_confirmations: Math.max(0, Number(firstEnv("XYTARA_BSV_REQUIRED_CONFIRMATIONS", "XYTARA_BSV_TERANODE_REQUIRED_CONFIRMATIONS") || 1)) || 1,
44
- sats_per_usd_cent: Number.isFinite(amountMultiplier) && amountMultiplier > 0 ? amountMultiplier : 100
45
- };
46
- }
47
-
48
- function buildBsvTeranodeTreasuryDestination(accountId, settlementMode) {
49
- if (!isBsvTeranodeSettlementMode(settlementMode)) return null;
50
- const config = loadBsvTeranodeConfig();
51
- const externalRef = config.merchant_address || config.merchant_paymail || null;
52
- if (!externalRef) return null;
53
- const kind = config.merchant_address ? "bsv_teranode_address" : "bsv_teranode_paymail";
54
- return {
55
- destination_id: config.merchant_address
56
- ? `bsv_teranode_${config.merchant_address}`
57
- : `bsv_teranode_${config.merchant_paymail.replace(/[^a-z0-9]+/gi, "_").toLowerCase()}`,
58
- destination_kind: kind,
59
- account_id: accountId || null,
60
- settlement_mode: DEFAULT_BSV_SETTLEMENT_MODE,
61
- external_ref: externalRef,
62
- rail: config.rail,
63
- network: config.network
64
- };
65
- }
66
-
67
- function buildBsvTeranodeSettlementHints({
68
- settlementMode,
69
- amountMinor,
70
- currency,
71
- settlementBindingHash,
72
- treasuryDestination
73
- }) {
74
- if (!isBsvTeranodeSettlementMode(settlementMode)) return null;
75
- const config = loadBsvTeranodeConfig();
76
- return {
77
- rail: config.rail,
78
- settlement_mode: DEFAULT_BSV_SETTLEMENT_MODE,
79
- network: config.network,
80
- mode: config.mode,
81
- amount_satoshis: Math.max(1, Number(amountMinor || 0) * config.sats_per_usd_cent),
82
- amount_minor: Number(amountMinor || 0),
83
- currency: currency || "USD_CENTS",
84
- merchant_address: config.merchant_address,
85
- merchant_paymail: config.merchant_paymail,
86
- merchant_label: config.merchant_label,
87
- settlement_reference: settlementBindingHash || null,
88
- treasury_destination_id:
89
- treasuryDestination && treasuryDestination.destination_id
90
- ? treasuryDestination.destination_id
91
- : null,
92
- custody_external_ref:
93
- treasuryDestination && treasuryDestination.external_ref
94
- ? treasuryDestination.external_ref
95
- : null,
96
- metanet_enabled: config.use_metanet,
97
- required_confirmations: config.required_confirmations,
98
- teranode_rpc_configured: !!config.rpc_url
99
- };
100
- }
101
-
102
- function extractBsvTeranodePaymentReference(paymentPayload) {
103
- if (!paymentPayload || typeof paymentPayload !== "object") return null;
104
- if (paymentPayload.bsv_teranode && typeof paymentPayload.bsv_teranode === "object") {
105
- return paymentPayload.bsv_teranode;
106
- }
107
- return null;
108
- }
109
-
110
- module.exports = {
111
- buildBsvTeranodeSettlementHints,
112
- buildBsvTeranodeTreasuryDestination,
113
- extractBsvTeranodePaymentReference,
114
- isBsvTeranodeSettlementMode,
115
- loadBsvTeranodeConfig,
116
- normalizeSettlementMode
117
- };
1
+ "use strict";
2
+
3
+ const DEFAULT_BSV_SETTLEMENT_MODE = "bsv_teranode";
4
+ const BSV_SETTLEMENT_ALIASES = new Set([
5
+ "bsv_teranode"
6
+ ]);
7
+
8
+ function firstEnv(...names) {
9
+ for (const name of names) {
10
+ const value = process.env[name];
11
+ if (typeof value === "string" && value.trim().length > 0) {
12
+ return value.trim();
13
+ }
14
+ }
15
+ return null;
16
+ }
17
+
18
+ function normalizeSettlementMode(mode) {
19
+ const normalized = String(mode || "").trim().toLowerCase();
20
+ if (!normalized) return DEFAULT_BSV_SETTLEMENT_MODE;
21
+ if (BSV_SETTLEMENT_ALIASES.has(normalized)) return DEFAULT_BSV_SETTLEMENT_MODE;
22
+ return normalized;
23
+ }
24
+
25
+ function isBsvTeranodeSettlementMode(mode) {
26
+ return normalizeSettlementMode(mode) === DEFAULT_BSV_SETTLEMENT_MODE;
27
+ }
28
+
29
+ function loadBsvTeranodeConfig() {
30
+ const amountMultiplier = Number(
31
+ firstEnv("XYTARA_BSV_SATS_PER_USD_CENT", "XYTARA_BSV_TERANODE_SATS_PER_USD_CENT") || 100
32
+ );
33
+ return {
34
+ settlement_mode: DEFAULT_BSV_SETTLEMENT_MODE,
35
+ rail: "bsv_teranode",
36
+ network: String(firstEnv("XYTARA_BSV_NETWORK", "XYTARA_BSV_TERANODE_NETWORK") || "mainnet").trim() || "mainnet",
37
+ rpc_url: firstEnv("XYTARA_BSV_ARC_RPC_URL", "XYTARA_BSV_ARC_URL", "XYTARA_BSV_TERANODE_RPC_URL"),
38
+ mode: String(firstEnv("XYTARA_BSV_MODE", "XYTARA_BSV_TERANODE_MODE") || "opreturn").trim() || "opreturn",
39
+ merchant_address: firstEnv("XYTARA_BSV_MERCHANT_ADDRESS", "XYTARA_BSV_TERANODE_MERCHANT_ADDRESS"),
40
+ merchant_paymail: firstEnv("XYTARA_BSV_MERCHANT_PAYMAIL", "XYTARA_BSV_TERANODE_MERCHANT_PAYMAIL"),
41
+ merchant_label: String(firstEnv("XYTARA_BSV_MERCHANT_LABEL", "XYTARA_BSV_TERANODE_MERCHANT_LABEL") || "naxytra-runtime").trim() || "naxytra-runtime",
42
+ use_metanet: String(firstEnv("XYTARA_BSV_USE_METANET", "XYTARA_BSV_TERANODE_USE_METANET") || "").trim().toLowerCase() === "true",
43
+ required_confirmations: Math.max(0, Number(firstEnv("XYTARA_BSV_REQUIRED_CONFIRMATIONS", "XYTARA_BSV_TERANODE_REQUIRED_CONFIRMATIONS") || 1)) || 1,
44
+ sats_per_usd_cent: Number.isFinite(amountMultiplier) && amountMultiplier > 0 ? amountMultiplier : 100
45
+ };
46
+ }
47
+
48
+ function buildBsvTeranodeTreasuryDestination(accountId, settlementMode) {
49
+ if (!isBsvTeranodeSettlementMode(settlementMode)) return null;
50
+ const config = loadBsvTeranodeConfig();
51
+ const externalRef = config.merchant_address || config.merchant_paymail || null;
52
+ if (!externalRef) return null;
53
+ const kind = config.merchant_address ? "bsv_teranode_address" : "bsv_teranode_paymail";
54
+ return {
55
+ destination_id: config.merchant_address
56
+ ? `bsv_teranode_${config.merchant_address}`
57
+ : `bsv_teranode_${config.merchant_paymail.replace(/[^a-z0-9]+/gi, "_").toLowerCase()}`,
58
+ destination_kind: kind,
59
+ account_id: accountId || null,
60
+ settlement_mode: DEFAULT_BSV_SETTLEMENT_MODE,
61
+ external_ref: externalRef,
62
+ rail: config.rail,
63
+ network: config.network
64
+ };
65
+ }
66
+
67
+ function buildBsvTeranodeSettlementHints({
68
+ settlementMode,
69
+ amountMinor,
70
+ currency,
71
+ settlementBindingHash,
72
+ treasuryDestination
73
+ }) {
74
+ if (!isBsvTeranodeSettlementMode(settlementMode)) return null;
75
+ const config = loadBsvTeranodeConfig();
76
+ return {
77
+ rail: config.rail,
78
+ settlement_mode: DEFAULT_BSV_SETTLEMENT_MODE,
79
+ network: config.network,
80
+ mode: config.mode,
81
+ amount_satoshis: Math.max(1, Number(amountMinor || 0) * config.sats_per_usd_cent),
82
+ amount_minor: Number(amountMinor || 0),
83
+ currency: currency || "USD_CENTS",
84
+ merchant_address: config.merchant_address,
85
+ merchant_paymail: config.merchant_paymail,
86
+ merchant_label: config.merchant_label,
87
+ settlement_reference: settlementBindingHash || null,
88
+ treasury_destination_id:
89
+ treasuryDestination && treasuryDestination.destination_id
90
+ ? treasuryDestination.destination_id
91
+ : null,
92
+ custody_external_ref:
93
+ treasuryDestination && treasuryDestination.external_ref
94
+ ? treasuryDestination.external_ref
95
+ : null,
96
+ metanet_enabled: config.use_metanet,
97
+ required_confirmations: config.required_confirmations,
98
+ teranode_rpc_configured: !!config.rpc_url
99
+ };
100
+ }
101
+
102
+ function extractBsvTeranodePaymentReference(paymentPayload) {
103
+ if (!paymentPayload || typeof paymentPayload !== "object") return null;
104
+ if (paymentPayload.bsv_teranode && typeof paymentPayload.bsv_teranode === "object") {
105
+ return paymentPayload.bsv_teranode;
106
+ }
107
+ return null;
108
+ }
109
+
110
+ module.exports = {
111
+ buildBsvTeranodeSettlementHints,
112
+ buildBsvTeranodeTreasuryDestination,
113
+ extractBsvTeranodePaymentReference,
114
+ isBsvTeranodeSettlementMode,
115
+ loadBsvTeranodeConfig,
116
+ normalizeSettlementMode
117
+ };