@xrpay/x402 0.0.0-stage → 0.1.1
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/LICENSE +21 -0
- package/README.md +191 -2
- package/dist/browser.js +2 -0
- package/dist/client.cjs +1552 -0
- package/dist/client.d.cts +46 -0
- package/dist/client.d.ts +46 -0
- package/dist/client.js +1529 -0
- package/dist/commerce.cjs +1611 -0
- package/dist/commerce.d.cts +99 -0
- package/dist/commerce.d.ts +99 -0
- package/dist/commerce.js +1588 -0
- package/dist/mcp-tools.d.ts +56 -0
- package/dist/mcp.d.ts +1 -0
- package/dist/mcp.js +1749 -0
- package/dist/protocol.cjs +1447 -0
- package/dist/protocol.d.cts +64 -0
- package/dist/protocol.d.ts +64 -0
- package/dist/protocol.js +1424 -0
- package/dist/server.cjs +1772 -0
- package/dist/server.d.cts +62 -0
- package/dist/server.d.ts +62 -0
- package/dist/server.js +1723 -0
- package/examples/buy-digital-product.mjs +44 -0
- package/examples/paid-api.mjs +25 -0
- package/package.json +101 -4
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type PaymentPayload, type XrplNetwork } from "./protocol.cjs";
|
|
2
|
+
export * from "./protocol.cjs";
|
|
3
|
+
export interface AgentWallet {
|
|
4
|
+
address?: string;
|
|
5
|
+
classicAddress?: string;
|
|
6
|
+
sign(transaction: any): {
|
|
7
|
+
tx_blob: string;
|
|
8
|
+
hash: string;
|
|
9
|
+
} | Promise<{
|
|
10
|
+
tx_blob: string;
|
|
11
|
+
hash: string;
|
|
12
|
+
}>;
|
|
13
|
+
}
|
|
14
|
+
export interface AgentLedgerClient {
|
|
15
|
+
getLedgerIndex(): Promise<number>;
|
|
16
|
+
autofill(transaction: any): Promise<any>;
|
|
17
|
+
}
|
|
18
|
+
export interface X402ClientOptions {
|
|
19
|
+
wallet: AgentWallet;
|
|
20
|
+
/** A connected XRPL client on the explicitly selected network. */
|
|
21
|
+
ledgerClient: AgentLedgerClient;
|
|
22
|
+
network: XrplNetwork;
|
|
23
|
+
currency: "XRP" | "RLUSD";
|
|
24
|
+
issuer?: string;
|
|
25
|
+
/** Human XRP/RLUSD amounts, not drops. Both caps are required. */
|
|
26
|
+
maxAmount: string;
|
|
27
|
+
maxTotalAmount: string;
|
|
28
|
+
maxFeeDrops?: string;
|
|
29
|
+
allowedRecipients?: string[];
|
|
30
|
+
fetch?: typeof globalThis.fetch;
|
|
31
|
+
}
|
|
32
|
+
export declare class X402Client {
|
|
33
|
+
private readonly options;
|
|
34
|
+
private totalAuthorized;
|
|
35
|
+
private queue;
|
|
36
|
+
private unresolvedPayment;
|
|
37
|
+
private pendingReceipt?;
|
|
38
|
+
constructor(options: X402ClientOptions);
|
|
39
|
+
get authorizedAmount(): string;
|
|
40
|
+
/** Serialize requests: the sequence scheme permits one pending payment per payer. */
|
|
41
|
+
fetch(input: RequestInfo | URL, init?: RequestInit, beforeSubmit?: (payload: PaymentPayload) => Promise<void>): Promise<Response>;
|
|
42
|
+
/** Accept only the receipt matching this client's unresolved signed hash. */
|
|
43
|
+
reconcileReceipt(receipt: unknown): boolean;
|
|
44
|
+
private selectRequirement;
|
|
45
|
+
private fetchOnce;
|
|
46
|
+
}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type PaymentPayload, type XrplNetwork } from "./protocol.js";
|
|
2
|
+
export * from "./protocol.js";
|
|
3
|
+
export interface AgentWallet {
|
|
4
|
+
address?: string;
|
|
5
|
+
classicAddress?: string;
|
|
6
|
+
sign(transaction: any): {
|
|
7
|
+
tx_blob: string;
|
|
8
|
+
hash: string;
|
|
9
|
+
} | Promise<{
|
|
10
|
+
tx_blob: string;
|
|
11
|
+
hash: string;
|
|
12
|
+
}>;
|
|
13
|
+
}
|
|
14
|
+
export interface AgentLedgerClient {
|
|
15
|
+
getLedgerIndex(): Promise<number>;
|
|
16
|
+
autofill(transaction: any): Promise<any>;
|
|
17
|
+
}
|
|
18
|
+
export interface X402ClientOptions {
|
|
19
|
+
wallet: AgentWallet;
|
|
20
|
+
/** A connected XRPL client on the explicitly selected network. */
|
|
21
|
+
ledgerClient: AgentLedgerClient;
|
|
22
|
+
network: XrplNetwork;
|
|
23
|
+
currency: "XRP" | "RLUSD";
|
|
24
|
+
issuer?: string;
|
|
25
|
+
/** Human XRP/RLUSD amounts, not drops. Both caps are required. */
|
|
26
|
+
maxAmount: string;
|
|
27
|
+
maxTotalAmount: string;
|
|
28
|
+
maxFeeDrops?: string;
|
|
29
|
+
allowedRecipients?: string[];
|
|
30
|
+
fetch?: typeof globalThis.fetch;
|
|
31
|
+
}
|
|
32
|
+
export declare class X402Client {
|
|
33
|
+
private readonly options;
|
|
34
|
+
private totalAuthorized;
|
|
35
|
+
private queue;
|
|
36
|
+
private unresolvedPayment;
|
|
37
|
+
private pendingReceipt?;
|
|
38
|
+
constructor(options: X402ClientOptions);
|
|
39
|
+
get authorizedAmount(): string;
|
|
40
|
+
/** Serialize requests: the sequence scheme permits one pending payment per payer. */
|
|
41
|
+
fetch(input: RequestInfo | URL, init?: RequestInit, beforeSubmit?: (payload: PaymentPayload) => Promise<void>): Promise<Response>;
|
|
42
|
+
/** Accept only the receipt matching this client's unresolved signed hash. */
|
|
43
|
+
reconcileReceipt(receipt: unknown): boolean;
|
|
44
|
+
private selectRequirement;
|
|
45
|
+
private fetchOnce;
|
|
46
|
+
}
|