UNPKG

optimus-init

Version:

Initialization utility for Optimus Security

59 lines (58 loc) 2.08 kB
/** * Optimus Authentication Client * Handles authentication for API requests to Optimus endpoints */ export declare class OptimusAuth { private keyId; private token; private baseUrl; /** * Create a new OptimusAuth client * @param envPath Path to the optimus.env file * @param baseUrl Base URL for the API (optional, will use OPTIMUS_ENDPOINT from env file if not provided) */ constructor(envPath?: string, baseUrl?: string); /** * Load environment variables from file */ private loadEnvFile; /** * Generate authentication signature */ private generateSignature; /** * Get authentication headers * @param payload Request payload (for signature generation) * @returns Authentication headers */ getAuthHeaders(payload?: any): Record<string, string>; /** * Make authenticated GET request * @param endpoint API endpoint path (will be appended to baseUrl) * @param params Query parameters * @returns Response data */ get<T = any>(endpoint: string, params?: Record<string, any>): Promise<T>; /** * Make authenticated POST request * @param endpoint API endpoint path * @param data Request body * @returns Response data */ post<T = any>(endpoint: string, data?: any): Promise<T>; /** * Download a file from an authenticated endpoint * @param endpoint API endpoint path * @param outputPath Path to save the file * @param params Query parameters */ downloadFile(endpoint: string, outputPath: string, params?: Record<string, any>): Promise<void>; /** * Download a file from an authenticated endpoint with a specific timestamp * @param endpoint API endpoint path * @param outputPath Path to save the file * @param params Query parameters * @param timestamp Specific timestamp to use for authentication */ downloadFileWithTimestamp(endpoint: string, outputPath: string, params: Record<string, any> | undefined, timestamp: string): Promise<void>; }