@t402/core 2.5.0 → 2.6.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/cjs/client/index.js +41 -4
- package/dist/cjs/client/index.js.map +1 -1
- package/dist/cjs/facilitator/index.js.map +1 -1
- package/dist/cjs/http/index.d.ts +331 -2
- package/dist/cjs/http/index.js +309 -8
- package/dist/cjs/http/index.js.map +1 -1
- package/dist/cjs/index.d.ts +23 -1
- package/dist/cjs/index.js +38 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/server/index.d.ts +1 -1
- package/dist/cjs/server/index.js +55 -4
- package/dist/cjs/server/index.js.map +1 -1
- package/dist/cjs/{t402HTTPResourceServer-B-aOi0BZ.d.ts → t402HTTPResourceServer-BIEvnbwL.d.ts} +9 -4
- package/dist/esm/{chunk-7RHSIMQL.mjs → chunk-4DIIUML6.mjs} +278 -10
- package/dist/esm/chunk-4DIIUML6.mjs.map +1 -0
- package/dist/esm/chunk-YM7W5RG3.mjs +44 -0
- package/dist/esm/chunk-YM7W5RG3.mjs.map +1 -0
- package/dist/esm/client/index.mjs +2 -2
- package/dist/esm/facilitator/index.mjs +1 -1
- package/dist/esm/http/index.d.mts +331 -2
- package/dist/esm/http/index.mjs +6 -2
- package/dist/esm/index.d.mts +23 -1
- package/dist/esm/index.mjs +3 -1
- package/dist/esm/server/index.d.mts +1 -1
- package/dist/esm/server/index.mjs +2 -2
- package/dist/esm/{t402HTTPResourceServer-CstWZOsH.d.mts → t402HTTPResourceServer-Jmmvy9kc.d.mts} +9 -4
- package/package.json +26 -10
- package/dist/esm/chunk-3VTYR43U.mjs +0 -7
- package/dist/esm/chunk-3VTYR43U.mjs.map +0 -1
- package/dist/esm/chunk-7RHSIMQL.mjs.map +0 -1
|
@@ -1,8 +1,337 @@
|
|
|
1
1
|
import { c as PaymentRequired, S as SettleResponse, a as PaymentPayload, P as PaymentRequirements } from '../mechanisms-dYCiYgko.mjs';
|
|
2
|
-
export { C as CompiledRoute, D as DynamicPayTo, a as DynamicPrice, F as FacilitatorClient, b as FacilitatorConfig, H as HTTPAdapter, c as HTTPFacilitatorClient, d as HTTPProcessResult, e as HTTPRequestContext, f as HTTPResponseInstructions, P as PaymentOption, g as PaywallConfig, h as PaywallProvider, i as ProcessSettleFailureResponse, j as ProcessSettleResultResponse, k as ProcessSettleSuccessResponse, R as RouteConfig, l as RouteConfigurationError, m as RouteValidationError, n as RoutesConfig, U as UnpaidResponseBody, o as UnpaidResponseResult, t as t402HTTPResourceServer } from '../t402HTTPResourceServer-
|
|
2
|
+
export { C as CompiledRoute, D as DynamicPayTo, a as DynamicPrice, F as FacilitatorClient, b as FacilitatorConfig, H as HTTPAdapter, c as HTTPFacilitatorClient, d as HTTPProcessResult, e as HTTPRequestContext, f as HTTPResponseInstructions, P as PaymentOption, g as PaywallConfig, h as PaywallProvider, i as ProcessSettleFailureResponse, j as ProcessSettleResultResponse, k as ProcessSettleSuccessResponse, R as RouteConfig, l as RouteConfigurationError, m as RouteValidationError, n as RoutesConfig, S as SettleOptions, U as UnpaidResponseBody, o as UnpaidResponseResult, t as t402HTTPResourceServer } from '../t402HTTPResourceServer-Jmmvy9kc.mjs';
|
|
3
3
|
export { f as t402HTTPClient } from '../t402HTTPClient-DbIXpGXL.mjs';
|
|
4
4
|
import 'zod';
|
|
5
5
|
|
|
6
|
+
type StreamStatus = "pending" | "active" | "paused" | "closing" | "closed" | "cancelled" | "expired";
|
|
7
|
+
interface StreamMetadata {
|
|
8
|
+
resourceId?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
tags?: string[];
|
|
11
|
+
extra?: Record<string, string>;
|
|
12
|
+
}
|
|
13
|
+
interface Stream {
|
|
14
|
+
id: string;
|
|
15
|
+
network: string;
|
|
16
|
+
scheme: string;
|
|
17
|
+
payer: string;
|
|
18
|
+
payee: string;
|
|
19
|
+
asset: string;
|
|
20
|
+
maxAmount: string;
|
|
21
|
+
currentAmount: string;
|
|
22
|
+
settledAmount: string;
|
|
23
|
+
ratePerSecond: string;
|
|
24
|
+
status: StreamStatus;
|
|
25
|
+
createdAt: string;
|
|
26
|
+
activatedAt?: string;
|
|
27
|
+
lastUpdatedAt: string;
|
|
28
|
+
expiresAt?: string;
|
|
29
|
+
closedAt?: string;
|
|
30
|
+
depositTxHash: string;
|
|
31
|
+
settlementTxHash: string;
|
|
32
|
+
metadata: StreamMetadata;
|
|
33
|
+
}
|
|
34
|
+
interface StreamUpdate {
|
|
35
|
+
id: string;
|
|
36
|
+
streamId: string;
|
|
37
|
+
amount: string;
|
|
38
|
+
signature: string;
|
|
39
|
+
timestamp: string;
|
|
40
|
+
sequenceNum: number;
|
|
41
|
+
resourceUnits: number;
|
|
42
|
+
}
|
|
43
|
+
interface StreamStats {
|
|
44
|
+
totalUpdates: number;
|
|
45
|
+
averageRate: string;
|
|
46
|
+
duration: number;
|
|
47
|
+
resourcesUsed: number;
|
|
48
|
+
efficiencyScore: number;
|
|
49
|
+
}
|
|
50
|
+
interface OpenStreamRequest {
|
|
51
|
+
network: string;
|
|
52
|
+
scheme: string;
|
|
53
|
+
payer: string;
|
|
54
|
+
payee: string;
|
|
55
|
+
asset: string;
|
|
56
|
+
maxAmount: string;
|
|
57
|
+
ratePerSecond?: string;
|
|
58
|
+
expiresAt?: string;
|
|
59
|
+
signature: string;
|
|
60
|
+
metadata?: StreamMetadata;
|
|
61
|
+
}
|
|
62
|
+
interface UpdateStreamRequest {
|
|
63
|
+
streamId: string;
|
|
64
|
+
amount: string;
|
|
65
|
+
signature: string;
|
|
66
|
+
resourceUnits?: number;
|
|
67
|
+
}
|
|
68
|
+
interface CloseStreamRequest {
|
|
69
|
+
streamId: string;
|
|
70
|
+
finalAmount: string;
|
|
71
|
+
payerSignature: string;
|
|
72
|
+
payeeSignature?: string;
|
|
73
|
+
reason?: string;
|
|
74
|
+
}
|
|
75
|
+
interface ListStreamsParams {
|
|
76
|
+
network?: string;
|
|
77
|
+
payer?: string;
|
|
78
|
+
payee?: string;
|
|
79
|
+
status?: StreamStatus[];
|
|
80
|
+
limit?: number;
|
|
81
|
+
offset?: number;
|
|
82
|
+
orderBy?: string;
|
|
83
|
+
orderDesc?: boolean;
|
|
84
|
+
}
|
|
85
|
+
interface OpenStreamResponse {
|
|
86
|
+
stream: Stream;
|
|
87
|
+
depositAmount?: string;
|
|
88
|
+
depositTo?: string;
|
|
89
|
+
}
|
|
90
|
+
interface UpdateStreamResponse {
|
|
91
|
+
stream: Stream;
|
|
92
|
+
update: StreamUpdate;
|
|
93
|
+
remaining: string;
|
|
94
|
+
canContinue: boolean;
|
|
95
|
+
}
|
|
96
|
+
interface CloseStreamResponse {
|
|
97
|
+
stream: Stream;
|
|
98
|
+
settledAmount: string;
|
|
99
|
+
txHash: string;
|
|
100
|
+
refundAmount: string;
|
|
101
|
+
}
|
|
102
|
+
interface GetStreamResponse {
|
|
103
|
+
stream: Stream;
|
|
104
|
+
updates?: StreamUpdate[];
|
|
105
|
+
stats?: StreamStats;
|
|
106
|
+
}
|
|
107
|
+
interface ListStreamsResponse {
|
|
108
|
+
streams: Stream[];
|
|
109
|
+
total: number;
|
|
110
|
+
limit: number;
|
|
111
|
+
offset: number;
|
|
112
|
+
hasMore: boolean;
|
|
113
|
+
}
|
|
114
|
+
interface PauseResumeResponse {
|
|
115
|
+
status: string;
|
|
116
|
+
message: string;
|
|
117
|
+
}
|
|
118
|
+
interface StreamingClientConfig {
|
|
119
|
+
url?: string;
|
|
120
|
+
apiKey?: string;
|
|
121
|
+
requesterAddress?: string;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* HTTP client for the t402 facilitator streaming API.
|
|
125
|
+
* Provides methods for managing payment streams.
|
|
126
|
+
*/
|
|
127
|
+
declare class StreamingClient {
|
|
128
|
+
readonly url: string;
|
|
129
|
+
private readonly apiKey?;
|
|
130
|
+
private readonly requesterAddress?;
|
|
131
|
+
constructor(config?: StreamingClientConfig);
|
|
132
|
+
/**
|
|
133
|
+
* Open a new payment stream
|
|
134
|
+
*/
|
|
135
|
+
openStream(params: OpenStreamRequest): Promise<OpenStreamResponse>;
|
|
136
|
+
/**
|
|
137
|
+
* Update a stream with a new cumulative amount
|
|
138
|
+
*/
|
|
139
|
+
updateStream(params: UpdateStreamRequest): Promise<UpdateStreamResponse>;
|
|
140
|
+
/**
|
|
141
|
+
* Close a stream and settle the final amount
|
|
142
|
+
*/
|
|
143
|
+
closeStream(params: CloseStreamRequest): Promise<CloseStreamResponse>;
|
|
144
|
+
/**
|
|
145
|
+
* Get stream details by ID
|
|
146
|
+
*/
|
|
147
|
+
getStream(id: string, options?: {
|
|
148
|
+
includeUpdates?: boolean;
|
|
149
|
+
includeStats?: boolean;
|
|
150
|
+
}): Promise<GetStreamResponse>;
|
|
151
|
+
/**
|
|
152
|
+
* Pause an active stream
|
|
153
|
+
*/
|
|
154
|
+
pauseStream(id: string): Promise<PauseResumeResponse>;
|
|
155
|
+
/**
|
|
156
|
+
* Resume a paused stream
|
|
157
|
+
*/
|
|
158
|
+
resumeStream(id: string): Promise<PauseResumeResponse>;
|
|
159
|
+
/**
|
|
160
|
+
* List streams with optional filters
|
|
161
|
+
*/
|
|
162
|
+
listStreams(filters?: ListStreamsParams): Promise<ListStreamsResponse>;
|
|
163
|
+
private buildHeaders;
|
|
164
|
+
private post;
|
|
165
|
+
private get;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
type IntentStatus = "pending" | "routed" | "executing" | "completed" | "failed" | "cancelled" | "expired";
|
|
169
|
+
type IntentPriority = "low" | "normal" | "high" | "urgent";
|
|
170
|
+
type RouteStepType = "transfer" | "swap" | "bridge" | "approve" | "wrap" | "unwrap";
|
|
171
|
+
interface RouteStep {
|
|
172
|
+
order: number;
|
|
173
|
+
type: RouteStepType;
|
|
174
|
+
network: string;
|
|
175
|
+
protocol?: string;
|
|
176
|
+
fromAsset: string;
|
|
177
|
+
toAsset: string;
|
|
178
|
+
fromAmount: string;
|
|
179
|
+
toAmount: string;
|
|
180
|
+
gasEstimate?: string;
|
|
181
|
+
data?: string;
|
|
182
|
+
}
|
|
183
|
+
interface Route {
|
|
184
|
+
id: string;
|
|
185
|
+
sourceNetwork: string;
|
|
186
|
+
targetNetwork: string;
|
|
187
|
+
sourceAsset: string;
|
|
188
|
+
targetAsset: string;
|
|
189
|
+
inputAmount: string;
|
|
190
|
+
outputAmount: string;
|
|
191
|
+
estimatedGas: string;
|
|
192
|
+
estimatedTime: number;
|
|
193
|
+
slippage: number;
|
|
194
|
+
score: number;
|
|
195
|
+
steps: RouteStep[];
|
|
196
|
+
requiresBridge: boolean;
|
|
197
|
+
bridgeProtocol?: string;
|
|
198
|
+
validUntil: string;
|
|
199
|
+
}
|
|
200
|
+
interface Intent {
|
|
201
|
+
id: string;
|
|
202
|
+
payer: string;
|
|
203
|
+
payee: string;
|
|
204
|
+
amount: string;
|
|
205
|
+
asset: string;
|
|
206
|
+
sourceNetworks?: string[];
|
|
207
|
+
targetNetwork?: string;
|
|
208
|
+
maxSlippage: number;
|
|
209
|
+
maxGasCost?: string;
|
|
210
|
+
priority: IntentPriority;
|
|
211
|
+
status: IntentStatus;
|
|
212
|
+
selectedRoute?: Route;
|
|
213
|
+
availableRoutes?: Route[];
|
|
214
|
+
createdAt: string;
|
|
215
|
+
expiresAt: string;
|
|
216
|
+
executedAt?: string;
|
|
217
|
+
txHashes?: string[];
|
|
218
|
+
errorMessage?: string;
|
|
219
|
+
metadata?: Record<string, string>;
|
|
220
|
+
}
|
|
221
|
+
interface CreateIntentRequest {
|
|
222
|
+
payer: string;
|
|
223
|
+
payee: string;
|
|
224
|
+
amount: string;
|
|
225
|
+
asset: string;
|
|
226
|
+
sourceNetworks?: string[];
|
|
227
|
+
targetNetwork?: string;
|
|
228
|
+
maxSlippage?: number;
|
|
229
|
+
maxGasCost?: string;
|
|
230
|
+
priority?: IntentPriority;
|
|
231
|
+
expiresIn?: number;
|
|
232
|
+
metadata?: Record<string, string>;
|
|
233
|
+
}
|
|
234
|
+
interface SelectRouteRequest {
|
|
235
|
+
routeId: string;
|
|
236
|
+
}
|
|
237
|
+
interface ExecuteIntentRequest {
|
|
238
|
+
signature: string;
|
|
239
|
+
routeId?: string;
|
|
240
|
+
}
|
|
241
|
+
interface CancelIntentRequest {
|
|
242
|
+
reason?: string;
|
|
243
|
+
}
|
|
244
|
+
interface ListIntentsParams {
|
|
245
|
+
payer?: string;
|
|
246
|
+
payee?: string;
|
|
247
|
+
status?: IntentStatus[];
|
|
248
|
+
limit?: number;
|
|
249
|
+
offset?: number;
|
|
250
|
+
}
|
|
251
|
+
interface CreateIntentResponse {
|
|
252
|
+
intent: Intent;
|
|
253
|
+
availableRoutes: Route[];
|
|
254
|
+
recommendedRoute?: Route;
|
|
255
|
+
}
|
|
256
|
+
interface SelectRouteResponse {
|
|
257
|
+
intent: Intent;
|
|
258
|
+
selectedRoute: Route;
|
|
259
|
+
}
|
|
260
|
+
interface ExecuteIntentResponse {
|
|
261
|
+
intent: Intent;
|
|
262
|
+
txHashes: string[];
|
|
263
|
+
status: string;
|
|
264
|
+
message?: string;
|
|
265
|
+
}
|
|
266
|
+
interface GetIntentResponse {
|
|
267
|
+
intent: Intent;
|
|
268
|
+
}
|
|
269
|
+
interface ListIntentsResponse {
|
|
270
|
+
intents: Intent[];
|
|
271
|
+
total: number;
|
|
272
|
+
limit: number;
|
|
273
|
+
offset: number;
|
|
274
|
+
hasMore: boolean;
|
|
275
|
+
}
|
|
276
|
+
interface CancelIntentResponse {
|
|
277
|
+
status: string;
|
|
278
|
+
message: string;
|
|
279
|
+
}
|
|
280
|
+
interface RefreshRoutesResponse {
|
|
281
|
+
intent: Intent;
|
|
282
|
+
availableRoutes: Route[];
|
|
283
|
+
recommendedRoute?: Route;
|
|
284
|
+
}
|
|
285
|
+
type IntentStats = Record<string, number>;
|
|
286
|
+
interface IntentClientConfig {
|
|
287
|
+
url?: string;
|
|
288
|
+
apiKey?: string;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* HTTP client for the t402 facilitator intent API.
|
|
292
|
+
* Provides methods for creating and managing cross-chain payment intents.
|
|
293
|
+
*/
|
|
294
|
+
declare class IntentClient {
|
|
295
|
+
readonly url: string;
|
|
296
|
+
private readonly apiKey?;
|
|
297
|
+
constructor(config?: IntentClientConfig);
|
|
298
|
+
/**
|
|
299
|
+
* Create a new payment intent and get available routes
|
|
300
|
+
*/
|
|
301
|
+
createIntent(params: CreateIntentRequest): Promise<CreateIntentResponse>;
|
|
302
|
+
/**
|
|
303
|
+
* Get intent details by ID
|
|
304
|
+
*/
|
|
305
|
+
getIntent(id: string): Promise<GetIntentResponse>;
|
|
306
|
+
/**
|
|
307
|
+
* Select a route for an intent
|
|
308
|
+
*/
|
|
309
|
+
selectRoute(id: string, params: SelectRouteRequest): Promise<SelectRouteResponse>;
|
|
310
|
+
/**
|
|
311
|
+
* Execute an intent with a signed authorization
|
|
312
|
+
*/
|
|
313
|
+
executeIntent(id: string, params: ExecuteIntentRequest): Promise<ExecuteIntentResponse>;
|
|
314
|
+
/**
|
|
315
|
+
* Cancel a pending intent
|
|
316
|
+
*/
|
|
317
|
+
cancelIntent(id: string, params?: CancelIntentRequest): Promise<CancelIntentResponse>;
|
|
318
|
+
/**
|
|
319
|
+
* Refresh available routes for an intent
|
|
320
|
+
*/
|
|
321
|
+
refreshRoutes(id: string): Promise<RefreshRoutesResponse>;
|
|
322
|
+
/**
|
|
323
|
+
* List intents with optional filters
|
|
324
|
+
*/
|
|
325
|
+
listIntents(filters?: ListIntentsParams): Promise<ListIntentsResponse>;
|
|
326
|
+
/**
|
|
327
|
+
* Get intent statistics (counts by status)
|
|
328
|
+
*/
|
|
329
|
+
getIntentStats(): Promise<IntentStats>;
|
|
330
|
+
private buildHeaders;
|
|
331
|
+
private post;
|
|
332
|
+
private get;
|
|
333
|
+
}
|
|
334
|
+
|
|
6
335
|
type QueryParamMethods = "GET" | "HEAD" | "DELETE";
|
|
7
336
|
type BodyMethods = "POST" | "PUT" | "PATCH";
|
|
8
337
|
/**
|
|
@@ -56,4 +385,4 @@ declare function encodePaymentResponseHeader(paymentResponse: SettleResponse & {
|
|
|
56
385
|
*/
|
|
57
386
|
declare function decodePaymentResponseHeader(paymentResponseHeader: string): SettleResponse;
|
|
58
387
|
|
|
59
|
-
export { type BodyMethods, type QueryParamMethods, decodePaymentRequiredHeader, decodePaymentResponseHeader, decodePaymentSignatureHeader, encodePaymentRequiredHeader, encodePaymentResponseHeader, encodePaymentSignatureHeader };
|
|
388
|
+
export { type BodyMethods, type CancelIntentRequest, type CancelIntentResponse, type CloseStreamRequest, type CloseStreamResponse, type CreateIntentRequest, type CreateIntentResponse, type ExecuteIntentRequest, type ExecuteIntentResponse, type GetIntentResponse, type GetStreamResponse, type Intent, IntentClient, type IntentClientConfig, type IntentPriority, type IntentStats, type IntentStatus, type ListIntentsParams, type ListIntentsResponse, type ListStreamsParams, type ListStreamsResponse, type OpenStreamRequest, type OpenStreamResponse, type PauseResumeResponse, type QueryParamMethods, type RefreshRoutesResponse, type Route, type RouteStep, type RouteStepType, type SelectRouteRequest, type SelectRouteResponse, type Stream, type StreamMetadata, type StreamStats, type StreamStatus, type StreamUpdate, StreamingClient, type StreamingClientConfig, type UpdateStreamRequest, type UpdateStreamResponse, decodePaymentRequiredHeader, decodePaymentResponseHeader, decodePaymentSignatureHeader, encodePaymentRequiredHeader, encodePaymentResponseHeader, encodePaymentSignatureHeader };
|
package/dist/esm/http/index.mjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
HTTPFacilitatorClient,
|
|
3
|
+
IntentClient,
|
|
3
4
|
RouteConfigurationError,
|
|
5
|
+
StreamingClient,
|
|
4
6
|
decodePaymentRequiredHeader,
|
|
5
7
|
decodePaymentResponseHeader,
|
|
6
8
|
decodePaymentSignatureHeader,
|
|
@@ -9,14 +11,16 @@ import {
|
|
|
9
11
|
encodePaymentSignatureHeader,
|
|
10
12
|
t402HTTPClient,
|
|
11
13
|
t402HTTPResourceServer
|
|
12
|
-
} from "../chunk-
|
|
13
|
-
import "../chunk-
|
|
14
|
+
} from "../chunk-4DIIUML6.mjs";
|
|
15
|
+
import "../chunk-YM7W5RG3.mjs";
|
|
14
16
|
import "../chunk-STKQDKUH.mjs";
|
|
15
17
|
import "../chunk-LJ4M5Z5U.mjs";
|
|
16
18
|
import "../chunk-4W2Y3RJM.mjs";
|
|
17
19
|
export {
|
|
18
20
|
HTTPFacilitatorClient,
|
|
21
|
+
IntentClient,
|
|
19
22
|
RouteConfigurationError,
|
|
23
|
+
StreamingClient,
|
|
20
24
|
decodePaymentRequiredHeader,
|
|
21
25
|
decodePaymentResponseHeader,
|
|
22
26
|
decodePaymentSignatureHeader,
|
package/dist/esm/index.d.mts
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* T402PaymentError - Structured error class for the T402 payment protocol.
|
|
3
|
+
*
|
|
4
|
+
* Wraps upstream errors with payment-specific context: phase, retryability,
|
|
5
|
+
* and optional HTTP status code.
|
|
6
|
+
*/
|
|
7
|
+
type PaymentPhase = "signing" | "submission" | "verification" | "settlement" | "unknown";
|
|
8
|
+
declare class T402PaymentError extends Error {
|
|
9
|
+
readonly cause?: Error;
|
|
10
|
+
readonly phase: PaymentPhase;
|
|
11
|
+
readonly retryable: boolean;
|
|
12
|
+
readonly code?: number;
|
|
13
|
+
constructor(message: string, options?: {
|
|
14
|
+
cause?: Error;
|
|
15
|
+
phase?: PaymentPhase;
|
|
16
|
+
retryable?: boolean;
|
|
17
|
+
code?: number;
|
|
18
|
+
});
|
|
19
|
+
isRetryable(): boolean;
|
|
20
|
+
toJSON(): Record<string, unknown>;
|
|
21
|
+
}
|
|
22
|
+
|
|
1
23
|
declare const t402Version = 2;
|
|
2
24
|
|
|
3
|
-
export { t402Version };
|
|
25
|
+
export { type PaymentPhase, T402PaymentError, t402Version };
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { C as CompiledRoute, F as FacilitatorClient, b as FacilitatorConfig, H as HTTPAdapter, c as HTTPFacilitatorClient, d as HTTPProcessResult, e as HTTPRequestContext, f as HTTPResponseInstructions, g as PaywallConfig, h as PaywallProvider, i as ProcessSettleFailureResponse, j as ProcessSettleResultResponse, k as ProcessSettleSuccessResponse, p as ResourceConfig, q as ResourceInfo, R as RouteConfig, l as RouteConfigurationError, m as RouteValidationError, n as RoutesConfig, U as UnpaidResponseBody, o as UnpaidResponseResult, t as t402HTTPResourceServer, r as t402ResourceServer } from '../t402HTTPResourceServer-
|
|
1
|
+
export { C as CompiledRoute, F as FacilitatorClient, b as FacilitatorConfig, H as HTTPAdapter, c as HTTPFacilitatorClient, d as HTTPProcessResult, e as HTTPRequestContext, f as HTTPResponseInstructions, g as PaywallConfig, h as PaywallProvider, i as ProcessSettleFailureResponse, j as ProcessSettleResultResponse, k as ProcessSettleSuccessResponse, p as ResourceConfig, q as ResourceInfo, R as RouteConfig, l as RouteConfigurationError, m as RouteValidationError, n as RoutesConfig, S as SettleOptions, U as UnpaidResponseBody, o as UnpaidResponseResult, t as t402HTTPResourceServer, r as t402ResourceServer } from '../t402HTTPResourceServer-Jmmvy9kc.mjs';
|
|
2
2
|
import '../mechanisms-dYCiYgko.mjs';
|
|
3
3
|
import 'zod';
|
|
@@ -2,10 +2,10 @@ import {
|
|
|
2
2
|
HTTPFacilitatorClient,
|
|
3
3
|
RouteConfigurationError,
|
|
4
4
|
t402HTTPResourceServer
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-4DIIUML6.mjs";
|
|
6
6
|
import {
|
|
7
7
|
t402Version
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-YM7W5RG3.mjs";
|
|
9
9
|
import "../chunk-STKQDKUH.mjs";
|
|
10
10
|
import {
|
|
11
11
|
deepEqual,
|
package/dist/esm/{t402HTTPResourceServer-CstWZOsH.d.mts → t402HTTPResourceServer-Jmmvy9kc.d.mts}
RENAMED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { a as PaymentPayload, P as PaymentRequirements, V as VerifyResponse, S as SettleResponse, e as SupportedResponse, N as Network, f as SchemeNetworkServer, R as ResourceServerExtension, g as SupportedKind, h as Price, c as PaymentRequired } from './mechanisms-dYCiYgko.mjs';
|
|
2
2
|
|
|
3
|
+
interface SettleOptions {
|
|
4
|
+
/** Optional idempotency key for replay protection */
|
|
5
|
+
idempotencyKey?: string;
|
|
6
|
+
}
|
|
3
7
|
interface FacilitatorConfig {
|
|
4
8
|
url?: string;
|
|
5
9
|
createAuthHeaders?: () => Promise<{
|
|
@@ -26,9 +30,10 @@ interface FacilitatorClient {
|
|
|
26
30
|
*
|
|
27
31
|
* @param paymentPayload - The payment to settle
|
|
28
32
|
* @param paymentRequirements - The requirements for settlement
|
|
33
|
+
* @param options - Optional settings including idempotency key
|
|
29
34
|
* @returns Settlement response
|
|
30
35
|
*/
|
|
31
|
-
settle(paymentPayload: PaymentPayload, paymentRequirements: PaymentRequirements): Promise<SettleResponse>;
|
|
36
|
+
settle(paymentPayload: PaymentPayload, paymentRequirements: PaymentRequirements, options?: SettleOptions): Promise<SettleResponse>;
|
|
32
37
|
/**
|
|
33
38
|
* Get supported payment kinds and extensions from the facilitator
|
|
34
39
|
*
|
|
@@ -62,9 +67,10 @@ declare class HTTPFacilitatorClient implements FacilitatorClient {
|
|
|
62
67
|
*
|
|
63
68
|
* @param paymentPayload - The payment to settle
|
|
64
69
|
* @param paymentRequirements - The requirements for settlement
|
|
70
|
+
* @param options - Optional settings including idempotency key
|
|
65
71
|
* @returns Settlement response
|
|
66
72
|
*/
|
|
67
|
-
settle(paymentPayload: PaymentPayload, paymentRequirements: PaymentRequirements): Promise<SettleResponse>;
|
|
73
|
+
settle(paymentPayload: PaymentPayload, paymentRequirements: PaymentRequirements, options?: SettleOptions): Promise<SettleResponse>;
|
|
68
74
|
/**
|
|
69
75
|
* Get supported payment kinds and extensions from the facilitator
|
|
70
76
|
*
|
|
@@ -467,7 +473,6 @@ interface RouteConfig {
|
|
|
467
473
|
*
|
|
468
474
|
* If not provided, defaults to { contentType: 'application/json', body: {} }.
|
|
469
475
|
*
|
|
470
|
-
* @param context - The HTTP request context
|
|
471
476
|
* @returns An object containing both contentType and body for the 402 response
|
|
472
477
|
*/
|
|
473
478
|
unpaidResponseBody?: UnpaidResponseBody;
|
|
@@ -716,4 +721,4 @@ declare class t402HTTPResourceServer {
|
|
|
716
721
|
private getDisplayAmount;
|
|
717
722
|
}
|
|
718
723
|
|
|
719
|
-
export { type CompiledRoute as C, type DynamicPayTo as D, type FacilitatorClient as F, type HTTPAdapter as H, type PaymentOption as P, type RouteConfig as R, type UnpaidResponseBody as U, type DynamicPrice as a, type FacilitatorConfig as b, HTTPFacilitatorClient as c, type HTTPProcessResult as d, type HTTPRequestContext as e, type HTTPResponseInstructions as f, type PaywallConfig as g, type PaywallProvider as h, type ProcessSettleFailureResponse as i, type ProcessSettleResultResponse as j, type ProcessSettleSuccessResponse as k, RouteConfigurationError as l, type RouteValidationError as m, type RoutesConfig as n, type UnpaidResponseResult as o, type ResourceConfig as p, type ResourceInfo as q, t402ResourceServer as r, t402HTTPResourceServer as t };
|
|
724
|
+
export { type CompiledRoute as C, type DynamicPayTo as D, type FacilitatorClient as F, type HTTPAdapter as H, type PaymentOption as P, type RouteConfig as R, type SettleOptions as S, type UnpaidResponseBody as U, type DynamicPrice as a, type FacilitatorConfig as b, HTTPFacilitatorClient as c, type HTTPProcessResult as d, type HTTPRequestContext as e, type HTTPResponseInstructions as f, type PaywallConfig as g, type PaywallProvider as h, type ProcessSettleFailureResponse as i, type ProcessSettleResultResponse as j, type ProcessSettleSuccessResponse as k, RouteConfigurationError as l, type RouteValidationError as m, type RoutesConfig as n, type UnpaidResponseResult as o, type ResourceConfig as p, type ResourceInfo as q, t402ResourceServer as r, t402HTTPResourceServer as t };
|
package/package.json
CHANGED
|
@@ -1,30 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@t402/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.1",
|
|
4
4
|
"main": "./dist/cjs/index.js",
|
|
5
5
|
"module": "./dist/esm/index.js",
|
|
6
6
|
"types": "./dist/cjs/index.d.ts",
|
|
7
|
-
"keywords": [
|
|
7
|
+
"keywords": [
|
|
8
|
+
"t402",
|
|
9
|
+
"payment",
|
|
10
|
+
"protocol",
|
|
11
|
+
"types",
|
|
12
|
+
"http-402",
|
|
13
|
+
"stablecoin",
|
|
14
|
+
"usdt"
|
|
15
|
+
],
|
|
8
16
|
"license": "Apache-2.0",
|
|
9
17
|
"author": "T402 Team",
|
|
10
|
-
"repository":
|
|
11
|
-
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://github.com/t402-io/t402.git",
|
|
21
|
+
"directory": "sdks/typescript/packages/core"
|
|
22
|
+
},
|
|
23
|
+
"description": "Core types, schemas, and constants for the T402 payment protocol",
|
|
12
24
|
"devDependencies": {
|
|
13
25
|
"@eslint/js": "^9.39.2",
|
|
14
|
-
"@types/node": "^25.2.
|
|
15
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
16
|
-
"@typescript-eslint/parser": "^8.
|
|
26
|
+
"@types/node": "^25.2.3",
|
|
27
|
+
"@typescript-eslint/eslint-plugin": "^8.56.0",
|
|
28
|
+
"@typescript-eslint/parser": "^8.56.0",
|
|
17
29
|
"eslint": "^9.24.0",
|
|
18
30
|
"eslint-plugin-import": "^2.31.0",
|
|
19
|
-
"eslint-plugin-jsdoc": "^62.
|
|
31
|
+
"eslint-plugin-jsdoc": "^62.6.0",
|
|
20
32
|
"eslint-plugin-prettier": "^5.5.5",
|
|
21
|
-
"glob": "^13.0.
|
|
33
|
+
"glob": "^13.0.5",
|
|
22
34
|
"prettier": "3.8.1",
|
|
23
35
|
"tsup": "^8.5.1",
|
|
24
36
|
"tsx": "^4.21.0",
|
|
25
37
|
"typescript": "^5.9.3",
|
|
26
38
|
"vite": "^7.3.1",
|
|
27
|
-
"vite-tsconfig-paths": "^6.1.
|
|
39
|
+
"vite-tsconfig-paths": "^6.1.1",
|
|
28
40
|
"vitest": "^3.2.4"
|
|
29
41
|
},
|
|
30
42
|
"dependencies": {
|
|
@@ -115,6 +127,10 @@
|
|
|
115
127
|
"files": [
|
|
116
128
|
"dist"
|
|
117
129
|
],
|
|
130
|
+
"homepage": "https://t402.io",
|
|
131
|
+
"publishConfig": {
|
|
132
|
+
"access": "public"
|
|
133
|
+
},
|
|
118
134
|
"scripts": {
|
|
119
135
|
"start": "tsx --env-file=.env index.ts",
|
|
120
136
|
"build": "tsup",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export const t402Version = 2;\n"],"mappings":";AAAO,IAAM,cAAc;","names":[]}
|