/** * Public types shared across the Web Component and React wrapper. * Keep this file framework-agnostic — no React, no DOM-specific types beyond * lib.dom globals. */ type AuthToken = { sig: string; ts: number; }; /** * Context handed to the auth provider each time a token is needed. The * signature verifier on the server side compares HMAC-SHA256(secret, * `${sessionId}:${ts}`) so the provider must know the current sessionId to * produce a valid signature — your backend returns { sig, ts }. */ type AuthProviderContext = { sessionId: string; }; type AuthProvider = (ctx: AuthProviderContext) => Promise | AuthToken; interface ChatConfig { chatId: string; title: string; subtitle: string; placeholder: string; initialMessages: Array<{ role: 'assistant'; content: string; }>; theme: { primaryColor?: string; avatarUrl?: string; mode?: 'dark' | 'light' | 'auto'; }; authMode: 'public' | 'signed'; sessionIdStrategy: 'auto' | 'header' | 'query'; attachments?: { enabled: boolean; maxFileSize: number; maxPerMessage: number; allowedMimeTypes: string[]; }; /** * When non-empty, the widget renders a mic button and starts a live * voice call against this provider-side agent id. Configured on the * Chat Trigger detail page in the dashboard so consumers don't need * to set the attribute on every embed. The voice-agent-id attribute * still wins when set, so per-page overrides keep working. */ voiceAgentId?: string; voiceProvider?: 'elevenlabs' | 'vapi' | 'retell' | ''; } interface HwChatOptions { /** Public chat id from the trigger — required */ chatId: string; /** * Base URL of the HostWebhook API. Defaults to https://api.hostwebhook.com. * Override for self-hosted / staging. */ apiBase?: string; /** * When the trigger is in `signed` mode, pass a function that returns a * fresh HMAC signature. The widget calls it lazily and caches the result * until ~1 minute before the 5-minute window expires. */ authProvider?: AuthProvider; /** * Alternative to authProvider: a URL the widget POSTs to for a fresh * signature. The endpoint is expected to return `{ sig, ts }`. Use this * when you don't control the page's JS (static HTML / CMS). */ authEndpoint?: string; /** * Dark / light / auto (follows system). Overrides the server's theme * config when set. */ theme?: 'dark' | 'light' | 'auto'; /** * Optional primary/accent color override (hex). Overrides trigger theme. */ primaryColor?: string; /** * Voice agent id (provider-side). When set, a mic button appears in * the header and clicking it starts a live voice call against this * agent — the call runs over the provider's WebSocket directly from * the visitor's browser, HostWebhook only handles the agent's tool * webhooks (the existing voiceCall trigger flow). */ voiceAgentId?: string; /** * Voice agent platform. Defaults to 'elevenlabs'. Vapi + Retell * drivers will ship in a follow-up release. */ voiceProvider?: 'elevenlabs' | 'vapi' | 'retell'; /** * Override the CDN URL the widget loads the provider SDK from. Useful * for self-hosting under a strict CSP that disallows esm.sh. */ voiceSdkUrl?: string; } export type { AuthProvider as A, ChatConfig as C, HwChatOptions as H, AuthToken as a };