trails/apps/journal/app/lib
Ullrich Schäfer 1ae406a8aa
Implement OAuth2 PKCE auth, discovery, and mobile API client
Journal server (Phase 1.4 + 1.5):
- Add oauth_clients, oauth_codes, oauth_tokens tables to journal schema
- Implement GET /oauth/authorize with PKCE flow and login redirect
- Implement POST /oauth/token (authorization_code + refresh_token grants)
- Add validateBearerToken() + getAuthenticatedUser() middleware
- Seed trails-cool-mobile as trusted OAuth client on server startup
- Add GET /.well-known/trails-cool discovery endpoint
- Add returnTo support to login page and magic link verify
- Add @trails-cool/api workspace dependency to journal

Mobile app (Phase 1.5 + 1.6):
- Login screen with server URL input and discovery validation
- OAuth2 PKCE login via expo-web-browser with expo-crypto for Hermes
- Token storage in expo-secure-store with auto-refresh on 401
- API client with bearer token injection and typed errors
- Server URL persistence with localhost default in dev mode
- API version compatibility check on app foreground
- Log out + switch server on Profile tab
- iOS ATS exception for local networking

Tests:
- PKCE crypto verification, OAuthError, token generation
- Discovery endpoint response shape
- API version semver compatibility
- API client error types

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 00:41:40 +02:00
..
sync Fix Wahoo import bugs, add Import All, update spec 2026-04-05 17:47:48 +02:00
activities.server.ts Fix lint: duration is never reassigned, use const 2026-04-05 20:04:10 +02:00
auth.server.ts Add purpose column to magic_tokens, fix email change race condition 2026-03-29 10:28:53 +02:00
db.ts Implement Journal auth: passkeys + magic links, no passwords 2026-03-23 17:38:46 +01:00
email.server.test.ts Add observability: health endpoints, structured logging, metrics, Grafana stack 2026-03-26 22:59:44 +01:00
email.server.ts Add observability: health endpoints, structured logging, metrics, Grafana stack 2026-03-26 22:59:44 +01:00
jwt.server.ts Implement Planner-Journal handoff (Group 9) 2026-03-24 20:22:58 +00:00
logger.server.ts Add observability: health endpoints, structured logging, metrics, Grafana stack 2026-03-26 22:59:44 +01:00
metrics.server.ts Add observability: health endpoints, structured logging, metrics, Grafana stack 2026-03-26 22:59:44 +01:00
oauth.server.test.ts Implement OAuth2 PKCE auth, discovery, and mobile API client 2026-04-13 00:41:40 +02:00
oauth.server.ts Implement OAuth2 PKCE auth, discovery, and mobile API client 2026-04-13 00:41:40 +02:00
routes.server.ts Sync notes through GPX, Journal, and Planner roundtrip 2026-04-11 03:35:40 +02:00