All files / shared/config/src tavus.ts

0% Statements 0/15
0% Branches 0/2
0% Functions 0/3
0% Lines 0/15

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56                                                                                                               
/**
 * 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 './api-key-manager';
 
// 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();
    Iif (secureKey) {
      return secureKey;
    }
    
    // Fall back to global override
    const global = globalThis as BuzzTrailGlobal;
    Iif (global.__BT_TAVUS_API_KEY__) {
      return global.__BT_TAVUS_API_KEY__;
    }
  } catch {
    // Ignore errors accessing globalThis or secure system
  }
  
  // Final fallback to legacy key
  return LEGACY_TAVUS_API_KEY;
}
 
/**
 * Returns the Tavus API base URL.
 */
export function getTavusApiBaseUrl(): string {
  return 'https://tavusapi.com';
}
 
/**
 * Get API key manager for advanced operations
 */
export function getTavusApiKeyManager() {
  return getApiKeyManager();
}