@mcp-use/client 2.0.0-beta.5 → 2.0.0-beta.7
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/.tsbuildinfo +1 -1
- package/dist/auth/browser.d.ts +2 -0
- package/dist/auth/browser.d.ts.map +1 -1
- package/dist/auth/session-store.d.ts +5 -0
- package/dist/auth/session-store.d.ts.map +1 -1
- package/dist/index-browser.js +13 -1
- package/dist/index-browser.js.map +1 -1
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/react/index.js +41 -4
- package/dist/react/index.js.map +1 -1
- package/dist/react/types.d.ts +2 -0
- package/dist/react/types.d.ts.map +1 -1
- package/dist/react/useMcp-operations.d.ts.map +1 -1
- package/dist/react/useMcp.d.ts.map +1 -1
- package/dist/react/view/ViewRenderer.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/react/index.js
CHANGED
|
@@ -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.
|
|
1476
|
+
var VERSION = "2.0.0-beta.6";
|
|
1477
1477
|
function getPackageVersion() {
|
|
1478
1478
|
return VERSION;
|
|
1479
1479
|
}
|
|
@@ -1849,6 +1849,14 @@ var OAuthSessionStore = class _OAuthSessionStore {
|
|
|
1849
1849
|
async getTokenEndpoint() {
|
|
1850
1850
|
return (await this.discoveryState())?.authorizationServerMetadata?.token_endpoint ?? null;
|
|
1851
1851
|
}
|
|
1852
|
+
/**
|
|
1853
|
+
* Return the protected-resource URL selected during OAuth discovery.
|
|
1854
|
+
* Consumers can persist it and reuse it for server-side refresh exchanges.
|
|
1855
|
+
*/
|
|
1856
|
+
async getResource() {
|
|
1857
|
+
const resource = (await this.discoveryState())?.resourceMetadata?.resource;
|
|
1858
|
+
return typeof resource === "string" ? resource : null;
|
|
1859
|
+
}
|
|
1852
1860
|
};
|
|
1853
1861
|
|
|
1854
1862
|
// src/auth/browser.ts
|
|
@@ -2113,6 +2121,10 @@ var BrowserOAuthClientProvider = class {
|
|
|
2113
2121
|
getTokenEndpoint() {
|
|
2114
2122
|
return this.session.getTokenEndpoint();
|
|
2115
2123
|
}
|
|
2124
|
+
/** Return the protected-resource URL selected during OAuth discovery. */
|
|
2125
|
+
getResource() {
|
|
2126
|
+
return this.session.getResource();
|
|
2127
|
+
}
|
|
2116
2128
|
/**
|
|
2117
2129
|
* Return the stored public OAuth client ID. Browser providers do not retain
|
|
2118
2130
|
* client secrets.
|
|
@@ -4925,12 +4937,18 @@ function useMcp(options) {
|
|
|
4925
4937
|
if (tokens?.access_token) {
|
|
4926
4938
|
const expiresAt = tokens.expires_in ? Date.now() + tokens.expires_in * 1e3 : void 0;
|
|
4927
4939
|
let tokenEndpoint = null;
|
|
4940
|
+
let resource = null;
|
|
4928
4941
|
let clientCreds = null;
|
|
4929
4942
|
try {
|
|
4930
4943
|
tokenEndpoint = await authProviderRef.current.getTokenEndpoint?.() ?? null;
|
|
4931
4944
|
} catch {
|
|
4932
4945
|
tokenEndpoint = null;
|
|
4933
4946
|
}
|
|
4947
|
+
try {
|
|
4948
|
+
resource = await authProviderRef.current.getResource?.() ?? null;
|
|
4949
|
+
} catch {
|
|
4950
|
+
resource = null;
|
|
4951
|
+
}
|
|
4934
4952
|
try {
|
|
4935
4953
|
clientCreds = await authProviderRef.current.getClientCredentials?.() ?? null;
|
|
4936
4954
|
} catch {
|
|
@@ -4947,6 +4965,7 @@ function useMcp(options) {
|
|
|
4947
4965
|
refresh_token: tokens.refresh_token,
|
|
4948
4966
|
scope: tokens.scope,
|
|
4949
4967
|
...tokenEndpoint ? { token_endpoint: tokenEndpoint } : {},
|
|
4968
|
+
...resource ? { resource } : {},
|
|
4950
4969
|
...clientCreds?.client_id ? { client_id: clientCreds.client_id } : {},
|
|
4951
4970
|
...clientCreds?.client_secret ? { client_secret: clientCreds.client_secret } : {}
|
|
4952
4971
|
});
|
|
@@ -7355,6 +7374,9 @@ function ViewRendererBase({
|
|
|
7355
7374
|
const iframeRef = useRef4(null);
|
|
7356
7375
|
const bridgeRef = useRef4(null);
|
|
7357
7376
|
const containerRef = useRef4(null);
|
|
7377
|
+
const pendingBlobRevocationsRef = useRef4(
|
|
7378
|
+
/* @__PURE__ */ new Map()
|
|
7379
|
+
);
|
|
7358
7380
|
const connectionRef = useRef4(
|
|
7359
7381
|
source.kind === "live" ? source.connection : null
|
|
7360
7382
|
);
|
|
@@ -7510,10 +7532,18 @@ function ViewRendererBase({
|
|
|
7510
7532
|
}, [source.kind, liveResourceUri, preloadedHtml, cspMode, resolveSandboxUrl]);
|
|
7511
7533
|
useEffect5(() => {
|
|
7512
7534
|
const url = activeSandboxUrl;
|
|
7535
|
+
if (!url || url.protocol !== "blob:") return;
|
|
7536
|
+
const pending = pendingBlobRevocationsRef.current.get(url.href);
|
|
7537
|
+
if (pending) {
|
|
7538
|
+
clearTimeout(pending);
|
|
7539
|
+
pendingBlobRevocationsRef.current.delete(url.href);
|
|
7540
|
+
}
|
|
7513
7541
|
return () => {
|
|
7514
|
-
|
|
7542
|
+
const timer = setTimeout(() => {
|
|
7515
7543
|
URL.revokeObjectURL(url.href);
|
|
7516
|
-
|
|
7544
|
+
pendingBlobRevocationsRef.current.delete(url.href);
|
|
7545
|
+
}, 1e3);
|
|
7546
|
+
pendingBlobRevocationsRef.current.set(url.href, timer);
|
|
7517
7547
|
};
|
|
7518
7548
|
}, [activeSandboxUrl]);
|
|
7519
7549
|
const isBlobSandbox = activeSandboxUrl?.protocol === "blob:";
|
|
@@ -7574,7 +7604,14 @@ function ViewRendererBase({
|
|
|
7574
7604
|
iframe.setAttribute("allow", allowAttribute);
|
|
7575
7605
|
}
|
|
7576
7606
|
const readyPromise = waitForSandboxProxyReady(iframe);
|
|
7577
|
-
|
|
7607
|
+
if (activeSandboxUrl.protocol === "blob:") {
|
|
7608
|
+
const response = await fetch(activeSandboxUrl.href);
|
|
7609
|
+
const sandboxHtml = await response.text();
|
|
7610
|
+
if (disposed) return;
|
|
7611
|
+
iframe.srcdoc = sandboxHtml;
|
|
7612
|
+
} else {
|
|
7613
|
+
iframe.src = activeSandboxUrl.href;
|
|
7614
|
+
}
|
|
7578
7615
|
await readyPromise;
|
|
7579
7616
|
if (disposed) return;
|
|
7580
7617
|
const capabilities = {
|