mcp-remote 0.0.10-3 → 0.0.10
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/react/index.js +52 -16
- package/package.json +1 -1
package/dist/react/index.js
CHANGED
|
@@ -121,18 +121,21 @@ var BrowserOAuthClientProvider = class {
|
|
|
121
121
|
* Extended popup-based authorization method specific to browser environments
|
|
122
122
|
*/
|
|
123
123
|
async openAuthorizationPopup(authorizationUrl, metadata) {
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
stateKey
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
124
|
+
const existingState = authorizationUrl.searchParams.get("state");
|
|
125
|
+
if (!existingState) {
|
|
126
|
+
const state = Math.random().toString(36).substring(2);
|
|
127
|
+
const stateKey = `${this.storageKeyPrefix}:state_${state}`;
|
|
128
|
+
localStorage.setItem(
|
|
129
|
+
stateKey,
|
|
130
|
+
JSON.stringify({
|
|
131
|
+
authorizationUrl: authorizationUrl.toString(),
|
|
132
|
+
metadata,
|
|
133
|
+
serverUrlHash: this.serverUrlHash,
|
|
134
|
+
expiry: +/* @__PURE__ */ new Date() + 1e3 * 60 * 5
|
|
135
|
+
})
|
|
136
|
+
);
|
|
137
|
+
authorizationUrl.searchParams.set("state", state);
|
|
138
|
+
}
|
|
136
139
|
const authUrl = authorizationUrl.toString();
|
|
137
140
|
localStorage.setItem(this.getKey("auth_url"), authUrl);
|
|
138
141
|
try {
|
|
@@ -193,6 +196,7 @@ var McpClient = class {
|
|
|
193
196
|
// Authentication state
|
|
194
197
|
metadata;
|
|
195
198
|
authUrlRef;
|
|
199
|
+
authState;
|
|
196
200
|
codeVerifier;
|
|
197
201
|
connecting = false;
|
|
198
202
|
// Update callbacks
|
|
@@ -442,6 +446,19 @@ var McpClient = class {
|
|
|
442
446
|
});
|
|
443
447
|
await this.authProvider.saveCodeVerifier(codeVerifier);
|
|
444
448
|
this.codeVerifier = codeVerifier;
|
|
449
|
+
const state = Math.random().toString(36).substring(2);
|
|
450
|
+
const stateKey = `${this.options.storageKeyPrefix}:state_${state}`;
|
|
451
|
+
localStorage.setItem(
|
|
452
|
+
stateKey,
|
|
453
|
+
JSON.stringify({
|
|
454
|
+
authorizationUrl: authorizationUrl.toString(),
|
|
455
|
+
metadata: this.metadata,
|
|
456
|
+
serverUrlHash: this.authProvider.serverUrlHash,
|
|
457
|
+
expiry: +/* @__PURE__ */ new Date() + 1e3 * 60 * 5
|
|
458
|
+
})
|
|
459
|
+
);
|
|
460
|
+
authorizationUrl.searchParams.set("state", state);
|
|
461
|
+
this.authState = state;
|
|
445
462
|
this.authUrlRef = authorizationUrl;
|
|
446
463
|
this.setAuthUrl(authorizationUrl.toString());
|
|
447
464
|
return authorizationUrl;
|
|
@@ -583,13 +600,32 @@ var McpClient = class {
|
|
|
583
600
|
* Manually trigger authentication
|
|
584
601
|
*/
|
|
585
602
|
async authenticate() {
|
|
586
|
-
if (!this.
|
|
587
|
-
|
|
603
|
+
if (!this.authProvider) {
|
|
604
|
+
try {
|
|
605
|
+
this.addLog("info", "Discovering OAuth metadata...");
|
|
606
|
+
this.metadata = await discoverOAuthMetadata(this.url);
|
|
607
|
+
this.addLog("debug", `OAuth metadata: ${this.metadata ? "Found" : "Not available"}`);
|
|
608
|
+
if (!this.metadata) {
|
|
609
|
+
throw new Error("No OAuth metadata available");
|
|
610
|
+
}
|
|
611
|
+
this.initAuthProvider();
|
|
612
|
+
} catch (err) {
|
|
613
|
+
this.addLog("error", `Failed to discover OAuth metadata: ${err instanceof Error ? err.message : String(err)}`);
|
|
614
|
+
return void 0;
|
|
615
|
+
}
|
|
588
616
|
}
|
|
589
|
-
|
|
617
|
+
try {
|
|
618
|
+
if (!this.authUrlRef || !this.authUrlRef.searchParams.get("state")) {
|
|
619
|
+
await this.startAuthFlow();
|
|
620
|
+
}
|
|
621
|
+
if (!this.authUrlRef) {
|
|
622
|
+
throw new Error("Failed to create authorization URL");
|
|
623
|
+
}
|
|
590
624
|
return this.authUrlRef.toString();
|
|
625
|
+
} catch (err) {
|
|
626
|
+
this.addLog("error", `Error preparing manual authentication: ${err instanceof Error ? err.message : String(err)}`);
|
|
627
|
+
return void 0;
|
|
591
628
|
}
|
|
592
|
-
return void 0;
|
|
593
629
|
}
|
|
594
630
|
/**
|
|
595
631
|
* Clear all localStorage items for this server
|