@testsmith/api-spector-agent 0.9.4 → 0.9.6
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 +105 -47
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -27361,8 +27361,8 @@ var require_cache3 = __commonJS({
|
|
|
27361
27361
|
* @returns {requestResponseList}
|
|
27362
27362
|
*/
|
|
27363
27363
|
#batchCacheOperations(operations) {
|
|
27364
|
-
const
|
|
27365
|
-
const backupCache = [...
|
|
27364
|
+
const cache4 = this.#relevantRequestResponseList;
|
|
27365
|
+
const backupCache = [...cache4];
|
|
27366
27366
|
const addedItems = [];
|
|
27367
27367
|
const resultList = [];
|
|
27368
27368
|
try {
|
|
@@ -27389,9 +27389,9 @@ var require_cache3 = __commonJS({
|
|
|
27389
27389
|
return [];
|
|
27390
27390
|
}
|
|
27391
27391
|
for (const requestResponse of requestResponses) {
|
|
27392
|
-
const idx =
|
|
27392
|
+
const idx = cache4.indexOf(requestResponse);
|
|
27393
27393
|
assert(idx !== -1);
|
|
27394
|
-
|
|
27394
|
+
cache4.splice(idx, 1);
|
|
27395
27395
|
}
|
|
27396
27396
|
} else if (operation.type === "put") {
|
|
27397
27397
|
if (operation.response == null) {
|
|
@@ -27421,11 +27421,11 @@ var require_cache3 = __commonJS({
|
|
|
27421
27421
|
}
|
|
27422
27422
|
requestResponses = this.#queryCache(operation.request);
|
|
27423
27423
|
for (const requestResponse of requestResponses) {
|
|
27424
|
-
const idx =
|
|
27424
|
+
const idx = cache4.indexOf(requestResponse);
|
|
27425
27425
|
assert(idx !== -1);
|
|
27426
|
-
|
|
27426
|
+
cache4.splice(idx, 1);
|
|
27427
27427
|
}
|
|
27428
|
-
|
|
27428
|
+
cache4.push([operation.request, operation.response]);
|
|
27429
27429
|
addedItems.push([operation.request, operation.response]);
|
|
27430
27430
|
}
|
|
27431
27431
|
resultList.push([operation.request, operation.response]);
|
|
@@ -27602,13 +27602,13 @@ var require_cachestorage = __commonJS({
|
|
|
27602
27602
|
if (options.cacheName != null) {
|
|
27603
27603
|
if (this.#caches.has(options.cacheName)) {
|
|
27604
27604
|
const cacheList = this.#caches.get(options.cacheName);
|
|
27605
|
-
const
|
|
27606
|
-
return await
|
|
27605
|
+
const cache4 = new Cache(kConstruct, cacheList);
|
|
27606
|
+
return await cache4.match(request, options);
|
|
27607
27607
|
}
|
|
27608
27608
|
} else {
|
|
27609
27609
|
for (const cacheList of this.#caches.values()) {
|
|
27610
|
-
const
|
|
27611
|
-
const response = await
|
|
27610
|
+
const cache4 = new Cache(kConstruct, cacheList);
|
|
27611
|
+
const response = await cache4.match(request, options);
|
|
27612
27612
|
if (response !== void 0) {
|
|
27613
27613
|
return response;
|
|
27614
27614
|
}
|
|
@@ -27638,12 +27638,12 @@ var require_cachestorage = __commonJS({
|
|
|
27638
27638
|
webidl.argumentLengthCheck(arguments, 1, prefix);
|
|
27639
27639
|
cacheName = webidl.converters.DOMString(cacheName, prefix, "cacheName");
|
|
27640
27640
|
if (this.#caches.has(cacheName)) {
|
|
27641
|
-
const
|
|
27642
|
-
return new Cache(kConstruct,
|
|
27641
|
+
const cache5 = this.#caches.get(cacheName);
|
|
27642
|
+
return new Cache(kConstruct, cache5);
|
|
27643
27643
|
}
|
|
27644
|
-
const
|
|
27645
|
-
this.#caches.set(cacheName,
|
|
27646
|
-
return new Cache(kConstruct,
|
|
27644
|
+
const cache4 = [];
|
|
27645
|
+
this.#caches.set(cacheName, cache4);
|
|
27646
|
+
return new Cache(kConstruct, cache4);
|
|
27647
27647
|
}
|
|
27648
27648
|
/**
|
|
27649
27649
|
* @see https://w3c.github.io/ServiceWorker/#cache-storage-delete
|
|
@@ -44740,7 +44740,7 @@ var require_numbers = __commonJS({
|
|
|
44740
44740
|
"node_modules/mqtt-packet/numbers.js"(exports2, module2) {
|
|
44741
44741
|
var { Buffer: Buffer2 } = require("buffer");
|
|
44742
44742
|
var max = 65536;
|
|
44743
|
-
var
|
|
44743
|
+
var cache4 = {};
|
|
44744
44744
|
var SubOk = Buffer2.isBuffer(Buffer2.from([1, 2]).subarray(0, 1));
|
|
44745
44745
|
function generateBuffer(i79) {
|
|
44746
44746
|
const buffer = Buffer2.allocUnsafe(2);
|
|
@@ -44750,7 +44750,7 @@ var require_numbers = __commonJS({
|
|
|
44750
44750
|
}
|
|
44751
44751
|
function generateCache() {
|
|
44752
44752
|
for (let i79 = 0; i79 < max; i79++) {
|
|
44753
|
-
|
|
44753
|
+
cache4[i79] = generateBuffer(i79);
|
|
44754
44754
|
}
|
|
44755
44755
|
}
|
|
44756
44756
|
function genBufVariableByteInt(num) {
|
|
@@ -44775,7 +44775,7 @@ var require_numbers = __commonJS({
|
|
|
44775
44775
|
return buffer;
|
|
44776
44776
|
}
|
|
44777
44777
|
module2.exports = {
|
|
44778
|
-
cache:
|
|
44778
|
+
cache: cache4,
|
|
44779
44779
|
generateCache,
|
|
44780
44780
|
generateNumber: generateBuffer,
|
|
44781
44781
|
genBufVariableByteInt,
|
|
@@ -54235,18 +54235,18 @@ var require_generate_unique_number = __commonJS({
|
|
|
54235
54235
|
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER === void 0 ? 9007199254740991 : Number.MAX_SAFE_INTEGER;
|
|
54236
54236
|
var TWO_TO_THE_POWER_OF_TWENTY_NINE = 536870912;
|
|
54237
54237
|
var TWO_TO_THE_POWER_OF_THIRTY = TWO_TO_THE_POWER_OF_TWENTY_NINE * 2;
|
|
54238
|
-
var createGenerateUniqueNumber = (
|
|
54238
|
+
var createGenerateUniqueNumber = (cache4, lastNumberWeakMap) => {
|
|
54239
54239
|
return (collection) => {
|
|
54240
54240
|
const lastNumber = lastNumberWeakMap.get(collection);
|
|
54241
54241
|
let nextNumber = lastNumber === void 0 ? collection.size : lastNumber < TWO_TO_THE_POWER_OF_THIRTY ? lastNumber + 1 : 0;
|
|
54242
54242
|
if (!collection.has(nextNumber)) {
|
|
54243
|
-
return
|
|
54243
|
+
return cache4(collection, nextNumber);
|
|
54244
54244
|
}
|
|
54245
54245
|
if (collection.size < TWO_TO_THE_POWER_OF_TWENTY_NINE) {
|
|
54246
54246
|
while (collection.has(nextNumber)) {
|
|
54247
54247
|
nextNumber = Math.floor(Math.random() * TWO_TO_THE_POWER_OF_THIRTY);
|
|
54248
54248
|
}
|
|
54249
|
-
return
|
|
54249
|
+
return cache4(collection, nextNumber);
|
|
54250
54250
|
}
|
|
54251
54251
|
if (collection.size > MAX_SAFE_INTEGER) {
|
|
54252
54252
|
throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");
|
|
@@ -54254,7 +54254,7 @@ var require_generate_unique_number = __commonJS({
|
|
|
54254
54254
|
while (collection.has(nextNumber)) {
|
|
54255
54255
|
nextNumber = Math.floor(Math.random() * MAX_SAFE_INTEGER);
|
|
54256
54256
|
}
|
|
54257
|
-
return
|
|
54257
|
+
return cache4(collection, nextNumber);
|
|
54258
54258
|
};
|
|
54259
54259
|
};
|
|
54260
54260
|
exports2.createGenerateUniqueNumber = createGenerateUniqueNumber;
|
|
@@ -54273,8 +54273,8 @@ var require_module = __commonJS({
|
|
|
54273
54273
|
var _cache = require_cache4();
|
|
54274
54274
|
var _generateUniqueNumber = require_generate_unique_number();
|
|
54275
54275
|
var LAST_NUMBER_WEAK_MAP = /* @__PURE__ */ new WeakMap();
|
|
54276
|
-
var
|
|
54277
|
-
var generateUniqueNumber = exports2.generateUniqueNumber = (0, _generateUniqueNumber.createGenerateUniqueNumber)(
|
|
54276
|
+
var cache4 = (0, _cache.createCache)(LAST_NUMBER_WEAK_MAP);
|
|
54277
|
+
var generateUniqueNumber = exports2.generateUniqueNumber = (0, _generateUniqueNumber.createGenerateUniqueNumber)(cache4, LAST_NUMBER_WEAK_MAP);
|
|
54278
54278
|
var addUniqueNumber = exports2.addUniqueNumber = (0, _addUniqueNumber.createAddUniqueNumber)(generateUniqueNumber);
|
|
54279
54279
|
}
|
|
54280
54280
|
});
|
|
@@ -73577,6 +73577,62 @@ async function readStream(body, kind, startMs, opts = {}) {
|
|
|
73577
73577
|
return { events, text, close, firstEventMs: Math.max(firstEventMs, 0) };
|
|
73578
73578
|
}
|
|
73579
73579
|
|
|
73580
|
+
// src/main/secrets/injected.ts
|
|
73581
|
+
var import_node_fs = require("node:fs");
|
|
73582
|
+
function parseDict(raw) {
|
|
73583
|
+
if (!raw) return null;
|
|
73584
|
+
try {
|
|
73585
|
+
const parsed = JSON.parse(raw);
|
|
73586
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
|
|
73587
|
+
const out = {};
|
|
73588
|
+
for (const [k2, v3] of Object.entries(parsed)) {
|
|
73589
|
+
if (typeof v3 === "string") out[k2] = v3;
|
|
73590
|
+
}
|
|
73591
|
+
return out;
|
|
73592
|
+
} catch {
|
|
73593
|
+
return null;
|
|
73594
|
+
}
|
|
73595
|
+
}
|
|
73596
|
+
var cache = /* @__PURE__ */ new Map();
|
|
73597
|
+
function cached(name, rawKey, build) {
|
|
73598
|
+
const hit = cache.get(name);
|
|
73599
|
+
if (hit && hit.key === rawKey) return hit.dict;
|
|
73600
|
+
const dict = build();
|
|
73601
|
+
cache.set(name, { key: rawKey, dict });
|
|
73602
|
+
return dict;
|
|
73603
|
+
}
|
|
73604
|
+
function valuesInline() {
|
|
73605
|
+
const raw = process.env["API_SPECTOR_SECRETS"];
|
|
73606
|
+
return cached("inline", raw ?? "", () => parseDict(raw));
|
|
73607
|
+
}
|
|
73608
|
+
function valuesFromFile() {
|
|
73609
|
+
const path = process.env["API_SPECTOR_SECRETS_FILE"];
|
|
73610
|
+
return cached("file", path ?? "", () => {
|
|
73611
|
+
if (!path) return null;
|
|
73612
|
+
try {
|
|
73613
|
+
return parseDict((0, import_node_fs.readFileSync)(path, "utf8"));
|
|
73614
|
+
} catch {
|
|
73615
|
+
return null;
|
|
73616
|
+
}
|
|
73617
|
+
});
|
|
73618
|
+
}
|
|
73619
|
+
function envNameMap() {
|
|
73620
|
+
const raw = process.env["API_SPECTOR_SECRET_ENV_MAP"];
|
|
73621
|
+
return cached("envmap", raw ?? "", () => parseDict(raw));
|
|
73622
|
+
}
|
|
73623
|
+
function injectedSecret(ref) {
|
|
73624
|
+
const direct = valuesInline();
|
|
73625
|
+
if (direct && typeof direct[ref] === "string") return direct[ref];
|
|
73626
|
+
const file = valuesFromFile();
|
|
73627
|
+
if (file && typeof file[ref] === "string") return file[ref];
|
|
73628
|
+
const map = envNameMap();
|
|
73629
|
+
if (map && typeof map[ref] === "string") {
|
|
73630
|
+
const value2 = process.env[map[ref]];
|
|
73631
|
+
if (value2 !== void 0 && value2 !== "") return value2;
|
|
73632
|
+
}
|
|
73633
|
+
return void 0;
|
|
73634
|
+
}
|
|
73635
|
+
|
|
73580
73636
|
// src/main/secrets/registry.ts
|
|
73581
73637
|
var providers = /* @__PURE__ */ new Map();
|
|
73582
73638
|
function registerSecretProvider(provider) {
|
|
@@ -73594,13 +73650,15 @@ function hasSecretScheme(ref) {
|
|
|
73594
73650
|
async function resolveExternalSecret(ref, ctx = {}) {
|
|
73595
73651
|
const scheme = schemeOf(ref);
|
|
73596
73652
|
if (!scheme) return null;
|
|
73653
|
+
const injected = injectedSecret(ref);
|
|
73654
|
+
if (injected !== void 0) return injected;
|
|
73597
73655
|
const provider = providers.get(scheme);
|
|
73598
73656
|
const refBody = ref.slice(scheme.length + 1);
|
|
73599
73657
|
return provider.resolve(refBody, ctx);
|
|
73600
73658
|
}
|
|
73601
73659
|
|
|
73602
73660
|
// src/main/secrets/providers/vault.ts
|
|
73603
|
-
var
|
|
73661
|
+
var import_node_fs2 = require("node:fs");
|
|
73604
73662
|
var import_node_os = require("node:os");
|
|
73605
73663
|
var import_node_path = require("node:path");
|
|
73606
73664
|
|
|
@@ -73620,7 +73678,7 @@ function env(...names) {
|
|
|
73620
73678
|
}
|
|
73621
73679
|
function readFileTrim(path) {
|
|
73622
73680
|
try {
|
|
73623
|
-
return (0,
|
|
73681
|
+
return (0, import_node_fs2.readFileSync)(path, "utf8").trim() || void 0;
|
|
73624
73682
|
} catch {
|
|
73625
73683
|
return void 0;
|
|
73626
73684
|
}
|
|
@@ -73818,11 +73876,11 @@ function resolveConn2() {
|
|
|
73818
73876
|
}
|
|
73819
73877
|
return { region, accessKeyId, secretAccessKey, sessionToken: env2("AWS_SESSION_TOKEN") };
|
|
73820
73878
|
}
|
|
73821
|
-
var
|
|
73879
|
+
var cache2 = /* @__PURE__ */ new Map();
|
|
73822
73880
|
async function getSecretString(conn, secretId) {
|
|
73823
73881
|
const cacheKey = `${conn.region}|${secretId}`;
|
|
73824
73882
|
const now = Date.now();
|
|
73825
|
-
const hit =
|
|
73883
|
+
const hit = cache2.get(cacheKey);
|
|
73826
73884
|
if (hit && hit.expiresAt > now) return hit.raw;
|
|
73827
73885
|
const host = `secretsmanager.${conn.region}.amazonaws.com`;
|
|
73828
73886
|
const body = JSON.stringify({ SecretId: secretId });
|
|
@@ -73850,7 +73908,7 @@ async function getSecretString(conn, secretId) {
|
|
|
73850
73908
|
const json = await res.json();
|
|
73851
73909
|
const raw = json?.SecretString;
|
|
73852
73910
|
if (raw === void 0) throw new Error(`AWS secret '${secretId}' has no SecretString (binary secrets are not supported)`);
|
|
73853
|
-
|
|
73911
|
+
cache2.set(cacheKey, { raw, expiresAt: now + 5 * 6e4 });
|
|
73854
73912
|
return raw;
|
|
73855
73913
|
}
|
|
73856
73914
|
async function resolve(refBody) {
|
|
@@ -73992,8 +74050,8 @@ var isId = (s8) => /^[a-z0-9]{26}$/i.test(s8);
|
|
|
73992
74050
|
async function vaultId(conn, vault) {
|
|
73993
74051
|
if (isId(vault)) return vault;
|
|
73994
74052
|
const cacheKey = `vaults:${vault}`;
|
|
73995
|
-
const
|
|
73996
|
-
if (
|
|
74053
|
+
const cached2 = idCache.get(cacheKey);
|
|
74054
|
+
if (cached2) return cached2;
|
|
73997
74055
|
const list = await opGet(conn, `/v1/vaults?filter=${encodeURIComponent(`name eq "${vault}"`)}`);
|
|
73998
74056
|
const id = Array.isArray(list) && list[0]?.id;
|
|
73999
74057
|
if (!id) throw new Error(`1Password: vault '${vault}' not found`);
|
|
@@ -74003,8 +74061,8 @@ async function vaultId(conn, vault) {
|
|
|
74003
74061
|
async function itemId(conn, vid, item) {
|
|
74004
74062
|
if (isId(item)) return item;
|
|
74005
74063
|
const cacheKey = `items:${vid}:${item}`;
|
|
74006
|
-
const
|
|
74007
|
-
if (
|
|
74064
|
+
const cached2 = idCache.get(cacheKey);
|
|
74065
|
+
if (cached2) return cached2;
|
|
74008
74066
|
const list = await opGet(conn, `/v1/vaults/${vid}/items?filter=${encodeURIComponent(`title eq "${item}"`)}`);
|
|
74009
74067
|
const id = Array.isArray(list) && list[0]?.id;
|
|
74010
74068
|
if (!id) throw new Error(`1Password: item '${item}' not found in vault`);
|
|
@@ -74050,7 +74108,7 @@ var onePasswordProvider = {
|
|
|
74050
74108
|
};
|
|
74051
74109
|
|
|
74052
74110
|
// src/main/secrets/providers/gcp.ts
|
|
74053
|
-
var
|
|
74111
|
+
var import_node_fs3 = require("node:fs");
|
|
74054
74112
|
var import_node_crypto2 = require("node:crypto");
|
|
74055
74113
|
var TOKEN_URI = "https://oauth2.googleapis.com/token";
|
|
74056
74114
|
var SCOPE = "https://www.googleapis.com/auth/cloud-platform";
|
|
@@ -74070,7 +74128,7 @@ function loadServiceAccount() {
|
|
|
74070
74128
|
raw = inline;
|
|
74071
74129
|
} else if (path) {
|
|
74072
74130
|
try {
|
|
74073
|
-
raw = (0,
|
|
74131
|
+
raw = (0, import_node_fs3.readFileSync)(path, "utf8");
|
|
74074
74132
|
} catch (e9) {
|
|
74075
74133
|
throw new Error(`GCP Secret Manager: cannot read GOOGLE_APPLICATION_CREDENTIALS '${path}': ${e9.message}`);
|
|
74076
74134
|
}
|
|
@@ -76081,10 +76139,10 @@ JSONPath.toPointer = function(pointer) {
|
|
|
76081
76139
|
};
|
|
76082
76140
|
JSONPath.toPathArray = function(expr) {
|
|
76083
76141
|
const {
|
|
76084
|
-
cache:
|
|
76142
|
+
cache: cache4
|
|
76085
76143
|
} = JSONPath;
|
|
76086
|
-
if (
|
|
76087
|
-
return
|
|
76144
|
+
if (cache4[expr]) {
|
|
76145
|
+
return cache4[expr].concat();
|
|
76088
76146
|
}
|
|
76089
76147
|
const subx = [];
|
|
76090
76148
|
const normalized = expr.replaceAll(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu, ";$&;").replaceAll(/[['](\??\(.*?\))[\]'](?!.\])/gu, function($0, $1) {
|
|
@@ -76098,8 +76156,8 @@ JSONPath.toPathArray = function(expr) {
|
|
|
76098
76156
|
const match = exp.match(/#(\d+)/u);
|
|
76099
76157
|
return !match || !match[1] ? exp : subx[match[1]];
|
|
76100
76158
|
});
|
|
76101
|
-
|
|
76102
|
-
return
|
|
76159
|
+
cache4[expr] = exprList;
|
|
76160
|
+
return cache4[expr].concat();
|
|
76103
76161
|
};
|
|
76104
76162
|
JSONPath.prototype.safeVm = {
|
|
76105
76163
|
Script: SafeScript
|
|
@@ -80025,7 +80083,7 @@ var Manager = class extends import_component_emitter6.Emitter {
|
|
|
80025
80083
|
// node_modules/socket.io-client/build/esm-debug/index.js
|
|
80026
80084
|
var import_debug11 = __toESM(require_src(), 1);
|
|
80027
80085
|
var debug11 = (0, import_debug11.default)("socket.io-client");
|
|
80028
|
-
var
|
|
80086
|
+
var cache3 = {};
|
|
80029
80087
|
function lookup(uri, opts) {
|
|
80030
80088
|
if (typeof uri === "object") {
|
|
80031
80089
|
opts = uri;
|
|
@@ -80036,18 +80094,18 @@ function lookup(uri, opts) {
|
|
|
80036
80094
|
const source = parsed.source;
|
|
80037
80095
|
const id = parsed.id;
|
|
80038
80096
|
const path = parsed.path;
|
|
80039
|
-
const sameNamespace =
|
|
80097
|
+
const sameNamespace = cache3[id] && path in cache3[id]["nsps"];
|
|
80040
80098
|
const newConnection = opts.forceNew || opts["force new connection"] || false === opts.multiplex || sameNamespace;
|
|
80041
80099
|
let io;
|
|
80042
80100
|
if (newConnection) {
|
|
80043
80101
|
debug11("ignoring socket cache for %s", source);
|
|
80044
80102
|
io = new Manager(source, opts);
|
|
80045
80103
|
} else {
|
|
80046
|
-
if (!
|
|
80104
|
+
if (!cache3[id]) {
|
|
80047
80105
|
debug11("new io instance for %s", source);
|
|
80048
|
-
|
|
80106
|
+
cache3[id] = new Manager(source, opts);
|
|
80049
80107
|
}
|
|
80050
|
-
io =
|
|
80108
|
+
io = cache3[id];
|
|
80051
80109
|
}
|
|
80052
80110
|
if (parsed.query && !opts.query) {
|
|
80053
80111
|
opts.query = parsed.queryKey;
|
|
@@ -81433,7 +81491,7 @@ var APP_URL = (process.env.APP_URL || "").replace(/\/+$/, "");
|
|
|
81433
81491
|
var AGENT_TOKEN = process.env.AGENT_TOKEN || "";
|
|
81434
81492
|
var RUNTIME_TOKEN = process.env.RUNTIME_TOKEN || "";
|
|
81435
81493
|
var POLL_MS = Number(process.env.POLL_INTERVAL_MS || 5e3);
|
|
81436
|
-
var VERSION = true ? "0.9.
|
|
81494
|
+
var VERSION = true ? "0.9.6" : "";
|
|
81437
81495
|
var authHeaders = AGENT_TOKEN ? { Authorization: `Bearer ${AGENT_TOKEN}` } : RUNTIME_TOKEN ? { "X-Runtime-Token": RUNTIME_TOKEN } : {};
|
|
81438
81496
|
async function postResult(m6, fields) {
|
|
81439
81497
|
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.6",
|
|
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",
|