// Single source of truth for the React shell's local-mode + networking constants.
// (main.js — the embedded Node entry — sets the matching PORT/BIND_HOST on its
// own side; keep the port here in sync with it.)

export const LOCAL_PORT = 3000;
export const LOCAL_URL = `http://127.0.0.1:${LOCAL_PORT}`;
export const HEALTH_URL = `${LOCAL_URL}/api/health`;

// @capacitor/preferences keys
export const PREF_SERVER_URL = 'serverUrl';
export const PREF_BIOMETRIC = 'biometricEnabled';
/** Value stored under PREF_SERVER_URL when the user chose on-device local mode. */
export const LOCAL_MODE_SENTINEL = 'local';

// capacitor-secure-storage-plugin
export const SECURE_KEY_NAME = 'tokenEncryptionKey';
export const ENCRYPTION_KEY_BYTES = 48;

// Networking / boot
export const REQUEST_TIMEOUT_MS = 15_000;
export const HEALTH_POLL_INTERVAL_MS = 250;
/** Give up the "starting local server" spinner and surface a real error instead
 *  of polling forever. Generous — the first launch unpacks the Node project. */
export const HEALTH_POLL_TIMEOUT_MS = 60_000;

// CSRF (double-submit). The cookie is httpOnly, so the token is read from a
// readable endpoint and echoed in a header — mirroring client/api.ts on the web.
export const CSRF_HEADER = 'x-csrf-token';
export const CSRF_TOKEN_PATH = '/api/auth/csrf-token';
