trails/apps/planner/app/components
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
..
ClientOnly.tsx Fix SSR and automerge timing 2026-03-23 00:49:54 +01:00
ColoredRoute.tsx Extract @trails-cool/map-core package from Planner 2026-04-12 22:28:14 +02:00
DayBreakdown.tsx Fix i18n: use planner namespace in sidebar components 2026-04-10 23:59:27 +02:00
ElevationChart.tsx Split ElevationChart + PlannerMap into deep modules; add visual regression testing 2026-05-10 16:41:23 +02:00
ExportButton.tsx Centralize waypoint Yjs serialization in waypointFromYMap/waypointToYMap 2026-05-18 21:02:27 +02:00
MapHelpers.tsx Split ElevationChart + PlannerMap into deep modules; add visual regression testing 2026-05-10 16:41:23 +02:00
MidpointHandles.tsx Add route interactions: click-to-split, drag-to-reshape, colored route rendering 2026-03-26 21:15:55 +01:00
NearbyPoiMarkers.tsx Add per-waypoint notes and nearby POI snap to Planner 2026-05-17 23:58:21 +02:00
NoGoAreaLayer.tsx Add undo/redo to planner 2026-04-04 10:04:01 +01:00
NotesPanel.tsx Fix notes not loading on session reload 2026-04-11 03:00:51 +02:00
ParticipantList.tsx Fix mobile header layout: hide secondary items on small screens 2026-04-12 19:39:19 +02:00
PlannerMap.tsx Add per-waypoint notes and nearby POI snap to Planner 2026-05-17 23:58:21 +02:00
PoiPanel.tsx Extract @trails-cool/map-core package from Planner 2026-04-12 22:28:14 +02:00
ProfileSelector.tsx Change default routing profile to fastbike, move hiking to end 2026-04-11 02:17:46 +02:00
RouteInteraction.tsx Extract @trails-cool/map-core package from Planner 2026-04-12 22:28:14 +02:00
SaveToJournalButton.tsx fix(planner): keep journal callback token off the client (#2 Phase A) 2026-05-26 00:29:24 +02:00
SessionView.tsx fix(planner): keep journal callback token off the client (#2 Phase A) 2026-05-26 00:29:24 +02:00
WaypointContextMenu.tsx Replace right-click behavior with context menu on waypoints 2026-04-11 02:42:43 +02:00
WaypointSidebar.tsx Centralize waypoint Yjs serialization in waypointFromYMap/waypointToYMap 2026-05-18 21:02:27 +02:00
YjsDebugPanel.tsx Session-bind /api/route and /api/overpass 2026-04-21 22:18:45 +02:00