@mcp-use/client 2.0.0-beta.8 → 2.0.0-beta.9

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.
@@ -128,7 +128,7 @@ var Logger = class {
128
128
  var logger = Logger.get();
129
129
 
130
130
  // src/utils/version.ts
131
- var VERSION = "2.0.0-beta.7";
131
+ var VERSION = "2.0.0-beta.8";
132
132
  function getPackageVersion() {
133
133
  return VERSION;
134
134
  }
package/dist/index.js CHANGED
@@ -1108,7 +1108,7 @@ init_connector_telemetry();
1108
1108
  init_logging();
1109
1109
 
1110
1110
  // src/utils/version.ts
1111
- var VERSION = "2.0.0-beta.7";
1111
+ var VERSION = "2.0.0-beta.8";
1112
1112
  function getPackageVersion() {
1113
1113
  return VERSION;
1114
1114
  }
@@ -1473,7 +1473,7 @@ var HttpConnector = class extends BaseConnector {
1473
1473
  };
1474
1474
 
1475
1475
  // src/utils/version.ts
1476
- var VERSION = "2.0.0-beta.7";
1476
+ var VERSION = "2.0.0-beta.8";
1477
1477
  function getPackageVersion() {
1478
1478
  return VERSION;
1479
1479
  }
@@ -5210,19 +5210,20 @@ function useMcp(options) {
5210
5210
  addLog("info", "Triggering fresh OAuth authorization...");
5211
5211
  const parsedUrl = new URL(url);
5212
5212
  const baseUrl = parsedUrl.origin + parsedUrl.pathname.replace(/\/+$/, "");
5213
- try {
5214
- await auth2(freshAuthProvider, {
5215
- serverUrl: baseUrl,
5216
- fetchFn: freshAuthProvider.getProxyFetch?.()
5217
- });
5213
+ const authResult = await auth2(freshAuthProvider, {
5214
+ serverUrl: baseUrl,
5215
+ fetchFn: freshAuthProvider.getProxyFetch?.()
5216
+ });
5217
+ if (authResult === "AUTHORIZED") {
5218
5218
  addLog("info", "OAuth flow completed (tokens obtained)");
5219
- } catch (err) {
5220
- addLog(
5221
- "info",
5222
- "OAuth flow initiated (popup/redirect):",
5223
- err instanceof Error ? err.message : "Redirecting..."
5224
- );
5219
+ connectingRef.current = false;
5220
+ connectRef.current?.();
5221
+ return;
5225
5222
  }
5223
+ if (authResult !== "REDIRECT") {
5224
+ throw new Error(`Unexpected OAuth auth() result: ${authResult}`);
5225
+ }
5226
+ addLog("info", "OAuth authorization redirect initiated");
5226
5227
  const newAuthUrl = freshAuthProvider.getLastAttemptedAuthUrl?.();
5227
5228
  if (newAuthUrl) {
5228
5229
  setAuthUrl(newAuthUrl);
@@ -5288,11 +5289,8 @@ function useMcp(options) {
5288
5289
  }
5289
5290
  } catch (authError) {
5290
5291
  if (!isMountedRef.current) return;
5291
- setState("pending_auth");
5292
- addLog(
5293
- "error",
5294
- `Manual authentication failed: ${authError instanceof Error ? authError.message : String(authError)}`
5295
- );
5292
+ const error2 = authError instanceof Error ? authError : new Error(String(authError));
5293
+ failConnection(`Manual authentication failed: ${error2.message}`, error2);
5296
5294
  }
5297
5295
  } else if (currentState === "authenticating") {
5298
5296
  addLog(