From df2547464615f1ebbb6fbe1b61b48c129bd4a548 Mon Sep 17 00:00:00 2001 From: bropat Date: Tue, 3 May 2022 17:39:05 +0000 Subject: [PATCH] Updated dependency eufy-security-client to 2.0.1 Updated dependency ws to 8.6.0 --- docs/_coverpage.md | 2 +- package-lock.json | 192 +++++++++++++++--------------- package.json | 10 +- src/lib/device/message_handler.ts | 2 +- src/lib/forward.ts | 42 ++++--- src/lib/server.ts | 11 +- src/lib/state.ts | 4 +- 7 files changed, 133 insertions(+), 130 deletions(-) diff --git a/docs/_coverpage.md b/docs/_coverpage.md index 98d45f1..7c418aa 100644 --- a/docs/_coverpage.md +++ b/docs/_coverpage.md @@ -1,6 +1,6 @@ ![logo](_media/eufy-security-ws.png) -# eufy-security-ws 0.9.0 +# eufy-security-ws 0.9.1 > A small server wrapper around [eufy-security-client](https://github.com/bropat/eufy-security-client) library to access it via a WebSocket diff --git a/package-lock.json b/package-lock.json index 00ee22b..df005f9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,21 +1,21 @@ { "name": "eufy-security-ws", - "version": "0.9.0", + "version": "0.9.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "eufy-security-ws", - "version": "0.9.0", + "version": "0.9.1", "license": "MIT", "dependencies": { "ansi-colors": "^4.1.1", "commander": "^9.2.0", - "eufy-security-client": "^2.0.0", + "eufy-security-client": "^2.0.1", "fs-extra": "^10.1.0", "promptly": "^3.2.0", "tslog": "^3.3.3", - "ws": "^8.5.0" + "ws": "^8.6.0" }, "bin": { "eufy-security-client": "dist/bin/client.js", @@ -26,8 +26,8 @@ "@types/node-rsa": "^1.1.1", "@types/promptly": "^3.0.2", "@types/ws": "^8.5.3", - "@typescript-eslint/eslint-plugin": "^5.21.0", - "@typescript-eslint/parser": "^5.21.0", + "@typescript-eslint/eslint-plugin": "^5.22.0", + "@typescript-eslint/parser": "^5.22.0", "eslint": "^8.14.0", "eslint-config-prettier": "^8.5.0", "prettier": "^2.6.2", @@ -318,14 +318,14 @@ } }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "5.21.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.21.0.tgz", - "integrity": "sha512-fTU85q8v5ZLpoZEyn/u1S2qrFOhi33Edo2CZ0+q1gDaWWm0JuPh3bgOyU8lM0edIEYgKLDkPFiZX2MOupgjlyg==", + "version": "5.22.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.22.0.tgz", + "integrity": "sha512-YCiy5PUzpAeOPGQ7VSGDEY2NeYUV1B0swde2e0HzokRsHBYjSdF6DZ51OuRZxVPHx0032lXGLvOMls91D8FXlg==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "5.21.0", - "@typescript-eslint/type-utils": "5.21.0", - "@typescript-eslint/utils": "5.21.0", + "@typescript-eslint/scope-manager": "5.22.0", + "@typescript-eslint/type-utils": "5.22.0", + "@typescript-eslint/utils": "5.22.0", "debug": "^4.3.2", "functional-red-black-tree": "^1.0.1", "ignore": "^5.1.8", @@ -351,14 +351,14 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "5.21.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.21.0.tgz", - "integrity": "sha512-8RUwTO77hstXUr3pZoWZbRQUxXcSXafZ8/5gpnQCfXvgmP9gpNlRGlWzvfbEQ14TLjmtU8eGnONkff8U2ui2Eg==", + "version": "5.22.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.22.0.tgz", + "integrity": "sha512-piwC4krUpRDqPaPbFaycN70KCP87+PC5WZmrWs+DlVOxxmF+zI6b6hETv7Quy4s9wbkV16ikMeZgXsvzwI3icQ==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "5.21.0", - "@typescript-eslint/types": "5.21.0", - "@typescript-eslint/typescript-estree": "5.21.0", + "@typescript-eslint/scope-manager": "5.22.0", + "@typescript-eslint/types": "5.22.0", + "@typescript-eslint/typescript-estree": "5.22.0", "debug": "^4.3.2" }, "engines": { @@ -378,13 +378,13 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "5.21.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.21.0.tgz", - "integrity": "sha512-XTX0g0IhvzcH/e3393SvjRCfYQxgxtYzL3UREteUneo72EFlt7UNoiYnikUtmGVobTbhUDByhJ4xRBNe+34kOQ==", + "version": "5.22.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.22.0.tgz", + "integrity": "sha512-yA9G5NJgV5esANJCO0oF15MkBO20mIskbZ8ijfmlKIvQKg0ynVKfHZ15/nhAJN5m8Jn3X5qkwriQCiUntC9AbA==", "dev": true, "dependencies": { - "@typescript-eslint/types": "5.21.0", - "@typescript-eslint/visitor-keys": "5.21.0" + "@typescript-eslint/types": "5.22.0", + "@typescript-eslint/visitor-keys": "5.22.0" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -395,12 +395,12 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "5.21.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.21.0.tgz", - "integrity": "sha512-MxmLZj0tkGlkcZCSE17ORaHl8Th3JQwBzyXL/uvC6sNmu128LsgjTX0NIzy+wdH2J7Pd02GN8FaoudJntFvSOw==", + "version": "5.22.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.22.0.tgz", + "integrity": "sha512-iqfLZIsZhK2OEJ4cQ01xOq3NaCuG5FQRKyHicA3xhZxMgaxQazLUHbH/B2k9y5i7l3+o+B5ND9Mf1AWETeMISA==", "dev": true, "dependencies": { - "@typescript-eslint/utils": "5.21.0", + "@typescript-eslint/utils": "5.22.0", "debug": "^4.3.2", "tsutils": "^3.21.0" }, @@ -421,9 +421,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "5.21.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.21.0.tgz", - "integrity": "sha512-XnOOo5Wc2cBlq8Lh5WNvAgHzpjnEzxn4CJBwGkcau7b/tZ556qrWXQz4DJyChYg8JZAD06kczrdgFPpEQZfDsA==", + "version": "5.22.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.22.0.tgz", + "integrity": "sha512-T7owcXW4l0v7NTijmjGWwWf/1JqdlWiBzPqzAWhobxft0SiEvMJB56QXmeCQjrPuM8zEfGUKyPQr/L8+cFUBLw==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -434,13 +434,13 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "5.21.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.21.0.tgz", - "integrity": "sha512-Y8Y2T2FNvm08qlcoSMoNchh9y2Uj3QmjtwNMdRQkcFG7Muz//wfJBGBxh8R7HAGQFpgYpdHqUpEoPQk+q9Kjfg==", + "version": "5.22.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.22.0.tgz", + "integrity": "sha512-EyBEQxvNjg80yinGE2xdhpDYm41so/1kOItl0qrjIiJ1kX/L/L8WWGmJg8ni6eG3DwqmOzDqOhe6763bF92nOw==", "dev": true, "dependencies": { - "@typescript-eslint/types": "5.21.0", - "@typescript-eslint/visitor-keys": "5.21.0", + "@typescript-eslint/types": "5.22.0", + "@typescript-eslint/visitor-keys": "5.22.0", "debug": "^4.3.2", "globby": "^11.0.4", "is-glob": "^4.0.3", @@ -461,15 +461,15 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "5.21.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.21.0.tgz", - "integrity": "sha512-q/emogbND9wry7zxy7VYri+7ydawo2HDZhRZ5k6yggIvXa7PvBbAAZ4PFH/oZLem72ezC4Pr63rJvDK/sTlL8Q==", + "version": "5.22.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.22.0.tgz", + "integrity": "sha512-HodsGb037iobrWSUMS7QH6Hl1kppikjA1ELiJlNSTYf/UdMEwzgj0WIp+lBNb6WZ3zTwb0tEz51j0Wee3iJ3wQ==", "dev": true, "dependencies": { "@types/json-schema": "^7.0.9", - "@typescript-eslint/scope-manager": "5.21.0", - "@typescript-eslint/types": "5.21.0", - "@typescript-eslint/typescript-estree": "5.21.0", + "@typescript-eslint/scope-manager": "5.22.0", + "@typescript-eslint/types": "5.22.0", + "@typescript-eslint/typescript-estree": "5.22.0", "eslint-scope": "^5.1.1", "eslint-utils": "^3.0.0" }, @@ -485,12 +485,12 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "5.21.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.21.0.tgz", - "integrity": "sha512-SX8jNN+iHqAF0riZQMkm7e8+POXa/fXw5cxL+gjpyP+FI+JVNhii53EmQgDAfDcBpFekYSlO0fGytMQwRiMQCA==", + "version": "5.22.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.22.0.tgz", + "integrity": "sha512-DbgTqn2Dv5RFWluG88tn0pP6Ex0ROF+dpDO1TNNZdRtLjUr6bdznjA6f/qNqJLjd2PgguAES2Zgxh/JzwzETDg==", "dev": true, "dependencies": { - "@typescript-eslint/types": "5.21.0", + "@typescript-eslint/types": "5.22.0", "eslint-visitor-keys": "^3.0.0" }, "engines": { @@ -1218,9 +1218,9 @@ } }, "node_modules/eufy-security-client": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/eufy-security-client/-/eufy-security-client-2.0.0.tgz", - "integrity": "sha512-vslCsj1+jk+1dTsa/W5VGIyQz22h9ens5yU+mfiTWoivemx3ijNYHKDU9NqUS+e9RTe831i62k/ssHG07qgQ0Q==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/eufy-security-client/-/eufy-security-client-2.0.1.tgz", + "integrity": "sha512-fncje2cMkNIumJw4iqBX5sKW0W7zIij0m6CYcGZ+szRa/G91w2z//WXRTXIhnTRTt0r2nl+2K12zgYfArA6Vkg==", "dependencies": { "@cospired/i18n-iso-languages": "^4.0.0", "crypto-js": "^4.1.1", @@ -2662,9 +2662,9 @@ "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, "node_modules/ws": { - "version": "8.5.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.5.0.tgz", - "integrity": "sha512-BWX0SWVgLPzYwF8lTzEy1egjhS4S4OEAHfsO8o65WOVsrnSRGaSiUaa9e0ggGlkMTtBlmOpEXiie9RUcBO86qg==", + "version": "8.6.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.6.0.tgz", + "integrity": "sha512-AzmM3aH3gk0aX7/rZLYvjdvZooofDu3fFOzGqcSnQ1tOcTWwhM/o+q++E8mAyVVIyUdajrkzWUGftaVSDLn1bw==", "engines": { "node": ">=10.0.0" }, @@ -2952,14 +2952,14 @@ } }, "@typescript-eslint/eslint-plugin": { - "version": "5.21.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.21.0.tgz", - "integrity": "sha512-fTU85q8v5ZLpoZEyn/u1S2qrFOhi33Edo2CZ0+q1gDaWWm0JuPh3bgOyU8lM0edIEYgKLDkPFiZX2MOupgjlyg==", + "version": "5.22.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.22.0.tgz", + "integrity": "sha512-YCiy5PUzpAeOPGQ7VSGDEY2NeYUV1B0swde2e0HzokRsHBYjSdF6DZ51OuRZxVPHx0032lXGLvOMls91D8FXlg==", "dev": true, "requires": { - "@typescript-eslint/scope-manager": "5.21.0", - "@typescript-eslint/type-utils": "5.21.0", - "@typescript-eslint/utils": "5.21.0", + "@typescript-eslint/scope-manager": "5.22.0", + "@typescript-eslint/type-utils": "5.22.0", + "@typescript-eslint/utils": "5.22.0", "debug": "^4.3.2", "functional-red-black-tree": "^1.0.1", "ignore": "^5.1.8", @@ -2969,52 +2969,52 @@ } }, "@typescript-eslint/parser": { - "version": "5.21.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.21.0.tgz", - "integrity": "sha512-8RUwTO77hstXUr3pZoWZbRQUxXcSXafZ8/5gpnQCfXvgmP9gpNlRGlWzvfbEQ14TLjmtU8eGnONkff8U2ui2Eg==", + "version": "5.22.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.22.0.tgz", + "integrity": "sha512-piwC4krUpRDqPaPbFaycN70KCP87+PC5WZmrWs+DlVOxxmF+zI6b6hETv7Quy4s9wbkV16ikMeZgXsvzwI3icQ==", "dev": true, "requires": { - "@typescript-eslint/scope-manager": "5.21.0", - "@typescript-eslint/types": "5.21.0", - "@typescript-eslint/typescript-estree": "5.21.0", + "@typescript-eslint/scope-manager": "5.22.0", + "@typescript-eslint/types": "5.22.0", + "@typescript-eslint/typescript-estree": "5.22.0", "debug": "^4.3.2" } }, "@typescript-eslint/scope-manager": { - "version": "5.21.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.21.0.tgz", - "integrity": "sha512-XTX0g0IhvzcH/e3393SvjRCfYQxgxtYzL3UREteUneo72EFlt7UNoiYnikUtmGVobTbhUDByhJ4xRBNe+34kOQ==", + "version": "5.22.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.22.0.tgz", + "integrity": "sha512-yA9G5NJgV5esANJCO0oF15MkBO20mIskbZ8ijfmlKIvQKg0ynVKfHZ15/nhAJN5m8Jn3X5qkwriQCiUntC9AbA==", "dev": true, "requires": { - "@typescript-eslint/types": "5.21.0", - "@typescript-eslint/visitor-keys": "5.21.0" + "@typescript-eslint/types": "5.22.0", + "@typescript-eslint/visitor-keys": "5.22.0" } }, "@typescript-eslint/type-utils": { - "version": "5.21.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.21.0.tgz", - "integrity": "sha512-MxmLZj0tkGlkcZCSE17ORaHl8Th3JQwBzyXL/uvC6sNmu128LsgjTX0NIzy+wdH2J7Pd02GN8FaoudJntFvSOw==", + "version": "5.22.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.22.0.tgz", + "integrity": "sha512-iqfLZIsZhK2OEJ4cQ01xOq3NaCuG5FQRKyHicA3xhZxMgaxQazLUHbH/B2k9y5i7l3+o+B5ND9Mf1AWETeMISA==", "dev": true, "requires": { - "@typescript-eslint/utils": "5.21.0", + "@typescript-eslint/utils": "5.22.0", "debug": "^4.3.2", "tsutils": "^3.21.0" } }, "@typescript-eslint/types": { - "version": "5.21.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.21.0.tgz", - "integrity": "sha512-XnOOo5Wc2cBlq8Lh5WNvAgHzpjnEzxn4CJBwGkcau7b/tZ556qrWXQz4DJyChYg8JZAD06kczrdgFPpEQZfDsA==", + "version": "5.22.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.22.0.tgz", + "integrity": "sha512-T7owcXW4l0v7NTijmjGWwWf/1JqdlWiBzPqzAWhobxft0SiEvMJB56QXmeCQjrPuM8zEfGUKyPQr/L8+cFUBLw==", "dev": true }, "@typescript-eslint/typescript-estree": { - "version": "5.21.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.21.0.tgz", - "integrity": "sha512-Y8Y2T2FNvm08qlcoSMoNchh9y2Uj3QmjtwNMdRQkcFG7Muz//wfJBGBxh8R7HAGQFpgYpdHqUpEoPQk+q9Kjfg==", + "version": "5.22.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.22.0.tgz", + "integrity": "sha512-EyBEQxvNjg80yinGE2xdhpDYm41so/1kOItl0qrjIiJ1kX/L/L8WWGmJg8ni6eG3DwqmOzDqOhe6763bF92nOw==", "dev": true, "requires": { - "@typescript-eslint/types": "5.21.0", - "@typescript-eslint/visitor-keys": "5.21.0", + "@typescript-eslint/types": "5.22.0", + "@typescript-eslint/visitor-keys": "5.22.0", "debug": "^4.3.2", "globby": "^11.0.4", "is-glob": "^4.0.3", @@ -3023,26 +3023,26 @@ } }, "@typescript-eslint/utils": { - "version": "5.21.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.21.0.tgz", - "integrity": "sha512-q/emogbND9wry7zxy7VYri+7ydawo2HDZhRZ5k6yggIvXa7PvBbAAZ4PFH/oZLem72ezC4Pr63rJvDK/sTlL8Q==", + "version": "5.22.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.22.0.tgz", + "integrity": "sha512-HodsGb037iobrWSUMS7QH6Hl1kppikjA1ELiJlNSTYf/UdMEwzgj0WIp+lBNb6WZ3zTwb0tEz51j0Wee3iJ3wQ==", "dev": true, "requires": { "@types/json-schema": "^7.0.9", - "@typescript-eslint/scope-manager": "5.21.0", - "@typescript-eslint/types": "5.21.0", - "@typescript-eslint/typescript-estree": "5.21.0", + "@typescript-eslint/scope-manager": "5.22.0", + "@typescript-eslint/types": "5.22.0", + "@typescript-eslint/typescript-estree": "5.22.0", "eslint-scope": "^5.1.1", "eslint-utils": "^3.0.0" } }, "@typescript-eslint/visitor-keys": { - "version": "5.21.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.21.0.tgz", - "integrity": "sha512-SX8jNN+iHqAF0riZQMkm7e8+POXa/fXw5cxL+gjpyP+FI+JVNhii53EmQgDAfDcBpFekYSlO0fGytMQwRiMQCA==", + "version": "5.22.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.22.0.tgz", + "integrity": "sha512-DbgTqn2Dv5RFWluG88tn0pP6Ex0ROF+dpDO1TNNZdRtLjUr6bdznjA6f/qNqJLjd2PgguAES2Zgxh/JzwzETDg==", "dev": true, "requires": { - "@typescript-eslint/types": "5.21.0", + "@typescript-eslint/types": "5.22.0", "eslint-visitor-keys": "^3.0.0" } }, @@ -3575,9 +3575,9 @@ "dev": true }, "eufy-security-client": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/eufy-security-client/-/eufy-security-client-2.0.0.tgz", - "integrity": "sha512-vslCsj1+jk+1dTsa/W5VGIyQz22h9ens5yU+mfiTWoivemx3ijNYHKDU9NqUS+e9RTe831i62k/ssHG07qgQ0Q==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/eufy-security-client/-/eufy-security-client-2.0.1.tgz", + "integrity": "sha512-fncje2cMkNIumJw4iqBX5sKW0W7zIij0m6CYcGZ+szRa/G91w2z//WXRTXIhnTRTt0r2nl+2K12zgYfArA6Vkg==", "requires": { "@cospired/i18n-iso-languages": "^4.0.0", "crypto-js": "^4.1.1", @@ -4628,9 +4628,9 @@ "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, "ws": { - "version": "8.5.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.5.0.tgz", - "integrity": "sha512-BWX0SWVgLPzYwF8lTzEy1egjhS4S4OEAHfsO8o65WOVsrnSRGaSiUaa9e0ggGlkMTtBlmOpEXiie9RUcBO86qg==", + "version": "8.6.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.6.0.tgz", + "integrity": "sha512-AzmM3aH3gk0aX7/rZLYvjdvZooofDu3fFOzGqcSnQ1tOcTWwhM/o+q++E8mAyVVIyUdajrkzWUGftaVSDLn1bw==", "requires": {} }, "xtend": { diff --git a/package.json b/package.json index 65de363..ae881ae 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eufy-security-ws", - "version": "0.9.0", + "version": "0.9.1", "description": "Node WebSocket server implementation to integrate Eufy Security devices", "main": "dist/lib/index.js", "bin": { @@ -45,19 +45,19 @@ "dependencies": { "ansi-colors": "^4.1.1", "commander": "^9.2.0", - "eufy-security-client": "^2.0.0", + "eufy-security-client": "^2.0.1", "fs-extra": "^10.1.0", "promptly": "^3.2.0", "tslog": "^3.3.3", - "ws": "^8.5.0" + "ws": "^8.6.0" }, "devDependencies": { "@types/node": "^16.11.32", "@types/node-rsa": "^1.1.1", "@types/promptly": "^3.0.2", "@types/ws": "^8.5.3", - "@typescript-eslint/eslint-plugin": "^5.21.0", - "@typescript-eslint/parser": "^5.21.0", + "@typescript-eslint/eslint-plugin": "^5.22.0", + "@typescript-eslint/parser": "^5.22.0", "eslint": "^8.14.0", "eslint-config-prettier": "^8.5.0", "prettier": "^2.6.2", diff --git a/src/lib/device/message_handler.ts b/src/lib/device/message_handler.ts index e568084..ef80cc4 100755 --- a/src/lib/device/message_handler.ts +++ b/src/lib/device/message_handler.ts @@ -33,7 +33,7 @@ export class DeviceMessageHandler { static async handle(message: IncomingMessageDevice, driver: EufySecurity, client: Client): Promise { const { serialNumber, command } = message; - const device = driver.getDevice(serialNumber); + const device = await driver.getDevice(serialNumber); const station = driver.getStation(device.getStationSerial()); switch (command) { diff --git a/src/lib/forward.ts b/src/lib/forward.ts index e8e3a10..c3d6c5a 100755 --- a/src/lib/forward.ts +++ b/src/lib/forward.ts @@ -137,9 +137,11 @@ export class EventForwarder { this.setupStation(station); }); - this.clients.driver.getDevices().forEach(device => { - this.setupDevice(device); - }); + this.clients.driver.getDevices().then((devices: Device[]) => { + devices.forEach(device => { + this.setupDevice(device); + }); + }).catch(); this.clients.driver.on("station livestream start", (station: Station, device: Device, metadata: StreamMetadata, videostream: Readable, audiostream: Readable) => { const serialNumber = device.getSerial(); @@ -379,13 +381,14 @@ export class EventForwarder { // eslint-disable-next-line @typescript-eslint/no-unused-vars station.on("rtsp url", (station: Station, channel:number, value: string) => { - const device = this.clients.driver.getStationDevice(station.getSerial(), channel); - this.forwardEvent({ - source: "device", - event: DeviceEvent.gotRtspUrl, - serialNumber: device.getSerial(), - rtspUrl: value, - }, 0); + this.clients.driver.getStationDevice(station.getSerial(), channel).then((device: Device) => { + this.forwardEvent({ + source: "device", + event: DeviceEvent.gotRtspUrl, + serialNumber: device.getSerial(), + rtspUrl: value, + }, 0); + }).catch(); }); station.on("command result", (station: Station, result: CommandResult) => { @@ -478,15 +481,16 @@ export class EventForwarder { break; } if (command !== undefined) { - const device = this.clients.driver.getStationDevice(station.getSerial(), result.channel); - this.forwardEvent({ - source: "device", - event: DeviceEvent.commandResult, - serialNumber: device.getSerial(), - command: command.split(".")[1], - returnCode: result.return_code, - returnCodeName: ErrorCode[result.return_code] !== undefined ? ErrorCode[result.return_code] : "UNKNOWN", - }, 0); + this.clients.driver.getStationDevice(station.getSerial(), result.channel).then((device: Device) => { + this.forwardEvent({ + source: "device", + event: DeviceEvent.commandResult, + serialNumber: device.getSerial(), + command: command?.split(".")[1], + returnCode: result.return_code, + returnCodeName: ErrorCode[result.return_code] !== undefined ? ErrorCode[result.return_code] : "UNKNOWN", + }, 0); + }).catch(); } } }); diff --git a/src/lib/server.ts b/src/lib/server.ts index 3c6c6bc..df277cf 100755 --- a/src/lib/server.ts +++ b/src/lib/server.ts @@ -3,7 +3,7 @@ import { WebSocketServer } from "ws" import { Logger } from "tslog"; import { EventEmitter, once } from "events"; import { Server as HttpServer, createServer, IncomingMessage as HttpIncomingMessage } from "http"; -import { DeviceNotFoundError, EufySecurity, InvalidCountryCodeError, InvalidLanguageCodeError, InvalidPropertyValueError, libVersion, NotSupportedError, ReadOnlyPropertyError, StationNotFoundError, WrongStationError, PropertyNotSupportedError, InvalidPropertyError, InvalidCommandValueError } from "eufy-security-client"; +import { DeviceNotFoundError, EufySecurity, InvalidCountryCodeError, InvalidLanguageCodeError, InvalidPropertyValueError, libVersion, NotSupportedError, ReadOnlyPropertyError, StationNotFoundError, WrongStationError, PropertyNotSupportedError, InvalidPropertyError, InvalidCommandValueError, Device } from "eufy-security-client"; import { EventForwarder } from "./forward"; import type * as OutgoingMessages from "./outgoing_message"; @@ -90,7 +90,7 @@ export class Client { if (msg.command === ServerCommand.startListening) { this.sendResultSuccess(msg.messageId, { - state: dumpState(this.driver, this.schemaVersion), + state: await dumpState(this.driver, this.schemaVersion), }); this.receiveEvents = true; return; @@ -304,8 +304,7 @@ export class ClientsController { disconnectedClients.forEach(client => { Object.keys(client.receiveLivestream).forEach(serialNumber => { - try { - const device = this.driver.getDevice(serialNumber); + this.driver.getDevice(serialNumber).then((device: Device) => { const station = this.driver.getStation(device.getStationSerial()); const streamingDevices = DeviceMessageHandler.getStreamingDevices(station.getSerial()); @@ -316,9 +315,9 @@ export class ClientsController { client.receiveLivestream[device.getSerial()] = false; DeviceMessageHandler.removeStreamingDevice(station.getSerial(), client); - } catch(error) { + }).catch((error) => { this.logger.error(`Error doing cleanup of client`, error); - } + }); }); }); this.cleanupLoggingEventForwarder(); diff --git a/src/lib/state.ts b/src/lib/state.ts index 1baaaaa..fdfff46 100755 --- a/src/lib/state.ts +++ b/src/lib/state.ts @@ -18,13 +18,13 @@ export type EufySecurityState = | EufySecurityStateSchema0; // eslint-disable-next-line @typescript-eslint/no-unused-vars -export const dumpState = (driver: EufySecurity, schemaVersion: number): EufySecurityState => { +export const dumpState = async (driver: EufySecurity, schemaVersion: number): Promise => { const base: Partial = { driver: dumpDriver(driver, schemaVersion), stations: Array.from(driver.getStations(), (station) => dumpStation(station, schemaVersion) ), - devices: Array.from(driver.getDevices(), (device) => + devices: Array.from(await driver.getDevices(), (device) => dumpDevice(device, schemaVersion) ), };