ring-client-api 13.2.0 → 13.2.1-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.
package/lib/api.js CHANGED
@@ -176,6 +176,13 @@ class RingApi extends subscribed_1.Subscribed {
176
176
  (0, util_1.logError)(e);
177
177
  }
178
178
  }));
179
+ pushReceiver.on('ON_DISCONNECT', () => {
180
+ pushReceiver.whenReady.catch((e) => {
181
+ (0, util_1.logError)('Connection to the push notification server has failed unexpectedly');
182
+ (0, util_1.logError)('If this happens repeatedly, verify connections to TCP/5228 are allowed and that DNS Adblock rules allow gtalk.google.com');
183
+ (0, util_1.logError)(e.message);
184
+ });
185
+ });
179
186
  try {
180
187
  await pushReceiver.connect();
181
188
  }
@@ -1,10 +1,12 @@
1
1
  import { AuthTokenResponse, SessionResponse } from './ring-types';
2
2
  import { ReplaySubject } from 'rxjs';
3
3
  import type { Credentials } from '@eneris/push-receiver/dist/types';
4
+ import { Agent } from 'undici';
4
5
  interface RequestOptions extends RequestInit {
5
6
  responseType?: 'json' | 'buffer';
6
7
  timeout?: number;
7
8
  json?: object;
9
+ dispatcher?: Agent;
8
10
  }
9
11
  export declare function clientApi(path: string): string;
10
12
  export declare function deviceApi(path: string): string;
@@ -42,7 +44,7 @@ export declare class RingRestClient {
42
44
  oldRefreshToken?: string;
43
45
  newRefreshToken: string;
44
46
  }>;
45
- onSession: ReplaySubject<SessionResponse>;
47
+ onSession: ReplaySubject<import("./ring-types").ProfileResponse>;
46
48
  readonly baseSessionMetadata: {
47
49
  api_version: number;
48
50
  device_model: string;
@@ -11,7 +11,12 @@ exports.appApi = appApi;
11
11
  const util_1 = require("./util");
12
12
  const rxjs_1 = require("rxjs");
13
13
  const assert_1 = __importDefault(require("assert"));
14
- const defaultRequestOptions = {
14
+ const undici_1 = require("undici");
15
+ const fetchAgent = new undici_1.Agent({
16
+ connections: 6,
17
+ pipelining: 1,
18
+ keepAliveTimeout: 115000,
19
+ }), defaultRequestOptions = {
15
20
  responseType: 'json',
16
21
  method: 'GET',
17
22
  timeout: 20000,
@@ -46,11 +51,11 @@ async function responseToError(response) {
46
51
  try {
47
52
  error.response.body = JSON.parse(bodyText);
48
53
  }
49
- catch (_) {
54
+ catch {
50
55
  error.response.body = bodyText;
51
56
  }
52
57
  }
53
- catch (_) {
58
+ catch {
54
59
  // ignore
55
60
  }
56
61
  return error;
@@ -74,6 +79,7 @@ async function requestWithRetry(requestOptions, retryCount = 0) {
74
79
  const options = {
75
80
  ...defaultRequestOptions,
76
81
  ...requestOptions,
82
+ dispatcher: fetchAgent,
77
83
  };
78
84
  // If a timeout is provided, create an AbortSignal for it
79
85
  if (options.timeout && !options.signal) {
@@ -95,7 +101,7 @@ async function requestWithRetry(requestOptions, retryCount = 0) {
95
101
  try {
96
102
  data = JSON.parse(text);
97
103
  }
98
- catch (_) {
104
+ catch {
99
105
  data = text;
100
106
  }
101
107
  }
@@ -139,7 +145,7 @@ function parseAuthConfig(rawRefreshToken) {
139
145
  (0, assert_1.default)(config.rt);
140
146
  return config;
141
147
  }
142
- catch (_) {
148
+ catch {
143
149
  return {
144
150
  rt: rawRefreshToken,
145
151
  };
@@ -363,7 +369,6 @@ class RingRestClient {
363
369
  authorization: `Bearer ${authTokenResponse.access_token}`,
364
370
  hardware_id: hardwareId,
365
371
  'User-Agent': 'android:com.ringapp',
366
- Connection: 'close',
367
372
  },
368
373
  });
369
374
  }
@@ -88,14 +88,14 @@ export declare class RingCamera extends Subscribed {
88
88
  private fetchingSnapshot;
89
89
  getSnapshot({ uuid }?: {
90
90
  uuid?: string;
91
- }): Promise<Buffer>;
91
+ }): Promise<Buffer<ArrayBufferLike>>;
92
92
  getNextSnapshot({ afterMs, maxWaitMs, force, uuid, }: {
93
93
  afterMs?: number;
94
94
  maxWaitMs?: number;
95
95
  force?: boolean;
96
96
  uuid?: string;
97
- }): Promise<Buffer & import("./rest-client").ExtendedResponse>;
98
- getSnapshotByUuid(uuid: string): Promise<Buffer & import("./rest-client").ExtendedResponse>;
97
+ }): Promise<Buffer<ArrayBufferLike> & import("./rest-client").ExtendedResponse>;
98
+ getSnapshotByUuid(uuid: string): Promise<Buffer<ArrayBufferLike> & import("./rest-client").ExtendedResponse>;
99
99
  recordToFile(outputPath: string, duration?: number): Promise<void>;
100
100
  streamVideo(ffmpegOptions: FfmpegOptions): Promise<StreamingSession>;
101
101
  /**
@@ -281,7 +281,7 @@ class RingCamera extends subscribed_1.Subscribed {
281
281
  processPushNotification(notification) {
282
282
  if (!('android_config' in notification) ||
283
283
  !('event' in notification.data) ||
284
- !('ding' in notification.data?.event)) {
284
+ !('ding' in (notification.data?.event ?? {}))) {
285
285
  // only process ding/motion notifications
286
286
  return;
287
287
  }
@@ -1006,8 +1006,7 @@ export interface ProfileResponse {
1006
1006
  account_type: 'ring' | string;
1007
1007
  };
1008
1008
  }
1009
- export interface SessionResponse extends ProfileResponse {
1010
- }
1009
+ export type SessionResponse = ProfileResponse;
1011
1010
  export interface AccountMonitoringStatus {
1012
1011
  accountUuid: string;
1013
1012
  externalServiceConfigType: 'rrms' | string;
package/lib/ring-types.js CHANGED
@@ -25,7 +25,6 @@ var RingDeviceType;
25
25
  RingDeviceType["CoAlarm"] = "alarm.co";
26
26
  RingDeviceType["SmokeCoListener"] = "listener.smoke-co";
27
27
  RingDeviceType["MultiLevelSwitch"] = "switch.multilevel";
28
- // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
29
28
  RingDeviceType["Fan"] = "switch.multilevel";
30
29
  RingDeviceType["MultiLevelBulb"] = "switch.multilevel.bulb";
31
30
  RingDeviceType["Switch"] = "switch";
@@ -40,12 +39,9 @@ var RingDeviceType;
40
39
  RingDeviceType["Thermostat"] = "temperature-control.thermostat";
41
40
  RingDeviceType["Sensor"] = "sensor";
42
41
  RingDeviceType["RingNetAdapter"] = "adapter.ringnet";
43
- // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
44
42
  RingDeviceType["CodeVault"] = "access-code.vault";
45
- // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
46
43
  RingDeviceType["SecurityAccessCode"] = "access-code";
47
44
  RingDeviceType["ZWaveAdapter"] = "adapter.zwave";
48
- // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
49
45
  RingDeviceType["ZWaveExtender"] = "range-extender.zwave";
50
46
  RingDeviceType["PanicButton"] = "security-panic";
51
47
  RingDeviceType["UnknownZWave"] = "unknown.zwave";
@@ -148,7 +148,7 @@ class WebrtcConnection extends subscribed_1.Subscribed {
148
148
  return;
149
149
  case 'pong':
150
150
  return;
151
- case 'notification':
151
+ case 'notification': {
152
152
  const { text } = message.body;
153
153
  if (text === 'camera_connected') {
154
154
  this.onCameraConnected.next();
@@ -159,6 +159,7 @@ class WebrtcConnection extends subscribed_1.Subscribed {
159
159
  return;
160
160
  }
161
161
  break;
162
+ }
162
163
  case 'close':
163
164
  (0, util_1.logError)('Video stream closed');
164
165
  (0, util_1.logError)(message.body);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ring-client-api",
3
- "version": "13.2.0",
3
+ "version": "13.2.1-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": {
@@ -13,7 +13,7 @@
13
13
  "scripts": {
14
14
  "build": "rm -rf lib && tsc --declaration && chmod +x ./lib/ring-*-cli.js",
15
15
  "dev": "tsc --declaration --watch --preserveWatchOutput",
16
- "lint": "eslint . --ext .ts",
16
+ "lint": "eslint .",
17
17
  "test": "jest",
18
18
  "test:watch": "jest --watch"
19
19
  },
@@ -26,6 +26,7 @@
26
26
  "rxjs": "^7.8.1",
27
27
  "socket.io-client": "^2.5.0",
28
28
  "systeminformation": "^5.23.5",
29
+ "undici": "^6.21.0",
29
30
  "uuid": "^11.0.3",
30
31
  "werift": "0.20.1",
31
32
  "ws": "^8.18.0"
@@ -34,7 +35,7 @@
34
35
  "@types/debug": "4.1.12",
35
36
  "@types/jest": "29.5.14",
36
37
  "@types/json-bigint": "^1.0.4",
37
- "@types/node": "22.9.0",
38
+ "@types/node": "22.9.3",
38
39
  "@types/socket.io-client": "1.4.36",
39
40
  "@types/uuid": "10.0.0",
40
41
  "@types/ws": "^8.5.13",
@@ -43,7 +44,7 @@
43
44
  "msw": "^2.6.4",
44
45
  "ts-jest": "29.2.5",
45
46
  "tsconfig": "*",
46
- "typescript": "5.6.3"
47
+ "typescript": "5.7.2"
47
48
  },
48
49
  "engines": {
49
50
  "node": "^18 || ^20 || ^22"