@t402/core 2.4.0 → 2.6.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.
Files changed (51) hide show
  1. package/dist/cjs/client/index.d.ts +2 -2
  2. package/dist/cjs/client/index.js +43 -5
  3. package/dist/cjs/client/index.js.map +1 -1
  4. package/dist/cjs/facilitator/index.d.ts +1 -1
  5. package/dist/cjs/facilitator/index.js.map +1 -1
  6. package/dist/cjs/http/index.d.ts +3 -3
  7. package/dist/cjs/http/index.js +63 -10
  8. package/dist/cjs/http/index.js.map +1 -1
  9. package/dist/cjs/index.d.ts +23 -1
  10. package/dist/cjs/index.js +38 -0
  11. package/dist/cjs/index.js.map +1 -1
  12. package/dist/cjs/{mechanisms-C7yK91d4.d.ts → mechanisms-dYCiYgko.d.ts} +76 -7
  13. package/dist/cjs/server/index.d.ts +2 -2
  14. package/dist/cjs/server/index.js +54 -6
  15. package/dist/cjs/server/index.js.map +1 -1
  16. package/dist/cjs/{t402HTTPClient-DmkFydNG.d.ts → t402HTTPClient-CHaMMGBY.d.ts} +2 -2
  17. package/dist/cjs/{t402HTTPResourceServer-CybruqCk.d.ts → t402HTTPResourceServer-CGZh_p2c.d.ts} +2 -3
  18. package/dist/cjs/types/index.d.ts +1 -1
  19. package/dist/cjs/types/index.js +2 -1
  20. package/dist/cjs/types/index.js.map +1 -1
  21. package/dist/cjs/types/v1/index.d.ts +1 -1
  22. package/dist/cjs/utils/index.d.ts +1 -1
  23. package/dist/esm/{chunk-KPNYZYDS.mjs → chunk-STKQDKUH.mjs} +3 -2
  24. package/dist/esm/chunk-STKQDKUH.mjs.map +1 -0
  25. package/dist/esm/chunk-YM7W5RG3.mjs +44 -0
  26. package/dist/esm/chunk-YM7W5RG3.mjs.map +1 -0
  27. package/dist/esm/{chunk-REMGOG6C.mjs → chunk-Z5HFSNZZ.mjs} +33 -12
  28. package/dist/esm/chunk-Z5HFSNZZ.mjs.map +1 -0
  29. package/dist/esm/client/index.d.mts +2 -2
  30. package/dist/esm/client/index.mjs +3 -3
  31. package/dist/esm/facilitator/index.d.mts +1 -1
  32. package/dist/esm/facilitator/index.mjs +1 -1
  33. package/dist/esm/http/index.d.mts +3 -3
  34. package/dist/esm/http/index.mjs +3 -3
  35. package/dist/esm/index.d.mts +23 -1
  36. package/dist/esm/index.mjs +3 -1
  37. package/dist/esm/{mechanisms-C7yK91d4.d.mts → mechanisms-dYCiYgko.d.mts} +76 -7
  38. package/dist/esm/server/index.d.mts +2 -2
  39. package/dist/esm/server/index.mjs +3 -3
  40. package/dist/esm/{t402HTTPClient-Bgjn3TRU.d.mts → t402HTTPClient-DbIXpGXL.d.mts} +2 -2
  41. package/dist/esm/{t402HTTPResourceServer-DuZIzhRI.d.mts → t402HTTPResourceServer-DDxVMmS2.d.mts} +2 -3
  42. package/dist/esm/types/index.d.mts +1 -1
  43. package/dist/esm/types/index.mjs +1 -1
  44. package/dist/esm/types/index.mjs.map +1 -1
  45. package/dist/esm/types/v1/index.d.mts +1 -1
  46. package/dist/esm/utils/index.d.mts +1 -1
  47. package/package.json +31 -15
  48. package/dist/esm/chunk-3VTYR43U.mjs +0 -7
  49. package/dist/esm/chunk-3VTYR43U.mjs.map +0 -1
  50. package/dist/esm/chunk-KPNYZYDS.mjs.map +0 -1
  51. package/dist/esm/chunk-REMGOG6C.mjs.map +0 -1
@@ -240,42 +240,77 @@ declare const T402_A2A_EXTENSION_URI = "https://github.com/google-a2a/a2a-t402/v
240
240
  declare const A2A_EXTENSIONS_HEADER = "X-A2A-Extensions";
241
241
  /**
242
242
  * Check if a task is in a payment-required state
243
+ *
244
+ * @param task - The A2A task to check
245
+ * @returns Whether the task requires payment
243
246
  */
244
247
  declare function isPaymentRequired(task: A2ATask): boolean;
245
248
  /**
246
249
  * Check if a task has completed payment
250
+ *
251
+ * @param task - The A2A task to check
252
+ * @returns Whether the task has completed payment
247
253
  */
248
254
  declare function isPaymentCompleted(task: A2ATask): boolean;
249
255
  /**
250
256
  * Check if a task has failed payment
257
+ *
258
+ * @param task - The A2A task to check
259
+ * @returns Whether the task has failed payment
251
260
  */
252
261
  declare function isPaymentFailed(task: A2ATask): boolean;
253
262
  /**
254
263
  * Extract payment requirements from a task
264
+ *
265
+ * @param task - The A2A task to extract requirements from
266
+ * @returns The payment requirements if the task requires payment
255
267
  */
256
268
  declare function getPaymentRequired(task: A2ATask): PaymentRequired | undefined;
257
269
  /**
258
270
  * Extract payment receipts from a task
271
+ *
272
+ * @param task - The A2A task to extract receipts from
273
+ * @returns The settlement receipts if available
259
274
  */
260
275
  declare function getPaymentReceipts(task: A2ATask): SettleResponse[] | undefined;
261
276
  /**
262
277
  * Create a payment-required message
278
+ *
279
+ * @param paymentRequired - The payment requirements
280
+ * @param text - Optional message text
281
+ * @returns An A2A message with payment-required metadata
263
282
  */
264
283
  declare function createPaymentRequiredMessage(paymentRequired: PaymentRequired, text?: string): A2AMessage;
265
284
  /**
266
285
  * Create a payment submission message
286
+ *
287
+ * @param paymentPayload - The payment payload to submit
288
+ * @param text - Optional message text
289
+ * @returns An A2A message with payment-submitted metadata
267
290
  */
268
291
  declare function createPaymentSubmissionMessage(paymentPayload: PaymentPayload, text?: string): A2AMessage;
269
292
  /**
270
293
  * Create a payment completed message
294
+ *
295
+ * @param receipts - The settlement receipts
296
+ * @param text - Optional message text
297
+ * @returns An A2A message with payment-completed metadata
271
298
  */
272
299
  declare function createPaymentCompletedMessage(receipts: SettleResponse[], text?: string): A2AMessage;
273
300
  /**
274
301
  * Create a payment failed message
302
+ *
303
+ * @param receipts - The settlement receipts
304
+ * @param errorCode - The error code
305
+ * @param text - Optional message text
306
+ * @returns An A2A message with payment-failed metadata
275
307
  */
276
308
  declare function createPaymentFailedMessage(receipts: SettleResponse[], errorCode: string, text?: string): A2AMessage;
277
309
  /**
278
310
  * Create a T402 extension declaration for agent cards
311
+ *
312
+ * @param required - Whether the extension is required
313
+ * @returns An A2A extension declaration
279
314
  */
280
315
  declare function createT402Extension(required?: boolean): A2AExtension;
281
316
 
@@ -564,17 +599,47 @@ interface APIError {
564
599
  details?: string;
565
600
  retry?: boolean;
566
601
  }
567
- /** Returns the HTTP status code for a given error code */
602
+ /**
603
+ * Returns the HTTP status code for a given error code
604
+ *
605
+ * @param code - The T402 error code
606
+ * @returns The corresponding HTTP status code
607
+ */
568
608
  declare function httpStatusForCode(code: ErrorCode): number;
569
- /** Returns true if the error code is a client error (T402-1xxx) */
609
+ /**
610
+ * Returns true if the error code is a client error (T402-1xxx)
611
+ *
612
+ * @param code - The T402 error code
613
+ * @returns Whether the error is a client error
614
+ */
570
615
  declare function isClientError(code: ErrorCode): boolean;
571
- /** Returns true if the error code is a server error (T402-2xxx) */
616
+ /**
617
+ * Returns true if the error code is a server error (T402-2xxx)
618
+ *
619
+ * @param code - The T402 error code
620
+ * @returns Whether the error is a server error
621
+ */
572
622
  declare function isServerError(code: ErrorCode): boolean;
573
- /** Returns true if the error code is a facilitator error (T402-3xxx) */
623
+ /**
624
+ * Returns true if the error code is a facilitator error (T402-3xxx)
625
+ *
626
+ * @param code - The T402 error code
627
+ * @returns Whether the error is a facilitator error
628
+ */
574
629
  declare function isFacilitatorError(code: ErrorCode): boolean;
575
- /** Returns true if the error code is a chain error (T402-4xxx) */
630
+ /**
631
+ * Returns true if the error code is a chain error (T402-4xxx)
632
+ *
633
+ * @param code - The T402 error code
634
+ * @returns Whether the error is a chain error
635
+ */
576
636
  declare function isChainError(code: ErrorCode): boolean;
577
- /** Returns true if the error code is a bridge error (T402-5xxx) */
637
+ /**
638
+ * Returns true if the error code is a bridge error (T402-5xxx)
639
+ *
640
+ * @param code - The T402 error code
641
+ * @returns Whether the error is a bridge error
642
+ */
578
643
  declare function isBridgeError(code: ErrorCode): boolean;
579
644
 
580
645
  /**
@@ -797,18 +862,21 @@ declare const SettleResponseSchema: z.ZodObject<{
797
862
  network: z.ZodString;
798
863
  errorReason: z.ZodOptional<z.ZodString>;
799
864
  payer: z.ZodOptional<z.ZodString>;
865
+ confirmations: z.ZodOptional<z.ZodString>;
800
866
  }, "strip", z.ZodTypeAny, {
801
867
  network: string;
802
868
  success: boolean;
803
869
  transaction: string;
804
870
  payer?: string | undefined;
805
871
  errorReason?: string | undefined;
872
+ confirmations?: string | undefined;
806
873
  }, {
807
874
  network: string;
808
875
  success: boolean;
809
876
  transaction: string;
810
877
  payer?: string | undefined;
811
878
  errorReason?: string | undefined;
879
+ confirmations?: string | undefined;
812
880
  }>;
813
881
  declare const PaymentRequirementsV1Schema: z.ZodObject<{
814
882
  scheme: z.ZodString;
@@ -996,6 +1064,7 @@ type SettleResponse = {
996
1064
  payer?: string;
997
1065
  transaction: string;
998
1066
  network: Network;
1067
+ confirmations?: string;
999
1068
  };
1000
1069
  type SupportedKind = {
1001
1070
  t402Version: number;
@@ -1123,4 +1192,4 @@ interface SchemeNetworkServer {
1123
1192
  }, facilitatorExtensions: string[]): Promise<PaymentRequirements>;
1124
1193
  }
1125
1194
 
1126
- export { createPaymentFailedMessage as $, type AssetAmount as A, type A2AArtifact as B, type A2ATaskStatus as C, type A2ATask as D, type A2ARequest as E, type A2AResponse as F, type A2AError as G, type A2AExtension as H, type A2ACapabilities as I, type A2AAgentCard as J, type A2ASkill as K, A2A_EXTENSIONS_HEADER as L, type Money as M, type Network as N, isPaymentRequired as O, type PaymentRequirements as P, isPaymentCompleted as Q, type ResourceServerExtension as R, type SettleResponse as S, T402_A2A_EXTENSION_URI as T, isPaymentFailed as U, type VerifyResponse as V, getPaymentRequired as W, getPaymentReceipts as X, createPaymentRequiredMessage as Y, createPaymentSubmissionMessage as Z, createPaymentCompletedMessage as _, type PaymentPayload as a, ERR_STREAM_NOT_FOUND as a$, createT402Extension as a0, type UptoPaymentRequirements as a1, type UptoExtra as a2, type UptoPayloadBase as a3, type UptoEvmPayload as a4, type UptoEvmPayloadCompact as a5, type UptoSettlement as a6, type UptoUsageDetails as a7, type UptoSettlementResponse as a8, type UptoValidationResult as a9, ERR_RATE_LIMITED as aA, ERR_SERVICE_UNAVAILABLE as aB, ERR_VERIFICATION_FAILED as aC, ERR_SETTLEMENT_FAILED as aD, ERR_INSUFFICIENT_BALANCE as aE, ERR_ALLOWANCE_INSUFFICIENT as aF, ERR_PAYMENT_MISMATCH as aG, ERR_DUPLICATE_PAYMENT as aH, ERR_SETTLEMENT_PENDING as aI, ERR_SETTLEMENT_TIMEOUT as aJ, ERR_NONCE_REPLAY as aK, ERR_IDEMPOTENCY_CONFLICT as aL, ERR_IDEMPOTENCY_UNAVAILABLE as aM, ERR_PREVIOUS_REQUEST_FAILED as aN, ERR_REQUEST_IN_PROGRESS as aO, ERR_CHAIN_UNAVAILABLE as aP, ERR_TRANSACTION_FAILED as aQ, ERR_TRANSACTION_REVERTED as aR, ERR_GAS_ESTIMATION_FAILED as aS, ERR_NONCE_CONFLICT as aT, ERR_CHAIN_CONGESTED as aU, ERR_CONTRACT_ERROR as aV, ERR_BRIDGE_UNAVAILABLE as aW, ERR_BRIDGE_QUOTE_FAILED as aX, ERR_BRIDGE_TRANSFER_FAILED as aY, ERR_BRIDGE_TIMEOUT as aZ, ERR_UNSUPPORTED_ROUTE as a_, type UptoUnit as aa, isUptoPaymentRequirements as ab, isUptoEvmPayload as ac, UPTO_SCHEME as ad, UPTO_DEFAULTS as ae, type ErrorCode as af, type APIError as ag, ERR_INVALID_REQUEST as ah, ERR_MISSING_PAYLOAD as ai, ERR_MISSING_REQUIREMENTS as aj, ERR_INVALID_PAYLOAD as ak, ERR_INVALID_REQUIREMENTS as al, ERR_INVALID_SIGNATURE as am, ERR_INVALID_NETWORK as an, ERR_INVALID_SCHEME as ao, ERR_INVALID_AMOUNT as ap, ERR_INVALID_ADDRESS as aq, ERR_EXPIRED_PAYMENT as ar, ERR_INVALID_NONCE as as, ERR_INSUFFICIENT_AMOUNT as at, ERR_INVALID_IDEMPOTENCY_KEY as au, ERR_SIGNATURE_EXPIRED as av, ERR_INTERNAL as aw, ERR_DATABASE_UNAVAILABLE as ax, ERR_CACHE_UNAVAILABLE as ay, ERR_RPC_UNAVAILABLE as az, type SchemeNetworkFacilitator as b, ERR_STREAM_ALREADY_CLOSED as b0, ERR_STREAM_ALREADY_PAUSED as b1, ERR_STREAM_NOT_PAUSED as b2, ERR_STREAM_AMOUNT_EXCEEDED as b3, ERR_STREAM_EXPIRED as b4, ERR_STREAM_INVALID_STATE as b5, ERR_STREAM_RATE_LIMITED as b6, ERR_INTENT_NOT_FOUND as b7, ERR_INTENT_ALREADY_EXECUTED as b8, ERR_INTENT_CANCELLED as b9, parsePaymentRequirements as bA, safeParsePaymentPayload as bB, safeParsePaymentRequired as bC, safeParsePaymentRequirements as bD, type ValidatedPaymentPayload as bE, type ValidatedPaymentRequired as bF, type ValidatedPaymentRequirements as bG, type ValidatedVerifyResponse as bH, type ValidatedSettleResponse as bI, ERR_INTENT_EXPIRED as ba, ERR_NO_ROUTES_AVAILABLE as bb, ERR_ROUTE_EXPIRED as bc, ERR_ROUTE_NOT_SELECTED as bd, ERR_INTENT_INVALID_STATE as be, ERR_RESOURCE_NOT_FOUND as bf, ERR_RESOURCE_ALREADY_EXISTS as bg, ERR_INVALID_PARAMETERS as bh, ERR_NOT_AUTHORIZED as bi, httpStatusForCode as bj, isClientError as bk, isServerError as bl, isFacilitatorError as bm, isChainError as bn, isBridgeError as bo, NetworkSchema as bp, ResourceInfoSchema as bq, PaymentRequirementsSchema as br, PaymentRequiredSchema as bs, PaymentPayloadSchema as bt, VerifyResponseSchema as bu, SettleResponseSchema as bv, PaymentRequirementsV1Schema as bw, PaymentPayloadV1Schema as bx, parsePaymentPayload as by, parsePaymentRequired as bz, type PaymentRequired as c, type SchemeNetworkClient as d, type SupportedResponse as e, type SchemeNetworkServer as f, type SupportedKind as g, type Price as h, type PaymentRequirementsV1 as i, type PaymentRequiredV1 as j, type PaymentPayloadV1 as k, type VerifyRequestV1 as l, type SettleRequestV1 as m, type SettleResponseV1 as n, type SupportedResponseV1 as o, type VerifyRequest as p, type SettleRequest as q, type MoneyParser as r, type A2APaymentStatus as s, type A2ATaskState as t, type A2ATextPart as u, type A2AFilePart as v, type A2ADataPart as w, type A2AMessagePart as x, type A2APaymentMetadata as y, type A2AMessage as z };
1195
+ export { ERR_GAS_ESTIMATION_FAILED as $, type A2AAgentCard as A, type A2AResponse as B, type A2ASkill as C, type A2ATask as D, type A2ATaskState as E, type A2ATaskStatus as F, type A2ATextPart as G, A2A_EXTENSIONS_HEADER as H, type APIError as I, type AssetAmount as J, ERR_ALLOWANCE_INSUFFICIENT as K, ERR_BRIDGE_QUOTE_FAILED as L, ERR_BRIDGE_TIMEOUT as M, type Network as N, ERR_BRIDGE_TRANSFER_FAILED as O, type PaymentRequirements as P, ERR_BRIDGE_UNAVAILABLE as Q, type ResourceServerExtension as R, type SettleResponse as S, ERR_CACHE_UNAVAILABLE as T, ERR_CHAIN_CONGESTED as U, type VerifyResponse as V, ERR_CHAIN_UNAVAILABLE as W, ERR_CONTRACT_ERROR as X, ERR_DATABASE_UNAVAILABLE as Y, ERR_DUPLICATE_PAYMENT as Z, ERR_EXPIRED_PAYMENT as _, type PaymentPayload as a, type SettleRequest as a$, ERR_IDEMPOTENCY_CONFLICT as a0, ERR_IDEMPOTENCY_UNAVAILABLE as a1, ERR_INSUFFICIENT_AMOUNT as a2, ERR_INSUFFICIENT_BALANCE as a3, ERR_INTENT_ALREADY_EXECUTED as a4, ERR_INTENT_CANCELLED as a5, ERR_INTENT_EXPIRED as a6, ERR_INTENT_INVALID_STATE as a7, ERR_INTENT_NOT_FOUND as a8, ERR_INTERNAL as a9, ERR_SERVICE_UNAVAILABLE as aA, ERR_SETTLEMENT_FAILED as aB, ERR_SETTLEMENT_PENDING as aC, ERR_SETTLEMENT_TIMEOUT as aD, ERR_SIGNATURE_EXPIRED as aE, ERR_STREAM_ALREADY_CLOSED as aF, ERR_STREAM_ALREADY_PAUSED as aG, ERR_STREAM_AMOUNT_EXCEEDED as aH, ERR_STREAM_EXPIRED as aI, ERR_STREAM_INVALID_STATE as aJ, ERR_STREAM_NOT_FOUND as aK, ERR_STREAM_NOT_PAUSED as aL, ERR_STREAM_RATE_LIMITED as aM, ERR_TRANSACTION_FAILED as aN, ERR_TRANSACTION_REVERTED as aO, ERR_UNSUPPORTED_ROUTE as aP, ERR_VERIFICATION_FAILED as aQ, type ErrorCode as aR, type Money as aS, type MoneyParser as aT, NetworkSchema as aU, PaymentPayloadSchema as aV, PaymentPayloadV1Schema as aW, PaymentRequiredSchema as aX, PaymentRequirementsSchema as aY, PaymentRequirementsV1Schema as aZ, ResourceInfoSchema as a_, ERR_INVALID_ADDRESS as aa, ERR_INVALID_AMOUNT as ab, ERR_INVALID_IDEMPOTENCY_KEY as ac, ERR_INVALID_NETWORK as ad, ERR_INVALID_NONCE as ae, ERR_INVALID_PARAMETERS as af, ERR_INVALID_PAYLOAD as ag, ERR_INVALID_REQUEST as ah, ERR_INVALID_REQUIREMENTS as ai, ERR_INVALID_SCHEME as aj, ERR_INVALID_SIGNATURE as ak, ERR_MISSING_PAYLOAD as al, ERR_MISSING_REQUIREMENTS as am, ERR_NONCE_CONFLICT as an, ERR_NONCE_REPLAY as ao, ERR_NOT_AUTHORIZED as ap, ERR_NO_ROUTES_AVAILABLE as aq, ERR_PAYMENT_MISMATCH as ar, ERR_PREVIOUS_REQUEST_FAILED as as, ERR_RATE_LIMITED as at, ERR_REQUEST_IN_PROGRESS as au, ERR_RESOURCE_ALREADY_EXISTS as av, ERR_RESOURCE_NOT_FOUND as aw, ERR_ROUTE_EXPIRED as ax, ERR_ROUTE_NOT_SELECTED as ay, ERR_RPC_UNAVAILABLE as az, type SchemeNetworkFacilitator as b, SettleResponseSchema as b0, T402_A2A_EXTENSION_URI as b1, UPTO_DEFAULTS as b2, UPTO_SCHEME as b3, type UptoEvmPayload as b4, type UptoEvmPayloadCompact as b5, type UptoExtra as b6, type UptoPayloadBase as b7, type UptoPaymentRequirements as b8, type UptoSettlement as b9, isServerError as bA, isUptoEvmPayload as bB, isUptoPaymentRequirements as bC, parsePaymentPayload as bD, parsePaymentRequired as bE, parsePaymentRequirements as bF, safeParsePaymentPayload as bG, safeParsePaymentRequired as bH, safeParsePaymentRequirements as bI, type UptoSettlementResponse as ba, type UptoUnit as bb, type UptoUsageDetails as bc, type UptoValidationResult as bd, type ValidatedPaymentPayload as be, type ValidatedPaymentRequired as bf, type ValidatedPaymentRequirements as bg, type ValidatedSettleResponse as bh, type ValidatedVerifyResponse as bi, type VerifyRequest as bj, VerifyResponseSchema as bk, createPaymentCompletedMessage as bl, createPaymentFailedMessage as bm, createPaymentRequiredMessage as bn, createPaymentSubmissionMessage as bo, createT402Extension as bp, getPaymentReceipts as bq, getPaymentRequired as br, httpStatusForCode as bs, isBridgeError as bt, isChainError as bu, isClientError as bv, isFacilitatorError as bw, isPaymentCompleted as bx, isPaymentFailed as by, isPaymentRequired as bz, type PaymentRequired as c, type SchemeNetworkClient as d, type SupportedResponse as e, type SchemeNetworkServer as f, type SupportedKind as g, type Price as h, type PaymentPayloadV1 as i, type PaymentRequiredV1 as j, type PaymentRequirementsV1 as k, type SettleRequestV1 as l, type SettleResponseV1 as m, type SupportedResponseV1 as n, type VerifyRequestV1 as o, type A2AArtifact as p, type A2ACapabilities as q, type A2ADataPart as r, type A2AError as s, type A2AExtension as t, type A2AFilePart as u, type A2AMessage as v, type A2AMessagePart as w, type A2APaymentMetadata as x, type A2APaymentStatus as y, type A2ARequest as z };
@@ -1,3 +1,3 @@
1
- export { C as CompiledRoute, F as FacilitatorClient, o as FacilitatorConfig, a as HTTPAdapter, H as HTTPFacilitatorClient, d as HTTPProcessResult, b as HTTPRequestContext, c as HTTPResponseInstructions, P as PaywallConfig, e as PaywallProvider, m as ProcessSettleFailureResponse, k as ProcessSettleResultResponse, l as ProcessSettleSuccessResponse, q as ResourceConfig, r as ResourceInfo, g as RouteConfig, R as RouteConfigurationError, n as RouteValidationError, h as RoutesConfig, U as UnpaidResponseBody, j as UnpaidResponseResult, t as t402HTTPResourceServer, p as t402ResourceServer } from '../t402HTTPResourceServer-CybruqCk.js';
2
- import '../mechanisms-C7yK91d4.js';
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-CGZh_p2c.js';
2
+ import '../mechanisms-dYCiYgko.js';
3
3
  import 'zod';
@@ -85,6 +85,38 @@ function deepEqual(obj1, obj2) {
85
85
  }
86
86
  }
87
87
 
88
+ // src/errors.ts
89
+ var T402PaymentError = class _T402PaymentError extends Error {
90
+ constructor(message, options) {
91
+ super(message);
92
+ __publicField(this, "cause");
93
+ __publicField(this, "phase");
94
+ __publicField(this, "retryable");
95
+ __publicField(this, "code");
96
+ this.name = "T402PaymentError";
97
+ this.cause = options?.cause;
98
+ this.phase = options?.phase ?? "unknown";
99
+ this.retryable = options?.retryable ?? false;
100
+ this.code = options?.code;
101
+ if (Error.captureStackTrace) {
102
+ Error.captureStackTrace(this, _T402PaymentError);
103
+ }
104
+ }
105
+ isRetryable() {
106
+ return this.retryable;
107
+ }
108
+ toJSON() {
109
+ return {
110
+ name: this.name,
111
+ message: this.message,
112
+ phase: this.phase,
113
+ retryable: this.retryable,
114
+ code: this.code,
115
+ cause: this.cause?.message
116
+ };
117
+ }
118
+ };
119
+
88
120
  // src/http/httpFacilitatorClient.ts
89
121
  var DEFAULT_FACILITATOR_URL = "https://facilitator.t402.io";
90
122
  var HTTPFacilitatorClient = class {
@@ -125,7 +157,11 @@ var HTTPFacilitatorClient = class {
125
157
  });
126
158
  if (!response.ok) {
127
159
  const errorText = await response.text().catch(() => response.statusText);
128
- throw new Error(`Facilitator verify failed (${response.status}): ${errorText}`);
160
+ throw new T402PaymentError(`Facilitator verify failed (${response.status}): ${errorText}`, {
161
+ phase: "verification",
162
+ code: response.status,
163
+ retryable: response.status >= 500 || response.status === 429
164
+ });
129
165
  }
130
166
  return await response.json();
131
167
  }
@@ -155,7 +191,11 @@ var HTTPFacilitatorClient = class {
155
191
  });
156
192
  if (!response.ok) {
157
193
  const errorText = await response.text().catch(() => response.statusText);
158
- throw new Error(`Facilitator settle failed (${response.status}): ${errorText}`);
194
+ throw new T402PaymentError(`Facilitator settle failed (${response.status}): ${errorText}`, {
195
+ phase: "settlement",
196
+ code: response.status,
197
+ retryable: response.status >= 500 || response.status === 429
198
+ });
159
199
  }
160
200
  return await response.json();
161
201
  }
@@ -178,7 +218,14 @@ var HTTPFacilitatorClient = class {
178
218
  });
179
219
  if (!response.ok) {
180
220
  const errorText = await response.text().catch(() => response.statusText);
181
- throw new Error(`Facilitator getSupported failed (${response.status}): ${errorText}`);
221
+ throw new T402PaymentError(
222
+ `Facilitator getSupported failed (${response.status}): ${errorText}`,
223
+ {
224
+ phase: "unknown",
225
+ code: response.status,
226
+ retryable: response.status >= 500 || response.status === 429
227
+ }
228
+ );
182
229
  }
183
230
  return await response.json();
184
231
  }
@@ -806,7 +853,8 @@ var SettleResponseSchema = import_zod.z.object({
806
853
  transaction: import_zod.z.string(),
807
854
  network: NetworkSchema,
808
855
  errorReason: import_zod.z.string().optional(),
809
- payer: import_zod.z.string().optional()
856
+ payer: import_zod.z.string().optional(),
857
+ confirmations: import_zod.z.string().optional()
810
858
  });
811
859
  var PaymentRequirementsV1Schema = import_zod.z.object({
812
860
  scheme: import_zod.z.string().min(1),
@@ -1121,12 +1169,12 @@ var t402HTTPResourceServer = class {
1121
1169
  * @returns Decoded payment payload or null
1122
1170
  */
1123
1171
  extractPayment(adapter) {
1124
- const header = adapter.getHeader("payment-signature") || adapter.getHeader("PAYMENT-SIGNATURE");
1172
+ const header = adapter.getHeader("payment-signature") || adapter.getHeader("PAYMENT-SIGNATURE") || adapter.getHeader("x-payment") || adapter.getHeader("X-PAYMENT");
1125
1173
  if (header) {
1126
1174
  try {
1127
1175
  return decodePaymentSignatureHeader(header);
1128
1176
  } catch (error) {
1129
- console.warn("Failed to decode PAYMENT-SIGNATURE header:", error);
1177
+ console.warn("Failed to decode payment header:", error);
1130
1178
  }
1131
1179
  }
1132
1180
  return null;