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,MAAM,UAAU,KAAA,CACb,KAAA,CAAM,GAAG,CAAA,CACT,GAAA,CAAI,CAAC,IAAA,KAAS,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,KAAK,IAAI,CAAA,IAAK,EAAE,CAAA,CAAE,CAAA,CAC3C,KAAK,GAAG,CAAA;AACX,EAAA,MAAM,QAAA,GAAW,MAAM,gBAAA,CAAiB,MAAA,EAAQ,OAAO,CAAA;AAEvD,EAAA,OAAO,EAAE,KAAA,EAAO,eAAA,CAAgB,QAAA,EAAU,QAAQ,GAAG,IAAA,EAAK;AAC5D;AAwBA,eAAsB,WAAA,CACpB,QACA,IAAA,EACkB;AAClB,EAAA,MAAM,IAAA,GAAO,iBAAA,CAAkB,IAAA,EAAM,GAAA,IAAO,MAAM,CAAA;AAClD,EAAA,MAAM,EAAA,GAAK,IAAI,eAAA,CAAgB;AAAA,IAC7B,cAAc,MAAA,CAAO,YAAA;AAAA,IACrB,YAAA,EAAc,MAAA,CAAO,MAAA,CAAO,YAAY,CAAA;AAAA,IACxC,kBAAkB,MAAA,CAAO;AAAA,GAC1B,EAAE,QAAA,EAAS;AACZ,EAAA,MAAM,GAAA,GAAM,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,EAAE,CAAA,CAAA;AAEzB,EAAA,MAAM,OAAA,GAAU,IAAA,EAAM,KAAA,IAAS,UAAA,CAAW,KAAA;AAC1C,EAAA,IAAI,CAAC,OAAA,EAAS,MAAM,IAAI,MAAM,gEAAgE,CAAA;AAC9F,EAAA,MAAM,MAAM,MAAM,OAAA,CAAQ,KAAK,EAAE,MAAA,EAAQ,OAAO,CAAA;AAChD,EAAA,OAAO,IAAI,IAAA,EAAK;AAClB","file":"index.cjs","sourcesContent":["/* ------------------------------------------------------------------ *\n * Amount validation\n *\n * eSewa signs `total_amount` but posts the constituent amount fields\n * (`amount`, `tax_amount`, `product_service_charge`, `product_delivery_charge`)\n * alongside it. If they don't add up — or a field is negative or non-numeric —\n * eSewa rejects the form (or, worse, the numbers silently disagree with what you\n * signed). `validateAmounts` catches that BEFORE you build the form, purely and\n * offline. It is deliberately NOT called by `buildForm` so existing behaviour is\n * unchanged; call it yourself when you want the guard.\n * ------------------------------------------------------------------ */\n\n/** The amount fields eSewa expects, all in **rupees** (not paisa). */\nexport interface AmountFields {\n  /** Base product amount. */\n  amount: number;\n  /** Tax amount. Default 0. */\n  taxAmount?: number;\n  /** Product service charge. Default 0. */\n  productServiceCharge?: number;\n  /** Product delivery charge. Default 0. */\n  productDeliveryCharge?: number;\n  /**\n   * Grand total. If omitted, no equality check is performed and only the\n   * component fields are range-checked (mirrors `buildForm`, which derives the\n   * total when it isn't given).\n   */\n  totalAmount?: number;\n}\n\n/** Result of {@link validateAmounts}. */\nexport interface AmountValidation {\n  ok: boolean;\n  /** Human-readable reason when `ok` is `false`. */\n  reason?: string;\n}\n\n/** A finite, non-negative number (NaN/Infinity/negatives rejected). */\nfunction isNonNegNumber(v: number): boolean {\n  return typeof v === \"number\" && Number.isFinite(v) && v >= 0;\n}\n\n/**\n * Validate that the eSewa amount fields are internally consistent: every\n * component is a finite non-negative number, and — when `totalAmount` is given —\n * `amount + taxAmount + productServiceCharge + productDeliveryCharge` equals it.\n * Pure, offline, never throws.\n *\n * A tiny epsilon (1e-6) absorbs binary floating-point drift (e.g. `0.1 + 0.2`).\n *\n * @example\n * validateAmounts({ amount: 100, taxAmount: 13, totalAmount: 113 }); // { ok: true }\n * validateAmounts({ amount: 100, taxAmount: 13, totalAmount: 120 });\n * // { ok: false, reason: \"total_amount 120 ≠ amount+tax+service+delivery (113)\" }\n */\nexport function validateAmounts(fields: AmountFields): AmountValidation {\n  const amount = fields.amount;\n  const tax = fields.taxAmount ?? 0;\n  const service = fields.productServiceCharge ?? 0;\n  const delivery = fields.productDeliveryCharge ?? 0;\n\n  const named: Array<[string, number]> = [\n    [\"amount\", amount],\n    [\"tax_amount\", tax],\n    [\"product_service_charge\", service],\n    [\"product_delivery_charge\", delivery],\n  ];\n  for (const [name, value] of named) {\n    if (!isNonNegNumber(value)) {\n      return { ok: false, reason: `${name} must be a finite non-negative number (got ${String(value)})` };\n    }\n  }\n\n  if (fields.totalAmount !== undefined) {\n    if (!isNonNegNumber(fields.totalAmount)) {\n      return { ok: false, reason: `total_amount must be a finite non-negative number (got ${String(fields.totalAmount)})` };\n    }\n    const sum = amount + tax + service + delivery;\n    if (Math.abs(sum - fields.totalAmount) > 1e-6) {\n      return {\n        ok: false,\n        reason: `total_amount ${fields.totalAmount} ≠ amount+tax+service+delivery (${sum})`,\n      };\n    }\n  }\n\n  return { ok: true };\n}\n","/* ------------------------------------------------------------------ *\n * Transaction UUID helper\n *\n * eSewa's `transaction_uuid` must be unique per attempt and stick to a safe\n * charset (letters, digits and hyphens — anything URL/form-unsafe risks a\n * signature mismatch or a rejected form). `generateTransactionUuid` mints one\n * with a CSPRNG (Web Crypto `getRandomValues`), no dependency, isomorphic.\n * ------------------------------------------------------------------ */\n\n/** Allowed characters for an eSewa `transaction_uuid` (unreserved, sign-safe). */\nconst UUID_ALPHABET = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\";\n\n/**\n * `true` if `uuid` is a well-formed eSewa `transaction_uuid`: 1–64 chars, only\n * ASCII letters, digits and single hyphens (not leading/trailing/doubled). Pure.\n */\nexport function isValidTransactionUuid(uuid: string): boolean {\n  return typeof uuid === \"string\" && /^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/.test(uuid) && uuid.length <= 64;\n}\n\n/**\n * Generate a valid, unique eSewa `transaction_uuid` using the platform CSPRNG.\n * The result is `[A-Za-z0-9]` with an optional caller `prefix` joined by a\n * hyphen, and always passes {@link isValidTransactionUuid}.\n *\n * @param opts.length   number of random chars (default 20, clamped to 1–63).\n * @param opts.prefix   optional prefix (e.g. an order id); stripped to the safe\n *                      charset. The final length still respects the 64-char cap.\n *\n * @example\n * generateTransactionUuid();               // \"k3Zq9RtA1bVn7cPmLxQw\"\n * generateTransactionUuid({ prefix: \"240\" }); // \"240-Xq7…\"\n */\nexport function generateTransactionUuid(opts?: { length?: number; prefix?: string }): string {\n  const getRandom = globalThis.crypto?.getRandomValues?.bind(globalThis.crypto);\n  if (!getRandom) {\n    throw new Error(\"@lacspace/esewa: Web Crypto (globalThis.crypto.getRandomValues) is unavailable in this runtime.\");\n  }\n\n  const rawPrefix = (opts?.prefix ?? \"\").replace(/[^A-Za-z0-9]/g, \"\");\n  const reserved = rawPrefix ? rawPrefix.length + 1 : 0; // +1 for the hyphen\n  const want = opts?.length ?? 20;\n  const length = Math.max(1, Math.min(want, 63 - reserved));\n\n  const bytes = new Uint8Array(length);\n  getRandom(bytes);\n  let random = \"\";\n  for (let i = 0; i < length; i++) {\n    random += UUID_ALPHABET[bytes[i]! % UUID_ALPHABET.length];\n  }\n\n  return rawPrefix ? `${rawPrefix}-${random}` : random;\n}\n","/* ------------------------------------------------------------------ *\n * Transaction status — pure request builder + response parser\n *\n * `checkStatus` (in index) performs the network GET. These helpers are the pure\n * halves for callers who fetch themselves (edge caches, retries, logging, tests):\n *   - `buildStatusRequest` — the exact URL + query params, no I/O.\n *   - `parseStatusResponse` — narrow the untyped JSON into a typed shape.\n * ------------------------------------------------------------------ */\n\nimport type { EsewaEnv } from \"./index\";\nimport { ESEWA_STATUS_URLS } from \"./index\";\n\n/** The status values eSewa's transaction-status API can return. */\nexport type EsewaStatus =\n  | \"COMPLETE\"\n  | \"PENDING\"\n  | \"FULL_REFUND\"\n  | \"PARTIAL_REFUND\"\n  | \"AMBIGUOUS\"\n  | \"NOT_FOUND\"\n  | \"CANCELED\"\n  | \"ERROR\";\n\n/** Params for a transaction-status lookup. */\nexport interface StatusRequestParams {\n  product_code: string;\n  total_amount: string | number;\n  transaction_uuid: string;\n}\n\n/** A fully-built status request, ready to hand to any `fetch`. */\nexport interface StatusRequest {\n  url: string;\n  method: \"GET\";\n  /** The query params, pre-stringified, in eSewa's order. */\n  params: Record<string, string>;\n}\n\n/**\n * Build the eSewa transaction-status-check request purely — the status endpoint\n * URL with `product_code`, `total_amount` and `transaction_uuid` as query\n * params. No network. Feed `request.url` to your own `fetch`/cache.\n *\n * @example\n * const { url } = buildStatusRequest(\n *   { product_code: \"EPAYTEST\", total_amount: 100, transaction_uuid: \"tx-1\" },\n *   { env: \"test\" },\n * );\n */\nexport function buildStatusRequest(\n  params: StatusRequestParams,\n  opts?: { env?: EsewaEnv },\n): StatusRequest {\n  const fields: Record<string, string> = {\n    product_code: params.product_code,\n    total_amount: String(params.total_amount),\n    transaction_uuid: params.transaction_uuid,\n  };\n  const qs = new URLSearchParams(fields).toString();\n  return {\n    url: `${ESEWA_STATUS_URLS[opts?.env ?? \"test\"]}?${qs}`,\n    method: \"GET\",\n    params: fields,\n  };\n}\n\n/** The parsed, typed shape of an eSewa transaction-status response. */\nexport interface StatusResponse {\n  product_code?: string;\n  transaction_uuid?: string;\n  total_amount?: number;\n  /** Normalised to an {@link EsewaStatus} when recognised, else the raw string. */\n  status: EsewaStatus | string;\n  /** eSewa reference id (present once settled). */\n  ref_id?: string;\n  /** The original, untouched payload. */\n  raw: Record<string, unknown>;\n}\n\nconst KNOWN_STATUSES: ReadonlySet<string> = new Set<EsewaStatus>([\n  \"COMPLETE\",\n  \"PENDING\",\n  \"FULL_REFUND\",\n  \"PARTIAL_REFUND\",\n  \"AMBIGUOUS\",\n  \"NOT_FOUND\",\n  \"CANCELED\",\n  \"ERROR\",\n]);\n\n/** `true` if `status` is one of eSewa's documented status values. */\nexport function isEsewaStatus(status: unknown): status is EsewaStatus {\n  return typeof status === \"string\" && KNOWN_STATUSES.has(status);\n}\n\n/**\n * Parse/narrow the untyped JSON returned by the status API (or `checkStatus`)\n * into a typed {@link StatusResponse}. Tolerant: unknown/missing `status`\n * becomes `\"ERROR\"`, `total_amount` is coerced to a number when it parses, and\n * the original payload is preserved on `.raw`. Pure, never throws.\n *\n * @example\n * const parsed = parseStatusResponse(await res.json());\n * if (parsed.status === \"COMPLETE\") fulfilOrder(parsed.transaction_uuid!);\n */\nexport function parseStatusResponse(input: unknown): StatusResponse {\n  const raw = (input && typeof input === \"object\" ? input : {}) as Record<string, unknown>;\n  const rawStatus = raw.status;\n  const status: EsewaStatus | string = isEsewaStatus(rawStatus)\n    ? rawStatus\n    : typeof rawStatus === \"string\"\n      ? rawStatus\n      : \"ERROR\";\n\n  const out: StatusResponse = { status, raw };\n  if (typeof raw.product_code === \"string\") out.product_code = raw.product_code;\n  if (typeof raw.transaction_uuid === \"string\") out.transaction_uuid = raw.transaction_uuid;\n  if (typeof raw.ref_id === \"string\") out.ref_id = raw.ref_id;\n\n  if (typeof raw.total_amount === \"number\" && Number.isFinite(raw.total_amount)) {\n    out.total_amount = raw.total_amount;\n  } else if (typeof raw.total_amount === \"string\") {\n    const n = Number(raw.total_amount.replace(/,/g, \"\"));\n    if (Number.isFinite(n)) out.total_amount = n;\n  }\n\n  return out;\n}\n","/* ------------------------------------------------------------------ *\n * Typed success-response decode + verify (composition over the existing verify)\n *\n * eSewa posts back a base64 JSON `data` blob on the success redirect. `index`\n * already exposes `verifyResponse(base64, secret)` which decodes AND checks the\n * signature — this module adds the two things it deliberately does NOT change:\n *   - `decodeResponse` — decode-only, into a typed object (no signature check).\n *   - `verifyDecodedResponse` — COMPOSES the existing `verifyResponse` and\n *     returns the same result with the payload narrowed to `EsewaSuccessData`.\n * The existing `verifyResponse` is untouched and still the source of truth.\n * ------------------------------------------------------------------ */\n\nimport { verifyResponse } from \"./index\";\nimport type { EsewaStatus } from \"./status\";\n\n/** The typed shape of the decoded eSewa success `data` payload. */\nexport interface EsewaSuccessData {\n  transaction_code?: string;\n  status?: EsewaStatus | string;\n  total_amount?: string;\n  transaction_uuid?: string;\n  product_code?: string;\n  signed_field_names?: string;\n  signature?: string;\n  /** Any other fields eSewa includes. */\n  [key: string]: unknown;\n}\n\nconst B64_LOOKUP = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n\n/** Standard base64 decode to raw bytes (mirrors index's internal decoder). */\nfunction decodeBase64(b64: string): Uint8Array {\n  const clean = b64.replace(/[^A-Za-z0-9+/]/g, \"\");\n  const len = Math.floor((clean.length * 3) / 4);\n  const bytes = new Uint8Array(len);\n  let p = 0;\n  for (let i = 0; i < clean.length; i += 4) {\n    const c0 = B64_LOOKUP.indexOf(clean[i]!);\n    const c1 = B64_LOOKUP.indexOf(clean[i + 1]!);\n    const c2 = i + 2 < clean.length ? B64_LOOKUP.indexOf(clean[i + 2]!) : -1;\n    const c3 = i + 3 < clean.length ? B64_LOOKUP.indexOf(clean[i + 3]!) : -1;\n    if (p < len) bytes[p++] = (c0 << 2) | (c1 >> 4);\n    if (c2 >= 0 && p < len) bytes[p++] = ((c1 & 15) << 4) | (c2 >> 2);\n    if (c3 >= 0 && p < len) bytes[p++] = ((c2 & 3) << 6) | c3;\n  }\n  return bytes;\n}\n\n/**\n * Decode the base64 `data` payload eSewa posts to your success URL into a typed\n * {@link EsewaSuccessData} — WITHOUT checking the signature. Returns `null` when\n * the blob isn't valid base64 JSON. Pure, never throws.\n *\n * Use this only to read fields; to trust them, use {@link verifyDecodedResponse}\n * or the existing `verifyResponse`.\n *\n * @example\n * const data = decodeResponse(url.searchParams.get(\"data\")!);\n * console.log(data?.status, data?.transaction_uuid); // untrusted until verified\n */\nexport function decodeResponse(base64Data: string): EsewaSuccessData | null {\n  try {\n    const json = new TextDecoder().decode(decodeBase64(base64Data));\n    const parsed = JSON.parse(json) as unknown;\n    if (!parsed || typeof parsed !== \"object\" || Array.isArray(parsed)) return null;\n    return parsed as EsewaSuccessData;\n  } catch {\n    return null;\n  }\n}\n\n/** Result of {@link verifyDecodedResponse}. */\nexport interface VerifyDecodedResult {\n  valid: boolean;\n  /** The decoded payload, typed as {@link EsewaSuccessData}. */\n  data: EsewaSuccessData;\n}\n\n/**\n * Decode the base64 success payload into a typed object AND verify it, by\n * COMPOSING the existing `verifyResponse` (the signature logic is unchanged —\n * this only narrows the returned `data` type). Never throws.\n *\n * @example\n * const { valid, data } = await verifyDecodedResponse(rawData, secret);\n * if (valid && data.status === \"COMPLETE\") fulfilOrder(data.transaction_uuid!);\n */\nexport async function verifyDecodedResponse(\n  base64Data: string,\n  secret: string,\n): Promise<VerifyDecodedResult> {\n  const { valid, data } = await verifyResponse(base64Data, secret);\n  return { valid, data: data as EsewaSuccessData };\n}\n","/**\n * @lacspace/esewa\n *\n * eSewa ePay v2 (Nepal) — the correct, tiny way to integrate Nepal's most-used\n * payment gateway. Handles the three things every integration re-implements:\n *\n *   1. **Signing** — the HMAC-SHA256 signature eSewa requires on the checkout\n *      form, computed over `total_amount,transaction_uuid,product_code` in the\n *      exact order of `signed_field_names`, base64-encoded.\n *   2. **Form building** — a ready-to-POST `{ action, method, fields }` object\n *      with every field eSewa expects, including a valid `signature`.\n *   3. **Verification & status** — decode and verify the signed base64 `data`\n *      payload eSewa returns on success (timing-safe), and query the\n *      transaction-status API.\n *\n * Built on Web Crypto (`globalThis.crypto.subtle`) — never hand-rolled\n * cryptography. Isomorphic: Node 20+, edge runtimes and browsers. Zero deps.\n */\n\n/* ------------------------------------------------------------------ *\n * Endpoints & test credentials\n * ------------------------------------------------------------------ */\n\nexport type EsewaEnv = \"test\" | \"prod\";\n\n/** eSewa checkout form endpoints (the URL you POST the form to). */\nexport const ESEWA_FORM_URLS: Record<EsewaEnv, string> = {\n  test: \"https://rc-epay.esewa.com.np/api/epay/main/v2/form\",\n  prod: \"https://epay.esewa.com.np/api/epay/main/v2/form\",\n};\n\n/** eSewa transaction-status API endpoints. */\nexport const ESEWA_STATUS_URLS: Record<EsewaEnv, string> = {\n  test: \"https://rc.esewa.com.np/api/epay/transaction/status/\",\n  prod: \"https://epay.esewa.com.np/api/epay/transaction/status/\",\n};\n\n/** eSewa-published sandbox secret key (test environment only). */\nexport const ESEWA_TEST_SECRET = \"8gBm/:&EnhH.1/q@K@\";\n\n/** eSewa-published sandbox merchant/product code (test environment only). */\nexport const ESEWA_TEST_PRODUCT_CODE = \"EPAYTEST\";\n\n/** The fields eSewa signs, in the required order. */\nexport const ESEWA_SIGNED_FIELD_NAMES = \"total_amount,transaction_uuid,product_code\";\n\n/* ------------------------------------------------------------------ *\n * Web Crypto + base64 helpers (isomorphic, zero-dependency)\n * ------------------------------------------------------------------ */\n\nconst enc = new TextEncoder();\nconst B64 = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n\n/** Standard base64 (NOT url-safe) encode of raw bytes. */\nfunction toBase64(bytes: Uint8Array): string {\n  let out = \"\";\n  for (let i = 0; i < bytes.length; i += 3) {\n    const b0 = bytes[i]!;\n    const b1 = i + 1 < bytes.length ? bytes[i + 1]! : 0;\n    const b2 = i + 2 < bytes.length ? bytes[i + 2]! : 0;\n    out += B64[b0 >> 2];\n    out += B64[((b0 & 3) << 4) | (b1 >> 4)];\n    out += i + 1 < bytes.length ? B64[((b1 & 15) << 2) | (b2 >> 6)] : \"=\";\n    out += i + 2 < bytes.length ? B64[b2 & 63] : \"=\";\n  }\n  return out;\n}\n\n/** Standard base64 decode to raw bytes. */\nfunction fromBase64(b64: string): Uint8Array {\n  const clean = b64.replace(/[^A-Za-z0-9+/]/g, \"\");\n  const len = Math.floor((clean.length * 3) / 4);\n  const bytes = new Uint8Array(len);\n  let p = 0;\n  for (let i = 0; i < clean.length; i += 4) {\n    const c0 = B64.indexOf(clean[i]!);\n    const c1 = B64.indexOf(clean[i + 1]!);\n    const c2 = i + 2 < clean.length ? B64.indexOf(clean[i + 2]!) : -1;\n    const c3 = i + 3 < clean.length ? B64.indexOf(clean[i + 3]!) : -1;\n    if (p < len) bytes[p++] = (c0 << 2) | (c1 >> 4);\n    if (c2 >= 0 && p < len) bytes[p++] = ((c1 & 15) << 4) | (c2 >> 2);\n    if (c3 >= 0 && p < len) bytes[p++] = ((c2 & 3) << 6) | c3;\n  }\n  return bytes;\n}\n\n/** HMAC-SHA256 over `message` with `secret`, returned as standard base64. */\nasync function hmacSha256Base64(secret: string, message: string): Promise<string> {\n  const subtle = globalThis.crypto?.subtle;\n  if (!subtle) throw new Error(\"@lacspace/esewa: Web Crypto (globalThis.crypto.subtle) is unavailable in this runtime.\");\n  const key = await subtle.importKey(\n    \"raw\",\n    enc.encode(secret),\n    { name: \"HMAC\", hash: \"SHA-256\" },\n    false,\n    [\"sign\"],\n  );\n  const sig = await subtle.sign(\"HMAC\", key, enc.encode(message));\n  return toBase64(new Uint8Array(sig));\n}\n\n/** Constant-time comparison of two strings (avoids signature-timing leaks). */\nfunction timingSafeEqual(a: string, b: string): boolean {\n  const ab = enc.encode(a);\n  const bb = enc.encode(b);\n  // Compare a fixed number of bytes; length mismatch still fails.\n  let diff = ab.length ^ bb.length;\n  const n = Math.max(ab.length, bb.length);\n  for (let i = 0; i < n; i++) diff |= (ab[i] ?? 0) ^ (bb[i] ?? 0);\n  return diff === 0;\n}\n\n/* ------------------------------------------------------------------ *\n * Signing\n * ------------------------------------------------------------------ */\n\nexport interface SignFields {\n  total_amount: string | number;\n  transaction_uuid: string;\n  product_code: string;\n}\n\n/**\n * Compute the eSewa signature for the required signed fields. The message is\n * `total_amount=<v>,transaction_uuid=<v>,product_code=<v>` (the exact order of\n * `signed_field_names`), HMAC-SHA256'd with the merchant secret and returned as\n * standard base64.\n *\n * @example\n * const sig = await signPayment(\n *   { total_amount: 100, transaction_uuid: \"11-201\", product_code: \"EPAYTEST\" },\n *   ESEWA_TEST_SECRET,\n * );\n */\nexport async function signPayment(fields: SignFields, secret: string): Promise<string> {\n  const message =\n    `total_amount=${fields.total_amount},` +\n    `transaction_uuid=${fields.transaction_uuid},` +\n    `product_code=${fields.product_code}`;\n  return hmacSha256Base64(secret, message);\n}\n\n/* ------------------------------------------------------------------ *\n * Form building\n * ------------------------------------------------------------------ */\n\n/**\n * Convert integer paisa (minor units — as used across the @lacspace commerce\n * packages: cart, order, tax, invoice, money…) to rupees for eSewa's amount\n * fields. `paisaToRupees(12345)` → `123.45`.\n *\n * eSewa expects amounts in **rupees**, while the rest of the suite stores\n * **paisa** — convert at this boundary so a Rs 123.45 order isn't charged as\n * Rs 12,345.\n */\nexport function paisaToRupees(paisa: number): number {\n  return Math.round(paisa) / 100;\n}\n\nexport interface BuildFormInput {\n  /**\n   * Base product amount, **in rupees** — eSewa's unit, NOT paisa. If you keep\n   * integer minor units (paisa) like the other @lacspace commerce packages,\n   * convert here with `paisaToRupees(paisa)`. Passing paisa overcharges 100×.\n   */\n  amount: number;\n  /** Tax amount, in rupees (see `amount`). Default 0. */\n  taxAmount?: number;\n  /** Grand total, in rupees (see `amount`). Defaults to amount + tax + service + delivery. */\n  totalAmount?: number;\n  /** Unique transaction id you generate. */\n  transactionUuid: string;\n  /** Merchant product code (e.g. \"EPAYTEST\" in test). */\n  productCode: string;\n  /** Where eSewa redirects on success. */\n  successUrl: string;\n  /** Where eSewa redirects on failure. */\n  failureUrl: string;\n  /** Product service charge. Default 0. */\n  productServiceCharge?: number;\n  /** Product delivery charge. Default 0. */\n  productDeliveryCharge?: number;\n}\n\nexport interface EsewaForm {\n  /** URL to POST the form to. */\n  action: string;\n  method: \"POST\";\n  /** All fields eSewa expects, as strings ready for form inputs. */\n  fields: Record<string, string>;\n}\n\n/**\n * Build a ready-to-POST eSewa checkout form: `{ action, method, fields }`. The\n * `total_amount` defaults to `amount + taxAmount + serviceCharge + deliveryCharge`,\n * and a valid `signature` is computed for you.\n *\n * @example\n * const form = await buildForm(\n *   { amount: 100, transactionUuid: \"11-201\", productCode: ESEWA_TEST_PRODUCT_CODE,\n *     successUrl: \"https://me/ok\", failureUrl: \"https://me/fail\" },\n *   { secret: ESEWA_TEST_SECRET, env: \"test\" },\n * );\n * // render form.fields as hidden inputs and auto-submit to form.action\n */\nexport async function buildForm(\n  input: BuildFormInput,\n  opts: { secret: string; env?: EsewaEnv },\n): Promise<EsewaForm> {\n  const tax = input.taxAmount ?? 0;\n  const service = input.productServiceCharge ?? 0;\n  const delivery = input.productDeliveryCharge ?? 0;\n  const total = input.totalAmount ?? input.amount + tax + service + delivery;\n\n  const signature = await signPayment(\n    {\n      total_amount: total,\n      transaction_uuid: input.transactionUuid,\n      product_code: input.productCode,\n    },\n    opts.secret,\n  );\n\n  const fields: Record<string, string> = {\n    amount: String(input.amount),\n    tax_amount: String(tax),\n    total_amount: String(total),\n    transaction_uuid: input.transactionUuid,\n    product_code: input.productCode,\n    product_service_charge: String(service),\n    product_delivery_charge: String(delivery),\n    success_url: input.successUrl,\n    failure_url: input.failureUrl,\n    signed_field_names: ESEWA_SIGNED_FIELD_NAMES,\n    signature,\n  };\n\n  return { action: ESEWA_FORM_URLS[opts.env ?? \"test\"], method: \"POST\", fields };\n}\n\n/* ------------------------------------------------------------------ *\n * Response verification\n * ------------------------------------------------------------------ */\n\nexport interface VerifyResult {\n  valid: boolean;\n  /** The decoded response fields. */\n  data: Record<string, unknown>;\n}\n\n/**\n * Verify the signed base64 `data` payload eSewa appends to the success redirect.\n * Decodes the JSON, recomputes the signature over the fields named in its own\n * `signed_field_names`, and compares (timing-safe) against its `signature`.\n * Never throws — returns `{ valid, data }`.\n *\n * @example\n * const { valid, data } = await verifyResponse(url.searchParams.get(\"data\")!, secret);\n * if (valid && data.status === \"COMPLETE\") fulfilOrder(data.transaction_uuid);\n */\nexport async function verifyResponse(base64Data: string, secret: string): Promise<VerifyResult> {\n  let data: Record<string, unknown>;\n  try {\n    data = JSON.parse(new TextDecoder().decode(fromBase64(base64Data))) as Record<string, unknown>;\n  } catch {\n    return { valid: false, data: {} };\n  }\n\n  const names = typeof data.signed_field_names === \"string\" ? data.signed_field_names : \"\";\n  const provided = typeof data.signature === \"string\" ? data.signature : \"\";\n  if (!names || !provided) return { valid: false, data };\n\n  const message = names\n    .split(\",\")\n    .map((name) => `${name}=${data[name] ?? \"\"}`)\n    .join(\",\");\n  const expected = await hmacSha256Base64(secret, message);\n\n  return { valid: timingSafeEqual(expected, provided), data };\n}\n\n/* ------------------------------------------------------------------ *\n * Transaction status\n * ------------------------------------------------------------------ */\n\nexport interface StatusParams {\n  product_code: string;\n  total_amount: string | number;\n  transaction_uuid: string;\n}\n\n/**\n * Query the eSewa transaction-status API. GETs the status endpoint with\n * `product_code`, `total_amount` and `transaction_uuid` as query params and\n * returns the parsed JSON. Inject a custom `fetch` for tests or non-global\n * runtimes.\n *\n * @example\n * const status = await checkStatus(\n *   { product_code: \"EPAYTEST\", total_amount: 100, transaction_uuid: \"11-201\" },\n *   { env: \"test\" },\n * );\n */\nexport async function checkStatus(\n  params: StatusParams,\n  opts?: { env?: EsewaEnv; fetch?: typeof fetch },\n): Promise<unknown> {\n  const base = ESEWA_STATUS_URLS[opts?.env ?? \"test\"];\n  const qs = new URLSearchParams({\n    product_code: params.product_code,\n    total_amount: String(params.total_amount),\n    transaction_uuid: params.transaction_uuid,\n  }).toString();\n  const url = `${base}?${qs}`;\n\n  const doFetch = opts?.fetch ?? globalThis.fetch;\n  if (!doFetch) throw new Error(\"@lacspace/esewa: global fetch is unavailable; pass opts.fetch.\");\n  const res = await doFetch(url, { method: \"GET\" });\n  return res.json();\n}\n\n/* ------------------------------------------------------------------ *\n * New in 1.2.0 — additive, backward-compatible helpers.\n * Everything above is unchanged; the modules below only ADD API.\n * ------------------------------------------------------------------ */\n\n// Amount validation — verify amount+tax+service+delivery === total_amount.\nexport { validateAmounts } from \"./amounts\";\nexport type { AmountFields, AmountValidation } from \"./amounts\";\n\n// transaction_uuid generation/validation via CSPRNG.\nexport { generateTransactionUuid, isValidTransactionUuid } from \"./uuid\";\n\n// Pure status-request builder + typed status-response parser.\nexport { buildStatusRequest, parseStatusResponse, isEsewaStatus } from \"./status\";\nexport type { EsewaStatus, StatusRequest, StatusRequestParams, StatusResponse } from \"./status\";\n\n// Typed success-response decode + verify (composes verifyResponse).\nexport { decodeResponse, verifyDecodedResponse } from \"./response\";\nexport type { EsewaSuccessData, VerifyDecodedResult } from \"./response\";\n"]}