@hubex/mcp 0.6.20260910 → 0.7.0

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/auth.js CHANGED
@@ -175,7 +175,12 @@ class RefreshingAuth {
175
175
  }
176
176
  /**
177
177
  * A service-token login never carries a refresh token, so ask for one.
178
- * Best-effort: without it we simply re-authenticate when the access token expires.
178
+ * Best-effort for "service"/"login": credentials were already proven by the
179
+ * preceding login call, so a failure here just means retrying at expiry.
180
+ * Fatal for "token": the user-typed token is otherwise never round-tripped
181
+ * against the server, so this request is the only thing that can catch a
182
+ * token issued for the wrong environment (dev/stg/prod) — swallowing it
183
+ * would report success on a token that doesn't actually work.
179
184
  */
180
185
  async acquireRefreshToken() {
181
186
  try {
@@ -186,6 +191,8 @@ class RefreshingAuth {
186
191
  this.absorb(result);
187
192
  }
188
193
  catch (err) {
194
+ if (this.config.authMode === "token")
195
+ throw err;
189
196
  console.error("[hubex-mcp] could not obtain a refresh token; will re-authenticate on expiry: " +
190
197
  `${err.message}`);
191
198
  }
@@ -201,7 +208,13 @@ class RefreshingAuth {
201
208
  const res = await fetch(url, init);
202
209
  if (!res.ok) {
203
210
  const body = await res.text().catch(() => "");
204
- throw new Error(`${init.method ?? "GET"} ${url} failed (HTTP ${res.status}): ${body.slice(0, 500)}`);
211
+ let message = `${init.method ?? "GET"} ${url} failed (HTTP ${res.status}): ${body.slice(0, 500)}`;
212
+ if (res.status === 401 || res.status === 403) {
213
+ message +=
214
+ ` Сейчас выбрано окружение HUBEX_ENV=${this.config.env}. Если токен получен в другом ` +
215
+ `окружении (dev/stg/prod), авторизация не пройдёт — проверь, что токен именно из ${this.config.env}.`;
216
+ }
217
+ throw new Error(message);
205
218
  }
206
219
  return (await res.json());
207
220
  }