"use strict";
/**
 * Auth Handler for CLIProxyAPI
 *
 * Manages OAuth authentication for CLIProxy providers (Gemini, Codex, Antigravity).
 * CLIProxyAPI handles OAuth internally - we just need to:
 * 1. Check if auth exists (token files in CCS auth directory)
 * 2. Trigger OAuth flow by spawning binary with auth flag
 * 3. Auto-detect headless environments (SSH, no DISPLAY)
 * 4. Use --no-browser flag for headless, display OAuth URL for manual auth
 *
 * Token storage: ~/.ccs/cliproxy/auth/<provider>/
 * Each provider has its own directory to avoid conflicts.
 *
 * This file is a facade that re-exports from the auth/ submodule.
 * The actual implementation is split across:
 * - auth/auth-types.ts     - Types and OAuth configurations
 * - auth/token-manager.ts  - Token storage/retrieval/validation
 * - auth/oauth-handler.ts  - OAuth flow handling
 * - auth/environment-detector.ts - Headless detection and port management
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.initializeAccounts = exports.ensureAuth = exports.triggerOAuth = exports.showStep = exports.getTimeoutTroubleshooting = exports.killProcessOnPort = exports.isHeadlessEnvironment = exports.displayAuthStatus = exports.clearAuth = exports.getAllAuthStatus = exports.getAuthStatus = exports.isAuthenticated = exports.isTokenFileForProvider = exports.getProviderTokenDir = exports.getOAuthConfig = exports.PROVIDER_TYPE_VALUES = exports.PROVIDER_AUTH_PREFIXES = exports.OAUTH_CONFIGS = exports.OAUTH_CALLBACK_PORTS = void 0;
// Re-export configurations
var _1 = require(".");
Object.defineProperty(exports, "OAUTH_CALLBACK_PORTS", { enumerable: true, get: function () { return _1.OAUTH_CALLBACK_PORTS; } });
Object.defineProperty(exports, "OAUTH_CONFIGS", { enumerable: true, get: function () { return _1.OAUTH_CONFIGS; } });
Object.defineProperty(exports, "PROVIDER_AUTH_PREFIXES", { enumerable: true, get: function () { return _1.PROVIDER_AUTH_PREFIXES; } });
Object.defineProperty(exports, "PROVIDER_TYPE_VALUES", { enumerable: true, get: function () { return _1.PROVIDER_TYPE_VALUES; } });
Object.defineProperty(exports, "getOAuthConfig", { enumerable: true, get: function () { return _1.getOAuthConfig; } });
// Re-export token management functions
var _2 = require(".");
Object.defineProperty(exports, "getProviderTokenDir", { enumerable: true, get: function () { return _2.getProviderTokenDir; } });
Object.defineProperty(exports, "isTokenFileForProvider", { enumerable: true, get: function () { return _2.isTokenFileForProvider; } });
Object.defineProperty(exports, "isAuthenticated", { enumerable: true, get: function () { return _2.isAuthenticated; } });
Object.defineProperty(exports, "getAuthStatus", { enumerable: true, get: function () { return _2.getAuthStatus; } });
Object.defineProperty(exports, "getAllAuthStatus", { enumerable: true, get: function () { return _2.getAllAuthStatus; } });
Object.defineProperty(exports, "clearAuth", { enumerable: true, get: function () { return _2.clearAuth; } });
Object.defineProperty(exports, "displayAuthStatus", { enumerable: true, get: function () { return _2.displayAuthStatus; } });
// Re-export environment detection functions
var _3 = require(".");
Object.defineProperty(exports, "isHeadlessEnvironment", { enumerable: true, get: function () { return _3.isHeadlessEnvironment; } });
Object.defineProperty(exports, "killProcessOnPort", { enumerable: true, get: function () { return _3.killProcessOnPort; } });
Object.defineProperty(exports, "getTimeoutTroubleshooting", { enumerable: true, get: function () { return _3.getTimeoutTroubleshooting; } });
Object.defineProperty(exports, "showStep", { enumerable: true, get: function () { return _3.showStep; } });
// Re-export OAuth handling functions
var _4 = require(".");
Object.defineProperty(exports, "triggerOAuth", { enumerable: true, get: function () { return _4.triggerOAuth; } });
Object.defineProperty(exports, "ensureAuth", { enumerable: true, get: function () { return _4.ensureAuth; } });
// Re-export account management initialization
const account_manager_1 = require("../accounts/account-manager");
/**
 * Initialize accounts registry from existing tokens
 * Should be called on startup to populate accounts from existing token files
 */
function initializeAccounts() {
    (0, account_manager_1.discoverExistingAccounts)();
}
exports.initializeAccounts = initializeAccounts;
//# sourceMappingURL=auth-handler.js.map