ring-client-api 10.0.0-beta.6 → 10.0.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 +34 -0
- package/lib/api/api.js +1 -3
- package/lib/api/rest-client.d.ts +5 -0
- package/lib/api/rest-client.js +7 -6
- package/lib/api/ring-camera.d.ts +8 -0
- package/lib/api/ring-camera.js +10 -0
- package/lib/api/ring-types.d.ts +1 -0
- package/lib/api/ring-types.js +2 -0
- package/lib/api/streaming/simple-webrtc-session.d.ts +11 -0
- package/lib/api/streaming/simple-webrtc-session.js +63 -0
- package/lib/api/util.js +9 -0
- package/package.json +8 -7
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,40 @@
|
|
|
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
|
+
## [10.0.0](https://github.com/dgreif/ring/compare/v10.0.0-beta.8...v10.0.0) (2022-05-08)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* prevent push receiver ECONNRESET error from logging ([644e86d](https://github.com/dgreif/ring/commit/644e86d6517e73391139b12bac4dc048c8bedf13))
|
|
11
|
+
|
|
12
|
+
## [10.0.0-beta.8](https://github.com/dgreif/ring/compare/v10.0.0-beta.7...v10.0.0-beta.8) (2022-05-07)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* remove unnecessary dependencies ([0acf3c3](https://github.com/dgreif/ring/commit/0acf3c35ce2b62d98e3e50ba8489996400efb4e3))
|
|
18
|
+
|
|
19
|
+
## [10.0.0-beta.7](https://github.com/dgreif/ring/compare/v10.0.0-beta.6...v10.0.0-beta.7) (2022-05-07)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### ⚠ BREAKING CHANGES
|
|
23
|
+
|
|
24
|
+
* The `sendDoorbellMotionNotificationsToTv` and `sendCameraMotionNotificationsToTv` options have been removed. These options were originally inteded as a workaround for the fact that tvOS would only automatically start streaming for doorbell presses and not for motion events. tvOS 15 now supports this features as an option in the UI, so we no longer need this option at the plugin level.
|
|
25
|
+
|
|
26
|
+
### Features
|
|
27
|
+
|
|
28
|
+
* add `cocoa_floodlight` ([c7a7e9c](https://github.com/dgreif/ring/commit/c7a7e9cabf45ec6579a7d9a1033fa01930923243)), closes [#893](https://github.com/dgreif/ring/issues/893)
|
|
29
|
+
* **api:** simple webrtc session ([bac7a49](https://github.com/dgreif/ring/commit/bac7a49178bb5a22914e53fda91c0fdd522b4a74))
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
### Bug Fixes
|
|
33
|
+
|
|
34
|
+
* **homebridge:** add `name` option to schema so that it won't be removed by config-ui ([af6755a](https://github.com/dgreif/ring/commit/af6755aa09cf4aaad0963499ad0d1afd0beeab96)), closes [#870](https://github.com/dgreif/ring/issues/870)
|
|
35
|
+
* include device name when setting push token ([2466a25](https://github.com/dgreif/ring/commit/2466a2519341771d8c79557b5a61c339f31eddf6)), closes [#920](https://github.com/dgreif/ring/issues/920)
|
|
36
|
+
* npm audit fix ([c1fe605](https://github.com/dgreif/ring/commit/c1fe6051e46dac92b00bb2fd1202746fd576b15a))
|
|
37
|
+
* remove doorbell press simulation options ([e1d1225](https://github.com/dgreif/ring/commit/e1d12257b2acbdafdc6995a53d9052822c8a3460))
|
|
38
|
+
|
|
5
39
|
## [10.0.0-beta.6](https://github.com/dgreif/ring/compare/v10.0.0-beta.5...v10.0.0-beta.6) (2022-05-06)
|
|
6
40
|
|
|
7
41
|
|
package/lib/api/api.js
CHANGED
|
@@ -112,9 +112,7 @@ class RingApi extends subscribed_1.Subscribed {
|
|
|
112
112
|
method: 'PATCH',
|
|
113
113
|
json: {
|
|
114
114
|
device: {
|
|
115
|
-
metadata: {
|
|
116
|
-
pn_service: 'fcm',
|
|
117
|
-
},
|
|
115
|
+
metadata: Object.assign(Object.assign({}, this.restClient.baseSessionMetadata), { pn_service: 'fcm' }),
|
|
118
116
|
os: 'android',
|
|
119
117
|
push_notification_token: token,
|
|
120
118
|
},
|
package/lib/api/rest-client.d.ts
CHANGED
|
@@ -35,6 +35,10 @@ export declare class RingRestClient {
|
|
|
35
35
|
oldRefreshToken?: string | undefined;
|
|
36
36
|
newRefreshToken: string;
|
|
37
37
|
}>;
|
|
38
|
+
readonly baseSessionMetadata: {
|
|
39
|
+
api_version: number;
|
|
40
|
+
device_model: string;
|
|
41
|
+
};
|
|
38
42
|
constructor(authOptions: (EmailAuth | RefreshTokenAuth) & SessionOptions);
|
|
39
43
|
private getGrantData;
|
|
40
44
|
getAuth(twoFactorAuthCode?: string): Promise<AuthTokenResponse>;
|
|
@@ -44,6 +48,7 @@ export declare class RingRestClient {
|
|
|
44
48
|
private refreshSession;
|
|
45
49
|
request<T = void>(options: RequestOptions & {
|
|
46
50
|
url: string;
|
|
51
|
+
allowNoResponse?: boolean;
|
|
47
52
|
}): Promise<T & ExtendedResponse>;
|
|
48
53
|
getCurrentAuth(): Promise<AuthTokenResponse>;
|
|
49
54
|
clearTimeouts(): void;
|
package/lib/api/rest-client.js
CHANGED
|
@@ -55,7 +55,7 @@ function requestWithRetry(requestOptions) {
|
|
|
55
55
|
return data;
|
|
56
56
|
}
|
|
57
57
|
catch (e) {
|
|
58
|
-
if (!e.response) {
|
|
58
|
+
if (!e.response && !requestOptions.allowNoResponse) {
|
|
59
59
|
(0, util_1.logError)(`Failed to reach Ring server at ${requestOptions.url}. ${e.message}. Trying again in 5 seconds...`);
|
|
60
60
|
if (e.message.includes('NGHTTP2_ENHANCE_YOUR_CALM')) {
|
|
61
61
|
(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`);
|
|
@@ -70,11 +70,16 @@ function requestWithRetry(requestOptions) {
|
|
|
70
70
|
}
|
|
71
71
|
class RingRestClient {
|
|
72
72
|
constructor(authOptions) {
|
|
73
|
+
var _a;
|
|
73
74
|
this.authOptions = authOptions;
|
|
74
75
|
this.timeouts = [];
|
|
75
76
|
this.sessionPromise = undefined;
|
|
76
77
|
this.using2fa = false;
|
|
77
78
|
this.onRefreshTokenUpdated = new rxjs_1.ReplaySubject(1);
|
|
79
|
+
this.baseSessionMetadata = {
|
|
80
|
+
api_version: apiVersion,
|
|
81
|
+
device_model: (_a = this.authOptions.controlCenterDisplayName) !== null && _a !== void 0 ? _a : 'ring-client-api',
|
|
82
|
+
};
|
|
78
83
|
this.refreshToken =
|
|
79
84
|
'refreshToken' in this.authOptions
|
|
80
85
|
? this.authOptions.refreshToken
|
|
@@ -184,17 +189,13 @@ class RingRestClient {
|
|
|
184
189
|
});
|
|
185
190
|
}
|
|
186
191
|
fetchNewSession(authToken) {
|
|
187
|
-
var _a;
|
|
188
192
|
return __awaiter(this, void 0, void 0, function* () {
|
|
189
193
|
return requestWithRetry({
|
|
190
194
|
url: clientApi('session'),
|
|
191
195
|
json: {
|
|
192
196
|
device: {
|
|
193
197
|
hardware_id: yield this.hardwareIdPromise,
|
|
194
|
-
metadata:
|
|
195
|
-
api_version: apiVersion,
|
|
196
|
-
device_model: (_a = this.authOptions.controlCenterDisplayName) !== null && _a !== void 0 ? _a : 'ring-client-api',
|
|
197
|
-
},
|
|
198
|
+
metadata: this.baseSessionMetadata,
|
|
198
199
|
os: 'android', // can use android, ios, ring-site, windows for sure
|
|
199
200
|
},
|
|
200
201
|
},
|
package/lib/api/ring-camera.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { DeepPartial } from './util';
|
|
|
6
6
|
import { Subscribed } from './subscribed';
|
|
7
7
|
import { FfmpegOptions, StreamingSession } from './streaming/streaming-session';
|
|
8
8
|
import { StreamingConnectionOptions } from './streaming/streaming-connection-base';
|
|
9
|
+
import { SimpleWebRtcSession } from './streaming/simple-webrtc-session';
|
|
9
10
|
export declare function getBatteryLevel(data: Pick<CameraData, 'battery_life' | 'battery_life_2'> & {
|
|
10
11
|
health?: Partial<CameraData['health']>;
|
|
11
12
|
}): number | null;
|
|
@@ -95,6 +96,13 @@ export declare class RingCamera extends Subscribed {
|
|
|
95
96
|
getSnapshotByUuid(uuid: string): Promise<Buffer & import("./rest-client").ExtendedResponse>;
|
|
96
97
|
recordToFile(outputPath: string, duration?: number): Promise<void>;
|
|
97
98
|
streamVideo(ffmpegOptions: FfmpegOptions): Promise<StreamingSession>;
|
|
99
|
+
/**
|
|
100
|
+
* Returns a SimpleWebRtcSession, which can be initiated with an sdp offer.
|
|
101
|
+
* This session has no backplane for trickle ICE, and is designed for use in a
|
|
102
|
+
* browser setting. Note, cameras with Ring Edge enabled will stream with the speaker
|
|
103
|
+
* enabled as soon as the stream starts, which can drain the battery more quickly.
|
|
104
|
+
*/
|
|
105
|
+
createSimpleWebRtcSession(): SimpleWebRtcSession;
|
|
98
106
|
subscribeToDingEvents(): Promise<void & import("./rest-client").ExtendedResponse>;
|
|
99
107
|
unsubscribeFromDingEvents(): Promise<void & import("./rest-client").ExtendedResponse>;
|
|
100
108
|
subscribeToMotionEvents(): Promise<void & import("./rest-client").ExtendedResponse>;
|
package/lib/api/ring-camera.js
CHANGED
|
@@ -19,6 +19,7 @@ const subscribed_1 = require("./subscribed");
|
|
|
19
19
|
const webrtc_connection_1 = require("./streaming/webrtc-connection");
|
|
20
20
|
const ring_edge_connection_1 = require("./streaming/ring-edge-connection");
|
|
21
21
|
const streaming_session_1 = require("./streaming/streaming-session");
|
|
22
|
+
const simple_webrtc_session_1 = require("./streaming/simple-webrtc-session");
|
|
22
23
|
const maxSnapshotRefreshSeconds = 15, fullDayMs = 24 * 60 * 60 * 1000;
|
|
23
24
|
function parseBatteryLife(batteryLife) {
|
|
24
25
|
if (batteryLife === null || batteryLife === undefined) {
|
|
@@ -416,6 +417,15 @@ class RingCamera extends subscribed_1.Subscribed {
|
|
|
416
417
|
return liveCall;
|
|
417
418
|
});
|
|
418
419
|
}
|
|
420
|
+
/**
|
|
421
|
+
* Returns a SimpleWebRtcSession, which can be initiated with an sdp offer.
|
|
422
|
+
* This session has no backplane for trickle ICE, and is designed for use in a
|
|
423
|
+
* browser setting. Note, cameras with Ring Edge enabled will stream with the speaker
|
|
424
|
+
* enabled as soon as the stream starts, which can drain the battery more quickly.
|
|
425
|
+
*/
|
|
426
|
+
createSimpleWebRtcSession() {
|
|
427
|
+
return new simple_webrtc_session_1.SimpleWebRtcSession(this, this.restClient);
|
|
428
|
+
}
|
|
419
429
|
subscribeToDingEvents() {
|
|
420
430
|
return this.restClient.request({
|
|
421
431
|
method: 'POST',
|
package/lib/api/ring-types.d.ts
CHANGED
|
@@ -85,6 +85,7 @@ export declare enum RingCameraKind {
|
|
|
85
85
|
floodlight_pro = "floodlight_pro",
|
|
86
86
|
cocoa_camera = "cocoa_camera",
|
|
87
87
|
cocoa_doorbell = "cocoa_doorbell",
|
|
88
|
+
cocoa_floodlight = "cocoa_floodlight",
|
|
88
89
|
stickup_cam_mini = "stickup_cam_mini"
|
|
89
90
|
}
|
|
90
91
|
export declare const RingCameraModel: {
|
package/lib/api/ring-types.js
CHANGED
|
@@ -93,6 +93,7 @@ var RingCameraKind;
|
|
|
93
93
|
RingCameraKind["floodlight_pro"] = "floodlight_pro";
|
|
94
94
|
RingCameraKind["cocoa_camera"] = "cocoa_camera";
|
|
95
95
|
RingCameraKind["cocoa_doorbell"] = "cocoa_doorbell";
|
|
96
|
+
RingCameraKind["cocoa_floodlight"] = "cocoa_floodlight";
|
|
96
97
|
RingCameraKind["stickup_cam_mini"] = "stickup_cam_mini";
|
|
97
98
|
})(RingCameraKind = exports.RingCameraKind || (exports.RingCameraKind = {}));
|
|
98
99
|
exports.RingCameraModel = {
|
|
@@ -121,6 +122,7 @@ exports.RingCameraModel = {
|
|
|
121
122
|
floodlight_pro: 'Floodlight Pro',
|
|
122
123
|
cocoa_camera: 'Stick Up Cam',
|
|
123
124
|
cocoa_doorbell: 'Doorbell Gen 2',
|
|
125
|
+
cocoa_floodlight: 'Floodlight Cam Plus',
|
|
124
126
|
stickup_cam_mini: 'Indoor Cam',
|
|
125
127
|
};
|
|
126
128
|
exports.allAlarmStates = [
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { RingCamera } from '../ring-camera';
|
|
2
|
+
import { RingRestClient } from '../rest-client';
|
|
3
|
+
export declare class SimpleWebRtcSession {
|
|
4
|
+
private readonly camera;
|
|
5
|
+
private restClient;
|
|
6
|
+
readonly sessionId: string;
|
|
7
|
+
constructor(camera: RingCamera, restClient: RingRestClient);
|
|
8
|
+
start(sdp: string): Promise<string>;
|
|
9
|
+
end(): Promise<any>;
|
|
10
|
+
activateCameraSpeaker(): Promise<void>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.SimpleWebRtcSession = void 0;
|
|
13
|
+
const util_1 = require("../util");
|
|
14
|
+
function liveViewUrl(path) {
|
|
15
|
+
return `https://api.ring.com/integrations/v1/liveview/${path}`;
|
|
16
|
+
}
|
|
17
|
+
class SimpleWebRtcSession {
|
|
18
|
+
constructor(camera, restClient) {
|
|
19
|
+
this.camera = camera;
|
|
20
|
+
this.restClient = restClient;
|
|
21
|
+
this.sessionId = (0, util_1.generateUuid)();
|
|
22
|
+
}
|
|
23
|
+
start(sdp) {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
const response = yield this.restClient.request({
|
|
26
|
+
method: 'POST',
|
|
27
|
+
url: liveViewUrl('start'),
|
|
28
|
+
json: {
|
|
29
|
+
session_id: this.sessionId,
|
|
30
|
+
device_id: this.camera.id,
|
|
31
|
+
sdp,
|
|
32
|
+
protocol: 'webrtc',
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
return response.sdp;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
end() {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
const resp = yield this.restClient.request({
|
|
41
|
+
method: 'POST',
|
|
42
|
+
url: liveViewUrl('end'),
|
|
43
|
+
json: {
|
|
44
|
+
session_id: this.sessionId,
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
return resp;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
activateCameraSpeaker() {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
yield this.restClient.request({
|
|
53
|
+
method: 'PATCH',
|
|
54
|
+
url: liveViewUrl('options'),
|
|
55
|
+
json: {
|
|
56
|
+
session_id: this.sessionId,
|
|
57
|
+
actions: ['turn_off_stealth_mode'],
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.SimpleWebRtcSession = SimpleWebRtcSession;
|
package/lib/api/util.js
CHANGED
|
@@ -123,6 +123,15 @@ function randomString(length) {
|
|
|
123
123
|
exports.randomString = randomString;
|
|
124
124
|
// Override push receiver logging to avoid ECONNRESET errors leaking
|
|
125
125
|
function logPushReceiver(...args) {
|
|
126
|
+
try {
|
|
127
|
+
if (args[0].toString().includes('ECONNRESET')) {
|
|
128
|
+
// don't log ECONNRESET errors
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
catch (_) {
|
|
133
|
+
// proceed to log error
|
|
134
|
+
}
|
|
126
135
|
logDebug('[Push Receiver]');
|
|
127
136
|
logDebug(args[0]);
|
|
128
137
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ring-client-api",
|
|
3
|
-
"version": "10.0.0
|
|
3
|
+
"version": "10.0.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": {
|
|
@@ -15,12 +15,12 @@
|
|
|
15
15
|
"lint": "eslint '**/*.ts' --fix",
|
|
16
16
|
"build": "rm -rf lib && tsc --declaration",
|
|
17
17
|
"build-quick": "rm -rf lib && esbuild ./{api,examples,homebridge}/*.ts ./api/streaming/*.ts --target=es2017 --format=cjs --outdir=lib",
|
|
18
|
-
"example": "
|
|
19
|
-
"api-example": "
|
|
20
|
-
"record-example": "
|
|
21
|
-
"return-audio-example": "
|
|
22
|
-
"stream-example": "
|
|
23
|
-
"browser-example": "
|
|
18
|
+
"example": "node -r @swc-node/register ./lib/examples/example.js",
|
|
19
|
+
"api-example": "node -r @swc-node/register ./lib/examples/api-example.js",
|
|
20
|
+
"record-example": "node -r @swc-node/register ./lib/examples/record-example.js",
|
|
21
|
+
"return-audio-example": "node -r @swc-node/register ./lib/examples/return-audio-example.js",
|
|
22
|
+
"stream-example": "node -r @swc-node/register ./lib/examples/stream-example.js",
|
|
23
|
+
"browser-example": "node -r @swc-node/register ./lib/examples/browser-example.js",
|
|
24
24
|
"auth-cli": "npm run build-quick && ./ring-auth-cli.js",
|
|
25
25
|
"device-data-cli": "npm run build-quick && ./ring-device-data-cli.js",
|
|
26
26
|
"hb": "npm run build-quick && ./build/package-homebridge.sh && homebridge -P ./release-homebridge -U ./.homebridge",
|
|
@@ -70,6 +70,7 @@
|
|
|
70
70
|
"ws": "^8.6.0"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
|
+
"@swc-node/register": "^1.5.1",
|
|
73
74
|
"@types/debug": "4.1.7",
|
|
74
75
|
"@types/jest": "27.5.0",
|
|
75
76
|
"@types/node": "17.0.31",
|