/** * Application Configuration * * This file contains all configuration settings for the frontend application. * Centralized configuration makes it easier to manage environment-specific settings. */ // ============================================================================= // Environment Configuration // ============================================================================= /** * Set to true to use mock data instead of real backend calls. * Useful for development and testing without a running backend. */ export const NO_BACKEND_MODE = false; /** * Enable debug logging for API calls */ export const DEBUG_MODE = true; // ============================================================================= // API Configuration // ============================================================================= /** * Base URL for the backend API server */ export const API_BASE_URL = 'http://localhost:8000'; /** * API request timeout in milliseconds */ export const API_TIMEOUT = 30000; /** * API Endpoints * All backend API routes are defined here for easy reference and maintenance. */ export const API_ENDPOINTS = { // Authentication AUTH: { LOGIN: '/login', REGISTER: '/register', }, // Assets Management ASSETS: { GET: '/assets/get', CREATE: '/assets/create', CLAIM: '/assets/claim', ASSIGN: '/assets/assign', DELETE: '/assets/delete', }, // AI Services AI: { PROXY: '/ai/proxy', GET_ROLES: '/get_ai_roles', }, // Admin Operations ADMIN: { DECLARE_GUALE: '/admin/declare-guale', }, } as const; // ============================================================================= // Vault storage (user-isolated, multi-account) // ============================================================================= // - AsyncStorage keys for vault state (S0 share, initialized flag, mnemonic part backup). // - User-scoped: each account has its own keys so vault/mnemonic state is isolated. // - Store: use getVaultStorageKeys(userId) and write to INITIALIZED / SHARE_DEVICE / MNEMONIC_PART_LOCAL. // - Clear: use same keys in multiRemove (e.g. MeScreen Reset Vault State). // - Multi-account: same device, multiple users → each has independent vault (no cross-user leakage). const VAULT_KEY_PREFIX = 'sentinel_vault'; /** Base key names (for reference). Prefer getVaultStorageKeys(userId) for all reads/writes. */ export const VAULT_STORAGE_KEYS = { INITIALIZED: 'sentinel_vault_initialized', SHARE_DEVICE: 'sentinel_vault_s0', MNEMONIC_PART_LOCAL: 'sentinel_mnemonic_part_local', } as const; /** * Returns vault storage keys for the given user (user isolation). * - Use for: reading/writing S0, mnemonic part backup, clearing on Reset Vault State. * - userId null → guest namespace (_guest). userId set → per-user namespace (_u{userId}). */ export function getVaultStorageKeys(userId: number | string | null): { INITIALIZED: string; SHARE_DEVICE: string; MNEMONIC_PART_LOCAL: string; AES_KEY: string; SHARE_SERVER: string; SHARE_HEIR: string; } { const suffix = userId != null ? `_u${userId}` : '_guest'; return { INITIALIZED: `${VAULT_KEY_PREFIX}_initialized${suffix}`, SHARE_DEVICE: `${VAULT_KEY_PREFIX}_s0${suffix}`, MNEMONIC_PART_LOCAL: `sentinel_mnemonic_part_local${suffix}`, AES_KEY: `sentinel_aes_key${suffix}`, SHARE_SERVER: `sentinel_share_server${suffix}`, SHARE_HEIR: `sentinel_share_heir${suffix}`, }; } // ============================================================================= // Helper Functions // ============================================================================= /** * Build full API URL from endpoint * @param endpoint - API endpoint path (e.g., '/login') * @returns Full URL (e.g., 'http://192.168.56.103:8000/login') */ export function buildApiUrl(endpoint: string): string { return `${API_BASE_URL}${endpoint}`; } /** * Get default headers for API requests * @param token - Optional JWT token for authenticated requests * @returns Headers object */ export function getApiHeaders(token?: string): Record { const headers: Record = { 'Content-Type': 'application/json', }; if (token) { headers['Authorization'] = `Bearer ${token}`; } return headers; } /** * Log API debug information * Only logs when DEBUG_MODE is enabled */ export function logApiDebug(label: string, data: unknown): void { if (DEBUG_MODE) { console.log(`[API Debug] ${label}:`, data); } } // ============================================================================= // Mock User Configuration (for NO_BACKEND_MODE) // ============================================================================= export const MOCK_CONFIG = { USER: { id: 999, username: 'MockCaptain', email: 'captain@sentinel.local', public_key: 'mock_public_key', is_admin: true, guale: false, tier: 'premium', tier_expires_at: '2026-12-31T23:59:59Z', last_active_at: new Date().toISOString(), }, ACCESS_TOKEN: 'mock_access_token', RESPONSE_DELAY: 200, // milliseconds } as const; // ============================================================================= // AI Service Configuration // ============================================================================= export const AI_CONFIG = { /** * Default system prompt for AI conversations */ DEFAULT_SYSTEM_PROMPT: 'You are a helpful journal assistant. Help the user reflect on their thoughts and feelings.', /** * Mock response delay in milliseconds (for NO_BACKEND_MODE) */ MOCK_RESPONSE_DELAY: 500, /** * AI Roles configuration */ ROLES: [ { id: 'reflective', name: 'Reflective Assistant', description: 'Helps you dive deep into your thoughts and feelings through meaningful reflection.', systemPrompt: 'You are a helpful journal assistant. Help the user reflect on their thoughts and feelings.', icon: 'journal-outline', iconFamily: 'Ionicons', }, { id: 'creative', name: 'Creative Spark', description: 'A partner for brainstorming, creative writing, and exploring new ideas.', systemPrompt: 'You are a creative brainstorming partner. Help the user explore new ideas, write stories, or look at things from a fresh perspective.', icon: 'bulb-outline', iconFamily: 'Ionicons', }, { id: 'planner', name: 'Action Planner', description: 'Focused on turning thoughts into actionable plans and organized goals.', systemPrompt: 'You are a productivity coach. Help the user break down their thoughts into actionable steps and clear goals.', icon: 'list-outline', iconFamily: 'Ionicons', }, { id: 'empathetic', name: 'Empathetic Guide', description: 'Provides a safe, non-judgmental space for emotional support and empathy.', systemPrompt: 'You are a supportive and empathetic friend. Listen to the user\'s concerns and provide emotional support without judgment.', icon: 'heart-outline', iconFamily: 'Ionicons', }, ], } as const; // ============================================================================= // Export Type Definitions // ============================================================================= export type ApiEndpoint = typeof API_ENDPOINTS;