moltspay 1.6.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 +1 -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 +1466 -61
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/index.mjs +1466 -61
- package/dist/cli/index.mjs.map +1 -1
- package/dist/client/index.d.mts +41 -0
- package/dist/client/index.d.ts +41 -0
- package/dist/client/index.js +824 -10
- package/dist/client/index.js.map +1 -1
- package/dist/client/index.mjs +824 -10
- package/dist/client/index.mjs.map +1 -1
- package/dist/client/web/index.d.mts +17 -1
- package/dist/client/web/index.mjs +11 -0
- package/dist/client/web/index.mjs.map +1 -1
- package/dist/facilitators/index.d.mts +161 -4
- package/dist/facilitators/index.d.ts +161 -4
- package/dist/facilitators/index.js +370 -0
- package/dist/facilitators/index.js.map +1 -1
- package/dist/facilitators/index.mjs +365 -0
- 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 +1412 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1406 -31
- package/dist/index.mjs.map +1 -1
- package/dist/mcp/index.js +828 -14
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/index.mjs +828 -14
- 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 +95 -2
- package/dist/server/index.d.ts +95 -2
- package/dist/server/index.js +554 -14
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +554 -14
- 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 +7 -1
- package/schemas/moltspay.services.schema.json +100 -6
- package/scripts/postinstall.js +91 -0
|
@@ -32,21 +32,67 @@
|
|
|
32
32
|
},
|
|
33
33
|
"chain": {
|
|
34
34
|
"type": "string",
|
|
35
|
-
"enum": ["base", "polygon", "base_sepolia", "tempo_moderato", "bnb", "bnb_testnet", "solana", "solana_devnet"],
|
|
35
|
+
"enum": ["base", "polygon", "base_sepolia", "tempo_moderato", "bnb", "bnb_testnet", "solana", "solana_devnet", "alipay"],
|
|
36
36
|
"default": "base",
|
|
37
|
-
"description": "Single chain mode (use 'chains' for multi-chain)"
|
|
37
|
+
"description": "Single chain mode (use 'chains' for multi-chain). 'alipay' is a fiat rail (1.7.0+), not a blockchain."
|
|
38
38
|
},
|
|
39
39
|
"chains": {
|
|
40
40
|
"type": "array",
|
|
41
|
-
"description": "Supported chains. EVM chains use 'wallet', Solana chains use 'solana_wallet'.",
|
|
41
|
+
"description": "Supported chains/rails. EVM chains use 'wallet', Solana chains use 'solana_wallet', 'alipay' (1.7.0+) uses 'provider.alipay'.",
|
|
42
42
|
"items": {
|
|
43
43
|
"type": "string",
|
|
44
|
-
"enum": ["base", "polygon", "base_sepolia", "tempo_moderato", "bnb", "bnb_testnet", "solana", "solana_devnet"]
|
|
44
|
+
"enum": ["base", "polygon", "base_sepolia", "tempo_moderato", "bnb", "bnb_testnet", "solana", "solana_devnet", "alipay"]
|
|
45
45
|
},
|
|
46
46
|
"examples": [
|
|
47
47
|
["base", "polygon", "solana_devnet"],
|
|
48
|
-
["base", "base_sepolia", "solana", "solana_devnet"]
|
|
48
|
+
["base", "base_sepolia", "solana", "solana_devnet"],
|
|
49
|
+
["base", "polygon", "alipay"]
|
|
49
50
|
]
|
|
51
|
+
},
|
|
52
|
+
"alipay": {
|
|
53
|
+
"type": "object",
|
|
54
|
+
"description": "Alipay AI 收 provider config (1.7.0+). Required when 'chains' contains 'alipay'.",
|
|
55
|
+
"required": ["seller_id", "app_id", "seller_name", "service_id_default", "private_key_path", "alipay_public_key_path"],
|
|
56
|
+
"properties": {
|
|
57
|
+
"seller_id": {
|
|
58
|
+
"type": "string",
|
|
59
|
+
"pattern": "^[0-9]{16}$",
|
|
60
|
+
"description": "Merchant Alipay ID (16 digits)"
|
|
61
|
+
},
|
|
62
|
+
"app_id": {
|
|
63
|
+
"type": "string",
|
|
64
|
+
"pattern": "^[0-9]{16}$",
|
|
65
|
+
"description": "Application ID from Alipay Open Platform"
|
|
66
|
+
},
|
|
67
|
+
"seller_name": {
|
|
68
|
+
"type": "string",
|
|
69
|
+
"description": "Merchant legal name (shown in 'method.seller_name' of the 402 challenge)"
|
|
70
|
+
},
|
|
71
|
+
"service_id_default": {
|
|
72
|
+
"type": "string",
|
|
73
|
+
"description": "Default service_id when a service entry doesn't override it (e.g. 'API_0EA6DC4FC99A4DF7')"
|
|
74
|
+
},
|
|
75
|
+
"private_key_path": {
|
|
76
|
+
"type": "string",
|
|
77
|
+
"description": "Path to the RSA2 merchant private key PEM file (relative to moltspay.services.json)"
|
|
78
|
+
},
|
|
79
|
+
"alipay_public_key_path": {
|
|
80
|
+
"type": "string",
|
|
81
|
+
"description": "Path to the Alipay platform public key PEM file (relative to moltspay.services.json)"
|
|
82
|
+
},
|
|
83
|
+
"gateway_url": {
|
|
84
|
+
"type": "string",
|
|
85
|
+
"format": "uri",
|
|
86
|
+
"default": "https://openapi.alipay.com/gateway.do",
|
|
87
|
+
"description": "Open API gateway URL (use 'https://openapi.alipaydev.com/gateway.do' for sandbox)"
|
|
88
|
+
},
|
|
89
|
+
"sign_type": {
|
|
90
|
+
"type": "string",
|
|
91
|
+
"enum": ["RSA2"],
|
|
92
|
+
"default": "RSA2",
|
|
93
|
+
"description": "Signature algorithm. Only RSA2 is supported in 1.7.0."
|
|
94
|
+
}
|
|
95
|
+
}
|
|
50
96
|
}
|
|
51
97
|
}
|
|
52
98
|
},
|
|
@@ -74,7 +120,27 @@
|
|
|
74
120
|
"price": { "type": "number", "minimum": 0, "description": "Price in currency units" },
|
|
75
121
|
"currency": { "type": "string", "enum": ["USDC", "USDT"], "default": "USDC" },
|
|
76
122
|
"input": { "type": "object", "description": "Input parameters schema" },
|
|
77
|
-
"output": { "type": "object", "description": "Output schema" }
|
|
123
|
+
"output": { "type": "object", "description": "Output schema" },
|
|
124
|
+
"alipay": {
|
|
125
|
+
"type": "object",
|
|
126
|
+
"description": "Alipay AI 收 per-service config (1.7.0+). Set when this service accepts CNY payments.",
|
|
127
|
+
"required": ["price_cny", "goods_name"],
|
|
128
|
+
"properties": {
|
|
129
|
+
"service_id": {
|
|
130
|
+
"type": "string",
|
|
131
|
+
"description": "Per-service service_id (defaults to provider.alipay.service_id_default)"
|
|
132
|
+
},
|
|
133
|
+
"price_cny": {
|
|
134
|
+
"type": "string",
|
|
135
|
+
"pattern": "^\\d+(\\.\\d{1,2})?$",
|
|
136
|
+
"description": "CNY price as decimal string in 元 (e.g. '7.00' = 7 CNY, NOT cents)"
|
|
137
|
+
},
|
|
138
|
+
"goods_name": {
|
|
139
|
+
"type": "string",
|
|
140
|
+
"description": "Goods name shown to the user in the Alipay app"
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
78
144
|
}
|
|
79
145
|
}
|
|
80
146
|
}
|
|
@@ -90,6 +156,34 @@
|
|
|
90
156
|
"services": [
|
|
91
157
|
{ "id": "text-to-video", "function": "textToVideo", "price": 0.99, "currency": "USDC" }
|
|
92
158
|
]
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"provider": {
|
|
162
|
+
"name": "灵机一物",
|
|
163
|
+
"wallet": "0xb8d6f2441e8f8dfB6288A74Cf73804cDd0484E0C",
|
|
164
|
+
"chains": ["base", "polygon", "alipay"],
|
|
165
|
+
"alipay": {
|
|
166
|
+
"seller_id": "2088641494699428",
|
|
167
|
+
"app_id": "2021006150642142",
|
|
168
|
+
"seller_name": "上海超响应数字科技有限公司",
|
|
169
|
+
"service_id_default": "API_0EA6DC4FC99A4DF7",
|
|
170
|
+
"private_key_path": "./cert/ALIPAY_PRIVATE_KEY.txt",
|
|
171
|
+
"alipay_public_key_path": "./cert/ALIPAY_PUBLIC_KEY.txt"
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
"services": [
|
|
175
|
+
{
|
|
176
|
+
"id": "text-to-video",
|
|
177
|
+
"function": "textToVideo",
|
|
178
|
+
"price": 0.99,
|
|
179
|
+
"currency": "USDC",
|
|
180
|
+
"alipay": {
|
|
181
|
+
"service_id": "API_0EA6DC4FC99A4DF7",
|
|
182
|
+
"price_cny": "7.00",
|
|
183
|
+
"goods_name": "产品演示视频 - 系列一"
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
]
|
|
93
187
|
}
|
|
94
188
|
]
|
|
95
189
|
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* postinstall — greet, then provision the alipay-bot CLI.
|
|
5
|
+
*
|
|
6
|
+
* alipay-bot is a runtime dependency of the Alipay payment rail. It is NOT on
|
|
7
|
+
* npm (Alipay distributes it from their own CDN) and is licensed UNLICENSED, so
|
|
8
|
+
* it can neither be a package.json dependency nor be bundled into this package.
|
|
9
|
+
* Instead, installing moltspay provisions it automatically by invoking the
|
|
10
|
+
* @alipay/agent-payment helper's `install-cli`, which downloads the CLI directly
|
|
11
|
+
* from Alipay's CDN onto THIS machine — we never redistribute it ourselves.
|
|
12
|
+
*
|
|
13
|
+
* The user opted into this by installing moltspay (alipay-bot is a declared
|
|
14
|
+
* dependency of the Alipay rail), so provisioning it is part of that install.
|
|
15
|
+
*
|
|
16
|
+
* Best-effort by design: provisioning failure (offline / CDN unreachable) prints
|
|
17
|
+
* an actionable notice but NEVER fails `npm install`. The runtime `ensureCli`
|
|
18
|
+
* gate is the real enforcement point and re-states the one command to run.
|
|
19
|
+
*
|
|
20
|
+
* Opt out with MOLTSPAY_SKIP_CLI_INSTALL=1 (e.g. CI / sandboxes).
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
const { spawnSync } = require('child_process');
|
|
24
|
+
const path = require('path');
|
|
25
|
+
const fs = require('fs');
|
|
26
|
+
|
|
27
|
+
const banner = `
|
|
28
|
+
╔══════════════════════════════════════════════════════════════╗
|
|
29
|
+
║ ║
|
|
30
|
+
║ 🎉 Thanks for installing MoltsPay! ║
|
|
31
|
+
║ ║
|
|
32
|
+
║ Quick Start: ║
|
|
33
|
+
║ npx moltspay init # Setup wallet ║
|
|
34
|
+
║ npx moltspay status # Check balance ║
|
|
35
|
+
║ npx moltspay validate . # Validate service config ║
|
|
36
|
+
║ ║
|
|
37
|
+
║ 📖 Docs: https://moltspay.com/docs ║
|
|
38
|
+
║ 💬 Support: https://discord.gg/QwCJgVBxVK ║
|
|
39
|
+
║ ║
|
|
40
|
+
╚══════════════════════════════════════════════════════════════╝
|
|
41
|
+
`;
|
|
42
|
+
console.log(banner);
|
|
43
|
+
|
|
44
|
+
const PROVISION_HINT = 'npx -y @alipay/agent-payment install-cli';
|
|
45
|
+
|
|
46
|
+
function warnManual(reason) {
|
|
47
|
+
console.warn(
|
|
48
|
+
`\n[moltspay] alipay-bot CLI 未能自动安装(${reason})。\n` +
|
|
49
|
+
` Alipay 支付轨在使用前需手动安装:\n` +
|
|
50
|
+
` ${PROVISION_HINT}\n`,
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (process.env.MOLTSPAY_SKIP_CLI_INSTALL === '1') {
|
|
55
|
+
console.log('[moltspay] MOLTSPAY_SKIP_CLI_INSTALL=1 — 跳过 alipay-bot 自动安装。');
|
|
56
|
+
console.log(`[moltspay] 需要时手动安装:${PROVISION_HINT}`);
|
|
57
|
+
process.exit(0);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
console.log('[moltspay] 正在从支付宝官方 CDN 安装 alipay-bot CLI(Alipay 支付轨所需)…');
|
|
61
|
+
|
|
62
|
+
// Prefer the helper we already pulled in as a declared dependency (no extra
|
|
63
|
+
// network for the helper itself). Fall back to `npx` if it isn't resolvable
|
|
64
|
+
// (odd layout / installed with --ignore-scripts on the dep).
|
|
65
|
+
let result;
|
|
66
|
+
let helperCli = null;
|
|
67
|
+
try {
|
|
68
|
+
const helperPkgJson = require.resolve('@alipay/agent-payment/package.json');
|
|
69
|
+
const helperDir = path.dirname(helperPkgJson);
|
|
70
|
+
const bin = JSON.parse(fs.readFileSync(helperPkgJson, 'utf8')).bin;
|
|
71
|
+
const rel = typeof bin === 'string' ? bin : bin && bin['agent-payment'];
|
|
72
|
+
if (rel) helperCli = path.join(helperDir, rel);
|
|
73
|
+
} catch {
|
|
74
|
+
helperCli = null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (helperCli && fs.existsSync(helperCli)) {
|
|
78
|
+
result = spawnSync(process.execPath, [helperCli, 'install-cli'], { stdio: 'inherit' });
|
|
79
|
+
} else {
|
|
80
|
+
const npx = process.platform === 'win32' ? 'npx.cmd' : 'npx';
|
|
81
|
+
result = spawnSync(npx, ['-y', '@alipay/agent-payment', 'install-cli'], { stdio: 'inherit' });
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (!result || result.error || result.status !== 0) {
|
|
85
|
+
warnManual(result && result.error ? result.error.message : '离线或无法访问 *.alipay.com');
|
|
86
|
+
} else {
|
|
87
|
+
console.log('[moltspay] alipay-bot CLI 安装完成。');
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Never block the install over an optional rail's provisioning.
|
|
91
|
+
process.exit(0);
|