camstreamerlib 1.7.5 → 1.8.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/CamOverlayAPI.d.ts +8 -5
- package/CamOverlayAPI.js +45 -59
- 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/package.json +1 -1
package/CamOverlayAPI.d.ts
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
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;
|
|
@@ -36,7 +38,7 @@ export declare type UploadImageResponse = {
|
|
|
36
38
|
export declare type Align = 'A_RIGHT' | 'A_LEFT' | 'A_CENTER';
|
|
37
39
|
export declare type TextFit = 'TFM_SCALE' | 'TFM_TRUNCATE' | 'TFM_OVERFLOW';
|
|
38
40
|
export declare type WriteTextParams = [string, string, number, number, number, number, Align, TextFit?];
|
|
39
|
-
declare type Service = {
|
|
41
|
+
export declare type Service = {
|
|
40
42
|
id: number;
|
|
41
43
|
enabled: number;
|
|
42
44
|
schedule: string;
|
|
@@ -44,11 +46,12 @@ declare type Service = {
|
|
|
44
46
|
identifier: string;
|
|
45
47
|
camera: number;
|
|
46
48
|
};
|
|
47
|
-
declare type
|
|
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;
|
|
@@ -61,7 +64,7 @@ export declare class CamOverlayAPI extends EventEmitter {
|
|
|
61
64
|
constructor(options?: CamOverlayOptions);
|
|
62
65
|
connect(): Promise<void>;
|
|
63
66
|
createService(): Promise<number>;
|
|
64
|
-
updateServices(servicesJson:
|
|
67
|
+
updateServices(servicesJson: ServiceList): Promise<void>;
|
|
65
68
|
openWebsocket(digestHeader?: string): Promise<void>;
|
|
66
69
|
cairo(command: string, ...params: any[]): Promise<CairoResponse | CairoCreateResponse>;
|
|
67
70
|
writeText(...params: WriteTextParams): Promise<CairoResponse>;
|
|
@@ -82,5 +85,5 @@ 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;
|
|
85
89
|
}
|
|
86
|
-
export {};
|
package/CamOverlayAPI.js
CHANGED
|
@@ -16,16 +16,20 @@ const Digest_1 = require("./Digest");
|
|
|
16
16
|
const HTTPRequest_1 = require("./HTTPRequest");
|
|
17
17
|
class CamOverlayAPI extends EventEmitter {
|
|
18
18
|
constructor(options) {
|
|
19
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
19
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
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.camera = (_h = options === null || options === void 0 ? void 0 : options.camera) !== null && _h !== void 0 ? _h : 0;
|
|
29
33
|
this.callId = 0;
|
|
30
34
|
this.sendMessages = {};
|
|
31
35
|
EventEmitter.call(this);
|
|
@@ -47,12 +51,9 @@ class CamOverlayAPI extends EventEmitter {
|
|
|
47
51
|
createService() {
|
|
48
52
|
var _a;
|
|
49
53
|
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
|
-
};
|
|
54
|
+
const options = this.getBaseVapixConnectionParams();
|
|
55
|
+
options.method = 'GET';
|
|
56
|
+
options.path = '/local/camoverlay/api/services.cgi?action=get';
|
|
56
57
|
const response = (yield (0, HTTPRequest_1.httpRequest)(options));
|
|
57
58
|
let servicesJson;
|
|
58
59
|
try {
|
|
@@ -102,22 +103,20 @@ class CamOverlayAPI extends EventEmitter {
|
|
|
102
103
|
}
|
|
103
104
|
updateServices(servicesJson) {
|
|
104
105
|
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
|
-
};
|
|
106
|
+
const options = this.getBaseVapixConnectionParams();
|
|
107
|
+
options.method = 'POST';
|
|
108
|
+
options.path = '/local/camoverlay/api/services.cgi?action=set';
|
|
112
109
|
yield (0, HTTPRequest_1.httpRequest)(options, JSON.stringify(servicesJson));
|
|
113
110
|
});
|
|
114
111
|
}
|
|
115
112
|
openWebsocket(digestHeader) {
|
|
116
113
|
let promise = new Promise((resolve, reject) => {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
114
|
+
const userPass = this.auth.split(':');
|
|
115
|
+
const protocol = this.tls ? 'wss' : 'ws';
|
|
116
|
+
const addr = `${protocol}://${this.ip}:${this.port}/local/camoverlay/ws`;
|
|
117
|
+
const options = {
|
|
120
118
|
auth: this.auth,
|
|
119
|
+
rejectUnauthorized: !this.tlsInsecure,
|
|
121
120
|
headers: {},
|
|
122
121
|
};
|
|
123
122
|
if (digestHeader != undefined) {
|
|
@@ -241,55 +240,33 @@ class CamOverlayAPI extends EventEmitter {
|
|
|
241
240
|
}
|
|
242
241
|
promiseCGUpdate(action, params) {
|
|
243
242
|
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
|
-
};
|
|
243
|
+
const options = this.getBaseVapixConnectionParams();
|
|
244
|
+
options.method = 'POST';
|
|
245
|
+
options.path = encodeURI(`/local/camoverlay/api/customGraphics.cgi?action=${action}&service_id=${this.serviceID}${params}`);
|
|
252
246
|
yield (0, HTTPRequest_1.httpRequest)(options, '');
|
|
253
247
|
});
|
|
254
248
|
}
|
|
255
249
|
updateInfoticker(text) {
|
|
256
250
|
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
|
-
};
|
|
251
|
+
const options = this.getBaseVapixConnectionParams();
|
|
252
|
+
options.method = 'GET';
|
|
253
|
+
options.path = `/local/camoverlay/api/infoticker.cgi?service_id=${this.serviceID}&text=${text}`;
|
|
265
254
|
yield (0, HTTPRequest_1.httpRequest)(options, '');
|
|
266
255
|
});
|
|
267
256
|
}
|
|
268
257
|
setEnabled(enabled) {
|
|
269
258
|
return __awaiter(this, void 0, void 0, function* () {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
method: 'POST',
|
|
275
|
-
host: this.ip,
|
|
276
|
-
port: this.port,
|
|
277
|
-
path: path,
|
|
278
|
-
auth: this.auth,
|
|
279
|
-
};
|
|
280
|
-
yield (0, HTTPRequest_1.httpRequest)(options, '');
|
|
281
|
-
}
|
|
259
|
+
const options = this.getBaseVapixConnectionParams();
|
|
260
|
+
options.method = 'POST';
|
|
261
|
+
options.path = encodeURI(`/local/camoverlay/api/enabled.cgi?id_${this.serviceID}=${enabled ? 1 : 0}`);
|
|
262
|
+
yield (0, HTTPRequest_1.httpRequest)(options, '');
|
|
282
263
|
});
|
|
283
264
|
}
|
|
284
265
|
isEnabled() {
|
|
285
266
|
return __awaiter(this, void 0, void 0, function* () {
|
|
286
|
-
const options =
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
port: this.port,
|
|
290
|
-
path: '/local/camoverlay/api/services.cgi?action=get',
|
|
291
|
-
auth: this.auth,
|
|
292
|
-
};
|
|
267
|
+
const options = this.getBaseVapixConnectionParams();
|
|
268
|
+
options.method = 'GET';
|
|
269
|
+
options.path = '/local/camoverlay/api/services.cgi?action=get';
|
|
293
270
|
const response = (yield (0, HTTPRequest_1.httpRequest)(options, ''));
|
|
294
271
|
const data = JSON.parse(response);
|
|
295
272
|
for (let service of data.services) {
|
|
@@ -300,5 +277,14 @@ class CamOverlayAPI extends EventEmitter {
|
|
|
300
277
|
throw new Error('Service not found.');
|
|
301
278
|
});
|
|
302
279
|
}
|
|
280
|
+
getBaseVapixConnectionParams() {
|
|
281
|
+
return {
|
|
282
|
+
protocol: this.tls ? 'https:' : 'http:',
|
|
283
|
+
host: this.ip,
|
|
284
|
+
port: this.port,
|
|
285
|
+
auth: this.auth,
|
|
286
|
+
rejectUnauthorized: !this.tlsInsecure,
|
|
287
|
+
};
|
|
288
|
+
}
|
|
303
289
|
}
|
|
304
290
|
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;
|