@agentcash/router 1.10.2 → 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 +1 -1
- package/dist/index.cjs +11 -21
- package/dist/index.d.cts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +10 -21
- package/package.json +1 -1
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` |
|
|
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
|
|
|
@@ -470,6 +471,7 @@ __export(index_exports, {
|
|
|
470
471
|
BASE_USDC_ADDRESS: () => BASE_USDC_ADDRESS,
|
|
471
472
|
BASE_USDC_DECIMALS: () => BASE_USDC_DECIMALS,
|
|
472
473
|
DEFAULT_SOLANA_FACILITATOR_URL: () => DEFAULT_SOLANA_FACILITATOR_URL,
|
|
474
|
+
DEFAULT_TEMPO_RPC_URL: () => DEFAULT_TEMPO_RPC_URL,
|
|
473
475
|
HttpError: () => HttpError,
|
|
474
476
|
RouterConfigError: () => RouterConfigError,
|
|
475
477
|
SOLANA_MAINNET_NETWORK: () => SOLANA_MAINNET_NETWORK,
|
|
@@ -1574,7 +1576,7 @@ async function verifyHashMode(args, info) {
|
|
|
1574
1576
|
}
|
|
1575
1577
|
if (chargeResult.status === 402) {
|
|
1576
1578
|
const reason = await readChallengeReason(chargeResult.challenge);
|
|
1577
|
-
const detail = reason || "credential may be invalid, or check TEMPO_RPC_URL
|
|
1579
|
+
const detail = reason || "credential may be invalid, or check your TEMPO_RPC_URL endpoint";
|
|
1578
1580
|
report("warn", `MPP credential rejected: ${detail}`);
|
|
1579
1581
|
return { ok: false, kind: "invalid" };
|
|
1580
1582
|
}
|
|
@@ -4464,7 +4466,7 @@ var envShape = {
|
|
|
4464
4466
|
}).optional(),
|
|
4465
4467
|
TEMPO_RPC_URL: import_zod.z.string().refine(isUrl, {
|
|
4466
4468
|
params: { code: "invalid_mpp_rpc_url", ...mpp },
|
|
4467
|
-
message: "TEMPO_RPC_URL must be a valid URL \u2014
|
|
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."
|
|
4468
4470
|
}).optional(),
|
|
4469
4471
|
MPP_OPERATOR_KEY: import_zod.z.string().refine(isEvmPrivateKey, {
|
|
4470
4472
|
params: { code: "invalid_mpp_operator_key", ...mpp },
|
|
@@ -4505,14 +4507,6 @@ var EnvInputSchema = import_zod.z.object(envShape).passthrough().superRefine((en
|
|
|
4505
4507
|
["MPP_CURRENCY"]
|
|
4506
4508
|
);
|
|
4507
4509
|
}
|
|
4508
|
-
if (env.TEMPO_RPC_URL === void 0) {
|
|
4509
|
-
addIssue(
|
|
4510
|
-
ctx,
|
|
4511
|
-
{ code: "missing_mpp_rpc_url", ...mpp },
|
|
4512
|
-
"TEMPO_RPC_URL is required when MPP is enabled \u2014 authenticated Tempo JSON-RPC endpoint. Public rpc.tempo.xyz returns 401.",
|
|
4513
|
-
["TEMPO_RPC_URL"]
|
|
4514
|
-
);
|
|
4515
|
-
}
|
|
4516
4510
|
}
|
|
4517
4511
|
const collision = operatorAddressesCollide(env.MPP_OPERATOR_KEY, env.MPP_FEE_PAYER_KEY);
|
|
4518
4512
|
if (collision) {
|
|
@@ -4644,7 +4638,7 @@ function validateX402Config(config, env) {
|
|
|
4644
4638
|
}
|
|
4645
4639
|
return issues;
|
|
4646
4640
|
}
|
|
4647
|
-
function validateMppConfig(config
|
|
4641
|
+
function validateMppConfig(config) {
|
|
4648
4642
|
const m = config.mpp;
|
|
4649
4643
|
if (!m) {
|
|
4650
4644
|
return [
|
|
@@ -4692,12 +4686,6 @@ function validateMppConfig(config, env) {
|
|
|
4692
4686
|
`MPP recipient '${placeholder}' is a placeholder address and cannot receive payments.`
|
|
4693
4687
|
);
|
|
4694
4688
|
}
|
|
4695
|
-
if (!m.rpcUrl && !env.TEMPO_RPC_URL) {
|
|
4696
|
-
push(
|
|
4697
|
-
"missing_mpp_rpc_url",
|
|
4698
|
-
"MPP requires an authenticated Tempo RPC URL. Set TEMPO_RPC_URL env var or pass rpcUrl in the mpp config object."
|
|
4699
|
-
);
|
|
4700
|
-
}
|
|
4701
4689
|
if (m.feePayerKey && !isEvmPrivateKey(m.feePayerKey)) {
|
|
4702
4690
|
push(
|
|
4703
4691
|
"invalid_mpp_fee_payer_key",
|
|
@@ -4804,7 +4792,7 @@ function routerConfigFromEnv(options) {
|
|
|
4804
4792
|
const mppConfig = mppEnabled ? {
|
|
4805
4793
|
secretKey: env.MPP_SECRET_KEY,
|
|
4806
4794
|
currency: canonicalizeEvm(env.MPP_CURRENCY),
|
|
4807
|
-
rpcUrl: env.TEMPO_RPC_URL,
|
|
4795
|
+
rpcUrl: env.TEMPO_RPC_URL ?? DEFAULT_TEMPO_RPC_URL,
|
|
4808
4796
|
recipient: payeeAddress,
|
|
4809
4797
|
...env.MPP_FEE_PAYER_KEY ? { feePayerKey: env.MPP_FEE_PAYER_KEY } : {},
|
|
4810
4798
|
...env.MPP_OPERATOR_KEY ? { operatorKey: env.MPP_OPERATOR_KEY, session: {} } : {}
|
|
@@ -4855,7 +4843,7 @@ function getRouterConfigIssues(config, options = {}) {
|
|
|
4855
4843
|
});
|
|
4856
4844
|
}
|
|
4857
4845
|
if (protocols.includes("x402")) issues.push(...validateX402Config(config, env));
|
|
4858
|
-
if (protocols.includes("mpp")) issues.push(...validateMppConfig(config
|
|
4846
|
+
if (protocols.includes("mpp")) issues.push(...validateMppConfig(config));
|
|
4859
4847
|
return issues;
|
|
4860
4848
|
}
|
|
4861
4849
|
|
|
@@ -4927,6 +4915,7 @@ function getMppxStreamingContext(args) {
|
|
|
4927
4915
|
}
|
|
4928
4916
|
|
|
4929
4917
|
// src/init/mpp.ts
|
|
4918
|
+
init_constants();
|
|
4930
4919
|
async function initMpp(config, resolvedBaseUrl, kvStore, configError) {
|
|
4931
4920
|
if (configError) return { initError: configError };
|
|
4932
4921
|
if (!config.mpp) return {};
|
|
@@ -4935,7 +4924,7 @@ async function initMpp(config, resolvedBaseUrl, kvStore, configError) {
|
|
|
4935
4924
|
const { createClient, http } = await import("viem");
|
|
4936
4925
|
const { tempo: tempoChain } = await import("viem/chains");
|
|
4937
4926
|
const { privateKeyToAccount: privateKeyToAccount2 } = await import("viem/accounts");
|
|
4938
|
-
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;
|
|
4939
4928
|
const tempoClient = createClient({ chain: tempoChain, transport: http(rpcUrl) });
|
|
4940
4929
|
const getClient = async () => tempoClient;
|
|
4941
4930
|
const operatorAccount = config.mpp.operatorKey ? privateKeyToAccount2(config.mpp.operatorKey) : void 0;
|
|
@@ -5113,6 +5102,7 @@ function createRouterFromEnv(options) {
|
|
|
5113
5102
|
BASE_USDC_ADDRESS,
|
|
5114
5103
|
BASE_USDC_DECIMALS,
|
|
5115
5104
|
DEFAULT_SOLANA_FACILITATOR_URL,
|
|
5105
|
+
DEFAULT_TEMPO_RPC_URL,
|
|
5116
5106
|
HttpError,
|
|
5117
5107
|
RouterConfigError,
|
|
5118
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' | '
|
|
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' | '
|
|
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
|
|
|
@@ -1533,7 +1534,7 @@ async function verifyHashMode(args, info) {
|
|
|
1533
1534
|
}
|
|
1534
1535
|
if (chargeResult.status === 402) {
|
|
1535
1536
|
const reason = await readChallengeReason(chargeResult.challenge);
|
|
1536
|
-
const detail = reason || "credential may be invalid, or check TEMPO_RPC_URL
|
|
1537
|
+
const detail = reason || "credential may be invalid, or check your TEMPO_RPC_URL endpoint";
|
|
1537
1538
|
report("warn", `MPP credential rejected: ${detail}`);
|
|
1538
1539
|
return { ok: false, kind: "invalid" };
|
|
1539
1540
|
}
|
|
@@ -4423,7 +4424,7 @@ var envShape = {
|
|
|
4423
4424
|
}).optional(),
|
|
4424
4425
|
TEMPO_RPC_URL: z.string().refine(isUrl, {
|
|
4425
4426
|
params: { code: "invalid_mpp_rpc_url", ...mpp },
|
|
4426
|
-
message: "TEMPO_RPC_URL must be a valid URL \u2014
|
|
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."
|
|
4427
4428
|
}).optional(),
|
|
4428
4429
|
MPP_OPERATOR_KEY: z.string().refine(isEvmPrivateKey, {
|
|
4429
4430
|
params: { code: "invalid_mpp_operator_key", ...mpp },
|
|
@@ -4464,14 +4465,6 @@ var EnvInputSchema = z.object(envShape).passthrough().superRefine((env, ctx) =>
|
|
|
4464
4465
|
["MPP_CURRENCY"]
|
|
4465
4466
|
);
|
|
4466
4467
|
}
|
|
4467
|
-
if (env.TEMPO_RPC_URL === void 0) {
|
|
4468
|
-
addIssue(
|
|
4469
|
-
ctx,
|
|
4470
|
-
{ code: "missing_mpp_rpc_url", ...mpp },
|
|
4471
|
-
"TEMPO_RPC_URL is required when MPP is enabled \u2014 authenticated Tempo JSON-RPC endpoint. Public rpc.tempo.xyz returns 401.",
|
|
4472
|
-
["TEMPO_RPC_URL"]
|
|
4473
|
-
);
|
|
4474
|
-
}
|
|
4475
4468
|
}
|
|
4476
4469
|
const collision = operatorAddressesCollide(env.MPP_OPERATOR_KEY, env.MPP_FEE_PAYER_KEY);
|
|
4477
4470
|
if (collision) {
|
|
@@ -4603,7 +4596,7 @@ function validateX402Config(config, env) {
|
|
|
4603
4596
|
}
|
|
4604
4597
|
return issues;
|
|
4605
4598
|
}
|
|
4606
|
-
function validateMppConfig(config
|
|
4599
|
+
function validateMppConfig(config) {
|
|
4607
4600
|
const m = config.mpp;
|
|
4608
4601
|
if (!m) {
|
|
4609
4602
|
return [
|
|
@@ -4651,12 +4644,6 @@ function validateMppConfig(config, env) {
|
|
|
4651
4644
|
`MPP recipient '${placeholder}' is a placeholder address and cannot receive payments.`
|
|
4652
4645
|
);
|
|
4653
4646
|
}
|
|
4654
|
-
if (!m.rpcUrl && !env.TEMPO_RPC_URL) {
|
|
4655
|
-
push(
|
|
4656
|
-
"missing_mpp_rpc_url",
|
|
4657
|
-
"MPP requires an authenticated Tempo RPC URL. Set TEMPO_RPC_URL env var or pass rpcUrl in the mpp config object."
|
|
4658
|
-
);
|
|
4659
|
-
}
|
|
4660
4647
|
if (m.feePayerKey && !isEvmPrivateKey(m.feePayerKey)) {
|
|
4661
4648
|
push(
|
|
4662
4649
|
"invalid_mpp_fee_payer_key",
|
|
@@ -4763,7 +4750,7 @@ function routerConfigFromEnv(options) {
|
|
|
4763
4750
|
const mppConfig = mppEnabled ? {
|
|
4764
4751
|
secretKey: env.MPP_SECRET_KEY,
|
|
4765
4752
|
currency: canonicalizeEvm(env.MPP_CURRENCY),
|
|
4766
|
-
rpcUrl: env.TEMPO_RPC_URL,
|
|
4753
|
+
rpcUrl: env.TEMPO_RPC_URL ?? DEFAULT_TEMPO_RPC_URL,
|
|
4767
4754
|
recipient: payeeAddress,
|
|
4768
4755
|
...env.MPP_FEE_PAYER_KEY ? { feePayerKey: env.MPP_FEE_PAYER_KEY } : {},
|
|
4769
4756
|
...env.MPP_OPERATOR_KEY ? { operatorKey: env.MPP_OPERATOR_KEY, session: {} } : {}
|
|
@@ -4814,7 +4801,7 @@ function getRouterConfigIssues(config, options = {}) {
|
|
|
4814
4801
|
});
|
|
4815
4802
|
}
|
|
4816
4803
|
if (protocols.includes("x402")) issues.push(...validateX402Config(config, env));
|
|
4817
|
-
if (protocols.includes("mpp")) issues.push(...validateMppConfig(config
|
|
4804
|
+
if (protocols.includes("mpp")) issues.push(...validateMppConfig(config));
|
|
4818
4805
|
return issues;
|
|
4819
4806
|
}
|
|
4820
4807
|
|
|
@@ -4886,6 +4873,7 @@ function getMppxStreamingContext(args) {
|
|
|
4886
4873
|
}
|
|
4887
4874
|
|
|
4888
4875
|
// src/init/mpp.ts
|
|
4876
|
+
init_constants();
|
|
4889
4877
|
async function initMpp(config, resolvedBaseUrl, kvStore, configError) {
|
|
4890
4878
|
if (configError) return { initError: configError };
|
|
4891
4879
|
if (!config.mpp) return {};
|
|
@@ -4894,7 +4882,7 @@ async function initMpp(config, resolvedBaseUrl, kvStore, configError) {
|
|
|
4894
4882
|
const { createClient, http } = await import("viem");
|
|
4895
4883
|
const { tempo: tempoChain } = await import("viem/chains");
|
|
4896
4884
|
const { privateKeyToAccount: privateKeyToAccount2 } = await import("viem/accounts");
|
|
4897
|
-
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;
|
|
4898
4886
|
const tempoClient = createClient({ chain: tempoChain, transport: http(rpcUrl) });
|
|
4899
4887
|
const getClient = async () => tempoClient;
|
|
4900
4888
|
const operatorAccount = config.mpp.operatorKey ? privateKeyToAccount2(config.mpp.operatorKey) : void 0;
|
|
@@ -5071,6 +5059,7 @@ export {
|
|
|
5071
5059
|
BASE_USDC_ADDRESS,
|
|
5072
5060
|
BASE_USDC_DECIMALS,
|
|
5073
5061
|
DEFAULT_SOLANA_FACILITATOR_URL,
|
|
5062
|
+
DEFAULT_TEMPO_RPC_URL,
|
|
5074
5063
|
HttpError,
|
|
5075
5064
|
RouterConfigError,
|
|
5076
5065
|
SOLANA_MAINNET_NETWORK,
|