eufy-security-client 3.6.0 → 3.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/.prettierignore/342/200/216 +8 -0
  2. package/.prettierrc +11 -0
  3. package/README.md +18 -0
  4. package/a.ts +61 -0
  5. package/build/error.js.map +1 -1
  6. package/build/eufysecurity.d.ts +1 -0
  7. package/build/eufysecurity.js +721 -224
  8. package/build/eufysecurity.js.map +1 -1
  9. package/build/http/api.d.ts +29 -0
  10. package/build/http/api.js +991 -701
  11. package/build/http/api.js.map +1 -1
  12. package/build/http/cache.js.map +1 -1
  13. package/build/http/const.d.ts +6 -1
  14. package/build/http/const.js +2044 -7536
  15. package/build/http/const.js.map +1 -1
  16. package/build/http/device.d.ts +4 -0
  17. package/build/http/device.js +1325 -440
  18. package/build/http/device.js.map +1 -1
  19. package/build/http/error.js.map +1 -1
  20. package/build/http/index.js.map +1 -1
  21. package/build/http/interfaces.d.ts +22 -15
  22. package/build/http/models.d.ts +2 -1
  23. package/build/http/parameter.js +74 -63
  24. package/build/http/parameter.js.map +1 -1
  25. package/build/http/station.d.ts +20 -2
  26. package/build/http/station.js +8639 -3566
  27. package/build/http/station.js.map +1 -1
  28. package/build/http/types.d.ts +12 -0
  29. package/build/http/types.js +297 -155
  30. package/build/http/types.js.map +1 -1
  31. package/build/http/utils.d.ts +16 -6
  32. package/build/http/utils.js +335 -208
  33. package/build/http/utils.js.map +1 -1
  34. package/build/index.js.map +1 -1
  35. package/build/interfaces.d.ts +4 -3
  36. package/build/logging.js +8 -13
  37. package/build/logging.js.map +1 -1
  38. package/build/mqtt/interface.d.ts +2 -2
  39. package/build/mqtt/service.js +12 -3
  40. package/build/mqtt/service.js.map +1 -1
  41. package/build/p2p/ble.js +7 -6
  42. package/build/p2p/ble.js.map +1 -1
  43. package/build/p2p/error.js.map +1 -1
  44. package/build/p2p/interfaces.d.ts +41 -6
  45. package/build/p2p/session.js +1484 -383
  46. package/build/p2p/session.js.map +1 -1
  47. package/build/p2p/talkback.js.map +1 -1
  48. package/build/p2p/types.js +36 -36
  49. package/build/p2p/types.js.map +1 -1
  50. package/build/p2p/utils.d.ts +10 -0
  51. package/build/p2p/utils.js +183 -90
  52. package/build/p2p/utils.js.map +1 -1
  53. package/build/push/client.js +15 -4
  54. package/build/push/client.js.map +1 -1
  55. package/build/push/error.js.map +1 -1
  56. package/build/push/interfaces.d.ts +8 -8
  57. package/build/push/models.js.map +1 -1
  58. package/build/push/parser.js +6 -2
  59. package/build/push/parser.js.map +1 -1
  60. package/build/push/service.js +214 -85
  61. package/build/push/service.js.map +1 -1
  62. package/build/push/types.js.map +1 -1
  63. package/build/push/utils.js.map +1 -1
  64. package/build/utils.js +7 -15
  65. package/build/utils.js.map +1 -1
  66. package/coverage/clover.xml +11133 -13648
  67. package/coverage/coverage-final.json +20 -30
  68. package/coverage/lcov-report/error.ts.html +3 -3
  69. package/coverage/lcov-report/index.html +50 -65
  70. package/coverage/lcov-report/logging.ts.html +598 -0
  71. package/coverage/lcov.info +21072 -25751
  72. package/dont-care.js +101 -0
  73. package/package.json +9 -5
  74. package/build/package.json +0 -81
package/dont-care.js ADDED
@@ -0,0 +1,101 @@
1
+ const WebSocket = require('ws');
2
+ const fs = require('fs');
3
+
4
+ const WS_URL = 'ws://192.168.50.9:3000';
5
+
6
+ const ws = new WebSocket(WS_URL);
7
+ let id = 0;
8
+ let videoChunks = [];
9
+ let outputPath = '';
10
+
11
+ const send = (cmd, params) => ws.send(JSON.stringify({ messageId: ++id, command: cmd, ...params }));
12
+ const formatDate = (d) => d.toISOString().slice(0, 10).replaceAll('-', '');
13
+
14
+ console.log('Connecting to', WS_URL);
15
+
16
+ ws.on('open', () => {
17
+ send('set_api_schema', { schemaVersion: 21 });
18
+ send('start_listening');
19
+ });
20
+
21
+ ws.on('message', (data) => {
22
+ const msg = JSON.parse(data);
23
+
24
+ const stations = msg.result?.state?.stations;
25
+ if (stations?.length) {
26
+ console.log('Stations:', stations.join(', '));
27
+ const today = new Date(), tomorrow = new Date(today);
28
+ today.setDate(today.getDate() -1);
29
+ tomorrow.setDate(today.getDate() + 1);
30
+ stations.forEach(sn => {
31
+ if (sn === "T8030T2324021302") {
32
+ // if (sn === "T813452025312177") {
33
+ send('station.database_query_local', {
34
+ serialNumber: sn, serialNumbers: [],
35
+ startDate: formatDate(today), endDate: formatDate(tomorrow)
36
+ });
37
+
38
+ send('station.database_query_local', {
39
+ serialNumber: sn, serialNumbers: [sn],
40
+ startDate: formatDate(today), endDate: formatDate(tomorrow)
41
+ });
42
+ // send('station.get_commands', {
43
+ // serialNumber: sn
44
+ // });
45
+ }
46
+ }
47
+ );
48
+ }
49
+
50
+ const evt = msg.event?.event;
51
+
52
+ console.log(msg)
53
+
54
+ // if (evt === 'database count by date' && msg.event.data?.length) {
55
+ if (msg.messageId === 3) {
56
+ console.log("msg yess");
57
+ //console.log(msg.event.data)
58
+ //const r = msg.event.data[0];
59
+ //console.log(r)
60
+ //outputPath = './' + r.storage_path.split('/').pop().replace('.zxvideo', '.raw');
61
+ //console.log(`Found ${msg.event.data.length} events, downloading: ${r.storage_path}`);
62
+
63
+ //send('station.database_query_latest_info', { serialNumber: "T8030T2324021302" });
64
+ //station.database_query_latest_info
65
+ // send('device.start_download', { serialNumber: r.device_sn, path: r.storage_path, cipherId: r.cipher_id });
66
+ }
67
+
68
+ // if (evt === 'database query latest' && msg.event.data?.length) {
69
+ // console.log(msg.event.data);
70
+ // const r = msg.event.data[1];
71
+ // if (r.crop_local_path) {
72
+ // console.log("aaa");
73
+ // outputPath = './' + r.crop_local_path.split('/').pop().replace('.zxvideo', '.raw');
74
+ // console.log(outputPath);
75
+ // }
76
+ // }
77
+
78
+
79
+ //
80
+ // if (evt === 'download started') console.log('Download started...');
81
+ //
82
+ // if (evt === 'download video data' && msg.event.buffer?.data) {
83
+ // videoChunks.push(Buffer.from(msg.event.buffer.data));
84
+ // if (videoChunks.length % 100 === 0) process.stdout.write(` ${videoChunks.length} chunks\r`);
85
+ // }
86
+ //
87
+ // if (evt === 'download finished') {
88
+ // const buffer = Buffer.concat(videoChunks);
89
+ // fs.writeFileSync(outputPath, buffer);
90
+ // const mp4Path = outputPath.replace('.raw', '.mp4');
91
+ // console.log(`\nSaved ${buffer.length} bytes to ${outputPath}`);
92
+ // console.log(`Convert to mp4: ffmpeg -f h264 -i ${outputPath} -c:v copy -movflags +faststart ${mp4Path}`);
93
+ // ws.close();
94
+ // process.exit(0);
95
+ // }
96
+
97
+ if (msg.success === false) { console.log('ERROR:', msg.error); ws.close(); process.exit(1); }
98
+ });
99
+
100
+ ws.on('error', (e) => { console.error('Error:', e.message); process.exit(1); });
101
+ setTimeout(() => { console.log('Timeout'); ws.close(); process.exit(1); }, 120000);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eufy-security-client",
3
- "version": "3.6.0",
3
+ "version": "3.7.1",
4
4
  "description": "Client to communicate with Eufy-Security devices",
5
5
  "author": {
6
6
  "name": "bropat",
@@ -12,11 +12,14 @@
12
12
  "build:ts": "tsc -p tsconfig.build.json && npm run copy-proto-build",
13
13
  "copy-proto-build": "npx copyfiles -u 1 \"src/**/*.proto\" \"src/**/*.crt\" build",
14
14
  "test": "jest --coverage",
15
+ "test:watch": "jest --watch",
15
16
  "build": "npm run build:ts",
16
17
  "watch:ts": "tsc -p tsconfig.build.json --watch",
17
18
  "watch": "npm run watch:ts",
18
19
  "lint": "eslint --ext .ts src",
19
- "prepublishOnly": "tsc -p tsconfig.build.json && npm run copy-proto-build"
20
+ "prepublishOnly": "tsc -p tsconfig.build.json && npm run copy-proto-build",
21
+ "format": "prettier --write \"src/**/*.ts\"",
22
+ "format:check": "prettier --check \"src/**/*.ts\""
20
23
  },
21
24
  "license": "MIT",
22
25
  "keywords": [
@@ -42,18 +45,18 @@
42
45
  "dependencies": {
43
46
  "@cospired/i18n-iso-languages": "^4.2.0",
44
47
  "crypto-js": "^4.2.0",
45
- "date-and-time": "^4.1.1",
48
+ "date-and-time": "^4.2.0",
46
49
  "fs-extra": "^11.3.3",
47
50
  "got": "^14.4.2",
48
51
  "i18n-iso-countries": "^7.12.0",
49
52
  "image-type": "^5.2.0",
50
53
  "long": "^5.2.3",
51
- "mqtt": "^5.10.1",
54
+ "mqtt": "^5.15.0",
52
55
  "node-rsa": "^1.1.1",
53
56
  "node-schedule": "^2.1.1",
54
57
  "p-throttle": "^8.1.0",
55
58
  "protobufjs": "^8.0.0",
56
- "qs": "^6.13.0",
59
+ "qs": "^6.14.2",
57
60
  "sweet-collections": "^1.1.0",
58
61
  "tiny-typed-emitter": "^2.1.0",
59
62
  "typescript-logging": "^2.2.0",
@@ -70,6 +73,7 @@
70
73
  "@typescript-eslint/parser": "^8.48.0 ",
71
74
  "eslint": "^9.39.1",
72
75
  "jest": "^29.7.0",
76
+ "prettier": "^3.8.1",
73
77
  "ts-jest": "^29.4.6",
74
78
  "typescript": "^5.9.3",
75
79
  "typescript-eslint": "^8.49.0"
@@ -1,81 +0,0 @@
1
- {
2
- "name": "eufy-security-client",
3
- "version": "3.5.0",
4
- "description": "Client to comunicate with Eufy-Security devices",
5
- "author": {
6
- "name": "bropat",
7
- "email": "patrick.broetto@gmail.com"
8
- },
9
- "homepage": "https://github.com/bropat/eufy-security-client",
10
- "main": "build/index.js",
11
- "scripts": {
12
- "build:ts": "tsc -p tsconfig.build.json && npm run copy-proto-build",
13
- "copy-proto-build": "npx copyfiles -u 1 \"src/**/*.proto\" \"src/**/*.crt\" build",
14
- "test": "jest --coverage",
15
- "build": "npm run build:ts",
16
- "watch:ts": "tsc -p tsconfig.build.json --watch",
17
- "watch": "npm run watch:ts",
18
- "lint": "eslint --ext .ts src",
19
- "prepublishOnly": "tsc -p tsconfig.build.json && npm run copy-proto-build"
20
- },
21
- "license": "MIT",
22
- "keywords": [
23
- "eufy",
24
- "eufycam",
25
- "cam",
26
- "cameras",
27
- "security",
28
- "eufy-security",
29
- "doorbell",
30
- "lock",
31
- "keypad",
32
- "smartlock",
33
- "smartsafe"
34
- ],
35
- "repository": {
36
- "type": "git",
37
- "url": "https://github.com/bropat/eufy-security-client"
38
- },
39
- "engines": {
40
- "node": ">=20.0.0"
41
- },
42
- "dependencies": {
43
- "@cospired/i18n-iso-languages": "^4.2.0",
44
- "crypto-js": "^4.2.0",
45
- "date-and-time": "^4.1.1",
46
- "fs-extra": "^11.2.0",
47
- "got": "^14.4.2",
48
- "i18n-iso-countries": "^7.12.0",
49
- "image-type": "^5.2.0",
50
- "long": "^5.2.3",
51
- "mqtt": "^5.10.1",
52
- "node-rsa": "^1.1.1",
53
- "node-schedule": "^2.1.1",
54
- "p-throttle": "^8.1.0",
55
- "protobufjs": "^7.4.0",
56
- "qs": "^6.13.0",
57
- "sweet-collections": "^1.1.0",
58
- "tiny-typed-emitter": "^2.1.0",
59
- "typescript-logging": "^2.2.0",
60
- "typescript-logging-category-style": "^2.2.0"
61
- },
62
- "devDependencies": {
63
- "@types/crypto-js": "^4.2.2",
64
- "@types/jest": "^30.0.0",
65
- "@types/node": "^20.16.10",
66
- "@types/node-rsa": "^1.1.4",
67
- "@types/node-schedule": "^2.1.7",
68
- "@types/qs": "^6.9.16",
69
- "@typescript-eslint/eslint-plugin": "^8.48.0",
70
- "@typescript-eslint/parser": "^8.48.0 ",
71
- "eslint": "^9.39.1",
72
- "jest": "^30.2.0",
73
- "ts-jest": "^29.4.6",
74
- "typescript": "^5.9.3",
75
- "typescript-eslint": "^8.49.0"
76
- },
77
- "bugs": {
78
- "url": "https://github.com/bropat/eufy-security-client/issues"
79
- },
80
- "readmeFilename": "README.md"
81
- }