Commit Graph
13 Commits
Author SHA1 Message Date
mzspicoli 032fe1a348 fix(push): localize server notifications in pt-BR 2026-08-24 18:02:35 +02:00
Duarte Santos 8b99a644ed Release v1.2.9: Aktivitaetslog im Admin-Dashboard, Demo wieder online
Wer sich anmeldet, wer es vergeblich versucht und was ein Admin aendert, stand
bisher nirgends — der Server hat schlicht nichts protokolliert.

Aktivitaetslog:
- ./data/audit.log, eine JSON-Zeile pro Event, angehaengt statt neu geschrieben.
  Bewusst NICHT in db.json: die Datei wird bei jedem Save komplett neu geschrieben,
  und der Login-Handshake ist unauthentifiziert — ein Log darin haette aus einem
  Muell-Request einen vollen Rewrite gemacht.
- Aufbewahrung ist eine Obergrenze, kein Archiv: AUDIT_MAX (5000) bzw. AUDIT_DAYS (90).
- Per Default an (AUDIT_LOG=0 schaltet es ganz ab). IP-Adressen per Default AUS;
  AUDIT_IP=net speichert nur das Netz, full die ganze Adresse. Nie der User-Agent,
  nie die Passkey-ID eines Fehlversuchs, nie ein abgelehnter Invite-Code.
- Adresse kommt aus CF-Connecting-IP, dann X-Forwarded-For, dann X-Real-IP —
  ein Cloudflare-Tunnel schreibt den Besucher NICHT in XFF, dort steht sonst nur
  der Tunnel selbst und sieht dabei voellig plausibel aus.
- Loeschen wird selbst protokolliert, die Event-IDs zaehlen weiter: die Luecke bleibt sichtbar.
- Neue Karte in views/Admin.jsx (Filter, "Show more"), Aufbereitung in lib/audit.js
  mit 20 Tests. GET /api/admin/audit und POST /api/admin/audit/clear, beide hinter requireAdmin.

Demo:
- Die Live-Demo laeuft wieder, jetzt auf der Projektseite selbst statt auf GitHub Pages:
  opengym.duarte-santos.ch/demo/. Das eingebettete Telefon auf der Startseite geht damit auch
  wieder — es muss derselbe Host sein, X-Frame-Options ist SAMEORIGIN.

Doku: README-Config-Tabelle, .env.example, SELF_HOSTING, SECURITY (inkl. der
api/server.js-Zeilenverweise, die wieder stimmen).
2026-08-23 16:12:35 +02:00
Duarte Santos 9daf637044 Gastmodus abschaltbar: ALLOW_GUEST=0 nimmt die Tuer ohne Konto raus (#42) 2026-08-07 08:10:19 +02:00
Duarte Santos accc3c1038 Sessions you can actually end, and invite codes worth guessing at
SECURITY.md documented three weaknesses two hours ago. Documented is better than
hidden; fixed is better than documented.

Sessions were a signed cookie the server trusted for a year, and /api/logout
only cleared it in the browser you clicked it in — a copy left on a shared
machine stayed good until it expired, and the only way to end it was deleting
./data/secret and signing out the entire instance. The cookie payload now
carries the user's session version, and POST /api/logout/all bumps it, which
kills every cookie that account ever had. Settings grows a "Sign out
everywhere" row for it.

Cookies already in the wild have no version field. They read as version 0 and
match a user who has never bumped, so nobody is signed out by this deploy and
db.json needs no migration — sv appears lazily on the first bump. Verified
against a server running the new code with a db.json shaped like the live one.

Session default drops from 365 days to 90, overridable with SESSION_DAYS. The
expiry is baked into each cookie when issued, so lowering it never cuts an
existing session short.

Invite codes go from 32 to 64 bits. The app has no rate limiting by design and
/api/register/options answers whether a code is valid, so the code itself has to
be the part not worth guessing. Existing codes still work — validation is an
exact string compare. Unused old ones are worth revoking and reissuing.

What did not change: no rate limiting, still the reverse proxy's job, still the
first caveat in SECURITY.md. requireUserVerification stays false — raising it
could refuse passkeys that already exist, which is a lockout, not a fix.
2026-07-31 19:32:57 +02:00
Duarte Santos f3ba05aece Admin dashboard (phase 2): live 'training now' heartbeat + release v1.1.4
Backend: in-memory presence map + POST /api/activity heartbeat (authed);
each /api/admin/users row carries a fresh 'live' snapshot (routine,
exercise x/y, sets done/total, started-at) with a ~70s TTL. Disabling a
user clears their presence immediately.

Frontend: the workout screen pings /api/activity every 20s (signed-in
only) and sends a leave signal on unmount (fetch + sendBeacon). The
dashboard gains a 'Training now' section and live markers, auto-
refreshing every 15s.

Cuts the complete admin-dashboard feature (phases 1+2) as v1.1.4.
2026-07-22 02:06:19 +02:00
Duarte Santos 046217079c Admin dashboard (phase 1): users, disable, invite-gated signup
Adds an operator dashboard for self-hosters, gated on a passkey-
authenticated admin flag (ADMIN_UIDS env) and enforced server-side.

Backend:
- ADMIN_UIDS / INVITE_ONLY env (both off by default, OSS-friendly).
- Invite codes in db.json; /api/register gated when INVITE_ONLY, code
  burned on successful signup.
- disabled users are rejected by readSession — locked out everywhere.
- /api/admin/{users,user,user/disable,invites,invites/new,invites/revoke}
  behind an admin guard; /api/config exposes invite_only to the login UI.
- admin flag surfaced on /api/me, register/verify, login/verify.

Frontend:
- New /admin route + Settings link, shown only to admins: user list with
  workout counts and last-sync, disable/enable, invite generation, and a
  per-user workout-history drill-down.
- Registration sheet shows an invite-code field when the instance is
  invite-only.

Phase 2 (live 'training now' via a heartbeat) is separate.
2026-07-22 01:58:33 +02:00
Duarte Santos c5cf31e2ca Tighten reminder timing: 10s check interval + high-urgency push
Reminder loop only checked once a minute, unaligned to the minute
boundary, so it could sit up to 59s on the target time before noticing
- now capped at ~9s. Also mark pushes as urgency:'high', the one lever
we actually have over delivery speed (iOS/Android throttle low-urgency
background push harder under battery saving). Remaining delivery lag
after that is Apple/Google's own push relay scheduling, not something
we control from here.
2026-07-21 12:25:24 +02:00
Duarte Santos 10fa150d09 Flush pending state save immediately when tab backgrounds/closes
Settings changes (like the reminder time) were saved via a 1.5s
debounce; closing or switching away from the tab right after an edit
could kill that pending save before it reached the server, silently
losing the change. Now flushed on visibilitychange instead of relying
on the timer alone.

Also confirmed via a live server-side test (bypassing the client
entirely) that the reminder loop itself fires correctly — trimmed the
verbose per-tick debug log added for that test, kept the one for an
actual match.
2026-07-21 12:00:49 +02:00
Duarte Santos 0ac531acb8 Fix workout reminder using the server's timezone instead of the user's
The reminder compared 'now' against a single TZ env var, so it only
worked correctly for whoever's local time happened to match the
server's. The browser now reports its own IANA timezone (auto-
detected, no picker) and stores it with the reminder; the server
computes each user's local time/date individually via Intl, and the
client re-stamps it on every app load so it follows you when you
travel.
2026-07-21 11:46:45 +02:00
Duarte Santos 7dea9ccfcc Log push send failures instead of swallowing them silently
sendPush caught every webpush.sendNotification error to clean up
expired subscriptions, but never logged anything for other failure
modes — made a delivery problem indistinguishable from 'nothing to
send' when debugging.
2026-07-21 11:42:40 +02:00
Duarte Santos 4c2b6344f7 Add push notifications: rest-timer alert + workout-day reminder
Web Push (VAPID) backend: keys auto-generated on first run, per-user
subscriptions, one new dependency (web-push). The rest timer schedules
a server-side push on start/extend and cancels it on skip or on-screen
completion, so it only actually fires if the tab got suspended before
finishing. A per-minute check sends an optional daily reminder on days
with a planned routine that hasn't been logged yet.

Opt in per-profile in Settings — requires a signed-in passkey profile.
2026-07-21 11:07:10 +02:00
Duarte Santos 3333b4decd openGym: Open-Source-Release als Self-Hosting-App
Rebranding GymLog → openGym. Ein-Befehl-Self-Hosting via Docker Compose:
web (nginx serviert App + Proxy /api → api, ein Origin für Passkeys), api
(Node/WebAuthn), media-Service lädt Übungs-GIFs beim ersten Start automatisch.
Passkey-Domain über .env konfigurierbar (RP_ID/ORIGIN/WEB_PORT/RP_NAME),
Secure-Cookie nur bei HTTPS (http://localhost funktioniert). MIT-Lizenz,
README fürs Self-Hosting, docs/SELF_HOSTING.md, CONTRIBUTING.md.

Standalone-Stack Ende-zu-Ende getestet (Passkey-Register/-Login, Daten-Sync,
User-Isolation über den Proxy auf http://localhost).
2026-07-19 16:18:34 +02:00
Duarte Santos 29f5f64f8e GymLog: Gym- & Körpergewicht-Tracker — PWA mit Passkey-Login
Frontend: Static-SPA (Vanilla JS) — Dashboard, Wochenplan mit Per-Tag-Umplanung,
geführter Workout-Flow (Körpergewicht-Abfrage, Set-Logging, Rest-Timer, PR-Erkennung,
Gewichts-Bestätigung pro Übung), Activity-Heatmap, Kraft- & Gewichts-Charts,
Übungs-Bibliothek (1324 Übungen, autoplay GIFs), Swipe-Sheets, PWA/offline.

Backend: Node + @simplewebauthn — Passkey-Registrierung/-Login (Face ID),
HMAC-Session-Cookies, Per-User-State-Sync mit JSON-File-Storage.

Übungsdaten aus hasaneyldrm/exercises-dataset (Medien via scripts/fetch-media.sh).
2026-07-18 22:53:08 +02:00