UNPKG

eufy-security-client-fork

Version:

Client to comunicate with Eufy-Security devices

154 lines (153 loc) 5.74 kB
import { TypedEmitter } from "tiny-typed-emitter"; import * as NodeRSA from "node-rsa"; import { Address, CustomData } from "./models"; import { CommandType, P2PDataType, P2PConnectionType } from "./types"; import { P2PClientProtocolEvents, P2PCommand } from "./interfaces"; import { StationListResponse } from "../http/models"; import { HTTPApi } from "../http/api"; export declare class P2PClientProtocol extends TypedEmitter<P2PClientProtocolEvents> { private readonly MAX_RETRIES; private readonly MAX_COMMAND_RESULT_WAIT; private readonly MAX_AKNOWLEDGE_TIMEOUT; private readonly MAX_LOOKUP_TIMEOUT; private readonly LOOKUP_RETRY_TIMEOUT; private readonly MAX_EXPECTED_SEQNO_WAIT; private readonly HEARTBEAT_INTERVAL; private readonly MAX_COMMAND_QUEUE_TIMEOUT; private readonly AUDIO_CODEC_ANALYZE_TIMEOUT; private readonly KEEPALIVE_INTERVAL; private readonly ESD_DISCONNECT_TIMEOUT; private readonly MAX_STREAM_DATA_WAIT; private readonly UDP_RECVBUFFERSIZE_BYTES; private readonly MAX_PAYLOAD_BYTES; private readonly MAX_PACKET_BYTES; private readonly MAX_VIDEO_PACKET_BYTES; private readonly P2P_DATA_HEADER_BYTES; private readonly MAX_SEQUENCE_NUMBER; private socket; private binded; private connected; private connecting; private terminating; private seqNumber; private videoSeqNumber; private lockSeqNumber; private expectedSeqNo; private currentMessageBuilder; private currentMessageState; private talkbackStream?; private downloadTotalBytes; private downloadReceivedBytes; private cloudAddresses; private messageStates; private messageVideoStates; private sendQueue; private connectTimeout?; private lookupTimeout?; private lookupRetryTimeout?; private heartbeatTimeout?; private keepaliveTimeout?; private esdDisconnectTimeout?; private secondaryCommandTimeout?; private connectTime; private lastPong; private connectionType; private energySavingDevice; private energySavingDeviceP2PSeqMapping; private energySavingDeviceP2PDataSeqNumber; private connectAddress; private localIPAddress; private dskKey; private dskExpiration; private log; private deviceSNs; private api; private rawStation; private lastCustomData?; private lastChannel?; constructor(rawStation: StationListResponse, api: HTTPApi); private _incrementSequence; private _initialize; private initializeMessageBuilder; private initializeMessageState; private _clearTimeout; private _clearMessageStateTimeouts; private _clearMessageVideoStateTimeouts; private _clearHeartbeatTimeout; private _clearKeepaliveTimeout; private _clearConnectTimeout; private _clearLookupTimeout; private _clearLookupRetryTimeout; private _clearESDDisconnectTimeout; private _clearSecondaryCommandTimeout; private _disconnected; private closeEnergySavingDevice; private renewDSKKey; private localLookup; private cloudLookup; private cloudLookup2; private localLookupByAddress; private cloudLookupByAddress; private cloudLookupByAddress2; private cloudLookupByAddress3; isConnected(): boolean; private _startConnectTimeout; private _connect; private lookup; connect(host?: string): Promise<void>; private sendCamCheck; private sendCamCheck2; sendPing(address: Address): void; sendCommandWithIntString(p2pcommand: P2PCommand, customData?: CustomData): void; sendCommandWithInt(p2pcommand: P2PCommand, customData?: CustomData): void; sendCommandWithStringPayload(p2pcommand: P2PCommand, customData?: CustomData): void; sendCommandWithString(p2pcommand: P2PCommand, customData?: CustomData): void; sendCommandPing(channel?: number): void; sendCommandDevicePing(channel?: number): void; sendCommandWithoutData(commandType: CommandType, channel?: number): void; private sendQueuedMessage; private sendCommand; private _sendCommand; private handleMsg; private parseDataMessage; private handleData; private isIFrame; private waitForStreamData; private handleDataBinaryAndVideo; private handleDataControl; private sendAck; private getDataType; close(): Promise<void>; private getHeartbeatInterval; private onClose; private onError; private scheduleHeartbeat; private scheduleP2PKeepalive; setDownloadRSAPrivateKeyPem(pem: string): void; getRSAPrivateKey(): NodeRSA | null; private initializeStream; private endStream; private endRTSPStream; private emitStreamStartEvent; private emitStreamStopEvent; isStreaming(channel: number, datatype: P2PDataType): boolean; isLiveStreaming(channel: number): boolean; private isCurrentlyStreaming; isRTSPLiveStreaming(channel: number): boolean; isDownloading(channel: number): boolean; getLockSequenceNumber(): number; incLockSequenceNumber(): number; setConnectionType(type: P2PConnectionType): void; getConnectionType(): P2PConnectionType; isEnergySavingDevice(): boolean; private getDSKKeys; updateRawStation(value: StationListResponse): void; private initializeTalkbackStream; private sendTalkbackAudioFrame; private onTalkbackStreamClose; private onTalkbackStreamError; private _sendVideoData; isTalkbackOngoing(channel: number): boolean; startTalkback(channel?: number): void; stopTalkback(channel?: number): void; }