/** * Eufy Security Client - High-level client interface for CLI usage * * This class provides a simplified interface for CLI applications to interact * with the Eufy Security WebSocket API. It wraps the ApiManager and provides * methods that match the expected CLI interface. */ import { Logger, ILogObj } from "tslog"; import { EventEmitter } from "events"; /** * Device information interface containing essential device metadata * * @interface DeviceInfo * @public */ export interface DeviceInfo { /** Human-readable device name */ name: string; /** Unique device serial number identifier */ serialNumber: string; /** Device type (e.g., "Camera", "Doorbell", "Battery Doorbell") */ type: string; /** Serial number of the associated station (optional) */ stationSerial?: string; /** Device model identifier (optional) */ model?: string; /** Hardware version string (optional) */ hardwareVersion?: string; /** Software/firmware version string (optional) */ softwareVersion?: string; } /** * Configuration options for EufySecurityClient */ export interface EufySecurityClientConfig { /** WebSocket server URL (e.g., 'ws://localhost:3000') */ wsUrl: string; /** Optional external logger instance compatible with tslog (e.g., ConsoleLogger from @caplaz/eufy-security-scrypted) */ logger?: Logger; } /** * High-level Eufy Security Client for CLI applications */ export declare class EufySecurityClient extends EventEmitter { private apiManager; private logger; private devices; private isConnectedFlag; private eventListenerCleanup; /** * Creates a new EufySecurityClient instance * * @param config - Configuration object containing WebSocket URL and optional logger * * @example * ```typescript * const client = new EufySecurityClient({ * wsUrl: "ws://localhost:3000" * }); * * // With custom logger * const client = new EufySecurityClient({ * wsUrl: "ws://localhost:3000", * logger: customLogger * }); * ``` */ constructor(config: EufySecurityClientConfig); /** * Wait for the client to be ready (schema negotiation complete) * * @private * @param timeoutMs - Maximum time to wait in milliseconds (default: 10000) * @throws {Error} When timeout is reached before client becomes ready */ private waitForReady; /** * Connect to the WebSocket server and initialize the client * * Establishes WebSocket connection, performs schema negotiation, connects to the driver, * starts listening for events, and loads available devices. * * @throws {Error} If connection, schema negotiation, or driver connection fails * * @example * ```typescript * await client.connect(); * console.log('Client connected and ready'); * ``` */ connect(): Promise; /** * Disconnect from the WebSocket server and cleanup resources * * Gracefully closes the WebSocket connection, removes all event listeners, * clears device cache, and resets internal state to prevent memory leaks. * * @example * ```typescript * await client.disconnect(); * console.log('Client disconnected and cleaned up'); * ``` */ disconnect(): Promise; /** * Check if client is connected and ready for operations * * @returns true if WebSocket is connected and client is ready for API calls * * @example * ```typescript * if (client.isConnected()) { * const devices = await client.getDevices(); * } * ``` */ isConnected(): boolean; /** * Connect to the Eufy driver * * Establishes connection to the Eufy cloud driver. This is called automatically * by connect(), but can be called separately for more granular control. * * @throws {Error} If client not ready or driver connection fails * * @example * ```typescript * await client.connectDriver(); * console.log('Driver connected'); * ``` */ connectDriver(): Promise; /** * Get all available devices from the connected Eufy account * * @returns Promise resolving to array of device information objects * @throws {Error} If client is not connected * * @example * ```typescript * const devices = await client.getDevices(); * devices.forEach(device => { * console.log(`Device: ${device.name} (${device.serialNumber})`); * }); * ``` */ getDevices(): Promise; /** * Start live streaming from a specific device * * @param deviceSerial - Serial number of the device to start streaming from * @throws {Error} If client is not connected or device is not found * * @example * ```typescript * await client.startStream("T8210N20123456789"); * * // Listen for stream data * client.on('streamData', (data) => { * console.log(`Received ${data.type} data: ${data.buffer.length} bytes`); * }); * ``` */ startStream(deviceSerial: string): Promise; /** * Stop live streaming from a specific device * * @param deviceSerial - Serial number of the device to stop streaming from * @throws {Error} If client is not connected or device is not found * * @example * ```typescript * await client.stopStream("T8210N20123456789"); * console.log('Streaming stopped'); * ``` */ stopStream(deviceSerial: string): Promise; /** * Get pending CAPTCHA information * * Returns CAPTCHA information from the last CAPTCHA request event. * This is used by the CLI to display CAPTCHA information to the user. * * @returns CAPTCHA information or null if no CAPTCHA is pending */ getPendingCaptcha(): { captchaId: string; captcha: string; } | null; /** * Clear pending CAPTCHA information * * Clears any stored CAPTCHA information after it has been used. */ clearPendingCaptcha(): void; /** * Get pending MFA information * * Returns MFA information from the last MFA request event. * This is used by the CLI to display MFA information to the user. * * @returns MFA information or null if no MFA is pending */ getPendingMfa(): { methods: string[]; } | null; /** * Clear pending MFA information * * Clears any stored MFA information after it has been used. */ clearPendingMfa(): void; /** * Enhanced command API with more elegant fluent interface */ get commands(): import("./api-manager-commands").EnhancedCommandAPI; /** * Set up event handlers for API manager events * * Configures listeners for device events, stream events, and data events. * Transforms API manager events into client-friendly events. * Stores cleanup functions for proper resource management. * * @private */ private setupEventHandlers; /** * Load and cache device information from the server * * Retrieves device list from server response and fetches detailed properties * for each device. Handles errors gracefully by adding devices with minimal info. * * @private * @throws {Error} If server communication fails */ private loadDevices; /** * Add a device to the internal device cache * * @private * @param deviceData - Device data from server event */ private addDevice; /** * Remove a device from the internal device cache * * @private * @param serialNumber - Serial number of device to remove */ private removeDevice; /** * Convert device type number to human-readable name * * @private * @param type - Numeric device type from server * @returns Human-readable device type name */ private getDeviceTypeName; } //# sourceMappingURL=eufy-security-client.d.ts.map