camstreamerlib 1.7.6 → 1.8.1
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/CamOverlayAPI.d.ts +9 -4
- package/CamOverlayAPI.js +65 -67
- package/CamStreamerAPI.d.ts +4 -1
- package/CamStreamerAPI.js +11 -6
- package/CamSwitcherAPI.d.ts +4 -0
- package/CamSwitcherAPI.js +12 -6
- package/CameraVapix.d.ts +4 -1
- package/CameraVapix.js +11 -6
- package/HTTPRequest.d.ts +1 -0
- package/HTTPRequest.js +1 -1
- package/README.md +1 -1
- package/package.json +1 -1
package/CamOverlayAPI.d.ts
CHANGED
|
@@ -3,12 +3,14 @@
|
|
|
3
3
|
import * as EventEmitter from 'events';
|
|
4
4
|
export declare type CamOverlayOptions = {
|
|
5
5
|
protocol?: string;
|
|
6
|
+
tls?: boolean;
|
|
7
|
+
tlsInsecure?: boolean;
|
|
6
8
|
ip?: string;
|
|
7
9
|
port?: number;
|
|
8
10
|
auth?: string;
|
|
9
11
|
serviceName?: string;
|
|
10
12
|
serviceID?: number;
|
|
11
|
-
camera?: number;
|
|
13
|
+
camera?: number | number[];
|
|
12
14
|
};
|
|
13
15
|
export declare type Field = {
|
|
14
16
|
field_name: string;
|
|
@@ -42,19 +44,20 @@ export declare type Service = {
|
|
|
42
44
|
schedule: string;
|
|
43
45
|
name: string;
|
|
44
46
|
identifier: string;
|
|
45
|
-
|
|
47
|
+
cameraList: number[];
|
|
46
48
|
};
|
|
47
49
|
export declare type ServiceList = {
|
|
48
50
|
services: Service[];
|
|
49
51
|
};
|
|
50
52
|
export declare class CamOverlayAPI extends EventEmitter {
|
|
51
|
-
private
|
|
53
|
+
private tls;
|
|
54
|
+
private tlsInsecure;
|
|
52
55
|
private ip;
|
|
53
56
|
private port;
|
|
54
57
|
private auth;
|
|
55
58
|
private serviceName;
|
|
56
59
|
private serviceID;
|
|
57
|
-
private
|
|
60
|
+
private cameraList;
|
|
58
61
|
private callId;
|
|
59
62
|
private sendMessages;
|
|
60
63
|
private ws;
|
|
@@ -82,4 +85,6 @@ export declare class CamOverlayAPI extends EventEmitter {
|
|
|
82
85
|
updateInfoticker(text: string): Promise<void>;
|
|
83
86
|
setEnabled(enabled: boolean): Promise<void>;
|
|
84
87
|
isEnabled(): Promise<boolean>;
|
|
88
|
+
private getBaseVapixConnectionParams;
|
|
89
|
+
private compareCameraList;
|
|
85
90
|
}
|
package/CamOverlayAPI.js
CHANGED
|
@@ -19,13 +19,23 @@ class CamOverlayAPI extends EventEmitter {
|
|
|
19
19
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
20
20
|
super();
|
|
21
21
|
this.ws = null;
|
|
22
|
-
this.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
this.
|
|
27
|
-
this.
|
|
28
|
-
this.
|
|
22
|
+
this.tls = (_a = options === null || options === void 0 ? void 0 : options.tls) !== null && _a !== void 0 ? _a : false;
|
|
23
|
+
if ((options === null || options === void 0 ? void 0 : options.tls) === undefined && (options === null || options === void 0 ? void 0 : options.protocol) !== undefined) {
|
|
24
|
+
this.tls = options.protocol === 'wss';
|
|
25
|
+
}
|
|
26
|
+
this.tlsInsecure = (_b = options === null || options === void 0 ? void 0 : options.tlsInsecure) !== null && _b !== void 0 ? _b : false;
|
|
27
|
+
this.ip = (_c = options === null || options === void 0 ? void 0 : options.ip) !== null && _c !== void 0 ? _c : '127.0.0.1';
|
|
28
|
+
this.port = (_d = options === null || options === void 0 ? void 0 : options.port) !== null && _d !== void 0 ? _d : (this.tls ? 443 : 80);
|
|
29
|
+
this.auth = (_e = options === null || options === void 0 ? void 0 : options.auth) !== null && _e !== void 0 ? _e : '';
|
|
30
|
+
this.serviceName = (_f = options === null || options === void 0 ? void 0 : options.serviceName) !== null && _f !== void 0 ? _f : '';
|
|
31
|
+
this.serviceID = (_g = options === null || options === void 0 ? void 0 : options.serviceID) !== null && _g !== void 0 ? _g : -1;
|
|
32
|
+
this.cameraList = [0];
|
|
33
|
+
if (Array.isArray(options === null || options === void 0 ? void 0 : options.camera)) {
|
|
34
|
+
this.cameraList = options.camera;
|
|
35
|
+
}
|
|
36
|
+
else if (typeof (options === null || options === void 0 ? void 0 : options.camera) === 'number') {
|
|
37
|
+
this.cameraList = [options.camera];
|
|
38
|
+
}
|
|
29
39
|
this.callId = 0;
|
|
30
40
|
this.sendMessages = {};
|
|
31
41
|
EventEmitter.call(this);
|
|
@@ -33,7 +43,7 @@ class CamOverlayAPI extends EventEmitter {
|
|
|
33
43
|
connect() {
|
|
34
44
|
return __awaiter(this, void 0, void 0, function* () {
|
|
35
45
|
try {
|
|
36
|
-
if (this.serviceID
|
|
46
|
+
if (this.serviceID === -1) {
|
|
37
47
|
this.serviceID = yield this.createService();
|
|
38
48
|
}
|
|
39
49
|
yield this.openWebsocket();
|
|
@@ -47,12 +57,9 @@ class CamOverlayAPI extends EventEmitter {
|
|
|
47
57
|
createService() {
|
|
48
58
|
var _a;
|
|
49
59
|
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
-
const options =
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
path: '/local/camoverlay/api/services.cgi?action=get',
|
|
54
|
-
auth: this.auth,
|
|
55
|
-
};
|
|
60
|
+
const options = this.getBaseVapixConnectionParams();
|
|
61
|
+
options.method = 'GET';
|
|
62
|
+
options.path = '/local/camoverlay/api/services.cgi?action=get';
|
|
56
63
|
const response = (yield (0, HTTPRequest_1.httpRequest)(options));
|
|
57
64
|
let servicesJson;
|
|
58
65
|
try {
|
|
@@ -69,14 +76,14 @@ class CamOverlayAPI extends EventEmitter {
|
|
|
69
76
|
if (s.id > maxID) {
|
|
70
77
|
maxID = s.id;
|
|
71
78
|
}
|
|
72
|
-
if (s.identifier
|
|
79
|
+
if (s.identifier === this.serviceName && s.name === 'scripter') {
|
|
73
80
|
service = s;
|
|
74
81
|
break;
|
|
75
82
|
}
|
|
76
83
|
}
|
|
77
|
-
if (service
|
|
78
|
-
if (service.
|
|
79
|
-
service.
|
|
84
|
+
if (service !== null) {
|
|
85
|
+
if (service.cameraList === undefined || !this.compareCameraList(service.cameraList)) {
|
|
86
|
+
service.cameraList = this.cameraList;
|
|
80
87
|
yield this.updateServices(servicesJson);
|
|
81
88
|
return service.id;
|
|
82
89
|
}
|
|
@@ -92,7 +99,7 @@ class CamOverlayAPI extends EventEmitter {
|
|
|
92
99
|
schedule: '',
|
|
93
100
|
name: 'scripter',
|
|
94
101
|
identifier: this.serviceName,
|
|
95
|
-
|
|
102
|
+
cameraList: this.cameraList,
|
|
96
103
|
};
|
|
97
104
|
servicesJson.services.push(service);
|
|
98
105
|
yield this.updateServices(servicesJson);
|
|
@@ -102,25 +109,23 @@ class CamOverlayAPI extends EventEmitter {
|
|
|
102
109
|
}
|
|
103
110
|
updateServices(servicesJson) {
|
|
104
111
|
return __awaiter(this, void 0, void 0, function* () {
|
|
105
|
-
const options =
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
port: this.port,
|
|
109
|
-
path: '/local/camoverlay/api/services.cgi?action=set',
|
|
110
|
-
auth: this.auth,
|
|
111
|
-
};
|
|
112
|
+
const options = this.getBaseVapixConnectionParams();
|
|
113
|
+
options.method = 'POST';
|
|
114
|
+
options.path = '/local/camoverlay/api/services.cgi?action=set';
|
|
112
115
|
yield (0, HTTPRequest_1.httpRequest)(options, JSON.stringify(servicesJson));
|
|
113
116
|
});
|
|
114
117
|
}
|
|
115
118
|
openWebsocket(digestHeader) {
|
|
116
119
|
let promise = new Promise((resolve, reject) => {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
+
const userPass = this.auth.split(':');
|
|
121
|
+
const protocol = this.tls ? 'wss' : 'ws';
|
|
122
|
+
const addr = `${protocol}://${this.ip}:${this.port}/local/camoverlay/ws`;
|
|
123
|
+
const options = {
|
|
120
124
|
auth: this.auth,
|
|
125
|
+
rejectUnauthorized: !this.tlsInsecure,
|
|
121
126
|
headers: {},
|
|
122
127
|
};
|
|
123
|
-
if (digestHeader
|
|
128
|
+
if (digestHeader !== undefined) {
|
|
124
129
|
options.headers['Authorization'] = Digest_1.Digest.getAuthHeader(userPass[0], userPass[1], 'GET', '/local/camoverlay/ws', digestHeader);
|
|
125
130
|
}
|
|
126
131
|
this.ws = new WebSocket(addr, 'cairo-api', options);
|
|
@@ -143,7 +148,7 @@ class CamOverlayAPI extends EventEmitter {
|
|
|
143
148
|
}
|
|
144
149
|
});
|
|
145
150
|
this.ws.on('unexpected-response', (req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
146
|
-
if (res.statusCode
|
|
151
|
+
if (res.statusCode === 401 && res.headers['www-authenticate'] !== undefined)
|
|
147
152
|
this.openWebsocket(res.headers['www-authenticate']).then(resolve, reject);
|
|
148
153
|
else {
|
|
149
154
|
reject('Error: status code: ' + res.statusCode + ', ' + res.data);
|
|
@@ -221,14 +226,14 @@ class CamOverlayAPI extends EventEmitter {
|
|
|
221
226
|
for (let field of fields) {
|
|
222
227
|
const name = field.field_name;
|
|
223
228
|
field_specs += `&${name}=${field.text}`;
|
|
224
|
-
if (field.color
|
|
229
|
+
if (field.color !== undefined) {
|
|
225
230
|
field_specs += `&${name}_color=${field.color}`;
|
|
226
231
|
}
|
|
227
232
|
}
|
|
228
233
|
return this.promiseCGUpdate('update_text', field_specs);
|
|
229
234
|
}
|
|
230
235
|
formCoordinates(coordinates, x, y) {
|
|
231
|
-
return coordinates
|
|
236
|
+
return coordinates !== '' ? `&coord_system=${coordinates}&pos_x=${x}&pos_y=${y}` : '';
|
|
232
237
|
}
|
|
233
238
|
updateCGImage(path, coordinates = '', x = 0, y = 0) {
|
|
234
239
|
const coord = this.formCoordinates(coordinates, x, y);
|
|
@@ -241,62 +246,55 @@ class CamOverlayAPI extends EventEmitter {
|
|
|
241
246
|
}
|
|
242
247
|
promiseCGUpdate(action, params) {
|
|
243
248
|
return __awaiter(this, void 0, void 0, function* () {
|
|
244
|
-
const
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
host: this.ip,
|
|
248
|
-
port: this.port,
|
|
249
|
-
path: path,
|
|
250
|
-
auth: this.auth,
|
|
251
|
-
};
|
|
249
|
+
const options = this.getBaseVapixConnectionParams();
|
|
250
|
+
options.method = 'POST';
|
|
251
|
+
options.path = encodeURI(`/local/camoverlay/api/customGraphics.cgi?action=${action}&service_id=${this.serviceID}${params}`);
|
|
252
252
|
yield (0, HTTPRequest_1.httpRequest)(options, '');
|
|
253
253
|
});
|
|
254
254
|
}
|
|
255
255
|
updateInfoticker(text) {
|
|
256
256
|
return __awaiter(this, void 0, void 0, function* () {
|
|
257
|
-
const
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
host: this.ip,
|
|
261
|
-
port: this.port,
|
|
262
|
-
path: path,
|
|
263
|
-
auth: this.auth,
|
|
264
|
-
};
|
|
257
|
+
const options = this.getBaseVapixConnectionParams();
|
|
258
|
+
options.method = 'GET';
|
|
259
|
+
options.path = `/local/camoverlay/api/infoticker.cgi?service_id=${this.serviceID}&text=${text}`;
|
|
265
260
|
yield (0, HTTPRequest_1.httpRequest)(options, '');
|
|
266
261
|
});
|
|
267
262
|
}
|
|
268
263
|
setEnabled(enabled) {
|
|
269
264
|
return __awaiter(this, void 0, void 0, function* () {
|
|
270
|
-
const
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
method: 'POST',
|
|
274
|
-
host: this.ip,
|
|
275
|
-
port: this.port,
|
|
276
|
-
path: path,
|
|
277
|
-
auth: this.auth,
|
|
278
|
-
};
|
|
265
|
+
const options = this.getBaseVapixConnectionParams();
|
|
266
|
+
options.method = 'POST';
|
|
267
|
+
options.path = encodeURI(`/local/camoverlay/api/enabled.cgi?id_${this.serviceID}=${enabled ? 1 : 0}`);
|
|
279
268
|
yield (0, HTTPRequest_1.httpRequest)(options, '');
|
|
280
269
|
});
|
|
281
270
|
}
|
|
282
271
|
isEnabled() {
|
|
283
272
|
return __awaiter(this, void 0, void 0, function* () {
|
|
284
|
-
const options =
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
port: this.port,
|
|
288
|
-
path: '/local/camoverlay/api/services.cgi?action=get',
|
|
289
|
-
auth: this.auth,
|
|
290
|
-
};
|
|
273
|
+
const options = this.getBaseVapixConnectionParams();
|
|
274
|
+
options.method = 'GET';
|
|
275
|
+
options.path = '/local/camoverlay/api/services.cgi?action=get';
|
|
291
276
|
const response = (yield (0, HTTPRequest_1.httpRequest)(options, ''));
|
|
292
277
|
const data = JSON.parse(response);
|
|
293
278
|
for (let service of data.services) {
|
|
294
|
-
if (service.id
|
|
295
|
-
return service.enabled
|
|
279
|
+
if (service.id === this.serviceID) {
|
|
280
|
+
return service.enabled === 1;
|
|
296
281
|
}
|
|
297
282
|
}
|
|
298
283
|
throw new Error('Service not found.');
|
|
299
284
|
});
|
|
300
285
|
}
|
|
286
|
+
getBaseVapixConnectionParams() {
|
|
287
|
+
return {
|
|
288
|
+
protocol: this.tls ? 'https:' : 'http:',
|
|
289
|
+
host: this.ip,
|
|
290
|
+
port: this.port,
|
|
291
|
+
auth: this.auth,
|
|
292
|
+
rejectUnauthorized: !this.tlsInsecure,
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
compareCameraList(cameraList) {
|
|
296
|
+
return (this.cameraList.length === cameraList.length &&
|
|
297
|
+
this.cameraList.every((element, index) => element === cameraList[index]));
|
|
298
|
+
}
|
|
301
299
|
}
|
|
302
300
|
exports.CamOverlayAPI = CamOverlayAPI;
|
package/CamStreamerAPI.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
export declare type CamStreamerAPIOptions = {
|
|
2
2
|
protocol?: string;
|
|
3
|
+
tls?: boolean;
|
|
4
|
+
tlsInsecure?: boolean;
|
|
3
5
|
ip?: string;
|
|
4
6
|
port?: number;
|
|
5
7
|
auth?: string;
|
|
6
8
|
};
|
|
7
9
|
export declare class CamStreamerAPI {
|
|
8
|
-
private
|
|
10
|
+
private tls;
|
|
11
|
+
private tlsInsecure;
|
|
9
12
|
private ip;
|
|
10
13
|
private port;
|
|
11
14
|
private auth;
|
package/CamStreamerAPI.js
CHANGED
|
@@ -13,11 +13,15 @@ exports.CamStreamerAPI = void 0;
|
|
|
13
13
|
const HTTPRequest_1 = require("./HTTPRequest");
|
|
14
14
|
class CamStreamerAPI {
|
|
15
15
|
constructor(options) {
|
|
16
|
-
var _a, _b, _c, _d;
|
|
17
|
-
this.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
var _a, _b, _c, _d, _e;
|
|
17
|
+
this.tls = (_a = options === null || options === void 0 ? void 0 : options.tls) !== null && _a !== void 0 ? _a : false;
|
|
18
|
+
if ((options === null || options === void 0 ? void 0 : options.tls) === undefined && (options === null || options === void 0 ? void 0 : options.protocol) !== undefined) {
|
|
19
|
+
this.tls = options.protocol === 'https';
|
|
20
|
+
}
|
|
21
|
+
this.tlsInsecure = (_b = options === null || options === void 0 ? void 0 : options.tlsInsecure) !== null && _b !== void 0 ? _b : false;
|
|
22
|
+
this.ip = (_c = options === null || options === void 0 ? void 0 : options.ip) !== null && _c !== void 0 ? _c : '127.0.0.1';
|
|
23
|
+
this.port = (_d = options === null || options === void 0 ? void 0 : options.port) !== null && _d !== void 0 ? _d : (this.tls ? 443 : 80);
|
|
24
|
+
this.auth = (_e = options === null || options === void 0 ? void 0 : options.auth) !== null && _e !== void 0 ? _e : '';
|
|
21
25
|
}
|
|
22
26
|
getStreamList() {
|
|
23
27
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -52,10 +56,11 @@ class CamStreamerAPI {
|
|
|
52
56
|
}
|
|
53
57
|
getBaseConnectionParams() {
|
|
54
58
|
return {
|
|
55
|
-
protocol: this.
|
|
59
|
+
protocol: this.tls ? 'https:' : 'http:',
|
|
56
60
|
host: this.ip,
|
|
57
61
|
port: this.port,
|
|
58
62
|
auth: this.auth,
|
|
63
|
+
rejectUnauthorized: !this.tlsInsecure,
|
|
59
64
|
};
|
|
60
65
|
}
|
|
61
66
|
}
|
package/CamSwitcherAPI.d.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import * as EventEmitter from 'events';
|
|
3
3
|
export declare type CamSwitcherAPIOptions = {
|
|
4
|
+
tls?: boolean;
|
|
5
|
+
tlsInsecure?: boolean;
|
|
4
6
|
ip?: string;
|
|
5
7
|
port?: number;
|
|
6
8
|
auth?: string;
|
|
7
9
|
};
|
|
8
10
|
export declare class CamSwitcherAPI extends EventEmitter {
|
|
11
|
+
private tls;
|
|
12
|
+
private tlsInsecure;
|
|
9
13
|
private ip;
|
|
10
14
|
private port;
|
|
11
15
|
private auth;
|
package/CamSwitcherAPI.js
CHANGED
|
@@ -15,18 +15,23 @@ const EventEmitter = require("events");
|
|
|
15
15
|
const HTTPRequest_1 = require("./HTTPRequest");
|
|
16
16
|
class CamSwitcherAPI extends EventEmitter {
|
|
17
17
|
constructor(options) {
|
|
18
|
-
var _a, _b, _c;
|
|
18
|
+
var _a, _b, _c, _d, _e;
|
|
19
19
|
super();
|
|
20
|
-
this.
|
|
21
|
-
this.
|
|
22
|
-
this.
|
|
20
|
+
this.tls = (_a = options === null || options === void 0 ? void 0 : options.tls) !== null && _a !== void 0 ? _a : false;
|
|
21
|
+
this.tlsInsecure = (_b = options === null || options === void 0 ? void 0 : options.tlsInsecure) !== null && _b !== void 0 ? _b : false;
|
|
22
|
+
this.ip = (_c = options === null || options === void 0 ? void 0 : options.ip) !== null && _c !== void 0 ? _c : '127.0.0.1';
|
|
23
|
+
this.port = (_d = options === null || options === void 0 ? void 0 : options.port) !== null && _d !== void 0 ? _d : 80;
|
|
24
|
+
this.auth = (_e = options === null || options === void 0 ? void 0 : options.auth) !== null && _e !== void 0 ? _e : '';
|
|
23
25
|
EventEmitter.call(this);
|
|
24
26
|
}
|
|
25
27
|
connect() {
|
|
26
28
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27
29
|
try {
|
|
28
30
|
const token = yield this.get('/local/camswitcher/ws_authorization.cgi');
|
|
29
|
-
|
|
31
|
+
const protocol = this.tls ? 'wss' : 'ws';
|
|
32
|
+
this.ws = new WebSocket(`${protocol}://${this.ip}:${this.port}/local/camswitcher/events`, 'events', {
|
|
33
|
+
rejectUnauthorized: !this.tlsInsecure,
|
|
34
|
+
});
|
|
30
35
|
this.pingTimer = null;
|
|
31
36
|
this.ws.on('open', () => {
|
|
32
37
|
this.ws.send(JSON.stringify({ authorization: token }));
|
|
@@ -109,10 +114,11 @@ class CamSwitcherAPI extends EventEmitter {
|
|
|
109
114
|
}
|
|
110
115
|
getBaseConnectionParams() {
|
|
111
116
|
return {
|
|
112
|
-
protocol: 'http:',
|
|
117
|
+
protocol: this.tls ? 'https:' : 'http:',
|
|
113
118
|
host: this.ip,
|
|
114
119
|
port: this.port,
|
|
115
120
|
auth: this.auth,
|
|
121
|
+
rejectUnauthorized: !this.tlsInsecure,
|
|
116
122
|
};
|
|
117
123
|
}
|
|
118
124
|
}
|
package/CameraVapix.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ import * as http from 'http';
|
|
|
4
4
|
import { EventEmitter2 as EventEmitter } from 'eventemitter2';
|
|
5
5
|
export declare type CameraVapixOptions = {
|
|
6
6
|
protocol?: string;
|
|
7
|
+
tls?: boolean;
|
|
8
|
+
tlsInsecure?: boolean;
|
|
7
9
|
ip?: string;
|
|
8
10
|
port?: number;
|
|
9
11
|
auth?: string;
|
|
@@ -46,7 +48,8 @@ export declare type GuardTour = {
|
|
|
46
48
|
}[];
|
|
47
49
|
};
|
|
48
50
|
export declare class CameraVapix extends EventEmitter {
|
|
49
|
-
private
|
|
51
|
+
private tls;
|
|
52
|
+
private tlsInsecure;
|
|
50
53
|
private ip;
|
|
51
54
|
private port;
|
|
52
55
|
private auth;
|
package/CameraVapix.js
CHANGED
|
@@ -19,14 +19,18 @@ const RtspClient_1 = require("./RtspClient");
|
|
|
19
19
|
const HTTPRequest_1 = require("./HTTPRequest");
|
|
20
20
|
class CameraVapix extends eventemitter2_1.EventEmitter2 {
|
|
21
21
|
constructor(options) {
|
|
22
|
-
var _a, _b, _c, _d;
|
|
22
|
+
var _a, _b, _c, _d, _e;
|
|
23
23
|
super();
|
|
24
24
|
this.rtsp = null;
|
|
25
25
|
this.ws = null;
|
|
26
|
-
this.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
this.tls = (_a = options === null || options === void 0 ? void 0 : options.tls) !== null && _a !== void 0 ? _a : false;
|
|
27
|
+
if ((options === null || options === void 0 ? void 0 : options.tls) === undefined && (options === null || options === void 0 ? void 0 : options.protocol) !== undefined) {
|
|
28
|
+
this.tls = options.protocol === 'https';
|
|
29
|
+
}
|
|
30
|
+
this.tlsInsecure = (_b = options === null || options === void 0 ? void 0 : options.tlsInsecure) !== null && _b !== void 0 ? _b : false;
|
|
31
|
+
this.ip = (_c = options === null || options === void 0 ? void 0 : options.ip) !== null && _c !== void 0 ? _c : '127.0.0.1';
|
|
32
|
+
this.port = (_d = options === null || options === void 0 ? void 0 : options.port) !== null && _d !== void 0 ? _d : (this.tls ? 443 : 80);
|
|
33
|
+
this.auth = (_e = options === null || options === void 0 ? void 0 : options.auth) !== null && _e !== void 0 ? _e : '';
|
|
30
34
|
}
|
|
31
35
|
getParameterGroup(groupNames) {
|
|
32
36
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -318,10 +322,11 @@ class CameraVapix extends eventemitter2_1.EventEmitter2 {
|
|
|
318
322
|
}
|
|
319
323
|
getBaseVapixConnectionParams() {
|
|
320
324
|
return {
|
|
321
|
-
protocol: this.
|
|
325
|
+
protocol: this.tls ? 'https:' : 'http:',
|
|
322
326
|
host: this.ip,
|
|
323
327
|
port: this.port,
|
|
324
328
|
auth: this.auth,
|
|
329
|
+
rejectUnauthorized: !this.tlsInsecure,
|
|
325
330
|
};
|
|
326
331
|
}
|
|
327
332
|
}
|
package/HTTPRequest.d.ts
CHANGED
|
@@ -11,5 +11,6 @@ export declare type HttpRequestOptions = {
|
|
|
11
11
|
headers?: {
|
|
12
12
|
'Content-Type'?: string;
|
|
13
13
|
};
|
|
14
|
+
rejectUnauthorized?: boolean;
|
|
14
15
|
};
|
|
15
16
|
export declare function httpRequest(options: HttpRequestOptions, postData?: string, noWaitForData?: boolean): Promise<string | http.IncomingMessage>;
|
package/HTTPRequest.js
CHANGED
|
@@ -49,7 +49,7 @@ function request(options, postData, digestHeader, noWaitForData) {
|
|
|
49
49
|
var _a, _b;
|
|
50
50
|
if (digestHeader != undefined) {
|
|
51
51
|
if (options.auth == undefined) {
|
|
52
|
-
reject('No credentials found');
|
|
52
|
+
reject(new Error('No credentials found'));
|
|
53
53
|
}
|
|
54
54
|
const auth = options.auth.split(':');
|
|
55
55
|
delete options.auth;
|
package/README.md
CHANGED
|
@@ -197,7 +197,7 @@ Module for easy control of CamOverlay drawing API. For more details on supported
|
|
|
197
197
|
|
|
198
198
|
### methods
|
|
199
199
|
#### CameraVapix(options)
|
|
200
|
-
Options parameter contains access to the camera, service name, service ID and camera. If service ID is not specified, service is automatically created/selected based on serviceName. Specify video channel using parameter camera (in which View Area overlay will be shown). If omitted the default value camera=0 is used.
|
|
200
|
+
Options parameter contains access to the camera, service name, service ID and camera. If service ID is not specified, service is automatically created/selected based on serviceName. Specify video channel using parameter camera (in which View Area overlay will be shown). If you need to specify multiple video channels, you can use an array: `camera=[0,1]`. If omitted the default value `camera=0` is used.
|
|
201
201
|
```javascript
|
|
202
202
|
options = {
|
|
203
203
|
'ip': '127.0.0.1',
|