@zixt/host 0.0.92 → 0.0.93
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/dist/index.js +35 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -28,7 +28,7 @@ import { homedir as homedir3 } from "node:os";
|
|
|
28
28
|
// package.json
|
|
29
29
|
var package_default = {
|
|
30
30
|
name: "@zixt/host",
|
|
31
|
-
version: "0.0.
|
|
31
|
+
version: "0.0.93",
|
|
32
32
|
type: "module",
|
|
33
33
|
exports: {
|
|
34
34
|
".": "./src/client.ts",
|
|
@@ -16100,9 +16100,21 @@ var ApiOperationInput = external_exports.object({
|
|
|
16100
16100
|
}
|
|
16101
16101
|
}
|
|
16102
16102
|
});
|
|
16103
|
+
var TryApiAuthentication = external_exports.discriminatedUnion("mode", [
|
|
16104
|
+
external_exports.object({ mode: external_exports.literal("saved") }).strict(),
|
|
16105
|
+
external_exports.object({
|
|
16106
|
+
mode: external_exports.literal("one_time"),
|
|
16107
|
+
alternative: external_exports.array(external_exports.string().min(1).max(120)).min(1).max(20).refine((items) => new Set(items).size === items.length, "Schemes must be unique"),
|
|
16108
|
+
credentials: external_exports.record(
|
|
16109
|
+
external_exports.string().min(1).max(120),
|
|
16110
|
+
external_exports.record(external_exports.string().min(1).max(120), external_exports.string().min(1).max(2e4))
|
|
16111
|
+
)
|
|
16112
|
+
}).strict()
|
|
16113
|
+
]);
|
|
16103
16114
|
var TryApiOperationRequest = external_exports.object({
|
|
16104
16115
|
operationId: external_exports.string().min(1).max(240),
|
|
16105
16116
|
input: ApiOperationInput.default({ path: {}, query: {}, headers: {} }),
|
|
16117
|
+
authentication: TryApiAuthentication.default({ mode: "saved" }),
|
|
16106
16118
|
confirmed: external_exports.boolean().default(false)
|
|
16107
16119
|
}).strict();
|
|
16108
16120
|
var ApiOperationResult = external_exports.object({
|
|
@@ -16110,6 +16122,7 @@ var ApiOperationResult = external_exports.object({
|
|
|
16110
16122
|
status: external_exports.number().int().min(0).max(999).nullable(),
|
|
16111
16123
|
statusText: external_exports.string().max(500),
|
|
16112
16124
|
contentType: external_exports.string().max(500).nullable(),
|
|
16125
|
+
headers: external_exports.record(external_exports.string().min(1).max(200), external_exports.string().max(8e3)).refine((items) => Object.keys(items).length <= 100, "Too many response headers").default({}),
|
|
16113
16126
|
body: external_exports.string().max(2e5),
|
|
16114
16127
|
truncated: external_exports.boolean(),
|
|
16115
16128
|
durationMs: external_exports.number().int().min(0),
|
|
@@ -21788,6 +21801,9 @@ var REQUEST_BODY_LIMIT = 1e6;
|
|
|
21788
21801
|
var REQUEST_URL_LIMIT = 2e4;
|
|
21789
21802
|
var REQUEST_HEADERS_LIMIT = 64e3;
|
|
21790
21803
|
var REQUEST_TIMEOUT_MS2 = 3e4;
|
|
21804
|
+
var RESPONSE_HEADERS_LIMIT = 64e3;
|
|
21805
|
+
var RESPONSE_HEADER_VALUE_LIMIT = 8e3;
|
|
21806
|
+
var RESPONSE_HEADER_COUNT_LIMIT = 100;
|
|
21791
21807
|
var FORBIDDEN_HEADERS = /* @__PURE__ */ new Set([
|
|
21792
21808
|
"authorization",
|
|
21793
21809
|
"cookie",
|
|
@@ -21797,6 +21813,7 @@ var FORBIDDEN_HEADERS = /* @__PURE__ */ new Set([
|
|
|
21797
21813
|
"proxy-authorization",
|
|
21798
21814
|
"transfer-encoding"
|
|
21799
21815
|
]);
|
|
21816
|
+
var PRIVATE_RESPONSE_HEADERS = /* @__PURE__ */ new Set(["set-cookie", "set-cookie2"]);
|
|
21800
21817
|
function operationFor(connection, operationId) {
|
|
21801
21818
|
const operation = connection.operations.find(({ id }) => id === operationId);
|
|
21802
21819
|
if (!operation) throw new Error("That API operation is not available on this connection.");
|
|
@@ -21855,6 +21872,21 @@ async function boundedBody(response) {
|
|
|
21855
21872
|
}
|
|
21856
21873
|
return { body: new TextDecoder("utf-8", { fatal: false }).decode(joined), truncated };
|
|
21857
21874
|
}
|
|
21875
|
+
function boundedHeaders(response) {
|
|
21876
|
+
const result = {};
|
|
21877
|
+
let bytes = 0;
|
|
21878
|
+
for (const [name, rawValue] of response.headers) {
|
|
21879
|
+
const normalized = name.toLowerCase();
|
|
21880
|
+
if (PRIVATE_RESPONSE_HEADERS.has(normalized)) continue;
|
|
21881
|
+
if (Object.keys(result).length >= RESPONSE_HEADER_COUNT_LIMIT) break;
|
|
21882
|
+
const value = rawValue.slice(0, RESPONSE_HEADER_VALUE_LIMIT);
|
|
21883
|
+
const nextBytes = Buffer.byteLength(normalized) + Buffer.byteLength(value);
|
|
21884
|
+
if (bytes + nextBytes > RESPONSE_HEADERS_LIMIT) break;
|
|
21885
|
+
result[normalized] = value;
|
|
21886
|
+
bytes += nextBytes;
|
|
21887
|
+
}
|
|
21888
|
+
return result;
|
|
21889
|
+
}
|
|
21858
21890
|
async function executeApiOperation(input) {
|
|
21859
21891
|
const started = performance.now();
|
|
21860
21892
|
try {
|
|
@@ -21975,6 +22007,7 @@ async function executeApiOperation(input) {
|
|
|
21975
22007
|
status: response.status,
|
|
21976
22008
|
statusText: response.statusText.slice(0, 500),
|
|
21977
22009
|
contentType: response.headers.get("content-type")?.slice(0, 500) ?? null,
|
|
22010
|
+
headers: boundedHeaders(response),
|
|
21978
22011
|
...payload,
|
|
21979
22012
|
durationMs: Math.max(0, Math.round(performance.now() - started)),
|
|
21980
22013
|
error: response.ok ? null : `The API returned HTTP ${response.status}.`
|
|
@@ -21985,6 +22018,7 @@ async function executeApiOperation(input) {
|
|
|
21985
22018
|
status: null,
|
|
21986
22019
|
statusText: "",
|
|
21987
22020
|
contentType: null,
|
|
22021
|
+
headers: {},
|
|
21988
22022
|
body: "",
|
|
21989
22023
|
truncated: false,
|
|
21990
22024
|
durationMs: Math.max(0, Math.round(performance.now() - started)),
|