@testsmith/api-spector-agent 0.9.0 → 0.9.2

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 +24 -18
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -73627,20 +73627,21 @@ function readFileTrim(path) {
73627
73627
  }
73628
73628
  function resolveConn() {
73629
73629
  const cfg = getSecretsConfig()?.vault ?? {};
73630
- const address = env("VAULT_ADDR", "API_SPECTOR_VAULT_ADDR") ?? cfg.address;
73630
+ const address = env("VAULT_ADDR", "BAO_ADDR", "API_SPECTOR_VAULT_ADDR") ?? cfg.address;
73631
73631
  if (!address) {
73632
- throw new Error("Vault is not configured: set VAULT_ADDR (or settings.secrets.vault.address)");
73633
- }
73634
- const token = env("VAULT_TOKEN", "API_SPECTOR_VAULT_TOKEN") ?? readFileTrim((0, import_node_path.join)((0, import_node_os.homedir)(), ".vault-token"));
73635
- const roleId = env("VAULT_ROLE_ID", "API_SPECTOR_VAULT_ROLE_ID") ?? cfg.roleId;
73636
- const secretId = env("VAULT_SECRET_ID", "API_SPECTOR_VAULT_SECRET_ID");
73637
- const jwt = env("VAULT_JWT", "API_SPECTOR_VAULT_JWT") ?? (env("VAULT_JWT_PATH", "API_SPECTOR_VAULT_JWT_PATH") ? readFileTrim(env("VAULT_JWT_PATH", "API_SPECTOR_VAULT_JWT_PATH")) : void 0);
73638
- const jwtRole = env("VAULT_JWT_ROLE", "API_SPECTOR_VAULT_JWT_ROLE") ?? cfg.jwtRole;
73639
- const explicit = env("VAULT_AUTH_METHOD", "API_SPECTOR_VAULT_AUTH_METHOD") ?? cfg.authMethod;
73632
+ throw new Error("Vault/OpenBao is not configured: set VAULT_ADDR or BAO_ADDR (or settings.secrets.vault.address)");
73633
+ }
73634
+ const token = env("VAULT_TOKEN", "BAO_TOKEN", "API_SPECTOR_VAULT_TOKEN") ?? readFileTrim((0, import_node_path.join)((0, import_node_os.homedir)(), ".vault-token")) ?? readFileTrim((0, import_node_path.join)((0, import_node_os.homedir)(), ".bao-token"));
73635
+ const roleId = env("VAULT_ROLE_ID", "BAO_ROLE_ID", "API_SPECTOR_VAULT_ROLE_ID") ?? cfg.roleId;
73636
+ const secretId = env("VAULT_SECRET_ID", "BAO_SECRET_ID", "API_SPECTOR_VAULT_SECRET_ID");
73637
+ const jwtPath = env("VAULT_JWT_PATH", "BAO_JWT_PATH", "API_SPECTOR_VAULT_JWT_PATH");
73638
+ const jwt = env("VAULT_JWT", "BAO_JWT", "API_SPECTOR_VAULT_JWT") ?? (jwtPath ? readFileTrim(jwtPath) : void 0);
73639
+ const jwtRole = env("VAULT_JWT_ROLE", "BAO_JWT_ROLE", "API_SPECTOR_VAULT_JWT_ROLE") ?? cfg.jwtRole;
73640
+ const explicit = env("VAULT_AUTH_METHOD", "BAO_AUTH_METHOD", "API_SPECTOR_VAULT_AUTH_METHOD") ?? cfg.authMethod;
73640
73641
  const authMethod = explicit ?? (token ? "token" : roleId ? "approle" : jwt ? "jwt" : "token");
73641
73642
  return {
73642
73643
  address: address.replace(/\/+$/, ""),
73643
- namespace: env("VAULT_NAMESPACE", "API_SPECTOR_VAULT_NAMESPACE") ?? cfg.namespace,
73644
+ namespace: env("VAULT_NAMESPACE", "BAO_NAMESPACE", "API_SPECTOR_VAULT_NAMESPACE") ?? cfg.namespace,
73644
73645
  authMethod,
73645
73646
  token,
73646
73647
  roleId,
@@ -73648,9 +73649,9 @@ function resolveConn() {
73648
73649
  jwt,
73649
73650
  jwtRole,
73650
73651
  loginMount: cfg.loginMount,
73651
- kvVersion: env("VAULT_KV_VERSION", "API_SPECTOR_VAULT_KV_VERSION") ?? cfg.kvVersion ?? "auto",
73652
- skipVerify: (env("VAULT_SKIP_VERIFY", "API_SPECTOR_VAULT_SKIP_VERIFY") ?? "").toLowerCase() === "true" || cfg.skipVerify === true,
73653
- caPath: env("VAULT_CACERT", "API_SPECTOR_VAULT_CACERT")
73652
+ kvVersion: env("VAULT_KV_VERSION", "BAO_KV_VERSION", "API_SPECTOR_VAULT_KV_VERSION") ?? cfg.kvVersion ?? "auto",
73653
+ skipVerify: (env("VAULT_SKIP_VERIFY", "BAO_SKIP_VERIFY", "API_SPECTOR_VAULT_SKIP_VERIFY") ?? "").toLowerCase() === "true" || cfg.skipVerify === true,
73654
+ caPath: env("VAULT_CACERT", "BAO_CACERT", "API_SPECTOR_VAULT_CACERT")
73654
73655
  };
73655
73656
  }
73656
73657
  var cachedToken = null;
@@ -73724,15 +73725,15 @@ async function clientToken(conn) {
73724
73725
  cachedToken = { value: token, expiresAt: ttl > 0 ? now + ttl * 1e3 : now + 5 * 6e4 };
73725
73726
  return token;
73726
73727
  }
73727
- async function readSecret(refBody) {
73728
+ async function readSecret(refBody, scheme) {
73728
73729
  const hash = refBody.lastIndexOf("#");
73729
73730
  if (hash < 0) {
73730
- throw new Error(`Vault reference must be 'vault:<path>#<key>' (got 'vault:${refBody}')`);
73731
+ throw new Error(`${scheme} reference must be '${scheme}:<path>#<key>' (got '${scheme}:${refBody}')`);
73731
73732
  }
73732
73733
  const path = refBody.slice(0, hash).replace(/^\/+/, "");
73733
73734
  const key = refBody.slice(hash + 1);
73734
73735
  if (!path || !key) {
73735
- throw new Error(`Vault reference must be 'vault:<path>#<key>' (got 'vault:${refBody}')`);
73736
+ throw new Error(`${scheme} reference must be '${scheme}:<path>#<key>' (got '${scheme}:${refBody}')`);
73736
73737
  }
73737
73738
  const conn = resolveConn();
73738
73739
  const cacheKey = `${conn.address}|${conn.namespace ?? ""}|${path}`;
@@ -73757,7 +73758,11 @@ async function readSecret(refBody) {
73757
73758
  }
73758
73759
  var vaultProvider = {
73759
73760
  scheme: "vault",
73760
- resolve: (refBody) => readSecret(refBody)
73761
+ resolve: (refBody) => readSecret(refBody, "vault")
73762
+ };
73763
+ var openBaoProvider = {
73764
+ scheme: "bao",
73765
+ resolve: (refBody) => readSecret(refBody, "bao")
73761
73766
  };
73762
73767
 
73763
73768
  // src/main/secrets/providers/sigv4.ts
@@ -74195,6 +74200,7 @@ var gcpSecretManagerProvider = {
74195
74200
 
74196
74201
  // src/main/secrets/index.ts
74197
74202
  registerSecretProvider(vaultProvider);
74203
+ registerSecretProvider(openBaoProvider);
74198
74204
  registerSecretProvider(awsSecretsProvider);
74199
74205
  registerSecretProvider(azureKeyVaultProvider);
74200
74206
  registerSecretProvider(onePasswordProvider);
@@ -81427,7 +81433,7 @@ var APP_URL = (process.env.APP_URL || "").replace(/\/+$/, "");
81427
81433
  var AGENT_TOKEN = process.env.AGENT_TOKEN || "";
81428
81434
  var RUNTIME_TOKEN = process.env.RUNTIME_TOKEN || "";
81429
81435
  var POLL_MS = Number(process.env.POLL_INTERVAL_MS || 5e3);
81430
- var VERSION = true ? "0.9.0" : "";
81436
+ var VERSION = true ? "0.9.2" : "";
81431
81437
  var authHeaders = AGENT_TOKEN ? { Authorization: `Bearer ${AGENT_TOKEN}` } : RUNTIME_TOKEN ? { "X-Runtime-Token": RUNTIME_TOKEN } : {};
81432
81438
  async function postResult(m6, fields) {
81433
81439
  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.0",
3
+ "version": "0.9.2",
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",