@asteby/storefront-react 0.24.0 → 0.26.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.
- package/README.md +35 -2
- package/dist/account-server.cjs +128 -19
- package/dist/account-server.cjs.map +1 -1
- package/dist/account-server.d.cts +67 -4
- package/dist/account-server.d.ts +67 -4
- package/dist/account-server.js +125 -20
- package/dist/account-server.js.map +1 -1
- package/dist/account.cjs +261 -8
- package/dist/account.cjs.map +1 -1
- package/dist/account.css +99 -0
- package/dist/account.d.cts +132 -6
- package/dist/account.d.ts +132 -6
- package/dist/account.js +255 -9
- package/dist/account.js.map +1 -1
- package/dist/checkout.cjs +162 -8
- package/dist/checkout.cjs.map +1 -1
- package/dist/checkout.d.cts +104 -4
- package/dist/checkout.d.ts +104 -4
- package/dist/checkout.js +158 -10
- package/dist/checkout.js.map +1 -1
- package/dist/chunk-Z4C4LKXF.js +25 -0
- package/dist/chunk-Z4C4LKXF.js.map +1 -0
- package/dist/fit-key-B9sYQVwG.d.cts +49 -0
- package/dist/fit-key-B9sYQVwG.d.ts +49 -0
- package/dist/fitment.cjs +54 -9
- package/dist/fitment.cjs.map +1 -1
- package/dist/fitment.d.cts +20 -2
- package/dist/fitment.d.ts +20 -2
- package/dist/fitment.js +54 -10
- package/dist/fitment.js.map +1 -1
- package/dist/settings-types-jxFQFFqP.d.cts +77 -0
- package/dist/settings-types-jxFQFFqP.d.ts +77 -0
- package/dist/subjects-server.cjs +248 -0
- package/dist/subjects-server.cjs.map +1 -0
- package/dist/subjects-server.d.cts +130 -0
- package/dist/subjects-server.d.ts +130 -0
- package/dist/subjects-server.js +217 -0
- package/dist/subjects-server.js.map +1 -0
- package/dist/subjects.cjs +501 -0
- package/dist/subjects.cjs.map +1 -0
- package/dist/subjects.css +166 -0
- package/dist/subjects.d.cts +178 -0
- package/dist/subjects.d.ts +178 -0
- package/dist/subjects.js +465 -0
- package/dist/subjects.js.map +1 -0
- package/package.json +23 -2
- package/dist/types-D7pVK0GK.d.cts +0 -39
- package/dist/types-D7pVK0GK.d.ts +0 -39
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/account/voucher.ts","../src/account/voucher-document.ts","../src/account/server.ts"],"names":["repairPath","isStorefrontError","text","storefront","invoiceFileBytes","safeInvoiceFilename","renderVoucherDocument"],"mappings":";;;;;;;;;;;;;;;AAoBA,SAAS,KAAK,CAAA,EAA2B;AACvC,EAAA,IAAI,OAAO,MAAM,QAAA,IAAY,MAAA,CAAO,SAAS,CAAC,CAAA,EAAG,OAAO,MAAA,CAAO,CAAC,CAAA;AAChE,EAAA,IAAI,OAAO,CAAA,KAAM,QAAA,EAAU,OAAO,IAAA;AAClC,EAAA,MAAM,IAAI,CAAA,CAAE,IAAA,EAAK,CAAE,KAAA,CAAM,GAAG,GAAG,CAAA;AAC/B,EAAA,OAAO,CAAA,IAAK,IAAA;AACd;AAEA,SAAS,QAAQ,CAAA,EAA0B;AACzC,EAAA,IAAI,CAAC,CAAA,IAAK,OAAO,CAAA,KAAM,UAAU,OAAO,IAAA;AACxC,EAAA,MAAM,CAAA,GAAI,CAAA;AACV,EAAA,MAAM,MAAA,GAAS,IAAA,CAAK,CAAA,CAAE,MAAM,CAAA;AAC5B,EAAA,MAAM,GAAA,GAAM,IAAA,CAAK,CAAA,CAAE,aAAa,CAAA;AAChC,EAAA,OAAO,MAAA,IAAU,GAAA,IAAO,MAAA,CAAO,QAAA,CAAS,OAAO,MAAM,CAAC,CAAA,GAAI,EAAE,MAAA,EAAQ,aAAA,EAAe,GAAA,CAAI,WAAA,IAAc,GAAI,IAAA;AAC3G;AAGO,SAAS,UAAU,CAAA,EAAoG;AAC5H,EAAA,MAAM,MAAM,CAAA,EAAG,OAAA;AACf,EAAA,IAAI,CAAC,GAAA,IAAO,OAAO,GAAA,KAAQ,UAAU,OAAO,IAAA;AAC5C,EAAA,MAAM,CAAA,GAAiB;AAAA,IACrB,MAAA,EAAQ,IAAA,CAAK,GA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MACxB,MAAA,EAAQ,GAAA;AAAA,MACR,OAAA,EAAS;AAAA,QACP,cAAA,EAAgB,0BAAA;AAAA,QAChB,GAAG,cAAA;AAAA;AAAA,QAEH,2BAA2B,CAAA,yEAAA,EAA4E,QAAA,GAAW,QAAA,GAAW,CAAA,OAAA,EAAU,KAAK,CAAA,CAAA,CAAG,CAAA,6DAAA,CAAA;AAAA,QAC/I,GAAI,WAAW,EAAE,qBAAA,EAAuB,uCAAuC,MAAM,CAAA,MAAA,CAAA,KAAa;AAAC;AACrG,KACD,CAAA;AAAA,EACH,SAAS,GAAA,EAAK;AACZ,IAAA,OAAO,gBAAgB,GAAG,CAAA;AAAA,EAC5B;AACF","file":"account-server.cjs","sourcesContent":["/**\n * Pure pieces of the cash voucher (OXXO, SPEI, deposit): the normalized `VoucherView` of a `PendingPayment` and the\n * Code 128 barcode (the one cashiers' readers scan). No React, no DOM: the same code draws the barcode in the page\n * (`<Barcode>`) and in the printable document (`voucher-document.ts`, loaded only when the buyer prints).\n */\nimport type { Money, PendingPayment } from '@asteby/storefront'\n\nexport type VoucherView = {\n /** `oxxo`, `spei`, ... as the gateway publishes it. */\n method: string | null\n reference: string | null\n barcode: string | null\n clabe: string | null\n expires_at: string | null\n amount: Money | null\n instructions: string | null\n}\n\nconst MAX = 256\n\nfunction text(v: unknown): string | null {\n if (typeof v === 'number' && Number.isFinite(v)) return String(v)\n if (typeof v !== 'string') return null\n const s = v.trim().slice(0, MAX)\n return s || null\n}\n\nfunction moneyOf(v: unknown): Money | null {\n if (!v || typeof v !== 'object') return null\n const m = v as Record<string, unknown>\n const amount = text(m.amount)\n const cur = text(m.currency_code)\n return amount && cur && Number.isFinite(Number(amount)) ? { amount, currency_code: cur.toUpperCase() } : null\n}\n\n/** The voucher of a pending payment; `null` when it has neither reference, barcode nor CLABE (nothing to pay with). */\nexport function voucherOf(p: Pick<PendingPayment, 'payment' | 'total' | 'expires_at'> | null | undefined): VoucherView | null {\n const pay = p?.payment\n if (!pay || typeof pay !== 'object') return null\n const v: VoucherView = {\n method: text(pay.method ?? pay.provider),\n reference: text(pay.reference),\n barcode: text(pay.barcode),\n clabe: text(pay.clabe),\n expires_at: text(pay.expires_at) ?? text(p?.expires_at),\n amount: moneyOf(pay.amount) ?? moneyOf(p?.total),\n instructions: text(pay.instructions),\n }\n return v.reference || v.barcode || v.clabe ? v : null\n}\n\n/** The value the barcode encodes: the gateway's `barcode`, else the reference of an OXXO voucher. */\nexport function barcodeValue(v: Pick<VoucherView, 'barcode' | 'method' | 'reference'>): string | null {\n return v.barcode ?? (v.method?.toLowerCase() === 'oxxo' ? v.reference : null)\n}\n\n// 11-module patterns of symbols 0..105 and the 13-module stop (ISO/IEC 15417).\nconst BARS = [\n '11011001100', '11001101100', '11001100110', '10010011000', '10010001100', '10001001100', '10011001000', '10011000100', '10001100100', '11001001000',\n '11001000100', '11000100100', '10110011100', '10011011100', '10011001110', '10111001100', '10011101100', '10011100110', '11001110010', '11001011100',\n '11001001110', '11011100100', '11001110100', '11101101110', '11101001100', '11100101100', '11100100110', '11101100100', '11100110100', '11100110010',\n '11011011000', '11011000110', '11000110110', '10100011000', '10001011000', '10001000110', '10110001000', '10001101000', '10001100010', '11010001000',\n '11000101000', '11000100010', '10110111000', '10110001110', '10001101110', '10111011000', '10111000110', '10001110110', '11101110110', '11010001110',\n '11000101110', '11011101000', '11011100010', '11011101110', '11101011000', '11101000110', '11100010110', '11101101000', '11101100010', '11100011010',\n '11101111010', '11001000010', '11110001010', '10100110000', '10100001100', '10010110000', '10010000110', '10000101100', '10000100110', '10110010000',\n '10110000100', '10011010000', '10011000010', '10000110100', '10000110010', '11000010010', '11001010000', '11110111010', '11000010100', '10001111010',\n '10100111100', '10010111100', '10010011110', '10111100100', '10011110100', '10011110010', '11110100100', '11110010100', '11110010010', '11011011110',\n '11011110110', '11110110110', '10101111000', '10100011110', '10001011110', '10111101000', '10111100010', '11110101000', '11110100010', '10111011110',\n '10111101110', '11101011110', '11110101110', '11010000100', '11010010000', '11010011100',\n]\nconst STOP = '1100011101011'\n\n/**\n * Modules (`1` bar, `0` space) of the Code 128 of `value`: set C (digit pairs) when it is all digits of even length,\n * set B (printable ASCII) otherwise. `null` when it cannot be encoded.\n */\nexport function code128Modules(value: string): string | null {\n if (!value || value.length > 80) return null\n let codes: number[]\n if (/^\\d+$/.test(value) && value.length % 2 === 0) {\n codes = [105]\n for (let i = 0; i < value.length; i += 2) codes.push(Number(value.slice(i, i + 2)))\n } else {\n codes = [104]\n for (const ch of value) {\n const c = ch.charCodeAt(0)\n if (c < 32 || c > 126) return null\n codes.push(c - 32)\n }\n }\n let sum = codes[0]!\n for (let i = 1; i < codes.length; i++) sum += codes[i]! * i\n codes.push(sum % 103)\n return codes.map((c) => BARS[c]).join('') + STOP\n}\n\nexport type BarcodeGeometry = { width: number; height: number; rects: { x: number; w: number }[] }\n\n/** Bars of the barcode as rectangles (quiet zone of 10 modules each side included in `width`). `null` if not encodable. */\nexport function barcodeGeometry(value: string, opts: { module?: number; height?: number } = {}): BarcodeGeometry | null {\n const bits = code128Modules(value)\n if (!bits) return null\n const mod = opts.module ?? 2\n const quiet = 10\n const rects: { x: number; w: number }[] = []\n for (let i = 0; i < bits.length; ) {\n if (bits[i] === '0') {\n i++\n continue\n }\n let j = i\n while (j < bits.length && bits[j] === '1') j++\n rects.push({ x: (quiet + i) * mod, w: (j - i) * mod })\n i = j\n }\n return { width: (bits.length + quiet * 2) * mod, height: opts.height ?? 70, rects }\n}\n","/**\n * Printable voucher (A4 HTML) that does not depend on any payment gateway: built only from the voucher data OPS keeps.\n * Loaded on demand (the buyer taps print/download) or by `pendingVoucherResponse` on the server; plain text, no React.\n * Everything external passes through `esc` before it enters the HTML.\n */\nimport type { Money } from '@asteby/storefront'\nimport { barcodeGeometry, barcodeValue, type VoucherView } from './voucher.js'\n\nexport function esc(s: string): string {\n return s.replace(/[&<>\"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '\"': '"', \"'\": ''' })[c] as string)\n}\n\ntype DocText = {\n title: string\n total: string\n reference: string\n clabe: string\n expires: string\n expiresNote: string\n order: string\n barcode: string\n print: string\n footer: string\n stepsCash: string[]\n stepsSpei: string[]\n methods: Record<string, string>\n cash: string\n}\n\nconst ES: DocText = {\n title: 'Ficha de pago',\n total: 'Total a pagar',\n reference: 'Referencia',\n clabe: 'CLABE',\n expires: 'Vence',\n expiresNote: 'Pasada esa fecha la ficha deja de ser válida.',\n order: 'Pedido',\n barcode: 'Código de barras',\n print: 'Imprimir ficha',\n footer: 'Tu pedido se genera cuando se confirma el pago. Esta ficha es de un solo uso; no la compartas.',\n stepsCash: [\n 'Acude a la tienda OXXO (o el comercio indicado) y di que vas a hacer un pago de servicio en efectivo.',\n 'Muestra el código de barras o dicta la referencia y paga el monto exacto.',\n 'Conserva tu comprobante: confirmaremos tu pago automáticamente.',\n ],\n stepsSpei: ['Entra a la banca en línea o app de tu banco.', 'Haz una transferencia SPEI a la CLABE indicada por el monto exacto.', 'Conserva tu comprobante: confirmaremos tu pago automáticamente.'],\n methods: { oxxo: 'OXXO', spei: 'Transferencia SPEI', bank_transfer: 'Transferencia bancaria', bank_deposit: 'Depósito bancario', cash: 'Pago en efectivo' },\n cash: 'Pago en efectivo',\n}\n\nconst EN: DocText = {\n title: 'Payment voucher',\n total: 'Amount to pay',\n reference: 'Reference',\n clabe: 'CLABE',\n expires: 'Expires',\n expiresNote: 'After that date the voucher is no longer valid.',\n order: 'Order',\n barcode: 'Barcode',\n print: 'Print voucher',\n footer: 'Your order is created when the payment is confirmed. This voucher is single-use; do not share it.',\n stepsCash: [\n 'Go to an OXXO store (or the store indicated) and say you want to make a cash service payment.',\n 'Show the barcode or read out the reference and pay the exact amount.',\n 'Keep your receipt: we will confirm your payment automatically.',\n ],\n stepsSpei: ['Open your bank online or app.', 'Make a SPEI transfer to the CLABE below for the exact amount.', 'Keep your receipt: we will confirm your payment automatically.'],\n methods: { oxxo: 'OXXO', spei: 'SPEI transfer', bank_transfer: 'Bank transfer', bank_deposit: 'Bank deposit', cash: 'Cash payment' },\n cash: 'Cash payment',\n}\n\nexport type VoucherDocumentOptions = {\n shopName?: string\n /** Order number, if there is one yet. */\n number?: string | null\n locale?: string\n /** IANA zone the expiry is printed in (default: the runtime's). */\n timeZone?: string\n /** Print button on screen (hidden when printing). */\n printButton?: boolean\n /** Opens the print dialog on load. */\n autoPrint?: boolean\n /** `<script>` nonce when the one serving the voucher sends a CSP with `script-src 'nonce-…'`. */\n nonce?: string\n}\n\nconst CSS = `\n@page { size: A4; margin: 18mm; }\n* { box-sizing: border-box; }\nbody { margin: 0; font: 14px/1.5 system-ui, -apple-system, \"Segoe UI\", Roboto, sans-serif; color: #111; background: #fff; }\nmain { max-width: 174mm; margin: 0 auto; padding: 24px 16px; }\nh1 { font-size: 22px; margin: 0; }\n.muted { color: #555; }\n.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; border-bottom: 3px solid #111; padding-bottom: 12px; }\n.amount { font-size: 28px; font-weight: 700; text-align: right; }\n.box { border: 1px solid #111; padding: 14px 16px; margin-top: 18px; }\n.label { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: #555; }\n.value { font: 700 22px/1.3 ui-monospace, \"SF Mono\", Menlo, Consolas, monospace; word-break: break-all; letter-spacing: .04em; }\n.bar { margin-top: 18px; text-align: center; }\n.bar svg { max-width: 100%; height: auto; }\n.steps { margin: 18px 0 0; padding-left: 20px; }\n.note { margin-top: 18px; font-size: 12px; }\n.pre { white-space: pre-line; }\n.actions { margin-top: 24px; display: flex; gap: 12px; }\n.actions button { font: inherit; padding: 10px 18px; border: 1px solid #111; background: #111; color: #fff; cursor: pointer; }\n@media print { .actions { display: none; } main { padding: 0; } }\n`\n\nfunction formatMoney(m: Money | null, locale: string): string {\n if (!m) return ''\n try {\n return new Intl.NumberFormat(locale, { style: 'currency', currency: m.currency_code }).format(Number(m.amount))\n } catch {\n return `${m.amount} ${m.currency_code}`\n }\n}\n\nfunction formatDate(iso: string | null, locale: string, timeZone?: string): string {\n if (!iso) return ''\n const d = new Date(iso)\n if (Number.isNaN(d.getTime())) return ''\n try {\n return d.toLocaleString(locale, { dateStyle: 'long', timeStyle: 'short', ...(timeZone ? { timeZone } : {}) })\n } catch {\n return d.toISOString()\n }\n}\n\nfunction barcodeSvg(value: string, label: string): string | null {\n const g = barcodeGeometry(value)\n if (!g) return null\n const rects = g.rects.map((r) => `<rect x=\"${r.x}\" y=\"0\" width=\"${r.w}\" height=\"${g.height}\"/>`).join('')\n return `<svg viewBox=\"0 0 ${g.width} ${g.height}\" width=\"${g.width}\" height=\"${g.height}\" role=\"img\" aria-label=\"${esc(label)} ${esc(value)}\" shape-rendering=\"crispEdges\" fill=\"#000\">${rects}</svg>`\n}\n\n/** Complete HTML document of the voucher. Missing data is simply not drawn. */\nexport function renderVoucherDocument(v: VoucherView, opts: VoucherDocumentOptions = {}): string {\n const locale = opts.locale ?? 'es-MX'\n const t = locale.toLowerCase().startsWith('en') ? EN : ES\n const shop = opts.shopName || ''\n // Own keys only: a gateway method named `constructor` or `__proto__` must print as itself, not as Object internals.\n const method = v.method ? (Object.prototype.hasOwnProperty.call(t.methods, v.method.toLowerCase()) ? t.methods[v.method.toLowerCase()]! : v.method) : t.cash\n const isSpei = !!v.clabe && !v.reference\n const code = barcodeValue(v)\n const svg = code ? barcodeSvg(code, t.barcode) : null\n const expires = formatDate(v.expires_at, locale, opts.timeZone)\n const field = (label: string, value: string | null) => (value ? `<div class=\"box\"><div class=\"label\">${esc(label)}</div><div class=\"value\">${esc(value)}</div></div>` : '')\n const steps = isSpei ? t.stepsSpei : t.stepsCash\n const subtitle = [shop, method, opts.number ? `${t.order} ${opts.number}` : ''].filter(Boolean).map(esc).join(' · ')\n return `<!doctype html>\n<html lang=\"${esc(locale)}\"><head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"robots\" content=\"noindex\"><title>${esc(t.title)}${shop ? ` - ${esc(shop)}` : ''}</title><style>${CSS}</style></head>\n<body><main>\n<div class=\"head\"><div><h1>${esc(t.title)}</h1><div class=\"muted\">${subtitle}</div></div>\n${v.amount ? `<div><div class=\"label\" style=\"text-align:right\">${esc(t.total)}</div><div class=\"amount\">${esc(formatMoney(v.amount, locale))}</div></div>` : ''}</div>\n${field(t.reference, v.reference)}${field(t.clabe, v.clabe)}\n${svg ? `<div class=\"bar\">${svg}<div class=\"muted\" style=\"font-family:ui-monospace,monospace\">${esc(code as string)}</div></div>` : ''}\n${expires ? `<p><strong>${esc(t.expires)}:</strong> ${esc(expires)}. ${esc(t.expiresNote)}</p>` : ''}\n<ol class=\"steps\">${steps.map((s) => `<li>${esc(s)}</li>`).join('')}</ol>\n${v.instructions ? `<p class=\"note pre muted\">${esc(v.instructions)}</p>` : ''}\n<p class=\"note muted\">${esc(t.footer)}</p>\n${opts.printButton ? `<div class=\"actions\"><button type=\"button\" id=\"print\">${esc(t.print)}</button></div>` : ''}\n</main>\n${opts.printButton || opts.autoPrint ? `<script${opts.nonce ? ` nonce=\"${esc(opts.nonce)}\"` : ''}>(function(){var b=document.getElementById(\"print\");if(b)b.addEventListener(\"click\",function(){window.print()});${opts.autoPrint ? 'window.addEventListener(\"load\",function(){setTimeout(function(){window.print()},300)});' : ''}})();</script>` : ''}\n</body></html>`\n}\n","/**\n * Server side of the account screen (`@asteby/storefront-react/account/server`): `loadAuthCapabilities` for the loader\n * and `createAuthAction` for the action. No React, no router: Web `Request`/`Response` only, so any framework mounts it.\n *\n * The browser never talks to OPS. The action signs the buyer in with the store's `sk_` client and keeps the session\n * token in the store's own cookie, which is passed in (`customerCookie`), so name, flags and signing stay the store's.\n */\nimport { invoiceFileBytes, isStorefrontError, repairPath, safeInvoiceFilename, type CustomerCapabilities, type CustomerSession, type StorefrontClient } from '@asteby/storefront'\nimport { voucherOf } from './voucher.js'\nimport type { AuthActionData, AuthErrorCode, AuthIntent } from './types.js'\n\nexport type { AuthActionData, AuthErrorCode, AuthIntent, AuthStep } from './types.js'\n\n/** What is assumed when the store cannot be asked: password sign-in works, nothing else is offered. */\nexport const SAFE_AUTH_CAPABILITIES: Readonly<CustomerCapabilities> = Object.freeze({\n password: true,\n email_verification: false,\n otp_channels: Object.freeze([]) as unknown as CustomerCapabilities['otp_channels'],\n})\n\nconst FAILURE_TTL_MS = 5_000\nconst LOG_EVERY_MS = 60_000\nlet lastLogAt = -Infinity\n\n/** Server log (never the buyer's data): says what is missing and where it is repaired. At most once a minute. */\nfunction logMisconfigured(scopes: readonly string[]): void {\n const t = Date.now()\n if (t - lastLogAt < LOG_EVERY_MS) return\n lastLogAt = t\n console.error(\n `[@asteby/storefront-react] La credencial de la tienda no tiene permisos${scopes.length ? ` (${scopes.join(', ')})` : ''}; ` +\n `las cuentas de comprador no funcionan hasta repararlo en ${repairPath()}.`,\n )\n}\nconst cache = new WeakMap<object, { at: number; ok: boolean; value: CustomerCapabilities }>()\n\nexport type LoadAuthCapabilitiesOptions = {\n /** How long a good answer is reused per client (default 60 s). `0` disables the cache. */\n ttlMs?: number\n signal?: AbortSignal\n /** Clock, for tests. */\n now?: () => number\n}\n\n/**\n * Asks the store which ways of signing in it offers, with a short cache per client. It NEVER throws: when OPS does not\n * answer (older server, outage, token without scope) it returns `SAFE_AUTH_CAPABILITIES` and retries after a few\n * seconds, so the account screen always renders. Use it as the loader: `loader = () => loadAuthCapabilities(storefront)`.\n */\nexport async function loadAuthCapabilities(sf: StorefrontClient, options: LoadAuthCapabilitiesOptions = {}): Promise<CustomerCapabilities> {\n const now = options.now ?? Date.now\n const ttl = options.ttlMs ?? 60_000\n const hit = cache.get(sf)\n if (hit && now() - hit.at < (hit.ok ? ttl : FAILURE_TTL_MS)) return hit.value\n try {\n const got = await sf.customer.capabilities(options.signal ? { signal: options.signal } : undefined)\n const missing = Array.isArray(got?.missing_scopes) ? got.missing_scopes.filter((x): x is string => typeof x === 'string') : []\n const value: CustomerCapabilities = {\n // `password: false` (including for a missing scope) is respected: the form never offers what the token cannot do.\n password: got?.password !== false,\n email_verification: got?.email_verification === true,\n otp_channels: Array.isArray(got?.otp_channels) ? got.otp_channels : [],\n ...(typeof got?.unavailable_reason === 'string' ? { unavailable_reason: got.unavailable_reason } : {}),\n ...(missing.length ? { missing_scopes: missing } : {}),\n }\n if (value.unavailable_reason === 'missing_scope') logMisconfigured(missing)\n cache.set(sf, { at: now(), ok: true, value })\n return value\n } catch (err) {\n if (isStorefrontError(err) && err.code === 'insufficient_scope') {\n // The token cannot even read capabilities: do not offer password sign-in it could not complete.\n const value: CustomerCapabilities = {\n password: false,\n email_verification: false,\n otp_channels: [],\n unavailable_reason: 'missing_scope',\n missing_scopes: err.requiredScopes,\n }\n logMisconfigured(err.requiredScopes)\n cache.set(sf, { at: now(), ok: false, value })\n return value\n }\n cache.set(sf, { at: now(), ok: false, value: SAFE_AUTH_CAPABILITIES })\n return SAFE_AUTH_CAPABILITIES\n }\n}\n\n/** The part of a cookie the action needs. React Router's `createCookie(...)` and Remix's fit as they are. */\nexport type AuthCookie = {\n serialize(value: string, options?: { expires?: Date; maxAge?: number }): string | Promise<string>\n}\n\n/** Allows only a path inside the site (`/account`, `/orders?x=1`); anything else is `fallback`. Blocks `//host` and `/\\host`. */\nexport function safeNextPath(raw: string | null | undefined, fallback = '/account'): string {\n if (typeof raw !== 'string') return fallback\n const v = raw.trim()\n if (!v.startsWith('/') || v.startsWith('//') || v.startsWith('/\\\\') || /[\\u0000-\\u001f\\\\]/.test(v)) return fallback\n return v\n}\n\nexport type CreateAuthActionOptions = {\n storefront: StorefrontClient\n /** The store's cookie for the buyer session token (`createCookie('sf_customer', ...)`). */\n customerCookie: AuthCookie\n /** Validates the `next` field before redirecting (default `safeNextPath`). Return a same-site path. */\n safeNext?: (raw: string | null) => string\n /** Where to go after signing in when there is no `next` (default `/account`). Only used by the default `safeNext`. */\n defaultNext?: string\n /** Shopper IP for the per-shopper rate limit (see `clientIp` of the client). */\n clientIp?: (request: Request) => string | null | undefined\n /** Capabilities source, for tests or a shared cache (default `loadAuthCapabilities`). */\n capabilities?: (sf: StorefrontClient) => Promise<CustomerCapabilities>\n}\n\nexport type AuthActionArgs = { request: Request }\n\nconst fail = (code: AuthErrorCode, extra: Partial<AuthActionData> = {}, field?: string): AuthActionData => ({\n ok: false,\n ...extra,\n error: { code, ...(field ? { field } : {}) },\n})\n\n/** Maps what the SDK threw to the error the form shows. `ctx` tells what a 401 means on this step. */\nfunction toFailure(err: unknown, ctx: 'credentials' | 'code' | 'other', extra: Partial<AuthActionData>): AuthActionData {\n if (!isStorefrontError(err)) return fail('unavailable', extra)\n if (err.code === 'insufficient_scope') {\n logMisconfigured(err.requiredScopes)\n return fail('store_misconfigured', extra)\n }\n switch (err.status) {\n case 401:\n return fail(ctx === 'credentials' ? 'invalid_credentials' : ctx === 'code' ? 'invalid_code' : 'unavailable', extra, ctx === 'code' ? 'code' : undefined)\n case 409:\n return fail('email_taken', extra, 'email')\n case 429:\n return fail('rate_limited', extra)\n case 400:\n case 422:\n return fail('validation', extra, err.field)\n case 403:\n case 404:\n return fail('unsupported', extra)\n default:\n return fail('unavailable', extra)\n }\n}\n\n/**\n * The account action: one `POST` form with an `intent` field.\n *\n * | intent | fields | result |\n * | ------------- | ---------------------------------------- | -------------------------------------------------------- |\n * | `login` | email, password | signs in -> redirect |\n * | `register` | email, password, first_name?, last_name? | `step: 'verify'` or, without verification, redirect |\n * | `verify` | email, code | account ready -> redirect |\n * | `otp-request` | email | `step: 'otp'` (code sent) |\n * | `otp-login` | email, code | signs in -> redirect |\n * | `forgot` | email | `step: 'reset'` (always, so it never says who has an account) |\n * | `reset` | email, code, password | new password and signed in -> redirect |\n *\n * Success is a `303` to `next` (validated by `safeNext`) with `Set-Cookie` holding the session token; anything else is\n * an `AuthActionData` to render with `<AccountAuth data={...}>`. Passwords and codes are never echoed back.\n */\nexport function createAuthAction(options: CreateAuthActionOptions) {\n const { storefront: sf, customerCookie } = options\n const safeNext = options.safeNext ?? ((raw: string | null) => safeNextPath(raw, options.defaultNext ?? '/account'))\n const loadCaps = options.capabilities ?? ((client: StorefrontClient) => loadAuthCapabilities(client))\n\n async function signedIn(session: CustomerSession, next: string): Promise<Response> {\n const expires = new Date(session.expires_at)\n const cookie = await customerCookie.serialize(session.token, Number.isNaN(expires.getTime()) ? undefined : { expires })\n return new Response(null, { status: 303, headers: { Location: next, 'Set-Cookie': cookie } })\n }\n\n return async function authAction({ request }: AuthActionArgs): Promise<Response | AuthActionData> {\n const form = await request.formData().catch(() => null)\n if (!form) return fail('validation')\n const text = (name: string) => {\n const v = form.get(name)\n return typeof v === 'string' ? v : ''\n }\n const intent = text('intent') as AuthIntent\n const email = text('email').trim()\n const password = text('password')\n const code = text('code').replace(/\\s+/g, '')\n const next = safeNext(text('next') || null)\n const ip = options.clientIp?.(request)\n const w = ip ? { clientIp: ip } : undefined\n const carry: Partial<AuthActionData> = { email }\n if (!email) return fail('validation', carry, 'email')\n\n const caps = await loadCaps(sf)\n const passwordOn = caps.password\n // Off because the store's token lacks a scope (not a merchant choice): say so instead of \"not available\".\n const misconfigured = caps.unavailable_reason === 'missing_scope'\n const off = (): AuthActionData => fail(misconfigured ? 'store_misconfigured' : 'unsupported', carry)\n const otpOn = caps.otp_channels.includes('email')\n\n try {\n switch (intent) {\n case 'login': {\n if (!passwordOn) return off()\n if (!password) return fail('validation', carry, 'password')\n return await signedIn(await sf.customer.loginWithPassword({ email, password }, w), next)\n }\n case 'register': {\n if (!passwordOn) return off()\n if (!password) return fail('validation', carry, 'password')\n const res = await sf.customer.register(\n { email, password, ...(text('first_name').trim() ? { first_name: text('first_name').trim() } : {}), ...(text('last_name').trim() ? { last_name: text('last_name').trim() } : {}) },\n w,\n )\n return res.status === 'created' ? await signedIn(res.session, next) : { ok: true, step: 'verify', email }\n }\n case 'verify': {\n if (!code) return fail('validation', carry, 'code')\n return await signedIn(await sf.customer.verifyRegistration({ email, code }, w), next)\n }\n case 'otp-request': {\n if (!otpOn) return off()\n await sf.customer.requestOtp({ email }, w)\n return { ok: true, step: 'otp', email }\n }\n case 'otp-login': {\n if (!otpOn) return off()\n if (!code) return fail('validation', carry, 'code')\n return await signedIn(await sf.customer.createSession({ email, code }, w), next)\n }\n case 'forgot': {\n if (!passwordOn || !otpOn) return off()\n try {\n await sf.customer.requestOtp({ email }, w)\n } catch (err) {\n // Only throttling and a bad email are told; anything else looks the same as success (no account enumeration).\n if (isStorefrontError(err) && (err.status === 429 || err.status === 400)) throw err\n }\n return { ok: true, step: 'reset', email }\n }\n case 'reset': {\n if (!passwordOn) return off()\n if (!code) return fail('validation', carry, 'code')\n if (!password) return fail('validation', carry, 'password')\n await sf.customer.resetPassword({ email, code, password }, w)\n return await signedIn(await sf.customer.loginWithPassword({ email, password }, w), next)\n }\n default:\n return fail('validation', carry)\n }\n } catch (err) {\n const step = intent === 'verify' ? 'verify' : intent === 'otp-login' ? 'otp' : intent === 'reset' || intent === 'forgot' ? 'reset' : undefined\n const ctx = intent === 'login' ? 'credentials' : step ? 'code' : 'other'\n return toFailure(err, ctx, step && intent !== 'forgot' ? { ...carry, step } : carry)\n }\n }\n}\n\nexport type AuthAction = ReturnType<typeof createAuthAction>\n\n// ---------------------------------------------------------------------------\n// Resource routes of the order screens: the invoice file and the printable voucher\n// ---------------------------------------------------------------------------\n\n/** Headers every answer of a buyer route carries, error or not: never cached, never sniffed, never rendered as a page. */\nconst LOCKED_HEADERS = {\n 'Cache-Control': 'private, no-store',\n 'X-Content-Type-Options': 'nosniff',\n 'Referrer-Policy': 'no-referrer',\n 'X-Robots-Tag': 'noindex',\n} as const\nconst TEXT_HEADERS = { ...LOCKED_HEADERS, 'Content-Type': 'text/plain; charset=utf-8', 'Content-Security-Policy': \"default-src 'none'; sandbox\" } as const\nconst textResponse = (status: number, body: string, extra: Record<string, string> = {}) => new Response(body, { status, headers: { ...TEXT_HEADERS, ...extra } })\n\n/** Largest invoice file served (a CFDI PDF is well under 1 MB): anything bigger is refused before it is decoded. */\nexport const MAX_INVOICE_FILE_BYTES = 10 * 1024 * 1024\n\n/** Statuses a buyer-facing route answers with; anything unexpected is a plain 502 (never the upstream message). */\nfunction failureResponse(err: unknown): Response {\n if (isStorefrontError(err)) {\n if (err.status === 401) return textResponse(401, 'Sesion vencida')\n if (err.status === 404) return textResponse(404, 'No encontrado')\n if (err.status === 429) {\n const wait = typeof err.retryAfter === 'number' && Number.isFinite(err.retryAfter) && err.retryAfter > 0 ? Math.min(3600, Math.ceil(err.retryAfter)) : null\n return textResponse(429, 'Demasiados intentos', wait ? { 'Retry-After': String(wait) } : {})\n }\n }\n return textResponse(502, 'No pudimos obtener el archivo')\n}\n\nconst FILE_TYPES: Record<string, string> = { pdf: 'application/pdf', xml: 'application/xml' }\n\nexport type InvoiceFileResponseOptions = {\n /** Client WITH the buyer's session (`storefront.withCustomerToken(token)`). */\n storefront: StorefrontClient\n orderId: string\n invoiceId: string\n /** From the URL (`pdf` | `xml`); anything else is a 404. */\n kind: string | undefined\n signal?: AbortSignal\n /** Largest file served, in bytes (default `MAX_INVOICE_FILE_BYTES`, 10 MB); a bigger one is a generic 502. */\n maxBytes?: number\n}\n\n/**\n * Serves one file of an invoice or credit note to the signed-in buyer: the route handler of the store\n * (`account.order.$id.invoice.$doc.$kind.ts`) is `return invoiceFileResponse({ storefront, orderId, invoiceId, kind })`.\n * The buyer's token and any PAC URL stay on the server; the browser gets bytes with `Content-Disposition: attachment`,\n * `Cache-Control: private, no-store`, `nosniff` and a sandboxing CSP. The content type is taken from `kind`, never\n * from what the API says, so a file cannot make the browser render HTML under your origin. 401/404/429 pass through;\n * anything else is a generic 502 with no upstream detail.\n */\nexport async function invoiceFileResponse({ storefront, orderId, invoiceId, kind, signal, maxBytes = MAX_INVOICE_FILE_BYTES }: InvoiceFileResponseOptions): Promise<Response> {\n if (kind !== 'pdf' && kind !== 'xml') return textResponse(404, 'No encontrado')\n if (!orderId || !invoiceId) return textResponse(404, 'No encontrado')\n try {\n const file = await storefront.customer.invoiceFile(orderId, invoiceId, kind, signal ? { signal } : undefined)\n if (!file) return textResponse(404, 'No encontrado')\n // Checked on the encoded text (4 chars per 3 bytes, whitespace aside) so a huge answer is never decoded.\n if (file.content_base64.length > Math.ceil(maxBytes / 3) * 4 * 1.1 + 64) return textResponse(502, 'No pudimos obtener el archivo')\n const bytes = invoiceFileBytes(file)\n if (bytes.byteLength > maxBytes) return textResponse(502, 'No pudimos obtener el archivo')\n const name = safeInvoiceFilename(file.filename, kind === 'pdf' ? 'factura.pdf' : 'factura.xml')\n const filename = name.toLowerCase().endsWith(`.${kind}`) ? name : `${name}.${kind}`\n return new Response(bytes as BodyInit, {\n status: 200,\n headers: {\n 'Content-Type': FILE_TYPES[kind]!,\n 'Content-Length': String(bytes.byteLength),\n 'Content-Disposition': `attachment; filename=\"${filename}\"`,\n ...LOCKED_HEADERS,\n 'Content-Security-Policy': \"default-src 'none'; sandbox\",\n },\n })\n } catch (err) {\n return failureResponse(err)\n }\n}\n\nexport type PendingVoucherResponseOptions = {\n /** Client WITH the buyer's session. */\n storefront: StorefrontClient\n /** Checkout id (`PendingPayment.id`). */\n id: string\n /** `?descargar=1`: deliver it as a file instead of showing it. */\n download?: boolean\n shopName?: string\n locale?: string\n timeZone?: string\n signal?: AbortSignal\n}\n\n/**\n * The printable A4 voucher of a pending payment of the signed-in buyer. Served only when `id` is in HIS list (the list\n * is scoped by buyer in OPS): any other id is a 404. The document is self-contained, so its CSP allows nothing\n * external, only its own print script (with a per-response nonce) and inline styles.\n */\nexport async function pendingVoucherResponse({ storefront, id, download = false, shopName, locale, timeZone, signal }: PendingVoucherResponseOptions): Promise<Response> {\n try {\n const page = await storefront.customer.pendingPayments({ first: 100 }, signal ? { signal } : undefined)\n const item = page.nodes.find((p) => p.id === id)\n const voucher = item ? voucherOf(item) : null\n if (!item || !voucher) return textResponse(404, 'Ficha no encontrada')\n const nonce = btoa(String.fromCharCode(...crypto.getRandomValues(new Uint8Array(16))))\n const { renderVoucherDocument } = await import('./voucher-document.js')\n const html = renderVoucherDocument(voucher, { ...(shopName ? { shopName } : {}), ...(locale ? { locale } : {}), ...(timeZone ? { timeZone } : {}), printButton: !download, nonce })\n const safeId = id.replace(/[^A-Za-z0-9-]/g, '').slice(0, 8) || 'ficha'\n return new Response(html, {\n status: 200,\n headers: {\n 'Content-Type': 'text/html; charset=utf-8',\n ...LOCKED_HEADERS,\n // The download carries no script, so its policy allows none.\n 'Content-Security-Policy': `default-src 'none'; style-src 'unsafe-inline'; img-src data:; script-src ${download ? \"'none'\" : `'nonce-${nonce}'`}; base-uri 'none'; form-action 'none'; frame-ancestors 'self'`,\n ...(download ? { 'Content-Disposition': `attachment; filename=\"ficha-de-pago-${safeId}.html\"` } : {}),\n },\n })\n } catch (err) {\n return failureResponse(err)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/account/voucher.ts","../src/account/voucher-document.ts","../src/account/server.ts","../src/account/settings-server.ts"],"names":["isStorefrontError","text","repairPath","fail","storefront","invoiceFileBytes","safeInvoiceFilename","renderVoucherDocument"],"mappings":";;;;;;;;;;;;;;;AAoBA,SAAS,KAAK,CAAA,EAA2B;AACvC,EAAA,IAAI,OAAO,MAAM,QAAA,IAAY,MAAA,CAAO,SAAS,CAAC,CAAA,EAAG,OAAO,MAAA,CAAO,CAAC,CAAA;AAChE,EAAA,IAAI,OAAO,CAAA,KAAM,QAAA,EAAU,OAAO,IAAA;AAClC,EAAA,MAAM,IAAI,CAAA,CAAE,IAAA,EAAK,CAAE,KAAA,CAAM,GAAG,GAAG,CAAA;AAC/B,EAAA,OAAO,CAAA,IAAK,IAAA;AACd;AAEA,SAAS,QAAQ,CAAA,EAA0B;AACzC,EAAA,IAAI,CAAC,CAAA,IAAK,OAAO,CAAA,KAAM,UAAU,OAAO,IAAA;AACxC,EAAA,MAAM,CAAA,GAAI,CAAA;AACV,EAAA,MAAM,MAAA,GAAS,IAAA,CAAK,CAAA,CAAE,MAAM,CAAA;AAC5B,EAAA,MAAM,GAAA,GAAM,IAAA,CAAK,CAAA,CAAE,aAAa,CAAA;AAChC,EAAA,O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CAAA,KAAa;AAAC;AACrG,KACD,CAAA;AAAA,EACH,SAAS,GAAA,EAAK;AACZ,IAAA,OAAO,gBAAgB,GAAG,CAAA;AAAA,EAC5B;AACF","file":"account-server.cjs","sourcesContent":["/**\n * Pure pieces of the cash voucher (OXXO, SPEI, deposit): the normalized `VoucherView` of a `PendingPayment` and the\n * Code 128 barcode (the one cashiers' readers scan). No React, no DOM: the same code draws the barcode in the page\n * (`<Barcode>`) and in the printable document (`voucher-document.ts`, loaded only when the buyer prints).\n */\nimport type { Money, PendingPayment } from '@asteby/storefront'\n\nexport type VoucherView = {\n /** `oxxo`, `spei`, ... as the gateway publishes it. */\n method: string | null\n reference: string | null\n barcode: string | null\n clabe: string | null\n expires_at: string | null\n amount: Money | null\n instructions: string | null\n}\n\nconst MAX = 256\n\nfunction text(v: unknown): string | null {\n if (typeof v === 'number' && Number.isFinite(v)) return String(v)\n if (typeof v !== 'string') return null\n const s = v.trim().slice(0, MAX)\n return s || null\n}\n\nfunction moneyOf(v: unknown): Money | null {\n if (!v || typeof v !== 'object') return null\n const m = v as Record<string, unknown>\n const amount = text(m.amount)\n const cur = text(m.currency_code)\n return amount && cur && Number.isFinite(Number(amount)) ? { amount, currency_code: cur.toUpperCase() } : null\n}\n\n/** The voucher of a pending payment; `null` when it has neither reference, barcode nor CLABE (nothing to pay with). */\nexport function voucherOf(p: Pick<PendingPayment, 'payment' | 'total' | 'expires_at'> | null | undefined): VoucherView | null {\n const pay = p?.payment\n if (!pay || typeof pay !== 'object') return null\n const v: VoucherView = {\n method: text(pay.method ?? pay.provider),\n reference: text(pay.reference),\n barcode: text(pay.barcode),\n clabe: text(pay.clabe),\n expires_at: text(pay.expires_at) ?? text(p?.expires_at),\n amount: moneyOf(pay.amount) ?? moneyOf(p?.total),\n instructions: text(pay.instructions),\n }\n return v.reference || v.barcode || v.clabe ? v : null\n}\n\n/** The value the barcode encodes: the gateway's `barcode`, else the reference of an OXXO voucher. */\nexport function barcodeValue(v: Pick<VoucherView, 'barcode' | 'method' | 'reference'>): string | null {\n return v.barcode ?? (v.method?.toLowerCase() === 'oxxo' ? v.reference : null)\n}\n\n// 11-module patterns of symbols 0..105 and the 13-module stop (ISO/IEC 15417).\nconst BARS = [\n '11011001100', '11001101100', '11001100110', '10010011000', '10010001100', '10001001100', '10011001000', '10011000100', '10001100100', '11001001000',\n '11001000100', '11000100100', '10110011100', '10011011100', '10011001110', '10111001100', '10011101100', '10011100110', '11001110010', '11001011100',\n '11001001110', '11011100100', '11001110100', '11101101110', '11101001100', '11100101100', '11100100110', '11101100100', '11100110100', '11100110010',\n '11011011000', '11011000110', '11000110110', '10100011000', '10001011000', '10001000110', '10110001000', '10001101000', '10001100010', '11010001000',\n '11000101000', '11000100010', '10110111000', '10110001110', '10001101110', '10111011000', '10111000110', '10001110110', '11101110110', '11010001110',\n '11000101110', '11011101000', '11011100010', '11011101110', '11101011000', '11101000110', '11100010110', '11101101000', '11101100010', '11100011010',\n '11101111010', '11001000010', '11110001010', '10100110000', '10100001100', '10010110000', '10010000110', '10000101100', '10000100110', '10110010000',\n '10110000100', '10011010000', '10011000010', '10000110100', '10000110010', '11000010010', '11001010000', '11110111010', '11000010100', '10001111010',\n '10100111100', '10010111100', '10010011110', '10111100100', '10011110100', '10011110010', '11110100100', '11110010100', '11110010010', '11011011110',\n '11011110110', '11110110110', '10101111000', '10100011110', '10001011110', '10111101000', '10111100010', '11110101000', '11110100010', '10111011110',\n '10111101110', '11101011110', '11110101110', '11010000100', '11010010000', '11010011100',\n]\nconst STOP = '1100011101011'\n\n/**\n * Modules (`1` bar, `0` space) of the Code 128 of `value`: set C (digit pairs) when it is all digits of even length,\n * set B (printable ASCII) otherwise. `null` when it cannot be encoded.\n */\nexport function code128Modules(value: string): string | null {\n if (!value || value.length > 80) return null\n let codes: number[]\n if (/^\\d+$/.test(value) && value.length % 2 === 0) {\n codes = [105]\n for (let i = 0; i < value.length; i += 2) codes.push(Number(value.slice(i, i + 2)))\n } else {\n codes = [104]\n for (const ch of value) {\n const c = ch.charCodeAt(0)\n if (c < 32 || c > 126) return null\n codes.push(c - 32)\n }\n }\n let sum = codes[0]!\n for (let i = 1; i < codes.length; i++) sum += codes[i]! * i\n codes.push(sum % 103)\n return codes.map((c) => BARS[c]).join('') + STOP\n}\n\nexport type BarcodeGeometry = { width: number; height: number; rects: { x: number; w: number }[] }\n\n/** Bars of the barcode as rectangles (quiet zone of 10 modules each side included in `width`). `null` if not encodable. */\nexport function barcodeGeometry(value: string, opts: { module?: number; height?: number } = {}): BarcodeGeometry | null {\n const bits = code128Modules(value)\n if (!bits) return null\n const mod = opts.module ?? 2\n const quiet = 10\n const rects: { x: number; w: number }[] = []\n for (let i = 0; i < bits.length; ) {\n if (bits[i] === '0') {\n i++\n continue\n }\n let j = i\n while (j < bits.length && bits[j] === '1') j++\n rects.push({ x: (quiet + i) * mod, w: (j - i) * mod })\n i = j\n }\n return { width: (bits.length + quiet * 2) * mod, height: opts.height ?? 70, rects }\n}\n","/**\n * Printable voucher (A4 HTML) that does not depend on any payment gateway: built only from the voucher data OPS keeps.\n * Loaded on demand (the buyer taps print/download) or by `pendingVoucherResponse` on the server; plain text, no React.\n * Everything external passes through `esc` before it enters the HTML.\n */\nimport type { Money } from '@asteby/storefront'\nimport { barcodeGeometry, barcodeValue, type VoucherView } from './voucher.js'\n\nexport function esc(s: string): string {\n return s.replace(/[&<>\"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '\"': '"', \"'\": ''' })[c] as string)\n}\n\ntype DocText = {\n title: string\n total: string\n reference: string\n clabe: string\n expires: string\n expiresNote: string\n order: string\n barcode: string\n print: string\n footer: string\n stepsCash: string[]\n stepsSpei: string[]\n methods: Record<string, string>\n cash: string\n}\n\nconst ES: DocText = {\n title: 'Ficha de pago',\n total: 'Total a pagar',\n reference: 'Referencia',\n clabe: 'CLABE',\n expires: 'Vence',\n expiresNote: 'Pasada esa fecha la ficha deja de ser válida.',\n order: 'Pedido',\n barcode: 'Código de barras',\n print: 'Imprimir ficha',\n footer: 'Tu pedido se genera cuando se confirma el pago. Esta ficha es de un solo uso; no la compartas.',\n stepsCash: [\n 'Acude a la tienda OXXO (o el comercio indicado) y di que vas a hacer un pago de servicio en efectivo.',\n 'Muestra el código de barras o dicta la referencia y paga el monto exacto.',\n 'Conserva tu comprobante: confirmaremos tu pago automáticamente.',\n ],\n stepsSpei: ['Entra a la banca en línea o app de tu banco.', 'Haz una transferencia SPEI a la CLABE indicada por el monto exacto.', 'Conserva tu comprobante: confirmaremos tu pago automáticamente.'],\n methods: { oxxo: 'OXXO', spei: 'Transferencia SPEI', bank_transfer: 'Transferencia bancaria', bank_deposit: 'Depósito bancario', cash: 'Pago en efectivo' },\n cash: 'Pago en efectivo',\n}\n\nconst EN: DocText = {\n title: 'Payment voucher',\n total: 'Amount to pay',\n reference: 'Reference',\n clabe: 'CLABE',\n expires: 'Expires',\n expiresNote: 'After that date the voucher is no longer valid.',\n order: 'Order',\n barcode: 'Barcode',\n print: 'Print voucher',\n footer: 'Your order is created when the payment is confirmed. This voucher is single-use; do not share it.',\n stepsCash: [\n 'Go to an OXXO store (or the store indicated) and say you want to make a cash service payment.',\n 'Show the barcode or read out the reference and pay the exact amount.',\n 'Keep your receipt: we will confirm your payment automatically.',\n ],\n stepsSpei: ['Open your bank online or app.', 'Make a SPEI transfer to the CLABE below for the exact amount.', 'Keep your receipt: we will confirm your payment automatically.'],\n methods: { oxxo: 'OXXO', spei: 'SPEI transfer', bank_transfer: 'Bank transfer', bank_deposit: 'Bank deposit', cash: 'Cash payment' },\n cash: 'Cash payment',\n}\n\nexport type VoucherDocumentOptions = {\n shopName?: string\n /** Order number, if there is one yet. */\n number?: string | null\n locale?: string\n /** IANA zone the expiry is printed in (default: the runtime's). */\n timeZone?: string\n /** Print button on screen (hidden when printing). */\n printButton?: boolean\n /** Opens the print dialog on load. */\n autoPrint?: boolean\n /** `<script>` nonce when the one serving the voucher sends a CSP with `script-src 'nonce-…'`. */\n nonce?: string\n}\n\nconst CSS = `\n@page { size: A4; margin: 18mm; }\n* { box-sizing: border-box; }\nbody { margin: 0; font: 14px/1.5 system-ui, -apple-system, \"Segoe UI\", Roboto, sans-serif; color: #111; background: #fff; }\nmain { max-width: 174mm; margin: 0 auto; padding: 24px 16px; }\nh1 { font-size: 22px; margin: 0; }\n.muted { color: #555; }\n.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; border-bottom: 3px solid #111; padding-bottom: 12px; }\n.amount { font-size: 28px; font-weight: 700; text-align: right; }\n.box { border: 1px solid #111; padding: 14px 16px; margin-top: 18px; }\n.label { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: #555; }\n.value { font: 700 22px/1.3 ui-monospace, \"SF Mono\", Menlo, Consolas, monospace; word-break: break-all; letter-spacing: .04em; }\n.bar { margin-top: 18px; text-align: center; }\n.bar svg { max-width: 100%; height: auto; }\n.steps { margin: 18px 0 0; padding-left: 20px; }\n.note { margin-top: 18px; font-size: 12px; }\n.pre { white-space: pre-line; }\n.actions { margin-top: 24px; display: flex; gap: 12px; }\n.actions button { font: inherit; padding: 10px 18px; border: 1px solid #111; background: #111; color: #fff; cursor: pointer; }\n@media print { .actions { display: none; } main { padding: 0; } }\n`\n\nfunction formatMoney(m: Money | null, locale: string): string {\n if (!m) return ''\n try {\n return new Intl.NumberFormat(locale, { style: 'currency', currency: m.currency_code }).format(Number(m.amount))\n } catch {\n return `${m.amount} ${m.currency_code}`\n }\n}\n\nfunction formatDate(iso: string | null, locale: string, timeZone?: string): string {\n if (!iso) return ''\n const d = new Date(iso)\n if (Number.isNaN(d.getTime())) return ''\n try {\n return d.toLocaleString(locale, { dateStyle: 'long', timeStyle: 'short', ...(timeZone ? { timeZone } : {}) })\n } catch {\n return d.toISOString()\n }\n}\n\nfunction barcodeSvg(value: string, label: string): string | null {\n const g = barcodeGeometry(value)\n if (!g) return null\n const rects = g.rects.map((r) => `<rect x=\"${r.x}\" y=\"0\" width=\"${r.w}\" height=\"${g.height}\"/>`).join('')\n return `<svg viewBox=\"0 0 ${g.width} ${g.height}\" width=\"${g.width}\" height=\"${g.height}\" role=\"img\" aria-label=\"${esc(label)} ${esc(value)}\" shape-rendering=\"crispEdges\" fill=\"#000\">${rects}</svg>`\n}\n\n/** Complete HTML document of the voucher. Missing data is simply not drawn. */\nexport function renderVoucherDocument(v: VoucherView, opts: VoucherDocumentOptions = {}): string {\n const locale = opts.locale ?? 'es-MX'\n const t = locale.toLowerCase().startsWith('en') ? EN : ES\n const shop = opts.shopName || ''\n // Own keys only: a gateway method named `constructor` or `__proto__` must print as itself, not as Object internals.\n const method = v.method ? (Object.prototype.hasOwnProperty.call(t.methods, v.method.toLowerCase()) ? t.methods[v.method.toLowerCase()]! : v.method) : t.cash\n const isSpei = !!v.clabe && !v.reference\n const code = barcodeValue(v)\n const svg = code ? barcodeSvg(code, t.barcode) : null\n const expires = formatDate(v.expires_at, locale, opts.timeZone)\n const field = (label: string, value: string | null) => (value ? `<div class=\"box\"><div class=\"label\">${esc(label)}</div><div class=\"value\">${esc(value)}</div></div>` : '')\n const steps = isSpei ? t.stepsSpei : t.stepsCash\n const subtitle = [shop, method, opts.number ? `${t.order} ${opts.number}` : ''].filter(Boolean).map(esc).join(' · ')\n return `<!doctype html>\n<html lang=\"${esc(locale)}\"><head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"robots\" content=\"noindex\"><title>${esc(t.title)}${shop ? ` - ${esc(shop)}` : ''}</title><style>${CSS}</style></head>\n<body><main>\n<div class=\"head\"><div><h1>${esc(t.title)}</h1><div class=\"muted\">${subtitle}</div></div>\n${v.amount ? `<div><div class=\"label\" style=\"text-align:right\">${esc(t.total)}</div><div class=\"amount\">${esc(formatMoney(v.amount, locale))}</div></div>` : ''}</div>\n${field(t.reference, v.reference)}${field(t.clabe, v.clabe)}\n${svg ? `<div class=\"bar\">${svg}<div class=\"muted\" style=\"font-family:ui-monospace,monospace\">${esc(code as string)}</div></div>` : ''}\n${expires ? `<p><strong>${esc(t.expires)}:</strong> ${esc(expires)}. ${esc(t.expiresNote)}</p>` : ''}\n<ol class=\"steps\">${steps.map((s) => `<li>${esc(s)}</li>`).join('')}</ol>\n${v.instructions ? `<p class=\"note pre muted\">${esc(v.instructions)}</p>` : ''}\n<p class=\"note muted\">${esc(t.footer)}</p>\n${opts.printButton ? `<div class=\"actions\"><button type=\"button\" id=\"print\">${esc(t.print)}</button></div>` : ''}\n</main>\n${opts.printButton || opts.autoPrint ? `<script${opts.nonce ? ` nonce=\"${esc(opts.nonce)}\"` : ''}>(function(){var b=document.getElementById(\"print\");if(b)b.addEventListener(\"click\",function(){window.print()});${opts.autoPrint ? 'window.addEventListener(\"load\",function(){setTimeout(function(){window.print()},300)});' : ''}})();</script>` : ''}\n</body></html>`\n}\n","/**\n * Server side of the account screen (`@asteby/storefront-react/account/server`): `loadAuthCapabilities` for the loader\n * and `createAuthAction` for the action. No React, no router: Web `Request`/`Response` only, so any framework mounts it.\n *\n * The browser never talks to OPS. The action signs the buyer in with the store's `sk_` client and keeps the session\n * token in the store's own cookie, which is passed in (`customerCookie`), so name, flags and signing stay the store's.\n */\nimport { invoiceFileBytes, isStorefrontError, repairPath, safeInvoiceFilename, type CustomerCapabilities, type CustomerSession, type StorefrontClient } from '@asteby/storefront'\nimport { voucherOf } from './voucher.js'\nimport type { AuthActionData, AuthErrorCode, AuthIntent } from './types.js'\n\nexport type { AuthActionData, AuthErrorCode, AuthIntent, AuthStep } from './types.js'\n\n/** What is assumed when the store cannot be asked: password sign-in works, nothing else is offered. */\nexport const SAFE_AUTH_CAPABILITIES: Readonly<CustomerCapabilities> = Object.freeze({\n password: true,\n email_verification: false,\n otp_channels: Object.freeze([]) as unknown as CustomerCapabilities['otp_channels'],\n})\n\nconst FAILURE_TTL_MS = 5_000\nconst LOG_EVERY_MS = 60_000\nlet lastLogAt = -Infinity\n\n/** Server log (never the buyer's data): says what is missing and where it is repaired. At most once a minute. */\nfunction logMisconfigured(scopes: readonly string[]): void {\n const t = Date.now()\n if (t - lastLogAt < LOG_EVERY_MS) return\n lastLogAt = t\n console.error(\n `[@asteby/storefront-react] La credencial de la tienda no tiene permisos${scopes.length ? ` (${scopes.join(', ')})` : ''}; ` +\n `las cuentas de comprador no funcionan hasta repararlo en ${repairPath()}.`,\n )\n}\nconst cache = new WeakMap<object, { at: number; ok: boolean; value: CustomerCapabilities }>()\n\nexport type LoadAuthCapabilitiesOptions = {\n /** How long a good answer is reused per client (default 60 s). `0` disables the cache. */\n ttlMs?: number\n signal?: AbortSignal\n /** Clock, for tests. */\n now?: () => number\n}\n\n/**\n * Asks the store which ways of signing in it offers, with a short cache per client. It NEVER throws: when OPS does not\n * answer (older server, outage, token without scope) it returns `SAFE_AUTH_CAPABILITIES` and retries after a few\n * seconds, so the account screen always renders. Use it as the loader: `loader = () => loadAuthCapabilities(storefront)`.\n */\nexport async function loadAuthCapabilities(sf: StorefrontClient, options: LoadAuthCapabilitiesOptions = {}): Promise<CustomerCapabilities> {\n const now = options.now ?? Date.now\n const ttl = options.ttlMs ?? 60_000\n const hit = cache.get(sf)\n if (hit && now() - hit.at < (hit.ok ? ttl : FAILURE_TTL_MS)) return hit.value\n try {\n const got = await sf.customer.capabilities(options.signal ? { signal: options.signal } : undefined)\n const missing = Array.isArray(got?.missing_scopes) ? got.missing_scopes.filter((x): x is string => typeof x === 'string') : []\n const value: CustomerCapabilities = {\n // `password: false` (including for a missing scope) is respected: the form never offers what the token cannot do.\n password: got?.password !== false,\n email_verification: got?.email_verification === true,\n otp_channels: Array.isArray(got?.otp_channels) ? got.otp_channels : [],\n ...(typeof got?.unavailable_reason === 'string' ? { unavailable_reason: got.unavailable_reason } : {}),\n ...(missing.length ? { missing_scopes: missing } : {}),\n }\n if (value.unavailable_reason === 'missing_scope') logMisconfigured(missing)\n cache.set(sf, { at: now(), ok: true, value })\n return value\n } catch (err) {\n if (isStorefrontError(err) && err.code === 'insufficient_scope') {\n // The token cannot even read capabilities: do not offer password sign-in it could not complete.\n const value: CustomerCapabilities = {\n password: false,\n email_verification: false,\n otp_channels: [],\n unavailable_reason: 'missing_scope',\n missing_scopes: err.requiredScopes,\n }\n logMisconfigured(err.requiredScopes)\n cache.set(sf, { at: now(), ok: false, value })\n return value\n }\n cache.set(sf, { at: now(), ok: false, value: SAFE_AUTH_CAPABILITIES })\n return SAFE_AUTH_CAPABILITIES\n }\n}\n\n/** The part of a cookie the action needs. React Router's `createCookie(...)` and Remix's fit as they are. */\nexport type AuthCookie = {\n serialize(value: string, options?: { expires?: Date; maxAge?: number }): string | Promise<string>\n}\n\n/** Allows only a path inside the site (`/account`, `/orders?x=1`); anything else is `fallback`. Blocks `//host` and `/\\host`. */\nexport function safeNextPath(raw: string | null | undefined, fallback = '/account'): string {\n if (typeof raw !== 'string') return fallback\n const v = raw.trim()\n if (!v.startsWith('/') || v.startsWith('//') || v.startsWith('/\\\\') || /[\\u0000-\\u001f\\\\]/.test(v)) return fallback\n return v\n}\n\nexport type CreateAuthActionOptions = {\n storefront: StorefrontClient\n /** The store's cookie for the buyer session token (`createCookie('sf_customer', ...)`). */\n customerCookie: AuthCookie\n /** Validates the `next` field before redirecting (default `safeNextPath`). Return a same-site path. */\n safeNext?: (raw: string | null) => string\n /** Where to go after signing in when there is no `next` (default `/account`). Only used by the default `safeNext`. */\n defaultNext?: string\n /** Shopper IP for the per-shopper rate limit (see `clientIp` of the client). */\n clientIp?: (request: Request) => string | null | undefined\n /** Capabilities source, for tests or a shared cache (default `loadAuthCapabilities`). */\n capabilities?: (sf: StorefrontClient) => Promise<CustomerCapabilities>\n}\n\nexport type AuthActionArgs = { request: Request }\n\nconst fail = (code: AuthErrorCode, extra: Partial<AuthActionData> = {}, field?: string): AuthActionData => ({\n ok: false,\n ...extra,\n error: { code, ...(field ? { field } : {}) },\n})\n\n/** Maps what the SDK threw to the error the form shows. `ctx` tells what a 401 means on this step. */\nfunction toFailure(err: unknown, ctx: 'credentials' | 'code' | 'other', extra: Partial<AuthActionData>): AuthActionData {\n if (!isStorefrontError(err)) return fail('unavailable', extra)\n if (err.code === 'insufficient_scope') {\n logMisconfigured(err.requiredScopes)\n return fail('store_misconfigured', extra)\n }\n switch (err.status) {\n case 401:\n return fail(ctx === 'credentials' ? 'invalid_credentials' : ctx === 'code' ? 'invalid_code' : 'unavailable', extra, ctx === 'code' ? 'code' : undefined)\n case 409:\n return fail('email_taken', extra, 'email')\n case 429:\n return fail('rate_limited', extra)\n case 400:\n case 422:\n return fail('validation', extra, err.field)\n case 403:\n case 404:\n return fail('unsupported', extra)\n default:\n return fail('unavailable', extra)\n }\n}\n\n/**\n * The account action: one `POST` form with an `intent` field.\n *\n * | intent | fields | result |\n * | ------------- | ---------------------------------------- | -------------------------------------------------------- |\n * | `login` | email, password | signs in -> redirect |\n * | `register` | email, password, first_name?, last_name? | `step: 'verify'` or, without verification, redirect |\n * | `verify` | email, code | account ready -> redirect |\n * | `otp-request` | email | `step: 'otp'` (code sent) |\n * | `otp-login` | email, code | signs in -> redirect |\n * | `forgot` | email | `step: 'reset'` (always, so it never says who has an account) |\n * | `reset` | email, code, password | new password and signed in -> redirect |\n *\n * Success is a `303` to `next` (validated by `safeNext`) with `Set-Cookie` holding the session token; anything else is\n * an `AuthActionData` to render with `<AccountAuth data={...}>`. Passwords and codes are never echoed back.\n */\nexport function createAuthAction(options: CreateAuthActionOptions) {\n const { storefront: sf, customerCookie } = options\n const safeNext = options.safeNext ?? ((raw: string | null) => safeNextPath(raw, options.defaultNext ?? '/account'))\n const loadCaps = options.capabilities ?? ((client: StorefrontClient) => loadAuthCapabilities(client))\n\n async function signedIn(session: CustomerSession, next: string): Promise<Response> {\n const expires = new Date(session.expires_at)\n const cookie = await customerCookie.serialize(session.token, Number.isNaN(expires.getTime()) ? undefined : { expires })\n return new Response(null, { status: 303, headers: { Location: next, 'Set-Cookie': cookie } })\n }\n\n return async function authAction({ request }: AuthActionArgs): Promise<Response | AuthActionData> {\n const form = await request.formData().catch(() => null)\n if (!form) return fail('validation')\n const text = (name: string) => {\n const v = form.get(name)\n return typeof v === 'string' ? v : ''\n }\n const intent = text('intent') as AuthIntent\n const email = text('email').trim()\n const password = text('password')\n const code = text('code').replace(/\\s+/g, '')\n const next = safeNext(text('next') || null)\n const ip = options.clientIp?.(request)\n const w = ip ? { clientIp: ip } : undefined\n const carry: Partial<AuthActionData> = { email }\n if (!email) return fail('validation', carry, 'email')\n\n const caps = await loadCaps(sf)\n const passwordOn = caps.password\n // Off because the store's token lacks a scope (not a merchant choice): say so instead of \"not available\".\n const misconfigured = caps.unavailable_reason === 'missing_scope'\n const off = (): AuthActionData => fail(misconfigured ? 'store_misconfigured' : 'unsupported', carry)\n const otpOn = caps.otp_channels.includes('email')\n\n try {\n switch (intent) {\n case 'login': {\n if (!passwordOn) return off()\n if (!password) return fail('validation', carry, 'password')\n return await signedIn(await sf.customer.loginWithPassword({ email, password }, w), next)\n }\n case 'register': {\n if (!passwordOn) return off()\n if (!password) return fail('validation', carry, 'password')\n const res = await sf.customer.register(\n { email, password, ...(text('first_name').trim() ? { first_name: text('first_name').trim() } : {}), ...(text('last_name').trim() ? { last_name: text('last_name').trim() } : {}) },\n w,\n )\n return res.status === 'created' ? await signedIn(res.session, next) : { ok: true, step: 'verify', email }\n }\n case 'verify': {\n if (!code) return fail('validation', carry, 'code')\n return await signedIn(await sf.customer.verifyRegistration({ email, code }, w), next)\n }\n case 'otp-request': {\n if (!otpOn) return off()\n await sf.customer.requestOtp({ email }, w)\n return { ok: true, step: 'otp', email }\n }\n case 'otp-login': {\n if (!otpOn) return off()\n if (!code) return fail('validation', carry, 'code')\n return await signedIn(await sf.customer.createSession({ email, code }, w), next)\n }\n case 'forgot': {\n if (!passwordOn || !otpOn) return off()\n try {\n await sf.customer.requestOtp({ email }, w)\n } catch (err) {\n // Only throttling and a bad email are told; anything else looks the same as success (no account enumeration).\n if (isStorefrontError(err) && (err.status === 429 || err.status === 400)) throw err\n }\n return { ok: true, step: 'reset', email }\n }\n case 'reset': {\n if (!passwordOn) return off()\n if (!code) return fail('validation', carry, 'code')\n if (!password) return fail('validation', carry, 'password')\n await sf.customer.resetPassword({ email, code, password }, w)\n return await signedIn(await sf.customer.loginWithPassword({ email, password }, w), next)\n }\n default:\n return fail('validation', carry)\n }\n } catch (err) {\n const step = intent === 'verify' ? 'verify' : intent === 'otp-login' ? 'otp' : intent === 'reset' || intent === 'forgot' ? 'reset' : undefined\n const ctx = intent === 'login' ? 'credentials' : step ? 'code' : 'other'\n return toFailure(err, ctx, step && intent !== 'forgot' ? { ...carry, step } : carry)\n }\n }\n}\n\nexport type AuthAction = ReturnType<typeof createAuthAction>\n\n// ---------------------------------------------------------------------------\n// Resource routes of the order screens: the invoice file and the printable voucher\n// ---------------------------------------------------------------------------\n\n/** Headers every answer of a buyer route carries, error or not: never cached, never sniffed, never rendered as a page. */\nconst LOCKED_HEADERS = {\n 'Cache-Control': 'private, no-store',\n 'X-Content-Type-Options': 'nosniff',\n 'Referrer-Policy': 'no-referrer',\n 'X-Robots-Tag': 'noindex',\n} as const\nconst TEXT_HEADERS = { ...LOCKED_HEADERS, 'Content-Type': 'text/plain; charset=utf-8', 'Content-Security-Policy': \"default-src 'none'; sandbox\" } as const\nconst textResponse = (status: number, body: string, extra: Record<string, string> = {}) => new Response(body, { status, headers: { ...TEXT_HEADERS, ...extra } })\n\n/** Largest invoice file served (a CFDI PDF is well under 1 MB): anything bigger is refused before it is decoded. */\nexport const MAX_INVOICE_FILE_BYTES = 10 * 1024 * 1024\n\n/** Statuses a buyer-facing route answers with; anything unexpected is a plain 502 (never the upstream message). */\nfunction failureResponse(err: unknown): Response {\n if (isStorefrontError(err)) {\n if (err.status === 401) return textResponse(401, 'Sesion vencida')\n if (err.status === 404) return textResponse(404, 'No encontrado')\n if (err.status === 429) {\n const wait = typeof err.retryAfter === 'number' && Number.isFinite(err.retryAfter) && err.retryAfter > 0 ? Math.min(3600, Math.ceil(err.retryAfter)) : null\n return textResponse(429, 'Demasiados intentos', wait ? { 'Retry-After': String(wait) } : {})\n }\n }\n return textResponse(502, 'No pudimos obtener el archivo')\n}\n\nconst FILE_TYPES: Record<string, string> = { pdf: 'application/pdf', xml: 'application/xml' }\n\nexport type InvoiceFileResponseOptions = {\n /** Client WITH the buyer's session (`storefront.withCustomerToken(token)`). */\n storefront: StorefrontClient\n orderId: string\n invoiceId: string\n /** From the URL (`pdf` | `xml`); anything else is a 404. */\n kind: string | undefined\n signal?: AbortSignal\n /** Largest file served, in bytes (default `MAX_INVOICE_FILE_BYTES`, 10 MB); a bigger one is a generic 502. */\n maxBytes?: number\n}\n\n/**\n * Serves one file of an invoice or credit note to the signed-in buyer: the route handler of the store\n * (`account.order.$id.invoice.$doc.$kind.ts`) is `return invoiceFileResponse({ storefront, orderId, invoiceId, kind })`.\n * The buyer's token and any PAC URL stay on the server; the browser gets bytes with `Content-Disposition: attachment`,\n * `Cache-Control: private, no-store`, `nosniff` and a sandboxing CSP. The content type is taken from `kind`, never\n * from what the API says, so a file cannot make the browser render HTML under your origin. 401/404/429 pass through;\n * anything else is a generic 502 with no upstream detail.\n */\nexport async function invoiceFileResponse({ storefront, orderId, invoiceId, kind, signal, maxBytes = MAX_INVOICE_FILE_BYTES }: InvoiceFileResponseOptions): Promise<Response> {\n if (kind !== 'pdf' && kind !== 'xml') return textResponse(404, 'No encontrado')\n if (!orderId || !invoiceId) return textResponse(404, 'No encontrado')\n try {\n const file = await storefront.customer.invoiceFile(orderId, invoiceId, kind, signal ? { signal } : undefined)\n if (!file) return textResponse(404, 'No encontrado')\n // Checked on the encoded text (4 chars per 3 bytes, whitespace aside) so a huge answer is never decoded.\n if (file.content_base64.length > Math.ceil(maxBytes / 3) * 4 * 1.1 + 64) return textResponse(502, 'No pudimos obtener el archivo')\n const bytes = invoiceFileBytes(file)\n if (bytes.byteLength > maxBytes) return textResponse(502, 'No pudimos obtener el archivo')\n const name = safeInvoiceFilename(file.filename, kind === 'pdf' ? 'factura.pdf' : 'factura.xml')\n const filename = name.toLowerCase().endsWith(`.${kind}`) ? name : `${name}.${kind}`\n return new Response(bytes as BodyInit, {\n status: 200,\n headers: {\n 'Content-Type': FILE_TYPES[kind]!,\n 'Content-Length': String(bytes.byteLength),\n 'Content-Disposition': `attachment; filename=\"${filename}\"`,\n ...LOCKED_HEADERS,\n 'Content-Security-Policy': \"default-src 'none'; sandbox\",\n },\n })\n } catch (err) {\n return failureResponse(err)\n }\n}\n\nexport type PendingVoucherResponseOptions = {\n /** Client WITH the buyer's session. */\n storefront: StorefrontClient\n /** Checkout id (`PendingPayment.id`). */\n id: string\n /** `?descargar=1`: deliver it as a file instead of showing it. */\n download?: boolean\n shopName?: string\n locale?: string\n timeZone?: string\n signal?: AbortSignal\n}\n\n/**\n * The printable A4 voucher of a pending payment of the signed-in buyer. Served only when `id` is in HIS list (the list\n * is scoped by buyer in OPS): any other id is a 404. The document is self-contained, so its CSP allows nothing\n * external, only its own print script (with a per-response nonce) and inline styles.\n */\nexport async function pendingVoucherResponse({ storefront, id, download = false, shopName, locale, timeZone, signal }: PendingVoucherResponseOptions): Promise<Response> {\n try {\n const page = await storefront.customer.pendingPayments({ first: 100 }, signal ? { signal } : undefined)\n const item = page.nodes.find((p) => p.id === id)\n const voucher = item ? voucherOf(item) : null\n if (!item || !voucher) return textResponse(404, 'Ficha no encontrada')\n const nonce = btoa(String.fromCharCode(...crypto.getRandomValues(new Uint8Array(16))))\n const { renderVoucherDocument } = await import('./voucher-document.js')\n const html = renderVoucherDocument(voucher, { ...(shopName ? { shopName } : {}), ...(locale ? { locale } : {}), ...(timeZone ? { timeZone } : {}), printButton: !download, nonce })\n const safeId = id.replace(/[^A-Za-z0-9-]/g, '').slice(0, 8) || 'ficha'\n return new Response(html, {\n status: 200,\n headers: {\n 'Content-Type': 'text/html; charset=utf-8',\n ...LOCKED_HEADERS,\n // The download carries no script, so its policy allows none.\n 'Content-Security-Policy': `default-src 'none'; style-src 'unsafe-inline'; img-src data:; script-src ${download ? \"'none'\" : `'nonce-${nonce}'`}; base-uri 'none'; form-action 'none'; frame-ancestors 'self'`,\n ...(download ? { 'Content-Disposition': `attachment; filename=\"ficha-de-pago-${safeId}.html\"` } : {}),\n },\n })\n } catch (err) {\n return failureResponse(err)\n }\n}\n\n// Account settings (sessions, preferences, export, deletion): see ./settings-server.ts\nexport { createAccountSettingsAction, loadAccountSessions, loadAccountSettings, toSettingsFailure } from './settings-server.js'\nexport type { AccountSettingsAction, AccountSettingsData, AccountSettingsActionArgs, CreateAccountSettingsActionOptions, SettingsCookie } from './settings-server.js'\nexport type { AccountSettingsActionData, SettingsErrorCode, SettingsIntent } from './settings-types.js'\n","/**\n * Server side of the account settings (`@asteby/storefront-react/account/server`): `loadAccountSessions` for the loader\n * and `createAccountSettingsAction` for the action. No React, no router: Web `Request`/`Response` only.\n *\n * The browser never talks to OPS and never sees the buyer's token: the action reads it from the store's own cookie\n * (passed in), builds a client with it (`withCustomerToken`) and calls the contract. Answers carry codes\n * (`SettingsErrorCode`), never a server message, a value of the buyer or a credential; nothing is logged here.\n */\nimport { isStorefrontError, type Customer, type CustomerCapabilities, type CustomerSessionInfo, type StorefrontClient, type StorefrontError } from '@asteby/storefront'\nimport type { AuthCookie } from './server.js'\nimport type { AccountSettingsActionData, SettingsErrorCode, SettingsIntent } from './settings-types.js'\n\nexport type { AccountSettingsActionData, SettingsErrorCode, SettingsIntent } from './settings-types.js'\n\n/** The store's cookie for the buyer session token. React Router's `createCookie(...)` and Remix's fit as they are. */\nexport type SettingsCookie = AuthCookie & {\n parse(header: string | null): unknown | Promise<unknown>\n}\n\n/**\n * The buyer's sessions for the loader. NEVER throws: a store whose server is older than contract 1.9, an outage or an\n * expired session is `null`, and `<SessionsList sessions={null}>` degrades while the rest of the page renders.\n */\nexport async function loadAccountSessions(customer: StorefrontClient, options: { signal?: AbortSignal } = {}): Promise<CustomerSessionInfo[] | null> {\n try {\n return await customer.customer.sessions.list(options.signal ? { signal: options.signal } : undefined)\n } catch {\n return null\n }\n}\n\n/** Everything the settings page reads, each part on its own: a part that cannot be read is `null` and its section degrades. */\nexport type AccountSettingsData = {\n customer: Customer | null\n capabilities: CustomerCapabilities | null\n sessions: CustomerSessionInfo[] | null\n}\n\n/**\n * The loader of the whole settings page. NEVER throws and never fails as a whole: the three reads run together and a\n * failed one (older server, outage, expired session) is `null` for that part only. `customer` is `null` also when the\n * buyer's session is dead: the page should then send them to sign in.\n */\nexport async function loadAccountSettings(customer: StorefrontClient, options: { signal?: AbortSignal } = {}): Promise<AccountSettingsData> {\n const o = options.signal ? { signal: options.signal } : undefined\n const [profile, capabilities, sessions] = await Promise.all([\n customer.customer.get(o).catch(() => null),\n customer.customer.capabilities(o).catch(() => null),\n loadAccountSessions(customer, options),\n ])\n return { customer: profile, capabilities, sessions }\n}\n\nexport type CreateAccountSettingsActionOptions = {\n /** The store's own client (`sk_` token, no buyer). */\n storefront: StorefrontClient\n /** The store's cookie holding the buyer session token. */\n customerCookie: SettingsCookie\n /** Shopper IP for the per-shopper rate limit (see `clientIp` of the client). */\n clientIp?: (request: Request) => string | null | undefined\n}\n\nexport type AccountSettingsActionArgs = { request: Request }\n\nexport const fail = (intent: SettingsIntent | undefined, code: SettingsErrorCode, extra: { field?: string; retryAfter?: number } = {}): AccountSettingsActionData => ({\n ok: false,\n ...(intent ? { intent } : {}),\n error: { code, ...(extra.field ? { field: extra.field } : {}), ...(extra.retryAfter ? { retryAfter: extra.retryAfter } : {}) },\n})\n\n/** Maps what the SDK threw to the code the form shows. `ctx: 'credential'` is a call that checks the buyer's password or code. */\nexport function toSettingsFailure(err: unknown, intent: SettingsIntent | undefined, ctx: 'credential' | 'other' = 'other'): AccountSettingsActionData {\n if (!isStorefrontError(err)) return fail(intent, 'unavailable')\n const e: StorefrontError = err\n if (e.code === 'insufficient_scope') return fail(intent, 'unsupported')\n switch (e.status) {\n case 401:\n return fail(intent, 'session_expired')\n case 403:\n return fail(intent, e.code === 'reauth_required' ? 'reauth_required' : 'unsupported')\n case 404:\n return fail(intent, 'unsupported')\n case 409:\n return fail(intent, e.field === 'orders' ? 'blocked_orders' : e.field === 'pending_payments' ? 'blocked_pending_payments' : 'validation', e.field ? { field: e.field } : {})\n case 429: {\n const wait = typeof e.retryAfter === 'number' && Number.isFinite(e.retryAfter) && e.retryAfter > 0 ? Math.min(3600, Math.ceil(e.retryAfter)) : undefined\n return fail(intent, 'rate_limited', wait ? { retryAfter: wait } : {})\n }\n case 400:\n case 422:\n return ctx === 'credential' ? fail(intent, 'invalid_credential') : fail(intent, 'validation', e.field ? { field: e.field } : {})\n default:\n return fail(intent, 'unavailable')\n }\n}\n\n/**\n * The settings action: one `POST` form with an `intent` field.\n *\n * | intent | fields | result |\n * | ----------------------- | ------------ | ---------------------------------------- |\n * | `session-revoke` | session_id | closes that session (idempotent) |\n * | `session-revoke-others` | - | closes every session but this one |\n * | `locale` | locale | saves the language (`''` = the store's) |\n * | `notifications` | pref, pref_shown | saves the checked / unchecked boxes |\n *\n * It answers `AccountSettingsActionData` to render with the section that sent it. A buyer without a session is\n * `session_expired` (the store redirects to sign-in).\n */\nexport function createAccountSettingsAction(options: CreateAccountSettingsActionOptions) {\n const { storefront: sf, customerCookie } = options\n\n return async function settingsAction({ request }: AccountSettingsActionArgs): Promise<Response | AccountSettingsActionData> {\n // Every intent changes the account (or spends a sign-in code), and the buyer's cookie rides along: a form that\n // another site submits is refused before anything is read. `Sec-Fetch-Site` is set by the browser and cannot be\n // forged by a page; an older browser that omits it falls back to the cookie's SameSite.\n if (request.headers.get('Sec-Fetch-Site')?.toLowerCase() === 'cross-site') return fail(undefined, 'validation')\n const form = await request.formData().catch(() => null)\n if (!form) return fail(undefined, 'validation')\n const text = (name: string) => {\n const v = form.get(name)\n return typeof v === 'string' ? v : ''\n }\n const intent = text('intent') as SettingsIntent\n const raw = await customerCookie.parse(request.headers.get('Cookie'))\n const token = typeof raw === 'string' && raw ? raw : null\n if (!token) return fail(intent, 'session_expired')\n const ip = options.clientIp?.(request)\n const w = ip ? { clientIp: ip } : undefined\n const customer = sf.withCustomerToken(token)\n\n try {\n switch (intent) {\n case 'session-revoke': {\n const id = text('session_id').trim()\n if (!id || id.length > 64) return fail(intent, 'validation', { field: 'session_id' })\n // `others` is its own intent: never let the field spell it, so one button cannot do the other's work.\n if (id.toLowerCase() === 'others') return fail(intent, 'validation', { field: 'session_id' })\n await customer.customer.sessions.revoke(id, w)\n return { ok: true, intent }\n }\n case 'session-revoke-others': {\n await customer.customer.sessions.revokeOthers(w)\n return { ok: true, intent }\n }\n case 'locale': {\n const locale = text('locale').trim()\n if (locale.length > 35) return fail(intent, 'validation', { field: 'locale' })\n await customer.customer.update({ locale: locale || null }, w)\n return { ok: true, intent, saved: true }\n }\n case 'notifications': {\n const shown = form.getAll('pref_shown').filter((v): v is string => typeof v === 'string')\n const checked = new Set(form.getAll('pref').filter((v): v is string => typeof v === 'string'))\n if (shown.length === 0 || shown.length > 30) return fail(intent, 'validation', { field: 'preferences' })\n const notifications: Record<string, Record<string, boolean>> = {}\n for (const pair of shown) {\n const m = /^([a-z][a-z0-9_]{0,31}):([a-z][a-z0-9_]{0,31})$/.exec(pair)\n if (!m) return fail(intent, 'validation', { field: 'preferences' })\n ;(notifications[m[1]!] ??= {})[m[2]!] = checked.has(pair)\n }\n await customer.customer.update({ preferences: { notifications } }, w)\n return { ok: true, intent, saved: true }\n }\n default:\n return fail(undefined, 'validation')\n }\n } catch (err) {\n // A session that is already gone (404) is what the buyer wanted; a stranger's looks the same, by design.\n if (intent === 'session-revoke' && isStorefrontError(err) && err.status === 404) return { ok: true, intent }\n return toSettingsFailure(err, intent)\n }\n }\n}\n\nexport type AccountSettingsAction = ReturnType<typeof createAccountSettingsAction>\n"]}
|
|
@@ -1,6 +1,69 @@
|
|
|
1
|
-
import { StorefrontClient, CustomerCapabilities } from '@asteby/storefront';
|
|
2
|
-
import { A as AuthActionData } from './types-
|
|
3
|
-
export {
|
|
1
|
+
import { StorefrontClient, Customer, CustomerCapabilities, CustomerSessionInfo } from '@asteby/storefront';
|
|
2
|
+
import { A as AccountSettingsActionData, e as SettingsIntent, a as AuthActionData } from './settings-types-jxFQFFqP.cjs';
|
|
3
|
+
export { b as AuthErrorCode, c as AuthIntent, d as AuthStep, S as SettingsErrorCode } from './settings-types-jxFQFFqP.cjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Server side of the account settings (`@asteby/storefront-react/account/server`): `loadAccountSessions` for the loader
|
|
7
|
+
* and `createAccountSettingsAction` for the action. No React, no router: Web `Request`/`Response` only.
|
|
8
|
+
*
|
|
9
|
+
* The browser never talks to OPS and never sees the buyer's token: the action reads it from the store's own cookie
|
|
10
|
+
* (passed in), builds a client with it (`withCustomerToken`) and calls the contract. Answers carry codes
|
|
11
|
+
* (`SettingsErrorCode`), never a server message, a value of the buyer or a credential; nothing is logged here.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/** The store's cookie for the buyer session token. React Router's `createCookie(...)` and Remix's fit as they are. */
|
|
15
|
+
type SettingsCookie = AuthCookie & {
|
|
16
|
+
parse(header: string | null): unknown | Promise<unknown>;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* The buyer's sessions for the loader. NEVER throws: a store whose server is older than contract 1.9, an outage or an
|
|
20
|
+
* expired session is `null`, and `<SessionsList sessions={null}>` degrades while the rest of the page renders.
|
|
21
|
+
*/
|
|
22
|
+
declare function loadAccountSessions(customer: StorefrontClient, options?: {
|
|
23
|
+
signal?: AbortSignal;
|
|
24
|
+
}): Promise<CustomerSessionInfo[] | null>;
|
|
25
|
+
/** Everything the settings page reads, each part on its own: a part that cannot be read is `null` and its section degrades. */
|
|
26
|
+
type AccountSettingsData = {
|
|
27
|
+
customer: Customer | null;
|
|
28
|
+
capabilities: CustomerCapabilities | null;
|
|
29
|
+
sessions: CustomerSessionInfo[] | null;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* The loader of the whole settings page. NEVER throws and never fails as a whole: the three reads run together and a
|
|
33
|
+
* failed one (older server, outage, expired session) is `null` for that part only. `customer` is `null` also when the
|
|
34
|
+
* buyer's session is dead: the page should then send them to sign in.
|
|
35
|
+
*/
|
|
36
|
+
declare function loadAccountSettings(customer: StorefrontClient, options?: {
|
|
37
|
+
signal?: AbortSignal;
|
|
38
|
+
}): Promise<AccountSettingsData>;
|
|
39
|
+
type CreateAccountSettingsActionOptions = {
|
|
40
|
+
/** The store's own client (`sk_` token, no buyer). */
|
|
41
|
+
storefront: StorefrontClient;
|
|
42
|
+
/** The store's cookie holding the buyer session token. */
|
|
43
|
+
customerCookie: SettingsCookie;
|
|
44
|
+
/** Shopper IP for the per-shopper rate limit (see `clientIp` of the client). */
|
|
45
|
+
clientIp?: (request: Request) => string | null | undefined;
|
|
46
|
+
};
|
|
47
|
+
type AccountSettingsActionArgs = {
|
|
48
|
+
request: Request;
|
|
49
|
+
};
|
|
50
|
+
/** Maps what the SDK threw to the code the form shows. `ctx: 'credential'` is a call that checks the buyer's password or code. */
|
|
51
|
+
declare function toSettingsFailure(err: unknown, intent: SettingsIntent | undefined, ctx?: 'credential' | 'other'): AccountSettingsActionData;
|
|
52
|
+
/**
|
|
53
|
+
* The settings action: one `POST` form with an `intent` field.
|
|
54
|
+
*
|
|
55
|
+
* | intent | fields | result |
|
|
56
|
+
* | ----------------------- | ------------ | ---------------------------------------- |
|
|
57
|
+
* | `session-revoke` | session_id | closes that session (idempotent) |
|
|
58
|
+
* | `session-revoke-others` | - | closes every session but this one |
|
|
59
|
+
* | `locale` | locale | saves the language (`''` = the store's) |
|
|
60
|
+
* | `notifications` | pref, pref_shown | saves the checked / unchecked boxes |
|
|
61
|
+
*
|
|
62
|
+
* It answers `AccountSettingsActionData` to render with the section that sent it. A buyer without a session is
|
|
63
|
+
* `session_expired` (the store redirects to sign-in).
|
|
64
|
+
*/
|
|
65
|
+
declare function createAccountSettingsAction(options: CreateAccountSettingsActionOptions): ({ request }: AccountSettingsActionArgs) => Promise<Response | AccountSettingsActionData>;
|
|
66
|
+
type AccountSettingsAction = ReturnType<typeof createAccountSettingsAction>;
|
|
4
67
|
|
|
5
68
|
/**
|
|
6
69
|
* Server side of the account screen (`@asteby/storefront-react/account/server`): `loadAuthCapabilities` for the loader
|
|
@@ -109,4 +172,4 @@ type PendingVoucherResponseOptions = {
|
|
|
109
172
|
*/
|
|
110
173
|
declare function pendingVoucherResponse({ storefront, id, download, shopName, locale, timeZone, signal }: PendingVoucherResponseOptions): Promise<Response>;
|
|
111
174
|
|
|
112
|
-
export { type AuthAction, type AuthActionArgs, AuthActionData, type AuthCookie, type CreateAuthActionOptions, type InvoiceFileResponseOptions, type LoadAuthCapabilitiesOptions, MAX_INVOICE_FILE_BYTES, type PendingVoucherResponseOptions, SAFE_AUTH_CAPABILITIES, createAuthAction, invoiceFileResponse, loadAuthCapabilities, pendingVoucherResponse, safeNextPath };
|
|
175
|
+
export { type AccountSettingsAction, type AccountSettingsActionArgs, AccountSettingsActionData, type AccountSettingsData, type AuthAction, type AuthActionArgs, AuthActionData, type AuthCookie, type CreateAccountSettingsActionOptions, type CreateAuthActionOptions, type InvoiceFileResponseOptions, type LoadAuthCapabilitiesOptions, MAX_INVOICE_FILE_BYTES, type PendingVoucherResponseOptions, SAFE_AUTH_CAPABILITIES, type SettingsCookie, SettingsIntent, createAccountSettingsAction, createAuthAction, invoiceFileResponse, loadAccountSessions, loadAccountSettings, loadAuthCapabilities, pendingVoucherResponse, safeNextPath, toSettingsFailure };
|
package/dist/account-server.d.ts
CHANGED
|
@@ -1,6 +1,69 @@
|
|
|
1
|
-
import { StorefrontClient, CustomerCapabilities } from '@asteby/storefront';
|
|
2
|
-
import { A as AuthActionData } from './types-
|
|
3
|
-
export {
|
|
1
|
+
import { StorefrontClient, Customer, CustomerCapabilities, CustomerSessionInfo } from '@asteby/storefront';
|
|
2
|
+
import { A as AccountSettingsActionData, e as SettingsIntent, a as AuthActionData } from './settings-types-jxFQFFqP.js';
|
|
3
|
+
export { b as AuthErrorCode, c as AuthIntent, d as AuthStep, S as SettingsErrorCode } from './settings-types-jxFQFFqP.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Server side of the account settings (`@asteby/storefront-react/account/server`): `loadAccountSessions` for the loader
|
|
7
|
+
* and `createAccountSettingsAction` for the action. No React, no router: Web `Request`/`Response` only.
|
|
8
|
+
*
|
|
9
|
+
* The browser never talks to OPS and never sees the buyer's token: the action reads it from the store's own cookie
|
|
10
|
+
* (passed in), builds a client with it (`withCustomerToken`) and calls the contract. Answers carry codes
|
|
11
|
+
* (`SettingsErrorCode`), never a server message, a value of the buyer or a credential; nothing is logged here.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/** The store's cookie for the buyer session token. React Router's `createCookie(...)` and Remix's fit as they are. */
|
|
15
|
+
type SettingsCookie = AuthCookie & {
|
|
16
|
+
parse(header: string | null): unknown | Promise<unknown>;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* The buyer's sessions for the loader. NEVER throws: a store whose server is older than contract 1.9, an outage or an
|
|
20
|
+
* expired session is `null`, and `<SessionsList sessions={null}>` degrades while the rest of the page renders.
|
|
21
|
+
*/
|
|
22
|
+
declare function loadAccountSessions(customer: StorefrontClient, options?: {
|
|
23
|
+
signal?: AbortSignal;
|
|
24
|
+
}): Promise<CustomerSessionInfo[] | null>;
|
|
25
|
+
/** Everything the settings page reads, each part on its own: a part that cannot be read is `null` and its section degrades. */
|
|
26
|
+
type AccountSettingsData = {
|
|
27
|
+
customer: Customer | null;
|
|
28
|
+
capabilities: CustomerCapabilities | null;
|
|
29
|
+
sessions: CustomerSessionInfo[] | null;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* The loader of the whole settings page. NEVER throws and never fails as a whole: the three reads run together and a
|
|
33
|
+
* failed one (older server, outage, expired session) is `null` for that part only. `customer` is `null` also when the
|
|
34
|
+
* buyer's session is dead: the page should then send them to sign in.
|
|
35
|
+
*/
|
|
36
|
+
declare function loadAccountSettings(customer: StorefrontClient, options?: {
|
|
37
|
+
signal?: AbortSignal;
|
|
38
|
+
}): Promise<AccountSettingsData>;
|
|
39
|
+
type CreateAccountSettingsActionOptions = {
|
|
40
|
+
/** The store's own client (`sk_` token, no buyer). */
|
|
41
|
+
storefront: StorefrontClient;
|
|
42
|
+
/** The store's cookie holding the buyer session token. */
|
|
43
|
+
customerCookie: SettingsCookie;
|
|
44
|
+
/** Shopper IP for the per-shopper rate limit (see `clientIp` of the client). */
|
|
45
|
+
clientIp?: (request: Request) => string | null | undefined;
|
|
46
|
+
};
|
|
47
|
+
type AccountSettingsActionArgs = {
|
|
48
|
+
request: Request;
|
|
49
|
+
};
|
|
50
|
+
/** Maps what the SDK threw to the code the form shows. `ctx: 'credential'` is a call that checks the buyer's password or code. */
|
|
51
|
+
declare function toSettingsFailure(err: unknown, intent: SettingsIntent | undefined, ctx?: 'credential' | 'other'): AccountSettingsActionData;
|
|
52
|
+
/**
|
|
53
|
+
* The settings action: one `POST` form with an `intent` field.
|
|
54
|
+
*
|
|
55
|
+
* | intent | fields | result |
|
|
56
|
+
* | ----------------------- | ------------ | ---------------------------------------- |
|
|
57
|
+
* | `session-revoke` | session_id | closes that session (idempotent) |
|
|
58
|
+
* | `session-revoke-others` | - | closes every session but this one |
|
|
59
|
+
* | `locale` | locale | saves the language (`''` = the store's) |
|
|
60
|
+
* | `notifications` | pref, pref_shown | saves the checked / unchecked boxes |
|
|
61
|
+
*
|
|
62
|
+
* It answers `AccountSettingsActionData` to render with the section that sent it. A buyer without a session is
|
|
63
|
+
* `session_expired` (the store redirects to sign-in).
|
|
64
|
+
*/
|
|
65
|
+
declare function createAccountSettingsAction(options: CreateAccountSettingsActionOptions): ({ request }: AccountSettingsActionArgs) => Promise<Response | AccountSettingsActionData>;
|
|
66
|
+
type AccountSettingsAction = ReturnType<typeof createAccountSettingsAction>;
|
|
4
67
|
|
|
5
68
|
/**
|
|
6
69
|
* Server side of the account screen (`@asteby/storefront-react/account/server`): `loadAuthCapabilities` for the loader
|
|
@@ -109,4 +172,4 @@ type PendingVoucherResponseOptions = {
|
|
|
109
172
|
*/
|
|
110
173
|
declare function pendingVoucherResponse({ storefront, id, download, shopName, locale, timeZone, signal }: PendingVoucherResponseOptions): Promise<Response>;
|
|
111
174
|
|
|
112
|
-
export { type AuthAction, type AuthActionArgs, AuthActionData, type AuthCookie, type CreateAuthActionOptions, type InvoiceFileResponseOptions, type LoadAuthCapabilitiesOptions, MAX_INVOICE_FILE_BYTES, type PendingVoucherResponseOptions, SAFE_AUTH_CAPABILITIES, createAuthAction, invoiceFileResponse, loadAuthCapabilities, pendingVoucherResponse, safeNextPath };
|
|
175
|
+
export { type AccountSettingsAction, type AccountSettingsActionArgs, AccountSettingsActionData, type AccountSettingsData, type AuthAction, type AuthActionArgs, AuthActionData, type AuthCookie, type CreateAccountSettingsActionOptions, type CreateAuthActionOptions, type InvoiceFileResponseOptions, type LoadAuthCapabilitiesOptions, MAX_INVOICE_FILE_BYTES, type PendingVoucherResponseOptions, SAFE_AUTH_CAPABILITIES, type SettingsCookie, SettingsIntent, createAccountSettingsAction, createAuthAction, invoiceFileResponse, loadAccountSessions, loadAccountSettings, loadAuthCapabilities, pendingVoucherResponse, safeNextPath, toSettingsFailure };
|