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>
18 lines
486 B
TypeScript
18 lines
486 B
TypeScript
import { API_VERSION } from "@trails-cool/api";
|
|
|
|
/**
|
|
* GET /.well-known/trails-cool
|
|
*
|
|
* Discovery endpoint for mobile apps and federation.
|
|
* Returns instance metadata including API version, name, and base URL.
|
|
*/
|
|
export function loader() {
|
|
const domain = process.env.DOMAIN ?? "localhost";
|
|
const origin = process.env.ORIGIN ?? "http://localhost:3000";
|
|
|
|
return Response.json({
|
|
apiVersion: API_VERSION,
|
|
instanceName: domain,
|
|
apiBaseUrl: `${origin}/api/v1`,
|
|
});
|
|
}
|