ring-client-api 11.7.2 → 11.7.4
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.
- package/lib/ring-camera.d.ts +2 -0
- package/lib/ring-camera.js +14 -3
- package/lib/test/ring-camera.spec.js +12 -0
- package/package.json +13 -10
package/lib/ring-camera.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export declare function getBatteryLevel(data: Pick<CameraData, 'battery_life' |
|
|
|
14
14
|
export declare function getSearchQueryString(options: CameraEventOptions | (HistoryOptions & {
|
|
15
15
|
accountId: string;
|
|
16
16
|
})): string;
|
|
17
|
+
export declare function cleanSnapshotUuid(uuid?: string | null): string | null | undefined;
|
|
17
18
|
export declare class RingCamera extends Subscribed {
|
|
18
19
|
private initialData;
|
|
19
20
|
isDoorbot: boolean;
|
|
@@ -40,6 +41,7 @@ export declare class RingCamera extends Subscribed {
|
|
|
40
41
|
get name(): string;
|
|
41
42
|
get activeNotifications(): PushNotificationDing[];
|
|
42
43
|
get latestNotification(): PushNotificationDing | undefined;
|
|
44
|
+
get latestNotificationSnapshotUuid(): string | undefined;
|
|
43
45
|
get batteryLevel(): number | null;
|
|
44
46
|
get hasBattery(): boolean;
|
|
45
47
|
get hasLowBattery(): boolean;
|
package/lib/ring-camera.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RingCamera = exports.getSearchQueryString = exports.getBatteryLevel = void 0;
|
|
3
|
+
exports.RingCamera = exports.cleanSnapshotUuid = exports.getSearchQueryString = exports.getBatteryLevel = void 0;
|
|
4
4
|
const ring_types_1 = require("./ring-types");
|
|
5
5
|
const rest_client_1 = require("./rest-client");
|
|
6
6
|
const rxjs_1 = require("rxjs");
|
|
@@ -58,6 +58,13 @@ function getSearchQueryString(options) {
|
|
|
58
58
|
return queryString.length ? `?${queryString}` : '';
|
|
59
59
|
}
|
|
60
60
|
exports.getSearchQueryString = getSearchQueryString;
|
|
61
|
+
function cleanSnapshotUuid(uuid) {
|
|
62
|
+
if (!uuid) {
|
|
63
|
+
return uuid;
|
|
64
|
+
}
|
|
65
|
+
return uuid.replace(/:.*$/, '');
|
|
66
|
+
}
|
|
67
|
+
exports.cleanSnapshotUuid = cleanSnapshotUuid;
|
|
61
68
|
class RingCamera extends subscribed_1.Subscribed {
|
|
62
69
|
constructor(initialData, isDoorbot, restClient, avoidSnapshotBatteryDrain) {
|
|
63
70
|
super();
|
|
@@ -124,6 +131,10 @@ class RingCamera extends subscribed_1.Subscribed {
|
|
|
124
131
|
const notifications = this.activeNotifications;
|
|
125
132
|
return notifications[notifications.length - 1];
|
|
126
133
|
}
|
|
134
|
+
get latestNotificationSnapshotUuid() {
|
|
135
|
+
const notification = this.latestNotification;
|
|
136
|
+
return notification?.ding.image_uuid;
|
|
137
|
+
}
|
|
127
138
|
get batteryLevel() {
|
|
128
139
|
if (!('battery_life' in this.data)) {
|
|
129
140
|
return null;
|
|
@@ -368,7 +379,7 @@ class RingCamera extends subscribed_1.Subscribed {
|
|
|
368
379
|
'after-ms': afterMs,
|
|
369
380
|
'max-wait-ms': maxWaitMs,
|
|
370
381
|
extras: force ? 'force' : undefined,
|
|
371
|
-
uuid,
|
|
382
|
+
uuid: cleanSnapshotUuid(uuid),
|
|
372
383
|
},
|
|
373
384
|
headers: {
|
|
374
385
|
accept: 'image/jpeg',
|
|
@@ -381,7 +392,7 @@ class RingCamera extends subscribed_1.Subscribed {
|
|
|
381
392
|
}
|
|
382
393
|
getSnapshotByUuid(uuid) {
|
|
383
394
|
return this.restClient.request({
|
|
384
|
-
url: (0, rest_client_1.clientApi)('snapshots/uuid?uuid=' + uuid),
|
|
395
|
+
url: (0, rest_client_1.clientApi)('snapshots/uuid?uuid=' + cleanSnapshotUuid(uuid)),
|
|
385
396
|
responseType: 'buffer',
|
|
386
397
|
headers: {
|
|
387
398
|
accept: 'image/jpeg',
|
|
@@ -22,4 +22,16 @@ describe('Ring Camera', () => {
|
|
|
22
22
|
expect((0, index_1.getBatteryLevel)({ battery_life: '92', battery_life_2: 100 })).toEqual(92);
|
|
23
23
|
});
|
|
24
24
|
});
|
|
25
|
+
describe('cleanSnapshotUuid', () => {
|
|
26
|
+
it('should return the original uuid if it is already clean', () => {
|
|
27
|
+
expect((0, index_1.cleanSnapshotUuid)('c2a0a397-3538-422d-bb4e-51837a56b870')).toBe('c2a0a397-3538-422d-bb4e-51837a56b870');
|
|
28
|
+
});
|
|
29
|
+
it('should return remove anything after :', () => {
|
|
30
|
+
expect((0, index_1.cleanSnapshotUuid)('c2a0a397-3538-422d-bb4e-51837a56b870:122429140')).toBe('c2a0a397-3538-422d-bb4e-51837a56b870');
|
|
31
|
+
});
|
|
32
|
+
it('should handle falsy values', () => {
|
|
33
|
+
expect((0, index_1.cleanSnapshotUuid)(undefined)).toBe(undefined);
|
|
34
|
+
expect((0, index_1.cleanSnapshotUuid)(null)).toBe(null);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
25
37
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ring-client-api",
|
|
3
|
-
"version": "11.7.
|
|
3
|
+
"version": "11.7.4",
|
|
4
4
|
"description": "Unofficial API for Ring doorbells, cameras, security alarm system and smart lighting",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -19,28 +19,31 @@
|
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@eneris/push-receiver": "^3.1.4",
|
|
21
21
|
"@homebridge/camera-utils": "^2.2.0",
|
|
22
|
-
"
|
|
22
|
+
"@peculiar/asn1-schema": "^2.3.6",
|
|
23
|
+
"@peculiar/webcrypto": "^1.4.3",
|
|
23
24
|
"@types/socket.io-client": "1.4.36",
|
|
24
25
|
"colors": "1.4.0",
|
|
25
26
|
"debug": "^4.3.4",
|
|
26
27
|
"got": "^11.8.5",
|
|
27
28
|
"rxjs": "^7.8.0",
|
|
28
29
|
"socket.io-client": "^2.5.0",
|
|
29
|
-
"systeminformation": "^5.17.
|
|
30
|
+
"systeminformation": "^5.17.12",
|
|
30
31
|
"uuid": "^9.0.0",
|
|
31
|
-
"
|
|
32
|
+
"webcrypto-core": "^1.7.7",
|
|
33
|
+
"werift": "0.18.2",
|
|
34
|
+
"ws": "^8.13.0"
|
|
32
35
|
},
|
|
33
36
|
"devDependencies": {
|
|
34
37
|
"@types/debug": "4.1.7",
|
|
35
|
-
"@types/jest": "29.
|
|
36
|
-
"@types/node": "18.
|
|
38
|
+
"@types/jest": "29.5.0",
|
|
39
|
+
"@types/node": "18.15.9",
|
|
37
40
|
"@types/uuid": "9.0.1",
|
|
38
41
|
"@types/ws": "^8.5.4",
|
|
39
|
-
"eslint-config-shared": "
|
|
40
|
-
"jest": "29.
|
|
42
|
+
"eslint-config-shared": "*",
|
|
43
|
+
"jest": "29.5.0",
|
|
41
44
|
"ts-jest": "29.0.5",
|
|
42
|
-
"tsconfig": "
|
|
43
|
-
"typescript": "
|
|
45
|
+
"tsconfig": "*",
|
|
46
|
+
"typescript": "5.0.2"
|
|
44
47
|
},
|
|
45
48
|
"engines": {
|
|
46
49
|
"node": "^16 || ^18"
|