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
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { B as BaseFacilitator, H as HealthCheckResult, X as X402PaymentPayload,
|
|
2
|
-
export {
|
|
3
|
-
export { C as CDPFacilitator, a as CDPFacilitatorConfig } from '../cdp-
|
|
4
|
-
import { Keypair, PublicKey, Transaction } from '@solana/web3.js';
|
|
1
|
+
import { B as BaseFacilitator, H as HealthCheckResult, X as X402PaymentPayload, a as X402PaymentRequirements, V as VerifyResult, S as SettleResult } from '../registry-DIo0WNoO.js';
|
|
2
|
+
export { c as Facilitator, F as FacilitatorConfig, b as FacilitatorFee, d as FacilitatorRegistry, e as FacilitatorSelection, f as SelectionStrategy, g as createRegistry, h as getDefaultRegistry } from '../registry-DIo0WNoO.js';
|
|
3
|
+
export { C as CDPFacilitator, a as CDPFacilitatorConfig } from '../cdp-B5PhDUTC.js';
|
|
4
|
+
import { Keypair, PublicKey, Connection, Transaction } from '@solana/web3.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Tempo Testnet Facilitator
|
|
@@ -20,10 +20,32 @@ declare class TempoFacilitator extends BaseFacilitator {
|
|
|
20
20
|
readonly displayName = "Tempo Testnet";
|
|
21
21
|
readonly supportedNetworks: string[];
|
|
22
22
|
private rpcUrl;
|
|
23
|
+
private settlerWallet;
|
|
23
24
|
constructor();
|
|
25
|
+
/**
|
|
26
|
+
* Settler EOA address advertised to clients via `X-Payment-Required.extra.tempoSpender`.
|
|
27
|
+
* Web Client uses this as the `spender` field in the signed EIP-2612 Permit.
|
|
28
|
+
* Returns null if no TEMPO_SETTLER_KEY is configured — permit settlement unavailable.
|
|
29
|
+
*/
|
|
30
|
+
getSpenderAddress(): string | null;
|
|
24
31
|
healthCheck(): Promise<HealthCheckResult>;
|
|
25
32
|
verify(paymentPayload: X402PaymentPayload, requirements: X402PaymentRequirements): Promise<VerifyResult>;
|
|
33
|
+
/**
|
|
34
|
+
* Structural validation of an EIP-2612 permit payload. Does NOT submit
|
|
35
|
+
* anything on-chain — actual submission happens in settlePermit().
|
|
36
|
+
*/
|
|
37
|
+
private verifyPermit;
|
|
38
|
+
private verifyTxHash;
|
|
26
39
|
settle(paymentPayload: X402PaymentPayload, requirements: X402PaymentRequirements): Promise<SettleResult>;
|
|
40
|
+
/**
|
|
41
|
+
* EIP-2612 permit settlement path. Submits two transactions on Tempo:
|
|
42
|
+
* 1. pathUSD.permit(owner, spender=settler, value, deadline, v, r, s)
|
|
43
|
+
* 2. pathUSD.transferFrom(owner, payTo, value)
|
|
44
|
+
*
|
|
45
|
+
* The settler EOA pays Tempo gas (via the TIP-20 `feeToken` mechanism — no
|
|
46
|
+
* native tTEMPO required; any held TIP-20 token balance covers fees).
|
|
47
|
+
*/
|
|
48
|
+
private settlePermit;
|
|
27
49
|
private getTransactionReceipt;
|
|
28
50
|
}
|
|
29
51
|
|
|
@@ -243,6 +265,163 @@ declare class SolanaFacilitator extends BaseFacilitator {
|
|
|
243
265
|
* @param chain - Solana chain (solana or solana_devnet)
|
|
244
266
|
* @param feePayerPubkey - Optional fee payer public key for gasless transactions
|
|
245
267
|
*/
|
|
246
|
-
declare function createSolanaPaymentTransaction(senderPubkey: PublicKey, recipientPubkey: PublicKey, amount: bigint, chain: SolanaChainName, feePayerPubkey?: PublicKey): Promise<Transaction>;
|
|
268
|
+
declare function createSolanaPaymentTransaction(senderPubkey: PublicKey, recipientPubkey: PublicKey, amount: bigint, chain: SolanaChainName, feePayerPubkey?: PublicKey, connection?: Connection): Promise<Transaction>;
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Alipay AI 收 Facilitator (2.0.0)
|
|
272
|
+
*
|
|
273
|
+
* Implements the `Facilitator` interface for Alipay's 智能收 (AI Pay) 402
|
|
274
|
+
* protocol. Adds a fiat rail (CNY) alongside the existing USDC/EVM/SVM
|
|
275
|
+
* rails. Server-side only; clients shell out to the `alipay-bot` CLI
|
|
276
|
+
* (see `AlipayClient` under `src/client/alipay/` in 1.7.0-rc.2).
|
|
277
|
+
*
|
|
278
|
+
* Key protocol differences from x402:
|
|
279
|
+
* - Wire challenge is Base64URL-encoded `Payment-Needed` header with
|
|
280
|
+
* nested `{protocol, method}` JSON (not flat `accepts[]`).
|
|
281
|
+
* - Amount unit is **元** (CNY decimal string, not atomic units).
|
|
282
|
+
* - Signature is RSA2 (SHA256WithRSA), not EIP-712 / EIP-3009.
|
|
283
|
+
* - Verify/settle hit Alipay Open API HTTP endpoints, not chain RPC.
|
|
284
|
+
*
|
|
285
|
+
* The server emits **both** `X-Payment-Required` and `Payment-Needed`
|
|
286
|
+
* headers so that legacy `alipay-bot` skills (`@alipay/agent-payment@1.0.9`)
|
|
287
|
+
* keep working without changes.
|
|
288
|
+
*
|
|
289
|
+
* @see ../../docs/ALIPAY-RAIL.md — end-user integration guide
|
|
290
|
+
* @see ../../docs/ALIPAY-INTEGRATION-DESIGN.md — architecture & decisions
|
|
291
|
+
* @see ../../docs/ALIPAY-INTEGRATION-PLAN.md — implementation milestones
|
|
292
|
+
*
|
|
293
|
+
* Stub for 1.7.0-rc.1; bodies tracked in ALIPAY-INTEGRATION-PLAN.md §1.
|
|
294
|
+
*/
|
|
295
|
+
|
|
296
|
+
/** Network identifier exposed via `Facilitator.supportedNetworks`. */
|
|
297
|
+
declare const ALIPAY_NETWORK = "alipay";
|
|
298
|
+
/** x402 `scheme` string identifying the Alipay rail in `accepts[]`. */
|
|
299
|
+
declare const ALIPAY_SCHEME = "alipay-aipay";
|
|
300
|
+
/** Default production gateway URL. */
|
|
301
|
+
declare const ALIPAY_GATEWAY_PROD = "https://openapi.alipay.com/gateway.do";
|
|
302
|
+
/** Sandbox gateway URL (for testing without real CNY). */
|
|
303
|
+
declare const ALIPAY_GATEWAY_SANDBOX = "https://openapi.alipaydev.com/gateway.do";
|
|
304
|
+
/**
|
|
305
|
+
* Facilitator-level configuration sourced from `provider.alipay` in
|
|
306
|
+
* `moltspay.services.json`. The server resolves `private_key_path` and
|
|
307
|
+
* `alipay_public_key_path` to PEM strings before constructing the facilitator.
|
|
308
|
+
*/
|
|
309
|
+
interface AlipayFacilitatorConfig {
|
|
310
|
+
/** Merchant Alipay ID (16 digits, e.g. `"2088641494699428"`). */
|
|
311
|
+
seller_id: string;
|
|
312
|
+
/** Application ID from Alipay Open Platform. */
|
|
313
|
+
app_id: string;
|
|
314
|
+
/** Merchant legal name; appears in `method.seller_name` of the 402 challenge. */
|
|
315
|
+
seller_name: string;
|
|
316
|
+
/** Fallback `service_id` when a service doesn't override it. */
|
|
317
|
+
service_id_default: string;
|
|
318
|
+
/** RSA2 merchant private key (PEM). Loaded from `private_key_path` by the server. */
|
|
319
|
+
private_key_pem: string;
|
|
320
|
+
/** Alipay platform public key (PEM). Loaded from `alipay_public_key_path` by the server. */
|
|
321
|
+
alipay_public_key_pem: string;
|
|
322
|
+
/** Open API gateway URL. Defaults to {@link ALIPAY_GATEWAY_PROD}. */
|
|
323
|
+
gateway_url?: string;
|
|
324
|
+
/** Signature algorithm. Only `RSA2` is supported. */
|
|
325
|
+
sign_type?: 'RSA2';
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Inputs required to construct a 402 `Payment-Needed` challenge for a service.
|
|
329
|
+
*/
|
|
330
|
+
interface CreatePaymentRequirementsOpts {
|
|
331
|
+
/** Per-service Alipay `service_id` (overrides `provider.alipay.service_id_default`). */
|
|
332
|
+
serviceId: string;
|
|
333
|
+
/** CNY price as decimal string in **元** (e.g. `"1.00"` = 1 CNY). */
|
|
334
|
+
priceCny: string;
|
|
335
|
+
/** Goods name shown to the user in the Alipay app. */
|
|
336
|
+
goodsName: string;
|
|
337
|
+
/** Resource identifier (typically the request URL or its hash). */
|
|
338
|
+
resourceId: string;
|
|
339
|
+
/** Client-supplied `out_trade_no`; if omitted the facilitator generates one. */
|
|
340
|
+
outTradeNo?: string;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Both headers the server emits in a 402 response:
|
|
344
|
+
* - `x402Accepts` → `X-Payment-Required` (x402 standard, for new MoltsPay clients)
|
|
345
|
+
* - `paymentNeededHeader` → `Payment-Needed` (Alipay standard, for legacy `alipay-bot`)
|
|
346
|
+
*
|
|
347
|
+
* The two headers are mirrors of each other; the single source of truth lives
|
|
348
|
+
* in the server config.
|
|
349
|
+
*/
|
|
350
|
+
interface AlipayPaymentRequirements {
|
|
351
|
+
x402Accepts: X402PaymentRequirements;
|
|
352
|
+
paymentNeededHeader: string;
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Decoded `Payment-Proof` header from the buyer's request.
|
|
356
|
+
*
|
|
357
|
+
* The proof is Base64URL of `{protocol: {...}, method: {...}}` where:
|
|
358
|
+
* - `protocol.trade_no` is the 32-digit Alipay trade number
|
|
359
|
+
* - `protocol.payment_proof` is the RSA2-signed payment proof
|
|
360
|
+
* - `method.client_session` echoes the buyer's session for replay protection
|
|
361
|
+
*/
|
|
362
|
+
interface AlipayPaymentProof {
|
|
363
|
+
protocol: {
|
|
364
|
+
payment_proof: string;
|
|
365
|
+
trade_no: string;
|
|
366
|
+
[k: string]: unknown;
|
|
367
|
+
};
|
|
368
|
+
method: {
|
|
369
|
+
client_session: string;
|
|
370
|
+
[k: string]: unknown;
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Alipay AI 收 facilitator.
|
|
375
|
+
*
|
|
376
|
+
* Construction is cheap; expensive setup (key parsing, gateway probe) is
|
|
377
|
+
* deferred to `healthCheck()`.
|
|
378
|
+
*/
|
|
379
|
+
declare class AlipayFacilitator extends BaseFacilitator {
|
|
380
|
+
readonly name = "alipay";
|
|
381
|
+
readonly displayName = "Alipay AI \u6536";
|
|
382
|
+
readonly supportedNetworks: string[];
|
|
383
|
+
private readonly config;
|
|
384
|
+
constructor(config: AlipayFacilitatorConfig);
|
|
385
|
+
/**
|
|
386
|
+
* Build the 402 challenge for a service: signs the 8-field payload with
|
|
387
|
+
* RSA2, packages the nested `{protocol, method}` JSON as Base64URL for
|
|
388
|
+
* `Payment-Needed`, and emits the parallel x402 `accepts[]` entry.
|
|
389
|
+
*/
|
|
390
|
+
createPaymentRequirements(opts: CreatePaymentRequirementsOpts): Promise<AlipayPaymentRequirements>;
|
|
391
|
+
/**
|
|
392
|
+
* Verify a `Payment-Proof` by calling
|
|
393
|
+
* `alipay.aipay.agent.payment.verify` against the Alipay Open API.
|
|
394
|
+
*
|
|
395
|
+
* The proof is conveyed via `paymentPayload.payload`, which may be:
|
|
396
|
+
* - a raw Base64URL string (the `Payment-Proof` header value), or
|
|
397
|
+
* - an object `{ paymentProof: string }` / `{ proofHeader: string }`.
|
|
398
|
+
*
|
|
399
|
+
* All failure modes (malformed payload, network errors, Alipay
|
|
400
|
+
* `code != 10000`) return `{ valid: false, error }`. No exception
|
|
401
|
+
* escapes, regardless of client-supplied input.
|
|
402
|
+
*/
|
|
403
|
+
verify(paymentPayload: X402PaymentPayload, _requirements: X402PaymentRequirements): Promise<VerifyResult>;
|
|
404
|
+
/**
|
|
405
|
+
* Settle by calling `alipay.aipay.agent.fulfillment.confirm` after the
|
|
406
|
+
* service resource has been returned to the buyer.
|
|
407
|
+
*
|
|
408
|
+
* Per the design (see ALIPAY-INTEGRATION-DESIGN.md §5.1, risk row
|
|
409
|
+
* "履约确认失败"), this is **fire-and-forget**: the caller (registry /
|
|
410
|
+
* server) is expected to log fulfillment failures but NOT roll back
|
|
411
|
+
* the already-delivered resource.
|
|
412
|
+
*
|
|
413
|
+
* Re-decodes `paymentPayload.payload` to extract `trade_no` (verify
|
|
414
|
+
* does the same; the redundant Base64URL decode is negligible).
|
|
415
|
+
*/
|
|
416
|
+
settle(paymentPayload: X402PaymentPayload, _requirements: X402PaymentRequirements): Promise<SettleResult>;
|
|
417
|
+
/**
|
|
418
|
+
* Validate that the configured RSA keys parse and that the Open API
|
|
419
|
+
* gateway is reachable. Does NOT make a real business API call (would
|
|
420
|
+
* burn quota and could appear as a legitimate verify attempt in logs).
|
|
421
|
+
*/
|
|
422
|
+
healthCheck(): Promise<HealthCheckResult>;
|
|
423
|
+
/** Bundle the facilitator config into the shape openapi.ts wants. */
|
|
424
|
+
private getOpenApiConfig;
|
|
425
|
+
}
|
|
247
426
|
|
|
248
|
-
export { BNBFacilitator, type BNBPaymentIntent, BaseFacilitator, HealthCheckResult, SettleResult, SolanaFacilitator, type SolanaPaymentPayload, TempoFacilitator, VerifyResult, X402PaymentPayload, X402PaymentRequirements, createIntentTypedData, createSolanaPaymentTransaction };
|
|
427
|
+
export { ALIPAY_GATEWAY_PROD, ALIPAY_GATEWAY_SANDBOX, ALIPAY_NETWORK, ALIPAY_SCHEME, AlipayFacilitator, type AlipayFacilitatorConfig, type AlipayPaymentProof, type AlipayPaymentRequirements, BNBFacilitator, type BNBPaymentIntent, BaseFacilitator, type CreatePaymentRequirementsOpts, HealthCheckResult, SettleResult, SolanaFacilitator, type SolanaPaymentPayload, TempoFacilitator, VerifyResult, X402PaymentPayload, X402PaymentRequirements, createIntentTypedData, createSolanaPaymentTransaction };
|