moltspay 1.5.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 +143 -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 +1941 -204
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/index.mjs +1938 -201
- package/dist/cli/index.mjs.map +1 -1
- package/dist/client/index.d.mts +46 -0
- package/dist/client/index.d.ts +46 -0
- package/dist/client/index.js +1059 -118
- package/dist/client/index.js.map +1 -1
- package/dist/client/index.mjs +1055 -116
- package/dist/client/index.mjs.map +1 -1
- package/dist/client/web/index.d.mts +434 -0
- package/dist/client/web/index.mjs +1300 -0
- package/dist/client/web/index.mjs.map +1 -0
- package/dist/facilitators/index.d.mts +185 -6
- package/dist/facilitators/index.d.ts +185 -6
- package/dist/facilitators/index.js +497 -13
- package/dist/facilitators/index.js.map +1 -1
- package/dist/facilitators/index.mjs +492 -13
- 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 +1865 -172
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1854 -167
- package/dist/index.mjs.map +1 -1
- package/dist/mcp/index.js +1062 -123
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/index.mjs +1059 -120
- 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 +137 -2
- package/dist/server/index.d.ts +137 -2
- package/dist/server/index.js +757 -30
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +757 -30
- 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 +15 -2
- package/schemas/moltspay.services.schema.json +100 -6
- package/scripts/postinstall.js +91 -0
package/dist/index.d.mts
CHANGED
|
@@ -4,7 +4,82 @@ export { CHAINS, ERC20_ABI, getChain, getChainById, listChains } from './chains/
|
|
|
4
4
|
export { c as createWallet, g as getWalletAddress, l as loadWallet, w as walletExists } from './createWallet-D53qu7ie.mjs';
|
|
5
5
|
export { VerifyPaymentParams, VerifyPaymentResult, getTransactionStatus, verifyPayment, waitForTransaction } from './verify/index.mjs';
|
|
6
6
|
export { CDPWallet, getCDPWalletAddress, initCDPWallet, isCDPAvailable, loadCDPWallet } from './cdp/index.mjs';
|
|
7
|
-
export { B as BaseFacilitator,
|
|
8
|
-
export { C as CDPFacilitator, a as CDPFacilitatorConfig } from './cdp-
|
|
7
|
+
export { B as BaseFacilitator, c as Facilitator, F as FacilitatorConfig, b as FacilitatorFee, d as FacilitatorRegistry, e as FacilitatorSelection, H as HealthCheckResult, f as SelectionStrategy, S as SettleResult, V as VerifyResult, X as X402PaymentPayload, a as X402PaymentRequirements, g as createRegistry, h as getDefaultRegistry } from './registry-DIo0WNoO.mjs';
|
|
8
|
+
export { C as CDPFacilitator, a as CDPFacilitatorConfig } from './cdp-D-5Hg3y_.mjs';
|
|
9
9
|
import 'ethers';
|
|
10
10
|
import './index-D_2FkLwV.mjs';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Alipay rail log management (design §5.2 observability).
|
|
14
|
+
*
|
|
15
|
+
* The Alipay rail's latency lives in a chain of `alipay-bot` subprocess spawns
|
|
16
|
+
* and gateway round-trips that, in production, are invisible: the only output is
|
|
17
|
+
* the verbatim CLI passthrough the skill guide mandates on stdout. This module
|
|
18
|
+
* adds a structured, opt-in log channel so every node of the `pay402` state
|
|
19
|
+
* machine — and how long it took — can be observed and routed into the host
|
|
20
|
+
* app's log pipeline, WITHOUT changing default behavior or polluting stdout.
|
|
21
|
+
*
|
|
22
|
+
* Usage (host app):
|
|
23
|
+
* import { setAlipayLogLevel, setAlipayLogSink } from 'moltspay';
|
|
24
|
+
* setAlipayLogLevel('info'); // or env MOLTSPAY_ALIPAY_LOG=info
|
|
25
|
+
* setAlipayLogSink((line) => myLogger.info(line)); // default: process.stderr
|
|
26
|
+
*
|
|
27
|
+
* Levels: 'off' (default) < 'info' (node timings + flow totals) < 'debug'
|
|
28
|
+
* (adds per-spawn start/exit and per-poll ticks). The level is read from
|
|
29
|
+
* MOLTSPAY_ALIPAY_LOG at load and can be overridden at runtime.
|
|
30
|
+
*/
|
|
31
|
+
type AlipayLogLevel = 'off' | 'info' | 'debug';
|
|
32
|
+
/** A single structured log record. The sink receives both the line and this. */
|
|
33
|
+
interface AlipayLogEvent {
|
|
34
|
+
/** ISO-8601 timestamp. */
|
|
35
|
+
ts: string;
|
|
36
|
+
level: 'info' | 'debug';
|
|
37
|
+
/** Event name: flow.start | flow.pending | flow.settled | flow.failed |
|
|
38
|
+
* step.start | step.end | cli.exit | poll.tick. */
|
|
39
|
+
event: string;
|
|
40
|
+
/** Correlation id grouping all lines of one payment flow (session/tradeNo). */
|
|
41
|
+
flow?: string;
|
|
42
|
+
/** Node/step name, e.g. 'ensure-cli', 'payment-intent', '402-buyer-pay'. */
|
|
43
|
+
step?: string;
|
|
44
|
+
/** Elapsed milliseconds (on *.end / *.exit / flow.* total events). */
|
|
45
|
+
ms?: number;
|
|
46
|
+
[k: string]: unknown;
|
|
47
|
+
}
|
|
48
|
+
type AlipayLogSink = (line: string, event: AlipayLogEvent) => void;
|
|
49
|
+
/** Set the verbosity at runtime (overrides the MOLTSPAY_ALIPAY_LOG env). */
|
|
50
|
+
declare function setAlipayLogLevel(next: AlipayLogLevel): void;
|
|
51
|
+
/** Current effective level. */
|
|
52
|
+
declare function getAlipayLogLevel(): AlipayLogLevel;
|
|
53
|
+
/** Route alipay log lines anywhere (host log pipeline, file, collector, …). */
|
|
54
|
+
declare function setAlipayLogSink(fn: AlipayLogSink): void;
|
|
55
|
+
declare const alipayLog: {
|
|
56
|
+
info: (event: string, fields?: Record<string, unknown>) => void;
|
|
57
|
+
debug: (event: string, fields?: Record<string, unknown>) => void;
|
|
58
|
+
/** True if anything at all would be logged (cheap guard for hot paths). */
|
|
59
|
+
enabled: () => boolean;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* AlipayClient — the 8-step `pay402()` state machine (design §5.2.3).
|
|
64
|
+
*
|
|
65
|
+
* The Alipay skill guide §5 forbids skipping any step; each maps to one
|
|
66
|
+
* `alipay-bot` spawn. This class drives them in order and hands the caller a
|
|
67
|
+
* single terminal `AlipayPaymentResult`, so paying via Alipay looks the same
|
|
68
|
+
* as awaiting an EVM settle (design §5.2.3 "关键设计").
|
|
69
|
+
*
|
|
70
|
+
* 0. ensureCli() version gate (≥ MIN_CLI_VERSION)
|
|
71
|
+
* 1b. alipay-bot payment-intent … session handshake
|
|
72
|
+
* 2. alipay-bot check-wallet → NeedsWalletSetupError if unopened
|
|
73
|
+
* 3. dump Payment-Needed → tmp file (internal, user-invisible)
|
|
74
|
+
* 4. alipay-bot 402-buyer-pay -f … -r … → paymentUrl + tradeNo → onPaymentPending
|
|
75
|
+
* 5. pollUntil(tradeNo) 3s poll until paid / rejected / timeout
|
|
76
|
+
* 7. return resource body
|
|
77
|
+
* 8. alipay-bot 402-buyer-fulfillment-ack fire-and-forget
|
|
78
|
+
*/
|
|
79
|
+
|
|
80
|
+
/** Clear the check-wallet cache (tests, or after the user (un)binds a wallet). */
|
|
81
|
+
declare function resetWalletCache(): void;
|
|
82
|
+
/** Clear the payment-intent skip-cache (tests, or after (un)bind / session reset). */
|
|
83
|
+
declare function resetIntentCache(): void;
|
|
84
|
+
|
|
85
|
+
export { type AlipayLogEvent, type AlipayLogLevel, type AlipayLogSink, alipayLog, getAlipayLogLevel, resetIntentCache, resetWalletCache, setAlipayLogLevel, setAlipayLogSink };
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,82 @@ export { CHAINS, ERC20_ABI, getChain, getChainById, listChains } from './chains/
|
|
|
4
4
|
export { c as createWallet, g as getWalletAddress, l as loadWallet, w as walletExists } from './createWallet-D53qu7ie.js';
|
|
5
5
|
export { VerifyPaymentParams, VerifyPaymentResult, getTransactionStatus, verifyPayment, waitForTransaction } from './verify/index.js';
|
|
6
6
|
export { CDPWallet, getCDPWalletAddress, initCDPWallet, isCDPAvailable, loadCDPWallet } from './cdp/index.js';
|
|
7
|
-
export { B as BaseFacilitator,
|
|
8
|
-
export { C as CDPFacilitator, a as CDPFacilitatorConfig } from './cdp-
|
|
7
|
+
export { B as BaseFacilitator, c as Facilitator, F as FacilitatorConfig, b as FacilitatorFee, d as FacilitatorRegistry, e as FacilitatorSelection, H as HealthCheckResult, f as SelectionStrategy, S as SettleResult, V as VerifyResult, X as X402PaymentPayload, a as X402PaymentRequirements, g as createRegistry, h as getDefaultRegistry } from './registry-DIo0WNoO.js';
|
|
8
|
+
export { C as CDPFacilitator, a as CDPFacilitatorConfig } from './cdp-B5PhDUTC.js';
|
|
9
9
|
import 'ethers';
|
|
10
10
|
import './index-D_2FkLwV.js';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Alipay rail log management (design §5.2 observability).
|
|
14
|
+
*
|
|
15
|
+
* The Alipay rail's latency lives in a chain of `alipay-bot` subprocess spawns
|
|
16
|
+
* and gateway round-trips that, in production, are invisible: the only output is
|
|
17
|
+
* the verbatim CLI passthrough the skill guide mandates on stdout. This module
|
|
18
|
+
* adds a structured, opt-in log channel so every node of the `pay402` state
|
|
19
|
+
* machine — and how long it took — can be observed and routed into the host
|
|
20
|
+
* app's log pipeline, WITHOUT changing default behavior or polluting stdout.
|
|
21
|
+
*
|
|
22
|
+
* Usage (host app):
|
|
23
|
+
* import { setAlipayLogLevel, setAlipayLogSink } from 'moltspay';
|
|
24
|
+
* setAlipayLogLevel('info'); // or env MOLTSPAY_ALIPAY_LOG=info
|
|
25
|
+
* setAlipayLogSink((line) => myLogger.info(line)); // default: process.stderr
|
|
26
|
+
*
|
|
27
|
+
* Levels: 'off' (default) < 'info' (node timings + flow totals) < 'debug'
|
|
28
|
+
* (adds per-spawn start/exit and per-poll ticks). The level is read from
|
|
29
|
+
* MOLTSPAY_ALIPAY_LOG at load and can be overridden at runtime.
|
|
30
|
+
*/
|
|
31
|
+
type AlipayLogLevel = 'off' | 'info' | 'debug';
|
|
32
|
+
/** A single structured log record. The sink receives both the line and this. */
|
|
33
|
+
interface AlipayLogEvent {
|
|
34
|
+
/** ISO-8601 timestamp. */
|
|
35
|
+
ts: string;
|
|
36
|
+
level: 'info' | 'debug';
|
|
37
|
+
/** Event name: flow.start | flow.pending | flow.settled | flow.failed |
|
|
38
|
+
* step.start | step.end | cli.exit | poll.tick. */
|
|
39
|
+
event: string;
|
|
40
|
+
/** Correlation id grouping all lines of one payment flow (session/tradeNo). */
|
|
41
|
+
flow?: string;
|
|
42
|
+
/** Node/step name, e.g. 'ensure-cli', 'payment-intent', '402-buyer-pay'. */
|
|
43
|
+
step?: string;
|
|
44
|
+
/** Elapsed milliseconds (on *.end / *.exit / flow.* total events). */
|
|
45
|
+
ms?: number;
|
|
46
|
+
[k: string]: unknown;
|
|
47
|
+
}
|
|
48
|
+
type AlipayLogSink = (line: string, event: AlipayLogEvent) => void;
|
|
49
|
+
/** Set the verbosity at runtime (overrides the MOLTSPAY_ALIPAY_LOG env). */
|
|
50
|
+
declare function setAlipayLogLevel(next: AlipayLogLevel): void;
|
|
51
|
+
/** Current effective level. */
|
|
52
|
+
declare function getAlipayLogLevel(): AlipayLogLevel;
|
|
53
|
+
/** Route alipay log lines anywhere (host log pipeline, file, collector, …). */
|
|
54
|
+
declare function setAlipayLogSink(fn: AlipayLogSink): void;
|
|
55
|
+
declare const alipayLog: {
|
|
56
|
+
info: (event: string, fields?: Record<string, unknown>) => void;
|
|
57
|
+
debug: (event: string, fields?: Record<string, unknown>) => void;
|
|
58
|
+
/** True if anything at all would be logged (cheap guard for hot paths). */
|
|
59
|
+
enabled: () => boolean;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* AlipayClient — the 8-step `pay402()` state machine (design §5.2.3).
|
|
64
|
+
*
|
|
65
|
+
* The Alipay skill guide §5 forbids skipping any step; each maps to one
|
|
66
|
+
* `alipay-bot` spawn. This class drives them in order and hands the caller a
|
|
67
|
+
* single terminal `AlipayPaymentResult`, so paying via Alipay looks the same
|
|
68
|
+
* as awaiting an EVM settle (design §5.2.3 "关键设计").
|
|
69
|
+
*
|
|
70
|
+
* 0. ensureCli() version gate (≥ MIN_CLI_VERSION)
|
|
71
|
+
* 1b. alipay-bot payment-intent … session handshake
|
|
72
|
+
* 2. alipay-bot check-wallet → NeedsWalletSetupError if unopened
|
|
73
|
+
* 3. dump Payment-Needed → tmp file (internal, user-invisible)
|
|
74
|
+
* 4. alipay-bot 402-buyer-pay -f … -r … → paymentUrl + tradeNo → onPaymentPending
|
|
75
|
+
* 5. pollUntil(tradeNo) 3s poll until paid / rejected / timeout
|
|
76
|
+
* 7. return resource body
|
|
77
|
+
* 8. alipay-bot 402-buyer-fulfillment-ack fire-and-forget
|
|
78
|
+
*/
|
|
79
|
+
|
|
80
|
+
/** Clear the check-wallet cache (tests, or after the user (un)binds a wallet). */
|
|
81
|
+
declare function resetWalletCache(): void;
|
|
82
|
+
/** Clear the payment-intent skip-cache (tests, or after (un)bind / session reset). */
|
|
83
|
+
declare function resetIntentCache(): void;
|
|
84
|
+
|
|
85
|
+
export { type AlipayLogEvent, type AlipayLogLevel, type AlipayLogSink, alipayLog, getAlipayLogLevel, resetIntentCache, resetWalletCache, setAlipayLogLevel, setAlipayLogSink };
|