moltspay 1.2.1 → 1.4.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 +292 -34
- package/dist/cdp/index.d.mts +4 -4
- package/dist/cdp/index.d.ts +4 -4
- package/dist/cdp/index.js +110 -30368
- package/dist/cdp/index.js.map +1 -1
- package/dist/cdp/index.mjs +94 -30360
- package/dist/cdp/index.mjs.map +1 -1
- package/dist/cdp-DeohBe1o.d.ts +66 -0
- package/dist/cdp-p_eHuQpb.d.mts +66 -0
- package/dist/chains/index.d.mts +9 -8
- package/dist/chains/index.d.ts +9 -8
- package/dist/chains/index.js +86 -0
- package/dist/chains/index.js.map +1 -1
- package/dist/chains/index.mjs +86 -0
- package/dist/chains/index.mjs.map +1 -1
- package/dist/cli/index.js +2746 -290
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/index.mjs +2752 -282
- package/dist/cli/index.mjs.map +1 -1
- package/dist/client/index.d.mts +60 -4
- package/dist/client/index.d.ts +60 -4
- package/dist/client/index.js +734 -43
- package/dist/client/index.js.map +1 -1
- package/dist/client/index.mjs +732 -41
- package/dist/client/index.mjs.map +1 -1
- package/dist/facilitators/index.d.mts +220 -39
- package/dist/facilitators/index.d.ts +220 -39
- package/dist/facilitators/index.js +897 -1
- package/dist/facilitators/index.js.map +1 -1
- package/dist/facilitators/index.mjs +902 -1
- package/dist/facilitators/index.mjs.map +1 -1
- package/dist/{index-DgJPZMBG.d.mts → index-D_2FkLwV.d.mts} +6 -2
- package/dist/{index-DgJPZMBG.d.ts → index-D_2FkLwV.d.ts} +6 -2
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2238 -30837
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2167 -30766
- package/dist/index.mjs.map +1 -1
- package/dist/server/index.d.mts +30 -3
- package/dist/server/index.d.ts +30 -3
- package/dist/server/index.js +1345 -54
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +1355 -54
- package/dist/server/index.mjs.map +1 -1
- package/dist/verify/index.d.mts +1 -1
- package/dist/verify/index.d.ts +1 -1
- package/dist/verify/index.js +86 -0
- package/dist/verify/index.js.map +1 -1
- package/dist/verify/index.mjs +86 -0
- package/dist/verify/index.mjs.map +1 -1
- package/dist/wallet/index.d.mts +3 -3
- package/dist/wallet/index.d.ts +3 -3
- package/dist/wallet/index.js +86 -0
- package/dist/wallet/index.js.map +1 -1
- package/dist/wallet/index.mjs +86 -0
- package/dist/wallet/index.mjs.map +1 -1
- package/package.json +8 -2
- package/schemas/moltspay.services.schema.json +27 -132
package/dist/client/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Wallet } from 'ethers';
|
|
2
|
+
import { T as TokenSymbol } from '../index-D_2FkLwV.mjs';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* MoltsPay Client Types
|
|
@@ -78,8 +79,8 @@ interface PayOptions {
|
|
|
78
79
|
token?: TokenSymbol;
|
|
79
80
|
/** Auto-select token based on balance (default: false) */
|
|
80
81
|
autoSelect?: boolean;
|
|
81
|
-
/** Chain to pay on
|
|
82
|
-
chain?: 'base' | 'polygon' | 'base_sepolia';
|
|
82
|
+
/** Chain to pay on */
|
|
83
|
+
chain?: 'base' | 'polygon' | 'base_sepolia' | 'tempo_moderato' | 'bnb' | 'bnb_testnet' | 'solana' | 'solana_devnet';
|
|
83
84
|
}
|
|
84
85
|
declare class MoltsPayClient {
|
|
85
86
|
private configDir;
|
|
@@ -97,6 +98,10 @@ declare class MoltsPayClient {
|
|
|
97
98
|
* Get wallet address
|
|
98
99
|
*/
|
|
99
100
|
get address(): string | null;
|
|
101
|
+
/**
|
|
102
|
+
* Get wallet instance (for direct operations like approvals)
|
|
103
|
+
*/
|
|
104
|
+
getWallet(): Wallet | null;
|
|
100
105
|
/**
|
|
101
106
|
* Get current config
|
|
102
107
|
*/
|
|
@@ -121,6 +126,34 @@ declare class MoltsPayClient {
|
|
|
121
126
|
* @param options - Payment options (token selection)
|
|
122
127
|
*/
|
|
123
128
|
pay(serverUrl: string, service: string, params: Record<string, any>, options?: PayOptions): Promise<Record<string, any>>;
|
|
129
|
+
/**
|
|
130
|
+
* Handle MPP (Machine Payments Protocol) payment flow
|
|
131
|
+
* Called when pay() detects WWW-Authenticate header in 402 response
|
|
132
|
+
*/
|
|
133
|
+
private handleMPPPayment;
|
|
134
|
+
/**
|
|
135
|
+
* Handle BNB Chain payment flow (pre-approval + intent signature)
|
|
136
|
+
*
|
|
137
|
+
* Flow:
|
|
138
|
+
* 1. Check client has approved server wallet (done via `moltspay init`)
|
|
139
|
+
* 2. Sign EIP-712 payment intent (no gas, just signature)
|
|
140
|
+
* 3. Send intent to server
|
|
141
|
+
* 4. Server executes service
|
|
142
|
+
* 5. Server calls transferFrom if successful (pay-for-success)
|
|
143
|
+
*/
|
|
144
|
+
private handleBNBPayment;
|
|
145
|
+
/**
|
|
146
|
+
* Handle Solana payment flow
|
|
147
|
+
*
|
|
148
|
+
* Solana uses SPL token transfers with pay-for-success model:
|
|
149
|
+
* 1. Client creates and signs a transfer transaction
|
|
150
|
+
* 2. Server submits the transaction after service completes
|
|
151
|
+
*/
|
|
152
|
+
private handleSolanaPayment;
|
|
153
|
+
/**
|
|
154
|
+
* Check ERC20 allowance for a spender
|
|
155
|
+
*/
|
|
156
|
+
private checkAllowance;
|
|
124
157
|
/**
|
|
125
158
|
* Sign EIP-3009 transferWithAuthorization (GASLESS)
|
|
126
159
|
* This only signs - no on-chain transaction, no gas needed.
|
|
@@ -166,13 +199,36 @@ declare class MoltsPayClient {
|
|
|
166
199
|
native: number;
|
|
167
200
|
}>;
|
|
168
201
|
/**
|
|
169
|
-
* Get wallet balances on all supported chains (Base + Polygon)
|
|
202
|
+
* Get wallet balances on all supported chains (Base + Polygon + Tempo)
|
|
170
203
|
*/
|
|
171
204
|
getAllBalances(): Promise<Record<string, {
|
|
172
205
|
usdc: number;
|
|
173
206
|
usdt: number;
|
|
174
207
|
native: number;
|
|
208
|
+
tempo?: {
|
|
209
|
+
pathUSD: number;
|
|
210
|
+
alphaUSD: number;
|
|
211
|
+
betaUSD: number;
|
|
212
|
+
thetaUSD: number;
|
|
213
|
+
};
|
|
175
214
|
}>>;
|
|
215
|
+
/**
|
|
216
|
+
* Pay for a service using MPP (Machine Payments Protocol)
|
|
217
|
+
*
|
|
218
|
+
* This implements the MPP flow manually for EOA wallets:
|
|
219
|
+
* 1. Request service → get 402 with WWW-Authenticate
|
|
220
|
+
* 2. Parse payment requirements
|
|
221
|
+
* 3. Execute transfer on Tempo chain
|
|
222
|
+
* 4. Retry with transaction hash as credential
|
|
223
|
+
*
|
|
224
|
+
* @param url - Full URL of the MPP-enabled endpoint
|
|
225
|
+
* @param options - Request options (body, headers)
|
|
226
|
+
* @returns Response from the service
|
|
227
|
+
*/
|
|
228
|
+
payWithMPP(url: string, options?: {
|
|
229
|
+
body?: any;
|
|
230
|
+
headers?: Record<string, string>;
|
|
231
|
+
}): Promise<any>;
|
|
176
232
|
}
|
|
177
233
|
|
|
178
234
|
export { type ClientConfig, MoltsPayClient, type MoltsPayClientOptions, type PayOptions, type PaymentRequired, type ProviderInfo, type ServiceInfo, type ServicesResponse, type VerifyResponse, type WalletData };
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Wallet } from 'ethers';
|
|
2
|
+
import { T as TokenSymbol } from '../index-D_2FkLwV.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* MoltsPay Client Types
|
|
@@ -78,8 +79,8 @@ interface PayOptions {
|
|
|
78
79
|
token?: TokenSymbol;
|
|
79
80
|
/** Auto-select token based on balance (default: false) */
|
|
80
81
|
autoSelect?: boolean;
|
|
81
|
-
/** Chain to pay on
|
|
82
|
-
chain?: 'base' | 'polygon' | 'base_sepolia';
|
|
82
|
+
/** Chain to pay on */
|
|
83
|
+
chain?: 'base' | 'polygon' | 'base_sepolia' | 'tempo_moderato' | 'bnb' | 'bnb_testnet' | 'solana' | 'solana_devnet';
|
|
83
84
|
}
|
|
84
85
|
declare class MoltsPayClient {
|
|
85
86
|
private configDir;
|
|
@@ -97,6 +98,10 @@ declare class MoltsPayClient {
|
|
|
97
98
|
* Get wallet address
|
|
98
99
|
*/
|
|
99
100
|
get address(): string | null;
|
|
101
|
+
/**
|
|
102
|
+
* Get wallet instance (for direct operations like approvals)
|
|
103
|
+
*/
|
|
104
|
+
getWallet(): Wallet | null;
|
|
100
105
|
/**
|
|
101
106
|
* Get current config
|
|
102
107
|
*/
|
|
@@ -121,6 +126,34 @@ declare class MoltsPayClient {
|
|
|
121
126
|
* @param options - Payment options (token selection)
|
|
122
127
|
*/
|
|
123
128
|
pay(serverUrl: string, service: string, params: Record<string, any>, options?: PayOptions): Promise<Record<string, any>>;
|
|
129
|
+
/**
|
|
130
|
+
* Handle MPP (Machine Payments Protocol) payment flow
|
|
131
|
+
* Called when pay() detects WWW-Authenticate header in 402 response
|
|
132
|
+
*/
|
|
133
|
+
private handleMPPPayment;
|
|
134
|
+
/**
|
|
135
|
+
* Handle BNB Chain payment flow (pre-approval + intent signature)
|
|
136
|
+
*
|
|
137
|
+
* Flow:
|
|
138
|
+
* 1. Check client has approved server wallet (done via `moltspay init`)
|
|
139
|
+
* 2. Sign EIP-712 payment intent (no gas, just signature)
|
|
140
|
+
* 3. Send intent to server
|
|
141
|
+
* 4. Server executes service
|
|
142
|
+
* 5. Server calls transferFrom if successful (pay-for-success)
|
|
143
|
+
*/
|
|
144
|
+
private handleBNBPayment;
|
|
145
|
+
/**
|
|
146
|
+
* Handle Solana payment flow
|
|
147
|
+
*
|
|
148
|
+
* Solana uses SPL token transfers with pay-for-success model:
|
|
149
|
+
* 1. Client creates and signs a transfer transaction
|
|
150
|
+
* 2. Server submits the transaction after service completes
|
|
151
|
+
*/
|
|
152
|
+
private handleSolanaPayment;
|
|
153
|
+
/**
|
|
154
|
+
* Check ERC20 allowance for a spender
|
|
155
|
+
*/
|
|
156
|
+
private checkAllowance;
|
|
124
157
|
/**
|
|
125
158
|
* Sign EIP-3009 transferWithAuthorization (GASLESS)
|
|
126
159
|
* This only signs - no on-chain transaction, no gas needed.
|
|
@@ -166,13 +199,36 @@ declare class MoltsPayClient {
|
|
|
166
199
|
native: number;
|
|
167
200
|
}>;
|
|
168
201
|
/**
|
|
169
|
-
* Get wallet balances on all supported chains (Base + Polygon)
|
|
202
|
+
* Get wallet balances on all supported chains (Base + Polygon + Tempo)
|
|
170
203
|
*/
|
|
171
204
|
getAllBalances(): Promise<Record<string, {
|
|
172
205
|
usdc: number;
|
|
173
206
|
usdt: number;
|
|
174
207
|
native: number;
|
|
208
|
+
tempo?: {
|
|
209
|
+
pathUSD: number;
|
|
210
|
+
alphaUSD: number;
|
|
211
|
+
betaUSD: number;
|
|
212
|
+
thetaUSD: number;
|
|
213
|
+
};
|
|
175
214
|
}>>;
|
|
215
|
+
/**
|
|
216
|
+
* Pay for a service using MPP (Machine Payments Protocol)
|
|
217
|
+
*
|
|
218
|
+
* This implements the MPP flow manually for EOA wallets:
|
|
219
|
+
* 1. Request service → get 402 with WWW-Authenticate
|
|
220
|
+
* 2. Parse payment requirements
|
|
221
|
+
* 3. Execute transfer on Tempo chain
|
|
222
|
+
* 4. Retry with transaction hash as credential
|
|
223
|
+
*
|
|
224
|
+
* @param url - Full URL of the MPP-enabled endpoint
|
|
225
|
+
* @param options - Request options (body, headers)
|
|
226
|
+
* @returns Response from the service
|
|
227
|
+
*/
|
|
228
|
+
payWithMPP(url: string, options?: {
|
|
229
|
+
body?: any;
|
|
230
|
+
headers?: Record<string, string>;
|
|
231
|
+
}): Promise<any>;
|
|
176
232
|
}
|
|
177
233
|
|
|
178
234
|
export { type ClientConfig, MoltsPayClient, type MoltsPayClientOptions, type PayOptions, type PaymentRequired, type ProviderInfo, type ServiceInfo, type ServicesResponse, type VerifyResponse, type WalletData };
|