camstreamerlib 3.0.0 → 3.2.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 +5 -10
- package/CamOverlayAPI.js +16 -32
- package/CamOverlayDrawingAPI.d.ts +9 -6
- package/CamOverlayDrawingAPI.js +49 -78
- package/CamOverlayPainter/Frame.js +2 -2
- package/CamOverlayPainter/Painter.d.ts +2 -1
- package/CamOverlayPainter/Painter.js +11 -7
- package/CamScripterAPICameraEventsGenerator.d.ts +11 -5
- package/CamScripterAPICameraEventsGenerator.js +48 -63
- package/CamStreamerAPI.d.ts +32 -14
- package/CamStreamerAPI.js +12 -25
- package/CamSwitcherAPI.d.ts +49 -21
- package/CamSwitcherAPI.js +23 -76
- package/CamSwitcherEvents.d.ts +19 -0
- package/CamSwitcherEvents.js +94 -0
- package/CameraVapix.d.ts +6 -14
- package/CameraVapix.js +24 -107
- package/CreatePackage.js +12 -5
- package/DefaultAgent.d.ts +15 -0
- package/DefaultAgent.js +67 -0
- package/HttpServer.d.ts +2 -0
- package/README.md +11 -1
- package/VapixEvents.d.ts +17 -0
- package/VapixEvents.js +82 -0
- package/events/AxisCameraStationEvents.d.ts +8 -0
- package/events/AxisCameraStationEvents.js +65 -0
- package/internal/HttpRequestSender.d.ts +28 -0
- package/internal/HttpRequestSender.js +114 -0
- package/internal/WsClient.d.ts +7 -4
- package/internal/WsClient.js +63 -30
- package/internal/common.d.ts +16 -1
- package/internal/common.js +9 -0
- package/package.json +4 -3
- package/internal/HttpRequest.d.ts +0 -13
- package/internal/HttpRequest.js +0 -65
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export type HttpRequestOptions = {
|
|
2
|
-
method?: string;
|
|
3
|
-
protocol: string;
|
|
4
|
-
host: string;
|
|
5
|
-
port: number;
|
|
6
|
-
path: string;
|
|
7
|
-
user?: string;
|
|
8
|
-
pass?: string;
|
|
9
|
-
timeout?: number;
|
|
10
|
-
headers?: Record<string, string>;
|
|
11
|
-
rejectUnauthorized?: boolean;
|
|
12
|
-
};
|
|
13
|
-
export declare function sendRequest(options: HttpRequestOptions, postData?: Buffer | string): Promise<Response>;
|
package/internal/HttpRequest.js
DELETED
|
@@ -1,65 +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.sendRequest = sendRequest;
|
|
13
|
-
const Digest_1 = require("./Digest");
|
|
14
|
-
function getURL(options) {
|
|
15
|
-
const url = new URL(options.protocol + options.host + options.path);
|
|
16
|
-
url.port = options.port.toString();
|
|
17
|
-
return url.toString();
|
|
18
|
-
}
|
|
19
|
-
function getDigestHeader(options, digestHeader) {
|
|
20
|
-
var _a, _b;
|
|
21
|
-
if (options.user === undefined || options.pass === undefined) {
|
|
22
|
-
throw new Error('No credentials found');
|
|
23
|
-
}
|
|
24
|
-
(_a = options.method) !== null && _a !== void 0 ? _a : (options.method = 'GET');
|
|
25
|
-
(_b = options.headers) !== null && _b !== void 0 ? _b : (options.headers = {});
|
|
26
|
-
return Digest_1.Digest.getAuthHeader(options.user, options.pass, options.method, options.path, digestHeader);
|
|
27
|
-
}
|
|
28
|
-
function sendRequestWithDigest(options, digestHeader, postData) {
|
|
29
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
-
var _a;
|
|
31
|
-
const url = getURL(options);
|
|
32
|
-
(_a = options.headers) !== null && _a !== void 0 ? _a : (options.headers = {});
|
|
33
|
-
options.headers['Authorization'] = getDigestHeader(options, digestHeader);
|
|
34
|
-
const controller = new AbortController();
|
|
35
|
-
if (options.timeout !== undefined) {
|
|
36
|
-
setTimeout(() => controller.abort(new Error('Request timeout')), options.timeout);
|
|
37
|
-
}
|
|
38
|
-
const req = new Request(url, { body: postData, method: options.method, headers: options.headers });
|
|
39
|
-
const res = yield fetch(req, { signal: controller.signal });
|
|
40
|
-
return res;
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
function sendRequest(options, postData) {
|
|
44
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
-
var _a;
|
|
46
|
-
const url = getURL(options);
|
|
47
|
-
const controller = new AbortController();
|
|
48
|
-
if (options.timeout !== undefined) {
|
|
49
|
-
setTimeout(() => controller.abort(new Error('Request timeout')), options.timeout);
|
|
50
|
-
}
|
|
51
|
-
if (options.user !== undefined && options.pass !== undefined) {
|
|
52
|
-
(_a = options.headers) !== null && _a !== void 0 ? _a : (options.headers = {});
|
|
53
|
-
options.headers['Authorization'] = `Basic ${btoa(options.user + ':' + options.pass)}`;
|
|
54
|
-
}
|
|
55
|
-
const req = new Request(url, { body: postData, method: options.method, headers: options.headers });
|
|
56
|
-
const res = yield fetch(req, { signal: controller.signal });
|
|
57
|
-
const wwwAuthenticateHeader = res.headers.get('www-authenticate');
|
|
58
|
-
if (res.status === 401 && wwwAuthenticateHeader !== null && wwwAuthenticateHeader.indexOf('Digest') !== -1) {
|
|
59
|
-
return sendRequestWithDigest(options, wwwAuthenticateHeader, postData);
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
return res;
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
}
|