feat(F-158): completed feature

This commit is contained in:
chattie
2026-08-22 17:50:55 +02:00
parent 7159baf851
commit 3e1a447e43
16 changed files with 348 additions and 77 deletions

View File

@@ -0,0 +1,20 @@
# F-158 — Diseño
## Decisión
Separar explícitamente URL pública y URL privada:
- Navegador POS: siempre usa `/api` del mismo origen (`:3006`).
- Route handler Next.js: usa `POS_BACKEND_URL`, server-only, con fallback `http://127.0.0.1:3000`.
- No exponer ni incrustar `NEXT_PUBLIC_API_URL` en el bundle.
## Proxy
- Construye destino desde el catch-all path y query string.
- Reenvía Cookie, Content-Type y `x-terminal-id`.
- Propaga status, Content-Type y todos los `Set-Cookie` del backend.
- GET y POST cubren las operaciones actuales del cliente POS.
## Desarrollo LAN
`allowedDevOrigins` incluye `192.168.18.93` y `localhost` para recursos Next/HMR.
## Seguridad
La URL backend queda server-only. Los paths proceden del segmento catch-all y se concatenan contra una base fija, sin aceptar host suministrado por el cliente.

View File

@@ -0,0 +1,14 @@
# F-158 — Documentación
## Acceso LAN
El TPV se abre en `http://192.168.18.93:3006`. Todas las llamadas del navegador permanecen en ese origen mediante `/api`; solo el servidor Next accede al backend en `127.0.0.1:3000`.
## Primera vinculación
Después del login, un dispositivo sin terminal muestra la pantalla **Vincular terminal**. Debe introducir el código de 8 caracteres. La vinculación se guarda en una cookie HttpOnly durante un año.
## Entorno local actual
- Terminal: `TPV Principal`
- Código de vinculación: `B794401C`
- Backend: puerto 3000
- Admin: puerto 3004
- POS: puerto 3006

View File

@@ -0,0 +1,24 @@
# F-158 — Implementer
## Implementación
- El cliente POS usa exclusivamente `/api`, nunca `localhost:3000` desde el navegador.
- El proxy Next usa `POS_BACKEND_URL` server-only con fallback `127.0.0.1:3000`.
- El proxy reenvía sesión, terminal y Content-Type; propaga `Set-Cookie` del login.
- La vinculación guarda `pos_terminal_id` como cookie HttpOnly durante un año y el proxy la traduce a `x-terminal-id`.
- Middleware reconoce la cookie real `mdv_session` además de nombres legacy.
- Añadida pantalla de vinculación inicial de 8 caracteres y estados de error/reintento.
- Corregidos errores TypeScript previos del esqueleto POS (`NextLayout`, tipos de config/customer/catch).
- `allowedDevOrigins` permite `192.168.18.93` y `localhost`.
## Evidencia
- `cd project/apps/pos && npm run build`: PASS, 4 rutas + middleware.
- `cd project/apps/pos && npx tsc --noEmit`: PASS.
- `cd project && node_modules/.bin/tsc --noEmit`: PASS.
- Login proxy: HTTP 200 + cookie `mdv_session`.
- Bind proxy: HTTP 200 + cookie `pos_terminal_id`.
- Config proxy autenticado/vinculado: HTTP 200 con store, terminal y métodos de pago.
- Servicios persistentes: 3000, 3004 y 3006 escuchando.
- `./scripts/verify.sh`: PASS.
## Configuración local
Se creó `TPV Principal` para la tienda por defecto. Código de vinculación: `B794401C`.

View File

@@ -0,0 +1,16 @@
{
"feature_id": "F-158",
"agent": "leader",
"stage": "close",
"verdict": "APPROVED",
"summary": "POS LAN usa proxy same-origin y completa login, vinculación y config sin localhost del navegador.",
"checks": [
{ "item": "Reviewer approved", "ok": true },
{ "item": "Security approved", "ok": true },
{ "item": "QA approved", "ok": true },
{ "item": "POS build passed", "ok": true },
{ "item": "Runtime acceptance passed", "ok": true },
{ "item": "verify.sh passed", "ok": true }
],
"issues": []
}

View File

@@ -0,0 +1,16 @@
{
"feature_id": "F-158",
"agent": "qa",
"stage": "qa_gate",
"verdict": "APPROVED",
"summary": "Flujo LAN completo validado contra 192.168.18.93:3006.",
"checks": [
{ "item": "Login through POS proxy", "ok": true, "evidence": "HTTP 200 and mdv_session cookie" },
{ "item": "Terminal bind through POS proxy", "ok": true, "evidence": "HTTP 200 and pos_terminal_id cookie" },
{ "item": "POS config through proxy", "ok": true, "evidence": "HTTP 200 with store, terminal and payment methods" },
{ "item": "No direct browser backend request", "ok": true, "evidence": "api-client uses /api" },
{ "item": "Build and types", "ok": true, "evidence": "POS build and both TypeScript checks passed" },
{ "item": "Runtime services", "ok": true, "evidence": "Ports 3000, 3004 and 3006 listening" }
],
"issues": []
}

View File

@@ -0,0 +1,15 @@
{
"feature_id": "F-158",
"agent": "reviewer",
"stage": "review_gate",
"verdict": "APPROVED",
"summary": "El POS elimina la dependencia de localhost en navegador y completa login, vinculación y config por proxy same-origin.",
"checks": [
{ "item": "No browser localhost URL", "ok": true, "evidence": "api-client base is /api; source search has no NEXT_PUBLIC_API_URL" },
{ "item": "Proxy contract", "ok": true, "evidence": "Cookies, terminal header, status and content type forwarded" },
{ "item": "Terminal persistence", "ok": true, "evidence": "HttpOnly pos_terminal_id cookie translated to x-terminal-id" },
{ "item": "POS production build", "ok": true, "evidence": "Next.js 15 build passed" },
{ "item": "Runtime flow", "ok": true, "evidence": "login 200, bind 200, config 200 through :3006" }
],
"issues": []
}

View File

@@ -0,0 +1,14 @@
{
"feature_id": "F-158",
"agent": "security",
"stage": "security_gate",
"verdict": "APPROVED",
"summary": "La URL backend queda server-only y las cookies de sesión/terminal se mantienen HttpOnly y same-origin.",
"checks": [
{ "item": "Backend URL not public", "ok": true, "evidence": "POS_BACKEND_URL is only read in server route handler" },
{ "item": "Terminal cookie protection", "ok": true, "evidence": "HttpOnly, SameSite=Lax, Secure in production" },
{ "item": "Fixed upstream host", "ok": true, "evidence": "Client controls path only; upstream base comes from trusted env" },
{ "item": "No broad header forwarding", "ok": true, "evidence": "Only cookie, content-type and x-terminal-id forwarded" }
],
"issues": []
}