@ampersend_ai/ampersend-sdk 0.0.16 → 0.0.21
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/ampersend/approval.d.ts +8 -8
- package/dist/ampersend/approval.d.ts.map +1 -1
- package/dist/ampersend/approval.js +10 -15
- package/dist/ampersend/approval.js.map +1 -1
- package/dist/ampersend/client.d.ts +4 -9
- package/dist/ampersend/client.d.ts.map +1 -1
- package/dist/ampersend/client.js +25 -21
- package/dist/ampersend/client.js.map +1 -1
- package/dist/ampersend/treasurer.d.ts +14 -79
- package/dist/ampersend/treasurer.d.ts.map +1 -1
- package/dist/ampersend/treasurer.js +34 -102
- package/dist/ampersend/treasurer.js.map +1 -1
- package/dist/ampersend/types.d.ts +356 -338
- package/dist/ampersend/types.d.ts.map +1 -1
- package/dist/ampersend/types.js +120 -150
- package/dist/ampersend/types.js.map +1 -1
- package/dist/ampersend/zod-bridge.d.ts +15 -0
- package/dist/ampersend/zod-bridge.d.ts.map +1 -0
- package/dist/ampersend/zod-bridge.js +29 -0
- package/dist/ampersend/zod-bridge.js.map +1 -0
- package/dist/cli/commands/fetch.d.ts.map +1 -1
- package/dist/cli/commands/fetch.js.map +1 -1
- package/dist/cli/commands/setup.d.ts +4 -0
- package/dist/cli/commands/setup.d.ts.map +1 -1
- package/dist/cli/commands/setup.js +52 -7
- package/dist/cli/commands/setup.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp/client/client.d.ts +0 -3
- package/dist/mcp/client/client.d.ts.map +1 -1
- package/dist/mcp/client/client.js +10 -14
- package/dist/mcp/client/client.js.map +1 -1
- package/dist/mcp/client/factory.d.ts +0 -2
- package/dist/mcp/client/factory.d.ts.map +1 -1
- package/dist/mcp/client/factory.js +0 -3
- package/dist/mcp/client/factory.js.map +1 -1
- package/dist/mcp/client/middleware.d.ts +0 -3
- package/dist/mcp/client/middleware.d.ts.map +1 -1
- package/dist/mcp/client/middleware.js +9 -12
- package/dist/mcp/client/middleware.js.map +1 -1
- package/dist/mcp/client/protocol.d.ts +81 -85
- package/dist/mcp/client/protocol.d.ts.map +1 -1
- package/dist/mcp/client/protocol.js +17 -15
- package/dist/mcp/client/protocol.js.map +1 -1
- package/dist/mcp/client/types.d.ts +6 -19
- package/dist/mcp/client/types.d.ts.map +1 -1
- package/dist/mcp/proxy/cli.d.ts.map +1 -1
- package/dist/mcp/proxy/cli.js +0 -1
- package/dist/mcp/proxy/cli.js.map +1 -1
- package/dist/mcp/proxy/env.d.ts +0 -9
- package/dist/mcp/proxy/env.d.ts.map +1 -1
- package/dist/mcp/proxy/env.js +0 -2
- package/dist/mcp/proxy/env.js.map +1 -1
- package/dist/mcp/proxy/factory.d.ts +0 -2
- package/dist/mcp/proxy/factory.d.ts.map +1 -1
- package/dist/mcp/proxy/factory.js +0 -3
- package/dist/mcp/proxy/factory.js.map +1 -1
- package/dist/mcp/server/fastmcp/middleware.d.ts +9 -29
- package/dist/mcp/server/fastmcp/middleware.d.ts.map +1 -1
- package/dist/mcp/server/fastmcp/middleware.js +10 -42
- package/dist/mcp/server/fastmcp/middleware.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/x402/envelopes.d.ts +62 -0
- package/dist/x402/envelopes.d.ts.map +1 -0
- package/dist/x402/envelopes.js +73 -0
- package/dist/x402/envelopes.js.map +1 -0
- package/dist/x402/http/client.d.ts +37 -0
- package/dist/x402/http/client.d.ts.map +1 -0
- package/dist/x402/http/client.js +159 -0
- package/dist/x402/http/client.js.map +1 -0
- package/dist/x402/http/factory.d.ts +11 -25
- package/dist/x402/http/factory.d.ts.map +1 -1
- package/dist/x402/http/factory.js +11 -22
- package/dist/x402/http/factory.js.map +1 -1
- package/dist/x402/http/index.d.ts +4 -1
- package/dist/x402/http/index.d.ts.map +1 -1
- package/dist/x402/http/index.js +2 -1
- package/dist/x402/http/index.js.map +1 -1
- package/dist/x402/index.d.ts +4 -1
- package/dist/x402/index.d.ts.map +1 -1
- package/dist/x402/index.js +3 -2
- package/dist/x402/index.js.map +1 -1
- package/dist/x402/treasurer.d.ts +22 -47
- package/dist/x402/treasurer.d.ts.map +1 -1
- package/dist/x402/treasurers/naive.d.ts +4 -40
- package/dist/x402/treasurers/naive.d.ts.map +1 -1
- package/dist/x402/treasurers/naive.js +7 -44
- package/dist/x402/treasurers/naive.js.map +1 -1
- package/dist/x402/wallet.d.ts +7 -32
- package/dist/x402/wallet.d.ts.map +1 -1
- package/dist/x402/wallet.js +0 -3
- package/dist/x402/wallet.js.map +1 -1
- package/dist/x402/wallets/account/wallet.d.ts +9 -30
- package/dist/x402/wallets/account/wallet.d.ts.map +1 -1
- package/dist/x402/wallets/account/wallet.js +30 -37
- package/dist/x402/wallets/account/wallet.js.map +1 -1
- package/dist/x402/wallets/index.d.ts +0 -1
- package/dist/x402/wallets/index.d.ts.map +1 -1
- package/dist/x402/wallets/index.js +0 -1
- package/dist/x402/wallets/index.js.map +1 -1
- package/dist/x402/wallets/smart-account/chain.d.ts +4 -0
- package/dist/x402/wallets/smart-account/chain.d.ts.map +1 -0
- package/dist/x402/wallets/smart-account/chain.js +12 -0
- package/dist/x402/wallets/smart-account/chain.js.map +1 -0
- package/dist/x402/wallets/smart-account/cosigned.d.ts +7 -33
- package/dist/x402/wallets/smart-account/cosigned.d.ts.map +1 -1
- package/dist/x402/wallets/smart-account/cosigned.js +28 -51
- package/dist/x402/wallets/smart-account/cosigned.js.map +1 -1
- package/dist/x402/wallets/smart-account/exact.d.ts +6 -20
- package/dist/x402/wallets/smart-account/exact.d.ts.map +1 -1
- package/dist/x402/wallets/smart-account/exact.js +33 -43
- package/dist/x402/wallets/smart-account/exact.js.map +1 -1
- package/dist/x402/wallets/smart-account/wallet.d.ts +6 -39
- package/dist/x402/wallets/smart-account/wallet.d.ts.map +1 -1
- package/dist/x402/wallets/smart-account/wallet.js +9 -36
- package/dist/x402/wallets/smart-account/wallet.js.map +1 -1
- package/package.json +8 -6
- package/dist/x402/http/adapter.d.ts +0 -38
- package/dist/x402/http/adapter.d.ts.map +0 -1
- package/dist/x402/http/adapter.js +0 -199
- package/dist/x402/http/adapter.js.map +0 -1
- package/dist/x402/http/v2-adapter.d.ts +0 -56
- package/dist/x402/http/v2-adapter.d.ts.map +0 -1
- package/dist/x402/http/v2-adapter.js +0 -94
- package/dist/x402/http/v2-adapter.js.map +0 -1
|
@@ -1,31 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Returns an `x402Client` subclass, so the result drops into
|
|
3
|
+
* `wrapFetchWithPayment` unchanged. For advanced setups, construct
|
|
4
|
+
* `AmpersendX402Client` directly.
|
|
5
5
|
*/
|
|
6
|
-
import { x402Client } from "@x402/core/client";
|
|
7
6
|
import type { Address, Hex } from "viem";
|
|
8
|
-
import {
|
|
9
|
-
/**
|
|
10
|
-
* Simplified options for Ampersend HTTP client wrapper.
|
|
11
|
-
*/
|
|
7
|
+
import { AmpersendX402Client } from "./client.ts";
|
|
12
8
|
export interface SimpleHttpClientOptions {
|
|
13
|
-
/** Smart account address */
|
|
9
|
+
/** Smart account address. */
|
|
14
10
|
smartAccountAddress: Address;
|
|
15
|
-
/** Session key private key for signing */
|
|
11
|
+
/** Session key private key for signing. */
|
|
16
12
|
sessionKeyPrivateKey: Hex;
|
|
17
|
-
/**
|
|
18
|
-
client?: x402Client;
|
|
19
|
-
/** Ampersend API URL (defaults to production) */
|
|
13
|
+
/** Ampersend API URL. Defaults to production. */
|
|
20
14
|
apiUrl?: string;
|
|
21
|
-
/**
|
|
22
|
-
network?:
|
|
15
|
+
/** v1 network name (e.g. `"base"`). v1 and v2 (CAIP-2) are both registered. */
|
|
16
|
+
network?: string;
|
|
23
17
|
}
|
|
24
18
|
/**
|
|
25
|
-
* Create an
|
|
26
|
-
*
|
|
27
|
-
* This integrates ampersend-sdk with Coinbase's x402 SDK, allowing you to use
|
|
28
|
-
* sophisticated payment authorization logic with the standard x402 HTTP client ecosystem.
|
|
19
|
+
* Create an `AmpersendX402Client` wired to the Ampersend API.
|
|
29
20
|
*
|
|
30
21
|
* @example
|
|
31
22
|
* ```typescript
|
|
@@ -36,14 +27,9 @@ export interface SimpleHttpClientOptions {
|
|
|
36
27
|
* smartAccountAddress: "0x...",
|
|
37
28
|
* sessionKeyPrivateKey: "0x...",
|
|
38
29
|
* })
|
|
39
|
-
*
|
|
40
30
|
* const fetchWithPay = wrapFetchWithPayment(fetch, client)
|
|
41
31
|
* const response = await fetchWithPay("https://paid-api.com/endpoint")
|
|
42
32
|
* ```
|
|
43
|
-
*
|
|
44
|
-
* @param options - Simplified HTTP client configuration
|
|
45
|
-
* @returns The configured x402Client instance
|
|
46
33
|
*/
|
|
47
|
-
export declare function createAmpersendHttpClient(options: SimpleHttpClientOptions):
|
|
48
|
-
export { wrapWithAmpersend } from "./adapter.ts";
|
|
34
|
+
export declare function createAmpersendHttpClient(options: SimpleHttpClientOptions): AmpersendX402Client;
|
|
49
35
|
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/x402/http/factory.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/x402/http/factory.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAGxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAKjD,MAAM,WAAW,uBAAuB;IACtC,6BAA6B;IAC7B,mBAAmB,EAAE,OAAO,CAAA;IAC5B,2CAA2C;IAC3C,oBAAoB,EAAE,GAAG,CAAA;IACzB,iDAAiD;IACjD,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,+EAA+E;IAC/E,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,uBAAuB,GAAG,mBAAmB,CAiB/F"}
|
|
@@ -1,21 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Returns an `x402Client` subclass, so the result drops into
|
|
3
|
+
* `wrapFetchWithPayment` unchanged. For advanced setups, construct
|
|
4
|
+
* `AmpersendX402Client` directly.
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
7
|
-
import { EvmNetworkToChainId } from "x402/types";
|
|
6
|
+
import { EVM_NETWORK_CHAIN_ID_MAP } from "@x402/evm/v1";
|
|
8
7
|
import { createAmpersendTreasurer } from "../../ampersend/treasurer.js";
|
|
9
|
-
import {
|
|
10
|
-
/** Default Ampersend API URL */
|
|
8
|
+
import { AmpersendX402Client } from "./client.js";
|
|
11
9
|
const DEFAULT_API_URL = "https://api.ampersend.ai";
|
|
12
|
-
/** Default network (Base mainnet for production) */
|
|
13
10
|
const DEFAULT_NETWORK = "base";
|
|
14
11
|
/**
|
|
15
|
-
* Create an
|
|
16
|
-
*
|
|
17
|
-
* This integrates ampersend-sdk with Coinbase's x402 SDK, allowing you to use
|
|
18
|
-
* sophisticated payment authorization logic with the standard x402 HTTP client ecosystem.
|
|
12
|
+
* Create an `AmpersendX402Client` wired to the Ampersend API.
|
|
19
13
|
*
|
|
20
14
|
* @example
|
|
21
15
|
* ```typescript
|
|
@@ -26,17 +20,13 @@ const DEFAULT_NETWORK = "base";
|
|
|
26
20
|
* smartAccountAddress: "0x...",
|
|
27
21
|
* sessionKeyPrivateKey: "0x...",
|
|
28
22
|
* })
|
|
29
|
-
*
|
|
30
23
|
* const fetchWithPay = wrapFetchWithPayment(fetch, client)
|
|
31
24
|
* const response = await fetchWithPay("https://paid-api.com/endpoint")
|
|
32
25
|
* ```
|
|
33
|
-
*
|
|
34
|
-
* @param options - Simplified HTTP client configuration
|
|
35
|
-
* @returns The configured x402Client instance
|
|
36
26
|
*/
|
|
37
27
|
export function createAmpersendHttpClient(options) {
|
|
38
28
|
const network = options.network ?? DEFAULT_NETWORK;
|
|
39
|
-
const chainId =
|
|
29
|
+
const chainId = EVM_NETWORK_CHAIN_ID_MAP[network];
|
|
40
30
|
if (chainId === undefined) {
|
|
41
31
|
throw new Error(`Unknown network: ${network}`);
|
|
42
32
|
}
|
|
@@ -44,11 +34,10 @@ export function createAmpersendHttpClient(options) {
|
|
|
44
34
|
smartAccountAddress: options.smartAccountAddress,
|
|
45
35
|
sessionKeyPrivateKey: options.sessionKeyPrivateKey,
|
|
46
36
|
apiUrl: options.apiUrl ?? DEFAULT_API_URL,
|
|
47
|
-
chainId,
|
|
48
37
|
});
|
|
49
|
-
|
|
50
|
-
|
|
38
|
+
return new AmpersendX402Client(treasurer).withNetworks({
|
|
39
|
+
v1: [network],
|
|
40
|
+
v2: [`eip155:${chainId}`],
|
|
41
|
+
});
|
|
51
42
|
}
|
|
52
|
-
// Re-export original for advanced use cases
|
|
53
|
-
export { wrapWithAmpersend } from "./adapter.js";
|
|
54
43
|
//# sourceMappingURL=factory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../src/x402/http/factory.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../src/x402/http/factory.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAA;AAGvD,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAA;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAEjD,MAAM,eAAe,GAAG,0BAA0B,CAAA;AAClD,MAAM,eAAe,GAAG,MAAM,CAAA;AAa9B;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,yBAAyB,CAAC,OAAgC;IACxE,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,eAAe,CAAA;IAClD,MAAM,OAAO,GAAI,wBAA6D,CAAC,OAAO,CAAC,CAAA;IACvF,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,oBAAoB,OAAO,EAAE,CAAC,CAAA;IAChD,CAAC;IAED,MAAM,SAAS,GAAG,wBAAwB,CAAC;QACzC,mBAAmB,EAAE,OAAO,CAAC,mBAAmB;QAChD,oBAAoB,EAAE,OAAO,CAAC,oBAAoB;QAClD,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,eAAe;KAC1C,CAAC,CAAA;IAEF,OAAO,IAAI,mBAAmB,CAAC,SAAS,CAAC,CAAC,YAAY,CAAC;QACrD,EAAE,EAAE,CAAC,OAAO,CAAC;QACb,EAAE,EAAE,CAAC,UAAU,OAAO,EAAE,CAAC;KAC1B,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { AmpersendX402Client, PaymentDeclinedError, UnsupportedProtocolError } from "./client.ts";
|
|
2
|
+
export type { AmpersendNetworks } from "./client.ts";
|
|
3
|
+
export { createAmpersendHttpClient } from "./factory.ts";
|
|
4
|
+
export type { SimpleHttpClientOptions } from "./factory.ts";
|
|
2
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/x402/http/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/x402/http/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AACjG,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AACxD,YAAY,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA"}
|
package/dist/x402/http/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/x402/http/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/x402/http/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAEjG,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA"}
|
package/dist/x402/index.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
export type { PaymentAuthorization, PaymentInstruction, PaymentRequest, Protocol, SchemeSpecificPayload, SettlementResult, } from "./envelopes.ts";
|
|
2
|
+
export { acceptedOf, amountOf, buildAuthorization, firstInstructionOf, resourceUrlOf } from "./envelopes.ts";
|
|
1
3
|
export type { Authorization, PaymentContext, PaymentStatus, X402Treasurer } from "./treasurer.ts";
|
|
2
4
|
export type { ERC3009AuthorizationData, ServerAuthorizationData } from "./types.ts";
|
|
3
5
|
export { WalletError } from "./wallet.ts";
|
|
4
6
|
export type { X402Wallet } from "./wallet.ts";
|
|
5
7
|
export { AccountWallet, SmartAccountWallet, createWalletFromConfig } from "./wallets/index.ts";
|
|
6
8
|
export type { SmartAccountConfig, WalletConfig, EOAWalletConfig, SmartAccountWalletConfig } from "./wallets/index.ts";
|
|
7
|
-
export {
|
|
9
|
+
export { AmpersendX402Client, PaymentDeclinedError, UnsupportedProtocolError, createAmpersendHttpClient, } from "./http/index.ts";
|
|
10
|
+
export type { AmpersendNetworks, SimpleHttpClientOptions } from "./http/index.ts";
|
|
8
11
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/x402/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/x402/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AACjG,YAAY,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAA;AACnF,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAG7C,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAA;AAC9F,YAAY,EAAE,kBAAkB,EAAE,YAAY,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAA;AAGrH,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/x402/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,QAAQ,EACR,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAG5G,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AACjG,YAAY,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAA;AACnF,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAG7C,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAA;AAC9F,YAAY,EAAE,kBAAkB,EAAE,YAAY,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAA;AAGrH,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,iBAAiB,CAAA;AACxB,YAAY,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAA"}
|
package/dist/x402/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
export { acceptedOf, amountOf, buildAuthorization, firstInstructionOf, resourceUrlOf } from "./envelopes.js";
|
|
1
2
|
export { WalletError } from "./wallet.js";
|
|
2
3
|
// Wallet implementations
|
|
3
4
|
export { AccountWallet, SmartAccountWallet, createWalletFromConfig } from "./wallets/index.js";
|
|
4
|
-
// HTTP
|
|
5
|
-
export {
|
|
5
|
+
// HTTP integration
|
|
6
|
+
export { AmpersendX402Client, PaymentDeclinedError, UnsupportedProtocolError, createAmpersendHttpClient, } from "./http/index.js";
|
|
6
7
|
//# sourceMappingURL=index.js.map
|
package/dist/x402/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/x402/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/x402/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAK5G,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAGzC,yBAAyB;AACzB,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAA;AAG9F,mBAAmB;AACnB,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,iBAAiB,CAAA"}
|
package/dist/x402/treasurer.d.ts
CHANGED
|
@@ -1,64 +1,39 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PaymentRequirementsV1, PaymentRequirementsV2 } from "@x402/core/schemas";
|
|
2
|
+
import type { PaymentAuthorization, PaymentRequest } from "./envelopes.ts";
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
+
* Loose caller context — which protocol triggered the flow and any debugging
|
|
5
|
+
* metadata. NOT payment details; those live on the {@link PaymentRequest}.
|
|
4
6
|
*/
|
|
5
7
|
export interface PaymentContext {
|
|
6
8
|
method: string;
|
|
7
|
-
params
|
|
9
|
+
params?: any;
|
|
8
10
|
metadata?: Record<string, unknown>;
|
|
9
11
|
}
|
|
10
|
-
/**
|
|
11
|
-
* Authorization linking a payment with a tracking ID
|
|
12
|
-
*/
|
|
13
12
|
export interface Authorization {
|
|
14
|
-
payment:
|
|
13
|
+
payment: PaymentAuthorization;
|
|
15
14
|
authorizationId: string;
|
|
15
|
+
/**
|
|
16
|
+
* The `accepts[i]` the wallet signed against. Must be `===` to an element
|
|
17
|
+
* of the original `PaymentRequest.data.accepts` — reference equality is
|
|
18
|
+
* load-bearing for downstream integrations (e.g. the `x402Client` subclass).
|
|
19
|
+
*/
|
|
20
|
+
accepted: PaymentRequirementsV1 | PaymentRequirementsV2;
|
|
16
21
|
}
|
|
17
|
-
/**
|
|
18
|
-
* Payment status types for tracking payment lifecycle
|
|
19
|
-
*/
|
|
20
22
|
export type PaymentStatus = "sending" | "accepted" | "rejected" | "declined" | "error";
|
|
21
23
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
24
|
+
* Separates payment *decisions* from payment *creation*. Receives the seller's
|
|
25
|
+
* full 402 body, returns a signed {@link Authorization} or `null` to decline.
|
|
26
|
+
* Internally picks an index into `request.data.accepts[]` and hands the
|
|
27
|
+
* resulting `PaymentInstruction` to a wallet; use {@link firstInstructionOf}
|
|
28
|
+
* for the trivial "take the first option" case.
|
|
26
29
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* async onPaymentRequired(requirements, context) {
|
|
33
|
-
* if (this.wouldExceedBudget(requirements[0])) {
|
|
34
|
-
* return null // Decline
|
|
35
|
-
* }
|
|
36
|
-
* const payment = await this.wallet.createPayment(requirements[0])
|
|
37
|
-
* return { payment, authorizationId: crypto.randomUUID() }
|
|
38
|
-
* }
|
|
39
|
-
*
|
|
40
|
-
* async onStatus(status, authorization, context) {
|
|
41
|
-
* console.log(`Payment ${authorization.authorizationId}: ${status}`)
|
|
42
|
-
* }
|
|
43
|
-
* }
|
|
44
|
-
* ```
|
|
30
|
+
* Return `null` only for domain-level declines (budget exhausted, user
|
|
31
|
+
* rejected, policy said no). Infrastructure failures — network errors, auth
|
|
32
|
+
* failures, wallet signing errors — must **throw**, so callers can distinguish
|
|
33
|
+
* "you can't have this payment" from "something is broken."
|
|
45
34
|
*/
|
|
46
35
|
export interface X402Treasurer {
|
|
47
|
-
|
|
48
|
-
* Called when payment is required.
|
|
49
|
-
*
|
|
50
|
-
* @param requirements - Array of payment requirements from seller (typically use first)
|
|
51
|
-
* @param context - Optional context about the request requiring payment
|
|
52
|
-
* @returns Authorization to proceed with payment, or null to decline
|
|
53
|
-
*/
|
|
54
|
-
onPaymentRequired(requirements: ReadonlyArray<PaymentRequirements>, context?: PaymentContext): Promise<Authorization | null>;
|
|
55
|
-
/**
|
|
56
|
-
* Called with payment status updates throughout the payment lifecycle.
|
|
57
|
-
*
|
|
58
|
-
* @param status - Current payment status
|
|
59
|
-
* @param authorization - The authorization returned from onPaymentRequired
|
|
60
|
-
* @param context - Optional context about the status update
|
|
61
|
-
*/
|
|
36
|
+
onPaymentRequired(request: PaymentRequest, context?: PaymentContext): Promise<Authorization | null>;
|
|
62
37
|
onStatus(status: PaymentStatus, authorization: Authorization, context?: PaymentContext): Promise<void>;
|
|
63
38
|
}
|
|
64
39
|
//# sourceMappingURL=treasurer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"treasurer.d.ts","sourceRoot":"","sources":["../../src/x402/treasurer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"treasurer.d.ts","sourceRoot":"","sources":["../../src/x402/treasurer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAEtF,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAE1E;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,GAAG,CAAA;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACnC;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,oBAAoB,CAAA;IAC7B,eAAe,EAAE,MAAM,CAAA;IACvB;;;;OAIG;IACH,QAAQ,EAAE,qBAAqB,GAAG,qBAAqB,CAAA;CACxD;AAED,MAAM,MAAM,aAAa,GACrB,SAAS,GACT,UAAU,GACV,UAAU,GACV,UAAU,GACV,OAAO,CAAA;AAEX;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,aAAa;IAC5B,iBAAiB,CAAC,OAAO,EAAE,cAAc,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAAA;IACnG,QAAQ,CAAC,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACvG"}
|
|
@@ -1,52 +1,16 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type PaymentRequest } from "../envelopes.ts";
|
|
2
2
|
import type { Authorization, PaymentContext, PaymentStatus, X402Treasurer } from "../treasurer.ts";
|
|
3
3
|
import type { X402Wallet } from "../wallet.ts";
|
|
4
4
|
import { type WalletConfig } from "../wallets/index.ts";
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* This treasurer automatically approves all payment requests without
|
|
9
|
-
* any budget checks or user confirmation. Useful for:
|
|
10
|
-
* - Testing and development
|
|
11
|
-
* - Trusted sellers where all requests should be paid
|
|
12
|
-
* - Simple use cases without budget limits
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```typescript
|
|
16
|
-
* const wallet = new AccountWallet(account)
|
|
17
|
-
* const treasurer = new NaiveTreasurer(wallet)
|
|
18
|
-
*
|
|
19
|
-
* // Auto-approves all payments
|
|
20
|
-
* const client = new X402Client({ treasurer })
|
|
21
|
-
* ```
|
|
6
|
+
* Auto-approves any request by signing its first `accepts[]` entry. No budget
|
|
7
|
+
* or policy checks; for testing and development only.
|
|
22
8
|
*/
|
|
23
9
|
export declare class NaiveTreasurer implements X402Treasurer {
|
|
24
10
|
private wallet;
|
|
25
11
|
constructor(wallet: X402Wallet);
|
|
26
|
-
|
|
27
|
-
* Always approves payment by creating payment with the wallet.
|
|
28
|
-
* Uses the first requirement from the array.
|
|
29
|
-
*/
|
|
30
|
-
onPaymentRequired(requirements: Array<PaymentRequirements>, _context?: PaymentContext): Promise<Authorization | null>;
|
|
31
|
-
/**
|
|
32
|
-
* Logs payment status to console for debugging.
|
|
33
|
-
*/
|
|
12
|
+
onPaymentRequired(request: PaymentRequest, _context?: PaymentContext): Promise<Authorization | null>;
|
|
34
13
|
onStatus(status: PaymentStatus, authorization: Authorization, _context?: PaymentContext): Promise<void>;
|
|
35
14
|
}
|
|
36
|
-
/**
|
|
37
|
-
* Creates a naive treasurer that automatically approves all payment requests.
|
|
38
|
-
* This treasurer selects the first payment requirement and creates a payment immediately.
|
|
39
|
-
*
|
|
40
|
-
* @param walletConfig - Configuration for the wallet to use
|
|
41
|
-
* @returns An X402Treasurer implementation
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* ```typescript
|
|
45
|
-
* const treasurer = createNaiveTreasurer({
|
|
46
|
-
* type: 'eoa',
|
|
47
|
-
* privateKey: '0x...'
|
|
48
|
-
* })
|
|
49
|
-
* ```
|
|
50
|
-
*/
|
|
51
15
|
export declare function createNaiveTreasurer(walletConfig: WalletConfig): X402Treasurer;
|
|
52
16
|
//# sourceMappingURL=naive.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"naive.d.ts","sourceRoot":"","sources":["../../../src/x402/treasurers/naive.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"naive.d.ts","sourceRoot":"","sources":["../../../src/x402/treasurers/naive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAA;AACrF,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAClG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAA0B,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAE/E;;;GAGG;AACH,qBAAa,cAAe,YAAW,aAAa;IACtC,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,UAAU;IAEhC,iBAAiB,CAAC,OAAO,EAAE,cAAc,EAAE,QAAQ,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAUpG,QAAQ,CAAC,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,QAAQ,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAG9G;AAED,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,YAAY,GAAG,aAAa,CAG9E"}
|
|
@@ -1,64 +1,27 @@
|
|
|
1
|
+
import { acceptedOf, firstInstructionOf } from "../envelopes.js";
|
|
1
2
|
import { createWalletFromConfig } from "../wallets/index.js";
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* This treasurer automatically approves all payment requests without
|
|
6
|
-
* any budget checks or user confirmation. Useful for:
|
|
7
|
-
* - Testing and development
|
|
8
|
-
* - Trusted sellers where all requests should be paid
|
|
9
|
-
* - Simple use cases without budget limits
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* const wallet = new AccountWallet(account)
|
|
14
|
-
* const treasurer = new NaiveTreasurer(wallet)
|
|
15
|
-
*
|
|
16
|
-
* // Auto-approves all payments
|
|
17
|
-
* const client = new X402Client({ treasurer })
|
|
18
|
-
* ```
|
|
4
|
+
* Auto-approves any request by signing its first `accepts[]` entry. No budget
|
|
5
|
+
* or policy checks; for testing and development only.
|
|
19
6
|
*/
|
|
20
7
|
export class NaiveTreasurer {
|
|
21
8
|
wallet;
|
|
22
9
|
constructor(wallet) {
|
|
23
10
|
this.wallet = wallet;
|
|
24
11
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
*/
|
|
29
|
-
async onPaymentRequired(requirements, _context) {
|
|
30
|
-
if (requirements.length === 0) {
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
// Create payment using the wallet
|
|
34
|
-
const payment = await this.wallet.createPayment(requirements[0]);
|
|
12
|
+
async onPaymentRequired(request, _context) {
|
|
13
|
+
const instruction = firstInstructionOf(request);
|
|
14
|
+
const payment = await this.wallet.createPayment(instruction);
|
|
35
15
|
return {
|
|
36
16
|
payment,
|
|
37
17
|
authorizationId: crypto.randomUUID(),
|
|
18
|
+
accepted: acceptedOf(instruction),
|
|
38
19
|
};
|
|
39
20
|
}
|
|
40
|
-
/**
|
|
41
|
-
* Logs payment status to console for debugging.
|
|
42
|
-
*/
|
|
43
21
|
async onStatus(status, authorization, _context) {
|
|
44
22
|
console.log(`[NaiveTreasurer] Payment ${authorization.authorizationId}: ${status}`);
|
|
45
23
|
}
|
|
46
24
|
}
|
|
47
|
-
/**
|
|
48
|
-
* Creates a naive treasurer that automatically approves all payment requests.
|
|
49
|
-
* This treasurer selects the first payment requirement and creates a payment immediately.
|
|
50
|
-
*
|
|
51
|
-
* @param walletConfig - Configuration for the wallet to use
|
|
52
|
-
* @returns An X402Treasurer implementation
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* ```typescript
|
|
56
|
-
* const treasurer = createNaiveTreasurer({
|
|
57
|
-
* type: 'eoa',
|
|
58
|
-
* privateKey: '0x...'
|
|
59
|
-
* })
|
|
60
|
-
* ```
|
|
61
|
-
*/
|
|
62
25
|
export function createNaiveTreasurer(walletConfig) {
|
|
63
26
|
const wallet = createWalletFromConfig(walletConfig);
|
|
64
27
|
return new NaiveTreasurer(wallet);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"naive.js","sourceRoot":"","sources":["../../../src/x402/treasurers/naive.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"naive.js","sourceRoot":"","sources":["../../../src/x402/treasurers/naive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAuB,MAAM,iBAAiB,CAAA;AAGrF,OAAO,EAAE,sBAAsB,EAAqB,MAAM,qBAAqB,CAAA;AAE/E;;;GAGG;AACH,MAAM,OAAO,cAAc;IACL;IAApB,YAAoB,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;IAAG,CAAC;IAE1C,KAAK,CAAC,iBAAiB,CAAC,OAAuB,EAAE,QAAyB;QACxE,MAAM,WAAW,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAA;QAC/C,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,WAAW,CAAC,CAAA;QAC5D,OAAO;YACL,OAAO;YACP,eAAe,EAAE,MAAM,CAAC,UAAU,EAAE;YACpC,QAAQ,EAAE,UAAU,CAAC,WAAW,CAAC;SAClC,CAAA;IACH,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,MAAqB,EAAE,aAA4B,EAAE,QAAyB;QAC3F,OAAO,CAAC,GAAG,CAAC,4BAA4B,aAAa,CAAC,eAAe,KAAK,MAAM,EAAE,CAAC,CAAA;IACrF,CAAC;CACF;AAED,MAAM,UAAU,oBAAoB,CAAC,YAA0B;IAC7D,MAAM,MAAM,GAAG,sBAAsB,CAAC,YAAY,CAAC,CAAA;IACnD,OAAO,IAAI,cAAc,CAAC,MAAM,CAAC,CAAA;AACnC,CAAC"}
|
package/dist/x402/wallet.d.ts
CHANGED
|
@@ -1,43 +1,18 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PaymentAuthorization, PaymentInstruction } from "./envelopes.ts";
|
|
2
2
|
import type { ServerAuthorizationData } from "./types.ts";
|
|
3
|
-
/**
|
|
4
|
-
* Error thrown when wallet cannot create a payment
|
|
5
|
-
*/
|
|
6
3
|
export declare class WalletError extends Error {
|
|
7
4
|
cause?: Error | undefined;
|
|
8
5
|
constructor(message: string, cause?: Error | undefined);
|
|
9
6
|
}
|
|
10
7
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* An X402Wallet is responsible for creating cryptographically signed payment payloads
|
|
14
|
-
* that can be submitted to sellers. Different wallet implementations support
|
|
15
|
-
* different account types (EOA, smart accounts, etc.).
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```typescript
|
|
19
|
-
* class AccountWallet implements X402Wallet {
|
|
20
|
-
* constructor(private account: Account) {}
|
|
8
|
+
* Signs a {@link PaymentInstruction} into a {@link PaymentAuthorization}.
|
|
21
9
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* }
|
|
26
|
-
* // Create and sign payment
|
|
27
|
-
* return signedPayment
|
|
28
|
-
* }
|
|
29
|
-
* }
|
|
30
|
-
* ```
|
|
10
|
+
* Implementations read fields via {@link acceptedOf} / {@link amountOf} and
|
|
11
|
+
* return via {@link buildAuthorization}, which handles the v1/v2 envelope
|
|
12
|
+
* packaging (including v2's `resource`/`accepted`/`extensions` echo).
|
|
31
13
|
*/
|
|
32
14
|
export interface X402Wallet {
|
|
33
|
-
/**
|
|
34
|
-
|
|
35
|
-
*
|
|
36
|
-
* @param requirements - Payment requirements from seller
|
|
37
|
-
* @param serverAuthorization - Optional server co-signature data (for co-signed smart account keys)
|
|
38
|
-
* @returns Signed payment payload ready for submission
|
|
39
|
-
* @throws {WalletError} If unable to create payment (unsupported scheme, insufficient funds, etc.)
|
|
40
|
-
*/
|
|
41
|
-
createPayment(requirements: PaymentRequirements, serverAuthorization?: ServerAuthorizationData): Promise<PaymentPayload>;
|
|
15
|
+
/** @throws {WalletError} for unsupported schemes, insufficient funds, etc. */
|
|
16
|
+
createPayment(instruction: PaymentInstruction, serverAuthorization?: ServerAuthorizationData): Promise<PaymentAuthorization>;
|
|
42
17
|
}
|
|
43
18
|
//# sourceMappingURL=wallet.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src/x402/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src/x402/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAC9E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAA;AAEzD,qBAAa,WAAY,SAAQ,KAAK;IAG3B,KAAK,CAAC,EAAE,KAAK;gBADpB,OAAO,EAAE,MAAM,EACR,KAAK,CAAC,EAAE,KAAK,YAAA;CAKvB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,UAAU;IACzB,8EAA8E;IAC9E,aAAa,CACX,WAAW,EAAE,kBAAkB,EAC/B,mBAAmB,CAAC,EAAE,uBAAuB,GAC5C,OAAO,CAAC,oBAAoB,CAAC,CAAA;CACjC"}
|
package/dist/x402/wallet.js
CHANGED
package/dist/x402/wallet.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../src/x402/wallet.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../src/x402/wallet.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,WAAY,SAAQ,KAAK;IAG3B;IAFT,YACE,OAAe,EACR,KAAa;QAEpB,KAAK,CAAC,OAAO,CAAC,CAAA;QAFP,UAAK,GAAL,KAAK,CAAQ;QAGpB,IAAI,CAAC,IAAI,GAAG,aAAa,CAAA;IAC3B,CAAC;CACF"}
|
|
@@ -1,41 +1,20 @@
|
|
|
1
1
|
import type { Hex, LocalAccount } from "viem";
|
|
2
|
-
import type
|
|
3
|
-
import type { ServerAuthorizationData } from "
|
|
2
|
+
import { type PaymentAuthorization, type PaymentInstruction } from "../../envelopes.ts";
|
|
3
|
+
import type { ServerAuthorizationData } from "../../types.ts";
|
|
4
4
|
import { type X402Wallet } from "../../wallet.ts";
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* Supports the "exact" payment scheme.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* import { privateKeyToAccount } from "viem/accounts"
|
|
14
|
-
*
|
|
15
|
-
* // From viem Account
|
|
16
|
-
* const account = privateKeyToAccount("0x...")
|
|
17
|
-
* const wallet = new AccountWallet(account)
|
|
18
|
-
*
|
|
19
|
-
* // From private key directly
|
|
20
|
-
* const wallet = AccountWallet.fromPrivateKey("0x...")
|
|
21
|
-
* ```
|
|
6
|
+
* EOA wallet for x402 `exact` on EVM. A `LocalAccount` is sufficient for
|
|
7
|
+
* EIP-3009 and base Permit2; EIP-2612 permit enrichment is skipped because it
|
|
8
|
+
* needs `readContract`, which `LocalAccount` lacks.
|
|
22
9
|
*/
|
|
23
10
|
export declare class AccountWallet implements X402Wallet {
|
|
24
11
|
private account;
|
|
12
|
+
private signer;
|
|
13
|
+
private schemeV1;
|
|
14
|
+
private schemeV2;
|
|
25
15
|
constructor(account: LocalAccount);
|
|
26
|
-
/**
|
|
27
|
-
* Creates an AccountWallet from a private key
|
|
28
|
-
*/
|
|
29
16
|
static fromPrivateKey(privateKey: Hex): AccountWallet;
|
|
30
|
-
|
|
31
|
-
* Creates a payment payload from requirements.
|
|
32
|
-
* Only supports "exact" payment scheme.
|
|
33
|
-
* Note: serverAuthorization parameter is ignored for EOA wallets (only used by SmartAccountWallet)
|
|
34
|
-
*/
|
|
35
|
-
createPayment(requirements: PaymentRequirements, _serverAuthorization?: ServerAuthorizationData): Promise<PaymentPayload>;
|
|
36
|
-
/**
|
|
37
|
-
* Returns the account address
|
|
38
|
-
*/
|
|
17
|
+
createPayment(instruction: PaymentInstruction, serverAuthorization?: ServerAuthorizationData): Promise<PaymentAuthorization>;
|
|
39
18
|
get address(): Hex;
|
|
40
19
|
}
|
|
41
20
|
//# sourceMappingURL=wallet.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../../../src/x402/wallets/account/wallet.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../../../src/x402/wallets/account/wallet.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAG7C,OAAO,EAAkC,KAAK,oBAAoB,EAAE,KAAK,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AACvH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAA;AAC7D,OAAO,EAAe,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE9D;;;;GAIG;AACH,qBAAa,aAAc,YAAW,UAAU;IAC9C,OAAO,CAAC,OAAO,CAAc;IAC7B,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,QAAQ,CAAgB;gBAEpB,OAAO,EAAE,YAAY;IAUjC,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,GAAG,GAAG,aAAa;IAI/C,aAAa,CACjB,WAAW,EAAE,kBAAkB,EAC/B,mBAAmB,CAAC,EAAE,uBAAuB,GAC5C,OAAO,CAAC,oBAAoB,CAAC;IAiChC,IAAI,OAAO,IAAI,GAAG,CAEjB;CACF"}
|