moltspay 1.5.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +143 -0
- package/dist/cdp/index.js.map +1 -1
- package/dist/cdp/index.mjs.map +1 -1
- package/dist/{cdp-DeohBe1o.d.ts → cdp-B5PhDUTC.d.ts} +1 -1
- package/dist/{cdp-p_eHuQpb.d.mts → cdp-D-5Hg3y_.d.mts} +1 -1
- package/dist/chains/index.d.mts +37 -1
- package/dist/chains/index.d.ts +37 -1
- package/dist/chains/index.js +22 -0
- package/dist/chains/index.js.map +1 -1
- package/dist/chains/index.mjs +19 -0
- package/dist/chains/index.mjs.map +1 -1
- package/dist/cli/index.js +1941 -204
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/index.mjs +1938 -201
- package/dist/cli/index.mjs.map +1 -1
- package/dist/client/index.d.mts +46 -0
- package/dist/client/index.d.ts +46 -0
- package/dist/client/index.js +1059 -118
- package/dist/client/index.js.map +1 -1
- package/dist/client/index.mjs +1055 -116
- package/dist/client/index.mjs.map +1 -1
- package/dist/client/web/index.d.mts +434 -0
- package/dist/client/web/index.mjs +1300 -0
- package/dist/client/web/index.mjs.map +1 -0
- package/dist/facilitators/index.d.mts +185 -6
- package/dist/facilitators/index.d.ts +185 -6
- package/dist/facilitators/index.js +497 -13
- package/dist/facilitators/index.js.map +1 -1
- package/dist/facilitators/index.mjs +492 -13
- package/dist/facilitators/index.mjs.map +1 -1
- package/dist/index.d.mts +77 -2
- package/dist/index.d.ts +77 -2
- package/dist/index.js +1865 -172
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1854 -167
- package/dist/index.mjs.map +1 -1
- package/dist/mcp/index.js +1062 -123
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/index.mjs +1059 -120
- package/dist/mcp/index.mjs.map +1 -1
- package/dist/{registry-OsEO2dOu.d.mts → registry-DIo0WNoO.d.mts} +8 -1
- package/dist/{registry-OsEO2dOu.d.ts → registry-DIo0WNoO.d.ts} +8 -1
- package/dist/server/index.d.mts +137 -2
- package/dist/server/index.d.ts +137 -2
- package/dist/server/index.js +757 -30
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +757 -30
- package/dist/server/index.mjs.map +1 -1
- package/dist/verify/index.js.map +1 -1
- package/dist/verify/index.mjs.map +1 -1
- package/dist/wallet/index.js.map +1 -1
- package/dist/wallet/index.mjs.map +1 -1
- package/package.json +15 -2
- package/schemas/moltspay.services.schema.json +100 -6
- package/scripts/postinstall.js +91 -0
package/dist/client/index.d.mts
CHANGED
|
@@ -10,6 +10,13 @@ interface ClientConfig {
|
|
|
10
10
|
maxPerTx: number;
|
|
11
11
|
maxPerDay: number;
|
|
12
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* Ordered rail preference (2.0.0). When the server's 402 offers more than
|
|
15
|
+
* one rail (e.g. USDC on Base AND CNY via Alipay) and the caller didn't
|
|
16
|
+
* pass an explicit `rail`, the first entry here that the server also
|
|
17
|
+
* accepts wins. e.g. `["base", "alipay"]`.
|
|
18
|
+
*/
|
|
19
|
+
railPreference?: string[];
|
|
13
20
|
}
|
|
14
21
|
interface WalletData {
|
|
15
22
|
address: string;
|
|
@@ -62,6 +69,10 @@ interface VerifyResponse {
|
|
|
62
69
|
}
|
|
63
70
|
interface MoltsPayClientOptions {
|
|
64
71
|
configDir?: string;
|
|
72
|
+
/** Ordered rail preference; see {@link ClientConfig.railPreference}. */
|
|
73
|
+
railPreference?: string[];
|
|
74
|
+
/** Stable Alipay session id (else AIPAY_SESSION_ID, else a fresh UUID). */
|
|
75
|
+
alipaySessionId?: string;
|
|
65
76
|
}
|
|
66
77
|
|
|
67
78
|
/**
|
|
@@ -84,14 +95,35 @@ interface PayOptions {
|
|
|
84
95
|
chain?: 'base' | 'polygon' | 'base_sepolia' | 'tempo_moderato' | 'bnb' | 'bnb_testnet' | 'solana' | 'solana_devnet';
|
|
85
96
|
/** Send raw data at top level instead of wrapped in { params } */
|
|
86
97
|
rawData?: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Explicit payment rail (2.0.0): `'alipay'` or a chain name. When set,
|
|
100
|
+
* routing skips the default crypto path. `'alipay'` dispatches to the
|
|
101
|
+
* alipay-bot-backed {@link AlipayClient} and needs no EVM wallet.
|
|
102
|
+
*/
|
|
103
|
+
rail?: string;
|
|
104
|
+
/** Alipay: surfaced once the payment URL + tradeNo are known. */
|
|
105
|
+
onPaymentPending?: (info: {
|
|
106
|
+
paymentUrl: string;
|
|
107
|
+
shortenUrl?: string;
|
|
108
|
+
tradeNo: string;
|
|
109
|
+
}) => void;
|
|
110
|
+
/** Alipay: forward CLI output to the user verbatim (line by line). */
|
|
111
|
+
onLine?: (line: string) => void;
|
|
112
|
+
/** Alipay: overall budget; defaults to the challenge's pay_before window. */
|
|
113
|
+
timeoutMs?: number;
|
|
114
|
+
/** Cancellation (alipay poll loop). */
|
|
115
|
+
signal?: AbortSignal;
|
|
87
116
|
}
|
|
88
117
|
declare class MoltsPayClient {
|
|
89
118
|
private configDir;
|
|
90
119
|
private config;
|
|
91
120
|
private walletData;
|
|
92
121
|
private wallet;
|
|
122
|
+
private signer;
|
|
93
123
|
private todaySpending;
|
|
94
124
|
private lastSpendingReset;
|
|
125
|
+
private railPreference?;
|
|
126
|
+
private alipaySessionId?;
|
|
95
127
|
constructor(options?: MoltsPayClientOptions);
|
|
96
128
|
/**
|
|
97
129
|
* Check if client is initialized (has wallet)
|
|
@@ -129,6 +161,16 @@ declare class MoltsPayClient {
|
|
|
129
161
|
* @param options - Payment options (token selection)
|
|
130
162
|
*/
|
|
131
163
|
pay(serverUrl: string, service: string, params: Record<string, any>, options?: PayOptions): Promise<Record<string, any>>;
|
|
164
|
+
/**
|
|
165
|
+
* Pay for a service over the Alipay fiat rail (2.0.0).
|
|
166
|
+
*
|
|
167
|
+
* Unlike the crypto path this needs no EVM wallet — it shells out to
|
|
168
|
+
* alipay-bot via {@link AlipayClient}. Flow: hit the resource with no
|
|
169
|
+
* payment to get the 402 challenge, confirm the server actually offers the
|
|
170
|
+
* alipay rail (selectRail), then run the 8-step state machine and return the
|
|
171
|
+
* resource body.
|
|
172
|
+
*/
|
|
173
|
+
private payViaAlipay;
|
|
132
174
|
/**
|
|
133
175
|
* Handle MPP (Machine Payments Protocol) payment flow
|
|
134
176
|
* Called when pay() detects WWW-Authenticate header in 402 response
|
|
@@ -161,6 +203,10 @@ declare class MoltsPayClient {
|
|
|
161
203
|
* Sign EIP-3009 transferWithAuthorization (GASLESS)
|
|
162
204
|
* This only signs - no on-chain transaction, no gas needed.
|
|
163
205
|
* Supports both USDC and USDT.
|
|
206
|
+
*
|
|
207
|
+
* Delegates typed-data construction to `core/eip3009.ts` and the signature
|
|
208
|
+
* itself to `this.signer`. That way Web Client (Phase 4) can reuse the same
|
|
209
|
+
* flow with an EIP-1193 signer without duplicating typed-data layout.
|
|
164
210
|
*/
|
|
165
211
|
private signEIP3009;
|
|
166
212
|
/**
|
package/dist/client/index.d.ts
CHANGED
|
@@ -10,6 +10,13 @@ interface ClientConfig {
|
|
|
10
10
|
maxPerTx: number;
|
|
11
11
|
maxPerDay: number;
|
|
12
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* Ordered rail preference (2.0.0). When the server's 402 offers more than
|
|
15
|
+
* one rail (e.g. USDC on Base AND CNY via Alipay) and the caller didn't
|
|
16
|
+
* pass an explicit `rail`, the first entry here that the server also
|
|
17
|
+
* accepts wins. e.g. `["base", "alipay"]`.
|
|
18
|
+
*/
|
|
19
|
+
railPreference?: string[];
|
|
13
20
|
}
|
|
14
21
|
interface WalletData {
|
|
15
22
|
address: string;
|
|
@@ -62,6 +69,10 @@ interface VerifyResponse {
|
|
|
62
69
|
}
|
|
63
70
|
interface MoltsPayClientOptions {
|
|
64
71
|
configDir?: string;
|
|
72
|
+
/** Ordered rail preference; see {@link ClientConfig.railPreference}. */
|
|
73
|
+
railPreference?: string[];
|
|
74
|
+
/** Stable Alipay session id (else AIPAY_SESSION_ID, else a fresh UUID). */
|
|
75
|
+
alipaySessionId?: string;
|
|
65
76
|
}
|
|
66
77
|
|
|
67
78
|
/**
|
|
@@ -84,14 +95,35 @@ interface PayOptions {
|
|
|
84
95
|
chain?: 'base' | 'polygon' | 'base_sepolia' | 'tempo_moderato' | 'bnb' | 'bnb_testnet' | 'solana' | 'solana_devnet';
|
|
85
96
|
/** Send raw data at top level instead of wrapped in { params } */
|
|
86
97
|
rawData?: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Explicit payment rail (2.0.0): `'alipay'` or a chain name. When set,
|
|
100
|
+
* routing skips the default crypto path. `'alipay'` dispatches to the
|
|
101
|
+
* alipay-bot-backed {@link AlipayClient} and needs no EVM wallet.
|
|
102
|
+
*/
|
|
103
|
+
rail?: string;
|
|
104
|
+
/** Alipay: surfaced once the payment URL + tradeNo are known. */
|
|
105
|
+
onPaymentPending?: (info: {
|
|
106
|
+
paymentUrl: string;
|
|
107
|
+
shortenUrl?: string;
|
|
108
|
+
tradeNo: string;
|
|
109
|
+
}) => void;
|
|
110
|
+
/** Alipay: forward CLI output to the user verbatim (line by line). */
|
|
111
|
+
onLine?: (line: string) => void;
|
|
112
|
+
/** Alipay: overall budget; defaults to the challenge's pay_before window. */
|
|
113
|
+
timeoutMs?: number;
|
|
114
|
+
/** Cancellation (alipay poll loop). */
|
|
115
|
+
signal?: AbortSignal;
|
|
87
116
|
}
|
|
88
117
|
declare class MoltsPayClient {
|
|
89
118
|
private configDir;
|
|
90
119
|
private config;
|
|
91
120
|
private walletData;
|
|
92
121
|
private wallet;
|
|
122
|
+
private signer;
|
|
93
123
|
private todaySpending;
|
|
94
124
|
private lastSpendingReset;
|
|
125
|
+
private railPreference?;
|
|
126
|
+
private alipaySessionId?;
|
|
95
127
|
constructor(options?: MoltsPayClientOptions);
|
|
96
128
|
/**
|
|
97
129
|
* Check if client is initialized (has wallet)
|
|
@@ -129,6 +161,16 @@ declare class MoltsPayClient {
|
|
|
129
161
|
* @param options - Payment options (token selection)
|
|
130
162
|
*/
|
|
131
163
|
pay(serverUrl: string, service: string, params: Record<string, any>, options?: PayOptions): Promise<Record<string, any>>;
|
|
164
|
+
/**
|
|
165
|
+
* Pay for a service over the Alipay fiat rail (2.0.0).
|
|
166
|
+
*
|
|
167
|
+
* Unlike the crypto path this needs no EVM wallet — it shells out to
|
|
168
|
+
* alipay-bot via {@link AlipayClient}. Flow: hit the resource with no
|
|
169
|
+
* payment to get the 402 challenge, confirm the server actually offers the
|
|
170
|
+
* alipay rail (selectRail), then run the 8-step state machine and return the
|
|
171
|
+
* resource body.
|
|
172
|
+
*/
|
|
173
|
+
private payViaAlipay;
|
|
132
174
|
/**
|
|
133
175
|
* Handle MPP (Machine Payments Protocol) payment flow
|
|
134
176
|
* Called when pay() detects WWW-Authenticate header in 402 response
|
|
@@ -161,6 +203,10 @@ declare class MoltsPayClient {
|
|
|
161
203
|
* Sign EIP-3009 transferWithAuthorization (GASLESS)
|
|
162
204
|
* This only signs - no on-chain transaction, no gas needed.
|
|
163
205
|
* Supports both USDC and USDT.
|
|
206
|
+
*
|
|
207
|
+
* Delegates typed-data construction to `core/eip3009.ts` and the signature
|
|
208
|
+
* itself to `this.signer`. That way Web Client (Phase 4) can reuse the same
|
|
209
|
+
* flow with an EIP-1193 signer without duplicating typed-data layout.
|
|
164
210
|
*/
|
|
165
211
|
private signEIP3009;
|
|
166
212
|
/**
|