mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-30 16:33:16 +00:00
55fc5f6679
A journey's share link can now ask readers for a password, stop working on a date its owner picks, and count how often it was opened (#2553, #1702, no password, no expiry and no views. - journey_share_tokens gains password_hash, password_version, expires_at, view_count and last_viewed_at (append-only migration, SQLite and Postgres, added only where missing). - The password is hashed with bcrypt at the account cost. POST /api/public/journey/:token/unlock checks it, rate limited per address and link (only refusals count), and sets an httpOnly cookie scoped to the link's API path holding an HMAC over the token and the password version. Secure follows the request, so plain-HTTP installs keep working. Changing or removing the password raises the version and locks every old cookie out. - Every public route, the photo proxies included, first checks the link: 404 unknown, 410 expired (JOURNEY_LINK_EXPIRED), 401 locked (JOURNEY_PASSWORD_REQUIRED). - Saving the share switches keeps the password and the expiry; the owner's read returns has_password, expires_at, view_count and last_viewed_at, never the hash, and none of it reaches the public payload. - A reader is counted once a day per address and browser, in an in-memory store behind an injectable port; a restart may count them again. - create_journey_share_link takes password and expires_at like the REST route; get_journey_share_link reports has_password.