ring-client-api 9.23.0 → 9.24.0

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/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [9.24.0](https://github.com/dgreif/ring/compare/v9.23.0...v9.24.0) (2022-01-22)
6
+
7
+
8
+ ### Features
9
+
10
+ * support glassbreak sensor ([98271f9](https://github.com/dgreif/ring/commit/98271f91f13aaae051fccaab7165cd17f2a2377c))
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * allow process to exit when RingApi.disconnect() is called ([#851](https://github.com/dgreif/ring/issues/851)) ([8ef25ac](https://github.com/dgreif/ring/commit/8ef25acca66c533873b7fd43c7c899e34b4a7617))
16
+ * avoid error when ring terminates video stream ([7717d5e](https://github.com/dgreif/ring/commit/7717d5eaa40afed3d34f0e8e6eea1402e21afef7)), closes [#853](https://github.com/dgreif/ring/issues/853)
17
+ * update dependencies ([c80d052](https://github.com/dgreif/ring/commit/c80d052f9eaf4c0a50a495166177daa40299ffa7))
18
+
5
19
  ## [9.23.0](https://github.com/dgreif/ring/compare/v9.22.1...v9.23.0) (2021-10-17)
6
20
 
7
21
 
package/README.md CHANGED
@@ -109,7 +109,7 @@ Camera also includes the following observables:
109
109
  * `onDoorbellPressed`: emits a ding every time the doorbell is pressed
110
110
  * `onMotionDetected`: `true` or `false` based on `onActiveDings` containing a motion ding
111
111
 
112
- Some other useful propeties
112
+ Some other useful properties
113
113
  * `id`
114
114
  * `name`: same as `description` from `data`
115
115
  * `hasLight`: does this camera have a light
package/lib/api/api.js CHANGED
@@ -24,7 +24,8 @@ class RingApi extends subscribed_1.Subscribed {
24
24
  super();
25
25
  this.options = options;
26
26
  this.restClient = new rest_client_1.RingRestClient(this.options);
27
- this.onRefreshTokenUpdated = this.restClient.onRefreshTokenUpdated.asObservable();
27
+ this.onRefreshTokenUpdated =
28
+ this.restClient.onRefreshTokenUpdated.asObservable();
28
29
  if (options.debug) {
29
30
  (0, util_1.enableDebug)();
30
31
  }
@@ -169,6 +170,7 @@ class RingApi extends subscribed_1.Subscribed {
169
170
  .catch((e) => {
170
171
  (0, util_1.logError)(e);
171
172
  });
173
+ this.restClient.clearTimeouts();
172
174
  }
173
175
  }
174
176
  exports.RingApi = RingApi;
@@ -24,6 +24,7 @@ export declare class RingRestClient {
24
24
  refreshToken: string | undefined;
25
25
  private hardwareIdPromise;
26
26
  private _authPromise;
27
+ private timeouts;
27
28
  private clearPreviousAuth;
28
29
  private get authPromise();
29
30
  private sessionPromise?;
@@ -44,4 +45,5 @@ export declare class RingRestClient {
44
45
  url: string;
45
46
  }): Promise<T & ExtendedResponse>;
46
47
  getCurrentAuth(): Promise<AuthTokenResponse>;
48
+ clearTimeouts(): void;
47
49
  }
@@ -66,12 +66,15 @@ function requestWithRetry(requestOptions) {
66
66
  class RingRestClient {
67
67
  constructor(authOptions) {
68
68
  this.authOptions = authOptions;
69
- // prettier-ignore
70
- this.refreshToken = ('refreshToken' in this.authOptions ? this.authOptions.refreshToken : undefined);
71
- this.hardwareIdPromise = (0, util_1.getHardwareId)(this.authOptions.systemId);
69
+ this.timeouts = [];
72
70
  this.sessionPromise = undefined;
73
71
  this.using2fa = false;
74
72
  this.onRefreshTokenUpdated = new rxjs_1.ReplaySubject(1);
73
+ this.refreshToken =
74
+ 'refreshToken' in this.authOptions
75
+ ? this.authOptions.refreshToken
76
+ : undefined;
77
+ this.hardwareIdPromise = (0, util_1.getHardwareId)(this.authOptions.systemId);
75
78
  }
76
79
  clearPreviousAuth() {
77
80
  this._authPromise = undefined;
@@ -83,11 +86,12 @@ class RingRestClient {
83
86
  authPromise
84
87
  .then(({ expires_in }) => {
85
88
  // clear the existing auth promise 1 minute before it expires
86
- setTimeout(() => {
89
+ const timeout = setTimeout(() => {
87
90
  if (this._authPromise === authPromise) {
88
91
  this.clearPreviousAuth();
89
92
  }
90
93
  }, ((expires_in || 3600) - 60) * 1000);
94
+ this.timeouts.push(timeout);
91
95
  })
92
96
  .catch(() => {
93
97
  // ignore these errors here, they should be handled by the function making a rest request
@@ -288,5 +292,8 @@ class RingRestClient {
288
292
  getCurrentAuth() {
289
293
  return this.authPromise;
290
294
  }
295
+ clearTimeouts() {
296
+ this.timeouts.forEach(clearTimeout);
297
+ }
291
298
  }
292
299
  exports.RingRestClient = RingRestClient;
@@ -73,17 +73,6 @@ class RingCamera extends subscribed_1.Subscribed {
73
73
  this.restClient = restClient;
74
74
  this.avoidSnapshotBatteryDrain = avoidSnapshotBatteryDrain;
75
75
  this.treatKnockAsDing = treatKnockAsDing;
76
- this.id = this.initialData.id;
77
- this.deviceType = this.initialData.kind;
78
- this.model = ring_types_1.RingCameraModel[this.initialData.kind] || 'Unknown Model';
79
- this.onData = new rxjs_1.BehaviorSubject(this.initialData);
80
- this.hasLight = this.initialData.led_status !== undefined;
81
- this.hasSiren = this.initialData.siren_status !== undefined;
82
- this.hasBattery = (0, ring_types_1.isBatteryCameraKind)(this.deviceType) ||
83
- (typeof this.initialData.battery_life === 'string' &&
84
- this.batteryLevel !== null &&
85
- this.batteryLevel < 100 &&
86
- this.batteryLevel >= 0);
87
76
  this.onRequestUpdate = new rxjs_1.Subject();
88
77
  this.onRequestActiveDings = new rxjs_1.Subject();
89
78
  this.onNewDing = new rxjs_1.Subject();
@@ -93,12 +82,24 @@ class RingCamera extends subscribed_1.Subscribed {
93
82
  this.onMotionDetected = this.onActiveDings.pipe((0, operators_1.map)((dings) => dings.some((ding) => ding.motion || ding.kind === 'motion')), (0, operators_1.distinctUntilChanged)(), (0, operators_1.publishReplay)(1), (0, operators_1.refCount)());
94
83
  this.onMotionStarted = this.onMotionDetected.pipe((0, operators_1.filter)((currentlyDetected) => currentlyDetected), (0, operators_1.mapTo)(null), // no value needed, event is what matters
95
84
  (0, operators_1.share)());
85
+ this.expiredDingIds = [];
86
+ this.lastSnapshotTimestampLocal = 0;
87
+ this.id = this.initialData.id;
88
+ this.deviceType = this.initialData.kind;
89
+ this.model = ring_types_1.RingCameraModel[this.initialData.kind] || 'Unknown Model';
90
+ this.onData = new rxjs_1.BehaviorSubject(this.initialData);
91
+ this.hasLight = this.initialData.led_status !== undefined;
92
+ this.hasSiren = this.initialData.siren_status !== undefined;
93
+ this.hasBattery =
94
+ (0, ring_types_1.isBatteryCameraKind)(this.deviceType) ||
95
+ (typeof this.initialData.battery_life === 'string' &&
96
+ this.batteryLevel !== null &&
97
+ this.batteryLevel < 100 &&
98
+ this.batteryLevel >= 0);
96
99
  this.onBatteryLevel = this.onData.pipe((0, operators_1.map)(getBatteryLevel), (0, operators_1.distinctUntilChanged)());
97
100
  this.onInHomeDoorbellStatus = this.onData.pipe((0, operators_1.map)(({ settings: { chime_settings } }) => {
98
101
  return Boolean(chime_settings === null || chime_settings === void 0 ? void 0 : chime_settings.enable);
99
102
  }), (0, operators_1.distinctUntilChanged)());
100
- this.expiredDingIds = [];
101
- this.lastSnapshotTimestampLocal = 0;
102
103
  if (!initialData.subscribed) {
103
104
  this.subscribeToDingEvents().catch((e) => {
104
105
  (0, util_1.logError)('Failed to subscribe ' + initialData.description + ' to ding events');
@@ -5,7 +5,7 @@ export declare class RingChime {
5
5
  private initialData;
6
6
  private restClient;
7
7
  id: number;
8
- deviceType: "chime" | "chime_pro" | "chime_v2" | "chime_pro_v2";
8
+ deviceType: import("./ring-types").ChimeKind;
9
9
  model: string;
10
10
  onData: BehaviorSubject<ChimeData>;
11
11
  onRequestUpdate: Subject<unknown>;
@@ -23,11 +23,11 @@ class RingChime {
23
23
  constructor(initialData, restClient) {
24
24
  this.initialData = initialData;
25
25
  this.restClient = restClient;
26
+ this.onRequestUpdate = new rxjs_1.Subject();
26
27
  this.id = this.initialData.id;
27
28
  this.deviceType = this.initialData.kind;
28
29
  this.model = ring_types_1.ChimeModel[this.deviceType] || 'Chime';
29
30
  this.onData = new rxjs_1.BehaviorSubject(this.initialData);
30
- this.onRequestUpdate = new rxjs_1.Subject();
31
31
  }
32
32
  updateData(update) {
33
33
  this.onData.next(update);
@@ -10,6 +10,7 @@ export declare enum RingDeviceType {
10
10
  TemperatureSensor = "sensor.temperature",
11
11
  WaterSensor = "sensor.water",
12
12
  TiltSensor = "sensor.tilt",
13
+ GlassbreakSensor = "sensor.glassbreak",
13
14
  RangeExtender = "range-extender.zwave",
14
15
  ZigbeeAdapter = "adapter.zigbee",
15
16
  AccessCodeVault = "access-code.vault",
@@ -214,7 +215,7 @@ export interface BeamBridge {
214
215
  role: string;
215
216
  updated_at: string;
216
217
  }
217
- declare type ChimeKind = 'chime' | 'chime_pro' | 'chime_v2' | 'chime_pro_v2';
218
+ export declare type ChimeKind = 'chime' | 'chime_pro' | 'chime_v2' | 'chime_pro_v2';
218
219
  export declare const ChimeModel: {
219
220
  readonly [P in ChimeKind]: string;
220
221
  };
@@ -14,6 +14,7 @@ var RingDeviceType;
14
14
  RingDeviceType["TemperatureSensor"] = "sensor.temperature";
15
15
  RingDeviceType["WaterSensor"] = "sensor.water";
16
16
  RingDeviceType["TiltSensor"] = "sensor.tilt";
17
+ RingDeviceType["GlassbreakSensor"] = "sensor.glassbreak";
17
18
  RingDeviceType["RangeExtender"] = "range-extender.zwave";
18
19
  RingDeviceType["ZigbeeAdapter"] = "adapter.zigbee";
19
20
  RingDeviceType["AccessCodeVault"] = "access-code.vault";
@@ -32,8 +32,8 @@ class SipSession extends subscribed_1.Subscribed {
32
32
  this.hasStarted = false;
33
33
  this.hasCallEnded = false;
34
34
  this.onCallEndedSubject = new rxjs_1.ReplaySubject(1);
35
- this.sipCall = this.createSipCall(this.sipOptions);
36
35
  this.onCallEnded = this.onCallEndedSubject.asObservable();
36
+ this.sipCall = this.createSipCall(this.sipOptions);
37
37
  }
38
38
  createSipCall(sipOptions) {
39
39
  if (this.sipCall) {
package/lib/api/sip.d.ts CHANGED
@@ -19,6 +19,7 @@ export function create(options: any, callback: any): {
19
19
  isFlowUri: (uri: any) => boolean;
20
20
  hostname: () => any;
21
21
  destroy: () => void;
22
+ makeResponse: typeof makeResponse;
22
23
  };
23
24
  export function start(options: any, callback: any): void;
24
25
  export function parseAOR(data: any): any;
package/lib/api/sip.js CHANGED
@@ -1300,6 +1300,7 @@ exports.create = function (options, callback) {
1300
1300
  transaction.destroy();
1301
1301
  transport.destroy();
1302
1302
  },
1303
+ makeResponse,
1303
1304
  };
1304
1305
  };
1305
1306
  exports.start = function (options, callback) {
package/lib/api/util.js CHANGED
@@ -8,14 +8,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
11
14
  Object.defineProperty(exports, "__esModule", { value: true });
12
15
  exports.randomString = exports.randomInteger = exports.mapAsync = exports.stringify = exports.requestInput = exports.getHardwareId = exports.generateUuid = exports.enableDebug = exports.useLogger = exports.logError = exports.logInfo = exports.logDebug = exports.delay = void 0;
13
- const debug = require("debug");
16
+ const debug_1 = __importDefault(require("debug"));
14
17
  const colors_1 = require("colors");
15
18
  const readline_1 = require("readline");
16
19
  const uuid_1 = require("uuid");
17
20
  const systeminformation_1 = require("systeminformation");
18
- const debugLogger = debug('ring'), uuidNamespace = 'e53ffdc0-e91d-4ce1-bec2-df939d94739c';
21
+ const debugLogger = (0, debug_1.default)('ring'), uuidNamespace = 'e53ffdc0-e91d-4ce1-bec2-df939d94739c';
19
22
  let logger = {
20
23
  logInfo(message) {
21
24
  debugLogger(message);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ring-client-api",
3
- "version": "9.23.0",
3
+ "version": "9.24.0",
4
4
  "description": "Unofficial API for Ring doorbells, cameras, security alarm system and smart lighting",
5
5
  "main": "lib/api/index.js",
6
6
  "bin": {
@@ -57,38 +57,38 @@
57
57
  "@homebridge/plugin-ui-utils": "0.0.19",
58
58
  "@types/socket.io-client": "1.4.36",
59
59
  "colors": "1.4.0",
60
- "debug": "4.3.2",
61
- "got": "11.8.2",
62
- "rxjs": "7.4.0",
60
+ "debug": "4.3.3",
61
+ "got": "11.8.3",
62
+ "rxjs": "7.5.2",
63
63
  "sdp": "3.0.3",
64
64
  "socket.io-client": "2.4.0",
65
65
  "stun": "2.1.0",
66
- "systeminformation": "5.9.7",
66
+ "systeminformation": "5.10.7",
67
67
  "uuid": "8.3.2"
68
68
  },
69
69
  "devDependencies": {
70
70
  "@types/debug": "4.1.7",
71
- "@types/jest": "27.0.2",
72
- "@types/node": "16.11.1",
73
- "@types/uuid": "8.3.1",
74
- "@typescript-eslint/eslint-plugin": "5.0.0",
75
- "@typescript-eslint/parser": "5.0.0",
76
- "concurrently": "^6.3.0",
71
+ "@types/jest": "27.4.0",
72
+ "@types/node": "17.0.10",
73
+ "@types/uuid": "8.3.4",
74
+ "@typescript-eslint/eslint-plugin": "5.10.0",
75
+ "@typescript-eslint/parser": "5.10.0",
76
+ "concurrently": "^7.0.0",
77
77
  "conventional-github-releaser": "3.1.5",
78
- "dotenv": "10.0.0",
79
- "eslint": "8.0.1",
78
+ "dotenv": "14.2.0",
79
+ "eslint": "8.7.0",
80
80
  "eslint-config-prettier": "8.3.0",
81
- "eslint-plugin-jest": "25.2.2",
81
+ "eslint-plugin-jest": "25.7.0",
82
82
  "eslint-plugin-prettier": "4.0.0",
83
- "express": "4.17.1",
84
- "homebridge": "1.3.5",
85
- "jest": "27.3.0",
86
- "prettier": "2.4.1",
83
+ "express": "4.17.2",
84
+ "homebridge": "1.4.0",
85
+ "jest": "27.4.7",
86
+ "prettier": "2.5.1",
87
87
  "reflect-metadata": "0.1.13",
88
88
  "rimraf": "3.0.2",
89
89
  "standard-version": "9.3.2",
90
- "ts-jest": "27.0.7",
91
- "typescript": "4.4.4"
90
+ "ts-jest": "27.1.3",
91
+ "typescript": "4.5.5"
92
92
  },
93
93
  "engines": {
94
94
  "node": "^10 || ^12.20 || ^14 || ^16",