@lunora/x402 1.0.0-alpha.2 → 1.0.0-alpha.21
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 +2 -0
- package/dist/charge/index.d.mts +110 -47
- package/dist/charge/index.d.ts +110 -47
- package/dist/charge/index.mjs +1 -7
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +1 -2
- package/dist/packem_shared/DEFAULT_ALLOWED_ASSETS-BIIP_mdG.mjs +1 -0
- package/dist/packem_shared/DEFAULT_FACILITATOR_URL-lUtljfJI.mjs +1 -0
- package/dist/packem_shared/EVM_NETWORKS-XOms9Rtk.mjs +1 -0
- package/dist/packem_shared/config.d-Dki_2r9a.d.mts +472 -0
- package/dist/packem_shared/config.d-Dki_2r9a.d.ts +472 -0
- package/dist/packem_shared/createChargeMiddleware-MQhSA6Wt.mjs +1 -0
- package/dist/packem_shared/createFacilitatorClient-Dj4Ll9xQ.mjs +1 -0
- package/dist/packem_shared/createPayFetch-B6A51xPI.mjs +1 -0
- package/dist/packem_shared/createProcedureChargeGate-Cfm5mD2y.mjs +1 -0
- package/dist/packem_shared/registerWallet-Cu4qF5tj.mjs +1 -0
- package/dist/packem_shared/toPaymentEventRow-D_kRVcb3.mjs +1 -0
- package/dist/packem_shared/withX402-D10895ct.mjs +1 -0
- package/dist/pay/index.d.mts +61 -43
- package/dist/pay/index.d.ts +61 -43
- package/dist/pay/index.mjs +1 -21
- package/package.json +8 -8
- package/dist/packem_shared/DEFAULT_FACILITATOR_URL-Cbz6kIqa.mjs +0 -4
- package/dist/packem_shared/DEFAULT_STABLECOIN_DECIMALS-CSu5b5lD.mjs +0 -85
- package/dist/packem_shared/EVM_NETWORKS-BhnYWUQ4.mjs +0 -26
- package/dist/packem_shared/config.d-CddwCiBm.d.mts +0 -325
- package/dist/packem_shared/config.d-CddwCiBm.d.ts +0 -325
- package/dist/packem_shared/createChargeMiddleware-BJkYJeFf.mjs +0 -148
- package/dist/packem_shared/createFacilitatorClient-rXHBnCZm.mjs +0 -16
- package/dist/packem_shared/createPayFetch-O2vkvM1v.mjs +0 -17
- package/dist/packem_shared/createProcedureChargeGate-CV8ITlQP.mjs +0 -19
- package/dist/packem_shared/registerWallet-I4pVwq65.mjs +0 -109
- package/dist/packem_shared/toPaymentEventRow-DW4O9N7Y.mjs +0 -22
- package/dist/packem_shared/withX402-rUq0voT8.mjs +0 -15
package/dist/pay/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { e as X402PayConfig } from "../packem_shared/config.d-
|
|
2
|
-
export { type C as Caip2, D as DEFAULT_FACILITATOR_URL,
|
|
1
|
+
import { e as X402PayConfig } from "../packem_shared/config.d-Dki_2r9a.js";
|
|
2
|
+
export { type A as AllowedAsset, type C as Caip2, m as DEFAULT_ALLOWED_ASSETS, D as DEFAULT_FACILITATOR_URL, n as DEFAULT_STABLECOIN_DECIMALS, type o as SpendPolicy, type p as SpendState, type X as X402CdpSignerConfig, type d as X402Network, type f as X402Price, type j as X402SignerConfig, q as assertBoundedPolicy, s as buildPaymentGuard, u as buildSpendPolicy, v as createSpendState, k as isEvmNetwork, l as isSvmNetwork, w as releaseSpendOnFailure, r as resolveFacilitatorUrl, t as toCaip2, x as usdToAtomic } from "../packem_shared/config.d-Dki_2r9a.js";
|
|
3
3
|
import { x402Client } from '@x402/core/client';
|
|
4
4
|
import { ClientSvmSigner } from '@x402/svm';
|
|
5
5
|
import { PrivateKeyAccount } from 'viem/accounts';
|
|
@@ -8,70 +8,88 @@ import '@x402/core/http';
|
|
|
8
8
|
import '@x402/core/types';
|
|
9
9
|
/** Reads a secret by name; resolves `undefined` when unset. */
|
|
10
10
|
type GetSecret = (name: string) => Promise<string | undefined> | string | undefined;
|
|
11
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* How the wallet reads its key material — wired to `ctx.secrets.get` in an action.
|
|
13
|
+
* @experimental
|
|
14
|
+
*/
|
|
12
15
|
interface WalletDeps {
|
|
13
16
|
/** Read a secret (e.g. a private key) by name; `undefined` when unset. */
|
|
14
17
|
readonly getSecret: GetSecret;
|
|
15
18
|
}
|
|
16
19
|
/**
|
|
17
|
-
* Resolve a viem `LocalAccount` from a raw private key. The key may be given with
|
|
18
|
-
* or without the `0x` prefix. The account is a structural `ClientEvmSigner`
|
|
19
|
-
* (`address` + `signTypedData`), so `@x402/evm` accepts it directly.
|
|
20
|
-
|
|
20
|
+
* Resolve a viem `LocalAccount` from a raw private key. The key may be given with
|
|
21
|
+
* or without the `0x` prefix. The account is a structural `ClientEvmSigner`
|
|
22
|
+
* (`address` + `signTypedData`), so `@x402/evm` accepts it directly.
|
|
23
|
+
* @experimental
|
|
24
|
+
*/
|
|
21
25
|
declare const resolveEvmAccount: (privateKey: string) => Promise<PrivateKeyAccount>;
|
|
22
26
|
/**
|
|
23
|
-
* Resolve a `@solana/kit` `KeyPairSigner` from a raw Solana secret key. The secret
|
|
24
|
-
* may be given as a JSON byte array (`[12,34,…]`, the `solana-keygen` keyfile
|
|
25
|
-
* format) or as a base58 string. A 64-byte value is a full secret key (seed ‖
|
|
26
|
-
* public key); a 32-byte value is the seed alone. The returned signer is a
|
|
27
|
-
* structural `ClientSvmSigner` (`TransactionSigner`), so `@x402/svm` accepts it.
|
|
28
|
-
|
|
27
|
+
* Resolve a `@solana/kit` `KeyPairSigner` from a raw Solana secret key. The secret
|
|
28
|
+
* may be given as a JSON byte array (`[12,34,…]`, the `solana-keygen` keyfile
|
|
29
|
+
* format) or as a base58 string. A 64-byte value is a full secret key (seed ‖
|
|
30
|
+
* public key); a 32-byte value is the seed alone. The returned signer is a
|
|
31
|
+
* structural `ClientSvmSigner` (`TransactionSigner`), so `@x402/svm` accepts it.
|
|
32
|
+
* @experimental
|
|
33
|
+
*/
|
|
29
34
|
declare const resolveSvmSigner: (secret: string) => Promise<ClientSvmSigner>;
|
|
30
35
|
/**
|
|
31
|
-
* Register the scheme family the configured network needs on `client`, wired to
|
|
32
|
-
* the agent signer. Dispatches on network family (EVM vs SVM) and on custody —
|
|
33
|
-
* `"signer"` (a signer the caller already built; registered directly, no secret
|
|
34
|
-
* read), `"raw-key"` (a `ctx.secrets` private key → viem account on EVM or a
|
|
35
|
-
* `@solana/kit` keypair on SVM), or `"cdp"` (a Coinbase-managed wallet via
|
|
36
|
-
* `@coinbase/cdp-sdk`).
|
|
37
|
-
|
|
36
|
+
* Register the scheme family the configured network needs on `client`, wired to
|
|
37
|
+
* the agent signer. Dispatches on network family (EVM vs SVM) and on custody —
|
|
38
|
+
* `"signer"` (a signer the caller already built; registered directly, no secret
|
|
39
|
+
* read), `"raw-key"` (a `ctx.secrets` private key → viem account on EVM or a
|
|
40
|
+
* `@solana/kit` keypair on SVM), or `"cdp"` (a Coinbase-managed wallet via
|
|
41
|
+
* `@coinbase/cdp-sdk`).
|
|
42
|
+
* @experimental
|
|
43
|
+
*/
|
|
38
44
|
declare const registerWallet: (client: x402Client, config: X402PayConfig, deps: WalletDeps) => Promise<void>;
|
|
39
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* A payment-enabled `fetch`: same signature as the platform `fetch`.
|
|
47
|
+
* @experimental
|
|
48
|
+
*/
|
|
40
49
|
type PayFetch = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
41
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* Dependencies for building a pay-rail fetch: secret access, plus an optional base `fetch` to wrap.
|
|
52
|
+
* @experimental
|
|
53
|
+
*/
|
|
42
54
|
interface X402PayDeps extends WalletDeps {
|
|
43
55
|
/** The `fetch` to wrap (defaults to `globalThis.fetch`). Inject to test or to chain transports. */
|
|
44
56
|
readonly fetch?: typeof globalThis.fetch;
|
|
45
57
|
}
|
|
46
58
|
/**
|
|
47
|
-
* Build a payment-enabled `fetch` for `config`. Throws (before resolving a
|
|
48
|
-
* signer) when `config.policy` is unbounded — an agent wallet is never built
|
|
49
|
-
* with unlimited spend authority.
|
|
50
|
-
|
|
59
|
+
* Build a payment-enabled `fetch` for `config`. Throws (before resolving a
|
|
60
|
+
* signer) when `config.policy` is unbounded — an agent wallet is never built
|
|
61
|
+
* with unlimited spend authority.
|
|
62
|
+
* @experimental
|
|
63
|
+
*/
|
|
51
64
|
declare const createPayFetch: (config: X402PayConfig, deps: X402PayDeps) => Promise<PayFetch>;
|
|
52
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* A configured pay rail: a payment-enabled `fetch` bounded by the spend policy.
|
|
67
|
+
* @experimental
|
|
68
|
+
*/
|
|
53
69
|
interface X402Pay {
|
|
54
70
|
/** A `fetch` that transparently pays for `402`-gated resources under the policy. */
|
|
55
71
|
readonly fetch: PayFetch;
|
|
56
72
|
}
|
|
57
73
|
/**
|
|
58
|
-
* Build a pay rail for `config`. The returned `fetch` answers `402` challenges by
|
|
59
|
-
* signing and retrying, within `config.policy`. Throws (before touching the
|
|
60
|
-
* signer) when the policy is unbounded.
|
|
61
|
-
|
|
74
|
+
* Build a pay rail for `config`. The returned `fetch` answers `402` challenges by
|
|
75
|
+
* signing and retrying, within `config.policy`. Throws (before touching the
|
|
76
|
+
* signer) when the policy is unbounded.
|
|
77
|
+
* @experimental
|
|
78
|
+
*/
|
|
62
79
|
declare const createX402Pay: (config: X402PayConfig, deps: X402PayDeps) => Promise<X402Pay>;
|
|
63
80
|
/**
|
|
64
|
-
* A synchronous, lazily-initialised pay rail — what codegen wires `ctx.x402` to.
|
|
65
|
-
*
|
|
66
|
-
* `buildCtx` must stay synchronous, but {@link createX402Pay} is async (it reads
|
|
67
|
-
* the wallet secret and imports the signer). So this returns an {@link X402Pay}
|
|
68
|
-
* immediately whose `fetch` builds the real rail on its **first** call and
|
|
69
|
-
* memoises it: the viem/`@x402` signer imports + Secrets Store read are paid for
|
|
70
|
-
* only when an action actually pays, and the single `SpendState` behind the
|
|
71
|
-
* rail is shared across every payment for the lifetime of this ctx — so the
|
|
72
|
-
* per-run cap scopes to the ctx, not to each request. A failed build (e.g. an
|
|
73
|
-
* unbounded policy) is memoised too, keeping the rail deterministically
|
|
74
|
-
* fail-closed.
|
|
75
|
-
|
|
81
|
+
* A synchronous, lazily-initialised pay rail — what codegen wires `ctx.x402` to.
|
|
82
|
+
*
|
|
83
|
+
* `buildCtx` must stay synchronous, but {@link createX402Pay} is async (it reads
|
|
84
|
+
* the wallet secret and imports the signer). So this returns an {@link X402Pay}
|
|
85
|
+
* immediately whose `fetch` builds the real rail on its **first** call and
|
|
86
|
+
* memoises it: the viem/`@x402` signer imports + Secrets Store read are paid for
|
|
87
|
+
* only when an action actually pays, and the single `SpendState` behind the
|
|
88
|
+
* rail is shared across every payment for the lifetime of this ctx — so the
|
|
89
|
+
* per-run cap scopes to the ctx, not to each request. A failed build (e.g. an
|
|
90
|
+
* unbounded policy) is memoised too, keeping the rail deterministically
|
|
91
|
+
* fail-closed.
|
|
92
|
+
* @experimental
|
|
93
|
+
*/
|
|
76
94
|
declare const lazyX402Pay: (config: X402PayConfig, deps: X402PayDeps) => X402Pay;
|
|
77
95
|
export { type PayFetch, type WalletDeps, X402Pay, type X402PayConfig, type X402PayDeps, createPayFetch, createX402Pay, lazyX402Pay, registerWallet, resolveEvmAccount, resolveSvmSigner };
|
package/dist/pay/index.mjs
CHANGED
|
@@ -1,21 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
export { DEFAULT_FACILITATOR_URL, resolveFacilitatorUrl } from '../packem_shared/DEFAULT_FACILITATOR_URL-Cbz6kIqa.mjs';
|
|
3
|
-
export { isEvmNetwork, isSvmNetwork, toCaip2 } from '../packem_shared/EVM_NETWORKS-BhnYWUQ4.mjs';
|
|
4
|
-
export { DEFAULT_STABLECOIN_DECIMALS, assertBoundedPolicy, buildPaymentGuard, buildSpendPolicy, createSpendState, recordSpend, usdToAtomic } from '../packem_shared/DEFAULT_STABLECOIN_DECIMALS-CSu5b5lD.mjs';
|
|
5
|
-
export { registerWallet, resolveEvmAccount, resolveSvmSigner } from '../packem_shared/registerWallet-I4pVwq65.mjs';
|
|
6
|
-
|
|
7
|
-
const createX402Pay = async (config, deps) => {
|
|
8
|
-
const fetch = await createPayFetch(config, deps);
|
|
9
|
-
return { fetch };
|
|
10
|
-
};
|
|
11
|
-
const lazyX402Pay = (config, deps) => {
|
|
12
|
-
let railPromise;
|
|
13
|
-
const fetch = async (input, init) => {
|
|
14
|
-
railPromise ??= createX402Pay(config, deps);
|
|
15
|
-
const rail = await railPromise;
|
|
16
|
-
return rail.fetch(input, init);
|
|
17
|
-
};
|
|
18
|
-
return { fetch };
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export { createPayFetch, createX402Pay, lazyX402Pay };
|
|
1
|
+
import{createPayFetch as c}from"../packem_shared/createPayFetch-B6A51xPI.mjs";import{DEFAULT_FACILITATOR_URL as S,resolveFacilitatorUrl as A}from"../packem_shared/DEFAULT_FACILITATOR_URL-lUtljfJI.mjs";import{isEvmNetwork as d,isSvmNetwork as y,toCaip2 as E}from"../packem_shared/EVM_NETWORKS-XOms9Rtk.mjs";import{DEFAULT_ALLOWED_ASSETS as f,DEFAULT_STABLECOIN_DECIMALS as u,assertBoundedPolicy as T,buildPaymentGuard as v,buildSpendPolicy as F,createSpendState as P,releaseSpendOnFailure as _,usdToAtomic as x}from"../packem_shared/DEFAULT_ALLOWED_ASSETS-BIIP_mdG.mjs";import{registerWallet as U,resolveEvmAccount as h,resolveSvmSigner as w}from"../packem_shared/registerWallet-Cu4qF5tj.mjs";const i=async(e,r)=>({fetch:await c(e,r)}),s=(e,r)=>{let t;return{fetch:async(o,a)=>(t??=i(e,r),(await t).fetch(o,a))}};export{f as DEFAULT_ALLOWED_ASSETS,S as DEFAULT_FACILITATOR_URL,u as DEFAULT_STABLECOIN_DECIMALS,T as assertBoundedPolicy,v as buildPaymentGuard,F as buildSpendPolicy,c as createPayFetch,P as createSpendState,i as createX402Pay,d as isEvmNetwork,y as isSvmNetwork,s as lazyX402Pay,U as registerWallet,_ as releaseSpendOnFailure,h as resolveEvmAccount,A as resolveFacilitatorUrl,w as resolveSvmSigner,E as toCaip2,x as usdToAtomic};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/x402",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.21",
|
|
4
4
|
"description": "Agentic payments (x402) for Lunora: charge agents per request (charge rail) and let your agents pay x402-gated resources (pay rail)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agents",
|
|
@@ -52,13 +52,13 @@
|
|
|
52
52
|
"access": "public"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@lunora/errors": "1.0.0-alpha.
|
|
56
|
-
"@solana/kit": "
|
|
57
|
-
"@x402/core": "2.
|
|
58
|
-
"@x402/evm": "2.
|
|
59
|
-
"@x402/fetch": "2.
|
|
60
|
-
"@x402/svm": "2.
|
|
61
|
-
"viem": "2.
|
|
55
|
+
"@lunora/errors": "1.0.0-alpha.8",
|
|
56
|
+
"@solana/kit": "7.0.0",
|
|
57
|
+
"@x402/core": "2.19.0",
|
|
58
|
+
"@x402/evm": "2.19.0",
|
|
59
|
+
"@x402/fetch": "2.19.0",
|
|
60
|
+
"@x402/svm": "2.19.0",
|
|
61
|
+
"viem": "2.55.8"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
64
|
"@coinbase/cdp-sdk": ">=1.0.0",
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { LunoraError } from '@lunora/errors';
|
|
2
|
-
import { toCaip2 } from './EVM_NETWORKS-BhnYWUQ4.mjs';
|
|
3
|
-
|
|
4
|
-
const USD_AMOUNT = /^\d+(?:\.\d+)?$/;
|
|
5
|
-
const normaliseAddress = (address, network) => network.startsWith("eip155:") ? address.toLowerCase() : address;
|
|
6
|
-
const DEFAULT_STABLECOIN_DECIMALS = 6;
|
|
7
|
-
const createSpendState = () => {
|
|
8
|
-
let spent = 0n;
|
|
9
|
-
return {
|
|
10
|
-
add: (amount) => {
|
|
11
|
-
spent += amount;
|
|
12
|
-
},
|
|
13
|
-
get spentAtomic() {
|
|
14
|
-
return spent;
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
const usdToAtomic = (usd, decimals = DEFAULT_STABLECOIN_DECIMALS) => {
|
|
19
|
-
if (!Number.isInteger(decimals) || decimals < 0) {
|
|
20
|
-
throw new LunoraError("BAD_REQUEST", `x402 policy: decimals must be a non-negative integer, got ${String(decimals)}.`);
|
|
21
|
-
}
|
|
22
|
-
const raw = (typeof usd === "number" ? usd.toString() : usd).trim();
|
|
23
|
-
const unsigned = raw.startsWith("$") ? raw.slice(1) : raw;
|
|
24
|
-
if (!USD_AMOUNT.test(unsigned)) {
|
|
25
|
-
throw new LunoraError("BAD_REQUEST", `x402 policy: "${String(usd)}" is not a valid USD amount (use a plain decimal like "0.01").`);
|
|
26
|
-
}
|
|
27
|
-
const [whole = "0", fraction = ""] = unsigned.split(".");
|
|
28
|
-
const scaled = fraction.slice(0, decimals).padEnd(decimals, "0");
|
|
29
|
-
return BigInt(whole) * 10n ** BigInt(decimals) + BigInt(scaled === "" ? "0" : scaled);
|
|
30
|
-
};
|
|
31
|
-
const buildSpendPolicy = (policy) => {
|
|
32
|
-
const decimals = policy.decimals ?? DEFAULT_STABLECOIN_DECIMALS;
|
|
33
|
-
const maxPerCall = policy.maxPerCall === void 0 ? void 0 : usdToAtomic(policy.maxPerCall, decimals);
|
|
34
|
-
const allowedNetworks = policy.allowedNetworks?.map((network) => toCaip2(network));
|
|
35
|
-
const { allowedRecipients } = policy;
|
|
36
|
-
return (_version, requirements) => requirements.filter((requirement) => {
|
|
37
|
-
if (maxPerCall !== void 0 && BigInt(requirement.amount) > maxPerCall) {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
if (allowedNetworks !== void 0 && !allowedNetworks.includes(requirement.network)) {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
if (allowedRecipients !== void 0) {
|
|
44
|
-
const payTo = normaliseAddress(requirement.payTo, requirement.network);
|
|
45
|
-
return allowedRecipients.some((allowed) => normaliseAddress(allowed, requirement.network) === payTo);
|
|
46
|
-
}
|
|
47
|
-
return true;
|
|
48
|
-
});
|
|
49
|
-
};
|
|
50
|
-
const buildPaymentGuard = (policy, state) => {
|
|
51
|
-
const decimals = policy.decimals ?? DEFAULT_STABLECOIN_DECIMALS;
|
|
52
|
-
const maxPerRun = policy.maxPerRun === void 0 ? void 0 : usdToAtomic(policy.maxPerRun, decimals);
|
|
53
|
-
return async (context) => {
|
|
54
|
-
const requirement = context.selectedRequirements;
|
|
55
|
-
const amount = BigInt(requirement.amount);
|
|
56
|
-
if (maxPerRun !== void 0 && state.spentAtomic + amount > maxPerRun) {
|
|
57
|
-
return {
|
|
58
|
-
abort: true,
|
|
59
|
-
reason: `x402 policy: this payment (${requirement.amount}) would exceed the per-run cap (already spent ${state.spentAtomic.toString()}, cap ${maxPerRun.toString()}, in atomic base units).`
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
if (policy.onPaymentRequired !== void 0) {
|
|
63
|
-
const approved = await policy.onPaymentRequired(requirement);
|
|
64
|
-
if (!approved) {
|
|
65
|
-
return { abort: true, reason: "x402 policy: payment was declined by onPaymentRequired." };
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return void 0;
|
|
69
|
-
};
|
|
70
|
-
};
|
|
71
|
-
const recordSpend = (state) => (context) => {
|
|
72
|
-
state.add(BigInt(context.selectedRequirements.amount));
|
|
73
|
-
return Promise.resolve();
|
|
74
|
-
};
|
|
75
|
-
const assertBoundedPolicy = (policy) => {
|
|
76
|
-
const bounded = policy.maxPerCall !== void 0 || policy.maxPerRun !== void 0 || (policy.allowedRecipients?.length ?? 0) > 0 || (policy.allowedNetworks?.length ?? 0) > 0 || policy.onPaymentRequired !== void 0;
|
|
77
|
-
if (!bounded) {
|
|
78
|
-
throw new LunoraError(
|
|
79
|
-
"FORBIDDEN",
|
|
80
|
-
"x402 pay: refusing to build a wallet with an unbounded spend policy. Set at least one of maxPerCall, maxPerRun, allowedRecipients, allowedNetworks, or onPaymentRequired."
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
export { DEFAULT_STABLECOIN_DECIMALS, assertBoundedPolicy, buildPaymentGuard, buildSpendPolicy, createSpendState, recordSpend, usdToAtomic };
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
const NETWORK_TO_CAIP2 = {
|
|
2
|
-
arbitrum: "eip155:42161",
|
|
3
|
-
"arbitrum-sepolia": "eip155:421614",
|
|
4
|
-
base: "eip155:8453",
|
|
5
|
-
"base-sepolia": "eip155:84532",
|
|
6
|
-
ethereum: "eip155:1",
|
|
7
|
-
polygon: "eip155:137",
|
|
8
|
-
solana: "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
|
|
9
|
-
"solana-devnet": "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1"
|
|
10
|
-
};
|
|
11
|
-
const EVM_NETWORKS = ["arbitrum", "arbitrum-sepolia", "base", "base-sepolia", "ethereum", "polygon"];
|
|
12
|
-
const SVM_NETWORKS = ["solana", "solana-devnet"];
|
|
13
|
-
const toCaip2 = (network) => {
|
|
14
|
-
const mapped = NETWORK_TO_CAIP2[network];
|
|
15
|
-
if (mapped !== void 0) {
|
|
16
|
-
return mapped;
|
|
17
|
-
}
|
|
18
|
-
if (network.includes(":")) {
|
|
19
|
-
return network;
|
|
20
|
-
}
|
|
21
|
-
throw new Error(`Unknown x402 network "${network}". Use a friendly name (${EVM_NETWORKS.join(", ")}, ${SVM_NETWORKS.join(", ")}) or a raw CAIP-2 id.`);
|
|
22
|
-
};
|
|
23
|
-
const isEvmNetwork = (network) => toCaip2(network).startsWith("eip155:");
|
|
24
|
-
const isSvmNetwork = (network) => toCaip2(network).startsWith("solana:");
|
|
25
|
-
|
|
26
|
-
export { EVM_NETWORKS, NETWORK_TO_CAIP2, SVM_NETWORKS, isEvmNetwork, isSvmNetwork, toCaip2 };
|
|
@@ -1,325 +0,0 @@
|
|
|
1
|
-
import { ClientEvmSigner } from '@x402/evm';
|
|
2
|
-
import { ClientSvmSigner } from '@x402/svm';
|
|
3
|
-
import { ProcessSettleSuccessResponse } from '@x402/core/http';
|
|
4
|
-
import { BeforePaymentCreationHook, PaymentPolicy, AfterPaymentCreationHook } from '@x402/core/client';
|
|
5
|
-
import { PaymentRequirements } from '@x402/core/types';
|
|
6
|
-
/**
|
|
7
|
-
* A normalised record of one settled x402 payment. The settled `amount` is kept
|
|
8
|
-
* as its exact on-chain atomic-unit string (USDC has 6 decimals) — never coerced
|
|
9
|
-
* to a fractional-dollar number — so no precision is lost crossing the reporting
|
|
10
|
-
* seam.
|
|
11
|
-
*/
|
|
12
|
-
interface X402Receipt {
|
|
13
|
-
/** Settled amount in the asset's atomic base units (USDC: 6 decimals), as an exact string. */
|
|
14
|
-
readonly amount: string;
|
|
15
|
-
/** The settled asset's contract / mint address (e.g. Base USDC). */
|
|
16
|
-
readonly asset: string;
|
|
17
|
-
/** The payer's wallet address, when the facilitator reports it. */
|
|
18
|
-
readonly from: string | undefined;
|
|
19
|
-
/** The settlement network as a CAIP-2 id (e.g. `eip155:8453`). */
|
|
20
|
-
readonly network: string;
|
|
21
|
-
/** The gated resource this payment bought (a URL, or a procedure's `file:function` id). */
|
|
22
|
-
readonly resource: string;
|
|
23
|
-
/** The payout wallet the funds settled to (the merchant recipient). */
|
|
24
|
-
readonly to: string;
|
|
25
|
-
/** When the receipt was produced (epoch milliseconds). */
|
|
26
|
-
readonly ts: number;
|
|
27
|
-
/** On-chain settlement transaction id / hash. */
|
|
28
|
-
readonly tx: string;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* A one-way, opt-in sink for settled-payment receipts. Wire it via
|
|
32
|
-
* `config.onReceipt`. It is best-effort telemetry — the middleware fires it after
|
|
33
|
-
* settlement, does not block the paid response on it, and swallows any error it
|
|
34
|
-
* throws — so a sink must never rely on being awaited or on its failures
|
|
35
|
-
* surfacing.
|
|
36
|
-
*/
|
|
37
|
-
type X402ReceiptSink = (receipt: X402Receipt) => Promise<void> | void;
|
|
38
|
-
/**
|
|
39
|
-
* Normalise a successful facilitator settlement into an {@link X402Receipt}.
|
|
40
|
-
* `resource` (the gated URL or procedure id) and `ts` are supplied by the caller —
|
|
41
|
-
* the settlement result carries neither. Prefers the actual settled `amount`
|
|
42
|
-
* (present for `upto`-scheme partial settlements) and falls back to the route's
|
|
43
|
-
* required amount for `exact`.
|
|
44
|
-
*/
|
|
45
|
-
declare const toReceipt: (settlement: ProcessSettleSuccessResponse, context: {
|
|
46
|
-
readonly resource: string;
|
|
47
|
-
readonly ts: number;
|
|
48
|
-
}) => X402Receipt;
|
|
49
|
-
/**
|
|
50
|
-
* A row for `@lunora/payment`'s durable `events` table. Deliberately a plain
|
|
51
|
-
* structural type — building one imports nothing from `@lunora/payment`, so the
|
|
52
|
-
* rails stay decoupled.
|
|
53
|
-
*/
|
|
54
|
-
interface PaymentEventRow {
|
|
55
|
-
/** Epoch milliseconds the settlement was recorded. */
|
|
56
|
-
readonly processedAt: number;
|
|
57
|
-
/** The rail that produced the event. */
|
|
58
|
-
readonly provider: "x402";
|
|
59
|
-
/** The settlement tx hash — the natural unique event id (the table is unique on `(provider, providerEventId)`). */
|
|
60
|
-
readonly providerEventId: string;
|
|
61
|
-
/** The event kind, namespaced to the x402 rail. */
|
|
62
|
-
readonly type: "x402.settled";
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Shape a receipt as a row for `@lunora/payment`'s durable `events` table, so a
|
|
66
|
-
* settled x402 payment shows in Studio's Payments panel (its recent-events card)
|
|
67
|
-
* with ZERO coupling: this returns a plain object matching that table's
|
|
68
|
-
* documented column contract (`provider` / `providerEventId` / `type` /
|
|
69
|
-
* `processedAt`, unique on `(provider, providerEventId)`) and imports nothing
|
|
70
|
-
* from `@lunora/payment`. Insert it from a mutation ctx:
|
|
71
|
-
*
|
|
72
|
-
* ```ts
|
|
73
|
-
* onReceipt: (receipt) => ctx.db.insert("events", toPaymentEventRow(receipt)),
|
|
74
|
-
* ```
|
|
75
|
-
*
|
|
76
|
-
* The source of truth for the column contract is `@lunora/payment`'s `events`
|
|
77
|
-
* table (`packages/payment/src/schema.ts`). Amount / from / to / resource are
|
|
78
|
-
* intentionally not on this row — that card renders none of them; read them off
|
|
79
|
-
* the {@link X402Receipt} (e.g. into your own revenue table) if you need them.
|
|
80
|
-
*/
|
|
81
|
-
declare const toPaymentEventRow: (receipt: X402Receipt) => PaymentEventRow;
|
|
82
|
-
/**
|
|
83
|
-
* Network identity for `@lunora/x402`.
|
|
84
|
-
*
|
|
85
|
-
* `@x402/core` v2 speaks **CAIP-2** chain ids (`eip155:8453` for Base,
|
|
86
|
-
* `solana:5eyk…` for Solana mainnet) — `type Network = ` `${string}:${string}` ``.
|
|
87
|
-
* Lunora keeps ergonomic **friendly** names (`"base"`, `"base-sepolia"`) as the
|
|
88
|
-
* public surface and maps them to CAIP-2 here, at the single seam where we hand a
|
|
89
|
-
* network to the SDK. A raw CAIP-2 string is also accepted as a power-user escape
|
|
90
|
-
* hatch (e.g. a chain we don't yet have a friendly alias for).
|
|
91
|
-
*
|
|
92
|
-
* The friendly set is intentionally scoped to chains `@x402/evm` / `@x402/svm`
|
|
93
|
-
* can settle the ergonomic `price:"$0.01"` path on out of the box (i.e. chains in
|
|
94
|
-
* their `DEFAULT_STABLECOINS` registry). Notably that excludes Optimism and
|
|
95
|
-
* Avalanche today — advertising them would 500 at settlement — so they are not
|
|
96
|
-
* friendly aliases; a caller who needs them can still pass a raw CAIP-2 id with an
|
|
97
|
-
* explicit asset.
|
|
98
|
-
*/
|
|
99
|
-
/** A CAIP-2 chain identifier, e.g. `"eip155:8453"` (Base) or `"solana:5eyk…"`. */
|
|
100
|
-
type Caip2 = `${string}:${string}`;
|
|
101
|
-
/** Friendly network names Lunora maps to CAIP-2 for `@x402/core`. */
|
|
102
|
-
type FriendlyNetwork = "arbitrum" | "arbitrum-sepolia" | "base" | "base-sepolia" | "ethereum" | "polygon" | "solana" | "solana-devnet";
|
|
103
|
-
/**
|
|
104
|
-
* A network Lunora can settle on: a {@link FriendlyNetwork} alias (mapped to
|
|
105
|
-
* CAIP-2 internally) or a raw {@link Caip2} id for chains without a friendly name.
|
|
106
|
-
*/
|
|
107
|
-
type X402Network = Caip2 | FriendlyNetwork;
|
|
108
|
-
/**
|
|
109
|
-
* Friendly name → CAIP-2 id. Values verified against `@x402/evm` and `@x402/svm`
|
|
110
|
-
* `DEFAULT_STABLECOINS` at 2.17.0. `base` / `base-sepolia` are the primary
|
|
111
|
-
* prod / test pair.
|
|
112
|
-
*/
|
|
113
|
-
declare const NETWORK_TO_CAIP2: {
|
|
114
|
-
readonly arbitrum: "eip155:42161";
|
|
115
|
-
readonly "arbitrum-sepolia": "eip155:421614";
|
|
116
|
-
readonly base: "eip155:8453";
|
|
117
|
-
readonly "base-sepolia": "eip155:84532";
|
|
118
|
-
readonly ethereum: "eip155:1";
|
|
119
|
-
readonly polygon: "eip155:137";
|
|
120
|
-
readonly solana: "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp";
|
|
121
|
-
readonly "solana-devnet": "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1";
|
|
122
|
-
};
|
|
123
|
-
/** EVM friendly networks (signed via `@x402/evm` + viem). */
|
|
124
|
-
declare const EVM_NETWORKS: readonly ["arbitrum", "arbitrum-sepolia", "base", "base-sepolia", "ethereum", "polygon"];
|
|
125
|
-
/** Solana friendly networks (signed via `@x402/svm`). */
|
|
126
|
-
declare const SVM_NETWORKS: readonly ["solana", "solana-devnet"];
|
|
127
|
-
/**
|
|
128
|
-
* Resolve a network to its CAIP-2 id. Friendly aliases are looked up; a value
|
|
129
|
-
* that already looks like CAIP-2 (`namespace:reference`) passes through.
|
|
130
|
-
*/
|
|
131
|
-
declare const toCaip2: (network: X402Network) => Caip2;
|
|
132
|
-
/** True when `network` settles on an EVM chain (viem signer path). */
|
|
133
|
-
declare const isEvmNetwork: (network: X402Network) => boolean;
|
|
134
|
-
/** True when `network` settles on Solana (`@x402/svm` signer path). */
|
|
135
|
-
declare const isSvmNetwork: (network: X402Network) => boolean;
|
|
136
|
-
/**
|
|
137
|
-
* USDC — and every asset in `@x402/evm` / `@x402/svm`'s `DEFAULT_STABLECOINS` —
|
|
138
|
-
* uses 6 decimals, so a USD price converts to atomic base units at `10 ** 6`.
|
|
139
|
-
* Override per {@link SpendPolicy.decimals} only for a custom, non-6-decimal asset.
|
|
140
|
-
*/
|
|
141
|
-
declare const DEFAULT_STABLECOIN_DECIMALS = 6;
|
|
142
|
-
/**
|
|
143
|
-
* Spend limits and approval gates for an agent wallet. At least one bound must be
|
|
144
|
-
* set — see {@link assertBoundedPolicy} — or the pay rail refuses to build.
|
|
145
|
-
*
|
|
146
|
-
* Caps are denominated in USD (the stablecoin's dollar value); addresses and
|
|
147
|
-
* networks are matched against the requirement the server offers.
|
|
148
|
-
*/
|
|
149
|
-
interface SpendPolicy {
|
|
150
|
-
/** Network allowlist. When set, only these networks may be paid on. */
|
|
151
|
-
readonly allowedNetworks?: ReadonlyArray<X402Network>;
|
|
152
|
-
/** Recipient allowlist. When set, only these `payTo` addresses may be paid. */
|
|
153
|
-
readonly allowedRecipients?: ReadonlyArray<string>;
|
|
154
|
-
/** Stablecoin decimals for USD→atomic conversion (default {@link DEFAULT_STABLECOIN_DECIMALS}). */
|
|
155
|
-
readonly decimals?: number;
|
|
156
|
-
/** Hard ceiling on a single payment, in USD. */
|
|
157
|
-
readonly maxPerCall?: X402Price;
|
|
158
|
-
/** Hard ceiling on cumulative spend across this wallet's lifetime, in USD. */
|
|
159
|
-
readonly maxPerRun?: X402Price;
|
|
160
|
-
/**
|
|
161
|
-
* Approval gate. Called with the selected requirement before signing; return
|
|
162
|
-
* `false` (or reject) to refuse the payment. Use for human-in-the-loop or any
|
|
163
|
-
* dynamic rule the static caps can't express.
|
|
164
|
-
*/
|
|
165
|
-
readonly onPaymentRequired?: (requirement: PaymentRequirements) => Promise<boolean> | boolean;
|
|
166
|
-
}
|
|
167
|
-
/** A running spend ledger the per-run cap is measured against; the guard reads it, the recorder adds to it. */
|
|
168
|
-
interface SpendState {
|
|
169
|
-
/** Add a just-committed payment (atomic base units) to the total. */
|
|
170
|
-
readonly add: (amount: bigint) => void;
|
|
171
|
-
/** Cumulative spend so far, in atomic base units. */
|
|
172
|
-
readonly spentAtomic: bigint;
|
|
173
|
-
}
|
|
174
|
-
/** A fresh spend ledger. One per wallet instance; the guard + recorder share it. */
|
|
175
|
-
declare const createSpendState: () => SpendState;
|
|
176
|
-
/**
|
|
177
|
-
* Convert a USD amount (`0.01`, `"0.01"`, or the `"$0.01"` shorthand) to atomic
|
|
178
|
-
* stablecoin base units, exactly — parsed digit-by-digit so no binary-float drift
|
|
179
|
-
* can round a cap the wrong way. Throws on a malformed amount (including
|
|
180
|
-
* exponential notation like `"1e-7"`, which a decimal string never needs).
|
|
181
|
-
*/
|
|
182
|
-
declare const usdToAtomic: (usd: X402Price, decimals?: number) => bigint;
|
|
183
|
-
/**
|
|
184
|
-
* A `PaymentPolicy` that narrows the server's offered requirements to those a
|
|
185
|
-
* bounded wallet may pay: within the per-call cap, to an allowed recipient, on an
|
|
186
|
-
* allowed network. An empty result means the client cannot pay — fail-closed.
|
|
187
|
-
*/
|
|
188
|
-
declare const buildSpendPolicy: (policy: SpendPolicy) => PaymentPolicy;
|
|
189
|
-
/**
|
|
190
|
-
* A `BeforePaymentCreationHook` enforcing the stateful bounds the stateless
|
|
191
|
-
* {@link buildSpendPolicy} filter can't: the cumulative per-run cap and the async
|
|
192
|
-
* confirmation gate. Aborts (no signature) when either would be violated.
|
|
193
|
-
*/
|
|
194
|
-
declare const buildPaymentGuard: (policy: SpendPolicy, state: SpendState) => BeforePaymentCreationHook;
|
|
195
|
-
/**
|
|
196
|
-
* An `AfterPaymentCreationHook` that adds the just-created payment to `state`, so
|
|
197
|
-
* the next {@link buildPaymentGuard} call measures the per-run cap against it.
|
|
198
|
-
*/
|
|
199
|
-
declare const recordSpend: (state: SpendState) => AfterPaymentCreationHook;
|
|
200
|
-
/**
|
|
201
|
-
* Guard at wallet-build time: refuse a policy with no bound whatsoever. Signing
|
|
202
|
-
* money on an agent's behalf with unlimited spend authority is never the intent,
|
|
203
|
-
* so this fails loudly rather than defaulting to unbounded.
|
|
204
|
-
*/
|
|
205
|
-
declare const assertBoundedPolicy: (policy: SpendPolicy) => void;
|
|
206
|
-
/**
|
|
207
|
-
* The public, Coinbase-operated facilitator (verify + settle). It needs no API
|
|
208
|
-
* key. Override with a self-hosted or CDP facilitator via {@link FacilitatorConfig}.
|
|
209
|
-
*/
|
|
210
|
-
declare const DEFAULT_FACILITATOR_URL = "https://x402.org/facilitator";
|
|
211
|
-
/** How to reach a facilitator's `/verify` + `/settle` endpoints. */
|
|
212
|
-
interface FacilitatorConfig {
|
|
213
|
-
/** Extra headers for a private facilitator (e.g. a CDP bearer token). */
|
|
214
|
-
readonly headers?: Record<string, string>;
|
|
215
|
-
/** Base URL. Defaults to {@link DEFAULT_FACILITATOR_URL}. */
|
|
216
|
-
readonly url?: string;
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* A resource's price, as a USD-denominated decimal string (`"0.01"`, or the
|
|
220
|
-
* `"$0.01"` shorthand) or a number of dollars (`0.01`). The scheme resolves it
|
|
221
|
-
* to the network's stablecoin base units (USDC has 6 decimals) at challenge
|
|
222
|
-
* time. (Kept `number | string` rather than a `` `$${string}` `` template
|
|
223
|
-
* member — the template is subsumed by `string`, so it only adds noise.)
|
|
224
|
-
*/
|
|
225
|
-
type X402Price = number | string;
|
|
226
|
-
/** An EVM recipient address (the merchant wallet that receives settlement). */
|
|
227
|
-
type EvmAddress = `0x${string}`;
|
|
228
|
-
/** Recipient wallet the facilitator settles payments to, per network family. */
|
|
229
|
-
interface X402Recipient {
|
|
230
|
-
/** EVM payout address (required for EVM networks). */
|
|
231
|
-
readonly evm?: EvmAddress;
|
|
232
|
-
/** Solana payout address, base58 (required for SVM networks). */
|
|
233
|
-
readonly svm?: string;
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* Server-side (charge rail) config. The server needs only a **recipient
|
|
237
|
-
* address** — no private key — because the facilitator performs settlement.
|
|
238
|
-
*/
|
|
239
|
-
interface X402ChargeConfig {
|
|
240
|
-
readonly facilitator?: FacilitatorConfig;
|
|
241
|
-
/** Network this resource settles on. */
|
|
242
|
-
readonly network: X402Network;
|
|
243
|
-
/**
|
|
244
|
-
* Opt-in, one-way telemetry sink fired once per settled payment. Best-effort:
|
|
245
|
-
* it runs after settlement, never blocks the paid response, and its errors are
|
|
246
|
-
* swallowed. Use it to mirror x402 revenue into a durable table / `@lunora/payment`'s
|
|
247
|
-
* `events` table (see `toPaymentEventRow`) so it surfaces in Studio.
|
|
248
|
-
*/
|
|
249
|
-
readonly onReceipt?: X402ReceiptSink;
|
|
250
|
-
/** Default price for a gated resource; per-resource overrides win. */
|
|
251
|
-
readonly price: X402Price;
|
|
252
|
-
/** Payout wallet(s). */
|
|
253
|
-
readonly recipient: X402Recipient;
|
|
254
|
-
}
|
|
255
|
-
/**
|
|
256
|
-
* Client-side (pay rail) config. The signer holds spending authority, so the
|
|
257
|
-
* pay rail is ActionCtx-only and MUST be paired with a spend `policy` — the pay
|
|
258
|
-
* rail refuses to build if the policy is unbounded.
|
|
259
|
-
*/
|
|
260
|
-
interface X402PayConfig {
|
|
261
|
-
/** Network to transact on. Determines the signer family (EVM vs SVM). */
|
|
262
|
-
readonly network: X402Network;
|
|
263
|
-
/** Mandatory spend limits + approval gates. An unbounded policy is refused. */
|
|
264
|
-
readonly policy: SpendPolicy;
|
|
265
|
-
/** How the agent wallet is custodied (raw key, a user-supplied signer, or CDP-managed). */
|
|
266
|
-
readonly signer: X402SignerConfig;
|
|
267
|
-
}
|
|
268
|
-
/**
|
|
269
|
-
* CDP-managed wallet custody via `@coinbase/cdp-sdk` (an optional peer). The SDK
|
|
270
|
-
* gets-or-creates a named server account and signs the x402 EIP-712 payment
|
|
271
|
-
* authorization with it — no private key ever leaves Coinbase. Needs three CDP
|
|
272
|
-
* credentials, read from `ctx.secrets` under names that default to the SDK's own
|
|
273
|
-
* env-var names; override them if your secrets are named differently. (Note
|
|
274
|
-
* `@coinbase/x402` is a facilitator-auth helper, not a signer provider — CDP
|
|
275
|
-
* custody is `@coinbase/cdp-sdk`.) EVM only today; for CDP on Solana, build a
|
|
276
|
-
* `@solana/kit` signer around your CDP account and pass it via the `"signer"`
|
|
277
|
-
* escape hatch.
|
|
278
|
-
*/
|
|
279
|
-
interface X402CdpSignerConfig {
|
|
280
|
-
/** CDP account name to get-or-create and sign with. */
|
|
281
|
-
readonly account: string;
|
|
282
|
-
/** `ctx.secrets` name for the CDP API key id. Default `"CDP_API_KEY_ID"`. */
|
|
283
|
-
readonly apiKeyIdSecretName?: string;
|
|
284
|
-
/** `ctx.secrets` name for the CDP API key secret. Default `"CDP_API_KEY_SECRET"`. */
|
|
285
|
-
readonly apiKeySecretName?: string;
|
|
286
|
-
readonly type: "cdp";
|
|
287
|
-
/** `ctx.secrets` name for the CDP wallet secret. Default `"CDP_WALLET_SECRET"`. */
|
|
288
|
-
readonly walletSecretName?: string;
|
|
289
|
-
}
|
|
290
|
-
/**
|
|
291
|
-
* Wallet custody for the pay rail — three shapes.
|
|
292
|
-
*
|
|
293
|
-
* `"raw-key"` resolves a private key from `ctx.secrets` (viem for EVM, a
|
|
294
|
-
* `@solana/kit` keypair for Solana) — simplest, self-custodied.
|
|
295
|
-
*
|
|
296
|
-
* `"signer"` is the escape hatch: hand in a signer you already built — any
|
|
297
|
-
* `@x402/evm` `ClientEvmSigner` (a viem account from Turnkey, Privy, an AWS/GCP
|
|
298
|
-
* KMS `toAccount`, CDP's viem adapter, …) on an EVM network, or an `@x402/svm`
|
|
299
|
-
* `ClientSvmSigner` (a `@solana/kit` `TransactionSigner`) on Solana. Adapt any
|
|
300
|
-
* custody provider to the structural signer and pass it here; `@lunora/x402`
|
|
301
|
-
* takes no dependency on the provider's SDK.
|
|
302
|
-
*
|
|
303
|
-
* `"cdp"` is a Coinbase-managed wallet via `@coinbase/cdp-sdk`
|
|
304
|
-
* ({@link X402CdpSignerConfig}).
|
|
305
|
-
*
|
|
306
|
-
* Wired today: raw-key (EVM + SVM), the user-supplied signer (both families),
|
|
307
|
-
* and CDP-managed EVM custody. CDP on Solana is not yet wired — use the escape
|
|
308
|
-
* hatch.
|
|
309
|
-
*/
|
|
310
|
-
type X402SignerConfig = X402CdpSignerConfig | {
|
|
311
|
-
/** Name of the `ctx.secrets` entry holding the private key. */
|
|
312
|
-
readonly secretName: string;
|
|
313
|
-
readonly type: "raw-key";
|
|
314
|
-
} | {
|
|
315
|
-
/**
|
|
316
|
-
* A pre-built signer you own: an EVM `ClientEvmSigner` (viem account) on
|
|
317
|
-
* an EVM network, or an SVM `ClientSvmSigner` (`@solana/kit`
|
|
318
|
-
* `TransactionSigner`) on Solana. Must match the config `network`'s family.
|
|
319
|
-
*/
|
|
320
|
-
readonly signer: ClientEvmSigner | ClientSvmSigner;
|
|
321
|
-
readonly type: "signer";
|
|
322
|
-
};
|
|
323
|
-
/** Resolve a facilitator's base URL, applying the public default. */
|
|
324
|
-
declare const resolveFacilitatorUrl: (facilitator?: FacilitatorConfig) => string;
|
|
325
|
-
export { Caip2 as C, DEFAULT_FACILITATOR_URL as D, EVM_NETWORKS as E, FacilitatorConfig as F, NETWORK_TO_CAIP2 as N, PaymentEventRow as P, SVM_NETWORKS as S, X402CdpSignerConfig as X, EvmAddress as a, FriendlyNetwork as b, X402ChargeConfig as c, X402Network as d, X402PayConfig as e, X402Price as f, X402Receipt as g, X402ReceiptSink as h, X402Recipient as i, X402SignerConfig as j, isEvmNetwork as k, isSvmNetwork as l, DEFAULT_STABLECOIN_DECIMALS as m, SpendPolicy as n, SpendState as o, assertBoundedPolicy as p, buildPaymentGuard as q, resolveFacilitatorUrl as r, buildSpendPolicy as s, toCaip2 as t, createSpendState as u, recordSpend as v, usdToAtomic as w, toPaymentEventRow as x, toReceipt as y };
|