camstreamerlib 4.0.0-beta.2 → 4.0.0-beta.4
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/cjs/CamOverlayAPI.js +176 -0
- package/cjs/CamOverlayDrawingAPI.js +235 -0
- package/cjs/CamOverlayPainter/Frame.js +301 -0
- package/{CamOverlayPainter → cjs/CamOverlayPainter}/Painter.d.ts +14 -3
- package/cjs/CamOverlayPainter/Painter.js +171 -0
- package/cjs/CamOverlayPainter/ResourceManager.js +46 -0
- package/cjs/CamScripterAPI.js +70 -0
- package/cjs/CamScripterAPICameraEventsGenerator.js +162 -0
- package/cjs/CamStreamerAPI.js +65 -0
- package/{CamSwitcherAPI.d.ts → cjs/CamSwitcherAPI.d.ts} +3 -3
- package/cjs/CamSwitcherAPI.js +350 -0
- package/{CamSwitcherEvents.d.ts → cjs/CamSwitcherEvents.d.ts} +1 -1
- package/cjs/CamSwitcherEvents.js +67 -0
- package/cjs/CreatePackage.js +106 -0
- package/{VapixAPI.d.ts → cjs/VapixAPI.d.ts} +9 -9
- package/cjs/VapixAPI.js +462 -0
- package/cjs/VapixEvents.js +88 -0
- package/cjs/errors/errors.js +79 -0
- package/cjs/events/AxisCameraStationEvents.js +48 -0
- package/cjs/events/GenetecAgent.js +123 -0
- package/cjs/index.d.ts +11 -0
- package/cjs/index.js +31 -0
- package/cjs/internal/Digest.js +42 -0
- package/cjs/internal/ProxyClient.js +44 -0
- package/{internal → cjs/internal}/common.d.ts +0 -1
- package/cjs/internal/common.js +27 -0
- package/cjs/internal/constants.js +4 -0
- package/cjs/internal/transformers.js +32 -0
- package/cjs/internal/utils.js +46 -0
- package/cjs/internal/versionCompare.js +53 -0
- package/cjs/node/DefaultClient.js +54 -0
- package/cjs/node/HttpRequestSender.js +89 -0
- package/cjs/node/HttpServer.js +96 -0
- package/cjs/node/WsClient.js +149 -0
- package/cjs/node/WsEventClient.js +22 -0
- package/cjs/node/index.d.ts +2 -0
- package/cjs/node/index.js +7 -0
- package/cjs/types/CamOverlayAPI.js +47 -0
- package/cjs/types/CamScripterAPI.js +20 -0
- package/cjs/types/CamStreamerAPI.js +28 -0
- package/cjs/types/CamSwitcherAPI.js +137 -0
- package/cjs/types/CamSwitcherEvents.js +62 -0
- package/{types → cjs/types}/VapixAPI.d.ts +40 -61
- package/cjs/types/VapixAPI.js +130 -0
- package/cjs/types/common.js +14 -0
- package/cjs/web/DefaultClient.js +20 -0
- package/cjs/web/WsClient.js +62 -0
- package/cjs/web/index.d.ts +2 -0
- package/cjs/web/index.js +7 -0
- package/esm/CamOverlayAPI.d.ts +31 -0
- package/esm/CamOverlayDrawingAPI.d.ts +86 -0
- package/{CamOverlayDrawingAPI.js → esm/CamOverlayDrawingAPI.js} +6 -3
- package/esm/CamOverlayPainter/Frame.d.ts +96 -0
- package/esm/CamOverlayPainter/Painter.d.ts +48 -0
- package/{CamOverlayPainter → esm/CamOverlayPainter}/Painter.js +4 -1
- package/esm/CamOverlayPainter/ResourceManager.d.ts +14 -0
- package/{CamOverlayPainter → esm/CamOverlayPainter}/ResourceManager.js +6 -10
- package/esm/CamScripterAPI.d.ts +19 -0
- package/esm/CamScripterAPICameraEventsGenerator.d.ts +74 -0
- package/{CamScripterAPICameraEventsGenerator.js → esm/CamScripterAPICameraEventsGenerator.js} +6 -3
- package/esm/CamStreamerAPI.d.ts +16 -0
- package/esm/CamSwitcherAPI.d.ts +48 -0
- package/{CamSwitcherAPI.js → esm/CamSwitcherAPI.js} +19 -23
- package/esm/CamSwitcherEvents.d.ts +18 -0
- package/{CamSwitcherEvents.js → esm/CamSwitcherEvents.js} +1 -1
- package/esm/CreatePackage.d.ts +1 -0
- package/esm/VapixAPI.d.ts +66 -0
- package/{VapixAPI.js → esm/VapixAPI.js} +20 -16
- package/esm/VapixEvents.d.ts +43 -0
- package/{VapixEvents.js → esm/VapixEvents.js} +3 -3
- package/esm/errors/errors.d.ts +34 -0
- package/esm/events/AxisCameraStationEvents.d.ts +9 -0
- package/esm/events/GenetecAgent.d.ts +174 -0
- package/esm/index.d.ts +11 -0
- package/esm/index.js +11 -0
- package/esm/internal/Digest.d.ts +4 -0
- package/{internal → esm/internal}/Digest.js +6 -6
- package/esm/internal/ProxyClient.d.ts +11 -0
- package/esm/internal/common.d.ts +39 -0
- package/{internal → esm/internal}/common.js +0 -3
- package/esm/internal/constants.d.ts +1 -0
- package/esm/internal/transformers.d.ts +5 -0
- package/esm/internal/utils.d.ts +11 -0
- package/esm/internal/versionCompare.d.ts +6 -0
- package/esm/node/DefaultClient.d.ts +15 -0
- package/{node → esm/node}/DefaultClient.js +1 -1
- package/esm/node/HttpRequestSender.d.ts +28 -0
- package/esm/node/HttpServer.d.ts +21 -0
- package/{node → esm/node}/HttpServer.js +1 -1
- package/esm/node/WsClient.d.ts +39 -0
- package/esm/node/WsEventClient.d.ts +13 -0
- package/esm/node/index.d.ts +2 -0
- package/esm/node/index.js +2 -0
- package/esm/types/CamOverlayAPI.d.ts +188 -0
- package/esm/types/CamScripterAPI.d.ts +67 -0
- package/esm/types/CamStreamerAPI.d.ts +139 -0
- package/esm/types/CamSwitcherAPI.d.ts +814 -0
- package/esm/types/CamSwitcherEvents.d.ts +491 -0
- package/esm/types/VapixAPI.d.ts +1683 -0
- package/{types → esm/types}/VapixAPI.js +10 -12
- package/esm/types/common.d.ts +37 -0
- package/esm/web/DefaultClient.d.ts +6 -0
- package/esm/web/WsClient.d.ts +13 -0
- package/esm/web/index.d.ts +2 -0
- package/esm/web/index.js +2 -0
- package/package.json +6 -5
- package/README.md +0 -97
- /package/{CamOverlayAPI.d.ts → cjs/CamOverlayAPI.d.ts} +0 -0
- /package/{CamOverlayDrawingAPI.d.ts → cjs/CamOverlayDrawingAPI.d.ts} +0 -0
- /package/{CamOverlayPainter → cjs/CamOverlayPainter}/Frame.d.ts +0 -0
- /package/{CamOverlayPainter → cjs/CamOverlayPainter}/ResourceManager.d.ts +0 -0
- /package/{CamScripterAPI.d.ts → cjs/CamScripterAPI.d.ts} +0 -0
- /package/{CamScripterAPICameraEventsGenerator.d.ts → cjs/CamScripterAPICameraEventsGenerator.d.ts} +0 -0
- /package/{CamStreamerAPI.d.ts → cjs/CamStreamerAPI.d.ts} +0 -0
- /package/{CreatePackage.d.ts → cjs/CreatePackage.d.ts} +0 -0
- /package/{VapixEvents.d.ts → cjs/VapixEvents.d.ts} +0 -0
- /package/{errors → cjs/errors}/errors.d.ts +0 -0
- /package/{events → cjs/events}/AxisCameraStationEvents.d.ts +0 -0
- /package/{events → cjs/events}/GenetecAgent.d.ts +0 -0
- /package/{internal → cjs/internal}/Digest.d.ts +0 -0
- /package/{internal → cjs/internal}/ProxyClient.d.ts +0 -0
- /package/{internal → cjs/internal}/constants.d.ts +0 -0
- /package/{internal → cjs/internal}/transformers.d.ts +0 -0
- /package/{internal → cjs/internal}/utils.d.ts +0 -0
- /package/{internal → cjs/internal}/versionCompare.d.ts +0 -0
- /package/{node → cjs/node}/DefaultClient.d.ts +0 -0
- /package/{node → cjs/node}/HttpRequestSender.d.ts +0 -0
- /package/{node → cjs/node}/HttpServer.d.ts +0 -0
- /package/{node → cjs/node}/WsClient.d.ts +0 -0
- /package/{node → cjs/node}/WsEventClient.d.ts +0 -0
- /package/{types → cjs/types}/CamOverlayAPI.d.ts +0 -0
- /package/{types → cjs/types}/CamScripterAPI.d.ts +0 -0
- /package/{types → cjs/types}/CamStreamerAPI.d.ts +0 -0
- /package/{types → cjs/types}/CamSwitcherAPI.d.ts +0 -0
- /package/{types/CamswitcherEvents.d.ts → cjs/types/CamSwitcherEvents.d.ts} +0 -0
- /package/{types → cjs/types}/common.d.ts +0 -0
- /package/{web → cjs/web}/DefaultClient.d.ts +0 -0
- /package/{web → cjs/web}/WsClient.d.ts +0 -0
- /package/{CamOverlayAPI.js → esm/CamOverlayAPI.js} +0 -0
- /package/{CamOverlayPainter → esm/CamOverlayPainter}/Frame.js +0 -0
- /package/{CamScripterAPI.js → esm/CamScripterAPI.js} +0 -0
- /package/{CamStreamerAPI.js → esm/CamStreamerAPI.js} +0 -0
- /package/{CreatePackage.js → esm/CreatePackage.js} +0 -0
- /package/{errors → esm/errors}/errors.js +0 -0
- /package/{events → esm/events}/AxisCameraStationEvents.js +0 -0
- /package/{events → esm/events}/GenetecAgent.js +0 -0
- /package/{internal → esm/internal}/ProxyClient.js +0 -0
- /package/{internal → esm/internal}/constants.js +0 -0
- /package/{internal → esm/internal}/transformers.js +0 -0
- /package/{internal → esm/internal}/utils.js +0 -0
- /package/{internal → esm/internal}/versionCompare.js +0 -0
- /package/{node → esm/node}/HttpRequestSender.js +0 -0
- /package/{node → esm/node}/WsClient.js +0 -0
- /package/{node → esm/node}/WsEventClient.js +0 -0
- /package/{types → esm/types}/CamOverlayAPI.js +0 -0
- /package/{types → esm/types}/CamScripterAPI.js +0 -0
- /package/{types → esm/types}/CamStreamerAPI.js +0 -0
- /package/{types → esm/types}/CamSwitcherAPI.js +0 -0
- /package/{types/CamswitcherEvents.js → esm/types/CamSwitcherEvents.js} +0 -0
- /package/{types → esm/types}/common.js +0 -0
- /package/{web → esm/web}/DefaultClient.js +0 -0
- /package/{web → esm/web}/WsClient.js +0 -0
|
@@ -11,7 +11,7 @@ export class VapixAPI {
|
|
|
11
11
|
constructor(client, getProxyUrl) {
|
|
12
12
|
this.client = new ProxyClient(client, getProxyUrl);
|
|
13
13
|
}
|
|
14
|
-
async getUrlEncoded(proxy
|
|
14
|
+
async getUrlEncoded(proxy, path, parameters, headers = {}) {
|
|
15
15
|
const data = paramToUrl(parameters);
|
|
16
16
|
const head = { ...headers, 'Content-Type': 'application/x-www-form-urlencoded' };
|
|
17
17
|
const res = await this.client.post(proxy, path, data, {}, head);
|
|
@@ -20,7 +20,7 @@ export class VapixAPI {
|
|
|
20
20
|
}
|
|
21
21
|
return res;
|
|
22
22
|
}
|
|
23
|
-
async postJson(proxy
|
|
23
|
+
async postJson(proxy, path, jsonData, headers = {}) {
|
|
24
24
|
const data = JSON.stringify(jsonData);
|
|
25
25
|
const head = { ...headers, 'Content-Type': 'application/json' };
|
|
26
26
|
const res = await this.client.post(proxy, path, data, {}, head);
|
|
@@ -231,9 +231,9 @@ export class VapixAPI {
|
|
|
231
231
|
const gTour = {
|
|
232
232
|
id: gTourBaseName,
|
|
233
233
|
camNbr: response[gTourBaseName + '.CamNbr'],
|
|
234
|
-
name: response[gTourBaseName + '.Name'],
|
|
234
|
+
name: response[gTourBaseName + '.Name'] ?? 'Guard Tour ' + (i + 1),
|
|
235
235
|
randomEnabled: response[gTourBaseName + '.RandomEnabled'],
|
|
236
|
-
running: response[gTourBaseName + '.Running'],
|
|
236
|
+
running: response[gTourBaseName + '.Running'] ?? 'no',
|
|
237
237
|
timeBetweenSequences: response[gTourBaseName + '.TimeBetweenSequences'],
|
|
238
238
|
tour: [],
|
|
239
239
|
};
|
|
@@ -298,8 +298,12 @@ export class VapixAPI {
|
|
|
298
298
|
});
|
|
299
299
|
const data = parseCameraPtzResponse(await response.text());
|
|
300
300
|
const res = {};
|
|
301
|
-
Object.keys(data)
|
|
302
|
-
|
|
301
|
+
Object.keys(data)
|
|
302
|
+
.map(Number)
|
|
303
|
+
.forEach((camera) => {
|
|
304
|
+
if (data[camera] !== undefined) {
|
|
305
|
+
res[camera - 1] = data[camera]?.map(({ data: itemData, ...d }) => d);
|
|
306
|
+
}
|
|
303
307
|
});
|
|
304
308
|
return res;
|
|
305
309
|
}
|
|
@@ -323,7 +327,7 @@ export class VapixAPI {
|
|
|
323
327
|
}
|
|
324
328
|
async getInputState(port, proxy = null) {
|
|
325
329
|
const response = await (await this.getUrlEncoded(proxy, '/axis-cgi/io/port.cgi', { checkactive: port.toString() })).text();
|
|
326
|
-
return response.split('=')[1]
|
|
330
|
+
return response.split('=')[1]?.indexOf('active') === 0;
|
|
327
331
|
}
|
|
328
332
|
async setOutputState(port, active, proxy = null) {
|
|
329
333
|
return this.getUrlEncoded(proxy, '/axis-cgi/io/port.cgi', { action: active ? `${port}:/` : `${port}:\\` });
|
|
@@ -333,10 +337,10 @@ export class VapixAPI {
|
|
|
333
337
|
const xml = await res.text();
|
|
334
338
|
const result = (await parseStringPromise(xml));
|
|
335
339
|
const apps = [];
|
|
336
|
-
for (
|
|
340
|
+
for (const app of result.reply.application) {
|
|
337
341
|
apps.push({
|
|
338
|
-
...
|
|
339
|
-
appId: APP_IDS.find((id) => id.toLowerCase() ===
|
|
342
|
+
...app.$,
|
|
343
|
+
appId: APP_IDS.find((id) => id.toLowerCase() === app.$.Name.toLowerCase()) ?? null,
|
|
340
344
|
});
|
|
341
345
|
}
|
|
342
346
|
return apps;
|
|
@@ -389,14 +393,14 @@ export class VapixAPI {
|
|
|
389
393
|
const parseParameters = (response) => {
|
|
390
394
|
const params = {};
|
|
391
395
|
const lines = response.split(/[\r\n]/);
|
|
392
|
-
for (
|
|
393
|
-
if (
|
|
396
|
+
for (const line of lines) {
|
|
397
|
+
if (line.length === 0 || line.substring(0, 7) === '# Error') {
|
|
394
398
|
continue;
|
|
395
399
|
}
|
|
396
|
-
const delimiterPos =
|
|
400
|
+
const delimiterPos = line.indexOf('=');
|
|
397
401
|
if (delimiterPos !== -1) {
|
|
398
|
-
const paramName =
|
|
399
|
-
const paramValue =
|
|
402
|
+
const paramName = line.substring(0, delimiterPos);
|
|
403
|
+
const paramValue = line.substring(delimiterPos + 1);
|
|
400
404
|
params[paramName] = paramValue;
|
|
401
405
|
}
|
|
402
406
|
}
|
|
@@ -442,7 +446,7 @@ const parsePtz = (parsed) => {
|
|
|
442
446
|
};
|
|
443
447
|
res.push({
|
|
444
448
|
id,
|
|
445
|
-
name: data[0],
|
|
449
|
+
name: data[0] ?? 'Preset ' + id,
|
|
446
450
|
data: {
|
|
447
451
|
pan: getValue('pan'),
|
|
448
452
|
tilt: getValue('tilt'),
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { EventEmitter2 as EventEmitter } from 'eventemitter2';
|
|
2
|
+
import { WsOptions } from './internal/common';
|
|
3
|
+
export type VapixEventsOptions = WsOptions;
|
|
4
|
+
type TEventMessage = {
|
|
5
|
+
apiVersion: string;
|
|
6
|
+
method: string;
|
|
7
|
+
params: {
|
|
8
|
+
notification: {
|
|
9
|
+
timestamp: number;
|
|
10
|
+
topic: string;
|
|
11
|
+
message: {
|
|
12
|
+
source: Record<string, string>;
|
|
13
|
+
data: Record<string, string>;
|
|
14
|
+
key: Record<string, string>;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export interface VapixEvents {
|
|
20
|
+
on(event: 'open', listener: () => void): this;
|
|
21
|
+
on(event: 'close', listener: () => void): this;
|
|
22
|
+
on(event: 'error', listener: (err: Error) => void): this;
|
|
23
|
+
on(event: string, listener: (data: TEventMessage) => void): this;
|
|
24
|
+
emit(event: 'open'): boolean;
|
|
25
|
+
emit(event: 'close'): boolean;
|
|
26
|
+
emit(event: 'error', err: Error): boolean;
|
|
27
|
+
emit(event: string, msg: TEventMessage): boolean;
|
|
28
|
+
}
|
|
29
|
+
export declare class VapixEvents extends EventEmitter {
|
|
30
|
+
private tls;
|
|
31
|
+
private tlsInsecure;
|
|
32
|
+
private ip;
|
|
33
|
+
private port;
|
|
34
|
+
private user;
|
|
35
|
+
private pass;
|
|
36
|
+
private ws;
|
|
37
|
+
constructor(options?: VapixEventsOptions);
|
|
38
|
+
connect(): void;
|
|
39
|
+
disconnect(): void;
|
|
40
|
+
private createWsClient;
|
|
41
|
+
private isReservedEventName;
|
|
42
|
+
}
|
|
43
|
+
export {};
|
|
@@ -39,10 +39,10 @@ export class VapixEvents extends EventEmitter {
|
|
|
39
39
|
this.ws.on('open', () => {
|
|
40
40
|
const topics = [];
|
|
41
41
|
const eventNames = this.eventNames();
|
|
42
|
-
for (
|
|
43
|
-
if (!this.isReservedEventName(
|
|
42
|
+
for (const eventName of eventNames) {
|
|
43
|
+
if (!this.isReservedEventName(eventName)) {
|
|
44
44
|
const topic = {
|
|
45
|
-
topicFilter:
|
|
45
|
+
topicFilter: eventName,
|
|
46
46
|
};
|
|
47
47
|
topics.push(topic);
|
|
48
48
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export declare class ServiceUnavailableError extends Error {
|
|
2
|
+
constructor();
|
|
3
|
+
}
|
|
4
|
+
export declare class ServiceNotFoundError extends Error {
|
|
5
|
+
constructor();
|
|
6
|
+
}
|
|
7
|
+
export declare class ParsingBlobError extends Error {
|
|
8
|
+
constructor(err: unknown);
|
|
9
|
+
}
|
|
10
|
+
type TApplicationAPIAction = 'START' | 'RESTART' | 'STOP';
|
|
11
|
+
export declare class ApplicationAPIError extends Error {
|
|
12
|
+
constructor(action: TApplicationAPIAction, res: string);
|
|
13
|
+
}
|
|
14
|
+
type TSDCardAction = 'MOUNT' | 'UNMOUNT';
|
|
15
|
+
export declare class SDCardActionError extends Error {
|
|
16
|
+
constructor(action: TSDCardAction, res: string);
|
|
17
|
+
}
|
|
18
|
+
export declare class SDCardJobError extends Error {
|
|
19
|
+
constructor();
|
|
20
|
+
}
|
|
21
|
+
type TMaxFPSErrorType = 'MALFORMED_REPLY' | 'CHANNEL_NOT_FOUND' | 'CAPTURE_MODE_NOT_FOUND' | 'FPS_NOT_SPECIFIED';
|
|
22
|
+
export declare class MaxFPSError extends Error {
|
|
23
|
+
constructor(state: TMaxFPSErrorType);
|
|
24
|
+
}
|
|
25
|
+
export declare class NoDeviceInfoError extends Error {
|
|
26
|
+
constructor();
|
|
27
|
+
}
|
|
28
|
+
export declare class FetchDeviceInfoError extends Error {
|
|
29
|
+
constructor(err: unknown);
|
|
30
|
+
}
|
|
31
|
+
export declare class AddNewClipError extends Error {
|
|
32
|
+
constructor(message: string);
|
|
33
|
+
}
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IClient, HttpOptions } from '../internal/common';
|
|
2
|
+
export type AcsEventsOptions = HttpOptions;
|
|
3
|
+
export declare class AxisCameraStationEvents {
|
|
4
|
+
private sourceKey;
|
|
5
|
+
private client;
|
|
6
|
+
constructor(sourceKey: string, opt?: AcsEventsOptions | IClient);
|
|
7
|
+
sendEvent(data: Record<string, string>, eventType: string): Promise<void>;
|
|
8
|
+
private getDate;
|
|
9
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
declare const cameraGuidsResponseSchema: z.ZodObject<{
|
|
3
|
+
Rsp: z.ZodObject<{
|
|
4
|
+
Status: z.ZodString;
|
|
5
|
+
Result: z.ZodArray<z.ZodObject<{
|
|
6
|
+
Guid: z.ZodString;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
Guid: string;
|
|
9
|
+
}, {
|
|
10
|
+
Guid: string;
|
|
11
|
+
}>, "many">;
|
|
12
|
+
}, "strip", z.ZodTypeAny, {
|
|
13
|
+
Status: string;
|
|
14
|
+
Result: {
|
|
15
|
+
Guid: string;
|
|
16
|
+
}[];
|
|
17
|
+
}, {
|
|
18
|
+
Status: string;
|
|
19
|
+
Result: {
|
|
20
|
+
Guid: string;
|
|
21
|
+
}[];
|
|
22
|
+
}>;
|
|
23
|
+
}, "strip", z.ZodTypeAny, {
|
|
24
|
+
Rsp: {
|
|
25
|
+
Status: string;
|
|
26
|
+
Result: {
|
|
27
|
+
Guid: string;
|
|
28
|
+
}[];
|
|
29
|
+
};
|
|
30
|
+
}, {
|
|
31
|
+
Rsp: {
|
|
32
|
+
Status: string;
|
|
33
|
+
Result: {
|
|
34
|
+
Guid: string;
|
|
35
|
+
}[];
|
|
36
|
+
};
|
|
37
|
+
}>;
|
|
38
|
+
export type TCameraGuidsResponse = z.infer<typeof cameraGuidsResponseSchema>;
|
|
39
|
+
declare const connectionResponseSchema: z.ZodObject<{
|
|
40
|
+
Rsp: z.ZodObject<{
|
|
41
|
+
Status: z.ZodString;
|
|
42
|
+
}, "strip", z.ZodTypeAny, {
|
|
43
|
+
Status: string;
|
|
44
|
+
}, {
|
|
45
|
+
Status: string;
|
|
46
|
+
}>;
|
|
47
|
+
}, "strip", z.ZodTypeAny, {
|
|
48
|
+
Rsp: {
|
|
49
|
+
Status: string;
|
|
50
|
+
};
|
|
51
|
+
}, {
|
|
52
|
+
Rsp: {
|
|
53
|
+
Status: string;
|
|
54
|
+
};
|
|
55
|
+
}>;
|
|
56
|
+
export type TConnectionResponse = z.infer<typeof connectionResponseSchema>;
|
|
57
|
+
export declare const cameraDetailSchema: z.ZodObject<{
|
|
58
|
+
Guid: z.ZodOptional<z.ZodString>;
|
|
59
|
+
Name: z.ZodOptional<z.ZodString>;
|
|
60
|
+
EntityType: z.ZodOptional<z.ZodString>;
|
|
61
|
+
}, "strip", z.ZodTypeAny, {
|
|
62
|
+
Name?: string | undefined;
|
|
63
|
+
Guid?: string | undefined;
|
|
64
|
+
EntityType?: string | undefined;
|
|
65
|
+
}, {
|
|
66
|
+
Name?: string | undefined;
|
|
67
|
+
Guid?: string | undefined;
|
|
68
|
+
EntityType?: string | undefined;
|
|
69
|
+
}>;
|
|
70
|
+
export declare const cameraDetailsResponseSchema: z.ZodObject<{
|
|
71
|
+
Rsp: z.ZodObject<{
|
|
72
|
+
Status: z.ZodString;
|
|
73
|
+
Result: z.ZodUnion<[z.ZodArray<z.ZodObject<{
|
|
74
|
+
Guid: z.ZodOptional<z.ZodString>;
|
|
75
|
+
Name: z.ZodOptional<z.ZodString>;
|
|
76
|
+
EntityType: z.ZodOptional<z.ZodString>;
|
|
77
|
+
}, "strip", z.ZodTypeAny, {
|
|
78
|
+
Name?: string | undefined;
|
|
79
|
+
Guid?: string | undefined;
|
|
80
|
+
EntityType?: string | undefined;
|
|
81
|
+
}, {
|
|
82
|
+
Name?: string | undefined;
|
|
83
|
+
Guid?: string | undefined;
|
|
84
|
+
EntityType?: string | undefined;
|
|
85
|
+
}>, "many">, z.ZodObject<{
|
|
86
|
+
Guid: z.ZodOptional<z.ZodString>;
|
|
87
|
+
Name: z.ZodOptional<z.ZodString>;
|
|
88
|
+
EntityType: z.ZodOptional<z.ZodString>;
|
|
89
|
+
}, "strip", z.ZodTypeAny, {
|
|
90
|
+
Name?: string | undefined;
|
|
91
|
+
Guid?: string | undefined;
|
|
92
|
+
EntityType?: string | undefined;
|
|
93
|
+
}, {
|
|
94
|
+
Name?: string | undefined;
|
|
95
|
+
Guid?: string | undefined;
|
|
96
|
+
EntityType?: string | undefined;
|
|
97
|
+
}>]>;
|
|
98
|
+
}, "strip", z.ZodTypeAny, {
|
|
99
|
+
Status: string;
|
|
100
|
+
Result: {
|
|
101
|
+
Name?: string | undefined;
|
|
102
|
+
Guid?: string | undefined;
|
|
103
|
+
EntityType?: string | undefined;
|
|
104
|
+
} | {
|
|
105
|
+
Name?: string | undefined;
|
|
106
|
+
Guid?: string | undefined;
|
|
107
|
+
EntityType?: string | undefined;
|
|
108
|
+
}[];
|
|
109
|
+
}, {
|
|
110
|
+
Status: string;
|
|
111
|
+
Result: {
|
|
112
|
+
Name?: string | undefined;
|
|
113
|
+
Guid?: string | undefined;
|
|
114
|
+
EntityType?: string | undefined;
|
|
115
|
+
} | {
|
|
116
|
+
Name?: string | undefined;
|
|
117
|
+
Guid?: string | undefined;
|
|
118
|
+
EntityType?: string | undefined;
|
|
119
|
+
}[];
|
|
120
|
+
}>;
|
|
121
|
+
}, "strip", z.ZodTypeAny, {
|
|
122
|
+
Rsp: {
|
|
123
|
+
Status: string;
|
|
124
|
+
Result: {
|
|
125
|
+
Name?: string | undefined;
|
|
126
|
+
Guid?: string | undefined;
|
|
127
|
+
EntityType?: string | undefined;
|
|
128
|
+
} | {
|
|
129
|
+
Name?: string | undefined;
|
|
130
|
+
Guid?: string | undefined;
|
|
131
|
+
EntityType?: string | undefined;
|
|
132
|
+
}[];
|
|
133
|
+
};
|
|
134
|
+
}, {
|
|
135
|
+
Rsp: {
|
|
136
|
+
Status: string;
|
|
137
|
+
Result: {
|
|
138
|
+
Name?: string | undefined;
|
|
139
|
+
Guid?: string | undefined;
|
|
140
|
+
EntityType?: string | undefined;
|
|
141
|
+
} | {
|
|
142
|
+
Name?: string | undefined;
|
|
143
|
+
Guid?: string | undefined;
|
|
144
|
+
EntityType?: string | undefined;
|
|
145
|
+
}[];
|
|
146
|
+
};
|
|
147
|
+
}>;
|
|
148
|
+
export type TCameraDetailsResponse = z.infer<typeof cameraDetailsResponseSchema>;
|
|
149
|
+
export type TCameraDetail = z.infer<typeof cameraDetailSchema>;
|
|
150
|
+
export type TParams = Array<'Guid' | 'Name' | 'EntityType'>;
|
|
151
|
+
export type GenetecAgentOptions = {
|
|
152
|
+
protocol?: 'http' | 'https' | 'https_insecure';
|
|
153
|
+
ip?: string;
|
|
154
|
+
port?: number;
|
|
155
|
+
base_uri?: string;
|
|
156
|
+
user?: string;
|
|
157
|
+
pass?: string;
|
|
158
|
+
app_id?: string;
|
|
159
|
+
};
|
|
160
|
+
export declare class GenetecAgent {
|
|
161
|
+
private settings;
|
|
162
|
+
private baseUrl;
|
|
163
|
+
private credentials;
|
|
164
|
+
constructor(options?: GenetecAgentOptions);
|
|
165
|
+
checkConnection(): Promise<TConnectionResponse>;
|
|
166
|
+
getAllCameraGuids(): Promise<TCameraGuidsResponse>;
|
|
167
|
+
getCameraDetails(guids: {
|
|
168
|
+
Guid: string;
|
|
169
|
+
}[], parameters: TParams): Promise<TCameraDetail[]>;
|
|
170
|
+
sendBookmark(guids: string[], bookmarkText: string): Promise<Response>;
|
|
171
|
+
private getRequestOptions;
|
|
172
|
+
private getTimeStamp;
|
|
173
|
+
}
|
|
174
|
+
export {};
|
package/esm/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './internal/common';
|
|
2
|
+
export * from './internal/constants';
|
|
3
|
+
export * from './internal/utils';
|
|
4
|
+
export * from './internal/versionCompare';
|
|
5
|
+
export * from './types/common';
|
|
6
|
+
export { CamSwitcherAPI } from './CamSwitcherAPI';
|
|
7
|
+
export { CamSwitcherEvents } from './CamSwitcherEvents';
|
|
8
|
+
export { VapixAPI } from './VapixAPI';
|
|
9
|
+
export * from './types/CamSwitcherEvents';
|
|
10
|
+
export * from './types/CamSwitcherAPI';
|
|
11
|
+
export * from './types/VapixAPI';
|
package/esm/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './internal/common';
|
|
2
|
+
export * from './internal/constants';
|
|
3
|
+
export * from './internal/utils';
|
|
4
|
+
export * from './internal/versionCompare';
|
|
5
|
+
export * from './types/common';
|
|
6
|
+
export { CamSwitcherAPI } from './CamSwitcherAPI';
|
|
7
|
+
export { CamSwitcherEvents } from './CamSwitcherEvents';
|
|
8
|
+
export { VapixAPI } from './VapixAPI';
|
|
9
|
+
export * from './types/CamSwitcherEvents';
|
|
10
|
+
export * from './types/CamSwitcherAPI';
|
|
11
|
+
export * from './types/VapixAPI';
|
|
@@ -4,17 +4,17 @@ export class Digest {
|
|
|
4
4
|
getAuthHeader(user, pass, method, uri, wwwAuthenticateHeader) {
|
|
5
5
|
const digestItems = {};
|
|
6
6
|
const digestArr = wwwAuthenticateHeader.substring(wwwAuthenticateHeader.indexOf('Digest') + 6).split(',');
|
|
7
|
-
for (
|
|
8
|
-
const pos =
|
|
9
|
-
const key =
|
|
10
|
-
const value =
|
|
7
|
+
for (const arg of digestArr) {
|
|
8
|
+
const pos = arg.indexOf('=');
|
|
9
|
+
const key = arg.substring(0, pos).trim();
|
|
10
|
+
const value = arg.substring(pos + 1).trim();
|
|
11
11
|
digestItems[key] = value.replace(/"/g, '');
|
|
12
12
|
}
|
|
13
13
|
const HA1 = crypto.createHash('md5').update(`${user}:${digestItems['realm']}:${pass}`).digest('hex');
|
|
14
14
|
const HA2 = crypto.createHash('md5').update(`${method}:${uri}`).digest('hex');
|
|
15
15
|
const ncValue = ('00000000' + this.nonceCount.toString(16)).slice(-8);
|
|
16
16
|
let response;
|
|
17
|
-
if (digestItems['qop']) {
|
|
17
|
+
if (digestItems['qop'] !== undefined) {
|
|
18
18
|
response = crypto
|
|
19
19
|
.createHash('md5')
|
|
20
20
|
.update(`${HA1}:${digestItems['nonce']}:${ncValue}:162d50aa594e9648:auth:${HA2}`)
|
|
@@ -29,7 +29,7 @@ export class Digest {
|
|
|
29
29
|
`nonce="${digestItems['nonce']}",` +
|
|
30
30
|
`uri="${uri}",` +
|
|
31
31
|
`response="${response}"`;
|
|
32
|
-
if (digestItems['qop']) {
|
|
32
|
+
if (digestItems['qop'] !== undefined) {
|
|
33
33
|
header += `,qop=auth,nc=${ncValue},cnonce="162d50aa594e9648"`;
|
|
34
34
|
}
|
|
35
35
|
this.nonceCount++;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { IClient, TParameters } from './common';
|
|
3
|
+
import { TProxyParam } from '../types/common';
|
|
4
|
+
export declare class ProxyClient<Client extends IClient = IClient> {
|
|
5
|
+
client: Client;
|
|
6
|
+
getProxyUrl: () => string;
|
|
7
|
+
constructor(client: Client, getProxyUrl: () => string);
|
|
8
|
+
get: (proxy: TProxyParam, path: string, parameters?: TParameters, headers?: Record<string, string>) => Promise<import("./common").TResponse>;
|
|
9
|
+
post: (proxy: TProxyParam, path: string, data: string | Buffer | FormData, parameters?: TParameters, headers?: Record<string, string>) => Promise<import("./common").TResponse>;
|
|
10
|
+
private getReal;
|
|
11
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
type Options = {
|
|
3
|
+
ip?: string;
|
|
4
|
+
port?: number;
|
|
5
|
+
user?: string;
|
|
6
|
+
pass?: string;
|
|
7
|
+
tls?: boolean;
|
|
8
|
+
tlsInsecure?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export type HttpOptions = Options & {
|
|
11
|
+
keepAlive?: boolean;
|
|
12
|
+
};
|
|
13
|
+
export type WsOptions = Options;
|
|
14
|
+
export type TResponse = {
|
|
15
|
+
ok: boolean;
|
|
16
|
+
json: () => Promise<any>;
|
|
17
|
+
text: () => Promise<string>;
|
|
18
|
+
status: number;
|
|
19
|
+
body: any | null;
|
|
20
|
+
};
|
|
21
|
+
export type TParameters = Record<string, string | number | boolean | null | undefined>;
|
|
22
|
+
export type TGetFunction = (url: string, parameters?: TParameters, headers?: Record<string, string>) => Promise<TResponse>;
|
|
23
|
+
export type TPostFunction = (url: string, data: string | Buffer | FormData, parameters?: TParameters, headers?: Record<string, string>) => Promise<TResponse>;
|
|
24
|
+
export interface IClient {
|
|
25
|
+
get: TGetFunction;
|
|
26
|
+
post: TPostFunction;
|
|
27
|
+
}
|
|
28
|
+
export interface IWebsocket<Event extends {
|
|
29
|
+
readonly data: string;
|
|
30
|
+
}> {
|
|
31
|
+
destroy: () => void;
|
|
32
|
+
onmessage: null | ((event: Event) => void);
|
|
33
|
+
send: (data: string) => void;
|
|
34
|
+
}
|
|
35
|
+
export declare function isClient(arg?: Options | IClient): arg is IClient;
|
|
36
|
+
export declare function responseStringify(res: TResponse): Promise<string>;
|
|
37
|
+
export declare function pad(num: number, size: number): string;
|
|
38
|
+
export declare function isNullish<T>(value: T | undefined | null): value is undefined | null;
|
|
39
|
+
export {};
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
export function isClient(arg = {}) {
|
|
2
2
|
return 'get' in arg && 'post' in arg;
|
|
3
3
|
}
|
|
4
|
-
export function isBrowserEnvironment() {
|
|
5
|
-
return typeof process === 'undefined' || !process.versions.node;
|
|
6
|
-
}
|
|
7
4
|
export async function responseStringify(res) {
|
|
8
5
|
return JSON.stringify({
|
|
9
6
|
status: res.status,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const FIRMWARE_WITH_BITRATE_MODES_SUPPORT = "11.11.73";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CamelCasedProperties, CamelCasedPropertiesDeep, SnakeCasedProperties, SnakeCasedPropertiesDeep } from 'type-fest';
|
|
2
|
+
export declare const toCamelCase: <T extends object>(o: T) => CamelCasedProperties<T>;
|
|
3
|
+
export declare const toCamelCaseDeep: <T extends object>(o: T) => CamelCasedPropertiesDeep<T>;
|
|
4
|
+
export declare const toSnakeCase: <T extends object>(o: T) => SnakeCasedProperties<T>;
|
|
5
|
+
export declare const toSnakeCaseDeep: <T extends object>(o: T) => SnakeCasedPropertiesDeep<T>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TPlaylistPlayType } from '../types/CamSwitcherAPI';
|
|
2
|
+
import { TParameters } from './common';
|
|
3
|
+
export declare const addParametersToPath: (path: string, params?: TParameters) => string;
|
|
4
|
+
export declare const paramToUrl: (params?: TParameters) => string;
|
|
5
|
+
export declare const arrayToUrl: (arr: string | string[]) => string;
|
|
6
|
+
export declare const isCamera: (id?: string) => boolean;
|
|
7
|
+
export declare const isStream: (id?: string) => boolean;
|
|
8
|
+
export declare const isClip: (id?: string) => boolean;
|
|
9
|
+
export declare const isTracker: (id?: string) => boolean;
|
|
10
|
+
export declare const isPlaylist: (id?: string) => boolean;
|
|
11
|
+
export declare const isLoopPlayType: (playType: TPlaylistPlayType) => boolean;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const assertVersionString: (s: string, msg?: string) => void;
|
|
2
|
+
export declare const isFirmwareVersionAtLeast: (version: string, compareVersion: string) => boolean;
|
|
3
|
+
export declare const isVersionAtLeast: (version: string, compareVersion: string) => boolean;
|
|
4
|
+
export declare const firmwareVersionCompare: (a: string, b: string) => 1 | -1 | 0;
|
|
5
|
+
export declare const versionCompare: (a: string, b: string) => 1 | -1 | 0;
|
|
6
|
+
export declare const fixVersionToDots: (version: string) => string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { IClient, HttpOptions, TParameters } from '../internal/common';
|
|
3
|
+
export declare class DefaultClient implements IClient {
|
|
4
|
+
private tls;
|
|
5
|
+
private ip;
|
|
6
|
+
private port;
|
|
7
|
+
private user;
|
|
8
|
+
private pass;
|
|
9
|
+
private httpRequestSender;
|
|
10
|
+
constructor(opt?: HttpOptions);
|
|
11
|
+
get url(): string;
|
|
12
|
+
get(path: string, parameters?: TParameters, headers?: Record<string, string>): Promise<import("undici").Response>;
|
|
13
|
+
post(path: string, data: string | FormData | Buffer, parameters?: TParameters, headers?: Record<string, string>): Promise<import("undici").Response>;
|
|
14
|
+
private getBaseConnectionParams;
|
|
15
|
+
}
|
|
@@ -36,7 +36,7 @@ export class DefaultClient {
|
|
|
36
36
|
return this.httpRequestSender.sendRequest(options, data);
|
|
37
37
|
}
|
|
38
38
|
getBaseConnectionParams(method, path, params) {
|
|
39
|
-
|
|
39
|
+
const pathName = addParametersToPath(path, params);
|
|
40
40
|
return {
|
|
41
41
|
method: method,
|
|
42
42
|
protocol: this.tls ? 'https:' : 'http:',
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { FormData as UndiciFormData, Response as UndiciResponse } from 'undici';
|
|
3
|
+
export type HttpRequestOptions = {
|
|
4
|
+
method?: string;
|
|
5
|
+
protocol: string;
|
|
6
|
+
host: string;
|
|
7
|
+
port: number;
|
|
8
|
+
path: string;
|
|
9
|
+
user?: string;
|
|
10
|
+
pass?: string;
|
|
11
|
+
timeout?: number;
|
|
12
|
+
headers?: Record<string, string>;
|
|
13
|
+
};
|
|
14
|
+
export type AgentOptions = {
|
|
15
|
+
rejectUnaurhorized?: boolean;
|
|
16
|
+
keepAlive?: boolean;
|
|
17
|
+
};
|
|
18
|
+
export declare class HttpRequestSender {
|
|
19
|
+
private agent?;
|
|
20
|
+
private authData?;
|
|
21
|
+
constructor(agentOptions?: AgentOptions);
|
|
22
|
+
sendRequest(options: HttpRequestOptions, postData?: Buffer | string | UndiciFormData): Promise<UndiciResponse>;
|
|
23
|
+
private sendRequestWithAuth;
|
|
24
|
+
private static getURL;
|
|
25
|
+
private getAuthorization;
|
|
26
|
+
private invalidateAuthorization;
|
|
27
|
+
private static getAuthHeader;
|
|
28
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import * as http from 'http';
|
|
4
|
+
import * as EventEmitter from 'events';
|
|
5
|
+
export type HttpServerOptions = {
|
|
6
|
+
host?: string;
|
|
7
|
+
port?: number;
|
|
8
|
+
};
|
|
9
|
+
type TOnRequestCallback = (req: http.IncomingMessage, res: http.ServerResponse) => void;
|
|
10
|
+
export declare class HttpServer extends EventEmitter {
|
|
11
|
+
private host;
|
|
12
|
+
private port;
|
|
13
|
+
private registeredPaths;
|
|
14
|
+
private server;
|
|
15
|
+
private sockets;
|
|
16
|
+
constructor(options?: HttpServerOptions);
|
|
17
|
+
getServer(): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
18
|
+
onRequest(pathName: string, callback: TOnRequestCallback): void;
|
|
19
|
+
close(): void;
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import * as EventEmitter from 'events';
|
|
4
|
+
import { WsOptions } from '../internal/common';
|
|
5
|
+
export type WsClientOptions = WsOptions & {
|
|
6
|
+
address: string;
|
|
7
|
+
headers?: Record<string, string>;
|
|
8
|
+
pingInterval?: number;
|
|
9
|
+
protocol?: string;
|
|
10
|
+
};
|
|
11
|
+
export interface WsClient {
|
|
12
|
+
on(event: 'open', listener: () => void): this;
|
|
13
|
+
on(event: 'close', listener: () => void): this;
|
|
14
|
+
on(event: 'message', listener: (data: Buffer) => void): this;
|
|
15
|
+
on(event: 'error', listener: (err: Error) => void): this;
|
|
16
|
+
emit(event: 'open'): boolean;
|
|
17
|
+
emit(event: 'close'): boolean;
|
|
18
|
+
emit(event: 'message', data: Buffer): boolean;
|
|
19
|
+
emit(event: 'error', err: Error): boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare class WsClient extends EventEmitter {
|
|
22
|
+
private user;
|
|
23
|
+
private pass;
|
|
24
|
+
private address;
|
|
25
|
+
private protocol?;
|
|
26
|
+
private pingInterval;
|
|
27
|
+
private wsOptions;
|
|
28
|
+
private digestAddress;
|
|
29
|
+
private isAlive;
|
|
30
|
+
private pingTimer?;
|
|
31
|
+
private ws?;
|
|
32
|
+
private isClosed;
|
|
33
|
+
constructor(options: WsClientOptions);
|
|
34
|
+
open(wwwAuthenticateHeader?: string): void;
|
|
35
|
+
send(data: Buffer | string): void;
|
|
36
|
+
close(): void;
|
|
37
|
+
reconnect(): void;
|
|
38
|
+
private closeWsConnection;
|
|
39
|
+
}
|