@agentcash/router 1.10.1 → 1.10.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -57,7 +57,7 @@ The recommended entry point reads its config from `process.env`. A copy-paste `.
57
57
  |-----|----------|---------|
58
58
  | `MPP_SECRET_KEY` | when MPP is enabled | Server-side MPP secret. Presence toggles MPP on. |
59
59
  | `MPP_CURRENCY` | when MPP is enabled | Tempo currency address. Use `TEMPO_USDC_ADDRESS` for Tempo USDC. |
60
- | `TEMPO_RPC_URL` | when MPP is enabled | Authenticated Tempo JSON-RPC endpoint. Public `rpc.tempo.xyz` returns 401. |
60
+ | `TEMPO_RPC_URL` | no | Tempo JSON-RPC endpoint for MPP on-chain verification. Defaults to the public `DEFAULT_TEMPO_RPC_URL` (`https://rpc.tempo.xyz`). Override only if you have a dedicated endpoint. |
61
61
  | `MPP_OPERATOR_KEY` | no | Signs server-side close/settle. When set, MPP session mode is enabled automatically (required for `.metered()`: both streaming and request-mode per-tick billing). Address must equal the payee. |
62
62
  | `MPP_FEE_PAYER_KEY` | no | Sponsors client gas for channel open/topUp. Must resolve to a different address than `MPP_OPERATOR_KEY` (Tempo rejects fee-delegated txs where `sender === feePayer`). |
63
63
 
package/dist/index.cjs CHANGED
@@ -31,7 +31,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
31
31
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
32
 
33
33
  // src/constants.ts
34
- var BASE_MAINNET_NETWORK, SOLANA_MAINNET_NETWORK, TEMPO_USDC_ADDRESS, TEMPO_USDC_DECIMALS, BASE_USDC_ADDRESS, BASE_USDC_DECIMALS, ZERO_EVM_ADDRESS, DEFAULT_SOLANA_FACILITATOR_URL;
34
+ var BASE_MAINNET_NETWORK, SOLANA_MAINNET_NETWORK, TEMPO_USDC_ADDRESS, TEMPO_USDC_DECIMALS, BASE_USDC_ADDRESS, BASE_USDC_DECIMALS, ZERO_EVM_ADDRESS, DEFAULT_SOLANA_FACILITATOR_URL, DEFAULT_TEMPO_RPC_URL;
35
35
  var init_constants = __esm({
36
36
  "src/constants.ts"() {
37
37
  "use strict";
@@ -43,6 +43,7 @@ var init_constants = __esm({
43
43
  BASE_USDC_DECIMALS = 6;
44
44
  ZERO_EVM_ADDRESS = "0x0000000000000000000000000000000000000000";
45
45
  DEFAULT_SOLANA_FACILITATOR_URL = "https://facilitator.corbits.dev";
46
+ DEFAULT_TEMPO_RPC_URL = "https://rpc.tempo.xyz";
46
47
  }
47
48
  });
48
49
 
@@ -412,7 +413,7 @@ async function createX402Server(config, kvStore) {
412
413
  const { x402ResourceServer, HTTPFacilitatorClient } = await import("@x402/core/server");
413
414
  const { registerExactEvmScheme } = await import("@x402/evm/exact/server");
414
415
  const { bazaarResourceServerExtension } = await import("@x402/extensions/bazaar");
415
- const { siwxResourceServerExtension } = await import("@x402/extensions/sign-in-with-x");
416
+ const { createSIWxResourceServerExtension, InMemorySIWxStorage } = await import("@x402/extensions/sign-in-with-x");
416
417
  const { facilitator: defaultFacilitator } = await import("@coinbase/x402");
417
418
  const configuredNetworks = getConfiguredX402Networks(config);
418
419
  const facilitatorsByNetwork = getResolvedX402Facilitators(
@@ -442,7 +443,9 @@ async function createX402Server(config, kvStore) {
442
443
  registerExactSvmScheme(server, { networks: svmNetworks });
443
444
  }
444
445
  server.registerExtension(bazaarResourceServerExtension);
445
- server.registerExtension(siwxResourceServerExtension);
446
+ server.registerExtension(
447
+ createSIWxResourceServerExtension({ storage: new InMemorySIWxStorage() })
448
+ );
446
449
  const initPromise = server.initialize();
447
450
  return {
448
451
  server,
@@ -468,6 +471,7 @@ __export(index_exports, {
468
471
  BASE_USDC_ADDRESS: () => BASE_USDC_ADDRESS,
469
472
  BASE_USDC_DECIMALS: () => BASE_USDC_DECIMALS,
470
473
  DEFAULT_SOLANA_FACILITATOR_URL: () => DEFAULT_SOLANA_FACILITATOR_URL,
474
+ DEFAULT_TEMPO_RPC_URL: () => DEFAULT_TEMPO_RPC_URL,
471
475
  HttpError: () => HttpError,
472
476
  RouterConfigError: () => RouterConfigError,
473
477
  SOLANA_MAINNET_NETWORK: () => SOLANA_MAINNET_NETWORK,
@@ -1572,7 +1576,7 @@ async function verifyHashMode(args, info) {
1572
1576
  }
1573
1577
  if (chargeResult.status === 402) {
1574
1578
  const reason = await readChallengeReason(chargeResult.challenge);
1575
- const detail = reason || "credential may be invalid, or check TEMPO_RPC_URL configuration";
1579
+ const detail = reason || "credential may be invalid, or check your TEMPO_RPC_URL endpoint";
1576
1580
  report("warn", `MPP credential rejected: ${detail}`);
1577
1581
  return { ok: false, kind: "invalid" };
1578
1582
  }
@@ -4462,7 +4466,7 @@ var envShape = {
4462
4466
  }).optional(),
4463
4467
  TEMPO_RPC_URL: import_zod.z.string().refine(isUrl, {
4464
4468
  params: { code: "invalid_mpp_rpc_url", ...mpp },
4465
- message: "TEMPO_RPC_URL must be a valid URL \u2014 authenticated Tempo JSON-RPC endpoint. Public rpc.tempo.xyz returns 401."
4469
+ message: "TEMPO_RPC_URL must be a valid URL \u2014 the Tempo JSON-RPC endpoint used for MPP on-chain verification. Optional; defaults to the public DEFAULT_TEMPO_RPC_URL."
4466
4470
  }).optional(),
4467
4471
  MPP_OPERATOR_KEY: import_zod.z.string().refine(isEvmPrivateKey, {
4468
4472
  params: { code: "invalid_mpp_operator_key", ...mpp },
@@ -4503,14 +4507,6 @@ var EnvInputSchema = import_zod.z.object(envShape).passthrough().superRefine((en
4503
4507
  ["MPP_CURRENCY"]
4504
4508
  );
4505
4509
  }
4506
- if (env.TEMPO_RPC_URL === void 0) {
4507
- addIssue(
4508
- ctx,
4509
- { code: "missing_mpp_rpc_url", ...mpp },
4510
- "TEMPO_RPC_URL is required when MPP is enabled \u2014 authenticated Tempo JSON-RPC endpoint. Public rpc.tempo.xyz returns 401.",
4511
- ["TEMPO_RPC_URL"]
4512
- );
4513
- }
4514
4510
  }
4515
4511
  const collision = operatorAddressesCollide(env.MPP_OPERATOR_KEY, env.MPP_FEE_PAYER_KEY);
4516
4512
  if (collision) {
@@ -4642,7 +4638,7 @@ function validateX402Config(config, env) {
4642
4638
  }
4643
4639
  return issues;
4644
4640
  }
4645
- function validateMppConfig(config, env) {
4641
+ function validateMppConfig(config) {
4646
4642
  const m = config.mpp;
4647
4643
  if (!m) {
4648
4644
  return [
@@ -4690,12 +4686,6 @@ function validateMppConfig(config, env) {
4690
4686
  `MPP recipient '${placeholder}' is a placeholder address and cannot receive payments.`
4691
4687
  );
4692
4688
  }
4693
- if (!m.rpcUrl && !env.TEMPO_RPC_URL) {
4694
- push(
4695
- "missing_mpp_rpc_url",
4696
- "MPP requires an authenticated Tempo RPC URL. Set TEMPO_RPC_URL env var or pass rpcUrl in the mpp config object."
4697
- );
4698
- }
4699
4689
  if (m.feePayerKey && !isEvmPrivateKey(m.feePayerKey)) {
4700
4690
  push(
4701
4691
  "invalid_mpp_fee_payer_key",
@@ -4802,7 +4792,7 @@ function routerConfigFromEnv(options) {
4802
4792
  const mppConfig = mppEnabled ? {
4803
4793
  secretKey: env.MPP_SECRET_KEY,
4804
4794
  currency: canonicalizeEvm(env.MPP_CURRENCY),
4805
- rpcUrl: env.TEMPO_RPC_URL,
4795
+ rpcUrl: env.TEMPO_RPC_URL ?? DEFAULT_TEMPO_RPC_URL,
4806
4796
  recipient: payeeAddress,
4807
4797
  ...env.MPP_FEE_PAYER_KEY ? { feePayerKey: env.MPP_FEE_PAYER_KEY } : {},
4808
4798
  ...env.MPP_OPERATOR_KEY ? { operatorKey: env.MPP_OPERATOR_KEY, session: {} } : {}
@@ -4853,7 +4843,7 @@ function getRouterConfigIssues(config, options = {}) {
4853
4843
  });
4854
4844
  }
4855
4845
  if (protocols.includes("x402")) issues.push(...validateX402Config(config, env));
4856
- if (protocols.includes("mpp")) issues.push(...validateMppConfig(config, env));
4846
+ if (protocols.includes("mpp")) issues.push(...validateMppConfig(config));
4857
4847
  return issues;
4858
4848
  }
4859
4849
 
@@ -4925,6 +4915,7 @@ function getMppxStreamingContext(args) {
4925
4915
  }
4926
4916
 
4927
4917
  // src/init/mpp.ts
4918
+ init_constants();
4928
4919
  async function initMpp(config, resolvedBaseUrl, kvStore, configError) {
4929
4920
  if (configError) return { initError: configError };
4930
4921
  if (!config.mpp) return {};
@@ -4933,7 +4924,7 @@ async function initMpp(config, resolvedBaseUrl, kvStore, configError) {
4933
4924
  const { createClient, http } = await import("viem");
4934
4925
  const { tempo: tempoChain } = await import("viem/chains");
4935
4926
  const { privateKeyToAccount: privateKeyToAccount2 } = await import("viem/accounts");
4936
- const rpcUrl = config.mpp.rpcUrl ?? process.env.TEMPO_RPC_URL;
4927
+ const rpcUrl = config.mpp.rpcUrl ?? process.env.TEMPO_RPC_URL ?? DEFAULT_TEMPO_RPC_URL;
4937
4928
  const tempoClient = createClient({ chain: tempoChain, transport: http(rpcUrl) });
4938
4929
  const getClient = async () => tempoClient;
4939
4930
  const operatorAccount = config.mpp.operatorKey ? privateKeyToAccount2(config.mpp.operatorKey) : void 0;
@@ -5111,6 +5102,7 @@ function createRouterFromEnv(options) {
5111
5102
  BASE_USDC_ADDRESS,
5112
5103
  BASE_USDC_DECIMALS,
5113
5104
  DEFAULT_SOLANA_FACILITATOR_URL,
5105
+ DEFAULT_TEMPO_RPC_URL,
5114
5106
  HttpError,
5115
5107
  RouterConfigError,
5116
5108
  SOLANA_MAINNET_NETWORK,
package/dist/index.d.cts CHANGED
@@ -411,7 +411,7 @@ interface RouterConfig {
411
411
  currency: string;
412
412
  /** MPP payee address (EVM). Overrides `payeeAddress` for MPP only. Required when `payeeAddress` is unset. MUST equal `operatorKey`'s derived address when `session` is enabled. */
413
413
  recipient?: string;
414
- /** Tempo RPC URL for on-chain verification. Falls back to `TEMPO_RPC_URL`. */
414
+ /** Tempo RPC URL for on-chain verification. Falls back to `TEMPO_RPC_URL`, then to the public `DEFAULT_TEMPO_RPC_URL`. */
415
415
  rpcUrl?: string;
416
416
  /** Hex private key. Signs channel close/settle; required for `session`. Address MUST equal `recipient`/payee — mppx asserts sender===payee on settle. Validated at init. */
417
417
  operatorKey?: string;
@@ -793,7 +793,7 @@ declare class RouteBuilder<TBody = undefined, TQuery = undefined, TOutput = unde
793
793
  private register;
794
794
  }
795
795
 
796
- type RouterConfigIssueCode = 'missing_base_url' | 'invalid_base_url' | 'empty_protocols' | 'missing_x402_accepts' | 'missing_x402_network' | 'unsupported_x402_network' | 'missing_x402_asset' | 'invalid_x402_decimals' | 'missing_x402_payee' | 'invalid_x402_payee' | 'invalid_solana_payee' | 'invalid_solana_facilitator_url' | 'missing_cdp_keys' | 'placeholder_payee' | 'missing_mpp_config' | 'missing_mpp_secret_key' | 'missing_mpp_currency' | 'invalid_mpp_currency' | 'missing_mpp_recipient' | 'invalid_mpp_recipient' | 'missing_mpp_rpc_url' | 'invalid_mpp_rpc_url' | 'invalid_mpp_fee_payer_key' | 'invalid_mpp_operator_key' | 'mpp_operator_equals_fee_payer' | 'mpp_operator_recipient_mismatch' | 'missing_discovery_title' | 'missing_discovery_description' | 'missing_discovery_guidance' | 'invalid_server_url' | 'kv_url_without_token' | 'kv_token_without_url' | 'invalid_kv_url' | 'missing_kv_in_production';
796
+ type RouterConfigIssueCode = 'missing_base_url' | 'invalid_base_url' | 'empty_protocols' | 'missing_x402_accepts' | 'missing_x402_network' | 'unsupported_x402_network' | 'missing_x402_asset' | 'invalid_x402_decimals' | 'missing_x402_payee' | 'invalid_x402_payee' | 'invalid_solana_payee' | 'invalid_solana_facilitator_url' | 'missing_cdp_keys' | 'placeholder_payee' | 'missing_mpp_config' | 'missing_mpp_secret_key' | 'missing_mpp_currency' | 'invalid_mpp_currency' | 'missing_mpp_recipient' | 'invalid_mpp_recipient' | 'invalid_mpp_rpc_url' | 'invalid_mpp_fee_payer_key' | 'invalid_mpp_operator_key' | 'mpp_operator_equals_fee_payer' | 'mpp_operator_recipient_mismatch' | 'missing_discovery_title' | 'missing_discovery_description' | 'missing_discovery_guidance' | 'invalid_server_url' | 'kv_url_without_token' | 'kv_token_without_url' | 'invalid_kv_url' | 'missing_kv_in_production';
797
797
  type RouterConfigIssueSeverity = 'error' | 'warning';
798
798
  interface RouterConfigIssue {
799
799
  code: RouterConfigIssueCode;
@@ -870,6 +870,8 @@ declare const BASE_USDC_DECIMALS = 6;
870
870
  declare const ZERO_EVM_ADDRESS = "0x0000000000000000000000000000000000000000";
871
871
  /** Public Solana x402 facilitator. Override per-deployment via `SOLANA_FACILITATOR_URL`. */
872
872
  declare const DEFAULT_SOLANA_FACILITATOR_URL = "https://facilitator.corbits.dev";
873
+ /** Public Tempo JSON-RPC endpoint used for MPP on-chain verification. Override per-deployment via `TEMPO_RPC_URL`. */
874
+ declare const DEFAULT_TEMPO_RPC_URL = "https://rpc.tempo.xyz";
873
875
 
874
876
  interface MonitorEntry {
875
877
  provider: string;
@@ -912,4 +914,4 @@ declare function createRouter<const P extends Record<string, string> = Record<ne
912
914
  */
913
915
  declare function createRouterFromEnv<const P extends Record<string, string> = Record<never, string>>(options: CreateRouterFromEnvOptions<P>): ServiceRouter<Extract<keyof P, string>>;
914
916
 
915
- export { BASE_MAINNET_NETWORK, BASE_USDC_ADDRESS, BASE_USDC_DECIMALS, type CreateRouterFromEnvOptions, DEFAULT_SOLANA_FACILITATOR_URL, type DiscoveryConfig, type HandlerContext, HttpError, type KvStore, type PaidOptions, type ProtocolType, type RouterConfig, RouterConfigError, type RouterConfigIssue, type RouterConfigIssueCode, type RouterConfigIssueSeverity, type RouterPlugin, SOLANA_MAINNET_NETWORK, type ServiceRouter, type SettlementErrorContext, type SettlementLifecycleContext, type SettlementSettledContext, TEMPO_USDC_ADDRESS, TEMPO_USDC_DECIMALS, type X402FacilitatorsConfig, ZERO_EVM_ADDRESS, createRouter, createRouterFromEnv, routerConfigFromEnv };
917
+ export { BASE_MAINNET_NETWORK, BASE_USDC_ADDRESS, BASE_USDC_DECIMALS, type CreateRouterFromEnvOptions, DEFAULT_SOLANA_FACILITATOR_URL, DEFAULT_TEMPO_RPC_URL, type DiscoveryConfig, type HandlerContext, HttpError, type KvStore, type PaidOptions, type ProtocolType, type RouterConfig, RouterConfigError, type RouterConfigIssue, type RouterConfigIssueCode, type RouterConfigIssueSeverity, type RouterPlugin, SOLANA_MAINNET_NETWORK, type ServiceRouter, type SettlementErrorContext, type SettlementLifecycleContext, type SettlementSettledContext, TEMPO_USDC_ADDRESS, TEMPO_USDC_DECIMALS, type X402FacilitatorsConfig, ZERO_EVM_ADDRESS, createRouter, createRouterFromEnv, routerConfigFromEnv };
package/dist/index.d.ts CHANGED
@@ -411,7 +411,7 @@ interface RouterConfig {
411
411
  currency: string;
412
412
  /** MPP payee address (EVM). Overrides `payeeAddress` for MPP only. Required when `payeeAddress` is unset. MUST equal `operatorKey`'s derived address when `session` is enabled. */
413
413
  recipient?: string;
414
- /** Tempo RPC URL for on-chain verification. Falls back to `TEMPO_RPC_URL`. */
414
+ /** Tempo RPC URL for on-chain verification. Falls back to `TEMPO_RPC_URL`, then to the public `DEFAULT_TEMPO_RPC_URL`. */
415
415
  rpcUrl?: string;
416
416
  /** Hex private key. Signs channel close/settle; required for `session`. Address MUST equal `recipient`/payee — mppx asserts sender===payee on settle. Validated at init. */
417
417
  operatorKey?: string;
@@ -793,7 +793,7 @@ declare class RouteBuilder<TBody = undefined, TQuery = undefined, TOutput = unde
793
793
  private register;
794
794
  }
795
795
 
796
- type RouterConfigIssueCode = 'missing_base_url' | 'invalid_base_url' | 'empty_protocols' | 'missing_x402_accepts' | 'missing_x402_network' | 'unsupported_x402_network' | 'missing_x402_asset' | 'invalid_x402_decimals' | 'missing_x402_payee' | 'invalid_x402_payee' | 'invalid_solana_payee' | 'invalid_solana_facilitator_url' | 'missing_cdp_keys' | 'placeholder_payee' | 'missing_mpp_config' | 'missing_mpp_secret_key' | 'missing_mpp_currency' | 'invalid_mpp_currency' | 'missing_mpp_recipient' | 'invalid_mpp_recipient' | 'missing_mpp_rpc_url' | 'invalid_mpp_rpc_url' | 'invalid_mpp_fee_payer_key' | 'invalid_mpp_operator_key' | 'mpp_operator_equals_fee_payer' | 'mpp_operator_recipient_mismatch' | 'missing_discovery_title' | 'missing_discovery_description' | 'missing_discovery_guidance' | 'invalid_server_url' | 'kv_url_without_token' | 'kv_token_without_url' | 'invalid_kv_url' | 'missing_kv_in_production';
796
+ type RouterConfigIssueCode = 'missing_base_url' | 'invalid_base_url' | 'empty_protocols' | 'missing_x402_accepts' | 'missing_x402_network' | 'unsupported_x402_network' | 'missing_x402_asset' | 'invalid_x402_decimals' | 'missing_x402_payee' | 'invalid_x402_payee' | 'invalid_solana_payee' | 'invalid_solana_facilitator_url' | 'missing_cdp_keys' | 'placeholder_payee' | 'missing_mpp_config' | 'missing_mpp_secret_key' | 'missing_mpp_currency' | 'invalid_mpp_currency' | 'missing_mpp_recipient' | 'invalid_mpp_recipient' | 'invalid_mpp_rpc_url' | 'invalid_mpp_fee_payer_key' | 'invalid_mpp_operator_key' | 'mpp_operator_equals_fee_payer' | 'mpp_operator_recipient_mismatch' | 'missing_discovery_title' | 'missing_discovery_description' | 'missing_discovery_guidance' | 'invalid_server_url' | 'kv_url_without_token' | 'kv_token_without_url' | 'invalid_kv_url' | 'missing_kv_in_production';
797
797
  type RouterConfigIssueSeverity = 'error' | 'warning';
798
798
  interface RouterConfigIssue {
799
799
  code: RouterConfigIssueCode;
@@ -870,6 +870,8 @@ declare const BASE_USDC_DECIMALS = 6;
870
870
  declare const ZERO_EVM_ADDRESS = "0x0000000000000000000000000000000000000000";
871
871
  /** Public Solana x402 facilitator. Override per-deployment via `SOLANA_FACILITATOR_URL`. */
872
872
  declare const DEFAULT_SOLANA_FACILITATOR_URL = "https://facilitator.corbits.dev";
873
+ /** Public Tempo JSON-RPC endpoint used for MPP on-chain verification. Override per-deployment via `TEMPO_RPC_URL`. */
874
+ declare const DEFAULT_TEMPO_RPC_URL = "https://rpc.tempo.xyz";
873
875
 
874
876
  interface MonitorEntry {
875
877
  provider: string;
@@ -912,4 +914,4 @@ declare function createRouter<const P extends Record<string, string> = Record<ne
912
914
  */
913
915
  declare function createRouterFromEnv<const P extends Record<string, string> = Record<never, string>>(options: CreateRouterFromEnvOptions<P>): ServiceRouter<Extract<keyof P, string>>;
914
916
 
915
- export { BASE_MAINNET_NETWORK, BASE_USDC_ADDRESS, BASE_USDC_DECIMALS, type CreateRouterFromEnvOptions, DEFAULT_SOLANA_FACILITATOR_URL, type DiscoveryConfig, type HandlerContext, HttpError, type KvStore, type PaidOptions, type ProtocolType, type RouterConfig, RouterConfigError, type RouterConfigIssue, type RouterConfigIssueCode, type RouterConfigIssueSeverity, type RouterPlugin, SOLANA_MAINNET_NETWORK, type ServiceRouter, type SettlementErrorContext, type SettlementLifecycleContext, type SettlementSettledContext, TEMPO_USDC_ADDRESS, TEMPO_USDC_DECIMALS, type X402FacilitatorsConfig, ZERO_EVM_ADDRESS, createRouter, createRouterFromEnv, routerConfigFromEnv };
917
+ export { BASE_MAINNET_NETWORK, BASE_USDC_ADDRESS, BASE_USDC_DECIMALS, type CreateRouterFromEnvOptions, DEFAULT_SOLANA_FACILITATOR_URL, DEFAULT_TEMPO_RPC_URL, type DiscoveryConfig, type HandlerContext, HttpError, type KvStore, type PaidOptions, type ProtocolType, type RouterConfig, RouterConfigError, type RouterConfigIssue, type RouterConfigIssueCode, type RouterConfigIssueSeverity, type RouterPlugin, SOLANA_MAINNET_NETWORK, type ServiceRouter, type SettlementErrorContext, type SettlementLifecycleContext, type SettlementSettledContext, TEMPO_USDC_ADDRESS, TEMPO_USDC_DECIMALS, type X402FacilitatorsConfig, ZERO_EVM_ADDRESS, createRouter, createRouterFromEnv, routerConfigFromEnv };
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ var __export = (target, all) => {
9
9
  };
10
10
 
11
11
  // src/constants.ts
12
- var BASE_MAINNET_NETWORK, SOLANA_MAINNET_NETWORK, TEMPO_USDC_ADDRESS, TEMPO_USDC_DECIMALS, BASE_USDC_ADDRESS, BASE_USDC_DECIMALS, ZERO_EVM_ADDRESS, DEFAULT_SOLANA_FACILITATOR_URL;
12
+ var BASE_MAINNET_NETWORK, SOLANA_MAINNET_NETWORK, TEMPO_USDC_ADDRESS, TEMPO_USDC_DECIMALS, BASE_USDC_ADDRESS, BASE_USDC_DECIMALS, ZERO_EVM_ADDRESS, DEFAULT_SOLANA_FACILITATOR_URL, DEFAULT_TEMPO_RPC_URL;
13
13
  var init_constants = __esm({
14
14
  "src/constants.ts"() {
15
15
  "use strict";
@@ -21,6 +21,7 @@ var init_constants = __esm({
21
21
  BASE_USDC_DECIMALS = 6;
22
22
  ZERO_EVM_ADDRESS = "0x0000000000000000000000000000000000000000";
23
23
  DEFAULT_SOLANA_FACILITATOR_URL = "https://facilitator.corbits.dev";
24
+ DEFAULT_TEMPO_RPC_URL = "https://rpc.tempo.xyz";
24
25
  }
25
26
  });
26
27
 
@@ -390,7 +391,7 @@ async function createX402Server(config, kvStore) {
390
391
  const { x402ResourceServer, HTTPFacilitatorClient } = await import("@x402/core/server");
391
392
  const { registerExactEvmScheme } = await import("@x402/evm/exact/server");
392
393
  const { bazaarResourceServerExtension } = await import("@x402/extensions/bazaar");
393
- const { siwxResourceServerExtension } = await import("@x402/extensions/sign-in-with-x");
394
+ const { createSIWxResourceServerExtension, InMemorySIWxStorage } = await import("@x402/extensions/sign-in-with-x");
394
395
  const { facilitator: defaultFacilitator } = await import("@coinbase/x402");
395
396
  const configuredNetworks = getConfiguredX402Networks(config);
396
397
  const facilitatorsByNetwork = getResolvedX402Facilitators(
@@ -420,7 +421,9 @@ async function createX402Server(config, kvStore) {
420
421
  registerExactSvmScheme(server, { networks: svmNetworks });
421
422
  }
422
423
  server.registerExtension(bazaarResourceServerExtension);
423
- server.registerExtension(siwxResourceServerExtension);
424
+ server.registerExtension(
425
+ createSIWxResourceServerExtension({ storage: new InMemorySIWxStorage() })
426
+ );
424
427
  const initPromise = server.initialize();
425
428
  return {
426
429
  server,
@@ -1531,7 +1534,7 @@ async function verifyHashMode(args, info) {
1531
1534
  }
1532
1535
  if (chargeResult.status === 402) {
1533
1536
  const reason = await readChallengeReason(chargeResult.challenge);
1534
- const detail = reason || "credential may be invalid, or check TEMPO_RPC_URL configuration";
1537
+ const detail = reason || "credential may be invalid, or check your TEMPO_RPC_URL endpoint";
1535
1538
  report("warn", `MPP credential rejected: ${detail}`);
1536
1539
  return { ok: false, kind: "invalid" };
1537
1540
  }
@@ -4421,7 +4424,7 @@ var envShape = {
4421
4424
  }).optional(),
4422
4425
  TEMPO_RPC_URL: z.string().refine(isUrl, {
4423
4426
  params: { code: "invalid_mpp_rpc_url", ...mpp },
4424
- message: "TEMPO_RPC_URL must be a valid URL \u2014 authenticated Tempo JSON-RPC endpoint. Public rpc.tempo.xyz returns 401."
4427
+ message: "TEMPO_RPC_URL must be a valid URL \u2014 the Tempo JSON-RPC endpoint used for MPP on-chain verification. Optional; defaults to the public DEFAULT_TEMPO_RPC_URL."
4425
4428
  }).optional(),
4426
4429
  MPP_OPERATOR_KEY: z.string().refine(isEvmPrivateKey, {
4427
4430
  params: { code: "invalid_mpp_operator_key", ...mpp },
@@ -4462,14 +4465,6 @@ var EnvInputSchema = z.object(envShape).passthrough().superRefine((env, ctx) =>
4462
4465
  ["MPP_CURRENCY"]
4463
4466
  );
4464
4467
  }
4465
- if (env.TEMPO_RPC_URL === void 0) {
4466
- addIssue(
4467
- ctx,
4468
- { code: "missing_mpp_rpc_url", ...mpp },
4469
- "TEMPO_RPC_URL is required when MPP is enabled \u2014 authenticated Tempo JSON-RPC endpoint. Public rpc.tempo.xyz returns 401.",
4470
- ["TEMPO_RPC_URL"]
4471
- );
4472
- }
4473
4468
  }
4474
4469
  const collision = operatorAddressesCollide(env.MPP_OPERATOR_KEY, env.MPP_FEE_PAYER_KEY);
4475
4470
  if (collision) {
@@ -4601,7 +4596,7 @@ function validateX402Config(config, env) {
4601
4596
  }
4602
4597
  return issues;
4603
4598
  }
4604
- function validateMppConfig(config, env) {
4599
+ function validateMppConfig(config) {
4605
4600
  const m = config.mpp;
4606
4601
  if (!m) {
4607
4602
  return [
@@ -4649,12 +4644,6 @@ function validateMppConfig(config, env) {
4649
4644
  `MPP recipient '${placeholder}' is a placeholder address and cannot receive payments.`
4650
4645
  );
4651
4646
  }
4652
- if (!m.rpcUrl && !env.TEMPO_RPC_URL) {
4653
- push(
4654
- "missing_mpp_rpc_url",
4655
- "MPP requires an authenticated Tempo RPC URL. Set TEMPO_RPC_URL env var or pass rpcUrl in the mpp config object."
4656
- );
4657
- }
4658
4647
  if (m.feePayerKey && !isEvmPrivateKey(m.feePayerKey)) {
4659
4648
  push(
4660
4649
  "invalid_mpp_fee_payer_key",
@@ -4761,7 +4750,7 @@ function routerConfigFromEnv(options) {
4761
4750
  const mppConfig = mppEnabled ? {
4762
4751
  secretKey: env.MPP_SECRET_KEY,
4763
4752
  currency: canonicalizeEvm(env.MPP_CURRENCY),
4764
- rpcUrl: env.TEMPO_RPC_URL,
4753
+ rpcUrl: env.TEMPO_RPC_URL ?? DEFAULT_TEMPO_RPC_URL,
4765
4754
  recipient: payeeAddress,
4766
4755
  ...env.MPP_FEE_PAYER_KEY ? { feePayerKey: env.MPP_FEE_PAYER_KEY } : {},
4767
4756
  ...env.MPP_OPERATOR_KEY ? { operatorKey: env.MPP_OPERATOR_KEY, session: {} } : {}
@@ -4812,7 +4801,7 @@ function getRouterConfigIssues(config, options = {}) {
4812
4801
  });
4813
4802
  }
4814
4803
  if (protocols.includes("x402")) issues.push(...validateX402Config(config, env));
4815
- if (protocols.includes("mpp")) issues.push(...validateMppConfig(config, env));
4804
+ if (protocols.includes("mpp")) issues.push(...validateMppConfig(config));
4816
4805
  return issues;
4817
4806
  }
4818
4807
 
@@ -4884,6 +4873,7 @@ function getMppxStreamingContext(args) {
4884
4873
  }
4885
4874
 
4886
4875
  // src/init/mpp.ts
4876
+ init_constants();
4887
4877
  async function initMpp(config, resolvedBaseUrl, kvStore, configError) {
4888
4878
  if (configError) return { initError: configError };
4889
4879
  if (!config.mpp) return {};
@@ -4892,7 +4882,7 @@ async function initMpp(config, resolvedBaseUrl, kvStore, configError) {
4892
4882
  const { createClient, http } = await import("viem");
4893
4883
  const { tempo: tempoChain } = await import("viem/chains");
4894
4884
  const { privateKeyToAccount: privateKeyToAccount2 } = await import("viem/accounts");
4895
- const rpcUrl = config.mpp.rpcUrl ?? process.env.TEMPO_RPC_URL;
4885
+ const rpcUrl = config.mpp.rpcUrl ?? process.env.TEMPO_RPC_URL ?? DEFAULT_TEMPO_RPC_URL;
4896
4886
  const tempoClient = createClient({ chain: tempoChain, transport: http(rpcUrl) });
4897
4887
  const getClient = async () => tempoClient;
4898
4888
  const operatorAccount = config.mpp.operatorKey ? privateKeyToAccount2(config.mpp.operatorKey) : void 0;
@@ -5069,6 +5059,7 @@ export {
5069
5059
  BASE_USDC_ADDRESS,
5070
5060
  BASE_USDC_DECIMALS,
5071
5061
  DEFAULT_SOLANA_FACILITATOR_URL,
5062
+ DEFAULT_TEMPO_RPC_URL,
5072
5063
  HttpError,
5073
5064
  RouterConfigError,
5074
5065
  SOLANA_MAINNET_NETWORK,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentcash/router",
3
- "version": "1.10.1",
3
+ "version": "1.10.3",
4
4
  "description": "Unified route builder for Next.js App Router APIs with x402, MPP, SIWX, and API key auth",
5
5
  "type": "module",
6
6
  "exports": {
@@ -28,10 +28,10 @@
28
28
  ],
29
29
  "dependencies": {
30
30
  "@coinbase/x402": "^2.1.0",
31
- "@x402/core": "^2.11.0",
32
- "@x402/evm": "^2.11.0",
33
- "@x402/extensions": "^2.11.0",
34
- "@x402/svm": "^2.11.0",
31
+ "@x402/core": "^2.13.0",
32
+ "@x402/evm": "^2.13.0",
33
+ "@x402/extensions": "^2.13.0",
34
+ "@x402/svm": "^2.13.0",
35
35
  "mppx": "^0.6.16",
36
36
  "viem": "^2.47.6",
37
37
  "zod-openapi": "^5.0.0"