moltspay 2.0.0 → 2.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 (50) hide show
  1. package/.env.example +23 -0
  2. package/CHANGELOG.md +551 -0
  3. package/README.md +466 -8
  4. package/dist/cdp/index.js.map +1 -1
  5. package/dist/cdp/index.mjs.map +1 -1
  6. package/dist/chains/index.d.mts +69 -4
  7. package/dist/chains/index.d.ts +69 -4
  8. package/dist/chains/index.js +45 -1
  9. package/dist/chains/index.js.map +1 -1
  10. package/dist/chains/index.mjs +39 -1
  11. package/dist/chains/index.mjs.map +1 -1
  12. package/dist/cli/index.js +5444 -2126
  13. package/dist/cli/index.js.map +1 -1
  14. package/dist/cli/index.mjs +5457 -2133
  15. package/dist/cli/index.mjs.map +1 -1
  16. package/dist/client/index.d.mts +307 -1
  17. package/dist/client/index.d.ts +307 -1
  18. package/dist/client/index.js +639 -34
  19. package/dist/client/index.js.map +1 -1
  20. package/dist/client/index.mjs +656 -52
  21. package/dist/client/index.mjs.map +1 -1
  22. package/dist/client/web/index.mjs.map +1 -1
  23. package/dist/facilitators/index.d.mts +512 -10
  24. package/dist/facilitators/index.d.ts +512 -10
  25. package/dist/facilitators/index.js +925 -13
  26. package/dist/facilitators/index.js.map +1 -1
  27. package/dist/facilitators/index.mjs +906 -12
  28. package/dist/facilitators/index.mjs.map +1 -1
  29. package/dist/index.d.mts +2 -2
  30. package/dist/index.d.ts +2 -2
  31. package/dist/index.js +2843 -551
  32. package/dist/index.js.map +1 -1
  33. package/dist/index.mjs +2849 -558
  34. package/dist/index.mjs.map +1 -1
  35. package/dist/mcp/index.js +635 -32
  36. package/dist/mcp/index.js.map +1 -1
  37. package/dist/mcp/index.mjs +660 -57
  38. package/dist/mcp/index.mjs.map +1 -1
  39. package/dist/server/index.d.mts +252 -11
  40. package/dist/server/index.d.ts +252 -11
  41. package/dist/server/index.js +2049 -261
  42. package/dist/server/index.js.map +1 -1
  43. package/dist/server/index.mjs +2049 -261
  44. package/dist/server/index.mjs.map +1 -1
  45. package/dist/verify/index.js.map +1 -1
  46. package/dist/verify/index.mjs.map +1 -1
  47. package/dist/wallet/index.js.map +1 -1
  48. package/dist/wallet/index.mjs.map +1 -1
  49. package/package.json +14 -2
  50. package/schemas/moltspay.services.schema.json +127 -16
@@ -32,16 +32,16 @@
32
32
  },
33
33
  "chain": {
34
34
  "type": "string",
35
- "enum": ["base", "polygon", "base_sepolia", "tempo_moderato", "bnb", "bnb_testnet", "solana", "solana_devnet", "alipay"],
35
+ "enum": ["base", "polygon", "base_sepolia", "tempo_moderato", "bnb", "bnb_testnet", "solana", "solana_devnet", "alipay", "wechat", "balance"],
36
36
  "default": "base",
37
- "description": "Single chain mode (use 'chains' for multi-chain). 'alipay' is a fiat rail (1.7.0+), not a blockchain."
37
+ "description": "Single chain mode (use 'chains' for multi-chain). 'alipay'/'wechat' are fiat rails (2.0+/2.1+), 'balance' is the custodial rail (2.2+), none are blockchains."
38
38
  },
39
39
  "chains": {
40
40
  "type": "array",
41
- "description": "Supported chains/rails. EVM chains use 'wallet', Solana chains use 'solana_wallet', 'alipay' (1.7.0+) uses 'provider.alipay'.",
41
+ "description": "Supported chains/rails. EVM chains use 'wallet', Solana chains use 'solana_wallet', 'alipay' (2.0+) uses 'provider.alipay', 'wechat' (2.1+) uses 'provider.wechat'.",
42
42
  "items": {
43
43
  "type": "string",
44
- "enum": ["base", "polygon", "base_sepolia", "tempo_moderato", "bnb", "bnb_testnet", "solana", "solana_devnet", "alipay"]
44
+ "enum": ["base", "polygon", "base_sepolia", "tempo_moderato", "bnb", "bnb_testnet", "solana", "solana_devnet", "alipay", "wechat", "balance"]
45
45
  },
46
46
  "examples": [
47
47
  ["base", "polygon", "solana_devnet"],
@@ -51,7 +51,7 @@
51
51
  },
52
52
  "alipay": {
53
53
  "type": "object",
54
- "description": "Alipay AI 收 provider config (1.7.0+). Required when 'chains' contains 'alipay'.",
54
+ "description": "Alipay AI 收 provider config (2.0+). Required when 'chains' contains 'alipay'.",
55
55
  "required": ["seller_id", "app_id", "seller_name", "service_id_default", "private_key_path", "alipay_public_key_path"],
56
56
  "properties": {
57
57
  "seller_id": {
@@ -70,7 +70,7 @@
70
70
  },
71
71
  "service_id_default": {
72
72
  "type": "string",
73
- "description": "Default service_id when a service entry doesn't override it (e.g. 'API_0EA6DC4FC99A4DF7')"
73
+ "description": "Default service_id when a service entry doesn't override it (e.g. 'API_XXXXXXXXXXXXXXXX')"
74
74
  },
75
75
  "private_key_path": {
76
76
  "type": "string",
@@ -90,7 +90,102 @@
90
90
  "type": "string",
91
91
  "enum": ["RSA2"],
92
92
  "default": "RSA2",
93
- "description": "Signature algorithm. Only RSA2 is supported in 1.7.0."
93
+ "description": "Signature algorithm. Only RSA2 is supported in 2.0."
94
+ }
95
+ }
96
+ },
97
+ "wechat": {
98
+ "type": "object",
99
+ "description": "WeChat Pay v3 Native provider config (2.1+). Required when 'chains' contains 'wechat'.",
100
+ "required": ["mchid", "appid", "serial_no", "private_key_path", "notify_url"],
101
+ "properties": {
102
+ "mchid": {
103
+ "type": "string",
104
+ "description": "Merchant id (商户号)"
105
+ },
106
+ "appid": {
107
+ "type": "string",
108
+ "description": "App id (official account / mini-program / app)"
109
+ },
110
+ "serial_no": {
111
+ "type": "string",
112
+ "description": "Merchant API certificate serial number"
113
+ },
114
+ "private_key_path": {
115
+ "type": "string",
116
+ "description": "Path to the merchant RSA private key PEM file (relative to moltspay.services.json)"
117
+ },
118
+ "platform_public_key_path": {
119
+ "type": "string",
120
+ "description": "Path to the WeChat platform certificate public key PEM (enables response verification)"
121
+ },
122
+ "apiv3_key": {
123
+ "type": "string",
124
+ "minLength": 32,
125
+ "maxLength": 32,
126
+ "description": "APIv3 key (32 bytes). Only needed for callback decryption (Phase 2)"
127
+ },
128
+ "notify_url": {
129
+ "type": "string",
130
+ "format": "uri",
131
+ "description": "Async result notify URL. Required by Native order create even when polling."
132
+ },
133
+ "api_base": {
134
+ "type": "string",
135
+ "format": "uri",
136
+ "default": "https://api.mch.weixin.qq.com",
137
+ "description": "Open API base URL"
138
+ }
139
+ }
140
+ },
141
+ "balance": {
142
+ "type": "object",
143
+ "description": "Custodial balance rail config (2.2+). Required when 'chains' contains 'balance'. Enabling requires Node.js >= 22.5.",
144
+ "required": ["db_path"],
145
+ "properties": {
146
+ "db_path": {
147
+ "type": "string",
148
+ "description": "SQLite ledger file path (relative to moltspay.services.json); created on first start"
149
+ },
150
+ "currency": {
151
+ "type": "string",
152
+ "enum": ["USD", "CNY"],
153
+ "default": "USD",
154
+ "description": "Ledger quote currency. Recorded once and enforced on reopen (a mismatch refuses to start). CNY funds 1:1 from WeChat (payer_total is fen)."
155
+ },
156
+ "single_limit": {
157
+ "type": "string",
158
+ "pattern": "^\\d+(\\.\\d{1,2})?$",
159
+ "default": "5.00",
160
+ "description": "Default per-transaction limit for new buyers (decimal string, ledger currency)"
161
+ },
162
+ "daily_limit": {
163
+ "type": "string",
164
+ "pattern": "^\\d+(\\.\\d{1,2})?$",
165
+ "default": "10.00",
166
+ "description": "Default daily limit for new buyers (decimal string, ledger currency)"
167
+ },
168
+ "topup_packs": {
169
+ "type": "array",
170
+ "minItems": 1,
171
+ "items": { "type": "string", "pattern": "^\\d+(\\.\\d{1,2})?$" },
172
+ "description": "Offered recharge amounts in ledger currency (2.3+), e.g. [\"20.00\", \"50.00\"]"
173
+ },
174
+ "default_pack": {
175
+ "type": "string",
176
+ "pattern": "^\\d+(\\.\\d{1,2})?$",
177
+ "description": "Pack the client auto-selects when a 402 finds an insufficient balance (2.3+). Must be one of topup_packs."
178
+ },
179
+ "auto_topup_max": {
180
+ "type": "string",
181
+ "pattern": "^\\d+(\\.\\d{1,2})?$",
182
+ "description": "Ceiling on client auto-topup without explicit pack selection (2.3+). Must be >= the largest topup_pack."
183
+ },
184
+ "auth_mode": {
185
+ "type": "string",
186
+ "enum": ["off", "shadow", "enforce"],
187
+ "default": "off",
188
+ "description": "Balance spend authentication (2.4+). 'off': signature not checked (default, backward-compatible; buyer_id keeps bearer semantics). 'shadow': verify per-request signatures and log what would be denied, without blocking (use to confirm every client signs before tightening). 'enforce': reject unsigned/invalid/wrong-signer deductions with 401. The account's signer address is TOFU-bound on first signed use and anchored to the WeChat payer openid at top-up."
94
189
  }
95
190
  }
96
191
  }
@@ -123,7 +218,7 @@
123
218
  "output": { "type": "object", "description": "Output schema" },
124
219
  "alipay": {
125
220
  "type": "object",
126
- "description": "Alipay AI 收 per-service config (1.7.0+). Set when this service accepts CNY payments.",
221
+ "description": "Alipay AI 收 per-service config (2.0+). Set when this service accepts CNY payments.",
127
222
  "required": ["price_cny", "goods_name"],
128
223
  "properties": {
129
224
  "service_id": {
@@ -140,6 +235,22 @@
140
235
  "description": "Goods name shown to the user in the Alipay app"
141
236
  }
142
237
  }
238
+ },
239
+ "wechat": {
240
+ "type": "object",
241
+ "description": "WeChat Pay Native per-service config (2.1+). Set when this service accepts CNY payments.",
242
+ "required": ["price_cny", "description"],
243
+ "properties": {
244
+ "price_cny": {
245
+ "type": "string",
246
+ "pattern": "^\\d+(\\.\\d{1,2})?$",
247
+ "description": "CNY price as decimal string in yuan (e.g. '10.00' = 10 CNY, NOT fen)"
248
+ },
249
+ "description": {
250
+ "type": "string",
251
+ "description": "Order description shown to the payer in the WeChat app"
252
+ }
253
+ }
143
254
  }
144
255
  }
145
256
  }
@@ -159,14 +270,14 @@
159
270
  },
160
271
  {
161
272
  "provider": {
162
- "name": "灵机一物",
163
- "wallet": "0xb8d6f2441e8f8dfB6288A74Cf73804cDd0484E0C",
273
+ "name": "My Shop",
274
+ "wallet": "0x0000000000000000000000000000000000000000",
164
275
  "chains": ["base", "polygon", "alipay"],
165
276
  "alipay": {
166
- "seller_id": "2088641494699428",
167
- "app_id": "2021006150642142",
168
- "seller_name": "上海超响应数字科技有限公司",
169
- "service_id_default": "API_0EA6DC4FC99A4DF7",
277
+ "seller_id": "2088000000000000",
278
+ "app_id": "2021000000000000",
279
+ "seller_name": "Example Merchant Co., Ltd.",
280
+ "service_id_default": "API_XXXXXXXXXXXXXXXX",
170
281
  "private_key_path": "./cert/ALIPAY_PRIVATE_KEY.txt",
171
282
  "alipay_public_key_path": "./cert/ALIPAY_PUBLIC_KEY.txt"
172
283
  }
@@ -178,9 +289,9 @@
178
289
  "price": 0.99,
179
290
  "currency": "USDC",
180
291
  "alipay": {
181
- "service_id": "API_0EA6DC4FC99A4DF7",
292
+ "service_id": "API_XXXXXXXXXXXXXXXX",
182
293
  "price_cny": "7.00",
183
- "goods_name": "产品演示视频 - 系列一"
294
+ "goods_name": "Demo Video"
184
295
  }
185
296
  }
186
297
  ]