// Shape of the website-widget configuration, stored in data/widget.json. // Mirrors the theme config pattern — file-backed, versioned, admin-editable. export type WidgetConfig = { // Master feature flag. When false, the widget does not render anywhere. enabled: boolean; // HMAC-signed site key the embed script passes as data-key. Auto-generated // on first boot if empty. Rotate via POST /api/config/widget/rotate-key. key: string; // Stable site identifier derived from the key. Used for Redis lookup and // revocation. Populated alongside `key`. siteId: string; // Public base URL where widget.js is hosted. Typically the sidecar host. // If empty, the embed page falls back to its own VITE_API_URL at fetch time. url: string; // Origin allowlist. Empty array means any origin is accepted (test mode). // Set tight values in production: ['https://hospital.com']. allowedOrigins: string[]; // Embed toggles — where the widget should render. Kept as an object so we // can add other surfaces (public landing page, portal, etc.) without a // breaking schema change. embed: { // Show on the staff login page. Useful for testing without a public // landing page; turn off in production. loginPage: boolean; }; // Bookkeeping — incremented on every update, like the theme config. version?: number; updatedAt?: string; }; export const DEFAULT_WIDGET_CONFIG: WidgetConfig = { enabled: true, key: '', siteId: '', url: '', allowedOrigins: [], embed: { loginPage: true, }, };