@testsmith/api-spector-agent 0.7.3 → 0.7.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.
Files changed (2) hide show
  1. package/dist/index.cjs +278 -121
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -7472,9 +7472,9 @@ var require_dispatcher_base = __commonJS({
7472
7472
  }
7473
7473
  close(callback) {
7474
7474
  if (callback === void 0) {
7475
- return new Promise((resolve4, reject) => {
7475
+ return new Promise((resolve5, reject) => {
7476
7476
  this.close((err, data) => {
7477
- return err ? reject(err) : resolve4(data);
7477
+ return err ? reject(err) : resolve5(data);
7478
7478
  });
7479
7479
  });
7480
7480
  }
@@ -7512,9 +7512,9 @@ var require_dispatcher_base = __commonJS({
7512
7512
  err = null;
7513
7513
  }
7514
7514
  if (callback === void 0) {
7515
- return new Promise((resolve4, reject) => {
7515
+ return new Promise((resolve5, reject) => {
7516
7516
  this.destroy(err, (err2, data) => {
7517
- return err2 ? reject(err2) : resolve4(data);
7517
+ return err2 ? reject(err2) : resolve5(data);
7518
7518
  });
7519
7519
  });
7520
7520
  }
@@ -10991,8 +10991,8 @@ var require_promise = __commonJS({
10991
10991
  function createDeferredPromise() {
10992
10992
  let res;
10993
10993
  let rej;
10994
- const promise = new Promise((resolve4, reject) => {
10995
- res = resolve4;
10994
+ const promise = new Promise((resolve5, reject) => {
10995
+ res = resolve5;
10996
10996
  rej = reject;
10997
10997
  });
10998
10998
  return { promise, resolve: res, reject: rej };
@@ -12293,12 +12293,12 @@ upgrade: ${upgrade}\r
12293
12293
  cb();
12294
12294
  }
12295
12295
  }
12296
- const waitForDrain = () => new Promise((resolve4, reject) => {
12296
+ const waitForDrain = () => new Promise((resolve5, reject) => {
12297
12297
  assert(callback === null);
12298
12298
  if (socket[kError]) {
12299
12299
  reject(socket[kError]);
12300
12300
  } else {
12301
- callback = resolve4;
12301
+ callback = resolve5;
12302
12302
  }
12303
12303
  });
12304
12304
  socket.on("close", onDrain).on("drain", onDrain);
@@ -13143,12 +13143,12 @@ var require_client_h2 = __commonJS({
13143
13143
  cb();
13144
13144
  }
13145
13145
  }
13146
- const waitForDrain = () => new Promise((resolve4, reject) => {
13146
+ const waitForDrain = () => new Promise((resolve5, reject) => {
13147
13147
  assert(callback === null);
13148
13148
  if (socket[kError]) {
13149
13149
  reject(socket[kError]);
13150
13150
  } else {
13151
- callback = resolve4;
13151
+ callback = resolve5;
13152
13152
  }
13153
13153
  });
13154
13154
  h2stream.on("close", onDrain).on("drain", onDrain);
@@ -13459,16 +13459,16 @@ var require_client = __commonJS({
13459
13459
  return this[kNeedDrain] < 2;
13460
13460
  }
13461
13461
  [kClose]() {
13462
- return new Promise((resolve4) => {
13462
+ return new Promise((resolve5) => {
13463
13463
  if (this[kSize]) {
13464
- this[kClosedResolve] = resolve4;
13464
+ this[kClosedResolve] = resolve5;
13465
13465
  } else {
13466
- resolve4(null);
13466
+ resolve5(null);
13467
13467
  }
13468
13468
  });
13469
13469
  }
13470
13470
  [kDestroy](err) {
13471
- return new Promise((resolve4) => {
13471
+ return new Promise((resolve5) => {
13472
13472
  const requests = this[kQueue].splice(this[kPendingIdx]);
13473
13473
  for (let i68 = 0; i68 < requests.length; i68++) {
13474
13474
  const request = requests[i68];
@@ -13479,7 +13479,7 @@ var require_client = __commonJS({
13479
13479
  this[kClosedResolve]();
13480
13480
  this[kClosedResolve] = null;
13481
13481
  }
13482
- resolve4(null);
13482
+ resolve5(null);
13483
13483
  };
13484
13484
  if (this[kHTTPContext]) {
13485
13485
  this[kHTTPContext].destroy(err, callback);
@@ -13879,8 +13879,8 @@ var require_pool_base = __commonJS({
13879
13879
  }
13880
13880
  return Promise.all(closeAll);
13881
13881
  } else {
13882
- return new Promise((resolve4) => {
13883
- this[kClosedResolve] = resolve4;
13882
+ return new Promise((resolve5) => {
13883
+ this[kClosedResolve] = resolve5;
13884
13884
  });
13885
13885
  }
13886
13886
  }
@@ -14972,10 +14972,10 @@ var require_socks5_proxy_agent = __commonJS({
14972
14972
  const proxyHost = this[kProxyUrl].hostname;
14973
14973
  const proxyPort = parseInt(this[kProxyUrl].port) || 1080;
14974
14974
  debug("creating SOCKS5 connection to", proxyHost, proxyPort);
14975
- const socket = await new Promise((resolve4, reject) => {
14975
+ const socket = await new Promise((resolve5, reject) => {
14976
14976
  const onConnect = () => {
14977
14977
  socket2.removeListener("error", onError);
14978
- resolve4(socket2);
14978
+ resolve5(socket2);
14979
14979
  };
14980
14980
  const onError = (err) => {
14981
14981
  socket2.removeListener("connect", onConnect);
@@ -14994,14 +14994,14 @@ var require_socks5_proxy_agent = __commonJS({
14994
14994
  socket.destroy();
14995
14995
  });
14996
14996
  await socks5Client.handshake();
14997
- await new Promise((resolve4, reject) => {
14997
+ await new Promise((resolve5, reject) => {
14998
14998
  const timeout = setTimeout(() => {
14999
14999
  reject(new Error("SOCKS5 authentication timeout"));
15000
15000
  }, 5e3);
15001
15001
  const onAuthenticated = () => {
15002
15002
  clearTimeout(timeout);
15003
15003
  socks5Client.removeListener("error", onError);
15004
- resolve4();
15004
+ resolve5();
15005
15005
  };
15006
15006
  const onError = (err) => {
15007
15007
  clearTimeout(timeout);
@@ -15010,14 +15010,14 @@ var require_socks5_proxy_agent = __commonJS({
15010
15010
  };
15011
15011
  if (socks5Client.state === "authenticated") {
15012
15012
  clearTimeout(timeout);
15013
- resolve4();
15013
+ resolve5();
15014
15014
  } else {
15015
15015
  socks5Client.once("authenticated", onAuthenticated);
15016
15016
  socks5Client.once("error", onError);
15017
15017
  }
15018
15018
  });
15019
15019
  await socks5Client.connect(targetHost, targetPort);
15020
- await new Promise((resolve4, reject) => {
15020
+ await new Promise((resolve5, reject) => {
15021
15021
  const timeout = setTimeout(() => {
15022
15022
  reject(new Error("SOCKS5 connection timeout"));
15023
15023
  }, 5e3);
@@ -15025,7 +15025,7 @@ var require_socks5_proxy_agent = __commonJS({
15025
15025
  debug("SOCKS5 tunnel established to", targetHost, targetPort, "via", info);
15026
15026
  clearTimeout(timeout);
15027
15027
  socks5Client.removeListener("error", onError);
15028
- resolve4();
15028
+ resolve5();
15029
15029
  };
15030
15030
  const onError = (err) => {
15031
15031
  clearTimeout(timeout);
@@ -15066,8 +15066,8 @@ var require_socks5_proxy_agent = __commonJS({
15066
15066
  servername: targetHost,
15067
15067
  ...connectOpts.tls || {}
15068
15068
  });
15069
- await new Promise((resolve4, reject) => {
15070
- finalSocket.once("secureConnect", resolve4);
15069
+ await new Promise((resolve5, reject) => {
15070
+ finalSocket.once("secureConnect", resolve5);
15071
15071
  finalSocket.once("error", reject);
15072
15072
  });
15073
15073
  }
@@ -16092,7 +16092,7 @@ var require_readable = __commonJS({
16092
16092
  if (this._readableState.closeEmitted) {
16093
16093
  return Promise.resolve(null);
16094
16094
  }
16095
- return new Promise((resolve4, reject) => {
16095
+ return new Promise((resolve5, reject) => {
16096
16096
  if (this[kContentLength] && this[kContentLength] > limit || this[kBytesRead] > limit) {
16097
16097
  this.destroy(new AbortError());
16098
16098
  }
@@ -16106,11 +16106,11 @@ var require_readable = __commonJS({
16106
16106
  if (signal.aborted) {
16107
16107
  reject(signal.reason ?? new AbortError());
16108
16108
  } else {
16109
- resolve4(null);
16109
+ resolve5(null);
16110
16110
  }
16111
16111
  });
16112
16112
  } else {
16113
- this.on("close", resolve4);
16113
+ this.on("close", resolve5);
16114
16114
  }
16115
16115
  this.on("error", noop).on("data", () => {
16116
16116
  if (this[kBytesRead] > limit) {
@@ -16138,7 +16138,7 @@ var require_readable = __commonJS({
16138
16138
  }
16139
16139
  function consume(stream, type) {
16140
16140
  assert(!stream[kConsume]);
16141
- return new Promise((resolve4, reject) => {
16141
+ return new Promise((resolve5, reject) => {
16142
16142
  if (isUnusable(stream)) {
16143
16143
  const rState = stream._readableState;
16144
16144
  if (rState.destroyed && rState.closeEmitted === false) {
@@ -16153,7 +16153,7 @@ var require_readable = __commonJS({
16153
16153
  stream[kConsume] = {
16154
16154
  type,
16155
16155
  stream,
16156
- resolve: resolve4,
16156
+ resolve: resolve5,
16157
16157
  reject,
16158
16158
  length: 0,
16159
16159
  body: []
@@ -16227,18 +16227,18 @@ var require_readable = __commonJS({
16227
16227
  return buffer;
16228
16228
  }
16229
16229
  function consumeEnd(consume2, encoding) {
16230
- const { type, body, resolve: resolve4, stream, length } = consume2;
16230
+ const { type, body, resolve: resolve5, stream, length } = consume2;
16231
16231
  try {
16232
16232
  if (type === "text") {
16233
- resolve4(chunksDecode(body, length, encoding));
16233
+ resolve5(chunksDecode(body, length, encoding));
16234
16234
  } else if (type === "json") {
16235
- resolve4(JSON.parse(chunksDecode(body, length, encoding)));
16235
+ resolve5(JSON.parse(chunksDecode(body, length, encoding)));
16236
16236
  } else if (type === "arrayBuffer") {
16237
- resolve4(chunksConcat(body, length).buffer);
16237
+ resolve5(chunksConcat(body, length).buffer);
16238
16238
  } else if (type === "blob") {
16239
- resolve4(new Blob(body, { type: stream[kContentType] }));
16239
+ resolve5(new Blob(body, { type: stream[kContentType] }));
16240
16240
  } else if (type === "bytes") {
16241
- resolve4(chunksConcat(body, length));
16241
+ resolve5(chunksConcat(body, length));
16242
16242
  }
16243
16243
  consumeFinish(consume2);
16244
16244
  } catch (err) {
@@ -16428,9 +16428,9 @@ var require_api_request = __commonJS({
16428
16428
  };
16429
16429
  function request(opts, callback) {
16430
16430
  if (callback === void 0) {
16431
- return new Promise((resolve4, reject) => {
16431
+ return new Promise((resolve5, reject) => {
16432
16432
  request.call(this, opts, (err, data) => {
16433
- return err ? reject(err) : resolve4(data);
16433
+ return err ? reject(err) : resolve5(data);
16434
16434
  });
16435
16435
  });
16436
16436
  }
@@ -16642,9 +16642,9 @@ var require_api_stream = __commonJS({
16642
16642
  };
16643
16643
  function stream(opts, factory, callback) {
16644
16644
  if (callback === void 0) {
16645
- return new Promise((resolve4, reject) => {
16645
+ return new Promise((resolve5, reject) => {
16646
16646
  stream.call(this, opts, factory, (err, data) => {
16647
- return err ? reject(err) : resolve4(data);
16647
+ return err ? reject(err) : resolve5(data);
16648
16648
  });
16649
16649
  });
16650
16650
  }
@@ -16932,9 +16932,9 @@ var require_api_upgrade = __commonJS({
16932
16932
  };
16933
16933
  function upgrade(opts, callback) {
16934
16934
  if (callback === void 0) {
16935
- return new Promise((resolve4, reject) => {
16935
+ return new Promise((resolve5, reject) => {
16936
16936
  upgrade.call(this, opts, (err, data) => {
16937
- return err ? reject(err) : resolve4(data);
16937
+ return err ? reject(err) : resolve5(data);
16938
16938
  });
16939
16939
  });
16940
16940
  }
@@ -17027,9 +17027,9 @@ var require_api_connect = __commonJS({
17027
17027
  };
17028
17028
  function connect(opts, callback) {
17029
17029
  if (callback === void 0) {
17030
- return new Promise((resolve4, reject) => {
17030
+ return new Promise((resolve5, reject) => {
17031
17031
  connect.call(this, opts, (err, data) => {
17032
- return err ? reject(err) : resolve4(data);
17032
+ return err ? reject(err) : resolve5(data);
17033
17033
  });
17034
17034
  });
17035
17035
  }
@@ -18297,7 +18297,7 @@ var require_snapshot_recorder = __commonJS({
18297
18297
  "node_modules/undici/lib/mock/snapshot-recorder.js"(exports2, module2) {
18298
18298
  "use strict";
18299
18299
  var { writeFile: writeFile2, readFile: readFile4, mkdir } = require("node:fs/promises");
18300
- var { dirname, resolve: resolve4 } = require("node:path");
18300
+ var { dirname, resolve: resolve5 } = require("node:path");
18301
18301
  var { setTimeout: setTimeout2, clearTimeout: clearTimeout2 } = require("node:timers");
18302
18302
  var { InvalidArgumentError, UndiciError } = require_errors();
18303
18303
  var { hashId, isUrlExcludedFactory, normalizeHeaders, createHeaderFilters } = require_snapshot_utils();
@@ -18498,7 +18498,7 @@ var require_snapshot_recorder = __commonJS({
18498
18498
  throw new InvalidArgumentError("Snapshot path is required");
18499
18499
  }
18500
18500
  try {
18501
- const data = await readFile4(resolve4(path), "utf8");
18501
+ const data = await readFile4(resolve5(path), "utf8");
18502
18502
  const parsed = JSON.parse(data);
18503
18503
  if (Array.isArray(parsed)) {
18504
18504
  this.#snapshots.clear();
@@ -18527,7 +18527,7 @@ var require_snapshot_recorder = __commonJS({
18527
18527
  if (!path) {
18528
18528
  throw new InvalidArgumentError("Snapshot path is required");
18529
18529
  }
18530
- const resolvedPath = resolve4(path);
18530
+ const resolvedPath = resolve5(path);
18531
18531
  await mkdir(dirname(resolvedPath), { recursive: true });
18532
18532
  const data = Array.from(this.#snapshots.entries()).map(([hash, snapshot]) => ({
18533
18533
  hash,
@@ -25365,7 +25365,7 @@ var require_fetch = __commonJS({
25365
25365
  const agent = fetchParams.controller.dispatcher;
25366
25366
  const path = url.pathname + url.search;
25367
25367
  const hasTrailingQuestionMark = url.search.length === 0 && url.href[url.href.length - url.hash.length - 1] === "?";
25368
- return new Promise((resolve4, reject) => agent.dispatch(
25368
+ return new Promise((resolve5, reject) => agent.dispatch(
25369
25369
  {
25370
25370
  path: hasTrailingQuestionMark ? `${path}?` : path,
25371
25371
  origin: url.origin,
@@ -25445,7 +25445,7 @@ var require_fetch = __commonJS({
25445
25445
  }
25446
25446
  }
25447
25447
  const onError = this.onError.bind(this);
25448
- resolve4({
25448
+ resolve5({
25449
25449
  status,
25450
25450
  statusText,
25451
25451
  headersList,
@@ -25498,7 +25498,7 @@ var require_fetch = __commonJS({
25498
25498
  headersList.append(headerName, String(value), true);
25499
25499
  }
25500
25500
  }
25501
- resolve4({
25501
+ resolve5({
25502
25502
  status,
25503
25503
  statusText: STATUS_CODES2[status],
25504
25504
  headersList,
@@ -25514,7 +25514,7 @@ var require_fetch = __commonJS({
25514
25514
  for (let i68 = 0; i68 < rawHeaders.length; i68 += 2) {
25515
25515
  headersList.append(bufferToLowerCasedHeaderName(rawHeaders[i68]), rawHeaders[i68 + 1].toString("latin1"), true);
25516
25516
  }
25517
- resolve4({
25517
+ resolve5({
25518
25518
  status,
25519
25519
  statusText: STATUS_CODES2[status],
25520
25520
  headersList,
@@ -40543,20 +40543,20 @@ var require_compile = __commonJS({
40543
40543
  var util_1 = require_util7();
40544
40544
  var validate_1 = require_validate();
40545
40545
  var SchemaEnv = class {
40546
- constructor(env5) {
40546
+ constructor(env6) {
40547
40547
  var _a3;
40548
40548
  this.refs = {};
40549
40549
  this.dynamicAnchors = {};
40550
40550
  let schema;
40551
- if (typeof env5.schema == "object")
40552
- schema = env5.schema;
40553
- this.schema = env5.schema;
40554
- this.schemaId = env5.schemaId;
40555
- this.root = env5.root || this;
40556
- this.baseId = (_a3 = env5.baseId) !== null && _a3 !== void 0 ? _a3 : (0, resolve_1.normalizeId)(schema === null || schema === void 0 ? void 0 : schema[env5.schemaId || "$id"]);
40557
- this.schemaPath = env5.schemaPath;
40558
- this.localRefs = env5.localRefs;
40559
- this.meta = env5.meta;
40551
+ if (typeof env6.schema == "object")
40552
+ schema = env6.schema;
40553
+ this.schema = env6.schema;
40554
+ this.schemaId = env6.schemaId;
40555
+ this.root = env6.root || this;
40556
+ this.baseId = (_a3 = env6.baseId) !== null && _a3 !== void 0 ? _a3 : (0, resolve_1.normalizeId)(schema === null || schema === void 0 ? void 0 : schema[env6.schemaId || "$id"]);
40557
+ this.schemaPath = env6.schemaPath;
40558
+ this.localRefs = env6.localRefs;
40559
+ this.meta = env6.meta;
40560
40560
  this.$async = schema === null || schema === void 0 ? void 0 : schema.$async;
40561
40561
  this.refs = {};
40562
40562
  }
@@ -40654,7 +40654,7 @@ var require_compile = __commonJS({
40654
40654
  const schOrFunc = root.refs[ref];
40655
40655
  if (schOrFunc)
40656
40656
  return schOrFunc;
40657
- let _sch = resolve4.call(this, root, ref);
40657
+ let _sch = resolve5.call(this, root, ref);
40658
40658
  if (_sch === void 0) {
40659
40659
  const schema = (_a3 = root.localRefs) === null || _a3 === void 0 ? void 0 : _a3[ref];
40660
40660
  const { schemaId } = this.opts;
@@ -40681,7 +40681,7 @@ var require_compile = __commonJS({
40681
40681
  function sameSchemaEnv(s1, s210) {
40682
40682
  return s1.schema === s210.schema && s1.root === s210.root && s1.baseId === s210.baseId;
40683
40683
  }
40684
- function resolve4(root, ref) {
40684
+ function resolve5(root, ref) {
40685
40685
  let sch;
40686
40686
  while (typeof (sch = this.refs[ref]) == "string")
40687
40687
  ref = sch;
@@ -40740,15 +40740,15 @@ var require_compile = __commonJS({
40740
40740
  baseId = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, schId);
40741
40741
  }
40742
40742
  }
40743
- let env5;
40743
+ let env6;
40744
40744
  if (typeof schema != "boolean" && schema.$ref && !(0, util_1.schemaHasRulesButRef)(schema, this.RULES)) {
40745
40745
  const $ref = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, schema.$ref);
40746
- env5 = resolveSchema.call(this, root, $ref);
40746
+ env6 = resolveSchema.call(this, root, $ref);
40747
40747
  }
40748
40748
  const { schemaId } = this.opts;
40749
- env5 = env5 || new SchemaEnv({ schema, schemaId, root, baseId });
40750
- if (env5.schema !== env5.root.schema)
40751
- return env5;
40749
+ env6 = env6 || new SchemaEnv({ schema, schemaId, root, baseId });
40750
+ if (env6.schema !== env6.root.schema)
40751
+ return env6;
40752
40752
  return void 0;
40753
40753
  }
40754
40754
  }
@@ -41256,7 +41256,7 @@ var require_fast_uri = __commonJS({
41256
41256
  }
41257
41257
  return uri;
41258
41258
  }
41259
- function resolve4(baseURI, relativeURI, options) {
41259
+ function resolve5(baseURI, relativeURI, options) {
41260
41260
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
41261
41261
  const resolved = resolveComponent(parse(baseURI, schemelessOptions), parse(relativeURI, schemelessOptions), schemelessOptions, true);
41262
41262
  schemelessOptions.skipEscape = true;
@@ -41483,7 +41483,7 @@ var require_fast_uri = __commonJS({
41483
41483
  var fastUri = {
41484
41484
  SCHEMES,
41485
41485
  normalize,
41486
- resolve: resolve4,
41486
+ resolve: resolve5,
41487
41487
  resolveComponent,
41488
41488
  equal,
41489
41489
  serialize,
@@ -42149,8 +42149,8 @@ var require_ref = __commonJS({
42149
42149
  schemaType: "string",
42150
42150
  code(cxt) {
42151
42151
  const { gen, schema: $ref, it: it4 } = cxt;
42152
- const { baseId, schemaEnv: env5, validateName, opts, self: self2 } = it4;
42153
- const { root } = env5;
42152
+ const { baseId, schemaEnv: env6, validateName, opts, self: self2 } = it4;
42153
+ const { root } = env6;
42154
42154
  if (($ref === "#" || $ref === "#/") && baseId === root.baseId)
42155
42155
  return callRootRef();
42156
42156
  const schOrEnv = compile_1.resolveRef.call(self2, root, baseId, $ref);
@@ -42160,8 +42160,8 @@ var require_ref = __commonJS({
42160
42160
  return callValidate(schOrEnv);
42161
42161
  return inlineRefSchema(schOrEnv);
42162
42162
  function callRootRef() {
42163
- if (env5 === root)
42164
- return callRef(cxt, validateName, env5, env5.$async);
42163
+ if (env6 === root)
42164
+ return callRef(cxt, validateName, env6, env6.$async);
42165
42165
  const rootName = gen.scopeValue("root", { ref: root });
42166
42166
  return callRef(cxt, (0, codegen_1._)`${rootName}.validate`, root, root.$async);
42167
42167
  }
@@ -42191,14 +42191,14 @@ var require_ref = __commonJS({
42191
42191
  exports2.getValidate = getValidate;
42192
42192
  function callRef(cxt, v60, sch, $async) {
42193
42193
  const { gen, it: it4 } = cxt;
42194
- const { allErrors, schemaEnv: env5, opts } = it4;
42194
+ const { allErrors, schemaEnv: env6, opts } = it4;
42195
42195
  const passCxt = opts.passContext ? names_1.default.this : codegen_1.nil;
42196
42196
  if ($async)
42197
42197
  callAsyncRef();
42198
42198
  else
42199
42199
  callSyncRef();
42200
42200
  function callAsyncRef() {
42201
- if (!env5.$async)
42201
+ if (!env6.$async)
42202
42202
  throw new Error("async schema referenced by sync schema");
42203
42203
  const valid = gen.let("valid");
42204
42204
  gen.try(() => {
@@ -44805,11 +44805,161 @@ var onePasswordProvider = {
44805
44805
  resolve: (refBody) => resolve3(refBody)
44806
44806
  };
44807
44807
 
44808
+ // src/main/secrets/providers/gcp.ts
44809
+ var import_node_fs2 = require("node:fs");
44810
+ var import_node_crypto2 = require("node:crypto");
44811
+ var TOKEN_URI = "https://oauth2.googleapis.com/token";
44812
+ var SCOPE = "https://www.googleapis.com/auth/cloud-platform";
44813
+ var API_BASE = "https://secretmanager.googleapis.com/v1";
44814
+ function env5(...names) {
44815
+ for (const n63 of names) {
44816
+ const v60 = process.env[n63];
44817
+ if (v60 !== void 0 && v60 !== "") return v60;
44818
+ }
44819
+ return void 0;
44820
+ }
44821
+ function loadServiceAccount() {
44822
+ const inline = env5("GCP_SERVICE_ACCOUNT_KEY", "GOOGLE_APPLICATION_CREDENTIALS_JSON");
44823
+ const path = env5("GOOGLE_APPLICATION_CREDENTIALS");
44824
+ let raw;
44825
+ if (inline) {
44826
+ raw = inline;
44827
+ } else if (path) {
44828
+ try {
44829
+ raw = (0, import_node_fs2.readFileSync)(path, "utf8");
44830
+ } catch (e20) {
44831
+ throw new Error(`GCP Secret Manager: cannot read GOOGLE_APPLICATION_CREDENTIALS '${path}': ${e20.message}`);
44832
+ }
44833
+ }
44834
+ if (!raw) return void 0;
44835
+ let key;
44836
+ try {
44837
+ key = JSON.parse(raw);
44838
+ } catch {
44839
+ throw new Error("GCP Secret Manager: the service-account key is not valid JSON");
44840
+ }
44841
+ if (!key.client_email || !key.private_key) {
44842
+ throw new Error("GCP Secret Manager: the service-account key is missing client_email or private_key");
44843
+ }
44844
+ return key;
44845
+ }
44846
+ function resolveConn5() {
44847
+ const cfg = getSecretsConfig()?.gcp ?? {};
44848
+ const accessToken3 = env5("GCP_ACCESS_TOKEN", "GOOGLE_OAUTH_ACCESS_TOKEN");
44849
+ const serviceAccount = loadServiceAccount();
44850
+ if (!accessToken3 && !serviceAccount) {
44851
+ throw new Error(
44852
+ "GCP Secret Manager: no credentials (set GCP_ACCESS_TOKEN, or GOOGLE_APPLICATION_CREDENTIALS / GOOGLE_APPLICATION_CREDENTIALS_JSON to a service-account key)"
44853
+ );
44854
+ }
44855
+ const defaultProject = env5("GCP_PROJECT", "GOOGLE_CLOUD_PROJECT", "CLOUDSDK_CORE_PROJECT") ?? cfg.project ?? serviceAccount?.project_id;
44856
+ return { accessToken: accessToken3, serviceAccount, defaultProject };
44857
+ }
44858
+ var cachedToken3 = null;
44859
+ var secretCache3 = /* @__PURE__ */ new Map();
44860
+ var b64url = (b69) => (Buffer.isBuffer(b69) ? b69 : Buffer.from(b69)).toString("base64url");
44861
+ async function mintAccessToken(sa11) {
44862
+ const iat = Math.floor(Date.now() / 1e3);
44863
+ const aud = sa11.token_uri || TOKEN_URI;
44864
+ const header = b64url(JSON.stringify({ alg: "RS256", typ: "JWT" }));
44865
+ const claims = b64url(JSON.stringify({ iss: sa11.client_email, scope: SCOPE, aud, iat, exp: iat + 3600 }));
44866
+ const signingInput = `${header}.${claims}`;
44867
+ const signature = b64url((0, import_node_crypto2.createSign)("RSA-SHA256").update(signingInput).sign(sa11.private_key));
44868
+ const assertion = `${signingInput}.${signature}`;
44869
+ const body = new URLSearchParams({
44870
+ grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer",
44871
+ assertion
44872
+ });
44873
+ const res = await fetch(aud, {
44874
+ method: "POST",
44875
+ headers: { "content-type": "application/x-www-form-urlencoded" },
44876
+ body: body.toString()
44877
+ });
44878
+ if (!res.ok) {
44879
+ const text = await res.text().catch(() => "");
44880
+ throw new Error(`GCP token exchange ${res.status}: ${text.slice(0, 300)}`);
44881
+ }
44882
+ const json = await res.json();
44883
+ const token = json?.access_token;
44884
+ if (!token) throw new Error("GCP token endpoint did not return an access_token");
44885
+ return { token, ttl: Number(json?.expires_in ?? 3600) };
44886
+ }
44887
+ async function accessToken2(conn) {
44888
+ if (conn.accessToken) return conn.accessToken;
44889
+ const now = Date.now();
44890
+ if (cachedToken3 && cachedToken3.expiresAt > now + 3e4) return cachedToken3.value;
44891
+ const { token, ttl } = await mintAccessToken(conn.serviceAccount);
44892
+ cachedToken3 = { value: token, expiresAt: ttl > 0 ? now + ttl * 1e3 : now + 5 * 6e4 };
44893
+ return token;
44894
+ }
44895
+ function accessUrl(refPath, defaultProject) {
44896
+ if (refPath.startsWith("projects/")) {
44897
+ const hasVersion = /\/versions\/[^/]+$/.test(refPath);
44898
+ const full = hasVersion ? refPath : `${refPath.replace(/\/+$/, "")}/versions/latest`;
44899
+ return `${API_BASE}/${full}:access`;
44900
+ }
44901
+ const parts = refPath.replace(/^\/+/, "").split("/").filter(Boolean);
44902
+ let project;
44903
+ let secret;
44904
+ let version = "latest";
44905
+ if (parts.length >= 2) {
44906
+ [project, secret, version = "latest"] = parts;
44907
+ } else if (parts.length === 1) {
44908
+ project = defaultProject;
44909
+ secret = parts[0];
44910
+ } else {
44911
+ throw new Error(`GCP reference must be 'gcp:<project>/<secret>[/<version>]' (got 'gcp:${refPath}')`);
44912
+ }
44913
+ if (!project) {
44914
+ throw new Error(
44915
+ `GCP reference 'gcp:${refPath}' has no project and no default is set (set GCP_PROJECT or settings.secrets.gcp.project, or write 'gcp:<project>/<secret>')`
44916
+ );
44917
+ }
44918
+ return `${API_BASE}/projects/${project}/secrets/${secret}/versions/${version}:access`;
44919
+ }
44920
+ async function resolve4(refBody) {
44921
+ const hash = refBody.lastIndexOf("#");
44922
+ const refPath = hash < 0 ? refBody : refBody.slice(0, hash);
44923
+ const key = hash < 0 ? null : refBody.slice(hash + 1);
44924
+ const conn = resolveConn5();
44925
+ const url = accessUrl(refPath, conn.defaultProject);
44926
+ const now = Date.now();
44927
+ const hit = secretCache3.get(url);
44928
+ const rawPayload = hit && hit.expiresAt > now ? hit.value : await fetchPayload(conn, url, refBody);
44929
+ if (key === null) return rawPayload;
44930
+ let parsed;
44931
+ try {
44932
+ parsed = JSON.parse(rawPayload);
44933
+ } catch {
44934
+ throw new Error(`GCP secret '${refPath}' is not JSON, so key '${key}' cannot be read (drop the '#${key}')`);
44935
+ }
44936
+ if (!(key in parsed)) throw new Error(`GCP secret '${refPath}' has no key '${key}'`);
44937
+ return String(parsed[key]);
44938
+ }
44939
+ async function fetchPayload(conn, url, refBody) {
44940
+ const res = await fetch(url, { headers: { authorization: `Bearer ${await accessToken2(conn)}` } });
44941
+ if (!res.ok) {
44942
+ const text = await res.text().catch(() => "");
44943
+ throw new Error(`GCP Secret Manager ${res.status} for '${refBody}': ${text.slice(0, 300)}`);
44944
+ }
44945
+ const json = await res.json();
44946
+ const data = json?.payload?.data;
44947
+ if (data === void 0) throw new Error(`GCP secret '${refBody}' returned no payload data`);
44948
+ const value = Buffer.from(data, "base64").toString("utf8");
44949
+ secretCache3.set(url, { value, expiresAt: Date.now() + 5 * 6e4 });
44950
+ return value;
44951
+ }
44952
+ var gcpSecretManagerProvider = {
44953
+ scheme: "gcp",
44954
+ resolve: (refBody) => resolve4(refBody)
44955
+ };
44956
+
44808
44957
  // src/main/secrets/index.ts
44809
44958
  registerSecretProvider(vaultProvider);
44810
44959
  registerSecretProvider(awsSecretsProvider);
44811
44960
  registerSecretProvider(azureKeyVaultProvider);
44812
44961
  registerSecretProvider(onePasswordProvider);
44962
+ registerSecretProvider(gcpSecretManagerProvider);
44813
44963
 
44814
44964
  // src/main/ipc/secret-handler.ts
44815
44965
  var secretStore = {};
@@ -44916,7 +45066,14 @@ function buildUrl(baseUrl, params, vars) {
44916
45066
  return url + sep + qs;
44917
45067
  }
44918
45068
  function mergeVars(envVars, collectionVars, globals2, localVars = {}, dynamicVars = {}) {
44919
- return { ...dynamicVars, ...globals2, ...collectionVars, ...envVars, ...localVars };
45069
+ const out = {};
45070
+ for (const src of [dynamicVars, globals2, collectionVars, envVars, localVars]) {
45071
+ for (const [k68, v60] of Object.entries(src ?? {})) {
45072
+ if (v60 == null) continue;
45073
+ out[k68] = v60;
45074
+ }
45075
+ }
45076
+ return out;
44920
45077
  }
44921
45078
 
44922
45079
  // src/main/script-runner.ts
@@ -44969,10 +45126,10 @@ var Hooks = class {
44969
45126
  * @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
44970
45127
  * @public
44971
45128
  */
44972
- run(name, env5) {
45129
+ run(name, env6) {
44973
45130
  this[name] = this[name] || [];
44974
45131
  this[name].forEach(function(callback) {
44975
- callback.call(env5 && env5.context ? env5.context : env5, env5);
45132
+ callback.call(env6 && env6.context ? env6.context : env6, env6);
44976
45133
  });
44977
45134
  }
44978
45135
  };
@@ -45225,12 +45382,12 @@ var Jsep = class _Jsep {
45225
45382
  */
45226
45383
  runHook(name, node) {
45227
45384
  if (_Jsep.hooks[name]) {
45228
- const env5 = {
45385
+ const env6 = {
45229
45386
  context: this,
45230
45387
  node
45231
45388
  };
45232
- _Jsep.hooks.run(name, env5);
45233
- return env5.node;
45389
+ _Jsep.hooks.run(name, env6);
45390
+ return env6.node;
45234
45391
  }
45235
45392
  return node;
45236
45393
  }
@@ -45241,14 +45398,14 @@ var Jsep = class _Jsep {
45241
45398
  */
45242
45399
  searchHook(name) {
45243
45400
  if (_Jsep.hooks[name]) {
45244
- const env5 = {
45401
+ const env6 = {
45245
45402
  context: this
45246
45403
  };
45247
45404
  _Jsep.hooks[name].find(function(callback) {
45248
- callback.call(env5.context, env5);
45249
- return env5.node;
45405
+ callback.call(env6.context, env6);
45406
+ return env6.node;
45250
45407
  });
45251
- return env5.node;
45408
+ return env6.node;
45252
45409
  }
45253
45410
  }
45254
45411
  /**
@@ -45846,10 +46003,10 @@ var CONDITIONAL_EXP = "ConditionalExpression";
45846
46003
  var ternary = {
45847
46004
  name: "ternary",
45848
46005
  init(jsep2) {
45849
- jsep2.hooks.add("after-expression", function gobbleTernary(env5) {
45850
- if (env5.node && this.code === jsep2.QUMARK_CODE) {
46006
+ jsep2.hooks.add("after-expression", function gobbleTernary(env6) {
46007
+ if (env6.node && this.code === jsep2.QUMARK_CODE) {
45851
46008
  this.index++;
45852
- const test = env5.node;
46009
+ const test = env6.node;
45853
46010
  const consequent = this.gobbleExpression();
45854
46011
  if (!consequent) {
45855
46012
  this.throwError("Expected expression");
@@ -45861,7 +46018,7 @@ var ternary = {
45861
46018
  if (!alternate) {
45862
46019
  this.throwError("Expected expression");
45863
46020
  }
45864
- env5.node = {
46021
+ env6.node = {
45865
46022
  type: CONDITIONAL_EXP,
45866
46023
  test,
45867
46024
  consequent,
@@ -45872,9 +46029,9 @@ var ternary = {
45872
46029
  while (newTest.right.operator && jsep2.binary_ops[newTest.right.operator] <= 0.9) {
45873
46030
  newTest = newTest.right;
45874
46031
  }
45875
- env5.node.test = newTest.right;
45876
- newTest.right = env5.node;
45877
- env5.node = test;
46032
+ env6.node.test = newTest.right;
46033
+ newTest.right = env6.node;
46034
+ env6.node = test;
45878
46035
  }
45879
46036
  } else {
45880
46037
  this.throwError("Expected :");
@@ -45889,7 +46046,7 @@ var BSLASH_CODE = 92;
45889
46046
  var index = {
45890
46047
  name: "regex",
45891
46048
  init(jsep2) {
45892
- jsep2.hooks.add("gobble-token", function gobbleRegexLiteral(env5) {
46049
+ jsep2.hooks.add("gobble-token", function gobbleRegexLiteral(env6) {
45893
46050
  if (this.code === FSLASH_CODE) {
45894
46051
  const patternIndex = ++this.index;
45895
46052
  let inCharSet = false;
@@ -45911,13 +46068,13 @@ var index = {
45911
46068
  } catch (e20) {
45912
46069
  this.throwError(e20.message);
45913
46070
  }
45914
- env5.node = {
46071
+ env6.node = {
45915
46072
  type: jsep2.LITERAL,
45916
46073
  value,
45917
46074
  raw: this.expr.slice(patternIndex - 1, this.index)
45918
46075
  };
45919
- env5.node = this.gobbleTokenProperty(env5.node);
45920
- return env5.node;
46076
+ env6.node = this.gobbleTokenProperty(env6.node);
46077
+ return env6.node;
45921
46078
  }
45922
46079
  if (this.code === jsep2.OBRACK_CODE) {
45923
46080
  inCharSet = true;
@@ -45941,41 +46098,41 @@ var plugin = {
45941
46098
  init(jsep2) {
45942
46099
  const updateNodeTypes = [jsep2.IDENTIFIER, jsep2.MEMBER_EXP];
45943
46100
  plugin.assignmentOperators.forEach((op) => jsep2.addBinaryOp(op, plugin.assignmentPrecedence, true));
45944
- jsep2.hooks.add("gobble-token", function gobbleUpdatePrefix(env5) {
46101
+ jsep2.hooks.add("gobble-token", function gobbleUpdatePrefix(env6) {
45945
46102
  const code = this.code;
45946
46103
  if (plugin.updateOperators.some((c70) => c70 === code && c70 === this.expr.charCodeAt(this.index + 1))) {
45947
46104
  this.index += 2;
45948
- env5.node = {
46105
+ env6.node = {
45949
46106
  type: "UpdateExpression",
45950
46107
  operator: code === PLUS_CODE ? "++" : "--",
45951
46108
  argument: this.gobbleTokenProperty(this.gobbleIdentifier()),
45952
46109
  prefix: true
45953
46110
  };
45954
- if (!env5.node.argument || !updateNodeTypes.includes(env5.node.argument.type)) {
45955
- this.throwError(`Unexpected ${env5.node.operator}`);
46111
+ if (!env6.node.argument || !updateNodeTypes.includes(env6.node.argument.type)) {
46112
+ this.throwError(`Unexpected ${env6.node.operator}`);
45956
46113
  }
45957
46114
  }
45958
46115
  });
45959
- jsep2.hooks.add("after-token", function gobbleUpdatePostfix(env5) {
45960
- if (env5.node) {
46116
+ jsep2.hooks.add("after-token", function gobbleUpdatePostfix(env6) {
46117
+ if (env6.node) {
45961
46118
  const code = this.code;
45962
46119
  if (plugin.updateOperators.some((c70) => c70 === code && c70 === this.expr.charCodeAt(this.index + 1))) {
45963
- if (!updateNodeTypes.includes(env5.node.type)) {
45964
- this.throwError(`Unexpected ${env5.node.operator}`);
46120
+ if (!updateNodeTypes.includes(env6.node.type)) {
46121
+ this.throwError(`Unexpected ${env6.node.operator}`);
45965
46122
  }
45966
46123
  this.index += 2;
45967
- env5.node = {
46124
+ env6.node = {
45968
46125
  type: "UpdateExpression",
45969
46126
  operator: code === PLUS_CODE ? "++" : "--",
45970
- argument: env5.node,
46127
+ argument: env6.node,
45971
46128
  prefix: false
45972
46129
  };
45973
46130
  }
45974
46131
  }
45975
46132
  });
45976
- jsep2.hooks.add("after-expression", function gobbleAssignment(env5) {
45977
- if (env5.node) {
45978
- updateBinariesToAssignments(env5.node);
46133
+ jsep2.hooks.add("after-expression", function gobbleAssignment(env6) {
46134
+ if (env6.node) {
46135
+ updateBinariesToAssignments(env6.node);
45979
46136
  }
45980
46137
  });
45981
46138
  function updateBinariesToAssignments(node) {
@@ -47004,12 +47161,12 @@ function patchGlobals(patch) {
47004
47161
  }
47005
47162
 
47006
47163
  // src/main/auth-builder.ts
47007
- var import_node_crypto3 = __toESM(require("node:crypto"));
47164
+ var import_node_crypto4 = __toESM(require("node:crypto"));
47008
47165
  var import_node_http = require("node:http");
47009
47166
  var import_promises2 = require("node:fs/promises");
47010
47167
 
47011
47168
  // src/main/ntlm.ts
47012
- var import_node_crypto2 = __toESM(require("node:crypto"));
47169
+ var import_node_crypto3 = __toESM(require("node:crypto"));
47013
47170
  var SIGNATURE = Buffer.from("NTLMSSP\0", "latin1");
47014
47171
  var F_UNICODE = 1;
47015
47172
  var F_OEM = 2;
@@ -47075,7 +47232,7 @@ function md4(msg) {
47075
47232
  return out;
47076
47233
  }
47077
47234
  var utf16le = (s71) => Buffer.from(s71, "utf16le");
47078
- var hmacMd5 = (key, data) => import_node_crypto2.default.createHmac("md5", key).update(data).digest();
47235
+ var hmacMd5 = (key, data) => import_node_crypto3.default.createHmac("md5", key).update(data).digest();
47079
47236
  function ntowfv2(user, domain, password) {
47080
47237
  const ntHash = md4(utf16le(password));
47081
47238
  return hmacMd5(ntHash, utf16le(user.toUpperCase() + domain));
@@ -47133,7 +47290,7 @@ function computeNtlmV2Response(opts) {
47133
47290
  function createType3Message(opts) {
47134
47291
  const domain = opts.domain ?? "";
47135
47292
  const workstation = opts.workstation ?? "";
47136
- const clientChallenge = opts.clientChallenge ?? import_node_crypto2.default.randomBytes(8);
47293
+ const clientChallenge = opts.clientChallenge ?? import_node_crypto3.default.randomBytes(8);
47137
47294
  const timestamp = filetime(opts.timestamp ?? Date.now());
47138
47295
  const { ntResponse, lmResponse } = computeNtlmV2Response({
47139
47296
  user: opts.user,
@@ -47227,7 +47384,7 @@ function parseDigestChallenge(wwwAuth) {
47227
47384
  };
47228
47385
  }
47229
47386
  function md5(s71) {
47230
- return import_node_crypto3.default.createHash("md5").update(s71).digest("hex");
47387
+ return import_node_crypto4.default.createHash("md5").update(s71).digest("hex");
47231
47388
  }
47232
47389
  function buildDigestAuthHeader(challenge, username, password, method, uri) {
47233
47390
  const { realm, nonce, qop, algorithm, opaque } = challenge;
@@ -47239,7 +47396,7 @@ function buildDigestAuthHeader(challenge, username, password, method, uri) {
47239
47396
  let cnonce;
47240
47397
  if (qop === "auth" || qop === "auth-int") {
47241
47398
  nc = "00000001";
47242
- cnonce = import_node_crypto3.default.randomBytes(8).toString("hex");
47399
+ cnonce = import_node_crypto4.default.randomBytes(8).toString("hex");
47243
47400
  response = md5(`${ha1}:${nonce}:${nc}:${cnonce}:${qop}:${ha22}`);
47244
47401
  } else {
47245
47402
  response = md5(`${ha1}:${nonce}:${ha22}`);
@@ -47400,12 +47557,12 @@ async function fetchOAuth2Token(auth, vars) {
47400
47557
  throw new Error(`OAuth 2.0 token request failed (${resp.status}): ${body}`);
47401
47558
  }
47402
47559
  const json = await resp.json();
47403
- const accessToken2 = String(json["access_token"] ?? "");
47404
- if (!accessToken2) throw new Error("OAuth 2.0: token response missing access_token.");
47560
+ const accessToken3 = String(json["access_token"] ?? "");
47561
+ if (!accessToken3) throw new Error("OAuth 2.0: token response missing access_token.");
47405
47562
  const expiresIn = Number(json["expires_in"] ?? 3600);
47406
47563
  const expiresAt = Date.now() + expiresIn * 1e3;
47407
47564
  return {
47408
- accessToken: accessToken2,
47565
+ accessToken: accessToken3,
47409
47566
  expiresAt,
47410
47567
  refreshToken: json["refresh_token"] ? String(json["refresh_token"]) : void 0
47411
47568
  };
@@ -48130,7 +48287,7 @@ var APP_URL = (process.env.APP_URL || "").replace(/\/+$/, "");
48130
48287
  var AGENT_TOKEN = process.env.AGENT_TOKEN || "";
48131
48288
  var RUNTIME_TOKEN = process.env.RUNTIME_TOKEN || "";
48132
48289
  var POLL_MS = Number(process.env.POLL_INTERVAL_MS || 5e3);
48133
- var VERSION = true ? "0.7.3" : "";
48290
+ var VERSION = true ? "0.7.5" : "";
48134
48291
  var authHeaders = AGENT_TOKEN ? { Authorization: `Bearer ${AGENT_TOKEN}` } : RUNTIME_TOKEN ? { "X-Runtime-Token": RUNTIME_TOKEN } : {};
48135
48292
  async function postResult(m75, fields) {
48136
48293
  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.7.3",
3
+ "version": "0.7.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",