@xrpay/x402 0.0.0-stage → 0.1.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.
@@ -0,0 +1,64 @@
1
+ import BigNumber from "bignumber.cjs";
2
+ export declare const RLUSD_ASSET = "524C555344000000000000000000000000000000";
3
+ export declare const PAYMENT_HEADERS: {
4
+ readonly required: "PAYMENT-REQUIRED";
5
+ readonly signature: "PAYMENT-SIGNATURE";
6
+ readonly response: "PAYMENT-RESPONSE";
7
+ };
8
+ export type XrplNetwork = "xrpl:0" | "xrpl:1";
9
+ export interface PaymentRequirements {
10
+ scheme: "exact";
11
+ network: XrplNetwork;
12
+ asset: "XRP" | typeof RLUSD_ASSET;
13
+ amount: string;
14
+ payTo: string;
15
+ maxTimeoutSeconds: number;
16
+ extra: {
17
+ areFeesSponsored: false;
18
+ /** Omission selects the sequence transfer method. */
19
+ assetTransferMethod?: "sequence";
20
+ invoiceId?: string;
21
+ issuer?: string;
22
+ destinationTag?: number;
23
+ };
24
+ }
25
+ export interface PaymentRequired {
26
+ x402Version: 2;
27
+ resource: {
28
+ url: string;
29
+ description?: string;
30
+ mimeType?: string;
31
+ };
32
+ accepts: PaymentRequirements[];
33
+ error?: string;
34
+ }
35
+ export interface PaymentPayload {
36
+ x402Version: 2;
37
+ resource?: PaymentRequired["resource"];
38
+ accepted: PaymentRequirements;
39
+ payload: {
40
+ signedTxBlob: string;
41
+ };
42
+ }
43
+ export interface VerifyResponse {
44
+ isValid: boolean;
45
+ invalidReason?: string;
46
+ payer?: string;
47
+ }
48
+ export interface SettlementResponse {
49
+ success: boolean;
50
+ transaction: string;
51
+ network: string;
52
+ payer?: string;
53
+ errorReason?: string;
54
+ amount?: string;
55
+ }
56
+ export declare function isRecord(value: unknown): value is Record<string, any>;
57
+ export declare function positiveAmount(value: unknown, integer?: boolean): BigNumber;
58
+ export declare function amountEquals(a: string, b: string): boolean;
59
+ export declare function xrpToDrops(amount: string): string;
60
+ export declare function validateRequirements(value: unknown): asserts value is PaymentRequirements;
61
+ export declare function requirementsKey(value: PaymentRequirements): string;
62
+ export declare function validatePayload(value: unknown, requirement: PaymentRequirements): asserts value is PaymentPayload;
63
+ export declare function encodePaymentHeader(value: unknown): string;
64
+ export declare function decodePaymentHeader(value: string): unknown;
@@ -0,0 +1,64 @@
1
+ import BigNumber from "bignumber.js";
2
+ export declare const RLUSD_ASSET = "524C555344000000000000000000000000000000";
3
+ export declare const PAYMENT_HEADERS: {
4
+ readonly required: "PAYMENT-REQUIRED";
5
+ readonly signature: "PAYMENT-SIGNATURE";
6
+ readonly response: "PAYMENT-RESPONSE";
7
+ };
8
+ export type XrplNetwork = "xrpl:0" | "xrpl:1";
9
+ export interface PaymentRequirements {
10
+ scheme: "exact";
11
+ network: XrplNetwork;
12
+ asset: "XRP" | typeof RLUSD_ASSET;
13
+ amount: string;
14
+ payTo: string;
15
+ maxTimeoutSeconds: number;
16
+ extra: {
17
+ areFeesSponsored: false;
18
+ /** Omission selects the sequence transfer method. */
19
+ assetTransferMethod?: "sequence";
20
+ invoiceId?: string;
21
+ issuer?: string;
22
+ destinationTag?: number;
23
+ };
24
+ }
25
+ export interface PaymentRequired {
26
+ x402Version: 2;
27
+ resource: {
28
+ url: string;
29
+ description?: string;
30
+ mimeType?: string;
31
+ };
32
+ accepts: PaymentRequirements[];
33
+ error?: string;
34
+ }
35
+ export interface PaymentPayload {
36
+ x402Version: 2;
37
+ resource?: PaymentRequired["resource"];
38
+ accepted: PaymentRequirements;
39
+ payload: {
40
+ signedTxBlob: string;
41
+ };
42
+ }
43
+ export interface VerifyResponse {
44
+ isValid: boolean;
45
+ invalidReason?: string;
46
+ payer?: string;
47
+ }
48
+ export interface SettlementResponse {
49
+ success: boolean;
50
+ transaction: string;
51
+ network: string;
52
+ payer?: string;
53
+ errorReason?: string;
54
+ amount?: string;
55
+ }
56
+ export declare function isRecord(value: unknown): value is Record<string, any>;
57
+ export declare function positiveAmount(value: unknown, integer?: boolean): BigNumber;
58
+ export declare function amountEquals(a: string, b: string): boolean;
59
+ export declare function xrpToDrops(amount: string): string;
60
+ export declare function validateRequirements(value: unknown): asserts value is PaymentRequirements;
61
+ export declare function requirementsKey(value: PaymentRequirements): string;
62
+ export declare function validatePayload(value: unknown, requirement: PaymentRequirements): asserts value is PaymentPayload;
63
+ export declare function encodePaymentHeader(value: unknown): string;
64
+ export declare function decodePaymentHeader(value: string): unknown;