{"version":3,"sources":["../src/constants.ts","../src/detection.ts"],"sourcesContent":["/**\n * EIP-712 domain name for Circle Gateway batched payments.\n * Used in the `extra.name` field of PaymentRequirements to identify Circle batching options.\n */\nexport const CIRCLE_BATCHING_NAME = 'GatewayWalletBatched';\n\n/**\n * EIP-712 domain version for Circle Gateway batched payments.\n * Used in the `extra.version` field of PaymentRequirements.\n */\nexport const CIRCLE_BATCHING_VERSION = '1';\n\n/**\n * The payment scheme used for Circle batching (same as standard x402 exact scheme).\n */\nexport const CIRCLE_BATCHING_SCHEME = 'exact';\n\n/**\n * Minimum authorization validity window required by Gateway batching.\n */\nexport const GATEWAY_MIN_AUTH_VALIDITY_SECONDS = 7 * 24 * 60 * 60;\n\n/**\n * Extra validity window so authorizations still satisfy Gateway's minimum\n * after client/server clock differences and request latency.\n */\nexport const GATEWAY_AUTH_VALIDITY_BUFFER_SECONDS = 100;\n\n/**\n * Authorization validity window the SDK should publish and sign with.\n */\nexport const GATEWAY_AUTH_VALIDITY_WINDOW_SECONDS =\n  GATEWAY_MIN_AUTH_VALIDITY_SECONDS + GATEWAY_AUTH_VALIDITY_BUFFER_SECONDS;\n","import { CIRCLE_BATCHING_NAME, CIRCLE_BATCHING_VERSION } from './constants';\n\n/**\n * PaymentRequirements-like structure for detection.\n * We only need the `extra` field to detect batching options.\n */\ninterface PaymentRequirementsLike {\n  extra?: Record<string, unknown>;\n}\n\n/**\n * Check if a PaymentRequirements object supports batched settlement.\n *\n * Batching options are identified by:\n * - `extra.name === \"GatewayWalletBatched\"`\n * - `extra.version === \"1\"`\n *\n * @param requirements - The payment requirements to check\n * @returns true if this supports batched settlement\n *\n * @example\n * ```typescript\n * import { supportsBatching } from \"@circle-fin/x402-batching\";\n *\n * if (supportsBatching(paymentRequirements)) {\n *   // This option uses batched settlement (gas-free for users!)\n * }\n * ```\n */\nexport function supportsBatching(requirements: PaymentRequirementsLike): boolean {\n  const extra = requirements.extra;\n  if (!extra) {\n    return false;\n  }\n\n  return extra.name === CIRCLE_BATCHING_NAME && extra.version === CIRCLE_BATCHING_VERSION;\n}\n\n/**\n * Check if a PaymentRequirements object is a batched payment.\n *\n * This is an alias for `supportsBatching`, intended for server-side/facilitator use.\n * Use this to route payments to the appropriate handler.\n *\n * @param requirements - The payment requirements to check\n * @returns true if this is a batched payment\n *\n * @example\n * ```typescript\n * import { isBatchPayment, BatchFacilitatorClient } from \"@circle-fin/x402-batching/server\";\n *\n * const gateway = new BatchFacilitatorClient();\n *\n * // In your facilitator's verify/settle handler:\n * if (isBatchPayment(requirements)) {\n *   return gateway.verify(payload, requirements);\n * }\n * // else: handle with existing on-chain logic\n * ```\n */\nexport const isBatchPayment = supportsBatching;\n\n/**\n * Get the verifyingContract address from batching requirements.\n *\n * @param requirements - The payment requirements\n * @returns The batch wallet contract address, or undefined if not a batching option\n */\nexport function getVerifyingContract(\n  requirements: PaymentRequirementsLike,\n): string | undefined {\n  if (!supportsBatching(requirements)) {\n    return undefined;\n  }\n\n  const verifyingContract = requirements.extra?.verifyingContract;\n  if (typeof verifyingContract === 'string') {\n    return verifyingContract;\n  }\n\n  return undefined;\n}\n"],"mappings":";AAIO,IAAM,uBAAuB;AAM7B,IAAM,0BAA0B;AAKhC,IAAM,yBAAyB;AAK/B,IAAM,oCAAoC,IAAI,KAAK,KAAK;AAMxD,IAAM,uCAAuC;AAK7C,IAAM,uCACX,oCAAoC;;;ACH/B,SAAS,iBAAiB,cAAgD;AAC/E,QAAM,QAAQ,aAAa;AAC3B,MAAI,CAAC,OAAO;AACV,WAAO;AAAA,EACT;AAEA,SAAO,MAAM,SAAS,wBAAwB,MAAM,YAAY;AAClE;AAwBO,IAAM,iBAAiB;AAQvB,SAAS,qBACd,cACoB;AACpB,MAAI,CAAC,iBAAiB,YAAY,GAAG;AACnC,WAAO;AAAA,EACT;AAEA,QAAM,oBAAoB,aAAa,OAAO;AAC9C,MAAI,OAAO,sBAAsB,UAAU;AACzC,WAAO;AAAA,EACT;AAEA,SAAO;AACT;","names":[]}