camstreamerlib 2.0.6 → 3.0.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/package.json CHANGED
@@ -1,40 +1,52 @@
1
1
  {
2
2
  "name": "camstreamerlib",
3
- "version": "2.0.6",
3
+ "version": "3.0.0",
4
4
  "description": "Helper library for CamStreamer ACAP applications.",
5
5
  "prettier": "@camstreamer/prettier-config",
6
6
  "dependencies": {
7
7
  "adm-zip": "^0.5.9",
8
- "crypto": "^1.0.1",
9
8
  "eventemitter2": "^5.0.1",
10
9
  "prettify-xml": "^1.2.0",
11
10
  "ws": "^7.4.2",
12
11
  "xml2js": "^0.5.0"
13
12
  },
13
+ "engine": {
14
+ "node": ">=18.0.0"
15
+ },
14
16
  "devDependencies": {
17
+ "@camstreamer/eslint-config": "^1.0.0",
15
18
  "@camstreamer/prettier-config": "^2.0.4",
19
+ "@types/adm-zip": "^0.5.5",
16
20
  "@types/jest": "^28.0.0",
17
- "@types/node": "^18.0.6",
21
+ "@types/node": "^18.19.39",
22
+ "@types/ws": "^8.5.10",
23
+ "@types/xml2js": "^0.4.14",
24
+ "@typescript-eslint/eslint-plugin": "^6.8.0",
25
+ "@typescript-eslint/parser": "^6.8.0",
26
+ "eslint": "^8.51.0",
27
+ "eslint-plugin-deprecation": "^2.0.0",
28
+ "eslint-plugin-unused-imports": "^3.0.0",
18
29
  "jest": "^28.1.3",
19
30
  "npm-run-all": "^4.1.5",
20
31
  "prettier": "^2.7.1",
21
- "rimraf": "^3.0.2",
22
32
  "ts-jest": "^28.0.0",
23
33
  "ts-node": "^10.7.0",
24
- "typescript": "^4.7.4"
34
+ "typescript": "^5.2.2"
25
35
  },
26
36
  "scripts": {
27
37
  "clean": "rimraf dist/*",
28
38
  "build": "npm-run-all clean tsc copyPackage",
29
39
  "tsc": "tsc",
30
40
  "copyPackage": "cp -f LICENSE dist/ && cp -f README.md dist/ && cp -f package.json dist/",
31
- "pretty": "prettier --write \"./{src,doc}/*.{ts,tsx,md}\"",
32
- "pretty:check": "prettier --check \"./{src,doc}/*.{ts,tsx,md}\"",
41
+ "lint": "eslint \"src/**/*.ts\"",
42
+ "lint:fix": "eslint \"src/**/*.ts\" --fix",
43
+ "pretty": "prettier --write \"./{{src,doc}/**/*.{ts,tsx,md},README.md}\"",
44
+ "pretty:check": "prettier --check \"./{{src,doc}/**/*.{ts,tsx,md},README.md}\"",
33
45
  "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
34
46
  },
35
47
  "files": [
36
- "*.js",
37
- "*.ts"
48
+ "/**/*.js",
49
+ "/**/*.ts"
38
50
  ],
39
51
  "repository": {
40
52
  "type": "git",
package/HttpRequest.d.ts DELETED
@@ -1,15 +0,0 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- import * as http from 'http';
4
- export type HttpRequestOptions = {
5
- method?: string;
6
- protocol?: string;
7
- host: string;
8
- port: number;
9
- path?: string;
10
- auth?: string;
11
- timeout?: number;
12
- headers?: any;
13
- rejectUnauthorized?: boolean;
14
- };
15
- export declare function httpRequest(options: HttpRequestOptions, postData?: Buffer | string, noWaitForData?: boolean): Promise<string | http.IncomingMessage>;
package/HttpRequest.js DELETED
@@ -1,88 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.httpRequest = void 0;
13
- const http = require("http");
14
- const https = require("https");
15
- const Digest_1 = require("./Digest");
16
- function httpRequest(options, postData, noWaitForData = false) {
17
- var _a, _b, _c;
18
- var _d;
19
- return __awaiter(this, void 0, void 0, function* () {
20
- options.timeout = (_a = options.timeout) !== null && _a !== void 0 ? _a : 10000;
21
- if (postData !== undefined) {
22
- (_b = options.headers) !== null && _b !== void 0 ? _b : (options.headers = {});
23
- (_c = (_d = options.headers)['Content-Type']) !== null && _c !== void 0 ? _c : (_d['Content-Type'] = 'application/x-www-form-urlencoded');
24
- options.headers['Content-Length'] = Buffer.byteLength(postData);
25
- }
26
- let response = yield request(options, postData, undefined, noWaitForData);
27
- if (response.resp.statusCode == 200) {
28
- return noWaitForData ? response.resp : response.data;
29
- }
30
- else if (response.resp.statusCode == 401) {
31
- if (response.resp.headers['www-authenticate'] != undefined &&
32
- response.resp.headers['www-authenticate'].indexOf('Digest') != -1) {
33
- response = yield request(options, postData, response.resp.headers['www-authenticate'], noWaitForData);
34
- if (response.resp.statusCode == 200) {
35
- return noWaitForData ? response.resp : response.data;
36
- }
37
- }
38
- }
39
- if (noWaitForData) {
40
- throw new Error(`Error: status code: ${response.resp.statusCode}`);
41
- }
42
- else {
43
- throw new Error(`Error: status code: ${response.resp.statusCode}, ${response.data}`);
44
- }
45
- });
46
- }
47
- exports.httpRequest = httpRequest;
48
- function request(options, postData, digestHeader, noWaitForData) {
49
- return new Promise((resolve, reject) => {
50
- var _a, _b;
51
- if (digestHeader != undefined) {
52
- if (options.auth == undefined) {
53
- reject(new Error('No credentials found'));
54
- }
55
- const auth = options.auth.split(':');
56
- delete options.auth;
57
- (_a = options.method) !== null && _a !== void 0 ? _a : (options.method = 'GET');
58
- (_b = options.headers) !== null && _b !== void 0 ? _b : (options.headers = {});
59
- options['headers']['Authorization'] = Digest_1.Digest.getAuthHeader(auth[0], auth[1], options.method, options.path, digestHeader);
60
- }
61
- let client = options.protocol === 'https:' ? https : http;
62
- let req = client
63
- .request(options, (resp) => {
64
- if (!noWaitForData) {
65
- let data = '';
66
- resp.on('data', (chunk) => {
67
- data += chunk;
68
- });
69
- resp.on('end', () => {
70
- resolve({ resp: resp, data: data });
71
- });
72
- }
73
- else {
74
- resolve({ resp: resp });
75
- }
76
- })
77
- .on('error', (err) => {
78
- reject(err);
79
- });
80
- req.on('timeout', () => {
81
- req.destroy(new Error('Request timeout'));
82
- });
83
- if (postData != undefined) {
84
- req.write(postData);
85
- }
86
- req.end();
87
- });
88
- }
File without changes
File without changes