Files
ccs/src/cliproxy/index.ts
T
kaitranntt c4f09168ff feat(cliproxy): add customizable auth token manager
- Add CLIProxyAuthConfig type with api_key and management_secret fields
- Implement auth-token-manager.ts with inheritance chain:
  variant auth → global auth → default constants
- Add secure token generation using crypto.randomBytes (256-bit entropy)
- Export auth functions from cliproxy barrel (index.ts)
- Bump UNIFIED_CONFIG_VERSION to 6
2025-12-25 14:35:43 -05:00

151 lines
3.7 KiB
TypeScript

/**
* CLIProxy Module Exports
* Central export point for CLIProxyAPI binary management and execution
*/
// Types
export type {
PlatformInfo,
SupportedOS,
SupportedArch,
ArchiveExtension,
BinaryManagerConfig,
BinaryInfo,
DownloadProgress,
ProgressCallback,
ChecksumResult,
DownloadResult,
CLIProxyProvider,
CLIProxyConfig,
ExecutorConfig,
ProviderConfig,
ProviderModelMapping,
} from './types';
// Platform detection
export {
detectPlatform,
getDownloadUrl,
getChecksumsUrl,
getExecutableName,
getArchiveBinaryName,
isPlatformSupported,
getPlatformDescription,
CLIPROXY_VERSION,
} from './platform-detector';
// Binary management
export {
BinaryManager,
ensureCLIProxyBinary,
isCLIProxyInstalled,
getCLIProxyPath,
getInstalledCliproxyVersion,
installCliproxyVersion,
fetchLatestCliproxyVersion,
getPinnedVersion,
savePinnedVersion,
clearPinnedVersion,
isVersionPinned,
getVersionPinPath,
} from './binary-manager';
// Config generation
export {
generateConfig,
regenerateConfig,
configNeedsRegeneration,
parseUserApiKeys,
getClaudeEnvVars,
getEffectiveEnvVars,
getProviderSettingsPath,
ensureProviderSettings,
getProviderConfig,
getModelMapping,
getCliproxyDir,
getProviderAuthDir,
getAuthDir,
getConfigPath,
getBinDir,
configExists,
deleteConfig,
CLIPROXY_DEFAULT_PORT,
CLIPROXY_CONFIG_VERSION,
} from './config-generator';
// Base config loader (for reading config/base-*.settings.json)
export {
loadBaseConfig,
getModelMappingFromConfig,
getEnvVarsFromConfig,
clearConfigCache,
} from './base-config-loader';
// Model catalog and configuration
export type { ModelEntry, ProviderCatalog } from './model-catalog';
export { MODEL_CATALOG, supportsModelConfig, getProviderCatalog, findModel } from './model-catalog';
export {
hasUserSettings,
getCurrentModel,
configureProviderModel,
showCurrentConfig,
} from './model-config';
// Executor
export { execClaudeWithCLIProxy, isPortAvailable, findAvailablePort } from './cliproxy-executor';
// Authentication
export type { AuthStatus } from './auth-handler';
export {
isAuthenticated,
getAuthStatus,
getAllAuthStatus,
clearAuth,
triggerOAuth,
ensureAuth,
getOAuthConfig,
getProviderTokenDir,
displayAuthStatus,
} from './auth-handler';
// Stats fetcher
export type { CliproxyStats } from './stats-fetcher';
export { fetchCliproxyStats, isCliproxyRunning } from './stats-fetcher';
// OpenAI compatibility layer
export type { OpenAICompatProvider, OpenAICompatModel } from './openai-compat-manager';
export {
listOpenAICompatProviders,
getOpenAICompatProvider,
addOpenAICompatProvider,
updateOpenAICompatProvider,
removeOpenAICompatProvider,
OPENROUTER_TEMPLATE,
TOGETHER_TEMPLATE,
} from './openai-compat-manager';
// Service manager (background CLIProxy for dashboard)
export type { ServiceStartResult } from './service-manager';
export { ensureCliproxyService, stopCliproxyService, getServiceStatus } from './service-manager';
// Proxy detector (unified detection with multiple fallbacks)
export type { ProxyStatus, DetectionMethod } from './proxy-detector';
export { detectRunningProxy, waitForProxyHealthy, reclaimOrphanedProxy } from './proxy-detector';
// Startup lock (prevents race conditions between CCS processes)
export type { LockResult } from './startup-lock';
export { acquireStartupLock, withStartupLock } from './startup-lock';
// Auth token manager (customizable API key and management secret)
export {
generateSecureToken,
maskToken,
getEffectiveApiKey,
getEffectiveManagementSecret,
setGlobalApiKey,
setGlobalManagementSecret,
setVariantApiKey,
resetAuthToDefaults,
getAuthSummary,
} from './auth-token-manager';