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.
@@ -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.RingEdgeConnection = void 0;
13
4
  const ws_1 = require("ws");
@@ -56,8 +47,8 @@ class RingEdgeConnection extends streaming_connection_base_1.StreamingConnection
56
47
  return;
57
48
  }
58
49
  this.sendSessionMessage('ping');
59
- }), this.pc.onIceCandidate.subscribe((iceCandidate) => __awaiter(this, void 0, void 0, function* () {
60
- yield (0, rxjs_1.firstValueFrom)(this.onOfferSent);
50
+ }), this.pc.onIceCandidate.subscribe(async (iceCandidate) => {
51
+ await (0, rxjs_1.firstValueFrom)(this.onOfferSent);
61
52
  this.sendMessage({
62
53
  method: 'ice',
63
54
  body: {
@@ -76,69 +67,69 @@ class RingEdgeConnection extends streaming_connection_base_1.StreamingConnection
76
67
  mlineindex: 1,
77
68
  },
78
69
  });
79
- })));
70
+ }));
80
71
  }
81
- initiateCall() {
82
- return __awaiter(this, void 0, void 0, function* () {
83
- const { sdp } = yield this.pc.createOffer();
84
- this.sendMessage({
85
- method: 'live_view',
86
- body: {
87
- doorbot_id: this.camera.id,
88
- stream_options: { audio_enabled: true, video_enabled: true },
89
- sdp: sdp.replace('\na=group:BUNDLE 0 1', ''),
90
- },
91
- });
92
- this.onOfferSent.next();
72
+ async initiateCall() {
73
+ const { sdp } = await this.pc.createOffer();
74
+ this.sendMessage({
75
+ method: 'live_view',
76
+ body: {
77
+ doorbot_id: this.camera.id,
78
+ stream_options: { audio_enabled: true, video_enabled: true },
79
+ sdp: sdp.replace('\na=group:BUNDLE 0 1', ''),
80
+ },
93
81
  });
82
+ this.onOfferSent.next();
94
83
  }
95
- handleMessage(message) {
96
- return __awaiter(this, void 0, void 0, function* () {
97
- if (message.body.doorbot_id !== this.camera.id) {
98
- // ignore messages for other cameras
84
+ async handleMessage(message) {
85
+ if (message.body.doorbot_id !== this.camera.id) {
86
+ // ignore messages for other cameras
87
+ return;
88
+ }
89
+ if (['session_created', 'session_started'].includes(message.method) &&
90
+ 'session_id' in message.body &&
91
+ !this.sessionId) {
92
+ this.sessionId = message.body.session_id;
93
+ this.onSessionId.next(this.sessionId);
94
+ }
95
+ if (message.body.session_id && message.body.session_id !== this.sessionId) {
96
+ // ignore messages for other sessions
97
+ return;
98
+ }
99
+ switch (message.method) {
100
+ case 'session_created':
101
+ case 'session_started':
102
+ // session already stored above
99
103
  return;
100
- }
101
- if (['session_created', 'session_started'].includes(message.method) &&
102
- 'session_id' in message.body &&
103
- !this.sessionId) {
104
- this.sessionId = message.body.session_id;
105
- this.onSessionId.next(this.sessionId);
106
- }
107
- if (message.body.session_id && message.body.session_id !== this.sessionId) {
108
- // ignore messages for other sessions
104
+ case 'sdp':
105
+ await this.pc.acceptAnswer(message.body);
106
+ this.onCallAnswered.next(message.body.sdp);
109
107
  return;
110
- }
111
- switch (message.method) {
112
- case 'session_created':
113
- case 'session_started':
114
- // session already stored above
115
- return;
116
- case 'sdp':
117
- yield this.pc.acceptAnswer(message.body);
118
- this.onCallAnswered.next(message.body.sdp);
119
- return;
120
- case 'ice':
121
- yield this.pc.addIceCandidate({
122
- candidate: message.body.ice,
123
- sdpMLineIndex: message.body.mlineindex,
124
- });
125
- return;
126
- case 'pong':
127
- return;
128
- case 'close':
129
- (0, util_1.logError)('Video stream closed');
130
- (0, util_1.logError)(message.body);
131
- this.callEnded();
132
- return;
133
- }
134
- (0, util_1.logError)('UNKNOWN MESSAGE');
135
- (0, util_1.logError)(message);
136
- });
108
+ case 'ice':
109
+ await this.pc.addIceCandidate({
110
+ candidate: message.body.ice,
111
+ sdpMLineIndex: message.body.mlineindex,
112
+ });
113
+ return;
114
+ case 'pong':
115
+ return;
116
+ case 'close':
117
+ (0, util_1.logError)('Video stream closed');
118
+ (0, util_1.logError)(message.body);
119
+ this.callEnded();
120
+ return;
121
+ }
122
+ (0, util_1.logError)('UNKNOWN MESSAGE');
123
+ (0, util_1.logError)(message);
137
124
  }
138
125
  sendSessionMessage(method, body = {}) {
139
126
  const message = {
140
127
  method,
141
- body: Object.assign(Object.assign({}, body), { doorbot_id: this.camera.id, session_id: this.sessionId }),
128
+ body: {
129
+ ...body,
130
+ doorbot_id: this.camera.id,
131
+ session_id: this.sessionId,
132
+ },
142
133
  };
143
134
  if (this.sessionId) {
144
135
  // Send immediately if we already have a session id
@@ -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.SimpleWebRtcSession = void 0;
13
4
  const util_1 = require("../util");
@@ -20,43 +11,37 @@ class SimpleWebRtcSession {
20
11
  this.restClient = restClient;
21
12
  this.sessionId = (0, util_1.generateUuid)();
22
13
  }
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;
14
+ async start(sdp) {
15
+ const response = await this.restClient.request({
16
+ method: 'POST',
17
+ url: liveViewUrl('start'),
18
+ json: {
19
+ session_id: this.sessionId,
20
+ device_id: this.camera.id,
21
+ sdp,
22
+ protocol: 'webrtc',
23
+ },
36
24
  });
25
+ return response.sdp;
37
26
  }
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;
27
+ async end() {
28
+ const resp = await this.restClient.request({
29
+ method: 'POST',
30
+ url: liveViewUrl('end'),
31
+ json: {
32
+ session_id: this.sessionId,
33
+ },
48
34
  });
35
+ return resp;
49
36
  }
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
- });
37
+ async activateCameraSpeaker() {
38
+ await this.restClient.request({
39
+ method: 'PATCH',
40
+ url: liveViewUrl('options'),
41
+ json: {
42
+ session_id: this.sessionId,
43
+ actions: ['turn_off_stealth_mode'],
44
+ },
60
45
  });
61
46
  }
62
47
  }
@@ -1,7 +1,7 @@
1
1
  import { BasicPeerConnection } from './peer-connection';
2
2
  import { Subscribed } from '../subscribed';
3
3
  import { WebSocket } from 'ws';
4
- import { RtpPacket } from '@koush/werift';
4
+ import { RtpPacket } from 'werift';
5
5
  import { ReplaySubject, Subject } from 'rxjs';
6
6
  export interface StreamingConnectionOptions {
7
7
  createPeerConnection?: () => BasicPeerConnection;
@@ -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.StreamingConnectionBase = void 0;
13
4
  const peer_connection_1 = require("./peer-connection");
@@ -59,23 +50,19 @@ class StreamingConnectionBase extends subscribed_1.Subscribed {
59
50
  }
60
51
  }));
61
52
  }
62
- activate() {
63
- return __awaiter(this, void 0, void 0, function* () {
64
- if (this.activated) {
65
- return;
66
- }
67
- this.activated = true;
68
- yield (0, rxjs_1.firstValueFrom)(this.pc.onConnectionState.pipe((0, operators_1.filter)((state) => state === 'connected')));
69
- (0, util_1.logInfo)('Activating Session');
70
- this.sendSessionMessage('activate_session');
71
- });
53
+ async activate() {
54
+ if (this.activated) {
55
+ return;
56
+ }
57
+ this.activated = true;
58
+ await (0, rxjs_1.firstValueFrom)(this.pc.onConnectionState.pipe((0, operators_1.filter)((state) => state === 'connected')));
59
+ (0, util_1.logInfo)('Activating Session');
60
+ this.sendSessionMessage('activate_session');
72
61
  }
73
- activateCameraSpeaker() {
74
- return __awaiter(this, void 0, void 0, function* () {
75
- yield (0, rxjs_1.firstValueFrom)(this.onCallAnswered);
76
- this.sendSessionMessage('camera_options', {
77
- stealth_mode: false,
78
- });
62
+ async activateCameraSpeaker() {
63
+ await (0, rxjs_1.firstValueFrom)(this.onCallAnswered);
64
+ this.sendSessionMessage('camera_options', {
65
+ stealth_mode: false,
79
66
  });
80
67
  }
81
68
  sendMessage(message) {
@@ -1,4 +1,4 @@
1
- import { RtpPacket } from '@koush/werift';
1
+ import { RtpPacket } from 'werift';
2
2
  import { ReplaySubject, Subject } from 'rxjs';
3
3
  import { RingEdgeConnection } from './ring-edge-connection';
4
4
  import { WebrtcConnection } from './webrtc-connection';
@@ -15,6 +15,7 @@ export declare class StreamingSession extends Subscribed {
15
15
  private readonly camera;
16
16
  private connection;
17
17
  readonly onCallEnded: ReplaySubject<void>;
18
+ private readonly onUsingOpus;
18
19
  readonly onVideoRtp: Subject<RtpPacket>;
19
20
  readonly onAudioRtp: Subject<RtpPacket>;
20
21
  private readonly audioSplitter;
@@ -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.StreamingSession = void 0;
13
4
  const camera_utils_1 = require("@homebridge/camera-utils");
@@ -30,6 +21,7 @@ class StreamingSession extends subscribed_1.Subscribed {
30
21
  this.camera = camera;
31
22
  this.connection = connection;
32
23
  this.onCallEnded = new rxjs_1.ReplaySubject(1);
24
+ this.onUsingOpus = new rxjs_1.ReplaySubject(1);
33
25
  this.onVideoRtp = new rxjs_1.Subject();
34
26
  this.onAudioRtp = new rxjs_1.Subject();
35
27
  this.audioSplitter = new camera_utils_1.RtpSplitter();
@@ -39,80 +31,74 @@ class StreamingSession extends subscribed_1.Subscribed {
39
31
  this.bindToConnection(connection);
40
32
  }
41
33
  bindToConnection(connection) {
42
- this.addSubscriptions(connection.onAudioRtp.subscribe(this.onAudioRtp), connection.onVideoRtp.subscribe(this.onVideoRtp));
34
+ this.addSubscriptions(connection.onAudioRtp.subscribe(this.onAudioRtp), connection.onVideoRtp.subscribe(this.onVideoRtp), connection.onCallAnswered.subscribe((sdp) => {
35
+ this.onUsingOpus.next(sdp.toLocaleLowerCase().includes(' opus/'));
36
+ }));
43
37
  }
44
- activate() {
45
- return __awaiter(this, void 0, void 0, function* () {
46
- if (this.activated) {
47
- return;
48
- }
49
- this.activated = true;
50
- yield this.connection.activate();
51
- });
38
+ async activate() {
39
+ if (this.activated) {
40
+ return;
41
+ }
42
+ this.activated = true;
43
+ await this.connection.activate();
52
44
  }
53
- activateCameraSpeaker() {
54
- return __awaiter(this, void 0, void 0, function* () {
55
- if (this.cameraSpeakerActivated) {
56
- return;
57
- }
58
- this.cameraSpeakerActivated = true;
59
- yield this.connection.activateCameraSpeaker();
60
- });
45
+ async activateCameraSpeaker() {
46
+ if (this.cameraSpeakerActivated) {
47
+ return;
48
+ }
49
+ this.cameraSpeakerActivated = true;
50
+ await this.connection.activateCameraSpeaker();
61
51
  }
62
- reservePort(bufferPorts = 0) {
63
- return __awaiter(this, void 0, void 0, function* () {
64
- const ports = yield (0, camera_utils_1.reservePorts)({ count: bufferPorts + 1 });
65
- return ports[0];
66
- });
52
+ async reservePort(bufferPorts = 0) {
53
+ const ports = await (0, camera_utils_1.reservePorts)({ count: bufferPorts + 1 });
54
+ return ports[0];
67
55
  }
68
- startTranscoding(ffmpegOptions) {
69
- return __awaiter(this, void 0, void 0, function* () {
70
- const videoPort = yield this.reservePort(1), audioPort = yield this.reservePort(1), transcodeVideoStream = ffmpegOptions.video !== false, ffmpegInputArguments = [
71
- '-hide_banner',
72
- '-protocol_whitelist',
73
- 'pipe,udp,rtp,file,crypto',
74
- '-acodec',
75
- 'libopus',
76
- '-f',
77
- 'sdp',
78
- ...(ffmpegOptions.input || []),
79
- '-i',
80
- 'pipe:',
81
- ], ringSdp = yield (0, rxjs_1.firstValueFrom)(this.connection.onCallAnswered), inputSdp = getCleanSdp(ringSdp, transcodeVideoStream)
82
- .replace(/m=audio \d+/, `m=audio ${audioPort}`)
83
- .replace(/m=video \d+/, `m=video ${videoPort}`), ff = new camera_utils_1.FfmpegProcess({
84
- ffmpegArgs: ffmpegInputArguments.concat(...(ffmpegOptions.audio || ['-acodec', 'aac']), ...(transcodeVideoStream
85
- ? ffmpegOptions.video || ['-vcodec', 'copy']
86
- : []), ...(ffmpegOptions.output || [])),
87
- ffmpegPath: (0, ffmpeg_1.getFfmpegPath)(),
88
- exitCallback: () => this.callEnded(),
89
- logLabel: `From Ring (${this.camera.name})`,
90
- logger: {
91
- error: util_1.logError,
92
- info: util_1.logDebug,
93
- },
56
+ async startTranscoding(ffmpegOptions) {
57
+ const videoPort = await this.reservePort(1), audioPort = await this.reservePort(1), transcodeVideoStream = ffmpegOptions.video !== false, ringSdp = await (0, rxjs_1.firstValueFrom)(this.connection.onCallAnswered), usingOpus = await (0, rxjs_1.firstValueFrom)(this.onUsingOpus), ffmpegInputArguments = [
58
+ '-hide_banner',
59
+ '-protocol_whitelist',
60
+ 'pipe,udp,rtp,file,crypto',
61
+ // Ring will answer with either opus or pcmu
62
+ ...(usingOpus ? ['-acodec', 'libopus'] : []),
63
+ '-f',
64
+ 'sdp',
65
+ ...(ffmpegOptions.input || []),
66
+ '-i',
67
+ 'pipe:',
68
+ ], inputSdp = getCleanSdp(ringSdp, transcodeVideoStream)
69
+ .replace(/m=audio \d+/, `m=audio ${audioPort}`)
70
+ .replace(/m=video \d+/, `m=video ${videoPort}`), ff = new camera_utils_1.FfmpegProcess({
71
+ ffmpegArgs: ffmpegInputArguments.concat(...(ffmpegOptions.audio || ['-acodec', 'aac']), ...(transcodeVideoStream
72
+ ? ffmpegOptions.video || ['-vcodec', 'copy']
73
+ : []), ...(ffmpegOptions.output || [])),
74
+ ffmpegPath: (0, ffmpeg_1.getFfmpegPath)(),
75
+ exitCallback: () => this.callEnded(),
76
+ logLabel: `From Ring (${this.camera.name})`,
77
+ logger: {
78
+ error: util_1.logError,
79
+ info: util_1.logDebug,
80
+ },
81
+ });
82
+ this.addSubscriptions(this.onAudioRtp
83
+ .pipe((0, operators_1.concatMap)((rtp) => {
84
+ return this.audioSplitter.send(rtp.serialize(), {
85
+ port: audioPort,
94
86
  });
95
- this.addSubscriptions(this.onAudioRtp
87
+ }))
88
+ .subscribe());
89
+ if (transcodeVideoStream) {
90
+ this.addSubscriptions(this.onVideoRtp
96
91
  .pipe((0, operators_1.concatMap)((rtp) => {
97
- return this.audioSplitter.send(rtp.serialize(), {
98
- port: audioPort,
92
+ return this.videoSplitter.send(rtp.serialize(), {
93
+ port: videoPort,
99
94
  });
100
95
  }))
101
96
  .subscribe());
102
- if (transcodeVideoStream) {
103
- this.addSubscriptions(this.onVideoRtp
104
- .pipe((0, operators_1.concatMap)((rtp) => {
105
- return this.videoSplitter.send(rtp.serialize(), {
106
- port: videoPort,
107
- });
108
- }))
109
- .subscribe());
110
- }
111
- this.onCallEnded.subscribe(() => ff.stop());
112
- ff.writeStdin(inputSdp);
113
- // Activate the stream now that ffmpeg is ready to receive
114
- yield this.activate();
115
- });
97
+ }
98
+ this.onCallEnded.subscribe(() => ff.stop());
99
+ ff.writeStdin(inputSdp);
100
+ // Activate the stream now that ffmpeg is ready to receive
101
+ await this.activate();
116
102
  }
117
103
  callEnded() {
118
104
  this.unsubscribe();
@@ -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.WebrtcConnection = void 0;
13
4
  const ws_1 = require("ws");
@@ -32,29 +23,30 @@ class WebrtcConnection extends streaming_connection_base_1.StreamingConnectionBa
32
23
  (0, util_1.logDebug)(`WebSocket connected for ${camera.name}`);
33
24
  }));
34
25
  }
35
- handleMessage(message) {
36
- return __awaiter(this, void 0, void 0, function* () {
37
- switch (message.method) {
38
- case 'sdp':
39
- const answer = yield this.pc.createAnswer(message);
40
- this.sendSessionMessage('sdp', answer);
41
- this.onCallAnswered.next(message.sdp);
42
- this.sendSessionMessage('stream_options', {
43
- audio_enabled: true,
44
- video_enabled: true,
45
- });
46
- return;
47
- case 'ice':
48
- yield this.pc.addIceCandidate({
49
- candidate: message.ice,
50
- sdpMLineIndex: message.mlineindex,
51
- });
52
- return;
53
- }
54
- });
26
+ async handleMessage(message) {
27
+ switch (message.method) {
28
+ case 'sdp':
29
+ const answer = await this.pc.createAnswer(message);
30
+ this.sendSessionMessage('sdp', answer);
31
+ this.onCallAnswered.next(message.sdp);
32
+ this.sendSessionMessage('stream_options', {
33
+ audio_enabled: true,
34
+ video_enabled: true,
35
+ });
36
+ return;
37
+ case 'ice':
38
+ await this.pc.addIceCandidate({
39
+ candidate: message.ice,
40
+ sdpMLineIndex: message.mlineindex,
41
+ });
42
+ return;
43
+ }
55
44
  }
56
45
  sendSessionMessage(method, body = {}) {
57
- this.sendMessage(Object.assign(Object.assign({}, body), { method }));
46
+ this.sendMessage({
47
+ ...body,
48
+ method,
49
+ });
58
50
  }
59
51
  }
60
52
  exports.WebrtcConnection = WebrtcConnection;
package/lib/api/util.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
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
@@ -63,39 +54,35 @@ function generateUuid(seed) {
63
54
  return (0, uuid_1.v4)();
64
55
  }
65
56
  exports.generateUuid = generateUuid;
66
- function getHardwareId(systemId) {
67
- return __awaiter(this, void 0, void 0, function* () {
68
- if (systemId) {
69
- return generateUuid(systemId);
70
- }
71
- const timeoutValue = '-1', { os: id } = yield Promise.race([
72
- (0, systeminformation_1.uuid)(),
73
- delay(5000).then(() => ({ os: timeoutValue })),
74
- ]);
75
- if (id === timeoutValue) {
76
- logError('Request for system uuid timed out. Falling back to random session id');
77
- return (0, uuid_1.v4)();
78
- }
79
- if (id === '-') {
80
- // default value set by systeminformation if it can't find a real value
81
- logError('Unable to get system uuid. Falling back to random session id');
82
- return (0, uuid_1.v4)();
83
- }
84
- return generateUuid(id);
85
- });
57
+ async function getHardwareId(systemId) {
58
+ if (systemId) {
59
+ return generateUuid(systemId);
60
+ }
61
+ const timeoutValue = '-1', { os: id } = await Promise.race([
62
+ (0, systeminformation_1.uuid)(),
63
+ delay(5000).then(() => ({ os: timeoutValue })),
64
+ ]);
65
+ if (id === timeoutValue) {
66
+ logError('Request for system uuid timed out. Falling back to random session id');
67
+ return (0, uuid_1.v4)();
68
+ }
69
+ if (id === '-') {
70
+ // default value set by systeminformation if it can't find a real value
71
+ logError('Unable to get system uuid. Falling back to random session id');
72
+ return (0, uuid_1.v4)();
73
+ }
74
+ return generateUuid(id);
86
75
  }
87
76
  exports.getHardwareId = getHardwareId;
88
- function requestInput(question) {
89
- return __awaiter(this, void 0, void 0, function* () {
90
- const lineReader = (0, readline_1.createInterface)({
91
- input: process.stdin,
92
- output: process.stdout,
93
- }), answer = yield new Promise((resolve) => {
94
- lineReader.question(question, resolve);
95
- });
96
- lineReader.close();
97
- return answer.trim();
77
+ async function requestInput(question) {
78
+ const lineReader = (0, readline_1.createInterface)({
79
+ input: process.stdin,
80
+ output: process.stdout,
81
+ }), answer = await new Promise((resolve) => {
82
+ lineReader.question(question, resolve);
98
83
  });
84
+ lineReader.close();
85
+ return answer.trim();
99
86
  }
100
87
  exports.requestInput = requestInput;
101
88
  function stringify(data) {