@dominusnode/sdk 1.1.2 → 1.3.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 +189 -148
- package/dist/cjs/auth.d.ts +1 -0
- package/dist/cjs/auth.js +82 -2
- package/dist/cjs/client.d.ts +2 -0
- package/dist/cjs/client.js +3 -0
- package/dist/cjs/http.js +12 -6
- package/dist/cjs/index.d.ts +4 -2
- package/dist/cjs/index.js +5 -1
- package/dist/cjs/resources/agent-wallet.js +16 -6
- package/dist/cjs/resources/mpp.d.ts +161 -0
- package/dist/cjs/resources/mpp.js +132 -0
- package/dist/cjs/resources/teams.js +6 -2
- package/dist/cjs/resources/x402.d.ts +59 -4
- package/dist/cjs/resources/x402.js +39 -5
- package/dist/cjs/wallet.js +9 -3
- package/dist/esm/auth.d.ts +1 -0
- package/dist/esm/auth.js +49 -2
- package/dist/esm/client.d.ts +2 -0
- package/dist/esm/client.js +3 -0
- package/dist/esm/http.js +12 -6
- package/dist/esm/index.d.ts +4 -2
- package/dist/esm/index.js +2 -1
- package/dist/esm/resources/agent-wallet.js +16 -6
- package/dist/esm/resources/mpp.d.ts +161 -0
- package/dist/esm/resources/mpp.js +128 -0
- package/dist/esm/resources/teams.js +6 -2
- package/dist/esm/resources/x402.d.ts +59 -4
- package/dist/esm/resources/x402.js +38 -4
- package/dist/esm/wallet.js +9 -3
- package/package.json +3 -1
|
@@ -1,37 +1,92 @@
|
|
|
1
1
|
import type { HttpClient } from "../http.js";
|
|
2
|
+
/**
|
|
3
|
+
* x402 V2 protocol version.
|
|
4
|
+
* V2 uses CAIP-2 network identifiers (e.g. "eip155:8453" instead of "base").
|
|
5
|
+
*/
|
|
6
|
+
export declare const X402_PROTOCOL_VERSION = "2";
|
|
7
|
+
/**
|
|
8
|
+
* x402 V2 header constants.
|
|
9
|
+
* V2 renamed the payment headers. Servers should accept both old and new
|
|
10
|
+
* for backward compatibility during the transition period.
|
|
11
|
+
*/
|
|
12
|
+
export declare const X402_HEADERS: {
|
|
13
|
+
/** V2 payment header (replaces V1 "X-PAYMENT"). */
|
|
14
|
+
readonly PAYMENT_SIGNATURE: "PAYMENT-SIGNATURE";
|
|
15
|
+
/** V1 legacy payment header — kept for backward compatibility. */
|
|
16
|
+
readonly PAYMENT_SIGNATURE_LEGACY: "X-PAYMENT";
|
|
17
|
+
/** V2 payment response header (replaces V1 "X-PAYMENT-RESPONSE"). */
|
|
18
|
+
readonly PAYMENT_RESPONSE: "PAYMENT-RESPONSE";
|
|
19
|
+
/** V1 legacy payment response header. */
|
|
20
|
+
readonly PAYMENT_RESPONSE_LEGACY: "X-PAYMENT-RESPONSE";
|
|
21
|
+
/** V2 payment requirements header. */
|
|
22
|
+
readonly PAYMENT_REQUIRED: "PAYMENT-REQUIRED";
|
|
23
|
+
};
|
|
24
|
+
/** Payment scheme supported by x402. "exact" is the original; "permit2" is new in V2. */
|
|
25
|
+
export type X402Scheme = "exact" | "permit2";
|
|
26
|
+
/** Token supported by x402. V2 adds EURC alongside USDC. */
|
|
27
|
+
export type X402Token = "USDC" | "EURC";
|
|
2
28
|
export interface X402Facilitator {
|
|
3
29
|
address: string;
|
|
4
30
|
chain: string;
|
|
31
|
+
/** Human-readable network name (e.g. "base", "ethereum"). */
|
|
5
32
|
network: string;
|
|
33
|
+
/** CAIP-2 network identifier (e.g. "eip155:8453"). Added in V2. */
|
|
34
|
+
networkId: string;
|
|
6
35
|
}
|
|
7
36
|
export interface X402Pricing {
|
|
8
37
|
perRequestCents: number;
|
|
9
38
|
perGbCents: number;
|
|
10
39
|
currency: string;
|
|
11
40
|
}
|
|
41
|
+
export interface X402PaymentHeaders {
|
|
42
|
+
/** Header the client sends with the payment signature. */
|
|
43
|
+
request: string;
|
|
44
|
+
/** Header the server returns with the payment response. */
|
|
45
|
+
response: string;
|
|
46
|
+
/** Header the server uses to indicate payment requirements. */
|
|
47
|
+
required: string;
|
|
48
|
+
}
|
|
12
49
|
export interface X402Info {
|
|
13
50
|
supported: boolean;
|
|
14
51
|
enabled: boolean;
|
|
15
52
|
protocol: string;
|
|
53
|
+
/** Protocol version — "2" for x402 V2. */
|
|
16
54
|
version: string;
|
|
17
55
|
facilitators: X402Facilitator[];
|
|
18
56
|
pricing: X402Pricing;
|
|
57
|
+
/** Supported token symbols (e.g. ["USDC", "EURC"]). */
|
|
19
58
|
currencies: string[];
|
|
59
|
+
/** Supported payment schemes (e.g. ["exact", "permit2"]). */
|
|
60
|
+
schemes: string[];
|
|
20
61
|
walletType: string;
|
|
21
62
|
agenticWallets: boolean;
|
|
63
|
+
/** Header names used by this protocol version. */
|
|
64
|
+
paymentHeaders: X402PaymentHeaders;
|
|
22
65
|
}
|
|
23
66
|
/**
|
|
24
|
-
* x402 (HTTP 402 Payment Required) protocol information.
|
|
67
|
+
* x402 V2 (HTTP 402 Payment Required) protocol information.
|
|
25
68
|
*
|
|
26
69
|
* Provides details about x402 micropayment support, facilitator addresses,
|
|
27
|
-
* pricing,
|
|
70
|
+
* pricing, supported chains/currencies, and payment schemes for AI agent
|
|
71
|
+
* payments.
|
|
72
|
+
*
|
|
73
|
+
* V2 changes from V1:
|
|
74
|
+
* - Protocol version "2" (was "1")
|
|
75
|
+
* - CAIP-2 network IDs (e.g. "eip155:8453" instead of "base")
|
|
76
|
+
* - Payment header: PAYMENT-SIGNATURE (was X-PAYMENT)
|
|
77
|
+
* - Response header: PAYMENT-RESPONSE (was X-PAYMENT-RESPONSE)
|
|
78
|
+
* - Requirements header: PAYMENT-REQUIRED
|
|
79
|
+
* - New token: EURC (in addition to USDC)
|
|
80
|
+
* - New scheme: permit2 (in addition to exact)
|
|
81
|
+
* - Additional facilitator chains: Ethereum (eip155:1), Optimism (eip155:10),
|
|
82
|
+
* Arbitrum (eip155:42161), and Solana
|
|
28
83
|
*/
|
|
29
84
|
export declare class X402Resource {
|
|
30
85
|
private http;
|
|
31
86
|
constructor(http: HttpClient);
|
|
32
87
|
/**
|
|
33
|
-
* Get x402 protocol information including facilitator details,
|
|
34
|
-
* pricing, supported chains, and
|
|
88
|
+
* Get x402 V2 protocol information including facilitator details,
|
|
89
|
+
* pricing, supported chains, currencies, and payment schemes.
|
|
35
90
|
*
|
|
36
91
|
* This endpoint does not require authentication.
|
|
37
92
|
*/
|
|
@@ -1,8 +1,42 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* x402
|
|
2
|
+
* x402 V2 protocol version.
|
|
3
|
+
* V2 uses CAIP-2 network identifiers (e.g. "eip155:8453" instead of "base").
|
|
4
|
+
*/
|
|
5
|
+
export const X402_PROTOCOL_VERSION = "2";
|
|
6
|
+
/**
|
|
7
|
+
* x402 V2 header constants.
|
|
8
|
+
* V2 renamed the payment headers. Servers should accept both old and new
|
|
9
|
+
* for backward compatibility during the transition period.
|
|
10
|
+
*/
|
|
11
|
+
export const X402_HEADERS = {
|
|
12
|
+
/** V2 payment header (replaces V1 "X-PAYMENT"). */
|
|
13
|
+
PAYMENT_SIGNATURE: "PAYMENT-SIGNATURE",
|
|
14
|
+
/** V1 legacy payment header — kept for backward compatibility. */
|
|
15
|
+
PAYMENT_SIGNATURE_LEGACY: "X-PAYMENT",
|
|
16
|
+
/** V2 payment response header (replaces V1 "X-PAYMENT-RESPONSE"). */
|
|
17
|
+
PAYMENT_RESPONSE: "PAYMENT-RESPONSE",
|
|
18
|
+
/** V1 legacy payment response header. */
|
|
19
|
+
PAYMENT_RESPONSE_LEGACY: "X-PAYMENT-RESPONSE",
|
|
20
|
+
/** V2 payment requirements header. */
|
|
21
|
+
PAYMENT_REQUIRED: "PAYMENT-REQUIRED",
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* x402 V2 (HTTP 402 Payment Required) protocol information.
|
|
3
25
|
*
|
|
4
26
|
* Provides details about x402 micropayment support, facilitator addresses,
|
|
5
|
-
* pricing,
|
|
27
|
+
* pricing, supported chains/currencies, and payment schemes for AI agent
|
|
28
|
+
* payments.
|
|
29
|
+
*
|
|
30
|
+
* V2 changes from V1:
|
|
31
|
+
* - Protocol version "2" (was "1")
|
|
32
|
+
* - CAIP-2 network IDs (e.g. "eip155:8453" instead of "base")
|
|
33
|
+
* - Payment header: PAYMENT-SIGNATURE (was X-PAYMENT)
|
|
34
|
+
* - Response header: PAYMENT-RESPONSE (was X-PAYMENT-RESPONSE)
|
|
35
|
+
* - Requirements header: PAYMENT-REQUIRED
|
|
36
|
+
* - New token: EURC (in addition to USDC)
|
|
37
|
+
* - New scheme: permit2 (in addition to exact)
|
|
38
|
+
* - Additional facilitator chains: Ethereum (eip155:1), Optimism (eip155:10),
|
|
39
|
+
* Arbitrum (eip155:42161), and Solana
|
|
6
40
|
*/
|
|
7
41
|
export class X402Resource {
|
|
8
42
|
http;
|
|
@@ -10,8 +44,8 @@ export class X402Resource {
|
|
|
10
44
|
this.http = http;
|
|
11
45
|
}
|
|
12
46
|
/**
|
|
13
|
-
* Get x402 protocol information including facilitator details,
|
|
14
|
-
* pricing, supported chains, and
|
|
47
|
+
* Get x402 V2 protocol information including facilitator details,
|
|
48
|
+
* pricing, supported chains, currencies, and payment schemes.
|
|
15
49
|
*
|
|
16
50
|
* This endpoint does not require authentication.
|
|
17
51
|
*/
|
package/dist/esm/wallet.js
CHANGED
|
@@ -19,14 +19,18 @@ export class WalletResource {
|
|
|
19
19
|
}
|
|
20
20
|
/** Create a Stripe checkout session for wallet top-up. */
|
|
21
21
|
async topUpStripe(amountCents) {
|
|
22
|
-
if (!Number.isInteger(amountCents) ||
|
|
22
|
+
if (!Number.isInteger(amountCents) ||
|
|
23
|
+
amountCents <= 0 ||
|
|
24
|
+
amountCents > 2_147_483_647) {
|
|
23
25
|
throw new Error("amountCents must be a positive integer <= 2,147,483,647");
|
|
24
26
|
}
|
|
25
27
|
return this.http.post("/api/wallet/topup/stripe", { amountCents });
|
|
26
28
|
}
|
|
27
29
|
/** Create a crypto invoice for wallet top-up. Minimum $10 (1000 cents). */
|
|
28
30
|
async topUpCrypto(amountCents, currency) {
|
|
29
|
-
if (!Number.isInteger(amountCents) ||
|
|
31
|
+
if (!Number.isInteger(amountCents) ||
|
|
32
|
+
amountCents <= 0 ||
|
|
33
|
+
amountCents > 2_147_483_647) {
|
|
30
34
|
throw new Error("amountCents must be a positive integer <= 2,147,483,647");
|
|
31
35
|
}
|
|
32
36
|
if (amountCents < 1000) {
|
|
@@ -37,7 +41,9 @@ export class WalletResource {
|
|
|
37
41
|
}
|
|
38
42
|
/** Create a PayPal order for wallet top-up. Minimum $5 (500 cents). */
|
|
39
43
|
async topUpPaypal(amountCents) {
|
|
40
|
-
if (!Number.isInteger(amountCents) ||
|
|
44
|
+
if (!Number.isInteger(amountCents) ||
|
|
45
|
+
amountCents <= 0 ||
|
|
46
|
+
amountCents > 2_147_483_647) {
|
|
41
47
|
throw new Error("amountCents must be a positive integer <= 2,147,483,647");
|
|
42
48
|
}
|
|
43
49
|
if (amountCents < 500) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dominusnode/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Official Dominus Node SDK for Node.js/TypeScript",
|
|
5
5
|
"author": "Dominus Node",
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
],
|
|
21
21
|
"scripts": {
|
|
22
22
|
"build": "tsc -p tsconfig.json && tsc -p tsconfig.cjs.json && echo '{\"type\":\"commonjs\"}' > dist/cjs/package.json",
|
|
23
|
+
"prepare": "npm run build",
|
|
23
24
|
"test": "vitest run",
|
|
24
25
|
"clean": "rm -rf dist"
|
|
25
26
|
},
|
|
@@ -27,6 +28,7 @@
|
|
|
27
28
|
"node": ">=18.0.0"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
31
|
+
"@types/node": "^22.0.0",
|
|
30
32
|
"typescript": "^5.3.0",
|
|
31
33
|
"vitest": "^4.0.0"
|
|
32
34
|
}
|