@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.
@@ -1,8 +1,337 @@
1
1
  import { c as PaymentRequired, S as SettleResponse, a as PaymentPayload, P as PaymentRequirements } from '../mechanisms-dYCiYgko.js';
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-B-aOi0BZ.js';
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-BIEvnbwL.js';
3
3
  export { f as t402HTTPClient } from '../t402HTTPClient-CHaMMGBY.js';
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 };