@testsmith/api-spector-agent 0.9.18 → 0.9.19

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 +18 -6
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -80647,6 +80647,13 @@ async function performNtlmRequest(opts) {
80647
80647
  });
80648
80648
  }
80649
80649
  }
80650
+ function oauth2FetchError(err, url2, label) {
80651
+ const cause = err && typeof err === "object" ? err.cause : void 0;
80652
+ const causeObj = cause && typeof cause === "object" ? cause : void 0;
80653
+ const detail = typeof causeObj?.message === "string" && causeObj.message || (err instanceof Error ? err.message : String(err));
80654
+ const code = typeof causeObj?.code === "string" ? ` (${causeObj.code})` : "";
80655
+ return new Error(`OAuth 2.0 ${label} to ${url2} failed: ${detail}${code}`);
80656
+ }
80650
80657
  async function fetchOAuth2Token(auth, vars) {
80651
80658
  const flow = auth.oauth2Flow ?? "client_credentials";
80652
80659
  if (flow === "authorization_code") {
@@ -80677,11 +80684,16 @@ async function fetchOAuth2Token(auth, vars) {
80677
80684
  params.set("password", password);
80678
80685
  }
80679
80686
  const { fetch: nodeFetch } = await Promise.resolve().then(() => __toESM(require_undici()));
80680
- const resp = await nodeFetch(tokenUrl, {
80681
- method: "POST",
80682
- headers: { "Content-Type": "application/x-www-form-urlencoded" },
80683
- body: params.toString()
80684
- });
80687
+ let resp;
80688
+ try {
80689
+ resp = await nodeFetch(tokenUrl, {
80690
+ method: "POST",
80691
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
80692
+ body: params.toString()
80693
+ });
80694
+ } catch (err) {
80695
+ throw oauth2FetchError(err, tokenUrl, "token request");
80696
+ }
80685
80697
  if (!resp.ok) {
80686
80698
  const body = await resp.text();
80687
80699
  throw new Error(`OAuth 2.0 token request failed (${resp.status}): ${body}`);
@@ -81641,7 +81653,7 @@ var APP_URL = (process.env.APP_URL || "").replace(/\/+$/, "");
81641
81653
  var AGENT_TOKEN = process.env.AGENT_TOKEN || "";
81642
81654
  var RUNTIME_TOKEN = process.env.RUNTIME_TOKEN || "";
81643
81655
  var POLL_MS = Number(process.env.POLL_INTERVAL_MS || 5e3);
81644
- var VERSION = true ? "0.9.18" : "";
81656
+ var VERSION = true ? "0.9.19" : "";
81645
81657
  var authHeaders = AGENT_TOKEN ? { Authorization: `Bearer ${AGENT_TOKEN}` } : RUNTIME_TOKEN ? { "X-Runtime-Token": RUNTIME_TOKEN } : {};
81646
81658
  async function postResult(m6, fields) {
81647
81659
  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.18",
3
+ "version": "0.9.19",
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",