UNPKG

@payai/x402

Version:

PayAI-distributed wrapper for @x402/core v2

97 lines (95 loc) 3.27 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/types/index.ts var types_exports = {}; __export(types_exports, { FacilitatorResponseError: () => FacilitatorResponseError, SettleError: () => SettleError, VerifyError: () => VerifyError, getFacilitatorResponseError: () => getFacilitatorResponseError }); module.exports = __toCommonJS(types_exports); // src/types/facilitator.ts var VerifyError = class extends Error { /** * Creates a VerifyError from a failed verification response. * * @param statusCode - HTTP status code from the facilitator * @param response - The verify response containing error details */ constructor(statusCode, response) { const reason = response.invalidReason || "unknown reason"; const message = response.invalidMessage; super(message ? `${reason}: ${message}` : reason); this.name = "VerifyError"; this.statusCode = statusCode; this.invalidReason = response.invalidReason; this.invalidMessage = response.invalidMessage; this.payer = response.payer; } }; var SettleError = class extends Error { /** * Creates a SettleError from a failed settlement response. * * @param statusCode - HTTP status code from the facilitator * @param response - The settle response containing error details */ constructor(statusCode, response) { const reason = response.errorReason || "unknown reason"; const message = response.errorMessage; super(message ? `${reason}: ${message}` : reason); this.name = "SettleError"; this.statusCode = statusCode; this.errorReason = response.errorReason; this.errorMessage = response.errorMessage; this.payer = response.payer; this.transaction = response.transaction; this.network = response.network; } }; var FacilitatorResponseError = class extends Error { /** * Creates a FacilitatorResponseError for malformed facilitator responses. * * @param message - The boundary error message */ constructor(message) { super(message); this.name = "FacilitatorResponseError"; } }; function getFacilitatorResponseError(error) { let current = error; while (current instanceof Error) { if (current instanceof FacilitatorResponseError) { return current; } current = current.cause; } return null; } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { FacilitatorResponseError, SettleError, VerifyError, getFacilitatorResponseError }); //# sourceMappingURL=index.js.map