camstreamerlib 4.0.0-beta.3 → 4.0.0-beta.5

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/README.md CHANGED
@@ -31,6 +31,8 @@ npm install camstreamerlib
31
31
 
32
32
  - [CamScripterAPICameraEventsGenerator](doc/CamScripterAPICameraEventsGenerator.md) is a module which allows generating events on an Axis camera. These events can be used for triggers in the Axis camera rule engine (events/actions). It is also an easy way how to integrate events and metadata in VMS systems which support Axis camera events.
33
33
 
34
+ - [CamSwitcherAPI](doc/CamSwitcherAPI.md) is a module to access CamSwitcher API.
35
+
34
36
  - [CamSwitcherEvents](doc/CamSwitcherEvents.md) is a module which allows receiving events from CamSwitcher ACAP application.
35
37
 
36
38
  - [VapixEvents](doc/VapixEvents.md) is a module which allows receiving camera events from the VAPIX API.
@@ -124,10 +124,10 @@ class CamOverlayDrawingAPI extends EventEmitter {
124
124
  }
125
125
  if (dataJSON.call_id !== undefined) {
126
126
  if (errorResponse !== undefined) {
127
- this.sendMessages[dataJSON.call_id].reject(new Error(errorResponse.error));
127
+ this.sendMessages[dataJSON.call_id]?.reject(new Error(errorResponse.error));
128
128
  }
129
129
  else {
130
- this.sendMessages[dataJSON.call_id].resolve(dataJSON);
130
+ this.sendMessages[dataJSON.call_id]?.resolve(dataJSON);
131
131
  }
132
132
  delete this.sendMessages[dataJSON.call_id];
133
133
  }
@@ -197,6 +197,9 @@ class CamOverlayDrawingAPI extends EventEmitter {
197
197
  const now = Date.now();
198
198
  for (const callId in this.sendMessages) {
199
199
  const msg = this.sendMessages[callId];
200
+ if (!msg) {
201
+ continue;
202
+ }
200
203
  if (now - msg.sentTimestamp > 10000) {
201
204
  reconnect = true;
202
205
  msg.reject(new Error('Message timeout'));
@@ -223,7 +226,7 @@ class CamOverlayDrawingAPI extends EventEmitter {
223
226
  }
224
227
  reportClose() {
225
228
  for (const callId in this.sendMessages) {
226
- this.sendMessages[callId].reject(new Error('Connection lost'));
229
+ this.sendMessages[callId]?.reject(new Error('Connection lost'));
227
230
  }
228
231
  this.sendMessages = {};
229
232
  this.emit('close');
@@ -1,11 +1,22 @@
1
1
  import { CamOverlayDrawingAPI, CamOverlayDrawingOptions } from '../CamOverlayDrawingAPI';
2
2
  import ResourceManager from './ResourceManager';
3
3
  import { Frame, TFrameOptions } from './Frame';
4
- export declare const COORD: Record<string, [number, number]>;
4
+ export declare const COORD: {
5
+ readonly top_left: readonly [-1, -1];
6
+ readonly center_left: readonly [-1, 0];
7
+ readonly bottom_left: readonly [-1, 1];
8
+ readonly top_center: readonly [0, -1];
9
+ readonly center: readonly [0, 0];
10
+ readonly bottom_center: readonly [0, 1];
11
+ readonly top_right: readonly [1, -1];
12
+ readonly center_right: readonly [1, 0];
13
+ readonly bottom_right: readonly [1, 1];
14
+ };
15
+ type TCoAlignment = keyof typeof COORD;
5
16
  export type TPainterOptions = TFrameOptions & {
6
17
  screenWidth: number;
7
18
  screenHeight: number;
8
- coAlignment: string;
19
+ coAlignment: TCoAlignment;
9
20
  };
10
21
  export declare class Painter extends Frame {
11
22
  private screenWidth;
@@ -24,7 +35,7 @@ export declare class Painter extends Frame {
24
35
  registerImage(moniker: string, fileName: string): void;
25
36
  registerFont(moniker: string, fileName: string): void;
26
37
  setScreenSize(sw: number, sh: number): void;
27
- setCoAlignment(coAlignment: string): void;
38
+ setCoAlignment(coAlignment: TCoAlignment): void;
28
39
  protected layoutChanged(): void;
29
40
  display(scale?: number): Promise<void>;
30
41
  hide(): Promise<void>;
@@ -87,6 +87,9 @@ class Painter extends Frame_1.Frame {
87
87
  let lastCachedLayer;
88
88
  for (let i = 0; i < this.layers.length; i++) {
89
89
  const layer = this.layers[i];
90
+ if (layer === undefined) {
91
+ continue;
92
+ }
90
93
  if (layer.cairoCache !== undefined &&
91
94
  layer.surfaceCache !== undefined &&
92
95
  surface === undefined &&
@@ -120,7 +123,7 @@ class Painter extends Frame_1.Frame {
120
123
  }
121
124
  for (let i = layerIdx; i < this.layers.length; i++) {
122
125
  const currentLayer = this.layers[i];
123
- if (currentLayer.surfaceCache !== undefined && currentLayer.cairoCache !== undefined) {
126
+ if (currentLayer?.surfaceCache !== undefined && currentLayer.cairoCache !== undefined) {
124
127
  await this.cleanupSurface(currentLayer.surfaceCache, currentLayer.cairoCache);
125
128
  currentLayer.surfaceCache = undefined;
126
129
  currentLayer.cairoCache = undefined;
@@ -17,30 +17,26 @@ class ResourceManager {
17
17
  this.fontFileNames[moniker] = process.env.INSTALL_PATH + '/fonts/' + fileName;
18
18
  }
19
19
  async image(moniker) {
20
- if (moniker in this.images) {
20
+ if (this.images[moniker] !== undefined) {
21
21
  return this.images[moniker];
22
22
  }
23
- else if (moniker in this.imgFileNames) {
23
+ if (this.imgFileNames[moniker] !== undefined) {
24
24
  const imgData = await fs.readFile(this.imgFileNames[moniker]);
25
25
  this.images[moniker] = await this.co.uploadImageData(imgData);
26
26
  return this.images[moniker];
27
27
  }
28
- else {
29
- throw new Error('Error! Unknown image requested!');
30
- }
28
+ throw new Error('Error! Unknown image requested!');
31
29
  }
32
30
  async font(moniker) {
33
- if (moniker in this.fonts) {
31
+ if (this.fonts[moniker] !== undefined) {
34
32
  return this.fonts[moniker];
35
33
  }
36
- else if (moniker in this.fontFileNames) {
34
+ if (this.fontFileNames[moniker] !== undefined) {
37
35
  const fontData = await fs.readFile(this.fontFileNames[moniker]);
38
36
  this.fonts[moniker] = await this.co.uploadFontData(fontData);
39
37
  return this.fonts[moniker];
40
38
  }
41
- else {
42
- throw new Error('Error! Unknown font requested!');
43
- }
39
+ throw new Error('Error! Unknown font requested!');
44
40
  }
45
41
  clear() {
46
42
  this.images = {};
@@ -91,10 +91,10 @@ class CamScripterAPICameraEventsGenerator extends EventEmitter {
91
91
  }
92
92
  if (dataJSON.call_id !== undefined) {
93
93
  if (errorResponse !== undefined) {
94
- this.sendMessages[dataJSON.call_id].reject(new Error(errorResponse.error));
94
+ this.sendMessages[dataJSON.call_id]?.reject(new Error(errorResponse.error));
95
95
  }
96
96
  else {
97
- this.sendMessages[dataJSON.call_id].resolve(dataJSON);
97
+ this.sendMessages[dataJSON.call_id]?.resolve(dataJSON);
98
98
  }
99
99
  delete this.sendMessages[dataJSON.call_id];
100
100
  }
@@ -127,6 +127,9 @@ class CamScripterAPICameraEventsGenerator extends EventEmitter {
127
127
  const now = Date.now();
128
128
  for (const callId in this.sendMessages) {
129
129
  const msg = this.sendMessages[callId];
130
+ if (!msg) {
131
+ continue;
132
+ }
130
133
  if (now - msg.sentTimestamp > 10000) {
131
134
  reconnect = true;
132
135
  msg.reject(new Error('Message timeout'));
@@ -150,7 +153,7 @@ class CamScripterAPICameraEventsGenerator extends EventEmitter {
150
153
  }
151
154
  reportClose() {
152
155
  for (const callId in this.sendMessages) {
153
- this.sendMessages[callId].reject(new Error('Connection lost'));
156
+ this.sendMessages[callId]?.reject(new Error('Connection lost'));
154
157
  }
155
158
  this.sendMessages = {};
156
159
  this.emit('close');
@@ -296,16 +296,12 @@ const parseBitrateOptionsToBitrateVapixParams = (firmWareVersion, bitrateMode, c
296
296
  if (bitrateMode === null) {
297
297
  return '';
298
298
  }
299
- if (bitrateMode === 'VBR') {
300
- return 'videobitratemode=vbr';
301
- }
302
- if (bitrateMode === 'MBR') {
303
- return `videobitratemode=mbr&videomaxbitrate=${cameraOptions.maximumBitRate}`;
304
- }
305
- if (bitrateMode === 'ABR') {
306
- return `videobitratemode=abr&videoabrtargetbitrate=${cameraOptions.maximumBitRate}&videoabrretentiontime=${cameraOptions.retentionTime}&videoabrmaxbitrate=${cameraOptions.bitRateLimit}`;
307
- }
308
- throw new Error('Unknown bitrateMode param in getVapixParams method.');
299
+ const data = {
300
+ VBR: 'videobitratemode=vbr',
301
+ MBR: `videobitratemode=mbr&videomaxbitrate=${cameraOptions.maximumBitRate}`,
302
+ ABR: `videobitratemode=abr&videoabrtargetbitrate=${cameraOptions.maximumBitRate}&videoabrretentiontime=${cameraOptions.retentionTime}&videoabrmaxbitrate=${cameraOptions.bitRateLimit}`,
303
+ };
304
+ return data[bitrateMode];
309
305
  };
310
306
  const parseVapixParamsToBitrateOptions = (bitrateVapixParams) => {
311
307
  const params = {};
@@ -316,7 +312,7 @@ const parseVapixParamsToBitrateOptions = (bitrateVapixParams) => {
316
312
  const bitrateMode = params['videobitratemode'] !== undefined ? params['videobitratemode'].toUpperCase() : undefined;
317
313
  const hasLowerFw = bitrateMode === undefined && params['videomaxbitrate'] !== undefined;
318
314
  if (hasLowerFw) {
319
- const maximumBitRate = parseInt(params['videomaxbitrate'], 10);
315
+ const maximumBitRate = parseInt(params['videomaxbitrate'] ?? '0', 10);
320
316
  return {
321
317
  bitrateMode: 'MBR',
322
318
  maximumBitRate: maximumBitRate,
@@ -325,19 +321,19 @@ const parseVapixParamsToBitrateOptions = (bitrateVapixParams) => {
325
321
  };
326
322
  }
327
323
  if (bitrateMode === 'ABR') {
328
- const maximumBitRate = parseInt(params['videoabrtargetbitrate'], 10);
329
- const retentionTime = parseInt(params['videoabrretentiontime'], 10);
330
- const bitrateLimit = parseInt(params['videoabrmaxbitrate'], 10);
324
+ const maximumBitRate = parseInt(params['videoabrtargetbitrate'] ?? '0', 10);
325
+ const retentionTime = parseInt(params['videoabrretentiontime'] ?? '0', 10);
326
+ const bitRateLimit = parseInt(params['videoabrmaxbitrate'] ?? '0', 10);
331
327
  return {
332
- bitrateMode: bitrateMode,
333
- maximumBitRate: maximumBitRate,
334
- retentionTime: retentionTime,
335
- bitRateLimit: bitrateLimit,
328
+ bitrateMode,
329
+ maximumBitRate,
330
+ retentionTime,
331
+ bitRateLimit,
336
332
  };
337
333
  }
338
334
  else if (bitrateMode === 'MBR') {
339
- const maximumBitRate = parseInt(params['videomaxbitrate'], 10);
340
- const oldMaximumBitrateParamValue = parseInt(params['videombrmaxbitrate'], 10);
335
+ const maximumBitRate = params['videomaxbitrate'] !== undefined ? parseInt(params['videomaxbitrate'], 10) : null;
336
+ const oldMaximumBitrateParamValue = parseInt(params['videombrmaxbitrate'] ?? '0', 10);
341
337
  return {
342
338
  bitrateMode: bitrateMode,
343
339
  maximumBitRate: maximumBitRate ?? oldMaximumBitrateParamValue,
package/cjs/VapixAPI.d.ts CHANGED
@@ -1,13 +1,13 @@
1
- import { IClient, TParameters, TResponse } from './internal/common';
1
+ import { IClient, TParameters } from './internal/common';
2
2
  import { TApplication, TAudioSampleRates, TSDCardInfo, TPtzOverview, TCameraPTZItem, TCameraPTZItemData, TAudioDevice } from './types/VapixAPI';
3
3
  import { ProxyClient } from './internal/ProxyClient';
4
4
  import { TCameraImageConfig, TProxyParam } from './types/common';
5
5
  export declare class VapixAPI<Client extends IClient = IClient> {
6
6
  client: ProxyClient<Client>;
7
7
  constructor(client: Client, getProxyUrl: () => string);
8
- getUrlEncoded(proxy: TProxyParam | undefined, path: string, parameters?: TParameters, headers?: Record<string, string>): Promise<TResponse>;
9
- postJson(proxy: TProxyParam | undefined, path: string, jsonData: Record<string, any>, headers?: Record<string, string>): Promise<TResponse>;
10
- getCameraImage(params: TCameraImageConfig, proxy?: TProxyParam): Promise<TResponse>;
8
+ getUrlEncoded(proxy: TProxyParam, path: string, parameters?: TParameters, headers?: Record<string, string>): Promise<import("./internal/common").TResponse>;
9
+ postJson(proxy: TProxyParam, path: string, jsonData: Record<string, any>, headers?: Record<string, string>): Promise<import("./internal/common").TResponse>;
10
+ getCameraImage(params: TCameraImageConfig, proxy?: TProxyParam): Promise<import("./internal/common").TResponse>;
11
11
  getEventDeclarations(proxy?: TProxyParam): Promise<string>;
12
12
  getSupportedAudioSampleRate(proxy?: TProxyParam): Promise<TAudioSampleRates[]>;
13
13
  performAutofocus(proxy?: TProxyParam): Promise<void>;
@@ -16,8 +16,8 @@ export declare class VapixAPI<Client extends IClient = IClient> {
16
16
  unmountSDCard(proxy?: TProxyParam): Promise<number>;
17
17
  private _doSDCardMountAction;
18
18
  fetchSDCardJobProgress(jobId: number, proxy?: TProxyParam): Promise<number>;
19
- downloadCameraReport(proxy?: TProxyParam): Promise<TResponse>;
20
- getSystemLog(proxy?: TProxyParam): Promise<TResponse>;
19
+ downloadCameraReport(proxy?: TProxyParam): Promise<import("./internal/common").TResponse>;
20
+ getSystemLog(proxy?: TProxyParam): Promise<import("./internal/common").TResponse>;
21
21
  getMaxFps(channel: number, proxy?: TProxyParam): Promise<number>;
22
22
  getTimezone(proxy?: TProxyParam): Promise<string>;
23
23
  getDateTimeInfo(proxy?: TProxyParam): Promise<{
@@ -32,7 +32,7 @@ export declare class VapixAPI<Client extends IClient = IClient> {
32
32
  getDevicesSettings(proxy?: TProxyParam): Promise<TAudioDevice[]>;
33
33
  fetchRemoteDeviceInfo<T extends Record<string, any>>(payload: T, proxy?: TProxyParam): Promise<any>;
34
34
  getHeaders(proxy?: TProxyParam): Promise<Record<string, string>>;
35
- setHeaders(headers: Record<string, string>, proxy?: TProxyParam): Promise<TResponse>;
35
+ setHeaders(headers: Record<string, string>, proxy?: TProxyParam): Promise<import("./internal/common").TResponse>;
36
36
  getParameter(paramNames: string | string[], proxy?: TProxyParam): Promise<Record<string, string>>;
37
37
  setParameter(params: Record<string, string | number | boolean>, proxy?: TProxyParam): Promise<boolean>;
38
38
  getGuardTourList(proxy?: TProxyParam): Promise<{
@@ -54,10 +54,10 @@ export declare class VapixAPI<Client extends IClient = IClient> {
54
54
  getPTZPresetList(channel: number, proxy?: TProxyParam): Promise<string[]>;
55
55
  listPTZ(camera: number, proxy?: TProxyParam): Promise<TCameraPTZItem[]>;
56
56
  listPtzVideoSourceOverview(proxy?: TProxyParam): Promise<TPtzOverview>;
57
- goToPreset(channel: number, presetName: string, proxy?: TProxyParam): Promise<TResponse>;
57
+ goToPreset(channel: number, presetName: string, proxy?: TProxyParam): Promise<import("./internal/common").TResponse>;
58
58
  getPtzPosition(camera: number, proxy?: TProxyParam): Promise<TCameraPTZItemData>;
59
59
  getInputState(port: number, proxy?: TProxyParam): Promise<boolean>;
60
- setOutputState(port: number, active: boolean, proxy?: TProxyParam): Promise<TResponse>;
60
+ setOutputState(port: number, active: boolean, proxy?: TProxyParam): Promise<import("./internal/common").TResponse>;
61
61
  getApplicationList(proxy?: TProxyParam): Promise<TApplication[]>;
62
62
  startApplication(applicationID: string, proxy?: TProxyParam): Promise<void>;
63
63
  restartApplication(applicationID: string, proxy?: TProxyParam): Promise<void>;
package/cjs/VapixAPI.js CHANGED
@@ -14,7 +14,7 @@ class VapixAPI {
14
14
  constructor(client, getProxyUrl) {
15
15
  this.client = new ProxyClient_1.ProxyClient(client, getProxyUrl);
16
16
  }
17
- async getUrlEncoded(proxy = null, path, parameters, headers = {}) {
17
+ async getUrlEncoded(proxy, path, parameters, headers = {}) {
18
18
  const data = (0, utils_1.paramToUrl)(parameters);
19
19
  const head = { ...headers, 'Content-Type': 'application/x-www-form-urlencoded' };
20
20
  const res = await this.client.post(proxy, path, data, {}, head);
@@ -23,7 +23,7 @@ class VapixAPI {
23
23
  }
24
24
  return res;
25
25
  }
26
- async postJson(proxy = null, path, jsonData, headers = {}) {
26
+ async postJson(proxy, path, jsonData, headers = {}) {
27
27
  const data = JSON.stringify(jsonData);
28
28
  const head = { ...headers, 'Content-Type': 'application/json' };
29
29
  const res = await this.client.post(proxy, path, data, {}, head);
@@ -234,9 +234,9 @@ class VapixAPI {
234
234
  const gTour = {
235
235
  id: gTourBaseName,
236
236
  camNbr: response[gTourBaseName + '.CamNbr'],
237
- name: response[gTourBaseName + '.Name'],
237
+ name: response[gTourBaseName + '.Name'] ?? 'Guard Tour ' + (i + 1),
238
238
  randomEnabled: response[gTourBaseName + '.RandomEnabled'],
239
- running: response[gTourBaseName + '.Running'],
239
+ running: response[gTourBaseName + '.Running'] ?? 'no',
240
240
  timeBetweenSequences: response[gTourBaseName + '.TimeBetweenSequences'],
241
241
  tour: [],
242
242
  };
@@ -301,8 +301,12 @@ class VapixAPI {
301
301
  });
302
302
  const data = parseCameraPtzResponse(await response.text());
303
303
  const res = {};
304
- Object.keys(data).forEach((camera) => {
305
- res[Number(camera) - 1] = data[Number(camera)].map(({ data: itemData, ...d }) => d);
304
+ Object.keys(data)
305
+ .map(Number)
306
+ .forEach((camera) => {
307
+ if (data[camera] !== undefined) {
308
+ res[camera - 1] = data[camera]?.map(({ data: itemData, ...d }) => d);
309
+ }
306
310
  });
307
311
  return res;
308
312
  }
@@ -326,26 +330,26 @@ class VapixAPI {
326
330
  }
327
331
  async getInputState(port, proxy = null) {
328
332
  const response = await (await this.getUrlEncoded(proxy, '/axis-cgi/io/port.cgi', { checkactive: port.toString() })).text();
329
- return response.split('=')[1].indexOf('active') === 0;
333
+ return response.split('=')[1]?.indexOf('active') === 0;
330
334
  }
331
335
  async setOutputState(port, active, proxy = null) {
332
336
  return this.getUrlEncoded(proxy, '/axis-cgi/io/port.cgi', { action: active ? `${port}:/` : `${port}:\\` });
333
337
  }
334
338
  async getApplicationList(proxy = null) {
335
- const res = await this.getUrlEncoded(proxy, '/axis-cgi/applications/list.cgi');
339
+ const res = await this.client.get(proxy, '/axis-cgi/applications/list.cgi');
336
340
  const xml = await res.text();
337
341
  const result = (await (0, xml2js_1.parseStringPromise)(xml));
338
342
  const apps = [];
339
- for (let i = 0; i < result.reply.application.length; i++) {
343
+ for (const app of result.reply.application) {
340
344
  apps.push({
341
- ...result.reply.application[i].$,
342
- appId: VapixAPI_1.APP_IDS.find((id) => id.toLowerCase() === result.reply.application[i].$.Name.toLowerCase()) ?? null,
345
+ ...app.$,
346
+ appId: VapixAPI_1.APP_IDS.find((id) => id.toLowerCase() === app.$.Name.toLowerCase()) ?? null,
343
347
  });
344
348
  }
345
349
  return apps;
346
350
  }
347
351
  async startApplication(applicationID, proxy = null) {
348
- const res = await this.getUrlEncoded(proxy, '/axis-cgi/applications/control.cgi', {
352
+ const res = await this.client.get(proxy, '/axis-cgi/applications/control.cgi', {
349
353
  package: applicationID.toLowerCase(),
350
354
  action: 'start',
351
355
  });
@@ -355,7 +359,7 @@ class VapixAPI {
355
359
  }
356
360
  }
357
361
  async restartApplication(applicationID, proxy = null) {
358
- const res = await this.getUrlEncoded(proxy, '/axis-cgi/applications/control.cgi', {
362
+ const res = await this.client.get(proxy, '/axis-cgi/applications/control.cgi', {
359
363
  package: applicationID.toLowerCase(),
360
364
  action: 'restart',
361
365
  });
@@ -365,7 +369,7 @@ class VapixAPI {
365
369
  }
366
370
  }
367
371
  async stopApplication(applicationID, proxy = null) {
368
- const res = await this.getUrlEncoded(proxy, '/axis-cgi/applications/control.cgi', {
372
+ const res = await this.client.get(proxy, '/axis-cgi/applications/control.cgi', {
369
373
  package: applicationID.toLowerCase(),
370
374
  action: 'stop',
371
375
  });
@@ -393,14 +397,14 @@ exports.VapixAPI = VapixAPI;
393
397
  const parseParameters = (response) => {
394
398
  const params = {};
395
399
  const lines = response.split(/[\r\n]/);
396
- for (let i = 0; i < lines.length; i++) {
397
- if (lines[i].length === 0 || lines[i].substring(0, 7) === '# Error') {
400
+ for (const line of lines) {
401
+ if (line.length === 0 || line.substring(0, 7) === '# Error') {
398
402
  continue;
399
403
  }
400
- const delimiterPos = lines[i].indexOf('=');
404
+ const delimiterPos = line.indexOf('=');
401
405
  if (delimiterPos !== -1) {
402
- const paramName = lines[i].substring(0, delimiterPos);
403
- const paramValue = lines[i].substring(delimiterPos + 1);
406
+ const paramName = line.substring(0, delimiterPos);
407
+ const paramValue = line.substring(delimiterPos + 1);
404
408
  params[paramName] = paramValue;
405
409
  }
406
410
  }
@@ -446,7 +450,7 @@ const parsePtz = (parsed) => {
446
450
  };
447
451
  res.push({
448
452
  id,
449
- name: data[0],
453
+ name: data[0] ?? 'Preset ' + id,
450
454
  data: {
451
455
  pan: getValue('pan'),
452
456
  tilt: getValue('tilt'),
@@ -42,10 +42,10 @@ class VapixEvents extends eventemitter2_1.EventEmitter2 {
42
42
  this.ws.on('open', () => {
43
43
  const topics = [];
44
44
  const eventNames = this.eventNames();
45
- for (let i = 0; i < eventNames.length; i++) {
46
- if (!this.isReservedEventName(eventNames[i])) {
45
+ for (const eventName of eventNames) {
46
+ if (!this.isReservedEventName(eventName)) {
47
47
  const topic = {
48
- topicFilter: eventNames[i],
48
+ topicFilter: eventName,
49
49
  };
50
50
  topics.push(topic);
51
51
  }
@@ -7,17 +7,17 @@ class Digest {
7
7
  getAuthHeader(user, pass, method, uri, wwwAuthenticateHeader) {
8
8
  const digestItems = {};
9
9
  const digestArr = wwwAuthenticateHeader.substring(wwwAuthenticateHeader.indexOf('Digest') + 6).split(',');
10
- for (let i = 0; i < digestArr.length; i++) {
11
- const pos = digestArr[i].indexOf('=');
12
- const key = digestArr[i].substring(0, pos).trim();
13
- const value = digestArr[i].substring(pos + 1).trim();
10
+ for (const arg of digestArr) {
11
+ const pos = arg.indexOf('=');
12
+ const key = arg.substring(0, pos).trim();
13
+ const value = arg.substring(pos + 1).trim();
14
14
  digestItems[key] = value.replace(/"/g, '');
15
15
  }
16
16
  const HA1 = crypto.createHash('md5').update(`${user}:${digestItems['realm']}:${pass}`).digest('hex');
17
17
  const HA2 = crypto.createHash('md5').update(`${method}:${uri}`).digest('hex');
18
18
  const ncValue = ('00000000' + this.nonceCount.toString(16)).slice(-8);
19
19
  let response;
20
- if (digestItems['qop']) {
20
+ if (digestItems['qop'] !== undefined) {
21
21
  response = crypto
22
22
  .createHash('md5')
23
23
  .update(`${HA1}:${digestItems['nonce']}:${ncValue}:162d50aa594e9648:auth:${HA2}`)
@@ -32,7 +32,7 @@ class Digest {
32
32
  `nonce="${digestItems['nonce']}",` +
33
33
  `uri="${uri}",` +
34
34
  `response="${response}"`;
35
- if (digestItems['qop']) {
35
+ if (digestItems['qop'] !== undefined) {
36
36
  header += `,qop=auth,nc=${ncValue},cnonce="162d50aa594e9648"`;
37
37
  }
38
38
  this.nonceCount++;
@@ -39,7 +39,7 @@ class DefaultClient {
39
39
  return this.httpRequestSender.sendRequest(options, data);
40
40
  }
41
41
  getBaseConnectionParams(method, path, params) {
42
- let pathName = (0, utils_1.addParametersToPath)(path, params);
42
+ const pathName = (0, utils_1.addParametersToPath)(path, params);
43
43
  return {
44
44
  method: method,
45
45
  protocol: this.tls ? 'https:' : 'http:',
@@ -89,7 +89,7 @@ class HttpServer extends EventEmitter {
89
89
  close() {
90
90
  this.server.close();
91
91
  for (const key in this.sockets) {
92
- this.sockets[key].destroy();
92
+ this.sockets[key]?.destroy();
93
93
  }
94
94
  }
95
95
  }
@@ -1509,7 +1509,7 @@ export declare const audioDeviceRequestSchema: z.ZodObject<{
1509
1509
  }>;
1510
1510
  export type TAudioDeviceFromRequest = z.infer<typeof audioDeviceFromRequestSchema>;
1511
1511
  export declare const maxFpsResponseSchema: z.ZodObject<{
1512
- data: z.ZodArray<z.ZodObject<{
1512
+ data: z.ZodOptional<z.ZodArray<z.ZodObject<{
1513
1513
  channel: z.ZodNumber;
1514
1514
  captureMode: z.ZodArray<z.ZodObject<{
1515
1515
  enabled: z.ZodBoolean;
@@ -1533,23 +1533,23 @@ export declare const maxFpsResponseSchema: z.ZodObject<{
1533
1533
  enabled: boolean;
1534
1534
  maxFPS?: number | undefined;
1535
1535
  }[];
1536
- }>, "many">;
1536
+ }>, "many">>;
1537
1537
  }, "strip", z.ZodTypeAny, {
1538
- data: {
1538
+ data?: {
1539
1539
  channel: number;
1540
1540
  captureMode: {
1541
1541
  enabled: boolean;
1542
1542
  maxFPS?: number | undefined;
1543
1543
  }[];
1544
- }[];
1544
+ }[] | undefined;
1545
1545
  }, {
1546
- data: {
1546
+ data?: {
1547
1547
  channel: number;
1548
1548
  captureMode: {
1549
1549
  enabled: boolean;
1550
1550
  maxFPS?: number | undefined;
1551
1551
  }[];
1552
- }[];
1552
+ }[] | undefined;
1553
1553
  }>;
1554
1554
  export declare const dateTimeinfoSchema: z.ZodObject<{
1555
1555
  data: z.ZodObject<{
@@ -1590,8 +1590,8 @@ export declare const dateTimeinfoSchema: z.ZodObject<{
1590
1590
  }>;
1591
1591
  export declare const audioSampleRatesResponseSchema: z.ZodObject<{
1592
1592
  data: z.ZodObject<{
1593
- encoders: z.ZodUnion<[z.ZodObject<{
1594
- aac: z.ZodArray<z.ZodObject<{
1593
+ encoders: z.ZodObject<{
1594
+ aac: z.ZodOptional<z.ZodArray<z.ZodObject<{
1595
1595
  sample_rate: z.ZodNumber;
1596
1596
  bit_rates: z.ZodArray<z.ZodNumber, "many">;
1597
1597
  }, "strip", z.ZodTypeAny, {
@@ -1600,22 +1600,8 @@ export declare const audioSampleRatesResponseSchema: z.ZodObject<{
1600
1600
  }, {
1601
1601
  sample_rate: number;
1602
1602
  bit_rates: number[];
1603
- }>, "many">;
1604
- AAC: z.ZodUndefined;
1605
- }, "strip", z.ZodTypeAny, {
1606
- aac: {
1607
- sample_rate: number;
1608
- bit_rates: number[];
1609
- }[];
1610
- AAC?: undefined;
1611
- }, {
1612
- aac: {
1613
- sample_rate: number;
1614
- bit_rates: number[];
1615
- }[];
1616
- AAC?: undefined;
1617
- }>, z.ZodObject<{
1618
- AAC: z.ZodArray<z.ZodObject<{
1603
+ }>, "many">>;
1604
+ AAC: z.ZodOptional<z.ZodArray<z.ZodObject<{
1619
1605
  sample_rate: z.ZodNumber;
1620
1606
  bit_rates: z.ZodArray<z.ZodNumber, "many">;
1621
1607
  }, "strip", z.ZodTypeAny, {
@@ -1624,80 +1610,73 @@ export declare const audioSampleRatesResponseSchema: z.ZodObject<{
1624
1610
  }, {
1625
1611
  sample_rate: number;
1626
1612
  bit_rates: number[];
1627
- }>, "many">;
1628
- aac: z.ZodUndefined;
1613
+ }>, "many">>;
1629
1614
  }, "strip", z.ZodTypeAny, {
1630
- AAC: {
1615
+ aac?: {
1631
1616
  sample_rate: number;
1632
1617
  bit_rates: number[];
1633
- }[];
1634
- aac?: undefined;
1618
+ }[] | undefined;
1619
+ AAC?: {
1620
+ sample_rate: number;
1621
+ bit_rates: number[];
1622
+ }[] | undefined;
1635
1623
  }, {
1636
- AAC: {
1624
+ aac?: {
1637
1625
  sample_rate: number;
1638
1626
  bit_rates: number[];
1639
- }[];
1640
- aac?: undefined;
1641
- }>]>;
1627
+ }[] | undefined;
1628
+ AAC?: {
1629
+ sample_rate: number;
1630
+ bit_rates: number[];
1631
+ }[] | undefined;
1632
+ }>;
1642
1633
  }, "strip", z.ZodTypeAny, {
1643
1634
  encoders: {
1644
- aac: {
1635
+ aac?: {
1645
1636
  sample_rate: number;
1646
1637
  bit_rates: number[];
1647
- }[];
1648
- AAC?: undefined;
1649
- } | {
1650
- AAC: {
1638
+ }[] | undefined;
1639
+ AAC?: {
1651
1640
  sample_rate: number;
1652
1641
  bit_rates: number[];
1653
- }[];
1654
- aac?: undefined;
1642
+ }[] | undefined;
1655
1643
  };
1656
1644
  }, {
1657
1645
  encoders: {
1658
- aac: {
1646
+ aac?: {
1659
1647
  sample_rate: number;
1660
1648
  bit_rates: number[];
1661
- }[];
1662
- AAC?: undefined;
1663
- } | {
1664
- AAC: {
1649
+ }[] | undefined;
1650
+ AAC?: {
1665
1651
  sample_rate: number;
1666
1652
  bit_rates: number[];
1667
- }[];
1668
- aac?: undefined;
1653
+ }[] | undefined;
1669
1654
  };
1670
1655
  }>;
1671
1656
  }, "strip", z.ZodTypeAny, {
1672
1657
  data: {
1673
1658
  encoders: {
1674
- aac: {
1659
+ aac?: {
1675
1660
  sample_rate: number;
1676
1661
  bit_rates: number[];
1677
- }[];
1678
- AAC?: undefined;
1679
- } | {
1680
- AAC: {
1662
+ }[] | undefined;
1663
+ AAC?: {
1681
1664
  sample_rate: number;
1682
1665
  bit_rates: number[];
1683
- }[];
1684
- aac?: undefined;
1666
+ }[] | undefined;
1685
1667
  };
1686
1668
  };
1687
1669
  }, {
1688
1670
  data: {
1689
1671
  encoders: {
1690
- aac: {
1672
+ aac?: {
1691
1673
  sample_rate: number;
1692
1674
  bit_rates: number[];
1693
- }[];
1694
- AAC?: undefined;
1695
- } | {
1696
- AAC: {
1675
+ }[] | undefined;
1676
+ AAC?: {
1697
1677
  sample_rate: number;
1698
1678
  bit_rates: number[];
1699
- }[];
1700
- aac?: undefined;
1679
+ }[] | undefined;
1701
1680
  };
1702
1681
  };
1703
1682
  }>;