@testsmith/api-spector-agent 0.9.7 → 0.9.9
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 +64 -27
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -14457,7 +14457,7 @@ var require_pool = __commonJS({
|
|
|
14457
14457
|
function defaultFactory(origin, opts) {
|
|
14458
14458
|
return new Client(origin, opts);
|
|
14459
14459
|
}
|
|
14460
|
-
var
|
|
14460
|
+
var Pool2 = class extends PoolBase {
|
|
14461
14461
|
constructor(origin, {
|
|
14462
14462
|
connections,
|
|
14463
14463
|
factory = defaultFactory,
|
|
@@ -14530,7 +14530,7 @@ var require_pool = __commonJS({
|
|
|
14530
14530
|
}
|
|
14531
14531
|
}
|
|
14532
14532
|
};
|
|
14533
|
-
module2.exports =
|
|
14533
|
+
module2.exports = Pool2;
|
|
14534
14534
|
}
|
|
14535
14535
|
});
|
|
14536
14536
|
|
|
@@ -14550,7 +14550,7 @@ var require_balanced_pool = __commonJS({
|
|
|
14550
14550
|
kRemoveClient,
|
|
14551
14551
|
kGetDispatcher
|
|
14552
14552
|
} = require_pool_base();
|
|
14553
|
-
var
|
|
14553
|
+
var Pool2 = require_pool();
|
|
14554
14554
|
var { kUrl } = require_symbols();
|
|
14555
14555
|
var util = require_util();
|
|
14556
14556
|
var kFactory = Symbol("factory");
|
|
@@ -14571,7 +14571,7 @@ var require_balanced_pool = __commonJS({
|
|
|
14571
14571
|
return a19;
|
|
14572
14572
|
}
|
|
14573
14573
|
function defaultFactory(origin, opts) {
|
|
14574
|
-
return new
|
|
14574
|
+
return new Pool2(origin, opts);
|
|
14575
14575
|
}
|
|
14576
14576
|
var BalancedPool = class extends PoolBase {
|
|
14577
14577
|
constructor(upstreams = [], { factory = defaultFactory, connect, tls, ...opts } = {}) {
|
|
@@ -14808,7 +14808,7 @@ var require_agent = __commonJS({
|
|
|
14808
14808
|
var { InvalidArgumentError, MaxOriginsReachedError } = require_errors();
|
|
14809
14809
|
var { kClients, kRunning, kClose, kDestroy, kDispatch, kUrl } = require_symbols();
|
|
14810
14810
|
var DispatcherBase = require_dispatcher_base();
|
|
14811
|
-
var
|
|
14811
|
+
var Pool2 = require_pool();
|
|
14812
14812
|
var Client = require_client();
|
|
14813
14813
|
var util = require_util();
|
|
14814
14814
|
var kOnConnect = Symbol("onConnect");
|
|
@@ -14819,7 +14819,7 @@ var require_agent = __commonJS({
|
|
|
14819
14819
|
var kOptions = Symbol("options");
|
|
14820
14820
|
var kOrigins = Symbol("origins");
|
|
14821
14821
|
function defaultFactory(origin, opts) {
|
|
14822
|
-
return opts && opts.connections === 1 ? new Client(origin, opts) : new
|
|
14822
|
+
return opts && opts.connections === 1 ? new Client(origin, opts) : new Pool2(origin, opts);
|
|
14823
14823
|
}
|
|
14824
14824
|
var Agent2 = class extends DispatcherBase {
|
|
14825
14825
|
constructor({ factory = defaultFactory, maxOrigins = Infinity, connect, tls, ...options } = {}) {
|
|
@@ -15441,7 +15441,7 @@ var require_socks5_proxy_agent = __commonJS({
|
|
|
15441
15441
|
var { InvalidArgumentError } = require_errors();
|
|
15442
15442
|
var { Socks5Client, STATES } = require_socks5_client();
|
|
15443
15443
|
var { kDispatch, kClose, kDestroy } = require_symbols();
|
|
15444
|
-
var
|
|
15444
|
+
var Pool2 = require_pool();
|
|
15445
15445
|
var buildConnector = require_connect();
|
|
15446
15446
|
var { debuglog } = require("node:util");
|
|
15447
15447
|
var debug12 = debuglog("undici:socks5-proxy");
|
|
@@ -15564,7 +15564,7 @@ var require_socks5_proxy_agent = __commonJS({
|
|
|
15564
15564
|
const originKey = String(origin);
|
|
15565
15565
|
let pool = this[kPools].get(originKey);
|
|
15566
15566
|
if (!pool || pool.destroyed || pool.closed) {
|
|
15567
|
-
pool = new
|
|
15567
|
+
pool = new Pool2(origin, {
|
|
15568
15568
|
pipelining: opts.pipelining,
|
|
15569
15569
|
connections: opts.connections,
|
|
15570
15570
|
connect: async (connectOpts, callback) => {
|
|
@@ -15640,7 +15640,7 @@ var require_proxy_agent = __commonJS({
|
|
|
15640
15640
|
"use strict";
|
|
15641
15641
|
var { kProxy, kClose, kDestroy, kDispatch } = require_symbols();
|
|
15642
15642
|
var Agent2 = require_agent();
|
|
15643
|
-
var
|
|
15643
|
+
var Pool2 = require_pool();
|
|
15644
15644
|
var DispatcherBase = require_dispatcher_base();
|
|
15645
15645
|
var { InvalidArgumentError, RequestAbortedError, SecureProxyConnectionError } = require_errors();
|
|
15646
15646
|
var buildConnector = require_connect();
|
|
@@ -15658,7 +15658,7 @@ var require_proxy_agent = __commonJS({
|
|
|
15658
15658
|
return protocol4 === "https:" ? 443 : 80;
|
|
15659
15659
|
}
|
|
15660
15660
|
function defaultFactory(origin, opts) {
|
|
15661
|
-
return new
|
|
15661
|
+
return new Pool2(origin, opts);
|
|
15662
15662
|
}
|
|
15663
15663
|
var noop = () => {
|
|
15664
15664
|
};
|
|
@@ -15666,7 +15666,7 @@ var require_proxy_agent = __commonJS({
|
|
|
15666
15666
|
if (opts.connections === 1) {
|
|
15667
15667
|
return new Client(origin, opts);
|
|
15668
15668
|
}
|
|
15669
|
-
return new
|
|
15669
|
+
return new Pool2(origin, opts);
|
|
15670
15670
|
}
|
|
15671
15671
|
var Http1ProxyWrapper = class extends DispatcherBase {
|
|
15672
15672
|
#client;
|
|
@@ -18558,7 +18558,7 @@ var require_mock_pool = __commonJS({
|
|
|
18558
18558
|
"node_modules/undici/lib/mock/mock-pool.js"(exports2, module2) {
|
|
18559
18559
|
"use strict";
|
|
18560
18560
|
var { promisify } = require("node:util");
|
|
18561
|
-
var
|
|
18561
|
+
var Pool2 = require_pool();
|
|
18562
18562
|
var { buildMockDispatch } = require_mock_utils();
|
|
18563
18563
|
var {
|
|
18564
18564
|
kDispatches,
|
|
@@ -18573,7 +18573,7 @@ var require_mock_pool = __commonJS({
|
|
|
18573
18573
|
var { MockInterceptor } = require_mock_interceptor();
|
|
18574
18574
|
var Symbols = require_symbols();
|
|
18575
18575
|
var { InvalidArgumentError } = require_errors();
|
|
18576
|
-
var MockPool = class extends
|
|
18576
|
+
var MockPool = class extends Pool2 {
|
|
18577
18577
|
constructor(origin, opts) {
|
|
18578
18578
|
if (!opts || !opts.agent || typeof opts.agent.dispatch !== "function") {
|
|
18579
18579
|
throw new InvalidArgumentError("Argument opts.agent must implement Agent");
|
|
@@ -31120,7 +31120,7 @@ var require_undici = __commonJS({
|
|
|
31120
31120
|
"use strict";
|
|
31121
31121
|
var Client = require_client();
|
|
31122
31122
|
var Dispatcher = require_dispatcher();
|
|
31123
|
-
var
|
|
31123
|
+
var Pool2 = require_pool();
|
|
31124
31124
|
var BalancedPool = require_balanced_pool();
|
|
31125
31125
|
var RoundRobinPool = require_round_robin_pool();
|
|
31126
31126
|
var Agent2 = require_agent();
|
|
@@ -31147,7 +31147,7 @@ var require_undici = __commonJS({
|
|
|
31147
31147
|
Object.assign(Dispatcher.prototype, api);
|
|
31148
31148
|
module2.exports.Dispatcher = Dispatcher;
|
|
31149
31149
|
module2.exports.Client = Client;
|
|
31150
|
-
module2.exports.Pool =
|
|
31150
|
+
module2.exports.Pool = Pool2;
|
|
31151
31151
|
module2.exports.BalancedPool = BalancedPool;
|
|
31152
31152
|
module2.exports.RoundRobinPool = RoundRobinPool;
|
|
31153
31153
|
module2.exports.Agent = Agent2;
|
|
@@ -74293,7 +74293,7 @@ async function getSecret(ref) {
|
|
|
74293
74293
|
}
|
|
74294
74294
|
|
|
74295
74295
|
// src/shared/url-params.ts
|
|
74296
|
-
var PATH_PARAM_PATTERN = String.raw`\[([A-Za-z_]\w*)\]|(?<!\{)\{([A-Za-z_]\w*)\}(?!\})`;
|
|
74296
|
+
var PATH_PARAM_PATTERN = String.raw`\[([A-Za-z_]\w*)\]|(?<!\{)\{([A-Za-z_]\w*)\}(?!\})|:([A-Za-z_]\w*)`;
|
|
74297
74297
|
var PATH_PARAM_RE = new RegExp(PATH_PARAM_PATTERN, "g");
|
|
74298
74298
|
|
|
74299
74299
|
// src/main/interpolation.ts
|
|
@@ -74355,8 +74355,8 @@ function buildUrl(baseUrl, params, vars) {
|
|
|
74355
74355
|
templateTokens.add(String(name).trim());
|
|
74356
74356
|
return "";
|
|
74357
74357
|
});
|
|
74358
|
-
baseUrl.replaceAll(PATH_PARAM_RE2, (_m, g1, g22) => {
|
|
74359
|
-
templateTokens.add(g1 ?? g22);
|
|
74358
|
+
baseUrl.replaceAll(PATH_PARAM_RE2, (_m, g1, g22, g32) => {
|
|
74359
|
+
templateTokens.add(g1 ?? g22 ?? g32);
|
|
74360
74360
|
return "";
|
|
74361
74361
|
});
|
|
74362
74362
|
const enabled = (params ?? []).filter((p6) => p6.enabled && p6.key);
|
|
@@ -74372,8 +74372,8 @@ function buildUrl(baseUrl, params, vars) {
|
|
|
74372
74372
|
...Object.fromEntries(pathRows.map((p6) => [p6.key, interpolate(p6.value, vars)]))
|
|
74373
74373
|
} : vars;
|
|
74374
74374
|
let url2 = interpolate(baseUrl, mergedVars);
|
|
74375
|
-
url2 = url2.replaceAll(PATH_PARAM_RE2, (m6, g1, g22) => {
|
|
74376
|
-
const name = g1 ?? g22;
|
|
74375
|
+
url2 = url2.replaceAll(PATH_PARAM_RE2, (m6, g1, g22, g32) => {
|
|
74376
|
+
const name = g1 ?? g22 ?? g32;
|
|
74377
74377
|
return name in mergedVars ? mergedVars[name] : m6;
|
|
74378
74378
|
});
|
|
74379
74379
|
if (!queryRows.length) return url2;
|
|
@@ -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) ?? "";
|
|
@@ -80866,6 +80866,25 @@ function defaultAgent() {
|
|
|
80866
80866
|
_defaultAgent ??= new import_undici.Agent({ allowH2: true });
|
|
80867
80867
|
return _defaultAgent;
|
|
80868
80868
|
}
|
|
80869
|
+
function isLoopbackHost(host) {
|
|
80870
|
+
const h6 = host.toLowerCase().replace(/^\[|\]$/g, "");
|
|
80871
|
+
return h6 === "localhost" || h6.endsWith(".localhost") || h6 === "::1" || h6 === "0.0.0.0" || /^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(h6);
|
|
80872
|
+
}
|
|
80873
|
+
function noProxyList() {
|
|
80874
|
+
return (process.env["NO_PROXY"] ?? process.env["no_proxy"] ?? "").split(",").map((s8) => s8.trim().toLowerCase()).filter(Boolean);
|
|
80875
|
+
}
|
|
80876
|
+
function matchesNoProxy(host, list) {
|
|
80877
|
+
const h6 = host.toLowerCase().replace(/^\[|\]$/g, "");
|
|
80878
|
+
for (const entry of list) {
|
|
80879
|
+
if (entry === "*") return true;
|
|
80880
|
+
const e9 = entry.replace(/^\*?\.?/, "");
|
|
80881
|
+
if (h6 === e9 || h6.endsWith("." + e9)) return true;
|
|
80882
|
+
}
|
|
80883
|
+
return false;
|
|
80884
|
+
}
|
|
80885
|
+
function shouldBypassProxy(host, noProxy) {
|
|
80886
|
+
return isLoopbackHost(host) || matchesNoProxy(host, noProxy);
|
|
80887
|
+
}
|
|
80869
80888
|
async function buildDispatcher(proxy, tls) {
|
|
80870
80889
|
if (proxy?.url?.trim()) trustSystemCertificateStore();
|
|
80871
80890
|
const connectOpts = {};
|
|
@@ -80895,11 +80914,29 @@ async function buildDispatcher(proxy, tls) {
|
|
|
80895
80914
|
}
|
|
80896
80915
|
}
|
|
80897
80916
|
if (proxy?.url?.trim()) {
|
|
80898
|
-
|
|
80899
|
-
|
|
80900
|
-
|
|
80901
|
-
|
|
80902
|
-
|
|
80917
|
+
const uri = buildProxyUri({ url: proxy.url, auth: proxy.auth });
|
|
80918
|
+
const noProxy = noProxyList();
|
|
80919
|
+
return new import_undici.Agent({
|
|
80920
|
+
allowH2: true,
|
|
80921
|
+
factory: (origin) => {
|
|
80922
|
+
let host = "";
|
|
80923
|
+
try {
|
|
80924
|
+
host = (typeof origin === "string" ? new URL(origin) : origin).hostname;
|
|
80925
|
+
} catch {
|
|
80926
|
+
}
|
|
80927
|
+
if (shouldBypassProxy(host, noProxy)) {
|
|
80928
|
+
return new import_undici.Pool(origin, {
|
|
80929
|
+
allowH2: true,
|
|
80930
|
+
...hasTls ? { connect: connectOpts } : {}
|
|
80931
|
+
});
|
|
80932
|
+
}
|
|
80933
|
+
return new import_undici.ProxyAgent({
|
|
80934
|
+
uri,
|
|
80935
|
+
requestTls: hasTls ? connectOpts : void 0,
|
|
80936
|
+
proxyTls: hasTls ? connectOpts : void 0,
|
|
80937
|
+
allowH2: true
|
|
80938
|
+
});
|
|
80939
|
+
}
|
|
80903
80940
|
});
|
|
80904
80941
|
}
|
|
80905
80942
|
if (hasTls) {
|
|
@@ -81491,7 +81528,7 @@ var APP_URL = (process.env.APP_URL || "").replace(/\/+$/, "");
|
|
|
81491
81528
|
var AGENT_TOKEN = process.env.AGENT_TOKEN || "";
|
|
81492
81529
|
var RUNTIME_TOKEN = process.env.RUNTIME_TOKEN || "";
|
|
81493
81530
|
var POLL_MS = Number(process.env.POLL_INTERVAL_MS || 5e3);
|
|
81494
|
-
var VERSION = true ? "0.9.
|
|
81531
|
+
var VERSION = true ? "0.9.9" : "";
|
|
81495
81532
|
var authHeaders = AGENT_TOKEN ? { Authorization: `Bearer ${AGENT_TOKEN}` } : RUNTIME_TOKEN ? { "X-Runtime-Token": RUNTIME_TOKEN } : {};
|
|
81496
81533
|
async function postResult(m6, fields) {
|
|
81497
81534
|
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.9",
|
|
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",
|