trails/apps/planner
Ullrich Schäfer 0917de6080
fix(planner): keep journal callback token off the client (#2 Phase A)
The Save-to-Journal flow had the browser fetch the journal with a
\`Bearer \${callbackToken}\` header. The JWT was visible in DevTools,
exfiltratable via any XSS or browser extension, and the planner's
\`loader\` shipped it down to the client as part of the page payload.

Now:

- **New action**: \`POST /api/save-to-journal\` (\`routes/api.save-to-journal.ts\`).
  Body: \`{ sessionId, gpx }\`. The action loads \`callbackUrl\` +
  \`callbackToken\` from \`planner.sessions\` (set at /new time when the
  user came from the journal), POSTs to the journal server-to-server
  with the Bearer, and forwards the response.

- **\`SaveToJournalButton\`**: drops the \`callbackUrl\` + \`callbackToken\`
  props. Takes \`sessionId\` only and POSTs to the planner action.

- **\`session.\$id.tsx\` loader**: stops returning \`callbackUrl\` /
  \`callbackToken\` to the client. Returns a single \`hasJournalCallback\`
  boolean so the button still knows whether to render.

- **\`SessionView\`**: same prop simplification.

Trust model is unchanged: the same \`sessionId\` that grants Yjs
membership grants save authority. Knowing the URL = ability to act.
The action only adds a server-side hop so the JWT never reaches
browser JS.

Phase B (jti single-use enforcement on the journal side) follows in
a separate PR — needs a journal DB column + verifier change.

Full repo: pnpm typecheck / lint / test all green.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 00:29:24 +02:00
..
app fix(planner): keep journal callback token off the client (#2 Phase A) 2026-05-26 00:29:24 +02:00
public Add favicons, apple-touch-icons, and Chrome DevTools JSON 2026-03-29 10:35:03 +02:00
.gitignore Ignore .vitest-attachments in planner 2026-05-10 19:53:42 +02:00
Dockerfile Add packages/fit to journal and planner Dockerfiles 2026-05-01 08:10:15 +02:00
package.json Bump the production group with 14 updates 2026-05-24 08:31:11 +00:00
react-router.config.ts Complete monorepo toolchain setup (tasks 1.1-1.7) 2026-03-22 12:12:57 +01:00
server.ts fix(sentry): remove hardcoded DSN fallbacks; supply via env in CI 2026-05-25 23:07:07 +02:00
tsconfig.json Fix planner production server + use .ts extensions everywhere 2026-03-25 01:41:33 +01:00
vite.config.ts Fix Sentry build: disable telemetry, fix release version passing 2026-03-27 18:18:00 +01:00
vitest.browser.config.ts Remove invalid oxc.transform config from browser vitest config 2026-05-10 19:05:15 +02:00
vitest.config.ts Split ElevationChart + PlannerMap into deep modules; add visual regression testing 2026-05-10 16:41:23 +02:00