moltspay 1.3.0 → 1.4.1
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/.env.example +14 -0
- package/README.md +319 -89
- package/dist/cdp/index.d.mts +4 -4
- package/dist/cdp/index.d.ts +4 -4
- package/dist/cdp/index.js +57 -0
- package/dist/cdp/index.js.map +1 -1
- package/dist/cdp/index.mjs +57 -0
- package/dist/cdp/index.mjs.map +1 -1
- package/dist/chains/index.d.mts +9 -8
- package/dist/chains/index.d.ts +9 -8
- package/dist/chains/index.js +57 -0
- package/dist/chains/index.js.map +1 -1
- package/dist/chains/index.mjs +57 -0
- package/dist/chains/index.mjs.map +1 -1
- package/dist/cli/index.js +2021 -285
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/index.mjs +2023 -277
- package/dist/cli/index.mjs.map +1 -1
- package/dist/client/index.d.mts +39 -3
- package/dist/client/index.d.ts +39 -3
- package/dist/client/index.js +563 -37
- package/dist/client/index.js.map +1 -1
- package/dist/client/index.mjs +571 -35
- package/dist/client/index.mjs.map +1 -1
- package/dist/facilitators/index.d.mts +220 -1
- package/dist/facilitators/index.d.ts +220 -1
- package/dist/facilitators/index.js +664 -1
- package/dist/facilitators/index.js.map +1 -1
- package/dist/facilitators/index.mjs +670 -1
- package/dist/facilitators/index.mjs.map +1 -1
- package/dist/{index-On9ZaGDW.d.mts → index-D_2FkLwV.d.mts} +6 -2
- package/dist/{index-On9ZaGDW.d.ts → index-D_2FkLwV.d.ts} +6 -2
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1440 -153
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1448 -151
- package/dist/index.mjs.map +1 -1
- package/dist/server/index.d.mts +13 -3
- package/dist/server/index.d.ts +13 -3
- package/dist/server/index.js +909 -54
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +919 -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 +57 -0
- package/dist/verify/index.js.map +1 -1
- package/dist/verify/index.mjs +57 -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 +57 -0
- package/dist/wallet/index.js.map +1 -1
- package/dist/wallet/index.mjs +57 -0
- package/dist/wallet/index.mjs.map +1 -1
- package/package.json +5 -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
|
|
@@ -37,6 +38,7 @@ interface ServiceInfo {
|
|
|
37
38
|
output: Record<string, any>;
|
|
38
39
|
available: boolean;
|
|
39
40
|
provider?: ProviderInfo;
|
|
41
|
+
endpoint?: string;
|
|
40
42
|
}
|
|
41
43
|
interface ProviderInfo {
|
|
42
44
|
name: string;
|
|
@@ -78,8 +80,10 @@ interface PayOptions {
|
|
|
78
80
|
token?: TokenSymbol;
|
|
79
81
|
/** Auto-select token based on balance (default: false) */
|
|
80
82
|
autoSelect?: boolean;
|
|
81
|
-
/** Chain to pay on
|
|
82
|
-
chain?: 'base' | 'polygon' | 'base_sepolia';
|
|
83
|
+
/** Chain to pay on */
|
|
84
|
+
chain?: 'base' | 'polygon' | 'base_sepolia' | 'tempo_moderato' | 'bnb' | 'bnb_testnet' | 'solana' | 'solana_devnet';
|
|
85
|
+
/** Send raw data at top level instead of wrapped in { params } */
|
|
86
|
+
rawData?: boolean;
|
|
83
87
|
}
|
|
84
88
|
declare class MoltsPayClient {
|
|
85
89
|
private configDir;
|
|
@@ -97,6 +101,10 @@ declare class MoltsPayClient {
|
|
|
97
101
|
* Get wallet address
|
|
98
102
|
*/
|
|
99
103
|
get address(): string | null;
|
|
104
|
+
/**
|
|
105
|
+
* Get wallet instance (for direct operations like approvals)
|
|
106
|
+
*/
|
|
107
|
+
getWallet(): Wallet | null;
|
|
100
108
|
/**
|
|
101
109
|
* Get current config
|
|
102
110
|
*/
|
|
@@ -121,6 +129,34 @@ declare class MoltsPayClient {
|
|
|
121
129
|
* @param options - Payment options (token selection)
|
|
122
130
|
*/
|
|
123
131
|
pay(serverUrl: string, service: string, params: Record<string, any>, options?: PayOptions): Promise<Record<string, any>>;
|
|
132
|
+
/**
|
|
133
|
+
* Handle MPP (Machine Payments Protocol) payment flow
|
|
134
|
+
* Called when pay() detects WWW-Authenticate header in 402 response
|
|
135
|
+
*/
|
|
136
|
+
private handleMPPPayment;
|
|
137
|
+
/**
|
|
138
|
+
* Handle BNB Chain payment flow (pre-approval + intent signature)
|
|
139
|
+
*
|
|
140
|
+
* Flow:
|
|
141
|
+
* 1. Check client has approved server wallet (done via `moltspay init`)
|
|
142
|
+
* 2. Sign EIP-712 payment intent (no gas, just signature)
|
|
143
|
+
* 3. Send intent to server
|
|
144
|
+
* 4. Server executes service
|
|
145
|
+
* 5. Server calls transferFrom if successful (pay-for-success)
|
|
146
|
+
*/
|
|
147
|
+
private handleBNBPayment;
|
|
148
|
+
/**
|
|
149
|
+
* Handle Solana payment flow
|
|
150
|
+
*
|
|
151
|
+
* Solana uses SPL token transfers with pay-for-success model:
|
|
152
|
+
* 1. Client creates and signs a transfer transaction
|
|
153
|
+
* 2. Server submits the transaction after service completes
|
|
154
|
+
*/
|
|
155
|
+
private handleSolanaPayment;
|
|
156
|
+
/**
|
|
157
|
+
* Check ERC20 allowance for a spender
|
|
158
|
+
*/
|
|
159
|
+
private checkAllowance;
|
|
124
160
|
/**
|
|
125
161
|
* Sign EIP-3009 transferWithAuthorization (GASLESS)
|
|
126
162
|
* This only signs - no on-chain transaction, no gas needed.
|
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
|
|
@@ -37,6 +38,7 @@ interface ServiceInfo {
|
|
|
37
38
|
output: Record<string, any>;
|
|
38
39
|
available: boolean;
|
|
39
40
|
provider?: ProviderInfo;
|
|
41
|
+
endpoint?: string;
|
|
40
42
|
}
|
|
41
43
|
interface ProviderInfo {
|
|
42
44
|
name: string;
|
|
@@ -78,8 +80,10 @@ interface PayOptions {
|
|
|
78
80
|
token?: TokenSymbol;
|
|
79
81
|
/** Auto-select token based on balance (default: false) */
|
|
80
82
|
autoSelect?: boolean;
|
|
81
|
-
/** Chain to pay on
|
|
82
|
-
chain?: 'base' | 'polygon' | 'base_sepolia';
|
|
83
|
+
/** Chain to pay on */
|
|
84
|
+
chain?: 'base' | 'polygon' | 'base_sepolia' | 'tempo_moderato' | 'bnb' | 'bnb_testnet' | 'solana' | 'solana_devnet';
|
|
85
|
+
/** Send raw data at top level instead of wrapped in { params } */
|
|
86
|
+
rawData?: boolean;
|
|
83
87
|
}
|
|
84
88
|
declare class MoltsPayClient {
|
|
85
89
|
private configDir;
|
|
@@ -97,6 +101,10 @@ declare class MoltsPayClient {
|
|
|
97
101
|
* Get wallet address
|
|
98
102
|
*/
|
|
99
103
|
get address(): string | null;
|
|
104
|
+
/**
|
|
105
|
+
* Get wallet instance (for direct operations like approvals)
|
|
106
|
+
*/
|
|
107
|
+
getWallet(): Wallet | null;
|
|
100
108
|
/**
|
|
101
109
|
* Get current config
|
|
102
110
|
*/
|
|
@@ -121,6 +129,34 @@ declare class MoltsPayClient {
|
|
|
121
129
|
* @param options - Payment options (token selection)
|
|
122
130
|
*/
|
|
123
131
|
pay(serverUrl: string, service: string, params: Record<string, any>, options?: PayOptions): Promise<Record<string, any>>;
|
|
132
|
+
/**
|
|
133
|
+
* Handle MPP (Machine Payments Protocol) payment flow
|
|
134
|
+
* Called when pay() detects WWW-Authenticate header in 402 response
|
|
135
|
+
*/
|
|
136
|
+
private handleMPPPayment;
|
|
137
|
+
/**
|
|
138
|
+
* Handle BNB Chain payment flow (pre-approval + intent signature)
|
|
139
|
+
*
|
|
140
|
+
* Flow:
|
|
141
|
+
* 1. Check client has approved server wallet (done via `moltspay init`)
|
|
142
|
+
* 2. Sign EIP-712 payment intent (no gas, just signature)
|
|
143
|
+
* 3. Send intent to server
|
|
144
|
+
* 4. Server executes service
|
|
145
|
+
* 5. Server calls transferFrom if successful (pay-for-success)
|
|
146
|
+
*/
|
|
147
|
+
private handleBNBPayment;
|
|
148
|
+
/**
|
|
149
|
+
* Handle Solana payment flow
|
|
150
|
+
*
|
|
151
|
+
* Solana uses SPL token transfers with pay-for-success model:
|
|
152
|
+
* 1. Client creates and signs a transfer transaction
|
|
153
|
+
* 2. Server submits the transaction after service completes
|
|
154
|
+
*/
|
|
155
|
+
private handleSolanaPayment;
|
|
156
|
+
/**
|
|
157
|
+
* Check ERC20 allowance for a spender
|
|
158
|
+
*/
|
|
159
|
+
private checkAllowance;
|
|
124
160
|
/**
|
|
125
161
|
* Sign EIP-3009 transferWithAuthorization (GASLESS)
|
|
126
162
|
* This only signs - no on-chain transaction, no gas needed.
|