ring-client-api 11.7.1 → 11.7.3

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/api.js CHANGED
@@ -88,7 +88,7 @@ class RingApi extends subscribed_1.Subscribed {
88
88
  byId[intercom.id] = intercom;
89
89
  return byId;
90
90
  }, {});
91
- if (!cameras.length && !chimes.length) {
91
+ if (!cameras.length && !chimes.length && !intercoms.length) {
92
92
  return;
93
93
  }
94
94
  this.addSubscriptions((0, rxjs_1.merge)(onDeviceRequestUpdate, onPollForStatusUpdate)
@@ -61,6 +61,7 @@ async function logDeviceData() {
61
61
  name: location.name,
62
62
  cameras: location.cameras.map((camera) => camera.data),
63
63
  chimes: location.chimes.map((chime) => chime.data),
64
+ intercoms: location.intercoms.map((intercom) => intercom.data),
64
65
  devices: devices.map((device) => device.data),
65
66
  };
66
67
  }), results = {
@@ -55,6 +55,10 @@ class WeriftPeerConnection extends subscribed_1.Subscribed {
55
55
  ],
56
56
  parameters: 'packetization-mode=1;profile-level-id=640029;level-asymmetry-allowed=1',
57
57
  }),
58
+ new werift_1.RTCRtpCodecParameters({
59
+ mimeType: 'video/rtx',
60
+ clockRate: 90000,
61
+ }),
58
62
  ],
59
63
  },
60
64
  iceServers: ringIceServers.map((server) => ({ urls: server })),
@@ -11,6 +11,7 @@ export declare abstract class StreamingConnectionBase extends Subscribed {
11
11
  protected options: StreamingConnectionOptions;
12
12
  readonly onCallAnswered: ReplaySubject<string>;
13
13
  readonly onCallEnded: ReplaySubject<void>;
14
+ readonly onError: ReplaySubject<void>;
14
15
  readonly onMessage: ReplaySubject<{
15
16
  method: string;
16
17
  }>;
@@ -13,6 +13,7 @@ class StreamingConnectionBase extends subscribed_1.Subscribed {
13
13
  this.options = options;
14
14
  this.onCallAnswered = new rxjs_1.ReplaySubject(1);
15
15
  this.onCallEnded = new rxjs_1.ReplaySubject(1);
16
+ this.onError = new rxjs_1.ReplaySubject(1);
16
17
  this.onMessage = new rxjs_1.ReplaySubject();
17
18
  this.hasEnded = false;
18
19
  if (options.createPeerConnection) {
@@ -35,7 +36,14 @@ class StreamingConnectionBase extends subscribed_1.Subscribed {
35
36
  .pipe((0, operators_1.concatMap)((event) => {
36
37
  const message = JSON.parse(event.data);
37
38
  this.onMessage.next(message);
38
- return this.handleMessage(message);
39
+ return this.handleMessage(message).catch((e) => {
40
+ if (e instanceof Error &&
41
+ e.message.includes('negotiate codecs failed')) {
42
+ e = new Error('Failed to negotiate codecs. This is a known issue with Ring cameras. Please see https://github.com/dgreif/ring/wiki/Streaming-Legacy-Mode');
43
+ }
44
+ this.onError.next(e);
45
+ throw e;
46
+ });
39
47
  }))
40
48
  .subscribe(), onError.subscribe((e) => {
41
49
  (0, util_1.logError)(e);
@@ -51,6 +59,9 @@ class StreamingConnectionBase extends subscribed_1.Subscribed {
51
59
  (0, util_1.logDebug)('Stream connection closed');
52
60
  this.callEnded();
53
61
  }
62
+ }), this.onError.subscribe((e) => {
63
+ (0, util_1.logError)(e);
64
+ this.callEnded();
54
65
  }));
55
66
  }
56
67
  activate() {
@@ -56,7 +56,9 @@ class StreamingSession extends subscribed_1.Subscribed {
56
56
  return ports[0];
57
57
  }
58
58
  get isUsingOpus() {
59
- return (0, rxjs_1.firstValueFrom)(this.onUsingOpus);
59
+ return (0, rxjs_1.firstValueFrom)(this.onUsingOpus.pipe((0, operators_1.mergeWith)(this.connection.onError.pipe((0, operators_1.map)((e) => {
60
+ throw e;
61
+ })))));
60
62
  }
61
63
  async startTranscoding(ffmpegOptions) {
62
64
  if (this.hasEnded) {
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const index_1 = require("../index");
4
+ describe('Ring Camera', () => {
5
+ describe('battery level', () => {
6
+ it('should handle string battery life', () => {
7
+ expect((0, index_1.getBatteryLevel)({
8
+ battery_life: '49',
9
+ })).toEqual(49);
10
+ });
11
+ it('should handle null battery life', () => {
12
+ expect((0, index_1.getBatteryLevel)({ battery_life: null })).toEqual(null);
13
+ });
14
+ it('should handle right battery only', () => {
15
+ expect((0, index_1.getBatteryLevel)({ battery_life: null, battery_life_2: 24 })).toEqual(24);
16
+ });
17
+ it('should handle left battery only', () => {
18
+ expect((0, index_1.getBatteryLevel)({ battery_life: 76, battery_life_2: null })).toEqual(76);
19
+ });
20
+ it('should handle dual batteries', () => {
21
+ expect((0, index_1.getBatteryLevel)({ battery_life: '92', battery_life_2: 84 })).toEqual(84);
22
+ expect((0, index_1.getBatteryLevel)({ battery_life: '92', battery_life_2: 100 })).toEqual(92);
23
+ });
24
+ });
25
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ring-client-api",
3
- "version": "11.7.1",
3
+ "version": "11.7.3",
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
- "werift": "0.17.5",
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.16.9",
30
+ "systeminformation": "^5.17.12",
30
31
  "uuid": "^9.0.0",
31
- "ws": "^8.11.0"
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.2.4",
36
- "@types/node": "18.11.17",
37
- "@types/uuid": "9.0.0",
38
- "@types/ws": "^8.5.3",
39
- "eslint-config-shared": "0.0.0",
40
- "jest": "29.3.1",
41
- "ts-jest": "29.0.3",
42
- "tsconfig": "0.0.0",
43
- "typescript": "4.9.4"
38
+ "@types/jest": "29.5.0",
39
+ "@types/node": "18.15.9",
40
+ "@types/uuid": "9.0.1",
41
+ "@types/ws": "^8.5.4",
42
+ "eslint-config-shared": "*",
43
+ "jest": "29.5.0",
44
+ "ts-jest": "29.0.5",
45
+ "tsconfig": "*",
46
+ "typescript": "5.0.2"
44
47
  },
45
48
  "engines": {
46
49
  "node": "^16 || ^18"