ring-client-api 13.0.0-beta.4 → 13.0.0-beta.6

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
@@ -202,23 +202,33 @@ class RingApi extends subscribed_1.Subscribed {
202
202
  }
203
203
  }
204
204
  const notification = messageData;
205
- if (!('android_config' in notification)) {
206
- // This is not a v2 ding style notification, so we can't process it
207
- (0, util_1.logInfo)('Received push notification in unknown format');
208
- (0, util_1.logInfo)(JSON.stringify(message));
209
- return;
205
+ if ('android_config' in notification) {
206
+ const deviceId = notification.data?.device?.id;
207
+ if (deviceId) {
208
+ sendToDevice(deviceId, notification);
209
+ }
210
+ const eventCategory = notification.android_config.category;
211
+ if (eventCategory !== ring_types_1.PushNotificationAction.Ding &&
212
+ eventCategory !== ring_types_1.PushNotificationAction.Motion &&
213
+ eventCategory !== ring_types_1.PushNotificationAction.IntercomDing) {
214
+ (0, util_1.logDebug)('Received v2 push notification with unknown category: ' +
215
+ eventCategory);
216
+ (0, util_1.logDebug)(JSON.stringify(message));
217
+ }
210
218
  }
211
- const deviceId = notification.data?.device?.id;
212
- if (deviceId) {
213
- sendToDevice(deviceId, notification);
219
+ else if ('data' in notification &&
220
+ 'gcmData' in notification.data &&
221
+ 'alarm_meta' in notification.data.gcmData) {
222
+ const deviceId = notification.data.gcmData.alarm_meta.device_zid;
223
+ if (deviceId) {
224
+ sendToDevice(deviceId, notification);
225
+ }
214
226
  }
215
- const eventCategory = notification.android_config.category;
216
- if (eventCategory !== ring_types_1.PushNotificationAction.Ding &&
217
- eventCategory !== ring_types_1.PushNotificationAction.Motion &&
218
- eventCategory !== ring_types_1.PushNotificationAction.IntercomDing) {
219
- (0, util_1.logInfo)('Received push notification with unknown category: ' +
220
- eventCategory);
221
- (0, util_1.logInfo)(JSON.stringify(message));
227
+ else {
228
+ // This is not a v1 or v2 style notification, so we can't process it
229
+ (0, util_1.logDebug)('Received push notification in unknown format');
230
+ (0, util_1.logDebug)(JSON.stringify(message));
231
+ return;
222
232
  }
223
233
  }
224
234
  catch (e) {
@@ -39,11 +39,11 @@ function stripSensitiveFields(input) {
39
39
  else {
40
40
  const data = input[key];
41
41
  if (key.length === 36) {
42
- input[key.substr(0, 13) + '-uuid'] = data;
42
+ input[key.slice(0, 13) + '-uuid'] = data;
43
43
  delete input[key];
44
44
  }
45
45
  if (typeof data === 'string' && data.length === 36) {
46
- input[key] = data.substr(0, 13) + '-uuid';
46
+ input[key] = data.slice(0, 13) + '-uuid';
47
47
  }
48
48
  stripSensitiveFields(data);
49
49
  }
@@ -1,4 +1,4 @@
1
- import { CameraData, CameraDeviceSettingsData, CameraEventOptions, CameraEventResponse, CameraHealth, HistoryOptions, PeriodicFootageResponse, PushNotificationDingV2, VideoSearchResponse, OnvifCameraData, RingCameraKind } from './ring-types';
1
+ import { CameraData, CameraDeviceSettingsData, CameraEventOptions, CameraEventResponse, CameraHealth, HistoryOptions, PeriodicFootageResponse, PushNotificationDingV2, VideoSearchResponse, OnvifCameraData, RingCameraKind, PushNotification } from './ring-types';
2
2
  import { RingRestClient } from './rest-client';
3
3
  import { BehaviorSubject, Subject } from 'rxjs';
4
4
  import { DeepPartial } from './util';
@@ -61,7 +61,7 @@ export declare class RingCamera extends Subscribed {
61
61
  private createStreamingConnection;
62
62
  startLiveCall(options?: StreamingConnectionOptions): Promise<StreamingSession>;
63
63
  private removeDingById;
64
- processPushNotification(notification: PushNotificationDingV2): void;
64
+ processPushNotification(notification: PushNotification): void;
65
65
  getEvents(options?: CameraEventOptions): Promise<CameraEventResponse & import("./rest-client").ExtendedResponse>;
66
66
  videoSearch({ dateFrom, dateTo, order }?: {
67
67
  dateFrom: number;
@@ -79,8 +79,13 @@ class RingCamera extends subscribed_1.Subscribed {
79
79
  this.onActiveNotifications = new rxjs_1.BehaviorSubject([]);
80
80
  this.onDoorbellPressed = this.onNewNotification.pipe((0, operators_1.filter)((notification) => notification.android_config.category === ring_types_1.PushNotificationAction.Ding), (0, operators_1.share)());
81
81
  this.onMotionDetected = this.onActiveNotifications.pipe((0, operators_1.map)((notifications) => notifications.some((notification) => notification.android_config.category ===
82
- ring_types_1.PushNotificationAction.Motion)), (0, operators_1.distinctUntilChanged)(), (0, operators_1.publishReplay)(1), (0, operators_1.refCount)());
83
- this.onMotionStarted = this.onMotionDetected.pipe((0, operators_1.filter)((currentlyDetected) => currentlyDetected), (0, operators_1.mapTo)(null), // no value needed, event is what matters
82
+ ring_types_1.PushNotificationAction.Motion)), (0, operators_1.distinctUntilChanged)(), (0, operators_1.share)({
83
+ connector: () => new rxjs_1.ReplaySubject(1),
84
+ resetOnError: false,
85
+ resetOnComplete: false,
86
+ resetOnRefCountZero: false,
87
+ }));
88
+ this.onMotionStarted = this.onMotionDetected.pipe((0, operators_1.filter)((currentlyDetected) => currentlyDetected), (0, operators_1.map)(() => null), // no value needed, event is what matters
84
89
  (0, operators_1.share)());
85
90
  this.lastSnapshotTimestamp = 0;
86
91
  this.lastSnapshotTimestampLocal = 0;
@@ -265,7 +270,9 @@ class RingCamera extends subscribed_1.Subscribed {
265
270
  this.onActiveNotifications.next(otherDings);
266
271
  }
267
272
  processPushNotification(notification) {
268
- if (!('ding' in notification.data?.event)) {
273
+ if (!('android_config' in notification) ||
274
+ !('event' in notification.data) ||
275
+ !('ding' in notification.data?.event)) {
269
276
  // only process ding/motion notifications
270
277
  return;
271
278
  }
@@ -1,4 +1,4 @@
1
- import { IntercomHandsetAudioData, PushNotificationDingV2, PushNotificationIntercomUnlockV2 } from './ring-types';
1
+ import { IntercomHandsetAudioData, PushNotification } from './ring-types';
2
2
  import { RingRestClient } from './rest-client';
3
3
  import { BehaviorSubject, Subject } from 'rxjs';
4
4
  export declare class RingIntercom {
@@ -22,5 +22,5 @@ export declare class RingIntercom {
22
22
  private doorbotUrl;
23
23
  subscribeToDingEvents(): Promise<void & import("./rest-client").ExtendedResponse>;
24
24
  unsubscribeFromDingEvents(): Promise<void & import("./rest-client").ExtendedResponse>;
25
- processPushNotification(notification: PushNotificationDingV2 | PushNotificationIntercomUnlockV2): void;
25
+ processPushNotification(notification: PushNotification): void;
26
26
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ring-client-api",
3
- "version": "13.0.0-beta.4",
3
+ "version": "13.0.0-beta.6",
4
4
  "description": "Unofficial API for Ring doorbells, cameras, security alarm system and smart lighting",
5
5
  "main": "lib/index.js",
6
6
  "exports": {
@@ -17,7 +17,7 @@
17
17
  "test:watch": "jest --watch"
18
18
  },
19
19
  "dependencies": {
20
- "@eneris/push-receiver": "^4.1.4",
20
+ "@eneris/push-receiver": "4.1.3",
21
21
  "@homebridge/camera-utils": "^2.2.6",
22
22
  "@types/socket.io-client": "1.4.36",
23
23
  "colors": "1.4.0",