@openfacilitator/sdk 0.1.0 → 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/dist/index.d.mts CHANGED
@@ -43,6 +43,34 @@ interface PaymentAuthorization {
43
43
  /** Additional fields for specific schemes */
44
44
  [key: string]: unknown;
45
45
  }
46
+ /**
47
+ * Payment requirements from the server/resource
48
+ * Used for validation during verify/settle
49
+ */
50
+ interface PaymentRequirements {
51
+ /** Payment scheme (e.g., "exact") */
52
+ scheme: string;
53
+ /** Network identifier */
54
+ network: string;
55
+ /** Maximum amount required in base units */
56
+ maxAmountRequired: string;
57
+ /** Resource URL being paid for */
58
+ resource?: string;
59
+ /** Token/asset address */
60
+ asset: string;
61
+ /** Recipient address */
62
+ payTo?: string;
63
+ /** Human-readable description */
64
+ description?: string;
65
+ /** MIME type of resource */
66
+ mimeType?: string;
67
+ /** Maximum timeout in seconds */
68
+ maxTimeoutSeconds?: number;
69
+ /** Output schema for structured responses */
70
+ outputSchema?: Record<string, unknown>;
71
+ /** Extra data */
72
+ extra?: Record<string, unknown>;
73
+ }
46
74
  interface VerifyResponse {
47
75
  /** Whether the payment is valid */
48
76
  valid: boolean;
@@ -116,12 +144,16 @@ declare class OpenFacilitator {
116
144
  get url(): string;
117
145
  /**
118
146
  * Verify a payment is valid
147
+ * @param payment - The payment payload
148
+ * @param requirements - Payment requirements for validation
119
149
  */
120
- verify(payment: PaymentPayload): Promise<VerifyResponse>;
150
+ verify(payment: PaymentPayload, requirements: PaymentRequirements): Promise<VerifyResponse>;
121
151
  /**
122
152
  * Settle/broadcast a payment transaction
153
+ * @param payment - The payment payload
154
+ * @param requirements - Payment requirements for validation
123
155
  */
124
- settle(payment: PaymentPayload): Promise<SettleResponse>;
156
+ settle(payment: PaymentPayload, requirements: PaymentRequirements): Promise<SettleResponse>;
125
157
  /**
126
158
  * Get supported networks and payment kinds
127
159
  */
@@ -194,4 +226,4 @@ declare function getTestnets(): NetworkInfo[];
194
226
  */
195
227
  declare function isPaymentPayload(value: unknown): value is PaymentPayload;
196
228
 
197
- export { ConfigurationError, type FacilitatorConfig, FacilitatorError, NETWORKS, NetworkError, type NetworkInfo, type NetworkType, OpenFacilitator, type PaymentAuthorization, type PaymentKind, type PaymentPayload, type SettleResponse, SettlementError, type SupportedResponse, VerificationError, type VerifyResponse, createDefaultFacilitator, getMainnets, getNetwork, getNetworkType, getTestnets, isPaymentPayload, isValidNetwork, toV1NetworkId, toV2NetworkId };
229
+ export { ConfigurationError, type FacilitatorConfig, FacilitatorError, NETWORKS, NetworkError, type NetworkInfo, type NetworkType, OpenFacilitator, type PaymentAuthorization, type PaymentKind, type PaymentPayload, type PaymentRequirements, type SettleResponse, SettlementError, type SupportedResponse, VerificationError, type VerifyResponse, createDefaultFacilitator, getMainnets, getNetwork, getNetworkType, getTestnets, isPaymentPayload, isValidNetwork, toV1NetworkId, toV2NetworkId };
package/dist/index.d.ts CHANGED
@@ -43,6 +43,34 @@ interface PaymentAuthorization {
43
43
  /** Additional fields for specific schemes */
44
44
  [key: string]: unknown;
45
45
  }
46
+ /**
47
+ * Payment requirements from the server/resource
48
+ * Used for validation during verify/settle
49
+ */
50
+ interface PaymentRequirements {
51
+ /** Payment scheme (e.g., "exact") */
52
+ scheme: string;
53
+ /** Network identifier */
54
+ network: string;
55
+ /** Maximum amount required in base units */
56
+ maxAmountRequired: string;
57
+ /** Resource URL being paid for */
58
+ resource?: string;
59
+ /** Token/asset address */
60
+ asset: string;
61
+ /** Recipient address */
62
+ payTo?: string;
63
+ /** Human-readable description */
64
+ description?: string;
65
+ /** MIME type of resource */
66
+ mimeType?: string;
67
+ /** Maximum timeout in seconds */
68
+ maxTimeoutSeconds?: number;
69
+ /** Output schema for structured responses */
70
+ outputSchema?: Record<string, unknown>;
71
+ /** Extra data */
72
+ extra?: Record<string, unknown>;
73
+ }
46
74
  interface VerifyResponse {
47
75
  /** Whether the payment is valid */
48
76
  valid: boolean;
@@ -116,12 +144,16 @@ declare class OpenFacilitator {
116
144
  get url(): string;
117
145
  /**
118
146
  * Verify a payment is valid
147
+ * @param payment - The payment payload
148
+ * @param requirements - Payment requirements for validation
119
149
  */
120
- verify(payment: PaymentPayload): Promise<VerifyResponse>;
150
+ verify(payment: PaymentPayload, requirements: PaymentRequirements): Promise<VerifyResponse>;
121
151
  /**
122
152
  * Settle/broadcast a payment transaction
153
+ * @param payment - The payment payload
154
+ * @param requirements - Payment requirements for validation
123
155
  */
124
- settle(payment: PaymentPayload): Promise<SettleResponse>;
156
+ settle(payment: PaymentPayload, requirements: PaymentRequirements): Promise<SettleResponse>;
125
157
  /**
126
158
  * Get supported networks and payment kinds
127
159
  */
@@ -194,4 +226,4 @@ declare function getTestnets(): NetworkInfo[];
194
226
  */
195
227
  declare function isPaymentPayload(value: unknown): value is PaymentPayload;
196
228
 
197
- export { ConfigurationError, type FacilitatorConfig, FacilitatorError, NETWORKS, NetworkError, type NetworkInfo, type NetworkType, OpenFacilitator, type PaymentAuthorization, type PaymentKind, type PaymentPayload, type SettleResponse, SettlementError, type SupportedResponse, VerificationError, type VerifyResponse, createDefaultFacilitator, getMainnets, getNetwork, getNetworkType, getTestnets, isPaymentPayload, isValidNetwork, toV1NetworkId, toV2NetworkId };
229
+ export { ConfigurationError, type FacilitatorConfig, FacilitatorError, NETWORKS, NetworkError, type NetworkInfo, type NetworkType, OpenFacilitator, type PaymentAuthorization, type PaymentKind, type PaymentPayload, type PaymentRequirements, type SettleResponse, SettlementError, type SupportedResponse, VerificationError, type VerifyResponse, createDefaultFacilitator, getMainnets, getNetwork, getNetworkType, getTestnets, isPaymentPayload, isValidNetwork, toV1NetworkId, toV2NetworkId };
package/dist/index.js CHANGED
@@ -109,12 +109,19 @@ var OpenFacilitator = class {
109
109
  }
110
110
  /**
111
111
  * Verify a payment is valid
112
+ * @param payment - The payment payload
113
+ * @param requirements - Payment requirements for validation
112
114
  */
113
- async verify(payment) {
115
+ async verify(payment, requirements) {
114
116
  try {
117
+ const body = {
118
+ x402Version: payment.x402Version,
119
+ paymentPayload: payment,
120
+ paymentRequirements: requirements
121
+ };
115
122
  const response = await this.request("/verify", {
116
123
  method: "POST",
117
- body: JSON.stringify(payment)
124
+ body: JSON.stringify(body)
118
125
  });
119
126
  return response;
120
127
  } catch (error) {
@@ -127,12 +134,19 @@ var OpenFacilitator = class {
127
134
  }
128
135
  /**
129
136
  * Settle/broadcast a payment transaction
137
+ * @param payment - The payment payload
138
+ * @param requirements - Payment requirements for validation
130
139
  */
131
- async settle(payment) {
140
+ async settle(payment, requirements) {
132
141
  try {
142
+ const body = {
143
+ x402Version: payment.x402Version,
144
+ paymentPayload: payment,
145
+ paymentRequirements: requirements
146
+ };
133
147
  const response = await this.request("/settle", {
134
148
  method: "POST",
135
- body: JSON.stringify(payment)
149
+ body: JSON.stringify(body)
136
150
  });
137
151
  return response;
138
152
  } catch (error) {
package/dist/index.mjs CHANGED
@@ -68,12 +68,19 @@ var OpenFacilitator = class {
68
68
  }
69
69
  /**
70
70
  * Verify a payment is valid
71
+ * @param payment - The payment payload
72
+ * @param requirements - Payment requirements for validation
71
73
  */
72
- async verify(payment) {
74
+ async verify(payment, requirements) {
73
75
  try {
76
+ const body = {
77
+ x402Version: payment.x402Version,
78
+ paymentPayload: payment,
79
+ paymentRequirements: requirements
80
+ };
74
81
  const response = await this.request("/verify", {
75
82
  method: "POST",
76
- body: JSON.stringify(payment)
83
+ body: JSON.stringify(body)
77
84
  });
78
85
  return response;
79
86
  } catch (error) {
@@ -86,12 +93,19 @@ var OpenFacilitator = class {
86
93
  }
87
94
  /**
88
95
  * Settle/broadcast a payment transaction
96
+ * @param payment - The payment payload
97
+ * @param requirements - Payment requirements for validation
89
98
  */
90
- async settle(payment) {
99
+ async settle(payment, requirements) {
91
100
  try {
101
+ const body = {
102
+ x402Version: payment.x402Version,
103
+ paymentPayload: payment,
104
+ paymentRequirements: requirements
105
+ };
92
106
  const response = await this.request("/settle", {
93
107
  method: "POST",
94
- body: JSON.stringify(payment)
108
+ body: JSON.stringify(body)
95
109
  });
96
110
  return response;
97
111
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfacilitator/sdk",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "TypeScript SDK for x402 payment facilitation",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",