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.
Files changed (59) hide show
  1. package/README.md +292 -34
  2. package/dist/cdp/index.d.mts +4 -4
  3. package/dist/cdp/index.d.ts +4 -4
  4. package/dist/cdp/index.js +110 -30368
  5. package/dist/cdp/index.js.map +1 -1
  6. package/dist/cdp/index.mjs +94 -30360
  7. package/dist/cdp/index.mjs.map +1 -1
  8. package/dist/cdp-DeohBe1o.d.ts +66 -0
  9. package/dist/cdp-p_eHuQpb.d.mts +66 -0
  10. package/dist/chains/index.d.mts +9 -8
  11. package/dist/chains/index.d.ts +9 -8
  12. package/dist/chains/index.js +86 -0
  13. package/dist/chains/index.js.map +1 -1
  14. package/dist/chains/index.mjs +86 -0
  15. package/dist/chains/index.mjs.map +1 -1
  16. package/dist/cli/index.js +2746 -290
  17. package/dist/cli/index.js.map +1 -1
  18. package/dist/cli/index.mjs +2752 -282
  19. package/dist/cli/index.mjs.map +1 -1
  20. package/dist/client/index.d.mts +60 -4
  21. package/dist/client/index.d.ts +60 -4
  22. package/dist/client/index.js +734 -43
  23. package/dist/client/index.js.map +1 -1
  24. package/dist/client/index.mjs +732 -41
  25. package/dist/client/index.mjs.map +1 -1
  26. package/dist/facilitators/index.d.mts +220 -39
  27. package/dist/facilitators/index.d.ts +220 -39
  28. package/dist/facilitators/index.js +897 -1
  29. package/dist/facilitators/index.js.map +1 -1
  30. package/dist/facilitators/index.mjs +902 -1
  31. package/dist/facilitators/index.mjs.map +1 -1
  32. package/dist/{index-DgJPZMBG.d.mts → index-D_2FkLwV.d.mts} +6 -2
  33. package/dist/{index-DgJPZMBG.d.ts → index-D_2FkLwV.d.ts} +6 -2
  34. package/dist/index.d.mts +3 -2
  35. package/dist/index.d.ts +3 -2
  36. package/dist/index.js +2238 -30837
  37. package/dist/index.js.map +1 -1
  38. package/dist/index.mjs +2167 -30766
  39. package/dist/index.mjs.map +1 -1
  40. package/dist/server/index.d.mts +30 -3
  41. package/dist/server/index.d.ts +30 -3
  42. package/dist/server/index.js +1345 -54
  43. package/dist/server/index.js.map +1 -1
  44. package/dist/server/index.mjs +1355 -54
  45. package/dist/server/index.mjs.map +1 -1
  46. package/dist/verify/index.d.mts +1 -1
  47. package/dist/verify/index.d.ts +1 -1
  48. package/dist/verify/index.js +86 -0
  49. package/dist/verify/index.js.map +1 -1
  50. package/dist/verify/index.mjs +86 -0
  51. package/dist/verify/index.mjs.map +1 -1
  52. package/dist/wallet/index.d.mts +3 -3
  53. package/dist/wallet/index.d.ts +3 -3
  54. package/dist/wallet/index.js +86 -0
  55. package/dist/wallet/index.js.map +1 -1
  56. package/dist/wallet/index.mjs +86 -0
  57. package/dist/wallet/index.mjs.map +1 -1
  58. package/package.json +8 -2
  59. package/schemas/moltspay.services.schema.json +27 -132
@@ -1,4 +1,5 @@
1
- import { T as TokenSymbol } from '../index-DgJPZMBG.mjs';
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 (base, polygon, or base_sepolia, default: base) */
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 };
@@ -1,4 +1,5 @@
1
- import { T as TokenSymbol } from '../index-DgJPZMBG.js';
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 (base, polygon, or base_sepolia, default: base) */
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 };