Files
openwork/patches/@modelcontextprotocol__client@2.3.1.patch
Omar McAdam 4f388226be fix(deps): consolidate Dependabot security updates (#6271)
* fix(den-web): use JSX elements in static-render tests

* fix(deps): upgrade hono to 4.13.11

* fix(deps): upgrade follow-redirects to 1.16.1

* fix(deps): upgrade vite to 6.4.4 in both workspaces

* fix(deps): upgrade patched MCP SDK to 1.32.1

* fix(deps): upgrade patched MCP client to 2.3.1

* fix(deps): upgrade MCP server to 2.3.1
2026-10-20 16:32:10 -07:00

53 lines
4.2 KiB
Diff

diff --git a/dist/index.cjs b/dist/index.cjs
--- a/dist/index.cjs
+++ b/dist/index.cjs
@@ -666,9 +666,19 @@ async function auth(provider, options) {
*/
function determineScope(options) {
const { requestedScope, resourceMetadata, authServerMetadata, clientMetadata } = options;
- let effectiveScope = requestedScope || resourceMetadata?.scopes_supported?.join(" ") || clientMetadata.scope;
- if (effectiveScope && authServerMetadata?.scopes_supported?.includes("offline_access") && !effectiveScope.split(" ").includes("offline_access") && clientMetadata.grant_types?.includes("refresh_token")) effectiveScope = `${effectiveScope} offline_access`;
- return effectiveScope;
+ const requiredScopes = requestedScope?.split(/\s+/).filter(Boolean) ?? [];
+ const selectedScopes = clientMetadata.scope?.split(/\s+/).filter(Boolean) ?? [];
+ const authorizationServerScopes = authServerMetadata?.scopes_supported;
+ const resourceScopes = resourceMetadata?.scopes_supported;
+ const advertisedScopes = [...new Set([...(authorizationServerScopes ?? []), ...(resourceScopes ?? [])])];
+ if (advertisedScopes.length > 0) {
+ const unsupportedScope = selectedScopes.find((selectedScope) => !advertisedScopes.includes(selectedScope));
+ if (unsupportedScope) throw new Error(`The selected OAuth scope is not advertised by the authorization server or protected resource: ${unsupportedScope}`);
+ }
+ const effectiveScopes = [...new Set([...requiredScopes, ...selectedScopes])];
+ if (effectiveScopes.length === 0) effectiveScopes.push(...new Set(resourceScopes ?? authorizationServerScopes ?? []));
+ if (effectiveScopes.length > 0 && authServerMetadata?.scopes_supported?.includes("offline_access") && !effectiveScopes.includes("offline_access") && clientMetadata.grant_types?.includes("refresh_token")) effectiveScopes.push("offline_access");
+ return effectiveScopes.length > 0 ? effectiveScopes.join(" ") : void 0;
}
async function authInternal(provider, { serverUrl, authorizationCode, iss, scope, resourceMetadataUrl, fetchFn, skipIssuerMetadataValidation, forceReauthorization }) {
const clientMetadata = resolveClientMetadata(provider);
diff --git a/dist/index.mjs b/dist/index.mjs
--- a/dist/index.mjs
+++ b/dist/index.mjs
@@ -663,9 +663,19 @@ async function auth(provider, options) {
*/
function determineScope(options) {
const { requestedScope, resourceMetadata, authServerMetadata, clientMetadata } = options;
- let effectiveScope = requestedScope || resourceMetadata?.scopes_supported?.join(" ") || clientMetadata.scope;
- if (effectiveScope && authServerMetadata?.scopes_supported?.includes("offline_access") && !effectiveScope.split(" ").includes("offline_access") && clientMetadata.grant_types?.includes("refresh_token")) effectiveScope = `${effectiveScope} offline_access`;
- return effectiveScope;
+ const requiredScopes = requestedScope?.split(/\s+/).filter(Boolean) ?? [];
+ const selectedScopes = clientMetadata.scope?.split(/\s+/).filter(Boolean) ?? [];
+ const authorizationServerScopes = authServerMetadata?.scopes_supported;
+ const resourceScopes = resourceMetadata?.scopes_supported;
+ const advertisedScopes = [...new Set([...(authorizationServerScopes ?? []), ...(resourceScopes ?? [])])];
+ if (advertisedScopes.length > 0) {
+ const unsupportedScope = selectedScopes.find((selectedScope) => !advertisedScopes.includes(selectedScope));
+ if (unsupportedScope) throw new Error(`The selected OAuth scope is not advertised by the authorization server or protected resource: ${unsupportedScope}`);
+ }
+ const effectiveScopes = [...new Set([...requiredScopes, ...selectedScopes])];
+ if (effectiveScopes.length === 0) effectiveScopes.push(...new Set(resourceScopes ?? authorizationServerScopes ?? []));
+ if (effectiveScopes.length > 0 && authServerMetadata?.scopes_supported?.includes("offline_access") && !effectiveScopes.includes("offline_access") && clientMetadata.grant_types?.includes("refresh_token")) effectiveScopes.push("offline_access");
+ return effectiveScopes.length > 0 ? effectiveScopes.join(" ") : void 0;
}
async function authInternal(provider, { serverUrl, authorizationCode, iss, scope, resourceMetadataUrl, fetchFn, skipIssuerMetadataValidation, forceReauthorization }) {
const clientMetadata = resolveClientMetadata(provider);