Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

Merge branch 'main' into fix/mfa-backup-codes

Fernando Bonaaa5dd1abc645
diff --cc client/src/pages/SettingsPage.tsx
index f04511716,0d25f420e..ba03a11e8
--- a/client/src/pages/SettingsPage.tsx
+++ b/client/src/pages/SettingsPage.tsx
@@@ -6,9 -6,10 +6,10 @@@ import { SUPPORTED_LANGUAGES, useTransl
import Navbar from '../components/Layout/Navbar'
import CustomSelect from '../components/shared/CustomSelect'
import { useToast } from '../components/shared/Toast'
- import { Save, Map, Palette, User, Moon, Sun, Monitor, Shield, Camera, Trash2, Lock, KeyRound, Copy, Download, Printer } from 'lucide-react'
-import { Save, Map, Palette, User, Moon, Sun, Monitor, Shield, Camera, Trash2, Lock, KeyRound, Terminal, Copy, Plus, Check } from 'lucide-react'
++import { Save, Map, Palette, User, Moon, Sun, Monitor, Shield, Camera, Trash2, Lock, KeyRound, Copy, Download, Printer, Terminal, Plus, Check } from 'lucide-react'
import { authApi, adminApi, notificationsApi } from '../api/client'
import apiClient from '../api/client'
+ import { useAddonStore } from '../store/addonStore'
import type { LucideIcon } from 'lucide-react'
import type { UserWithOidc } from '../types'
import { getApiErrorMessage } from '../types'
@@@ -18,7 -19,13 +19,14 @@@ interface MapPreset
url: string
}
+const MFA_BACKUP_SESSION_KEY = 'trek_mfa_backup_codes_pending'
+ interface McpToken {
+ id: number
+ name: string
+ token_prefix: string
+ created_at: string
+ last_used_at: string | null
+ }
const MAP_PRESETS: MapPreset[] = [
{ name: 'OpenStreetMap', url: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png' },
diff --cc server/src/db/migrations.ts
index 5d2a52cef,451c5f901..5c787df07
--- a/server/src/db/migrations.ts
+++ b/server/src/db/migrations.ts
@@@ -394,9 -394,34 +394,37 @@@ function runMigrations(db: Database.Dat
CREATE INDEX IF NOT EXISTS idx_audit_log_created ON audit_log(created_at DESC);
`);
},
+ () => {
+ // MFA backup/recovery codes
+ try { db.exec('ALTER TABLE users ADD COLUMN mfa_backup_codes TEXT'); } catch {}
+ // MCP long-lived API tokens
+ () => db.exec(`
+ CREATE TABLE IF NOT EXISTS mcp_tokens (
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+ user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
+ name TEXT NOT NULL,
+ token_hash TEXT NOT NULL,
+ token_prefix TEXT NOT NULL,
+ created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
+ last_used_at DATETIME
+ )
+ `),
+ // MCP addon entry
+ () => {
+ try {
+ db.prepare("INSERT OR IGNORE INTO addons (id, name, description, type, icon, enabled, sort_order) VALUES (?, ?, ?, ?, ?, ?, ?)")
+ .run('mcp', 'MCP', 'Model Context Protocol for AI assistant integration', 'integration', 'Terminal', 0, 12);
+ } catch {}
+ },
+ // Index on mcp_tokens.token_hash
+ () => db.exec(`
+ CREATE UNIQUE INDEX IF NOT EXISTS idx_mcp_tokens_hash ON mcp_tokens(token_hash)
+ `),
+ // Ensure MCP addon type is 'integration'
+ () => {
+ try {
+ db.prepare("UPDATE addons SET type = 'integration' WHERE id = 'mcp'").run();
+ } catch {}
},
];