ring-client-api 13.2.0-beta.0 → 13.2.0-beta.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.
@@ -55,7 +55,10 @@ async function responseToError(response) {
55
55
  }
56
56
  return error;
57
57
  }
58
- async function requestWithRetry(requestOptions) {
58
+ async function requestWithRetry(requestOptions, retryCount = 0) {
59
+ if (typeof fetch !== 'function') {
60
+ throw new Error(`Your current NodeJS version (${process.version}) is too old to support this plugin. Please upgrade to the latest LTS version of NodeJS.`);
61
+ }
59
62
  try {
60
63
  if (requestOptions.json || requestOptions.responseType === 'json') {
61
64
  requestOptions.headers = {
@@ -110,13 +113,18 @@ async function requestWithRetry(requestOptions) {
110
113
  }
111
114
  catch (e) {
112
115
  if (!e.response && !requestOptions.allowNoResponse) {
113
- (0, util_1.logError)(`Failed to reach Ring server at ${requestOptions.url}. ${e.message}. Trying again in 5 seconds...`);
114
- if (e.message.includes('NGHTTP2_ENHANCE_YOUR_CALM')) {
115
- (0, util_1.logError)(`There is a known issue with your current NodeJS version (${process.version}). Please see https://github.com/dgreif/ring/wiki/NGHTTP2_ENHANCE_YOUR_CALM-Error for details`);
116
+ if (retryCount > 0) {
117
+ let detailedError = `Error: ${e.message}`;
118
+ detailedError += e.cause?.message ? `, Cause: ${e.cause.message}` : '';
119
+ detailedError += e.cause?.code ? `, Code: ${e.cause.code}` : '';
120
+ (0, util_1.logError)(`Retry #${retryCount} failed to reach Ring server at ${requestOptions.url}. ${detailedError}. Trying again in 5 seconds...`);
121
+ if (e.message.includes('NGHTTP2_ENHANCE_YOUR_CALM')) {
122
+ (0, util_1.logError)(`There is a known issue with your current NodeJS version (${process.version}). Please see https://github.com/dgreif/ring/wiki/NGHTTP2_ENHANCE_YOUR_CALM-Error for details`);
123
+ }
124
+ (0, util_1.logDebug)(e);
116
125
  }
117
- (0, util_1.logDebug)(e);
118
126
  await (0, util_1.delay)(5000);
119
- return requestWithRetry(requestOptions);
127
+ return requestWithRetry(requestOptions, retryCount + 1);
120
128
  }
121
129
  throw e;
122
130
  }
@@ -355,6 +363,7 @@ class RingRestClient {
355
363
  authorization: `Bearer ${authTokenResponse.access_token}`,
356
364
  hardware_id: hardwareId,
357
365
  'User-Agent': 'android:com.ringapp',
366
+ Connection: 'close',
358
367
  },
359
368
  });
360
369
  }
@@ -99,7 +99,9 @@ class WeriftPeerConnection extends subscribed_1.Subscribed {
99
99
  });
100
100
  });
101
101
  this.pc.onIceCandidate.subscribe((iceCandidate) => {
102
- this.onIceCandidate.next(iceCandidate);
102
+ if (iceCandidate) {
103
+ this.onIceCandidate.next(iceCandidate);
104
+ }
103
105
  });
104
106
  pc.iceConnectionStateChange.subscribe(() => {
105
107
  (0, util_1.logInfo)(`iceConnectionStateChange: ${pc.iceConnectionState}`);
@@ -35,6 +35,17 @@ interface NotificationMessage {
35
35
  text: string;
36
36
  } & SessionBody;
37
37
  }
38
+ interface CameraStartedMessage {
39
+ method: 'camera_started';
40
+ body: SessionBody;
41
+ }
42
+ interface StreamInfoMessage {
43
+ method: 'stream_info';
44
+ body: SessionBody & {
45
+ transcoding: boolean;
46
+ transcoding_reason: 'codec_mismatch' | string;
47
+ };
48
+ }
38
49
  declare enum CloseReasonCode {
39
50
  NormalClose = 0,
40
51
  AuthenticationFailed = 5,
@@ -49,5 +60,5 @@ interface CloseMessage {
49
60
  };
50
61
  } & SessionBody;
51
62
  }
52
- export type IncomingMessage = AnswerMessage | IceCandidateMessage | SessionCreatedMessage | SessionStartedMessage | PongMessage | CloseMessage | NotificationMessage;
63
+ export type IncomingMessage = AnswerMessage | IceCandidateMessage | SessionCreatedMessage | SessionStartedMessage | PongMessage | CloseMessage | NotificationMessage | CameraStartedMessage | StreamInfoMessage;
53
64
  export {};
@@ -164,6 +164,10 @@ class WebrtcConnection extends subscribed_1.Subscribed {
164
164
  (0, util_1.logError)(message.body);
165
165
  this.callEnded();
166
166
  return;
167
+ case 'camera_started':
168
+ case 'stream_info':
169
+ // ignore these messages as we don't use them
170
+ return;
167
171
  }
168
172
  (0, util_1.logError)('UNKNOWN MESSAGE');
169
173
  (0, util_1.logError)(message);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ring-client-api",
3
- "version": "13.2.0-beta.0",
3
+ "version": "13.2.0-beta.1",
4
4
  "description": "Unofficial API for Ring doorbells, cameras, security alarm system and smart lighting",
5
5
  "main": "lib/index.js",
6
6
  "exports": {
@@ -18,29 +18,29 @@
18
18
  "test:watch": "jest --watch"
19
19
  },
20
20
  "dependencies": {
21
- "@eneris/push-receiver": "4.2.0",
22
- "@homebridge/camera-utils": "^2.2.6",
21
+ "@eneris/push-receiver": "4.3.0",
22
+ "@homebridge/camera-utils": "^2.2.7-beta",
23
23
  "colors": "1.4.0",
24
24
  "debug": "^4.3.7",
25
25
  "json-bigint": "^1.0.0",
26
26
  "rxjs": "^7.8.1",
27
27
  "socket.io-client": "^2.5.0",
28
28
  "systeminformation": "^5.23.5",
29
- "uuid": "^10.0.0",
30
- "werift": "0.19.4",
29
+ "uuid": "^11.0.2",
30
+ "werift": "0.20.1",
31
31
  "ws": "^8.18.0"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/debug": "4.1.12",
35
- "@types/jest": "29.5.13",
35
+ "@types/jest": "29.5.14",
36
36
  "@types/json-bigint": "^1.0.4",
37
- "@types/node": "22.7.5",
37
+ "@types/node": "22.8.6",
38
38
  "@types/socket.io-client": "1.4.36",
39
39
  "@types/uuid": "10.0.0",
40
- "@types/ws": "^8.5.12",
40
+ "@types/ws": "^8.5.13",
41
41
  "eslint-config-shared": "*",
42
42
  "jest": "29.7.0",
43
- "msw": "^2.4.10",
43
+ "msw": "^2.6.0",
44
44
  "ts-jest": "29.2.5",
45
45
  "tsconfig": "*",
46
46
  "typescript": "5.6.3"