Skip to content

Commit

Permalink
Automatic detection of supported P2P encryption (none, type1, type2)
Browse files Browse the repository at this point in the history
Fixed regression introduced with activating p2p encryption for all devices (some older devices do not support it!)
Updated docs
Updated versions of the package dependencies
  • Loading branch information
bropat committed Aug 31, 2023
1 parent 255a4c8 commit fa8edf4
Show file tree
Hide file tree
Showing 22 changed files with 1,151 additions and 971 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ Please use GitHub issues for this.

## Changelog

### 2.8.1 (2023-08-31)

* (bropat) Automatic detection of supported P2P encryption (none, type1, type2)
* (bropat) Fixed regression introduced with activating p2p encryption for all devices (some older devices do not support it!)
* (bropat) Updated versions of the package dependencies

### 2.8.0 (2023-08-20)

* (bropat) Implemented p2p data encryption for all supported commands
Expand Down
2 changes: 1 addition & 1 deletion docs/_coverpage.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
![logo](_media/eufy-security-client.png)

# eufy-security-client <small>2.8.0</small>
# eufy-security-client <small>2.8.1</small>

> This shared library allows to control [Eufy security devices](https://us.eufylife.com/collections/security) by connecting to the Eufy cloud servers and local/remote stations over p2p
Expand Down
2 changes: 1 addition & 1 deletion docs/supported_devices.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
| ![T8420X image](_media/floodlight_small.jpg) | Floodlight Camera (T8420X) | :heavy_check_mark: | Firmware: 2.0.6.1 (20220824) |
| ![T8422 image](_media/floodlight_small.jpg) | Floodlight Cam (T8422) | :heavy_check_mark: | |
| ![T8423 image](_media/floodlight2pro_small.jpg) | Floodlight Cam 2 Pro (T8423) | :heavy_check_mark: | Firmware: 1.0.7.4 (20211219) |
| ![T8424 image](_media/floodlight2_small.jpg) | Floodlight Cam 2 (T8424) | :heavy_check_mark: | |
| ![T8424 image](_media/floodlight2_small.jpg) | Floodlight Cam 2 (T8424) | :heavy_check_mark: | Firmware: 2.0.8.8 (20230807) |
| ![T84A1 image](_media/walllight_s100_small.jpg) | Wired Wall Light Cam S100 (T84A1) | :heavy_check_mark: | Firmware: 1.0.8.2 (20230521) |
| ![T8200 image](_media/wireddoorbell2k_small.jpg) | Wired Doorbell 2k (T8200) | :heavy_check_mark: | |
| ![T8200X image](_media/wireddoorbell2k_small.jpg) | Wired Doorbell 2k (T8200X) | :heavy_check_mark: | Firmware: 2.0.6.0 (20220826) |
Expand Down
324 changes: 187 additions & 137 deletions package-lock.json

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eufy-security-client",
"version": "2.8.0",
"version": "2.8.1",
"description": "Client to comunicate with Eufy-Security devices",
"author": {
"name": "bropat",
Expand Down Expand Up @@ -42,7 +42,7 @@
"dependencies": {
"got": "^11.8.6",
"long": "^5.2.3",
"protobufjs": "^7.2.4",
"protobufjs": "^7.2.5",
"qs": "^6.11.2",
"node-rsa": "^1.1.1",
"crypto-js": "^4.1.1",
Expand All @@ -52,23 +52,23 @@
"@cospired/i18n-iso-languages": "^4.1.0",
"fs-extra": "^11.1.1",
"sweet-collections": "^1.1.0",
"mqtt": "^5.0.3",
"mqtt": "^5.0.4",
"node-schedule": "^2.1.1",
"p-throttle": "^4.1.1",
"image-type": "^4.1.0",
"date-and-time": "^3.0.2"
},
"devDependencies": {
"@types/node": "^16.18.41",
"@types/node": "^16.18.46",
"@types/qs": "^6.9.7",
"@types/node-rsa": "^1.1.1",
"@types/crypto-js": "^4.1.1",
"@types/fs-extra": "^11.0.1",
"@types/node-schedule": "^2.1.0",
"@typescript-eslint/eslint-plugin": "^6.4.0",
"@typescript-eslint/parser": "^6.4.0",
"eslint": "^8.47.0",
"typescript": "^5.1.6"
"@typescript-eslint/eslint-plugin": "^6.5.0",
"@typescript-eslint/parser": "^6.5.0",
"eslint": "^8.48.0",
"typescript": "^5.2.2"
},
"bugs": {
"url": "https://github.com/bropat/eufy-security-client/issues"
Expand Down
162 changes: 81 additions & 81 deletions src/eufysecurity.ts

Large diffs are not rendered by default.

222 changes: 106 additions & 116 deletions src/http/api.ts

Large diffs are not rendered by default.

172 changes: 86 additions & 86 deletions src/http/device.ts

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/http/parameter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Logger } from "ts-log";

import { CommandType } from "../p2p/types";
import { decodeBase64 } from "../p2p/utils";
import { decodeBase64, getNullTerminatedString } from "../p2p/utils";
import { parseJSON } from "../utils";
import { ParamType } from "./types";

Expand All @@ -26,7 +26,7 @@ export class ParameterHelper {
type === CommandType.CMD_WALL_LIGHT_SETTINGS_COLORED_LIGHTING_COLORS ||
type === CommandType.CMD_WALL_LIGHT_SETTINGS_DYNAMIC_LIGHTING_THEMES) {
if (typeof value === "string") {
const parsedValue = parseJSON(decodeBase64(value).toString("utf8"), log);
const parsedValue = parseJSON(getNullTerminatedString(decodeBase64(value), "utf-8"), log);
if (parsedValue === undefined) {
log.warn("Non-parsable parameter value received from eufy cloud. Will be ignored.", { type: type, value: value });
}
Expand Down
471 changes: 246 additions & 225 deletions src/http/station.ts

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/http/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5065,7 +5065,7 @@ export const DeviceProperties: Properties = {
[PropertyName.DeviceSnoozeStartTime]: DeviceSnoozeStartTimeProperty,
[PropertyName.DevicePersonName]: DevicePersonNameProperty,
},
[DeviceType.FLOODLIGHT_CAMERA_8424]: {
[DeviceType.FLOODLIGHT_CAMERA_8424]: { // T8424 Firmware: 2.0.8.8 (20230807)
...GenericDeviceProperties,
[PropertyName.DeviceEnabled]: DeviceEnabledStandaloneProperty,
[PropertyName.DeviceAutoNightvision]: DeviceAutoNightvisionProperty,
Expand Down Expand Up @@ -5095,8 +5095,8 @@ export const DeviceProperties: Properties = {
[PropertyName.DeviceVideoStreamingQuality]: DeviceVideoStreamingQualityProperty,
[PropertyName.DeviceNotificationType]: DeviceNotificationTypeIndoorFloodlightProperty,
[PropertyName.DeviceVideoRecordingQuality]: DeviceVideoRecordingQualityIndoorProperty,
[PropertyName.DeviceWifiRSSI]: DeviceWifiRSSIProperty,
[PropertyName.DeviceWifiSignalLevel]: DeviceWifiSignalLevelProperty,
//[PropertyName.DeviceWifiRSSI]: DeviceWifiRSSIProperty,
//[PropertyName.DeviceWifiSignalLevel]: DeviceWifiSignalLevelProperty,
[PropertyName.DeviceSnooze]: DeviceSnoozeProperty,
[PropertyName.DeviceSnoozeTime]: DeviceSnoozeTimeProperty,
[PropertyName.DeviceSnoozeStartTime]: DeviceSnoozeStartTimeProperty,
Expand Down
5 changes: 5 additions & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,9 @@ export interface EufySecurityEvents {
"user username updated": (device: Device, username: string) => void;
"user schedule updated": (device: Device, username: string, schedule: Schedule) => void;
"user passcode updated": (device: Device, username: string) => void;
}

export interface ErrorObject {
message: string;
stacktrace?: string;
}
9 changes: 5 additions & 4 deletions src/mqtt/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { load, Root } from "protobufjs";

import { MQTTServiceEvents } from "./interface";
import { DeviceSmartLockMessage } from "./model";
import { getError } from "../utils";

export class MQTTService extends TypedEmitter<MQTTServiceEvents> {

Expand Down Expand Up @@ -110,17 +111,17 @@ export class MQTTService extends TypedEmitter<MQTTServiceEvents> {
});
this.client.on("error", (error) => {
this.connecting = false;
this.log.error("MQTT Error", error);
this.log.error("MQTT Error", { error: getError(error) });
if ((error as any).code === 1 || (error as any).code === 2 || (error as any).code === 4 || (error as any).code === 5)
this.client?.end();
});
this.client.on("message", (topic, message, _packet) => {
if (topic.includes("smart_lock")) {
const parsedMessage = this.parseSmartLockMessage(message);
this.log.debug("Received a smart lock message over MQTT", parsedMessage);
this.log.debug("Received a smart lock message over MQTT", { message: parsedMessage });
this.emit("lock message", parsedMessage);
} else {
this.log.debug("MQTT message received", topic, message.toString("hex"));
this.log.debug("MQTT message received", { topic: topic, message: message.toString("hex") });
}
});
}
Expand All @@ -129,7 +130,7 @@ export class MQTTService extends TypedEmitter<MQTTServiceEvents> {
private _subscribeLock(deviceSN: string): void {
this.client?.subscribe(this.SUBSCRIBE_LOCK_FORMAT.replace("<device_sn>", deviceSN), { qos: 1 }, (error, granted) => {
if (error) {
this.log.error(`Subscribe error for lock ${deviceSN}`, error);
this.log.error(`Subscribe error for lock ${deviceSN}`, { error: getError(error), deviceSN: deviceSN });
}
if (granted) {
this.log.info(`Successfully registered to MQTT notifications for lock ${deviceSN}`);
Expand Down
10 changes: 6 additions & 4 deletions src/p2p/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { SortedMap } from "sweet-collections";
import { AlarmMode, DeviceType, MicStatus, TriggerType, VideoType } from "../http/types";
import { Address, CmdCameraInfoResponse, CommandResult, CustomData } from "./models";
import { TalkbackStream } from "./talkback";
import { AlarmEvent, AudioCodec, ChargingType, CommandType, DatabaseReturnCode, IndoorSoloSmartdropCommandType, P2PDataType, SmartSafeAlarm911Event, SmartSafeShakeAlarmEvent, P2PStorageType, TFCardStatus, VideoCodec } from "./types";
import { AlarmEvent, AudioCodec, ChargingType, CommandType, DatabaseReturnCode, IndoorSoloSmartdropCommandType, P2PDataType, SmartSafeAlarm911Event, SmartSafeShakeAlarmEvent, P2PStorageType, TFCardStatus, VideoCodec, InternalP2PCommandType } from "./types";

export interface P2PClientProtocolEvents {
"alarm mode": (mode: AlarmMode) => void;
Expand Down Expand Up @@ -51,10 +51,12 @@ export interface P2PClientProtocolEvents {
}

export interface P2PQueueMessage {
commandType: CommandType;
p2pCommandType: InternalP2PCommandType;
p2pCommand: P2PCommand;
//commandType: CommandType;
nestedCommandType?: CommandType;
channel: number;
payload: Buffer;
//channel: number;
//payload: Buffer;
timestamp: number;
customData?: CustomData;
}
Expand Down
Loading

0 comments on commit fa8edf4

Please sign in to comment.