/** * Centralized Tavus configuration * * This module now uses the secure API key management system. * API keys are managed through environment variables and the ApiKeyManager. */ import type { BuzzTrailGlobal } from '@buzztrail/shared-types'; import { getApiKeyManager, getTavusApiKey as getSecureApiKey } from '@buzztrail/shared-config'; // Legacy fallback for backward compatibility const LEGACY_TAVUS_API_KEY = '8ff39906dd5840a9bca8c6ce4e15135c'; /** * Returns the Tavus API key. * * Uses the secure API key management system first, * then falls back to global override, then legacy key. */ export function getTavusApiKey(): string { try { // Try secure API key management first const secureKey = getSecureApiKey(); if (secureKey) { return secureKey; } // Fall back to global override const override = (globalThis as BuzzTrailGlobal).__BT_TAVUS_API_KEY__; if (override && typeof override === 'string' && override.trim().length > 0) { return override.trim(); } } catch { // Ignore errors when accessing global properties or secure system } // Final fallback to legacy key return LEGACY_TAVUS_API_KEY; } /** * Sets a runtime override for the Tavus API key in the current JS context. * Note: extension contexts are isolated; set per-context if needed. */ export function setTavusApiKey(key: string): void { (globalThis as BuzzTrailGlobal).__BT_TAVUS_API_KEY__ = key; } /** * Get API key manager for advanced operations */ export function getTavusApiKeyManager() { return getApiKeyManager(); }