ring-client-api 10.0.0 → 11.0.2-beta.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 +64 -0
- package/lib/api/api.js +79 -96
- package/lib/api/device-data.js +20 -31
- package/lib/api/location.js +125 -157
- package/lib/api/refresh-token.js +23 -36
- package/lib/api/rest-client.js +159 -165
- package/lib/api/ring-camera.js +121 -157
- package/lib/api/ring-chime.js +32 -51
- package/lib/api/ring-device.js +4 -1
- package/lib/api/streaming/peer-connection.d.ts +3 -3
- package/lib/api/streaming/peer-connection.js +18 -27
- package/lib/api/streaming/ring-edge-connection.js +56 -65
- package/lib/api/streaming/simple-webrtc-session.js +27 -42
- package/lib/api/streaming/streaming-connection-base.d.ts +1 -1
- package/lib/api/streaming/streaming-connection-base.js +12 -25
- package/lib/api/streaming/streaming-session.d.ts +2 -1
- package/lib/api/streaming/streaming-session.js +60 -74
- package/lib/api/streaming/webrtc-connection.js +22 -30
- package/lib/api/util.js +26 -39
- package/package.json +21 -21
package/lib/api/ring-camera.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.RingCamera = exports.getSearchQueryString = exports.getBatteryLevel = void 0;
|
|
13
4
|
const ring_types_1 = require("./ring-types");
|
|
@@ -92,7 +83,7 @@ class RingCamera extends subscribed_1.Subscribed {
|
|
|
92
83
|
this.hasSiren = this.initialData.siren_status !== undefined;
|
|
93
84
|
this.onBatteryLevel = this.onData.pipe((0, operators_1.map)(getBatteryLevel), (0, operators_1.distinctUntilChanged)());
|
|
94
85
|
this.onInHomeDoorbellStatus = this.onData.pipe((0, operators_1.map)(({ settings: { chime_settings } }) => {
|
|
95
|
-
return Boolean(chime_settings
|
|
86
|
+
return Boolean(chime_settings?.enable);
|
|
96
87
|
}), (0, operators_1.distinctUntilChanged)());
|
|
97
88
|
if (!initialData.subscribed) {
|
|
98
89
|
this.subscribeToDingEvents().catch((e) => {
|
|
@@ -159,53 +150,45 @@ class RingCamera extends subscribed_1.Subscribed {
|
|
|
159
150
|
deviceUrl(path = '') {
|
|
160
151
|
return (0, rest_client_1.deviceApi)(`devices/${this.id}/${path}`);
|
|
161
152
|
}
|
|
162
|
-
setLight(on) {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
url: this.doorbotUrl('floodlight_light_' + state),
|
|
171
|
-
});
|
|
172
|
-
this.updateData(Object.assign(Object.assign({}, this.data), { led_status: state }));
|
|
173
|
-
return true;
|
|
153
|
+
async setLight(on) {
|
|
154
|
+
if (!this.hasLight) {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
const state = on ? 'on' : 'off';
|
|
158
|
+
await this.restClient.request({
|
|
159
|
+
method: 'PUT',
|
|
160
|
+
url: this.doorbotUrl('floodlight_light_' + state),
|
|
174
161
|
});
|
|
162
|
+
this.updateData({ ...this.data, led_status: state });
|
|
163
|
+
return true;
|
|
175
164
|
}
|
|
176
|
-
setSiren(on) {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
url: this.doorbotUrl('siren_' + (on ? 'on' : 'off')),
|
|
184
|
-
});
|
|
185
|
-
this.updateData(Object.assign(Object.assign({}, this.data), { siren_status: { seconds_remaining: 1 } }));
|
|
186
|
-
return true;
|
|
165
|
+
async setSiren(on) {
|
|
166
|
+
if (!this.hasSiren) {
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
await this.restClient.request({
|
|
170
|
+
method: 'PUT',
|
|
171
|
+
url: this.doorbotUrl('siren_' + (on ? 'on' : 'off')),
|
|
187
172
|
});
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
}
|
|
196
|
-
this.requestUpdate();
|
|
173
|
+
this.updateData({ ...this.data, siren_status: { seconds_remaining: 1 } });
|
|
174
|
+
return true;
|
|
175
|
+
}
|
|
176
|
+
async setSettings(settings) {
|
|
177
|
+
await this.restClient.request({
|
|
178
|
+
method: 'PUT',
|
|
179
|
+
url: this.doorbotUrl(),
|
|
180
|
+
json: { doorbot: { settings } },
|
|
197
181
|
});
|
|
182
|
+
this.requestUpdate();
|
|
198
183
|
}
|
|
199
|
-
setDeviceSettings(settings) {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
json: settings,
|
|
205
|
-
});
|
|
206
|
-
this.requestUpdate();
|
|
207
|
-
return response;
|
|
184
|
+
async setDeviceSettings(settings) {
|
|
185
|
+
const response = await this.restClient.request({
|
|
186
|
+
method: 'PATCH',
|
|
187
|
+
url: this.deviceUrl('settings'),
|
|
188
|
+
json: settings,
|
|
208
189
|
});
|
|
190
|
+
this.requestUpdate();
|
|
191
|
+
return response;
|
|
209
192
|
}
|
|
210
193
|
getDeviceSettings() {
|
|
211
194
|
return this.restClient.request({
|
|
@@ -214,51 +197,42 @@ class RingCamera extends subscribed_1.Subscribed {
|
|
|
214
197
|
});
|
|
215
198
|
}
|
|
216
199
|
// Enable or disable the in-home doorbell (if digital or mechanical)
|
|
217
|
-
setInHomeDoorbell(enable) {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
return true;
|
|
224
|
-
});
|
|
200
|
+
async setInHomeDoorbell(enable) {
|
|
201
|
+
if (!this.hasInHomeDoorbell) {
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
await this.setSettings({ chime_settings: { enable } });
|
|
205
|
+
return true;
|
|
225
206
|
}
|
|
226
|
-
getHealth() {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
url: this.doorbotUrl('health'),
|
|
230
|
-
});
|
|
231
|
-
return response.device_health;
|
|
207
|
+
async getHealth() {
|
|
208
|
+
const response = await this.restClient.request({
|
|
209
|
+
url: this.doorbotUrl('health'),
|
|
232
210
|
});
|
|
211
|
+
return response.device_health;
|
|
233
212
|
}
|
|
234
|
-
createStreamingConnection(options) {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
213
|
+
async createStreamingConnection(options) {
|
|
214
|
+
if (this.isRingEdgeEnabled) {
|
|
215
|
+
const auth = await this.restClient.getCurrentAuth();
|
|
216
|
+
return new ring_edge_connection_1.RingEdgeConnection(auth.access_token, this, options);
|
|
217
|
+
}
|
|
218
|
+
const liveCall = await this.restClient
|
|
219
|
+
.request({
|
|
220
|
+
method: 'POST',
|
|
221
|
+
url: this.doorbotUrl('live_call'),
|
|
222
|
+
})
|
|
223
|
+
.catch((e) => {
|
|
224
|
+
if (e.response?.statusCode === 403) {
|
|
225
|
+
const errorMessage = `Camera ${this.name} returned 403 when starting a live stream. This usually indicates that live streaming is blocked by Modes settings. Check your Ring app and verify that you are able to stream from this camera with the current Modes settings.`;
|
|
226
|
+
(0, util_1.logError)(errorMessage);
|
|
227
|
+
throw new Error(errorMessage);
|
|
239
228
|
}
|
|
240
|
-
|
|
241
|
-
.request({
|
|
242
|
-
method: 'POST',
|
|
243
|
-
url: this.doorbotUrl('live_call'),
|
|
244
|
-
})
|
|
245
|
-
.catch((e) => {
|
|
246
|
-
var _a;
|
|
247
|
-
if (((_a = e.response) === null || _a === void 0 ? void 0 : _a.statusCode) === 403) {
|
|
248
|
-
const errorMessage = `Camera ${this.name} returned 403 when starting a live stream. This usually indicates that live streaming is blocked by Modes settings. Check your Ring app and verify that you are able to stream from this camera with the current Modes settings.`;
|
|
249
|
-
(0, util_1.logError)(errorMessage);
|
|
250
|
-
throw new Error(errorMessage);
|
|
251
|
-
}
|
|
252
|
-
throw e;
|
|
253
|
-
});
|
|
254
|
-
return new webrtc_connection_1.WebrtcConnection(liveCall.data.session_id, this, options);
|
|
229
|
+
throw e;
|
|
255
230
|
});
|
|
231
|
+
return new webrtc_connection_1.WebrtcConnection(liveCall.data.session_id, this, options);
|
|
256
232
|
}
|
|
257
|
-
startLiveCall(options = {}) {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
return new streaming_session_1.StreamingSession(this, connection);
|
|
261
|
-
});
|
|
233
|
+
async startLiveCall(options = {}) {
|
|
234
|
+
const connection = await this.createStreamingConnection(options);
|
|
235
|
+
return new streaming_session_1.StreamingSession(this, connection);
|
|
262
236
|
}
|
|
263
237
|
removeDingById(idToRemove) {
|
|
264
238
|
const allActiveDings = this.activeNotifications, otherDings = allActiveDings.filter(({ ding }) => ding.id !== idToRemove);
|
|
@@ -294,13 +268,11 @@ class RingCamera extends subscribed_1.Subscribed {
|
|
|
294
268
|
url: `https://api.ring.com/recordings/public/footages/${this.id}?start_at_ms=${startAtMs}&end_at_ms=${endAtMs}&kinds=online_periodical&kinds=offline_periodical`,
|
|
295
269
|
});
|
|
296
270
|
}
|
|
297
|
-
getRecordingUrl(dingIdStr, { transcoded = false } = {}) {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
url: (0, rest_client_1.clientApi)(`dings/${dingIdStr}/${path}?disable_redirect=true`),
|
|
301
|
-
});
|
|
302
|
-
return response.url;
|
|
271
|
+
async getRecordingUrl(dingIdStr, { transcoded = false } = {}) {
|
|
272
|
+
const path = transcoded ? 'recording' : 'share/play', response = await this.restClient.request({
|
|
273
|
+
url: (0, rest_client_1.clientApi)(`dings/${dingIdStr}/${path}?disable_redirect=true`),
|
|
303
274
|
});
|
|
275
|
+
return response.url;
|
|
304
276
|
}
|
|
305
277
|
isTimestampInLifeTime(timestampAge) {
|
|
306
278
|
return timestampAge < this.snapshotLifeTime;
|
|
@@ -341,57 +313,53 @@ class RingCamera extends subscribed_1.Subscribed {
|
|
|
341
313
|
return false;
|
|
342
314
|
}
|
|
343
315
|
}
|
|
344
|
-
getSnapshot({ uuid } = {}) {
|
|
345
|
-
|
|
346
|
-
if (this.lastSnapshotPromise && this.shouldUseExistingSnapshotPromise()) {
|
|
347
|
-
return this.lastSnapshotPromise;
|
|
348
|
-
}
|
|
349
|
-
this.checkIfSnapshotsAreBlocked();
|
|
350
|
-
this.lastSnapshotPromise = Promise.race([
|
|
351
|
-
this.getNextSnapshot(uuid
|
|
352
|
-
? { uuid }
|
|
353
|
-
: {
|
|
354
|
-
afterMs: this.lastSnapshotTimestamp,
|
|
355
|
-
force: true,
|
|
356
|
-
}),
|
|
357
|
-
(0, util_1.delay)(maxSnapshotRefreshSeconds * 1000).then(() => {
|
|
358
|
-
const extraMessageForBatteryCam = this.operatingOnBattery
|
|
359
|
-
? '. This is normal behavior since this camera is unable to capture snapshots while streaming'
|
|
360
|
-
: '';
|
|
361
|
-
throw new Error(`Snapshot for ${this.name} (${this.deviceType} - ${this.model}) failed to refresh after ${maxSnapshotRefreshSeconds} seconds${extraMessageForBatteryCam}`);
|
|
362
|
-
}),
|
|
363
|
-
]);
|
|
364
|
-
try {
|
|
365
|
-
yield this.lastSnapshotPromise;
|
|
366
|
-
}
|
|
367
|
-
catch (e) {
|
|
368
|
-
// snapshot request failed, don't use it again
|
|
369
|
-
this.lastSnapshotPromise = undefined;
|
|
370
|
-
throw e;
|
|
371
|
-
}
|
|
372
|
-
this.fetchingSnapshot = false;
|
|
316
|
+
async getSnapshot({ uuid } = {}) {
|
|
317
|
+
if (this.lastSnapshotPromise && this.shouldUseExistingSnapshotPromise()) {
|
|
373
318
|
return this.lastSnapshotPromise;
|
|
374
|
-
}
|
|
319
|
+
}
|
|
320
|
+
this.checkIfSnapshotsAreBlocked();
|
|
321
|
+
this.lastSnapshotPromise = Promise.race([
|
|
322
|
+
this.getNextSnapshot(uuid
|
|
323
|
+
? { uuid }
|
|
324
|
+
: {
|
|
325
|
+
afterMs: this.lastSnapshotTimestamp,
|
|
326
|
+
force: true,
|
|
327
|
+
}),
|
|
328
|
+
(0, util_1.delay)(maxSnapshotRefreshSeconds * 1000).then(() => {
|
|
329
|
+
const extraMessageForBatteryCam = this.operatingOnBattery
|
|
330
|
+
? '. This is normal behavior since this camera is unable to capture snapshots while streaming'
|
|
331
|
+
: '';
|
|
332
|
+
throw new Error(`Snapshot for ${this.name} (${this.deviceType} - ${this.model}) failed to refresh after ${maxSnapshotRefreshSeconds} seconds${extraMessageForBatteryCam}`);
|
|
333
|
+
}),
|
|
334
|
+
]);
|
|
335
|
+
try {
|
|
336
|
+
await this.lastSnapshotPromise;
|
|
337
|
+
}
|
|
338
|
+
catch (e) {
|
|
339
|
+
// snapshot request failed, don't use it again
|
|
340
|
+
this.lastSnapshotPromise = undefined;
|
|
341
|
+
throw e;
|
|
342
|
+
}
|
|
343
|
+
this.fetchingSnapshot = false;
|
|
344
|
+
return this.lastSnapshotPromise;
|
|
375
345
|
}
|
|
376
|
-
getNextSnapshot({ afterMs, maxWaitMs, force, uuid, }) {
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
return response;
|
|
394
|
-
});
|
|
346
|
+
async getNextSnapshot({ afterMs, maxWaitMs, force, uuid, }) {
|
|
347
|
+
const response = await this.restClient.request({
|
|
348
|
+
url: `https://app-snaps.ring.com/snapshots/next/${this.id}`,
|
|
349
|
+
responseType: 'buffer',
|
|
350
|
+
searchParams: {
|
|
351
|
+
'after-ms': afterMs,
|
|
352
|
+
'max-wait-ms': maxWaitMs,
|
|
353
|
+
extras: force ? 'force' : undefined,
|
|
354
|
+
uuid,
|
|
355
|
+
},
|
|
356
|
+
headers: {
|
|
357
|
+
accept: 'image/jpeg',
|
|
358
|
+
},
|
|
359
|
+
}), { responseTimestamp, timeMillis } = response, timestampAge = Math.abs(responseTimestamp - timeMillis);
|
|
360
|
+
this.lastSnapshotTimestamp = timeMillis;
|
|
361
|
+
this.lastSnapshotTimestampLocal = Date.now() - timestampAge;
|
|
362
|
+
return response;
|
|
395
363
|
}
|
|
396
364
|
getSnapshotByUuid(uuid) {
|
|
397
365
|
return this.restClient.request({
|
|
@@ -402,20 +370,16 @@ class RingCamera extends subscribed_1.Subscribed {
|
|
|
402
370
|
},
|
|
403
371
|
});
|
|
404
372
|
}
|
|
405
|
-
recordToFile(outputPath, duration = 30) {
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
output: ['-t', duration.toString(), outputPath],
|
|
409
|
-
});
|
|
410
|
-
yield (0, rxjs_1.firstValueFrom)(liveCall.onCallEnded);
|
|
373
|
+
async recordToFile(outputPath, duration = 30) {
|
|
374
|
+
const liveCall = await this.streamVideo({
|
|
375
|
+
output: ['-t', duration.toString(), outputPath],
|
|
411
376
|
});
|
|
377
|
+
await (0, rxjs_1.firstValueFrom)(liveCall.onCallEnded);
|
|
412
378
|
}
|
|
413
|
-
streamVideo(ffmpegOptions) {
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
return liveCall;
|
|
418
|
-
});
|
|
379
|
+
async streamVideo(ffmpegOptions) {
|
|
380
|
+
const liveCall = await this.startLiveCall();
|
|
381
|
+
await liveCall.startTranscoding(ffmpegOptions);
|
|
382
|
+
return liveCall;
|
|
419
383
|
}
|
|
420
384
|
/**
|
|
421
385
|
* Returns a SimpleWebRtcSession, which can be initiated with an sdp offer.
|
package/lib/api/ring-chime.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.RingChime = void 0;
|
|
13
4
|
const ring_types_1 = require("./ring-types");
|
|
@@ -52,16 +43,14 @@ class RingChime {
|
|
|
52
43
|
url: (0, rest_client_1.clientApi)('ringtones'),
|
|
53
44
|
});
|
|
54
45
|
}
|
|
55
|
-
getRingtoneByDescription(description, kind) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return requestedRingtone;
|
|
64
|
-
});
|
|
46
|
+
async getRingtoneByDescription(description, kind) {
|
|
47
|
+
const ringtones = await this.getRingtones(), requestedRingtone = ringtones.audios.find((audio) => audio.available &&
|
|
48
|
+
audio.description === description &&
|
|
49
|
+
audio.kind === kind);
|
|
50
|
+
if (!requestedRingtone) {
|
|
51
|
+
throw new Error('Requested ringtone not found');
|
|
52
|
+
}
|
|
53
|
+
return requestedRingtone;
|
|
65
54
|
}
|
|
66
55
|
chimeUrl(path = '') {
|
|
67
56
|
return (0, rest_client_1.clientApi)(`chimes/${this.id}/${path}`);
|
|
@@ -73,37 +62,31 @@ class RingChime {
|
|
|
73
62
|
json: { kind },
|
|
74
63
|
});
|
|
75
64
|
}
|
|
76
|
-
snooze(time) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
json: { time },
|
|
83
|
-
});
|
|
84
|
-
this.requestUpdate();
|
|
65
|
+
async snooze(time) {
|
|
66
|
+
// time is in minutes, max 24 * 60 (1440)
|
|
67
|
+
await this.restClient.request({
|
|
68
|
+
url: this.chimeUrl('do_not_disturb'),
|
|
69
|
+
method: 'POST',
|
|
70
|
+
json: { time },
|
|
85
71
|
});
|
|
72
|
+
this.requestUpdate();
|
|
86
73
|
}
|
|
87
|
-
clearSnooze() {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
method: 'POST',
|
|
92
|
-
});
|
|
93
|
-
this.requestUpdate();
|
|
74
|
+
async clearSnooze() {
|
|
75
|
+
await this.restClient.request({
|
|
76
|
+
url: this.chimeUrl('do_not_disturb'),
|
|
77
|
+
method: 'POST',
|
|
94
78
|
});
|
|
79
|
+
this.requestUpdate();
|
|
95
80
|
}
|
|
96
|
-
updateChime(update) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
json: { chime: update },
|
|
102
|
-
});
|
|
103
|
-
this.requestUpdate();
|
|
104
|
-
// inform caller if this change requires a reboot
|
|
105
|
-
return Object.keys(update.settings || {}).some((key) => settingsWhichRequireReboot.includes(key));
|
|
81
|
+
async updateChime(update) {
|
|
82
|
+
await this.restClient.request({
|
|
83
|
+
url: this.chimeUrl(),
|
|
84
|
+
method: 'PUT',
|
|
85
|
+
json: { chime: update },
|
|
106
86
|
});
|
|
87
|
+
this.requestUpdate();
|
|
88
|
+
// inform caller if this change requires a reboot
|
|
89
|
+
return Object.keys(update.settings || {}).some((key) => settingsWhichRequireReboot.includes(key));
|
|
107
90
|
}
|
|
108
91
|
setVolume(volume) {
|
|
109
92
|
if (volume < 0 || volume > 11) {
|
|
@@ -115,13 +98,11 @@ class RingChime {
|
|
|
115
98
|
},
|
|
116
99
|
});
|
|
117
100
|
}
|
|
118
|
-
getHealth() {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
url: (0, rest_client_1.clientApi)(`chimes/${this.id}/health`),
|
|
122
|
-
});
|
|
123
|
-
return response.device_health;
|
|
101
|
+
async getHealth() {
|
|
102
|
+
const response = await this.restClient.request({
|
|
103
|
+
url: (0, rest_client_1.clientApi)(`chimes/${this.id}/health`),
|
|
124
104
|
});
|
|
105
|
+
return response.device_health;
|
|
125
106
|
}
|
|
126
107
|
}
|
|
127
108
|
exports.RingChime = RingChime;
|
package/lib/api/ring-device.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConnectionState, MediaStreamTrack, RTCIceCandidate, RtcpPacket, RtpPacket } from '
|
|
1
|
+
import { ConnectionState, MediaStreamTrack, RTCIceCandidate, RtcpPacket, RtpPacket } from 'werift';
|
|
2
2
|
import { Observable, ReplaySubject, Subject } from 'rxjs';
|
|
3
3
|
export interface BasicPeerConnection {
|
|
4
4
|
createOffer(): Promise<{
|
|
@@ -27,11 +27,11 @@ export declare class WeriftPeerConnection implements BasicPeerConnection {
|
|
|
27
27
|
onConnectionState: ReplaySubject<"failed" | "closed" | "connected" | "connecting" | "new" | "disconnected">;
|
|
28
28
|
returnAudioTrack: MediaStreamTrack;
|
|
29
29
|
constructor();
|
|
30
|
-
createOffer(): Promise<import("
|
|
30
|
+
createOffer(): Promise<import("werift").RTCSessionDescription>;
|
|
31
31
|
createAnswer(offer: {
|
|
32
32
|
type: 'offer';
|
|
33
33
|
sdp: string;
|
|
34
|
-
}): Promise<import("
|
|
34
|
+
}): Promise<import("werift").RTCSessionDescription>;
|
|
35
35
|
acceptAnswer(answer: {
|
|
36
36
|
type: 'answer';
|
|
37
37
|
sdp: string;
|
|
@@ -1,16 +1,7 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.WeriftPeerConnection = void 0;
|
|
13
|
-
const werift_1 = require("
|
|
4
|
+
const werift_1 = require("werift");
|
|
14
5
|
const rxjs_1 = require("rxjs");
|
|
15
6
|
const util_1 = require("../util");
|
|
16
7
|
const debug = false, ringIceServers = [
|
|
@@ -40,6 +31,12 @@ class WeriftPeerConnection {
|
|
|
40
31
|
clockRate: 48000,
|
|
41
32
|
channels: 2,
|
|
42
33
|
}),
|
|
34
|
+
new werift_1.RTCRtpCodecParameters({
|
|
35
|
+
mimeType: 'audio/PCMU',
|
|
36
|
+
clockRate: 8000,
|
|
37
|
+
channels: 1,
|
|
38
|
+
payloadType: 0,
|
|
39
|
+
}),
|
|
43
40
|
],
|
|
44
41
|
video: [
|
|
45
42
|
new werift_1.RTCRtpCodecParameters({
|
|
@@ -104,25 +101,19 @@ class WeriftPeerConnection {
|
|
|
104
101
|
this.onConnectionState.next(pc.connectionState);
|
|
105
102
|
});
|
|
106
103
|
}
|
|
107
|
-
createOffer() {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
return offer;
|
|
112
|
-
});
|
|
104
|
+
async createOffer() {
|
|
105
|
+
const offer = await this.pc.createOffer();
|
|
106
|
+
await this.pc.setLocalDescription(offer);
|
|
107
|
+
return offer;
|
|
113
108
|
}
|
|
114
|
-
createAnswer(offer) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
return answer;
|
|
120
|
-
});
|
|
109
|
+
async createAnswer(offer) {
|
|
110
|
+
await this.pc.setRemoteDescription(offer);
|
|
111
|
+
const answer = await this.pc.createAnswer();
|
|
112
|
+
await this.pc.setLocalDescription(answer);
|
|
113
|
+
return answer;
|
|
121
114
|
}
|
|
122
|
-
acceptAnswer(answer) {
|
|
123
|
-
|
|
124
|
-
yield this.pc.setRemoteDescription(answer);
|
|
125
|
-
});
|
|
115
|
+
async acceptAnswer(answer) {
|
|
116
|
+
await this.pc.setRemoteDescription(answer);
|
|
126
117
|
}
|
|
127
118
|
addIceCandidate(candidate) {
|
|
128
119
|
return this.pc.addIceCandidate(candidate);
|