unforgit 0.11.27 → 0.11.29

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.js CHANGED
@@ -51,6 +51,17 @@ function truncate(text, maxLength) {
51
51
  if (singleLine.length <= maxLength) return singleLine;
52
52
  return singleLine.slice(0, maxLength - 3) + "...";
53
53
  }
54
+ var REMOTE_PROBE_TIMEOUT_MS = 5e3;
55
+ async function probeFetch(url, init = {}, timeoutMs = REMOTE_PROBE_TIMEOUT_MS) {
56
+ try {
57
+ return await fetch(url, { ...init, signal: AbortSignal.timeout(timeoutMs) });
58
+ } catch (err) {
59
+ if (err instanceof DOMException && (err.name === "TimeoutError" || err.name === "AbortError")) {
60
+ throw new Error(`Request timed out after ${timeoutMs}ms`);
61
+ }
62
+ throw err;
63
+ }
64
+ }
54
65
  function maskKey(key) {
55
66
  if (key.length <= 10) return "***";
56
67
  return `${key.slice(0, 6)}...${key.slice(-4)}`;
@@ -2890,10 +2901,10 @@ authCommand.command("status").description("Check authentication status").action(
2890
2901
  if (config.remote.url) {
2891
2902
  logger.info("\nTesting connection...");
2892
2903
  try {
2893
- const res = await fetch(`${config.remote.url}/health`);
2904
+ const res = await probeFetch(`${config.remote.url}/health`);
2894
2905
  if (res.ok) {
2895
2906
  logger.info(" [ok] Server reachable");
2896
- const authRes = await fetch(`${config.remote.url}/v1/api-keys`, {
2907
+ const authRes = await probeFetch(`${config.remote.url}/v1/api-keys`, {
2897
2908
  headers: { Authorization: `Bearer ${apiKey}` }
2898
2909
  });
2899
2910
  if (authRes.ok) {
@@ -3660,7 +3671,7 @@ var doctorCommand = new Command27("doctor").description("Check system health and
3660
3671
  });
3661
3672
  }
3662
3673
  try {
3663
- const res = await fetch(`${config.remote.url}/health`);
3674
+ const res = await probeFetch(`${config.remote.url}/health`);
3664
3675
  if (res.ok) {
3665
3676
  results.push({ check: "remote", status: "ok", message: `Server reachable at ${config.remote.url}` });
3666
3677
  if (apiKey) {