@testsmith/api-spector-agent 0.6.3 → 0.6.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/dist/index.cjs +40 -39
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -44178,7 +44178,7 @@ var StreamFramer = class {
|
|
|
44178
44178
|
carry = "";
|
|
44179
44179
|
/** Feed a decoded text chunk; returns the frames that completed. */
|
|
44180
44180
|
push(text) {
|
|
44181
|
-
this.carry += text.
|
|
44181
|
+
this.carry += text.replaceAll(/\r\n?/g, "\n");
|
|
44182
44182
|
return this.mode === "sse" ? this.drainSse() : this.drainNdjson();
|
|
44183
44183
|
}
|
|
44184
44184
|
/** Emit whatever remains once the stream closes (a last line/block with no
|
|
@@ -44241,7 +44241,7 @@ var StreamFramer = class {
|
|
|
44241
44241
|
function toEvent(frame, kind, seq, tMs) {
|
|
44242
44242
|
let json;
|
|
44243
44243
|
const trimmed = frame.data.trim();
|
|
44244
|
-
if (trimmed && (trimmed
|
|
44244
|
+
if (trimmed && (trimmed.startsWith("{") || trimmed.startsWith("["))) {
|
|
44245
44245
|
try {
|
|
44246
44246
|
json = JSON.parse(trimmed);
|
|
44247
44247
|
} catch {
|
|
@@ -44335,7 +44335,7 @@ async function readStream(body, kind, startMs, opts = {}) {
|
|
|
44335
44335
|
} catch {
|
|
44336
44336
|
}
|
|
44337
44337
|
}
|
|
44338
|
-
return { events, text, close, firstEventMs: firstEventMs
|
|
44338
|
+
return { events, text, close, firstEventMs: Math.max(firstEventMs, 0) };
|
|
44339
44339
|
}
|
|
44340
44340
|
|
|
44341
44341
|
// src/main/secrets/registry.ts
|
|
@@ -44530,13 +44530,13 @@ function sha256hex(data) {
|
|
|
44530
44530
|
return (0, import_node_crypto.createHash)("sha256").update(data, "utf8").digest("hex");
|
|
44531
44531
|
}
|
|
44532
44532
|
function signSigV4(input) {
|
|
44533
|
-
const amzDate = input.now.toISOString().
|
|
44533
|
+
const amzDate = input.now.toISOString().replaceAll(/[:-]|\.\d{3}/g, "");
|
|
44534
44534
|
const dateStamp = amzDate.slice(0, 8);
|
|
44535
44535
|
const headers = { ...input.headers, host: input.host, "x-amz-date": amzDate };
|
|
44536
44536
|
if (input.sessionToken) headers["x-amz-security-token"] = input.sessionToken;
|
|
44537
44537
|
const lower = {};
|
|
44538
|
-
for (const k68 of Object.keys(headers)) lower[k68.toLowerCase()] = headers[k68].trim().
|
|
44539
|
-
const sortedKeys = Object.keys(lower).sort();
|
|
44538
|
+
for (const k68 of Object.keys(headers)) lower[k68.toLowerCase()] = headers[k68].trim().replaceAll(/\s+/g, " ");
|
|
44539
|
+
const sortedKeys = Object.keys(lower).sort((a38, b69) => a38.localeCompare(b69));
|
|
44540
44540
|
const canonicalHeaders = sortedKeys.map((k68) => `${k68}:${lower[k68]}
|
|
44541
44541
|
`).join("");
|
|
44542
44542
|
const signedHeaders = sortedKeys.join(";");
|
|
@@ -44795,7 +44795,7 @@ async function resolve3(refBody) {
|
|
|
44795
44795
|
if (!sectionLabel) return true;
|
|
44796
44796
|
return String(f74?.section?.label ?? "").toLowerCase() === sectionLabel.toLowerCase();
|
|
44797
44797
|
});
|
|
44798
|
-
if (
|
|
44798
|
+
if (match?.value === void 0) {
|
|
44799
44799
|
throw new Error(`1Password: field '${fieldLabel}' not found on item '${item}'`);
|
|
44800
44800
|
}
|
|
44801
44801
|
return String(match.value);
|
|
@@ -44829,7 +44829,7 @@ async function getSecret(ref) {
|
|
|
44829
44829
|
const stored = secretStore[ref];
|
|
44830
44830
|
if (stored) {
|
|
44831
44831
|
const ss = getSafeStorage();
|
|
44832
|
-
if (ss
|
|
44832
|
+
if (ss?.isEncryptionAvailable()) {
|
|
44833
44833
|
try {
|
|
44834
44834
|
return ss.decryptString(Buffer.from(stored, "base64"));
|
|
44835
44835
|
} catch {
|
|
@@ -44841,10 +44841,10 @@ async function getSecret(ref) {
|
|
|
44841
44841
|
|
|
44842
44842
|
// src/main/interpolation.ts
|
|
44843
44843
|
var import_dayjs2 = __toESM(require_dayjs_min());
|
|
44844
|
-
var vm = __toESM(require("vm"));
|
|
44844
|
+
var vm = __toESM(require("node:vm"));
|
|
44845
44845
|
var _fakerCache = null;
|
|
44846
44846
|
async function getFaker() {
|
|
44847
|
-
|
|
44847
|
+
_fakerCache ??= await Promise.resolve().then(() => (init_dist(), dist_exports));
|
|
44848
44848
|
return _fakerCache.faker;
|
|
44849
44849
|
}
|
|
44850
44850
|
var _exprContext = null;
|
|
@@ -44873,7 +44873,7 @@ async function buildDynamicVars() {
|
|
|
44873
44873
|
};
|
|
44874
44874
|
}
|
|
44875
44875
|
function interpolate(str, vars) {
|
|
44876
|
-
return str.
|
|
44876
|
+
return str.replaceAll(/\{\{([^}]+)\}\}/g, (match, key) => {
|
|
44877
44877
|
const trimmed = key.trim();
|
|
44878
44878
|
if (trimmed in vars) return vars[trimmed];
|
|
44879
44879
|
if (_exprContext && (trimmed.includes(".") || trimmed.includes("("))) {
|
|
@@ -44893,7 +44893,7 @@ function resolveDataRow(row, scope) {
|
|
|
44893
44893
|
}
|
|
44894
44894
|
function buildUrl(baseUrl, params, vars) {
|
|
44895
44895
|
const templateTokens = /* @__PURE__ */ new Set();
|
|
44896
|
-
baseUrl.
|
|
44896
|
+
baseUrl.replaceAll(/\{\{([^}]+)\}\}/g, (_m, name) => {
|
|
44897
44897
|
templateTokens.add(String(name).trim());
|
|
44898
44898
|
return "";
|
|
44899
44899
|
});
|
|
@@ -44920,8 +44920,8 @@ function mergeVars(envVars, collectionVars, globals2, localVars = {}, dynamicVar
|
|
|
44920
44920
|
}
|
|
44921
44921
|
|
|
44922
44922
|
// src/main/script-runner.ts
|
|
44923
|
-
var vm3 = __toESM(require("vm"));
|
|
44924
|
-
var crypto = __toESM(require("crypto"));
|
|
44923
|
+
var vm3 = __toESM(require("node:vm"));
|
|
44924
|
+
var crypto = __toESM(require("node:crypto"));
|
|
44925
44925
|
var import_dayjs3 = __toESM(require_dayjs_min());
|
|
44926
44926
|
var import_tv4 = __toESM(require_tv4());
|
|
44927
44927
|
|
|
@@ -46631,14 +46631,14 @@ function xmlFindAll(node, tag, nth) {
|
|
|
46631
46631
|
}
|
|
46632
46632
|
function xmlQuerySelector(root, selector) {
|
|
46633
46633
|
const parts = selector.trim().split(/\s*>\s*/);
|
|
46634
|
-
const m0 =
|
|
46634
|
+
const m0 = /^([A-Za-z0-9_:.-]+?)(?::nth-of-type\((\d+)\))?$/.exec(parts[0]);
|
|
46635
46635
|
if (!m0) return null;
|
|
46636
|
-
let candidates = xmlFindAll(root, m0[1], m0[2] ? parseInt(m0[2]) - 1 : 0);
|
|
46636
|
+
let candidates = xmlFindAll(root, m0[1], m0[2] ? Number.parseInt(m0[2]) - 1 : 0);
|
|
46637
46637
|
for (let i68 = 1; i68 < parts.length; i68++) {
|
|
46638
|
-
const m75 =
|
|
46638
|
+
const m75 = /^([A-Za-z0-9_:.-]+?)(?::nth-of-type\((\d+)\))?$/.exec(parts[i68]);
|
|
46639
46639
|
if (!m75) return null;
|
|
46640
46640
|
const tag = m75[1];
|
|
46641
|
-
const idx = m75[2] ? parseInt(m75[2]) - 1 : 0;
|
|
46641
|
+
const idx = m75[2] ? Number.parseInt(m75[2]) - 1 : 0;
|
|
46642
46642
|
const next = [];
|
|
46643
46643
|
for (const node of candidates) {
|
|
46644
46644
|
const children = Array.from(node.childNodes).filter((c70) => c70.nodeType === 1 && c70.tagName === tag);
|
|
@@ -46659,7 +46659,7 @@ function makeSandboxDOMParser() {
|
|
|
46659
46659
|
}
|
|
46660
46660
|
var _fakerCache2 = null;
|
|
46661
46661
|
async function getFaker2() {
|
|
46662
|
-
|
|
46662
|
+
_fakerCache2 ??= await Promise.resolve().then(() => (init_dist(), dist_exports));
|
|
46663
46663
|
return _fakerCache2.faker;
|
|
46664
46664
|
}
|
|
46665
46665
|
function makeAsserter(value, negated = false) {
|
|
@@ -46858,7 +46858,7 @@ function buildAt(ctx, testResults, consoleOutput) {
|
|
|
46858
46858
|
const period = options?.period ?? 30;
|
|
46859
46859
|
const algorithm = options?.algorithm ?? "sha1";
|
|
46860
46860
|
const base32chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
|
|
46861
|
-
const cleaned = secret.
|
|
46861
|
+
const cleaned = secret.replaceAll(/[\s=-]/g, "").toUpperCase();
|
|
46862
46862
|
let bits = "";
|
|
46863
46863
|
for (const c70 of cleaned) {
|
|
46864
46864
|
const val = base32chars.indexOf(c70);
|
|
@@ -46867,7 +46867,7 @@ function buildAt(ctx, testResults, consoleOutput) {
|
|
|
46867
46867
|
}
|
|
46868
46868
|
const keyBytes = Buffer.alloc(Math.floor(bits.length / 8));
|
|
46869
46869
|
for (let i68 = 0; i68 < keyBytes.length; i68++) {
|
|
46870
|
-
keyBytes[i68] = parseInt(bits.slice(i68 * 8, i68 * 8 + 8), 2);
|
|
46870
|
+
keyBytes[i68] = Number.parseInt(bits.slice(i68 * 8, i68 * 8 + 8), 2);
|
|
46871
46871
|
}
|
|
46872
46872
|
const counter = Math.floor(Date.now() / 1e3 / period);
|
|
46873
46873
|
const counterBuf = Buffer.alloc(8);
|
|
@@ -46946,8 +46946,9 @@ async function runScript(code, ctx, timeoutMs = 5e3) {
|
|
|
46946
46946
|
JSON,
|
|
46947
46947
|
Math,
|
|
46948
46948
|
Date,
|
|
46949
|
-
parseInt,
|
|
46950
|
-
parseFloat,
|
|
46949
|
+
parseInt: Number.parseInt,
|
|
46950
|
+
parseFloat: Number.parseFloat,
|
|
46951
|
+
// isNaN/isFinite intentionally expose the global (coercing) semantics user scripts expect
|
|
46951
46952
|
isNaN,
|
|
46952
46953
|
isFinite,
|
|
46953
46954
|
encodeURIComponent,
|
|
@@ -46983,12 +46984,12 @@ async function runScript(code, ctx, timeoutMs = 5e3) {
|
|
|
46983
46984
|
}
|
|
46984
46985
|
|
|
46985
46986
|
// src/main/globals-store.ts
|
|
46986
|
-
var import_promises = require("fs/promises");
|
|
46987
|
-
var
|
|
46987
|
+
var import_promises = require("node:fs/promises");
|
|
46988
|
+
var import_node_path2 = require("node:path");
|
|
46988
46989
|
var globals = {};
|
|
46989
46990
|
var currentDir = null;
|
|
46990
46991
|
function globalsPath(dir) {
|
|
46991
|
-
return (0,
|
|
46992
|
+
return (0, import_node_path2.join)(dir, "globals.json");
|
|
46992
46993
|
}
|
|
46993
46994
|
async function persistGlobals() {
|
|
46994
46995
|
if (!currentDir) return;
|
|
@@ -46999,12 +47000,12 @@ function patchGlobals(patch) {
|
|
|
46999
47000
|
}
|
|
47000
47001
|
|
|
47001
47002
|
// src/main/auth-builder.ts
|
|
47002
|
-
var
|
|
47003
|
-
var
|
|
47004
|
-
var import_promises2 = require("fs/promises");
|
|
47003
|
+
var import_node_crypto3 = __toESM(require("node:crypto"));
|
|
47004
|
+
var import_node_http = require("node:http");
|
|
47005
|
+
var import_promises2 = require("node:fs/promises");
|
|
47005
47006
|
|
|
47006
47007
|
// src/main/ntlm.ts
|
|
47007
|
-
var
|
|
47008
|
+
var import_node_crypto2 = __toESM(require("node:crypto"));
|
|
47008
47009
|
var SIGNATURE = Buffer.from("NTLMSSP\0", "latin1");
|
|
47009
47010
|
var F_UNICODE = 1;
|
|
47010
47011
|
var F_OEM = 2;
|
|
@@ -47070,7 +47071,7 @@ function md4(msg) {
|
|
|
47070
47071
|
return out;
|
|
47071
47072
|
}
|
|
47072
47073
|
var utf16le = (s71) => Buffer.from(s71, "utf16le");
|
|
47073
|
-
var hmacMd5 = (key, data) =>
|
|
47074
|
+
var hmacMd5 = (key, data) => import_node_crypto2.default.createHmac("md5", key).update(data).digest();
|
|
47074
47075
|
function ntowfv2(user, domain, password) {
|
|
47075
47076
|
const ntHash = md4(utf16le(password));
|
|
47076
47077
|
return hmacMd5(ntHash, utf16le(user.toUpperCase() + domain));
|
|
@@ -47128,7 +47129,7 @@ function computeNtlmV2Response(opts) {
|
|
|
47128
47129
|
function createType3Message(opts) {
|
|
47129
47130
|
const domain = opts.domain ?? "";
|
|
47130
47131
|
const workstation = opts.workstation ?? "";
|
|
47131
|
-
const clientChallenge = opts.clientChallenge ??
|
|
47132
|
+
const clientChallenge = opts.clientChallenge ?? import_node_crypto2.default.randomBytes(8);
|
|
47132
47133
|
const timestamp = filetime(opts.timestamp ?? Date.now());
|
|
47133
47134
|
const { ntResponse, lmResponse } = computeNtlmV2Response({
|
|
47134
47135
|
user: opts.user,
|
|
@@ -47222,7 +47223,7 @@ function parseDigestChallenge(wwwAuth) {
|
|
|
47222
47223
|
};
|
|
47223
47224
|
}
|
|
47224
47225
|
function md5(s71) {
|
|
47225
|
-
return
|
|
47226
|
+
return import_node_crypto3.default.createHash("md5").update(s71).digest("hex");
|
|
47226
47227
|
}
|
|
47227
47228
|
function buildDigestAuthHeader(challenge, username, password, method, uri) {
|
|
47228
47229
|
const { realm, nonce, qop, algorithm, opaque } = challenge;
|
|
@@ -47234,7 +47235,7 @@ function buildDigestAuthHeader(challenge, username, password, method, uri) {
|
|
|
47234
47235
|
let cnonce;
|
|
47235
47236
|
if (qop === "auth" || qop === "auth-int") {
|
|
47236
47237
|
nc = "00000001";
|
|
47237
|
-
cnonce =
|
|
47238
|
+
cnonce = import_node_crypto3.default.randomBytes(8).toString("hex");
|
|
47238
47239
|
response = md5(`${ha1}:${nonce}:${nc}:${cnonce}:${qop}:${ha22}`);
|
|
47239
47240
|
} else {
|
|
47240
47241
|
response = md5(`${ha1}:${nonce}:${ha22}`);
|
|
@@ -47323,7 +47324,7 @@ async function performNtlmRequest(opts) {
|
|
|
47323
47324
|
}
|
|
47324
47325
|
return {
|
|
47325
47326
|
status: statusCode,
|
|
47326
|
-
statusText:
|
|
47327
|
+
statusText: import_node_http.STATUS_CODES[statusCode] ?? "",
|
|
47327
47328
|
headers: { forEach: (cb) => entries.forEach(([k68, v60]) => cb(v60, k68)) },
|
|
47328
47329
|
text: () => Promise.resolve(bodyText)
|
|
47329
47330
|
};
|
|
@@ -47491,11 +47492,11 @@ function maskObject(obj, patterns) {
|
|
|
47491
47492
|
}
|
|
47492
47493
|
function maskHeaders(headers, patterns) {
|
|
47493
47494
|
if (!patterns.length) return headers;
|
|
47494
|
-
const alwaysMask = ["authorization", "cookie", "set-cookie"];
|
|
47495
|
+
const alwaysMask = /* @__PURE__ */ new Set(["authorization", "cookie", "set-cookie"]);
|
|
47495
47496
|
const result = {};
|
|
47496
47497
|
for (const [k68, v60] of Object.entries(headers)) {
|
|
47497
47498
|
const lower = k68.toLowerCase();
|
|
47498
|
-
if (alwaysMask.
|
|
47499
|
+
if (alwaysMask.has(lower) || patterns.some((p74) => lower.includes(p74.toLowerCase()))) {
|
|
47499
47500
|
result[k68] = "[REDACTED]";
|
|
47500
47501
|
} else {
|
|
47501
47502
|
result[k68] = v60;
|
|
@@ -47588,7 +47589,7 @@ function applyRequestDefaults(req) {
|
|
|
47588
47589
|
}
|
|
47589
47590
|
var _defaultAgent;
|
|
47590
47591
|
function defaultAgent() {
|
|
47591
|
-
|
|
47592
|
+
_defaultAgent ??= new import_undici.Agent({ allowH2: true });
|
|
47592
47593
|
return _defaultAgent;
|
|
47593
47594
|
}
|
|
47594
47595
|
async function buildDispatcher(proxy, tls) {
|
|
@@ -47961,7 +47962,7 @@ var APP_URL = (process.env.APP_URL || "").replace(/\/+$/, "");
|
|
|
47961
47962
|
var AGENT_TOKEN = process.env.AGENT_TOKEN || "";
|
|
47962
47963
|
var RUNTIME_TOKEN = process.env.RUNTIME_TOKEN || "";
|
|
47963
47964
|
var POLL_MS = Number(process.env.POLL_INTERVAL_MS || 5e3);
|
|
47964
|
-
var VERSION = true ? "0.6.
|
|
47965
|
+
var VERSION = true ? "0.6.5" : "";
|
|
47965
47966
|
var authHeaders = AGENT_TOKEN ? { Authorization: `Bearer ${AGENT_TOKEN}` } : RUNTIME_TOKEN ? { "X-Runtime-Token": RUNTIME_TOKEN } : {};
|
|
47966
47967
|
async function postResult(m75, fields) {
|
|
47967
47968
|
await fetch(`${APP_URL}/api/monitor-runtime/${m75.id}/result`, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testsmith/api-spector-agent",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.5",
|
|
4
4
|
"description": "API Spector private runner: monitor internal/local APIs the cloud cannot reach, with no inbound connections.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://api-spector.dev",
|