Commit graph

13 commits

Author SHA1 Message Date
sjcoetzeesj-coder
b3eaeb7287 feat(auth): password gate replacing the IP-only middleware guard
middleware.ts previously 404'd every external request, which meant the
app was unusable once hosted. There are no per-user accounts, so this
adds a single-password gate:

- /login page + POST /api/auth/login, POST /api/auth/logout
- lib/auth.ts: HMAC-SHA256 signed session cookie (lib/auth), Web Crypto
  only so the same code runs in Edge middleware and Node handlers
- middleware now admits: the signing flow (unchanged, still public),
  /login + /api/auth/*, local requests, and valid sessions. Everything
  else redirects to /login (pages) or returns 401 JSON (API calls).
- password compared with a constant-time compare, wrong attempts
  delayed 600ms to slow online guessing
- cookie is HttpOnly + SameSite=Lax, 12h, Secure when x-forwarded-proto
  says https (Coolify serves the proxy on http today)

APP_PASSWORD / AUTH_SECRET added to .env.example, with a warning: an
unquoted # in an env value starts a comment, which silently truncated
the first generated password and made login fail.

Verified against a real built server: anon->307 /login, anon API->401,
wrong password->401, correct password->200+cookie, signed-in request
reaches PocketBase, /resign/ still 200 without a cookie, forged
cookie->401.
2026-10-18 18:39:27 +02:00
sjcoetzeesj-coder
21db4d0e64 fix: resolve all 7 type errors that broke the production build
next build runs 'Linting and checking validity of types' and fails on
the first type error, so the Coolify image build died at
app/api/cipc/search/route.ts:640. These errors were pre-existing but
only surface on next build (npm run dev does not type check).

- cipc/search/route.ts: coerce spawnSync stdout/stderr with toString();
  result is typed as the un-overloaded return, so they are string|Buffer
- group-report pdf+email: use fetchCollection<YsterbaardGroup> instead of
  an invalid cast; normalise description null -> undefined for ReportData
- CipcExplorer (cipc + cipc-2): split the state ternary into two returns;
  the RowState union correlates state with differs, so 'diff' | 'match'
  matched neither variant
- ComplianceTreeGrid: ar_non_compliance_date is optional; the API omits it
  and this component never reads it

Verified: tsc --noEmit 0 errors, next build exit 0, standalone output ok.
2026-10-18 15:48:50 +02:00
sjcoetzeesj-coder
9ccd36ec93 build: make Dockerfile Coolify-ready
- add .dockerignore: without it the build context shipped .env.local
  (PB_TOKEN + CIPC passwords), node_modules and the full .git history
- bake NEXT_PUBLIC_PB_URL / NEXT_PUBLIC_BASE_URL / NEXT_PUBLIC_APP_URL
  as build args; NEXT_PUBLIC_PB_URL was read by client components but
  never supplied, so browser-side PocketBase calls would break
- docker-compose: same build args + Telegram runtime env
- document that agent-browser / PDFD sidecar routes stay on the PC
2026-10-18 15:30:20 +02:00
sjcoetzeesj-coder
11d0178ab1 feat: commit Workflow app source; move CIPC credentials to env
Adds the full Next.js app (app/, components/, lib/, scripts/, assets/,
docs/, Dockerfile, compose, configs) to version control.

Security:
- CIPC BizPortal customer-code logins (Login 1 + Login 3) now read
  CIPC_LOGIN1_CODE / CIPC_LOGIN1_PASSWORD / CIPC_LOGIN3_CODE /
  CIPC_LOGIN3_PASSWORD from .env.local instead of source.
- BizPortal personal login in apply-bizportal route reads
  BIZPORTAL_ID_NO / BIZPORTAL_PASSWORD.
- Added .env.example as the committed template.

.gitignore excludes .env*, node_modules, .next, logs, sqlite, Playwright
storage_state.json (live CIPC cookies), scratch dirs, client PDFs and
debug screenshots.
2026-10-18 15:21:45 +02:00
sjcoetzeesj-coder
f5c7960c6f fix(notes): sort by -id instead of -created (PB 400 on fresh collection sort=created)
PB returns 400 when sorting a freshly imported collection by autodate system
fields (created, updated) — those fields aren't yet exposed for sorting.
id always works.
2026-09-17 13:19:15 +02:00
sjcoetzeesj-coder
e934770a03 fix(notes): render collection-missing error inline instead of throwing 2026-09-16 14:58:43 +02:00
sjcoetzeesj-coder
6101ac550d chore(report): remove stale GET_debug helper that broke Next 14 type checks 2026-09-16 14:54:49 +02:00
sjcoetzeesj-coder
87a51fbce7 feat(notes): add PATCH + DELETE /api/notes/[id] handlers 2026-09-16 14:30:46 +02:00
sjcoetzeesj-coder
04e91a4096 feat(notes): add POST /api/notes handler 2026-09-16 14:30:04 +02:00
sjcoetzeesj-coder
66e255ce30 feat(notes): add NotesList client component with CRUD + filters 2026-09-16 14:29:35 +02:00
sjcoetzeesj-coder
ee4dfd79fb feat(notes): add /notes server page 2026-09-16 14:28:52 +02:00
sjcoetzeesj-coder
11dcb49b9f feat(notes): add Notes tab to NavBar at index 1 2026-09-16 14:28:12 +02:00
sjcoetzeesj-coder
f3e297b9c8 feat(notes): add YsterbaardNote type 2026-09-16 14:26:52 +02:00