@aastar/sdk 0.20.8 → 0.21.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/dist/BaseClient-CkBhQ1ou.d.cts +88 -0
- package/dist/UserClient-BDGP37PK.js +6 -0
- package/dist/{UserClient-AIIHB54I.js.map → UserClient-BDGP37PK.js.map} +1 -1
- package/dist/UserClient-FOAOBLGK.cjs +15 -0
- package/dist/UserClient-FOAOBLGK.cjs.map +1 -0
- package/dist/account.cjs +31 -0
- package/dist/account.cjs.map +1 -0
- package/dist/account.d.cts +48 -0
- package/dist/account.js +3 -3
- package/dist/admin.cjs +15 -0
- package/dist/admin.cjs.map +1 -0
- package/dist/admin.d.cts +62 -0
- package/dist/admin.js +3 -3
- package/dist/airaccount.cjs +452 -0
- package/dist/airaccount.cjs.map +1 -0
- package/dist/airaccount.d.cts +4 -0
- package/dist/airaccount.js +3 -3
- package/dist/channel-CkRRbzT8.d.cts +77 -0
- package/dist/channel.cjs +27 -0
- package/dist/channel.cjs.map +1 -0
- package/dist/channel.d.cts +64 -0
- package/dist/channel.js +3 -3
- package/dist/chunk-3HZEIFBW.cjs +118 -0
- package/dist/chunk-3HZEIFBW.cjs.map +1 -0
- package/dist/{chunk-7ARJ3OSU.js → chunk-57XLR2NT.js} +3 -3
- package/dist/{chunk-7ARJ3OSU.js.map → chunk-57XLR2NT.js.map} +1 -1
- package/dist/chunk-5JFYTJOE.cjs +448 -0
- package/dist/chunk-5JFYTJOE.cjs.map +1 -0
- package/dist/{chunk-KDH3UPKD.js → chunk-5NKU5NT5.js} +8 -8
- package/dist/{chunk-KDH3UPKD.js.map → chunk-5NKU5NT5.js.map} +1 -1
- package/dist/chunk-63JM67L7.cjs +435 -0
- package/dist/chunk-63JM67L7.cjs.map +1 -0
- package/dist/{chunk-IC3G6YM2.js → chunk-6OWZOTE7.js} +113 -9
- package/dist/chunk-6OWZOTE7.js.map +1 -0
- package/dist/chunk-CIEYY3A6.cjs +43259 -0
- package/dist/chunk-CIEYY3A6.cjs.map +1 -0
- package/dist/chunk-DEUBKZH5.cjs +421 -0
- package/dist/chunk-DEUBKZH5.cjs.map +1 -0
- package/dist/{chunk-TENYCMJ3.js → chunk-DF4WVR2H.js} +9 -9
- package/dist/{chunk-TENYCMJ3.js.map → chunk-DF4WVR2H.js.map} +1 -1
- package/dist/{chunk-BN5WY5GM.js → chunk-DQBKE4ND.js} +4 -4
- package/dist/{chunk-BN5WY5GM.js.map → chunk-DQBKE4ND.js.map} +1 -1
- package/dist/{chunk-4EZD7LPE.js → chunk-E4CQFW75.js} +3 -3
- package/dist/{chunk-4EZD7LPE.js.map → chunk-E4CQFW75.js.map} +1 -1
- package/dist/{chunk-LXWIPTPX.js → chunk-ENSMYCU6.js} +3 -3
- package/dist/{chunk-LXWIPTPX.js.map → chunk-ENSMYCU6.js.map} +1 -1
- package/dist/{chunk-FJ7XECC5.js → chunk-EY2AJTGV.js} +3 -3
- package/dist/{chunk-FJ7XECC5.js.map → chunk-EY2AJTGV.js.map} +1 -1
- package/dist/chunk-GAMSWXWI.cjs +1168 -0
- package/dist/chunk-GAMSWXWI.cjs.map +1 -0
- package/dist/chunk-IJN776TA.cjs +585 -0
- package/dist/chunk-IJN776TA.cjs.map +1 -0
- package/dist/{chunk-PKCHRXFR.js → chunk-KZERVPUR.js} +3 -3
- package/dist/{chunk-PKCHRXFR.js.map → chunk-KZERVPUR.js.map} +1 -1
- package/dist/{chunk-6QYXGMCR.js → chunk-M5WFKETT.js} +833 -47
- package/dist/chunk-M5WFKETT.js.map +1 -0
- package/dist/chunk-M7HXR7G5.cjs +128 -0
- package/dist/chunk-M7HXR7G5.cjs.map +1 -0
- package/dist/{chunk-PAABYXS6.js → chunk-MCALA6WM.js} +6 -6
- package/dist/{chunk-PAABYXS6.js.map → chunk-MCALA6WM.js.map} +1 -1
- package/dist/chunk-MXJEULSE.cjs +396 -0
- package/dist/chunk-MXJEULSE.cjs.map +1 -0
- package/dist/chunk-OVNOSAL3.cjs +4797 -0
- package/dist/chunk-OVNOSAL3.cjs.map +1 -0
- package/dist/chunk-Q7SFCCGT.cjs +11 -0
- package/dist/chunk-Q7SFCCGT.cjs.map +1 -0
- package/dist/{chunk-MVEWJIPY.js → chunk-RXPSL33E.js} +3 -3
- package/dist/{chunk-MVEWJIPY.js.map → chunk-RXPSL33E.js.map} +1 -1
- package/dist/{chunk-G3UJC4EL.js → chunk-UCLK6LTB.js} +39 -36
- package/dist/chunk-UCLK6LTB.js.map +1 -0
- package/dist/chunk-WR4OZUXR.cjs +115 -0
- package/dist/chunk-WR4OZUXR.cjs.map +1 -0
- package/dist/chunk-XQROKLZI.cjs +4521 -0
- package/dist/chunk-XQROKLZI.cjs.map +1 -0
- package/dist/chunk-Y4EJX7UA.cjs +228 -0
- package/dist/chunk-Y4EJX7UA.cjs.map +1 -0
- package/dist/chunk-Z4GZ6DQA.cjs +108 -0
- package/dist/chunk-Z4GZ6DQA.cjs.map +1 -0
- package/dist/contract-addresses-RABD77VP.cjs +49 -0
- package/dist/contract-addresses-RABD77VP.cjs.map +1 -0
- package/dist/{contract-addresses-N3TOL2WL.js → contract-addresses-TVXSRQ7I.js} +3 -3
- package/dist/{contract-addresses-N3TOL2WL.js.map → contract-addresses-TVXSRQ7I.js.map} +1 -1
- package/dist/core.cjs +898 -0
- package/dist/core.cjs.map +1 -0
- package/dist/core.d.cts +7048 -0
- package/dist/core.d.ts +130 -12
- package/dist/core.js +2 -2
- package/dist/dapp.cjs +289 -0
- package/dist/dapp.cjs.map +1 -0
- package/dist/dapp.d.cts +127 -0
- package/dist/dapp.js +3 -3
- package/dist/doc-types-471vSmPO.d.cts +16 -0
- package/dist/enduser.cjs +24 -0
- package/dist/enduser.cjs.map +1 -0
- package/dist/enduser.d.cts +261 -0
- package/dist/enduser.js +4 -4
- package/dist/identity.cjs +23 -0
- package/dist/identity.cjs.map +1 -0
- package/dist/identity.d.cts +81 -0
- package/dist/identity.js +3 -3
- package/dist/index-B6SfEQxo.d.cts +47 -0
- package/dist/index.cjs +2818 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +656 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +17 -17
- package/dist/kms.cjs +452 -0
- package/dist/kms.cjs.map +1 -0
- package/dist/kms.d.cts +3104 -0
- package/dist/kms.d.ts +62 -12
- package/dist/kms.js +3 -3
- package/dist/lib-FE4GR7TO.cjs +1865 -0
- package/dist/lib-FE4GR7TO.cjs.map +1 -0
- package/dist/operator.cjs +27 -0
- package/dist/operator.cjs.map +1 -0
- package/dist/operator.d.cts +164 -0
- package/dist/operator.js +3 -3
- package/dist/paymaster.cjs +63 -0
- package/dist/paymaster.cjs.map +1 -0
- package/dist/paymaster.d.cts +312 -0
- package/dist/paymaster.js +3 -3
- package/dist/src-CUHI6G6W.cjs +898 -0
- package/dist/src-CUHI6G6W.cjs.map +1 -0
- package/dist/src-KHCWIS4Q.cjs +63 -0
- package/dist/src-KHCWIS4Q.cjs.map +1 -0
- package/dist/{src-X5MIV3EB.js → src-RSN4U2T2.js} +5 -5
- package/dist/src-RSN4U2T2.js.map +1 -0
- package/dist/{src-L5SI5WNB.js → src-XCV6BTSV.js} +4 -4
- package/dist/{src-X5MIV3EB.js.map → src-XCV6BTSV.js.map} +1 -1
- package/dist/tier-router-DeeVg69O.d.cts +370 -0
- package/dist/tokens.cjs +15 -0
- package/dist/tokens.cjs.map +1 -0
- package/dist/tokens.d.cts +64 -0
- package/dist/tokens.js +3 -3
- package/dist/x402.cjs +103 -0
- package/dist/x402.cjs.map +1 -0
- package/dist/x402.d.cts +373 -0
- package/dist/x402.js +3 -3
- package/package.json +116 -32
- package/dist/UserClient-AIIHB54I.js +0 -6
- package/dist/chunk-6QYXGMCR.js.map +0 -1
- package/dist/chunk-G3UJC4EL.js.map +0 -1
- package/dist/chunk-IC3G6YM2.js.map +0 -1
- package/dist/src-L5SI5WNB.js.map +0 -1
package/dist/x402.cjs
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunk5JFYTJOE_cjs = require('./chunk-5JFYTJOE.cjs');
|
|
4
|
+
require('./chunk-CIEYY3A6.cjs');
|
|
5
|
+
require('./chunk-MXJEULSE.cjs');
|
|
6
|
+
require('./chunk-Q7SFCCGT.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
Object.defineProperty(exports, "EIP3009_TYPES", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () { return chunk5JFYTJOE_cjs.EIP3009_TYPES; }
|
|
13
|
+
});
|
|
14
|
+
Object.defineProperty(exports, "FacilitatorClient", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return chunk5JFYTJOE_cjs.FacilitatorClient; }
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "GTOKEN_EIP712_DOMAIN", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () { return chunk5JFYTJOE_cjs.GTOKEN_EIP712_DOMAIN; }
|
|
21
|
+
});
|
|
22
|
+
Object.defineProperty(exports, "HEADER_PAYMENT_REQUIRED", {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function () { return chunk5JFYTJOE_cjs.HEADER_PAYMENT_REQUIRED; }
|
|
25
|
+
});
|
|
26
|
+
Object.defineProperty(exports, "HEADER_PAYMENT_RESPONSE", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function () { return chunk5JFYTJOE_cjs.HEADER_PAYMENT_RESPONSE; }
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "HEADER_PAYMENT_SIGNATURE", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () { return chunk5JFYTJOE_cjs.HEADER_PAYMENT_SIGNATURE; }
|
|
33
|
+
});
|
|
34
|
+
Object.defineProperty(exports, "HEADER_V1_PAYMENT", {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
get: function () { return chunk5JFYTJOE_cjs.HEADER_V1_PAYMENT; }
|
|
37
|
+
});
|
|
38
|
+
Object.defineProperty(exports, "HEADER_V1_PAYMENT_RESPONSE", {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: function () { return chunk5JFYTJOE_cjs.HEADER_V1_PAYMENT_RESPONSE; }
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, "X402Client", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function () { return chunk5JFYTJOE_cjs.X402Client; }
|
|
45
|
+
});
|
|
46
|
+
Object.defineProperty(exports, "decodePaymentPayload", {
|
|
47
|
+
enumerable: true,
|
|
48
|
+
get: function () { return chunk5JFYTJOE_cjs.decodePaymentPayload; }
|
|
49
|
+
});
|
|
50
|
+
Object.defineProperty(exports, "decodePaymentRequired", {
|
|
51
|
+
enumerable: true,
|
|
52
|
+
get: function () { return chunk5JFYTJOE_cjs.decodePaymentRequired; }
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(exports, "decodeSettleResponse", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () { return chunk5JFYTJOE_cjs.decodeSettleResponse; }
|
|
57
|
+
});
|
|
58
|
+
Object.defineProperty(exports, "encodePaymentPayload", {
|
|
59
|
+
enumerable: true,
|
|
60
|
+
get: function () { return chunk5JFYTJOE_cjs.encodePaymentPayload; }
|
|
61
|
+
});
|
|
62
|
+
Object.defineProperty(exports, "encodePaymentRequired", {
|
|
63
|
+
enumerable: true,
|
|
64
|
+
get: function () { return chunk5JFYTJOE_cjs.encodePaymentRequired; }
|
|
65
|
+
});
|
|
66
|
+
Object.defineProperty(exports, "encodeSettleResponse", {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function () { return chunk5JFYTJOE_cjs.encodeSettleResponse; }
|
|
69
|
+
});
|
|
70
|
+
Object.defineProperty(exports, "extractPaymentRequired", {
|
|
71
|
+
enumerable: true,
|
|
72
|
+
get: function () { return chunk5JFYTJOE_cjs.extractPaymentRequired; }
|
|
73
|
+
});
|
|
74
|
+
Object.defineProperty(exports, "extractSettleResponse", {
|
|
75
|
+
enumerable: true,
|
|
76
|
+
get: function () { return chunk5JFYTJOE_cjs.extractSettleResponse; }
|
|
77
|
+
});
|
|
78
|
+
Object.defineProperty(exports, "generateNonce", {
|
|
79
|
+
enumerable: true,
|
|
80
|
+
get: function () { return chunk5JFYTJOE_cjs.generateNonce; }
|
|
81
|
+
});
|
|
82
|
+
Object.defineProperty(exports, "getEIP3009Domain", {
|
|
83
|
+
enumerable: true,
|
|
84
|
+
get: function () { return chunk5JFYTJOE_cjs.getEIP3009Domain; }
|
|
85
|
+
});
|
|
86
|
+
Object.defineProperty(exports, "signCancelAuthorization", {
|
|
87
|
+
enumerable: true,
|
|
88
|
+
get: function () { return chunk5JFYTJOE_cjs.signCancelAuthorization; }
|
|
89
|
+
});
|
|
90
|
+
Object.defineProperty(exports, "signGTokenTransferWithAuthorization", {
|
|
91
|
+
enumerable: true,
|
|
92
|
+
get: function () { return chunk5JFYTJOE_cjs.signGTokenTransferWithAuthorization; }
|
|
93
|
+
});
|
|
94
|
+
Object.defineProperty(exports, "signReceiveWithAuthorization", {
|
|
95
|
+
enumerable: true,
|
|
96
|
+
get: function () { return chunk5JFYTJOE_cjs.signReceiveWithAuthorization; }
|
|
97
|
+
});
|
|
98
|
+
Object.defineProperty(exports, "signTransferWithAuthorization", {
|
|
99
|
+
enumerable: true,
|
|
100
|
+
get: function () { return chunk5JFYTJOE_cjs.signTransferWithAuthorization; }
|
|
101
|
+
});
|
|
102
|
+
//# sourceMappingURL=x402.cjs.map
|
|
103
|
+
//# sourceMappingURL=x402.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"x402.cjs"}
|
package/dist/x402.d.cts
ADDED
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
import { Address, Hex, PublicClient, WalletClient } from 'viem';
|
|
2
|
+
|
|
3
|
+
/** CAIP-2 network identifier (e.g. "eip155:11155111" for Sepolia) */
|
|
4
|
+
type NetworkId = `eip155:${number}` | `solana:${string}`;
|
|
5
|
+
/** Resource description in 402 response */
|
|
6
|
+
type ResourceInfo = {
|
|
7
|
+
url: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
mimeType?: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Payment requirements — one option in the `accepts` array.
|
|
13
|
+
* Matches @x402/core PaymentRequirements.
|
|
14
|
+
*/
|
|
15
|
+
type PaymentRequirements = {
|
|
16
|
+
scheme: 'exact' | 'upto';
|
|
17
|
+
network: NetworkId;
|
|
18
|
+
asset: Address;
|
|
19
|
+
amount: string;
|
|
20
|
+
payTo: Address;
|
|
21
|
+
maxTimeoutSeconds: number;
|
|
22
|
+
extra: {
|
|
23
|
+
name: string;
|
|
24
|
+
version: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* 402 response body / PAYMENT-REQUIRED header.
|
|
29
|
+
* Server sends this to indicate payment is needed.
|
|
30
|
+
*/
|
|
31
|
+
type PaymentRequired = {
|
|
32
|
+
x402Version: 2;
|
|
33
|
+
error?: string;
|
|
34
|
+
resource: ResourceInfo;
|
|
35
|
+
accepts: PaymentRequirements[];
|
|
36
|
+
extensions?: Record<string, unknown>;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* EIP-3009 TransferWithAuthorization parameters.
|
|
40
|
+
*/
|
|
41
|
+
type EIP3009Authorization = {
|
|
42
|
+
from: Address;
|
|
43
|
+
to: Address;
|
|
44
|
+
value: string;
|
|
45
|
+
validAfter: string;
|
|
46
|
+
validBefore: string;
|
|
47
|
+
nonce: Hex;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Client payment payload — PAYMENT-SIGNATURE header.
|
|
51
|
+
* Client sends this on retry request.
|
|
52
|
+
*/
|
|
53
|
+
type PaymentPayload = {
|
|
54
|
+
x402Version: 2;
|
|
55
|
+
resource?: ResourceInfo;
|
|
56
|
+
accepted: PaymentRequirements;
|
|
57
|
+
payload: {
|
|
58
|
+
signature: Hex;
|
|
59
|
+
authorization: EIP3009Authorization;
|
|
60
|
+
};
|
|
61
|
+
extensions?: Record<string, unknown>;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Settlement response — PAYMENT-RESPONSE header.
|
|
65
|
+
* Server returns after facilitator settles.
|
|
66
|
+
*/
|
|
67
|
+
type SettleResponse = {
|
|
68
|
+
success: boolean;
|
|
69
|
+
transaction?: string;
|
|
70
|
+
network?: NetworkId;
|
|
71
|
+
payer?: Address;
|
|
72
|
+
errorReason?: string;
|
|
73
|
+
extensions?: Record<string, unknown>;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Facilitator verify response.
|
|
77
|
+
*/
|
|
78
|
+
type VerifyResponse = {
|
|
79
|
+
isValid: boolean;
|
|
80
|
+
invalidReason?: string;
|
|
81
|
+
payer?: Address;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Facilitator supported kinds response.
|
|
85
|
+
*/
|
|
86
|
+
type FacilitatorSupported = {
|
|
87
|
+
kinds: Array<{
|
|
88
|
+
x402Version: number;
|
|
89
|
+
scheme: string;
|
|
90
|
+
network: string;
|
|
91
|
+
extra?: Record<string, unknown>;
|
|
92
|
+
}>;
|
|
93
|
+
extensions: string[];
|
|
94
|
+
};
|
|
95
|
+
/** Direct settlement (for xPNTs and pre-approved tokens, bypasses EIP-3009) */
|
|
96
|
+
type DirectPaymentPayload = {
|
|
97
|
+
x402Version: 2;
|
|
98
|
+
scheme: 'direct';
|
|
99
|
+
from: Address;
|
|
100
|
+
to: Address;
|
|
101
|
+
asset: Address;
|
|
102
|
+
amount: string;
|
|
103
|
+
nonce: Hex;
|
|
104
|
+
};
|
|
105
|
+
/** Payment creation parameters (high-level SDK input) */
|
|
106
|
+
type X402PaymentParams = {
|
|
107
|
+
from: Address;
|
|
108
|
+
to: Address;
|
|
109
|
+
asset: Address;
|
|
110
|
+
amount: bigint;
|
|
111
|
+
validAfter?: bigint;
|
|
112
|
+
validBefore?: bigint;
|
|
113
|
+
nonce?: Hex;
|
|
114
|
+
};
|
|
115
|
+
/** Facilitator client configuration */
|
|
116
|
+
type FacilitatorConfig = {
|
|
117
|
+
url: string;
|
|
118
|
+
createAuthHeaders?: () => Promise<{
|
|
119
|
+
verify?: Record<string, string>;
|
|
120
|
+
settle?: Record<string, string>;
|
|
121
|
+
supported?: Record<string, string>;
|
|
122
|
+
}>;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
type X402ClientConfig = {
|
|
126
|
+
publicClient: PublicClient;
|
|
127
|
+
walletClient: WalletClient;
|
|
128
|
+
superPaymasterAddress: Address;
|
|
129
|
+
chainId: number;
|
|
130
|
+
/** Facilitator endpoint (default: self-facilitated via SuperPaymaster) */
|
|
131
|
+
facilitator?: FacilitatorConfig;
|
|
132
|
+
/** EIP-712 domain for asset token (defaults: USDC / version "2") */
|
|
133
|
+
tokenName?: string;
|
|
134
|
+
tokenVersion?: string;
|
|
135
|
+
/** Payment policy: max amount per request (in atomic units) */
|
|
136
|
+
maxAmountPerRequest?: bigint;
|
|
137
|
+
};
|
|
138
|
+
declare class X402Client {
|
|
139
|
+
private readonly actions;
|
|
140
|
+
private readonly config;
|
|
141
|
+
private readonly facilitatorClient?;
|
|
142
|
+
constructor(config: X402ClientConfig);
|
|
143
|
+
/**
|
|
144
|
+
* Create a signed payment payload (EIP-3009 TransferWithAuthorization).
|
|
145
|
+
* Returns a base64-encoded PaymentPayload ready for PAYMENT-SIGNATURE header.
|
|
146
|
+
*/
|
|
147
|
+
createPayment(params: X402PaymentParams): Promise<{
|
|
148
|
+
payload: PaymentPayload;
|
|
149
|
+
encoded: string;
|
|
150
|
+
nonce: Hex;
|
|
151
|
+
}>;
|
|
152
|
+
/**
|
|
153
|
+
* Settle payment on-chain via SuperPaymaster (self-facilitated).
|
|
154
|
+
* Uses EIP-3009 transferWithAuthorization path.
|
|
155
|
+
*/
|
|
156
|
+
settleOnChain(params: {
|
|
157
|
+
from: Address;
|
|
158
|
+
to: Address;
|
|
159
|
+
asset: Address;
|
|
160
|
+
amount: bigint;
|
|
161
|
+
validAfter: bigint;
|
|
162
|
+
validBefore: bigint;
|
|
163
|
+
nonce: Hex;
|
|
164
|
+
signature: Hex;
|
|
165
|
+
}): Promise<Hex>;
|
|
166
|
+
/**
|
|
167
|
+
* Settle payment on-chain via direct transfer (for xPNTs and pre-approved tokens).
|
|
168
|
+
*/
|
|
169
|
+
settleDirectOnChain(params: {
|
|
170
|
+
from: Address;
|
|
171
|
+
to: Address;
|
|
172
|
+
asset: Address;
|
|
173
|
+
amount: bigint;
|
|
174
|
+
nonce: Hex;
|
|
175
|
+
}): Promise<Hex>;
|
|
176
|
+
/**
|
|
177
|
+
* Get facilitator fee quote from on-chain contract.
|
|
178
|
+
*/
|
|
179
|
+
getQuote(): Promise<{
|
|
180
|
+
feeBPS: bigint;
|
|
181
|
+
}>;
|
|
182
|
+
/**
|
|
183
|
+
* Check if a nonce has been used.
|
|
184
|
+
*/
|
|
185
|
+
checkNonce(nonce: Hex): Promise<boolean>;
|
|
186
|
+
/**
|
|
187
|
+
* Settle via external facilitator (Coinbase, self-hosted, etc.).
|
|
188
|
+
* Requires facilitator config in constructor.
|
|
189
|
+
*/
|
|
190
|
+
settleViaFacilitator(payload: PaymentPayload, requirements: PaymentRequirements): Promise<SettleResponse>;
|
|
191
|
+
/**
|
|
192
|
+
* x402-aware fetch wrapper.
|
|
193
|
+
* Automatically handles 402 → sign → retry flow per x402 v2 spec.
|
|
194
|
+
*
|
|
195
|
+
* Pattern from: @x402/fetch wrapFetchWithPayment
|
|
196
|
+
*
|
|
197
|
+
* Flow:
|
|
198
|
+
* 1. Make initial request
|
|
199
|
+
* 2. If 402, extract PaymentRequired from PAYMENT-REQUIRED header
|
|
200
|
+
* 3. Select best payment option (applies policy: max amount check)
|
|
201
|
+
* 4. Sign EIP-3009 authorization
|
|
202
|
+
* 5. Retry with PAYMENT-SIGNATURE header
|
|
203
|
+
*/
|
|
204
|
+
x402Fetch(url: string, init?: RequestInit): Promise<Response>;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* HTTP Facilitator Client — standard x402 v2 facilitator API.
|
|
209
|
+
* Compatible with Coinbase hosted facilitator and self-hosted instances.
|
|
210
|
+
*
|
|
211
|
+
* Ref: coinbase/x402 HTTPFacilitatorClient pattern
|
|
212
|
+
*/
|
|
213
|
+
declare class FacilitatorClient {
|
|
214
|
+
private readonly url;
|
|
215
|
+
private readonly createAuthHeaders;
|
|
216
|
+
constructor(config: FacilitatorConfig);
|
|
217
|
+
private getHeaders;
|
|
218
|
+
/**
|
|
219
|
+
* POST /verify — validate payment signature off-chain (~100ms).
|
|
220
|
+
*/
|
|
221
|
+
verify(paymentPayload: PaymentPayload, paymentRequirements: PaymentRequirements): Promise<VerifyResponse>;
|
|
222
|
+
/**
|
|
223
|
+
* POST /settle — execute on-chain settlement (~2s on Base).
|
|
224
|
+
*/
|
|
225
|
+
settle(paymentPayload: PaymentPayload, paymentRequirements: PaymentRequirements): Promise<SettleResponse>;
|
|
226
|
+
/**
|
|
227
|
+
* GET /supported — query facilitator capabilities.
|
|
228
|
+
*/
|
|
229
|
+
supported(): Promise<FacilitatorSupported>;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
declare const EIP3009_TYPES: {
|
|
233
|
+
readonly TransferWithAuthorization: readonly [{
|
|
234
|
+
readonly name: "from";
|
|
235
|
+
readonly type: "address";
|
|
236
|
+
}, {
|
|
237
|
+
readonly name: "to";
|
|
238
|
+
readonly type: "address";
|
|
239
|
+
}, {
|
|
240
|
+
readonly name: "value";
|
|
241
|
+
readonly type: "uint256";
|
|
242
|
+
}, {
|
|
243
|
+
readonly name: "validAfter";
|
|
244
|
+
readonly type: "uint256";
|
|
245
|
+
}, {
|
|
246
|
+
readonly name: "validBefore";
|
|
247
|
+
readonly type: "uint256";
|
|
248
|
+
}, {
|
|
249
|
+
readonly name: "nonce";
|
|
250
|
+
readonly type: "bytes32";
|
|
251
|
+
}];
|
|
252
|
+
readonly ReceiveWithAuthorization: readonly [{
|
|
253
|
+
readonly name: "from";
|
|
254
|
+
readonly type: "address";
|
|
255
|
+
}, {
|
|
256
|
+
readonly name: "to";
|
|
257
|
+
readonly type: "address";
|
|
258
|
+
}, {
|
|
259
|
+
readonly name: "value";
|
|
260
|
+
readonly type: "uint256";
|
|
261
|
+
}, {
|
|
262
|
+
readonly name: "validAfter";
|
|
263
|
+
readonly type: "uint256";
|
|
264
|
+
}, {
|
|
265
|
+
readonly name: "validBefore";
|
|
266
|
+
readonly type: "uint256";
|
|
267
|
+
}, {
|
|
268
|
+
readonly name: "nonce";
|
|
269
|
+
readonly type: "bytes32";
|
|
270
|
+
}];
|
|
271
|
+
readonly CancelAuthorization: readonly [{
|
|
272
|
+
readonly name: "authorizer";
|
|
273
|
+
readonly type: "address";
|
|
274
|
+
}, {
|
|
275
|
+
readonly name: "nonce";
|
|
276
|
+
readonly type: "bytes32";
|
|
277
|
+
}];
|
|
278
|
+
};
|
|
279
|
+
declare function getEIP3009Domain(tokenName: string, tokenVersion: string, chainId: number, verifyingContract: Address): {
|
|
280
|
+
name: string;
|
|
281
|
+
version: string;
|
|
282
|
+
chainId: number;
|
|
283
|
+
verifyingContract: `0x${string}`;
|
|
284
|
+
};
|
|
285
|
+
declare function generateNonce(): Hex;
|
|
286
|
+
declare const GTOKEN_EIP712_DOMAIN: {
|
|
287
|
+
readonly name: "GToken";
|
|
288
|
+
readonly version: "1";
|
|
289
|
+
};
|
|
290
|
+
declare function signTransferWithAuthorization(walletClient: WalletClient, params: {
|
|
291
|
+
from: Address;
|
|
292
|
+
to: Address;
|
|
293
|
+
value: bigint;
|
|
294
|
+
validAfter: bigint;
|
|
295
|
+
validBefore: bigint;
|
|
296
|
+
nonce: Hex;
|
|
297
|
+
tokenName: string;
|
|
298
|
+
tokenVersion: string;
|
|
299
|
+
chainId: number;
|
|
300
|
+
verifyingContract: Address;
|
|
301
|
+
}): Promise<Hex>;
|
|
302
|
+
/**
|
|
303
|
+
* Sign a TransferWithAuthorization for GTokenAuthorization (EIP-3009).
|
|
304
|
+
* GToken-specific wrapper: enforces MAX_AUTH_VALIDITY = 300s before signing.
|
|
305
|
+
* Use this instead of the generic signTransferWithAuthorization when the
|
|
306
|
+
* verifying contract is GTokenAuthorization.
|
|
307
|
+
*/
|
|
308
|
+
declare function signGTokenTransferWithAuthorization(walletClient: WalletClient, params: {
|
|
309
|
+
from: Address;
|
|
310
|
+
to: Address;
|
|
311
|
+
value: bigint;
|
|
312
|
+
validAfter: bigint;
|
|
313
|
+
validBefore: bigint;
|
|
314
|
+
nonce: Hex;
|
|
315
|
+
tokenName: string;
|
|
316
|
+
tokenVersion: string;
|
|
317
|
+
chainId: number;
|
|
318
|
+
verifyingContract: Address;
|
|
319
|
+
}): Promise<Hex>;
|
|
320
|
+
/**
|
|
321
|
+
* Sign a ReceiveWithAuthorization for GTokenAuthorization (EIP-3009).
|
|
322
|
+
* The signed `to` address must be the one submitting the transaction on-chain.
|
|
323
|
+
* Note: `xPNTsToken` is NOT included in the signature (it's a relay-supplied hint for RC-2).
|
|
324
|
+
*/
|
|
325
|
+
declare function signReceiveWithAuthorization(walletClient: WalletClient, params: {
|
|
326
|
+
from: Address;
|
|
327
|
+
to: Address;
|
|
328
|
+
value: bigint;
|
|
329
|
+
validAfter: bigint;
|
|
330
|
+
validBefore: bigint;
|
|
331
|
+
nonce: Hex;
|
|
332
|
+
tokenName: string;
|
|
333
|
+
tokenVersion: string;
|
|
334
|
+
chainId: number;
|
|
335
|
+
verifyingContract: Address;
|
|
336
|
+
}): Promise<Hex>;
|
|
337
|
+
/**
|
|
338
|
+
* Sign a CancelAuthorization for GTokenAuthorization (EIP-3009).
|
|
339
|
+
* Must be signed by the original `authorizer` address.
|
|
340
|
+
*/
|
|
341
|
+
declare function signCancelAuthorization(walletClient: WalletClient, params: {
|
|
342
|
+
authorizer: Address;
|
|
343
|
+
nonce: Hex;
|
|
344
|
+
tokenName: string;
|
|
345
|
+
tokenVersion: string;
|
|
346
|
+
chainId: number;
|
|
347
|
+
verifyingContract: Address;
|
|
348
|
+
}): Promise<Hex>;
|
|
349
|
+
|
|
350
|
+
/** v2 header names (standard) */
|
|
351
|
+
declare const HEADER_PAYMENT_REQUIRED = "PAYMENT-REQUIRED";
|
|
352
|
+
declare const HEADER_PAYMENT_SIGNATURE = "PAYMENT-SIGNATURE";
|
|
353
|
+
declare const HEADER_PAYMENT_RESPONSE = "PAYMENT-RESPONSE";
|
|
354
|
+
/** v1 header names (backward compat) */
|
|
355
|
+
declare const HEADER_V1_PAYMENT = "X-PAYMENT";
|
|
356
|
+
declare const HEADER_V1_PAYMENT_RESPONSE = "X-PAYMENT-RESPONSE";
|
|
357
|
+
declare function encodePaymentRequired(req: PaymentRequired): string;
|
|
358
|
+
declare function decodePaymentRequired(encoded: string): PaymentRequired;
|
|
359
|
+
declare function encodePaymentPayload(payload: PaymentPayload): string;
|
|
360
|
+
declare function decodePaymentPayload(encoded: string): PaymentPayload;
|
|
361
|
+
declare function encodeSettleResponse(resp: SettleResponse): string;
|
|
362
|
+
declare function decodeSettleResponse(encoded: string): SettleResponse;
|
|
363
|
+
/**
|
|
364
|
+
* Extract PaymentRequired from a 402 Response.
|
|
365
|
+
* Tries v2 header first, falls back to v1.
|
|
366
|
+
*/
|
|
367
|
+
declare function extractPaymentRequired(response: Response): PaymentRequired | null;
|
|
368
|
+
/**
|
|
369
|
+
* Extract SettleResponse from a successful response.
|
|
370
|
+
*/
|
|
371
|
+
declare function extractSettleResponse(response: Response): SettleResponse | null;
|
|
372
|
+
|
|
373
|
+
export { type DirectPaymentPayload, type EIP3009Authorization, EIP3009_TYPES, FacilitatorClient, type FacilitatorConfig, type FacilitatorSupported, GTOKEN_EIP712_DOMAIN, HEADER_PAYMENT_REQUIRED, HEADER_PAYMENT_RESPONSE, HEADER_PAYMENT_SIGNATURE, HEADER_V1_PAYMENT, HEADER_V1_PAYMENT_RESPONSE, type NetworkId, type PaymentPayload, type PaymentRequired, type PaymentRequirements, type ResourceInfo, type SettleResponse, type VerifyResponse, X402Client, type X402ClientConfig, type X402PaymentParams, decodePaymentPayload, decodePaymentRequired, decodeSettleResponse, encodePaymentPayload, encodePaymentRequired, encodeSettleResponse, extractPaymentRequired, extractSettleResponse, generateNonce, getEIP3009Domain, signCancelAuthorization, signGTokenTransferWithAuthorization, signReceiveWithAuthorization, signTransferWithAuthorization };
|
package/dist/x402.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { EIP3009_TYPES, FacilitatorClient, GTOKEN_EIP712_DOMAIN, HEADER_PAYMENT_REQUIRED, HEADER_PAYMENT_RESPONSE, HEADER_PAYMENT_SIGNATURE, HEADER_V1_PAYMENT, HEADER_V1_PAYMENT_RESPONSE, X402Client, decodePaymentPayload, decodePaymentRequired, decodeSettleResponse, encodePaymentPayload, encodePaymentRequired, encodeSettleResponse, extractPaymentRequired, extractSettleResponse, generateNonce, getEIP3009Domain, signCancelAuthorization, signGTokenTransferWithAuthorization, signReceiveWithAuthorization, signTransferWithAuthorization } from './chunk-
|
|
2
|
-
import './chunk-
|
|
3
|
-
import './chunk-
|
|
1
|
+
export { EIP3009_TYPES, FacilitatorClient, GTOKEN_EIP712_DOMAIN, HEADER_PAYMENT_REQUIRED, HEADER_PAYMENT_RESPONSE, HEADER_PAYMENT_SIGNATURE, HEADER_V1_PAYMENT, HEADER_V1_PAYMENT_RESPONSE, X402Client, decodePaymentPayload, decodePaymentRequired, decodeSettleResponse, encodePaymentPayload, encodePaymentRequired, encodeSettleResponse, extractPaymentRequired, extractSettleResponse, generateNonce, getEIP3009Domain, signCancelAuthorization, signGTokenTransferWithAuthorization, signReceiveWithAuthorization, signTransferWithAuthorization } from './chunk-57XLR2NT.js';
|
|
2
|
+
import './chunk-M5WFKETT.js';
|
|
3
|
+
import './chunk-UCLK6LTB.js';
|
|
4
4
|
import './chunk-PZ5AY32C.js';
|
|
5
5
|
//# sourceMappingURL=x402.js.map
|
|
6
6
|
//# sourceMappingURL=x402.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aastar/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "All-in-one TypeScript SDK for the AAStar Protocol / Mycelium Network — ERC-4337 account abstraction, gasless transactions, SuperPaymaster gas sponsorship, KMS WebAuthn passkeys, BLS aggregate signatures, multi-chain (Optimism + Ethereum) community economies & reputation. Single bundled package with subpath exports.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"erc-4337",
|
|
@@ -32,65 +32,149 @@
|
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
34
|
"license": "Apache-2.0",
|
|
35
|
-
"main": "dist/index.
|
|
36
|
-
"module": "dist/index.js",
|
|
37
|
-
"types": "dist/index.d.ts",
|
|
35
|
+
"main": "./dist/index.cjs",
|
|
36
|
+
"module": "./dist/index.js",
|
|
37
|
+
"types": "./dist/index.d.ts",
|
|
38
38
|
"exports": {
|
|
39
39
|
".": {
|
|
40
|
-
"
|
|
41
|
-
|
|
40
|
+
"import": {
|
|
41
|
+
"types": "./dist/index.d.ts",
|
|
42
|
+
"default": "./dist/index.js"
|
|
43
|
+
},
|
|
44
|
+
"require": {
|
|
45
|
+
"types": "./dist/index.d.cts",
|
|
46
|
+
"default": "./dist/index.cjs"
|
|
47
|
+
}
|
|
42
48
|
},
|
|
43
49
|
"./core": {
|
|
44
|
-
"
|
|
45
|
-
|
|
50
|
+
"import": {
|
|
51
|
+
"types": "./dist/core.d.ts",
|
|
52
|
+
"default": "./dist/core.js"
|
|
53
|
+
},
|
|
54
|
+
"require": {
|
|
55
|
+
"types": "./dist/core.d.cts",
|
|
56
|
+
"default": "./dist/core.cjs"
|
|
57
|
+
}
|
|
46
58
|
},
|
|
47
59
|
"./account": {
|
|
48
|
-
"
|
|
49
|
-
|
|
60
|
+
"import": {
|
|
61
|
+
"types": "./dist/account.d.ts",
|
|
62
|
+
"default": "./dist/account.js"
|
|
63
|
+
},
|
|
64
|
+
"require": {
|
|
65
|
+
"types": "./dist/account.d.cts",
|
|
66
|
+
"default": "./dist/account.cjs"
|
|
67
|
+
}
|
|
50
68
|
},
|
|
51
69
|
"./paymaster": {
|
|
52
|
-
"
|
|
53
|
-
|
|
70
|
+
"import": {
|
|
71
|
+
"types": "./dist/paymaster.d.ts",
|
|
72
|
+
"default": "./dist/paymaster.js"
|
|
73
|
+
},
|
|
74
|
+
"require": {
|
|
75
|
+
"types": "./dist/paymaster.d.cts",
|
|
76
|
+
"default": "./dist/paymaster.cjs"
|
|
77
|
+
}
|
|
54
78
|
},
|
|
55
79
|
"./identity": {
|
|
56
|
-
"
|
|
57
|
-
|
|
80
|
+
"import": {
|
|
81
|
+
"types": "./dist/identity.d.ts",
|
|
82
|
+
"default": "./dist/identity.js"
|
|
83
|
+
},
|
|
84
|
+
"require": {
|
|
85
|
+
"types": "./dist/identity.d.cts",
|
|
86
|
+
"default": "./dist/identity.cjs"
|
|
87
|
+
}
|
|
58
88
|
},
|
|
59
89
|
"./tokens": {
|
|
60
|
-
"
|
|
61
|
-
|
|
90
|
+
"import": {
|
|
91
|
+
"types": "./dist/tokens.d.ts",
|
|
92
|
+
"default": "./dist/tokens.js"
|
|
93
|
+
},
|
|
94
|
+
"require": {
|
|
95
|
+
"types": "./dist/tokens.d.cts",
|
|
96
|
+
"default": "./dist/tokens.cjs"
|
|
97
|
+
}
|
|
62
98
|
},
|
|
63
99
|
"./dapp": {
|
|
64
|
-
"
|
|
65
|
-
|
|
100
|
+
"import": {
|
|
101
|
+
"types": "./dist/dapp.d.ts",
|
|
102
|
+
"default": "./dist/dapp.js"
|
|
103
|
+
},
|
|
104
|
+
"require": {
|
|
105
|
+
"types": "./dist/dapp.d.cts",
|
|
106
|
+
"default": "./dist/dapp.cjs"
|
|
107
|
+
}
|
|
66
108
|
},
|
|
67
109
|
"./x402": {
|
|
68
|
-
"
|
|
69
|
-
|
|
110
|
+
"import": {
|
|
111
|
+
"types": "./dist/x402.d.ts",
|
|
112
|
+
"default": "./dist/x402.js"
|
|
113
|
+
},
|
|
114
|
+
"require": {
|
|
115
|
+
"types": "./dist/x402.d.cts",
|
|
116
|
+
"default": "./dist/x402.cjs"
|
|
117
|
+
}
|
|
70
118
|
},
|
|
71
119
|
"./channel": {
|
|
72
|
-
"
|
|
73
|
-
|
|
120
|
+
"import": {
|
|
121
|
+
"types": "./dist/channel.d.ts",
|
|
122
|
+
"default": "./dist/channel.js"
|
|
123
|
+
},
|
|
124
|
+
"require": {
|
|
125
|
+
"types": "./dist/channel.d.cts",
|
|
126
|
+
"default": "./dist/channel.cjs"
|
|
127
|
+
}
|
|
74
128
|
},
|
|
75
129
|
"./enduser": {
|
|
76
|
-
"
|
|
77
|
-
|
|
130
|
+
"import": {
|
|
131
|
+
"types": "./dist/enduser.d.ts",
|
|
132
|
+
"default": "./dist/enduser.js"
|
|
133
|
+
},
|
|
134
|
+
"require": {
|
|
135
|
+
"types": "./dist/enduser.d.cts",
|
|
136
|
+
"default": "./dist/enduser.cjs"
|
|
137
|
+
}
|
|
78
138
|
},
|
|
79
139
|
"./operator": {
|
|
80
|
-
"
|
|
81
|
-
|
|
140
|
+
"import": {
|
|
141
|
+
"types": "./dist/operator.d.ts",
|
|
142
|
+
"default": "./dist/operator.js"
|
|
143
|
+
},
|
|
144
|
+
"require": {
|
|
145
|
+
"types": "./dist/operator.d.cts",
|
|
146
|
+
"default": "./dist/operator.cjs"
|
|
147
|
+
}
|
|
82
148
|
},
|
|
83
149
|
"./admin": {
|
|
84
|
-
"
|
|
85
|
-
|
|
150
|
+
"import": {
|
|
151
|
+
"types": "./dist/admin.d.ts",
|
|
152
|
+
"default": "./dist/admin.js"
|
|
153
|
+
},
|
|
154
|
+
"require": {
|
|
155
|
+
"types": "./dist/admin.d.cts",
|
|
156
|
+
"default": "./dist/admin.cjs"
|
|
157
|
+
}
|
|
86
158
|
},
|
|
87
159
|
"./kms": {
|
|
88
|
-
"
|
|
89
|
-
|
|
160
|
+
"import": {
|
|
161
|
+
"types": "./dist/kms.d.ts",
|
|
162
|
+
"default": "./dist/kms.js"
|
|
163
|
+
},
|
|
164
|
+
"require": {
|
|
165
|
+
"types": "./dist/kms.d.cts",
|
|
166
|
+
"default": "./dist/kms.cjs"
|
|
167
|
+
}
|
|
90
168
|
},
|
|
91
169
|
"./airaccount": {
|
|
92
|
-
"
|
|
93
|
-
|
|
170
|
+
"import": {
|
|
171
|
+
"types": "./dist/airaccount.d.ts",
|
|
172
|
+
"default": "./dist/airaccount.js"
|
|
173
|
+
},
|
|
174
|
+
"require": {
|
|
175
|
+
"types": "./dist/airaccount.d.cts",
|
|
176
|
+
"default": "./dist/airaccount.cjs"
|
|
177
|
+
}
|
|
94
178
|
}
|
|
95
179
|
},
|
|
96
180
|
"files": [
|