@testsmith/api-spector-agent 0.9.8 → 0.9.10
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 +30 -23
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -80651,7 +80651,7 @@ async function fetchOAuth2Token(auth, vars) {
|
|
|
80651
80651
|
params.set("grant_type", flow === "password" ? "password" : "client_credentials");
|
|
80652
80652
|
params.set("client_id", clientId);
|
|
80653
80653
|
params.set("client_secret", clientSecret);
|
|
80654
|
-
if (auth.oauth2Scopes) params.set("scope", auth.oauth2Scopes);
|
|
80654
|
+
if (auth.oauth2Scopes) params.set("scope", interpolate(auth.oauth2Scopes, vars));
|
|
80655
80655
|
if (flow === "password") {
|
|
80656
80656
|
let password = auth.password ?? "";
|
|
80657
80657
|
if (!password && auth.passwordSecretRef) password = await getSecret(auth.passwordSecretRef) ?? "";
|
|
@@ -80885,8 +80885,17 @@ function matchesNoProxy(host, list) {
|
|
|
80885
80885
|
function shouldBypassProxy(host, noProxy) {
|
|
80886
80886
|
return isLoopbackHost(host) || matchesNoProxy(host, noProxy);
|
|
80887
80887
|
}
|
|
80888
|
+
var _dispatcherCache = /* @__PURE__ */ new Map();
|
|
80888
80889
|
async function buildDispatcher(proxy, tls) {
|
|
80889
|
-
|
|
80890
|
+
const hasProxy = !!proxy?.url?.trim();
|
|
80891
|
+
if (!hasProxy && !tls) return defaultAgent();
|
|
80892
|
+
const key = JSON.stringify({
|
|
80893
|
+
proxy: hasProxy ? { url: proxy.url, auth: proxy.auth } : null,
|
|
80894
|
+
tls: tls ?? null
|
|
80895
|
+
});
|
|
80896
|
+
const cached2 = _dispatcherCache.get(key);
|
|
80897
|
+
if (cached2) return cached2;
|
|
80898
|
+
if (hasProxy) trustSystemCertificateStore();
|
|
80890
80899
|
const connectOpts = {};
|
|
80891
80900
|
let hasTls = false;
|
|
80892
80901
|
if (tls) {
|
|
@@ -80894,29 +80903,27 @@ async function buildDispatcher(proxy, tls) {
|
|
|
80894
80903
|
if (tls.rejectUnauthorized !== void 0) {
|
|
80895
80904
|
connectOpts["rejectUnauthorized"] = tls.rejectUnauthorized;
|
|
80896
80905
|
}
|
|
80897
|
-
|
|
80906
|
+
const unreadable = [];
|
|
80907
|
+
const readInto = async (field, path) => {
|
|
80908
|
+
if (!path) return;
|
|
80898
80909
|
try {
|
|
80899
|
-
connectOpts[
|
|
80900
|
-
} catch {
|
|
80901
|
-
}
|
|
80902
|
-
}
|
|
80903
|
-
if (tls.clientCertPath) {
|
|
80904
|
-
try {
|
|
80905
|
-
connectOpts["cert"] = await (0, import_promises2.readFile)(tls.clientCertPath);
|
|
80906
|
-
} catch {
|
|
80907
|
-
}
|
|
80908
|
-
}
|
|
80909
|
-
if (tls.clientKeyPath) {
|
|
80910
|
-
try {
|
|
80911
|
-
connectOpts["key"] = await (0, import_promises2.readFile)(tls.clientKeyPath);
|
|
80910
|
+
connectOpts[field] = await (0, import_promises2.readFile)(path);
|
|
80912
80911
|
} catch {
|
|
80912
|
+
unreadable.push(path);
|
|
80913
80913
|
}
|
|
80914
|
+
};
|
|
80915
|
+
await readInto("ca", tls.caCertPath);
|
|
80916
|
+
await readInto("cert", tls.clientCertPath);
|
|
80917
|
+
await readInto("key", tls.clientKeyPath);
|
|
80918
|
+
if (unreadable.length) {
|
|
80919
|
+
throw new Error(`TLS certificate file(s) not readable: ${unreadable.join(", ")}`);
|
|
80914
80920
|
}
|
|
80915
80921
|
}
|
|
80916
|
-
|
|
80922
|
+
let dispatcher;
|
|
80923
|
+
if (hasProxy) {
|
|
80917
80924
|
const uri = buildProxyUri({ url: proxy.url, auth: proxy.auth });
|
|
80918
80925
|
const noProxy = noProxyList();
|
|
80919
|
-
|
|
80926
|
+
dispatcher = new import_undici.Agent({
|
|
80920
80927
|
allowH2: true,
|
|
80921
80928
|
factory: (origin) => {
|
|
80922
80929
|
let host = "";
|
|
@@ -80938,11 +80945,11 @@ async function buildDispatcher(proxy, tls) {
|
|
|
80938
80945
|
});
|
|
80939
80946
|
}
|
|
80940
80947
|
});
|
|
80948
|
+
} else {
|
|
80949
|
+
dispatcher = new import_undici.Agent({ connect: connectOpts, allowH2: true });
|
|
80941
80950
|
}
|
|
80942
|
-
|
|
80943
|
-
|
|
80944
|
-
}
|
|
80945
|
-
return defaultAgent();
|
|
80951
|
+
_dispatcherCache.set(key, dispatcher);
|
|
80952
|
+
return dispatcher;
|
|
80946
80953
|
}
|
|
80947
80954
|
function buildBodyAndApplyHeaders(req, vars, headers) {
|
|
80948
80955
|
let body;
|
|
@@ -81528,7 +81535,7 @@ var APP_URL = (process.env.APP_URL || "").replace(/\/+$/, "");
|
|
|
81528
81535
|
var AGENT_TOKEN = process.env.AGENT_TOKEN || "";
|
|
81529
81536
|
var RUNTIME_TOKEN = process.env.RUNTIME_TOKEN || "";
|
|
81530
81537
|
var POLL_MS = Number(process.env.POLL_INTERVAL_MS || 5e3);
|
|
81531
|
-
var VERSION = true ? "0.9.
|
|
81538
|
+
var VERSION = true ? "0.9.10" : "";
|
|
81532
81539
|
var authHeaders = AGENT_TOKEN ? { Authorization: `Bearer ${AGENT_TOKEN}` } : RUNTIME_TOKEN ? { "X-Runtime-Token": RUNTIME_TOKEN } : {};
|
|
81533
81540
|
async function postResult(m6, fields) {
|
|
81534
81541
|
await fetch(`${APP_URL}/api/monitor-runtime/${m6.id}/result`, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testsmith/api-spector-agent",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.10",
|
|
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",
|