/** * Auth Guard Middleware * * Checks for valid API key authentication before executing protected commands. * Provides helpful error messages directing users to authenticate. */ /** * Check if a command requires authentication * * @param command - Command name or flag to check * @returns true if command requires authentication * * @example * ```typescript * requiresAuth('status'); // true * requiresAuth('login'); // false * requiresAuth('--help'); // false * ``` */ export declare function requiresAuth(command: string): boolean; /** * Get the list of public commands * * @returns Array of command names that don't require auth */ export declare function getPublicCommands(): string[]; /** * Add a command to the public (no-auth-required) list * * Useful for plugins or extensions that add unauthenticated commands. * * @param command - Command name to add */ export declare function addPublicCommand(command: string): void; /** * Authentication guard - checks auth and exits if not authenticated * * Call this at the start of protected command handlers. * Exits the process with code 1 if not authenticated. * * @param command - Command name being executed (for logging) * * @example * ```typescript * // In a command handler * export function statusCommand() { * authGuard('status'); * // ... rest of command (only runs if authenticated) * } * ``` */ export declare function authGuard(command: string): void; /** * Check authentication without exiting * * Use this for conditional logic where you don't want to exit. * * @returns Object with auth status and config * * @example * ```typescript * const { authenticated, config } = checkAuth(); * if (!authenticated) { * // Handle gracefully without exiting * } * ``` */ export declare function checkAuth(): { authenticated: boolean; apiKeySource: 'env' | 'global' | null; }; /** * Validate API key format * * Checks that the API key matches expected format without making API calls. * * @param apiKey - API key to validate * @returns Object with validity and any error message * * @example * ```typescript * const { valid, error } = validateApiKeyFormat('sf_live_abc123'); * if (!valid) { * console.error(error); * } * ``` */ export declare function validateApiKeyFormat(apiKey: string): { valid: boolean; error?: string; }; /** * Commander.js pre-action hook for auth guard * * Use this with Commander's hook system for automatic auth checking. * * @param thisCommand - Commander command object * * @example * ```typescript * program.hook('preAction', authGuardHook); * ``` */ export declare function authGuardHook(thisCommand: { name: () => string; }): void; //# sourceMappingURL=auth-guard.d.ts.map