@atxp/client 0.3.0 → 0.5.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/index.cjs +745 -142
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +745 -142
- package/dist/index.js.map +1 -1
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/client/auth.js +369 -99
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/client/auth.js.map +1 -1
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/client/streamableHttp.js +18 -18
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/client/streamableHttp.js.map +1 -1
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/auth/errors.js +162 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/auth/errors.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/auth.js +86 -14
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/auth.js.map +1 -1
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js +47 -9
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js.map +1 -1
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js +64 -5
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js.map +1 -1
- package/dist/node_modules/eventsource-parser/dist/index.js +1 -1
- package/dist/node_modules/eventsource-parser/dist/index.js.map +1 -1
- package/dist/node_modules/zod/{dist/esm/v3 → v3}/ZodError.js +3 -2
- package/dist/node_modules/zod/v3/ZodError.js.map +1 -0
- package/dist/node_modules/zod/v3/errors.js.map +1 -0
- package/dist/node_modules/zod/v3/helpers/errorUtil.js.map +1 -0
- package/dist/node_modules/zod/v3/helpers/parseUtil.js.map +1 -0
- package/dist/node_modules/zod/v3/helpers/util.js.map +1 -0
- package/dist/node_modules/zod/{dist/esm/v3 → v3}/locales/en.js +2 -0
- package/dist/node_modules/zod/v3/locales/en.js.map +1 -0
- package/dist/node_modules/zod/{dist/esm/v3 → v3}/types.js +5 -2
- package/dist/node_modules/zod/v3/types.js.map +1 -0
- package/package.json +2 -2
- package/dist/node_modules/zod/dist/esm/v3/ZodError.js.map +0 -1
- package/dist/node_modules/zod/dist/esm/v3/errors.js.map +0 -1
- package/dist/node_modules/zod/dist/esm/v3/helpers/errorUtil.js.map +0 -1
- package/dist/node_modules/zod/dist/esm/v3/helpers/parseUtil.js.map +0 -1
- package/dist/node_modules/zod/dist/esm/v3/helpers/util.js.map +0 -1
- package/dist/node_modules/zod/dist/esm/v3/locales/en.js.map +0 -1
- package/dist/node_modules/zod/dist/esm/v3/types.js.map +0 -1
- /package/dist/node_modules/zod/{dist/esm/v3 → v3}/errors.js +0 -0
- /package/dist/node_modules/zod/{dist/esm/v3 → v3}/helpers/errorUtil.js +0 -0
- /package/dist/node_modules/zod/{dist/esm/v3 → v3}/helpers/parseUtil.js +0 -0
- /package/dist/node_modules/zod/{dist/esm/v3 → v3}/helpers/util.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sources":["../../../../../../../../../node_modules/@modelcontextprotocol/sdk/dist/esm/client/auth.js"],"sourcesContent":["import pkceChallenge from \"pkce-challenge\";\nimport { LATEST_PROTOCOL_VERSION } from \"../types.js\";\nimport { OAuthClientInformationFullSchema, OAuthMetadataSchema, OAuthProtectedResourceMetadataSchema, OAuthTokensSchema } from \"../shared/auth.js\";\nimport { checkResourceAllowed, resourceUrlFromServerUrl } from \"../shared/auth-utils.js\";\nexport class UnauthorizedError extends Error {\n constructor(message) {\n super(message !== null && message !== void 0 ? message : \"Unauthorized\");\n }\n}\n/**\n * Orchestrates the full auth flow with a server.\n *\n * This can be used as a single entry point for all authorization functionality,\n * instead of linking together the other lower-level functions in this module.\n */\nexport async function auth(provider, { serverUrl, authorizationCode, scope, resourceMetadataUrl }) {\n let resourceMetadata;\n let authorizationServerUrl = serverUrl;\n try {\n resourceMetadata = await discoverOAuthProtectedResourceMetadata(serverUrl, { resourceMetadataUrl });\n if (resourceMetadata.authorization_servers && resourceMetadata.authorization_servers.length > 0) {\n authorizationServerUrl = resourceMetadata.authorization_servers[0];\n }\n }\n catch (_a) {\n // Ignore errors and fall back to /.well-known/oauth-authorization-server\n }\n const resource = await selectResourceURL(serverUrl, provider, resourceMetadata);\n const metadata = await discoverOAuthMetadata(authorizationServerUrl);\n // Handle client registration if needed\n let clientInformation = await Promise.resolve(provider.clientInformation());\n if (!clientInformation) {\n if (authorizationCode !== undefined) {\n throw new Error(\"Existing OAuth client information is required when exchanging an authorization code\");\n }\n if (!provider.saveClientInformation) {\n throw new Error(\"OAuth client information must be saveable for dynamic registration\");\n }\n const fullInformation = await registerClient(authorizationServerUrl, {\n metadata,\n clientMetadata: provider.clientMetadata,\n });\n await provider.saveClientInformation(fullInformation);\n clientInformation = fullInformation;\n }\n // Exchange authorization code for tokens\n if (authorizationCode !== undefined) {\n const codeVerifier = await provider.codeVerifier();\n const tokens = await exchangeAuthorization(authorizationServerUrl, {\n metadata,\n clientInformation,\n authorizationCode,\n codeVerifier,\n redirectUri: provider.redirectUrl,\n resource,\n });\n await provider.saveTokens(tokens);\n return \"AUTHORIZED\";\n }\n const tokens = await provider.tokens();\n // Handle token refresh or new authorization\n if (tokens === null || tokens === void 0 ? void 0 : tokens.refresh_token) {\n try {\n // Attempt to refresh the token\n const newTokens = await refreshAuthorization(authorizationServerUrl, {\n metadata,\n clientInformation,\n refreshToken: tokens.refresh_token,\n resource,\n });\n await provider.saveTokens(newTokens);\n return \"AUTHORIZED\";\n }\n catch (_b) {\n // Could not refresh OAuth tokens\n }\n }\n const state = provider.state ? await provider.state() : undefined;\n // Start new authorization flow\n const { authorizationUrl, codeVerifier } = await startAuthorization(authorizationServerUrl, {\n metadata,\n clientInformation,\n state,\n redirectUrl: provider.redirectUrl,\n scope: scope || provider.clientMetadata.scope,\n resource,\n });\n await provider.saveCodeVerifier(codeVerifier);\n await provider.redirectToAuthorization(authorizationUrl);\n return \"REDIRECT\";\n}\nexport async function selectResourceURL(serverUrl, provider, resourceMetadata) {\n const defaultResource = resourceUrlFromServerUrl(serverUrl);\n // If provider has custom validation, delegate to it\n if (provider.validateResourceURL) {\n return await provider.validateResourceURL(defaultResource, resourceMetadata === null || resourceMetadata === void 0 ? void 0 : resourceMetadata.resource);\n }\n // Only include resource parameter when Protected Resource Metadata is present\n if (!resourceMetadata) {\n return undefined;\n }\n // Validate that the metadata's resource is compatible with our request\n if (!checkResourceAllowed({ requestedResource: defaultResource, configuredResource: resourceMetadata.resource })) {\n throw new Error(`Protected resource ${resourceMetadata.resource} does not match expected ${defaultResource} (or origin)`);\n }\n // Prefer the resource from metadata since it's what the server is telling us to request\n return new URL(resourceMetadata.resource);\n}\n/**\n * Extract resource_metadata from response header.\n */\nexport function extractResourceMetadataUrl(res) {\n const authenticateHeader = res.headers.get(\"WWW-Authenticate\");\n if (!authenticateHeader) {\n return undefined;\n }\n const [type, scheme] = authenticateHeader.split(' ');\n if (type.toLowerCase() !== 'bearer' || !scheme) {\n return undefined;\n }\n const regex = /resource_metadata=\"([^\"]*)\"/;\n const match = regex.exec(authenticateHeader);\n if (!match) {\n return undefined;\n }\n try {\n return new URL(match[1]);\n }\n catch (_a) {\n return undefined;\n }\n}\n/**\n * Looks up RFC 9728 OAuth 2.0 Protected Resource Metadata.\n *\n * If the server returns a 404 for the well-known endpoint, this function will\n * return `undefined`. Any other errors will be thrown as exceptions.\n */\nexport async function discoverOAuthProtectedResourceMetadata(serverUrl, opts) {\n var _a;\n let url;\n if (opts === null || opts === void 0 ? void 0 : opts.resourceMetadataUrl) {\n url = new URL(opts === null || opts === void 0 ? void 0 : opts.resourceMetadataUrl);\n }\n else {\n url = new URL(\"/.well-known/oauth-protected-resource\", serverUrl);\n }\n let response;\n try {\n response = await fetch(url, {\n headers: {\n \"MCP-Protocol-Version\": (_a = opts === null || opts === void 0 ? void 0 : opts.protocolVersion) !== null && _a !== void 0 ? _a : LATEST_PROTOCOL_VERSION\n }\n });\n }\n catch (error) {\n // CORS errors come back as TypeError\n if (error instanceof TypeError) {\n response = await fetch(url);\n }\n else {\n throw error;\n }\n }\n if (response.status === 404) {\n throw new Error(`Resource server does not implement OAuth 2.0 Protected Resource Metadata.`);\n }\n if (!response.ok) {\n throw new Error(`HTTP ${response.status} trying to load well-known OAuth protected resource metadata.`);\n }\n return OAuthProtectedResourceMetadataSchema.parse(await response.json());\n}\n/**\n * Helper function to handle fetch with CORS retry logic\n */\nasync function fetchWithCorsRetry(url, headers) {\n try {\n return await fetch(url, { headers });\n }\n catch (error) {\n if (error instanceof TypeError) {\n if (headers) {\n // CORS errors come back as TypeError, retry without headers\n return fetchWithCorsRetry(url);\n }\n else {\n // We're getting CORS errors on retry too, return undefined\n return undefined;\n }\n }\n throw error;\n }\n}\n/**\n * Constructs the well-known path for OAuth metadata discovery\n */\nfunction buildWellKnownPath(pathname) {\n let wellKnownPath = `/.well-known/oauth-authorization-server${pathname}`;\n if (pathname.endsWith('/')) {\n // Strip trailing slash from pathname to avoid double slashes\n wellKnownPath = wellKnownPath.slice(0, -1);\n }\n return wellKnownPath;\n}\n/**\n * Tries to discover OAuth metadata at a specific URL\n */\nasync function tryMetadataDiscovery(url, protocolVersion) {\n const headers = {\n \"MCP-Protocol-Version\": protocolVersion\n };\n return await fetchWithCorsRetry(url, headers);\n}\n/**\n * Determines if fallback to root discovery should be attempted\n */\nfunction shouldAttemptFallback(response, pathname) {\n return !response || response.status === 404 && pathname !== '/';\n}\n/**\n * Looks up RFC 8414 OAuth 2.0 Authorization Server Metadata.\n *\n * If the server returns a 404 for the well-known endpoint, this function will\n * return `undefined`. Any other errors will be thrown as exceptions.\n */\nexport async function discoverOAuthMetadata(authorizationServerUrl, opts) {\n var _a;\n const issuer = new URL(authorizationServerUrl);\n const protocolVersion = (_a = opts === null || opts === void 0 ? void 0 : opts.protocolVersion) !== null && _a !== void 0 ? _a : LATEST_PROTOCOL_VERSION;\n // Try path-aware discovery first (RFC 8414 compliant)\n const wellKnownPath = buildWellKnownPath(issuer.pathname);\n const pathAwareUrl = new URL(wellKnownPath, issuer);\n let response = await tryMetadataDiscovery(pathAwareUrl, protocolVersion);\n // If path-aware discovery fails with 404, try fallback to root discovery\n if (shouldAttemptFallback(response, issuer.pathname)) {\n const rootUrl = new URL(\"/.well-known/oauth-authorization-server\", issuer);\n response = await tryMetadataDiscovery(rootUrl, protocolVersion);\n }\n if (!response || response.status === 404) {\n return undefined;\n }\n if (!response.ok) {\n throw new Error(`HTTP ${response.status} trying to load well-known OAuth metadata`);\n }\n return OAuthMetadataSchema.parse(await response.json());\n}\n/**\n * Begins the authorization flow with the given server, by generating a PKCE challenge and constructing the authorization URL.\n */\nexport async function startAuthorization(authorizationServerUrl, { metadata, clientInformation, redirectUrl, scope, state, resource, }) {\n const responseType = \"code\";\n const codeChallengeMethod = \"S256\";\n let authorizationUrl;\n if (metadata) {\n authorizationUrl = new URL(metadata.authorization_endpoint);\n if (!metadata.response_types_supported.includes(responseType)) {\n throw new Error(`Incompatible auth server: does not support response type ${responseType}`);\n }\n if (!metadata.code_challenge_methods_supported ||\n !metadata.code_challenge_methods_supported.includes(codeChallengeMethod)) {\n throw new Error(`Incompatible auth server: does not support code challenge method ${codeChallengeMethod}`);\n }\n }\n else {\n authorizationUrl = new URL(\"/authorize\", authorizationServerUrl);\n }\n // Generate PKCE challenge\n const challenge = await pkceChallenge();\n const codeVerifier = challenge.code_verifier;\n const codeChallenge = challenge.code_challenge;\n authorizationUrl.searchParams.set(\"response_type\", responseType);\n authorizationUrl.searchParams.set(\"client_id\", clientInformation.client_id);\n authorizationUrl.searchParams.set(\"code_challenge\", codeChallenge);\n authorizationUrl.searchParams.set(\"code_challenge_method\", codeChallengeMethod);\n authorizationUrl.searchParams.set(\"redirect_uri\", String(redirectUrl));\n if (state) {\n authorizationUrl.searchParams.set(\"state\", state);\n }\n if (scope) {\n authorizationUrl.searchParams.set(\"scope\", scope);\n }\n if (resource) {\n authorizationUrl.searchParams.set(\"resource\", resource.href);\n }\n return { authorizationUrl, codeVerifier };\n}\n/**\n * Exchanges an authorization code for an access token with the given server.\n */\nexport async function exchangeAuthorization(authorizationServerUrl, { metadata, clientInformation, authorizationCode, codeVerifier, redirectUri, resource, }) {\n const grantType = \"authorization_code\";\n let tokenUrl;\n if (metadata) {\n tokenUrl = new URL(metadata.token_endpoint);\n if (metadata.grant_types_supported &&\n !metadata.grant_types_supported.includes(grantType)) {\n throw new Error(`Incompatible auth server: does not support grant type ${grantType}`);\n }\n }\n else {\n tokenUrl = new URL(\"/token\", authorizationServerUrl);\n }\n // Exchange code for tokens\n const params = new URLSearchParams({\n grant_type: grantType,\n client_id: clientInformation.client_id,\n code: authorizationCode,\n code_verifier: codeVerifier,\n redirect_uri: String(redirectUri),\n });\n if (clientInformation.client_secret) {\n params.set(\"client_secret\", clientInformation.client_secret);\n }\n if (resource) {\n params.set(\"resource\", resource.href);\n }\n const response = await fetch(tokenUrl, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/x-www-form-urlencoded\",\n },\n body: params,\n });\n if (!response.ok) {\n throw new Error(`Token exchange failed: HTTP ${response.status}`);\n }\n return OAuthTokensSchema.parse(await response.json());\n}\n/**\n * Exchange a refresh token for an updated access token.\n */\nexport async function refreshAuthorization(authorizationServerUrl, { metadata, clientInformation, refreshToken, resource, }) {\n const grantType = \"refresh_token\";\n let tokenUrl;\n if (metadata) {\n tokenUrl = new URL(metadata.token_endpoint);\n if (metadata.grant_types_supported &&\n !metadata.grant_types_supported.includes(grantType)) {\n throw new Error(`Incompatible auth server: does not support grant type ${grantType}`);\n }\n }\n else {\n tokenUrl = new URL(\"/token\", authorizationServerUrl);\n }\n // Exchange refresh token\n const params = new URLSearchParams({\n grant_type: grantType,\n client_id: clientInformation.client_id,\n refresh_token: refreshToken,\n });\n if (clientInformation.client_secret) {\n params.set(\"client_secret\", clientInformation.client_secret);\n }\n if (resource) {\n params.set(\"resource\", resource.href);\n }\n const response = await fetch(tokenUrl, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/x-www-form-urlencoded\",\n },\n body: params,\n });\n if (!response.ok) {\n throw new Error(`Token refresh failed: HTTP ${response.status}`);\n }\n return OAuthTokensSchema.parse({ refresh_token: refreshToken, ...(await response.json()) });\n}\n/**\n * Performs OAuth 2.0 Dynamic Client Registration according to RFC 7591.\n */\nexport async function registerClient(authorizationServerUrl, { metadata, clientMetadata, }) {\n let registrationUrl;\n if (metadata) {\n if (!metadata.registration_endpoint) {\n throw new Error(\"Incompatible auth server: does not support dynamic client registration\");\n }\n registrationUrl = new URL(metadata.registration_endpoint);\n }\n else {\n registrationUrl = new URL(\"/register\", authorizationServerUrl);\n }\n const response = await fetch(registrationUrl, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify(clientMetadata),\n });\n if (!response.ok) {\n throw new Error(`Dynamic client registration failed: HTTP ${response.status}`);\n }\n return OAuthClientInformationFullSchema.parse(await response.json());\n}\n//# sourceMappingURL=auth.js.map"],"names":[],"mappings":";;;;;AAIO,MAAM,iBAAiB,SAAS,KAAK,CAAC;AAC7C,IAAI,WAAW,CAAC,OAAO,EAAE;AACzB,QAAQ,KAAK,CAAC,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,MAAM,GAAG,OAAO,GAAG,cAAc,CAAC;AAChF,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,IAAI,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,iBAAiB,EAAE,KAAK,EAAE,mBAAmB,EAAE,EAAE;AACnG,IAAI,IAAI,gBAAgB;AACxB,IAAI,IAAI,sBAAsB,GAAG,SAAS;AAC1C,IAAI,IAAI;AACR,QAAQ,gBAAgB,GAAG,MAAM,sCAAsC,CAAC,SAAS,EAAE,EAAE,mBAAmB,EAAE,CAAC;AAC3G,QAAQ,IAAI,gBAAgB,CAAC,qBAAqB,IAAI,gBAA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C,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;AACxE;;;;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"auth.js","sources":["../../../../../../../../../node_modules/@modelcontextprotocol/sdk/dist/esm/client/auth.js"],"sourcesContent":["import pkceChallenge from \"pkce-challenge\";\nimport { LATEST_PROTOCOL_VERSION } from \"../types.js\";\nimport { OAuthErrorResponseSchema, OpenIdProviderDiscoveryMetadataSchema } from \"../shared/auth.js\";\nimport { OAuthClientInformationFullSchema, OAuthMetadataSchema, OAuthProtectedResourceMetadataSchema, OAuthTokensSchema } from \"../shared/auth.js\";\nimport { checkResourceAllowed, resourceUrlFromServerUrl } from \"../shared/auth-utils.js\";\nimport { InvalidClientError, InvalidGrantError, OAUTH_ERRORS, OAuthError, ServerError, UnauthorizedClientError } from \"../server/auth/errors.js\";\nexport class UnauthorizedError extends Error {\n constructor(message) {\n super(message !== null && message !== void 0 ? message : \"Unauthorized\");\n }\n}\n/**\n * Determines the best client authentication method to use based on server support and client configuration.\n *\n * Priority order (highest to lowest):\n * 1. client_secret_basic (if client secret is available)\n * 2. client_secret_post (if client secret is available)\n * 3. none (for public clients)\n *\n * @param clientInformation - OAuth client information containing credentials\n * @param supportedMethods - Authentication methods supported by the authorization server\n * @returns The selected authentication method\n */\nfunction selectClientAuthMethod(clientInformation, supportedMethods) {\n const hasClientSecret = clientInformation.client_secret !== undefined;\n // If server doesn't specify supported methods, use RFC 6749 defaults\n if (supportedMethods.length === 0) {\n return hasClientSecret ? \"client_secret_post\" : \"none\";\n }\n // Try methods in priority order (most secure first)\n if (hasClientSecret && supportedMethods.includes(\"client_secret_basic\")) {\n return \"client_secret_basic\";\n }\n if (hasClientSecret && supportedMethods.includes(\"client_secret_post\")) {\n return \"client_secret_post\";\n }\n if (supportedMethods.includes(\"none\")) {\n return \"none\";\n }\n // Fallback: use what we have\n return hasClientSecret ? \"client_secret_post\" : \"none\";\n}\n/**\n * Applies client authentication to the request based on the specified method.\n *\n * Implements OAuth 2.1 client authentication methods:\n * - client_secret_basic: HTTP Basic authentication (RFC 6749 Section 2.3.1)\n * - client_secret_post: Credentials in request body (RFC 6749 Section 2.3.1)\n * - none: Public client authentication (RFC 6749 Section 2.1)\n *\n * @param method - The authentication method to use\n * @param clientInformation - OAuth client information containing credentials\n * @param headers - HTTP headers object to modify\n * @param params - URL search parameters to modify\n * @throws {Error} When required credentials are missing\n */\nfunction applyClientAuthentication(method, clientInformation, headers, params) {\n const { client_id, client_secret } = clientInformation;\n switch (method) {\n case \"client_secret_basic\":\n applyBasicAuth(client_id, client_secret, headers);\n return;\n case \"client_secret_post\":\n applyPostAuth(client_id, client_secret, params);\n return;\n case \"none\":\n applyPublicAuth(client_id, params);\n return;\n default:\n throw new Error(`Unsupported client authentication method: ${method}`);\n }\n}\n/**\n * Applies HTTP Basic authentication (RFC 6749 Section 2.3.1)\n */\nfunction applyBasicAuth(clientId, clientSecret, headers) {\n if (!clientSecret) {\n throw new Error(\"client_secret_basic authentication requires a client_secret\");\n }\n const credentials = btoa(`${clientId}:${clientSecret}`);\n headers.set(\"Authorization\", `Basic ${credentials}`);\n}\n/**\n * Applies POST body authentication (RFC 6749 Section 2.3.1)\n */\nfunction applyPostAuth(clientId, clientSecret, params) {\n params.set(\"client_id\", clientId);\n if (clientSecret) {\n params.set(\"client_secret\", clientSecret);\n }\n}\n/**\n * Applies public client authentication (RFC 6749 Section 2.1)\n */\nfunction applyPublicAuth(clientId, params) {\n params.set(\"client_id\", clientId);\n}\n/**\n * Parses an OAuth error response from a string or Response object.\n *\n * If the input is a standard OAuth2.0 error response, it will be parsed according to the spec\n * and an instance of the appropriate OAuthError subclass will be returned.\n * If parsing fails, it falls back to a generic ServerError that includes\n * the response status (if available) and original content.\n *\n * @param input - A Response object or string containing the error response\n * @returns A Promise that resolves to an OAuthError instance\n */\nexport async function parseErrorResponse(input) {\n const statusCode = input instanceof Response ? input.status : undefined;\n const body = input instanceof Response ? await input.text() : input;\n try {\n const result = OAuthErrorResponseSchema.parse(JSON.parse(body));\n const { error, error_description, error_uri } = result;\n const errorClass = OAUTH_ERRORS[error] || ServerError;\n return new errorClass(error_description || '', error_uri);\n }\n catch (error) {\n // Not a valid OAuth error response, but try to inform the user of the raw data anyway\n const errorMessage = `${statusCode ? `HTTP ${statusCode}: ` : ''}Invalid OAuth error response: ${error}. Raw body: ${body}`;\n return new ServerError(errorMessage);\n }\n}\n/**\n * Orchestrates the full auth flow with a server.\n *\n * This can be used as a single entry point for all authorization functionality,\n * instead of linking together the other lower-level functions in this module.\n */\nexport async function auth(provider, options) {\n var _a, _b;\n try {\n return await authInternal(provider, options);\n }\n catch (error) {\n // Handle recoverable error types by invalidating credentials and retrying\n if (error instanceof InvalidClientError || error instanceof UnauthorizedClientError) {\n await ((_a = provider.invalidateCredentials) === null || _a === void 0 ? void 0 : _a.call(provider, 'all'));\n return await authInternal(provider, options);\n }\n else if (error instanceof InvalidGrantError) {\n await ((_b = provider.invalidateCredentials) === null || _b === void 0 ? void 0 : _b.call(provider, 'tokens'));\n return await authInternal(provider, options);\n }\n // Throw otherwise\n throw error;\n }\n}\nasync function authInternal(provider, { serverUrl, authorizationCode, scope, resourceMetadataUrl, fetchFn, }) {\n let resourceMetadata;\n let authorizationServerUrl;\n try {\n resourceMetadata = await discoverOAuthProtectedResourceMetadata(serverUrl, { resourceMetadataUrl }, fetchFn);\n if (resourceMetadata.authorization_servers && resourceMetadata.authorization_servers.length > 0) {\n authorizationServerUrl = resourceMetadata.authorization_servers[0];\n }\n }\n catch (_a) {\n // Ignore errors and fall back to /.well-known/oauth-authorization-server\n }\n /**\n * If we don't get a valid authorization server metadata from protected resource metadata,\n * fallback to the legacy MCP spec's implementation (version 2025-03-26): MCP server acts as the Authorization server.\n */\n if (!authorizationServerUrl) {\n authorizationServerUrl = serverUrl;\n }\n const resource = await selectResourceURL(serverUrl, provider, resourceMetadata);\n const metadata = await discoverAuthorizationServerMetadata(authorizationServerUrl, {\n fetchFn,\n });\n // Handle client registration if needed\n let clientInformation = await Promise.resolve(provider.clientInformation());\n if (!clientInformation) {\n if (authorizationCode !== undefined) {\n throw new Error(\"Existing OAuth client information is required when exchanging an authorization code\");\n }\n if (!provider.saveClientInformation) {\n throw new Error(\"OAuth client information must be saveable for dynamic registration\");\n }\n const fullInformation = await registerClient(authorizationServerUrl, {\n metadata,\n clientMetadata: provider.clientMetadata,\n fetchFn,\n });\n await provider.saveClientInformation(fullInformation);\n clientInformation = fullInformation;\n }\n // Exchange authorization code for tokens\n if (authorizationCode !== undefined) {\n const codeVerifier = await provider.codeVerifier();\n const tokens = await exchangeAuthorization(authorizationServerUrl, {\n metadata,\n clientInformation,\n authorizationCode,\n codeVerifier,\n redirectUri: provider.redirectUrl,\n resource,\n addClientAuthentication: provider.addClientAuthentication,\n fetchFn: fetchFn,\n });\n await provider.saveTokens(tokens);\n return \"AUTHORIZED\";\n }\n const tokens = await provider.tokens();\n // Handle token refresh or new authorization\n if (tokens === null || tokens === void 0 ? void 0 : tokens.refresh_token) {\n try {\n // Attempt to refresh the token\n const newTokens = await refreshAuthorization(authorizationServerUrl, {\n metadata,\n clientInformation,\n refreshToken: tokens.refresh_token,\n resource,\n addClientAuthentication: provider.addClientAuthentication,\n fetchFn,\n });\n await provider.saveTokens(newTokens);\n return \"AUTHORIZED\";\n }\n catch (error) {\n // If this is a ServerError, or an unknown type, log it out and try to continue. Otherwise, escalate so we can fix things and retry.\n if (!(error instanceof OAuthError) || error instanceof ServerError) {\n // Could not refresh OAuth tokens\n }\n else {\n // Refresh failed for another reason, re-throw\n throw error;\n }\n }\n }\n const state = provider.state ? await provider.state() : undefined;\n // Start new authorization flow\n const { authorizationUrl, codeVerifier } = await startAuthorization(authorizationServerUrl, {\n metadata,\n clientInformation,\n state,\n redirectUrl: provider.redirectUrl,\n scope: scope || provider.clientMetadata.scope,\n resource,\n });\n await provider.saveCodeVerifier(codeVerifier);\n await provider.redirectToAuthorization(authorizationUrl);\n return \"REDIRECT\";\n}\nexport async function selectResourceURL(serverUrl, provider, resourceMetadata) {\n const defaultResource = resourceUrlFromServerUrl(serverUrl);\n // If provider has custom validation, delegate to it\n if (provider.validateResourceURL) {\n return await provider.validateResourceURL(defaultResource, resourceMetadata === null || resourceMetadata === void 0 ? void 0 : resourceMetadata.resource);\n }\n // Only include resource parameter when Protected Resource Metadata is present\n if (!resourceMetadata) {\n return undefined;\n }\n // Validate that the metadata's resource is compatible with our request\n if (!checkResourceAllowed({ requestedResource: defaultResource, configuredResource: resourceMetadata.resource })) {\n throw new Error(`Protected resource ${resourceMetadata.resource} does not match expected ${defaultResource} (or origin)`);\n }\n // Prefer the resource from metadata since it's what the server is telling us to request\n return new URL(resourceMetadata.resource);\n}\n/**\n * Extract resource_metadata from response header.\n */\nexport function extractResourceMetadataUrl(res) {\n const authenticateHeader = res.headers.get(\"WWW-Authenticate\");\n if (!authenticateHeader) {\n return undefined;\n }\n const [type, scheme] = authenticateHeader.split(' ');\n if (type.toLowerCase() !== 'bearer' || !scheme) {\n return undefined;\n }\n const regex = /resource_metadata=\"([^\"]*)\"/;\n const match = regex.exec(authenticateHeader);\n if (!match) {\n return undefined;\n }\n try {\n return new URL(match[1]);\n }\n catch (_a) {\n return undefined;\n }\n}\n/**\n * Looks up RFC 9728 OAuth 2.0 Protected Resource Metadata.\n *\n * If the server returns a 404 for the well-known endpoint, this function will\n * return `undefined`. Any other errors will be thrown as exceptions.\n */\nexport async function discoverOAuthProtectedResourceMetadata(serverUrl, opts, fetchFn = fetch) {\n const response = await discoverMetadataWithFallback(serverUrl, 'oauth-protected-resource', fetchFn, {\n protocolVersion: opts === null || opts === void 0 ? void 0 : opts.protocolVersion,\n metadataUrl: opts === null || opts === void 0 ? void 0 : opts.resourceMetadataUrl,\n });\n if (!response || response.status === 404) {\n throw new Error(`Resource server does not implement OAuth 2.0 Protected Resource Metadata.`);\n }\n if (!response.ok) {\n throw new Error(`HTTP ${response.status} trying to load well-known OAuth protected resource metadata.`);\n }\n return OAuthProtectedResourceMetadataSchema.parse(await response.json());\n}\n/**\n * Helper function to handle fetch with CORS retry logic\n */\nasync function fetchWithCorsRetry(url, headers, fetchFn = fetch) {\n try {\n return await fetchFn(url, { headers });\n }\n catch (error) {\n if (error instanceof TypeError) {\n if (headers) {\n // CORS errors come back as TypeError, retry without headers\n return fetchWithCorsRetry(url, undefined, fetchFn);\n }\n else {\n // We're getting CORS errors on retry too, return undefined\n return undefined;\n }\n }\n throw error;\n }\n}\n/**\n * Constructs the well-known path for auth-related metadata discovery\n */\nfunction buildWellKnownPath(wellKnownPrefix, pathname = '', options = {}) {\n // Strip trailing slash from pathname to avoid double slashes\n if (pathname.endsWith('/')) {\n pathname = pathname.slice(0, -1);\n }\n return options.prependPathname\n ? `${pathname}/.well-known/${wellKnownPrefix}`\n : `/.well-known/${wellKnownPrefix}${pathname}`;\n}\n/**\n * Tries to discover OAuth metadata at a specific URL\n */\nasync function tryMetadataDiscovery(url, protocolVersion, fetchFn = fetch) {\n const headers = {\n \"MCP-Protocol-Version\": protocolVersion\n };\n return await fetchWithCorsRetry(url, headers, fetchFn);\n}\n/**\n * Determines if fallback to root discovery should be attempted\n */\nfunction shouldAttemptFallback(response, pathname) {\n return !response || (response.status >= 400 && response.status < 500) && pathname !== '/';\n}\n/**\n * Generic function for discovering OAuth metadata with fallback support\n */\nasync function discoverMetadataWithFallback(serverUrl, wellKnownType, fetchFn, opts) {\n var _a, _b;\n const issuer = new URL(serverUrl);\n const protocolVersion = (_a = opts === null || opts === void 0 ? void 0 : opts.protocolVersion) !== null && _a !== void 0 ? _a : LATEST_PROTOCOL_VERSION;\n let url;\n if (opts === null || opts === void 0 ? void 0 : opts.metadataUrl) {\n url = new URL(opts.metadataUrl);\n }\n else {\n // Try path-aware discovery first\n const wellKnownPath = buildWellKnownPath(wellKnownType, issuer.pathname);\n url = new URL(wellKnownPath, (_b = opts === null || opts === void 0 ? void 0 : opts.metadataServerUrl) !== null && _b !== void 0 ? _b : issuer);\n url.search = issuer.search;\n }\n let response = await tryMetadataDiscovery(url, protocolVersion, fetchFn);\n // If path-aware discovery fails with 404 and we're not already at root, try fallback to root discovery\n if (!(opts === null || opts === void 0 ? void 0 : opts.metadataUrl) && shouldAttemptFallback(response, issuer.pathname)) {\n const rootUrl = new URL(`/.well-known/${wellKnownType}`, issuer);\n response = await tryMetadataDiscovery(rootUrl, protocolVersion, fetchFn);\n }\n return response;\n}\n/**\n * Looks up RFC 8414 OAuth 2.0 Authorization Server Metadata.\n *\n * If the server returns a 404 for the well-known endpoint, this function will\n * return `undefined`. Any other errors will be thrown as exceptions.\n *\n * @deprecated This function is deprecated in favor of `discoverAuthorizationServerMetadata`.\n */\nexport async function discoverOAuthMetadata(issuer, { authorizationServerUrl, protocolVersion, } = {}, fetchFn = fetch) {\n if (typeof issuer === 'string') {\n issuer = new URL(issuer);\n }\n if (!authorizationServerUrl) {\n authorizationServerUrl = issuer;\n }\n if (typeof authorizationServerUrl === 'string') {\n authorizationServerUrl = new URL(authorizationServerUrl);\n }\n protocolVersion !== null && protocolVersion !== void 0 ? protocolVersion : (protocolVersion = LATEST_PROTOCOL_VERSION);\n const response = await discoverMetadataWithFallback(authorizationServerUrl, 'oauth-authorization-server', fetchFn, {\n protocolVersion,\n metadataServerUrl: authorizationServerUrl,\n });\n if (!response || response.status === 404) {\n return undefined;\n }\n if (!response.ok) {\n throw new Error(`HTTP ${response.status} trying to load well-known OAuth metadata`);\n }\n return OAuthMetadataSchema.parse(await response.json());\n}\n/**\n * Builds a list of discovery URLs to try for authorization server metadata.\n * URLs are returned in priority order:\n * 1. OAuth metadata at the given URL\n * 2. OAuth metadata at root (if URL has path)\n * 3. OIDC metadata endpoints\n */\nexport function buildDiscoveryUrls(authorizationServerUrl) {\n const url = typeof authorizationServerUrl === 'string' ? new URL(authorizationServerUrl) : authorizationServerUrl;\n const hasPath = url.pathname !== '/';\n const urlsToTry = [];\n if (!hasPath) {\n // Root path: https://example.com/.well-known/oauth-authorization-server\n urlsToTry.push({\n url: new URL('/.well-known/oauth-authorization-server', url.origin),\n type: 'oauth'\n });\n // OIDC: https://example.com/.well-known/openid-configuration\n urlsToTry.push({\n url: new URL(`/.well-known/openid-configuration`, url.origin),\n type: 'oidc'\n });\n return urlsToTry;\n }\n // Strip trailing slash from pathname to avoid double slashes\n let pathname = url.pathname;\n if (pathname.endsWith('/')) {\n pathname = pathname.slice(0, -1);\n }\n // 1. OAuth metadata at the given URL\n // Insert well-known before the path: https://example.com/.well-known/oauth-authorization-server/tenant1\n urlsToTry.push({\n url: new URL(`/.well-known/oauth-authorization-server${pathname}`, url.origin),\n type: 'oauth'\n });\n // Root path: https://example.com/.well-known/oauth-authorization-server\n urlsToTry.push({\n url: new URL('/.well-known/oauth-authorization-server', url.origin),\n type: 'oauth'\n });\n // 3. OIDC metadata endpoints\n // RFC 8414 style: Insert /.well-known/openid-configuration before the path\n urlsToTry.push({\n url: new URL(`/.well-known/openid-configuration${pathname}`, url.origin),\n type: 'oidc'\n });\n // OIDC Discovery 1.0 style: Append /.well-known/openid-configuration after the path\n urlsToTry.push({\n url: new URL(`${pathname}/.well-known/openid-configuration`, url.origin),\n type: 'oidc'\n });\n return urlsToTry;\n}\n/**\n * Discovers authorization server metadata with support for RFC 8414 OAuth 2.0 Authorization Server Metadata\n * and OpenID Connect Discovery 1.0 specifications.\n *\n * This function implements a fallback strategy for authorization server discovery:\n * 1. Attempts RFC 8414 OAuth metadata discovery first\n * 2. If OAuth discovery fails, falls back to OpenID Connect Discovery\n *\n * @param authorizationServerUrl - The authorization server URL obtained from the MCP Server's\n * protected resource metadata, or the MCP server's URL if the\n * metadata was not found.\n * @param options - Configuration options\n * @param options.fetchFn - Optional fetch function for making HTTP requests, defaults to global fetch\n * @param options.protocolVersion - MCP protocol version to use, defaults to LATEST_PROTOCOL_VERSION\n * @returns Promise resolving to authorization server metadata, or undefined if discovery fails\n */\nexport async function discoverAuthorizationServerMetadata(authorizationServerUrl, { fetchFn = fetch, protocolVersion = LATEST_PROTOCOL_VERSION, } = {}) {\n var _a;\n const headers = { 'MCP-Protocol-Version': protocolVersion };\n // Get the list of URLs to try\n const urlsToTry = buildDiscoveryUrls(authorizationServerUrl);\n // Try each URL in order\n for (const { url: endpointUrl, type } of urlsToTry) {\n const response = await fetchWithCorsRetry(endpointUrl, headers, fetchFn);\n if (!response) {\n /**\n * CORS error occurred - don't throw as the endpoint may not allow CORS,\n * continue trying other possible endpoints\n */\n continue;\n }\n if (!response.ok) {\n // Continue looking for any 4xx response code.\n if (response.status >= 400 && response.status < 500) {\n continue; // Try next URL\n }\n throw new Error(`HTTP ${response.status} trying to load ${type === 'oauth' ? 'OAuth' : 'OpenID provider'} metadata from ${endpointUrl}`);\n }\n // Parse and validate based on type\n if (type === 'oauth') {\n return OAuthMetadataSchema.parse(await response.json());\n }\n else {\n const metadata = OpenIdProviderDiscoveryMetadataSchema.parse(await response.json());\n // MCP spec requires OIDC providers to support S256 PKCE\n if (!((_a = metadata.code_challenge_methods_supported) === null || _a === void 0 ? void 0 : _a.includes('S256'))) {\n throw new Error(`Incompatible OIDC provider at ${endpointUrl}: does not support S256 code challenge method required by MCP specification`);\n }\n return metadata;\n }\n }\n return undefined;\n}\n/**\n * Begins the authorization flow with the given server, by generating a PKCE challenge and constructing the authorization URL.\n */\nexport async function startAuthorization(authorizationServerUrl, { metadata, clientInformation, redirectUrl, scope, state, resource, }) {\n const responseType = \"code\";\n const codeChallengeMethod = \"S256\";\n let authorizationUrl;\n if (metadata) {\n authorizationUrl = new URL(metadata.authorization_endpoint);\n if (!metadata.response_types_supported.includes(responseType)) {\n throw new Error(`Incompatible auth server: does not support response type ${responseType}`);\n }\n if (!metadata.code_challenge_methods_supported ||\n !metadata.code_challenge_methods_supported.includes(codeChallengeMethod)) {\n throw new Error(`Incompatible auth server: does not support code challenge method ${codeChallengeMethod}`);\n }\n }\n else {\n authorizationUrl = new URL(\"/authorize\", authorizationServerUrl);\n }\n // Generate PKCE challenge\n const challenge = await pkceChallenge();\n const codeVerifier = challenge.code_verifier;\n const codeChallenge = challenge.code_challenge;\n authorizationUrl.searchParams.set(\"response_type\", responseType);\n authorizationUrl.searchParams.set(\"client_id\", clientInformation.client_id);\n authorizationUrl.searchParams.set(\"code_challenge\", codeChallenge);\n authorizationUrl.searchParams.set(\"code_challenge_method\", codeChallengeMethod);\n authorizationUrl.searchParams.set(\"redirect_uri\", String(redirectUrl));\n if (state) {\n authorizationUrl.searchParams.set(\"state\", state);\n }\n if (scope) {\n authorizationUrl.searchParams.set(\"scope\", scope);\n }\n if (scope === null || scope === void 0 ? void 0 : scope.includes(\"offline_access\")) {\n // if the request includes the OIDC-only \"offline_access\" scope,\n // we need to set the prompt to \"consent\" to ensure the user is prompted to grant offline access\n // https://openid.net/specs/openid-connect-core-1_0.html#OfflineAccess\n authorizationUrl.searchParams.append(\"prompt\", \"consent\");\n }\n if (resource) {\n authorizationUrl.searchParams.set(\"resource\", resource.href);\n }\n return { authorizationUrl, codeVerifier };\n}\n/**\n * Exchanges an authorization code for an access token with the given server.\n *\n * Supports multiple client authentication methods as specified in OAuth 2.1:\n * - Automatically selects the best authentication method based on server support\n * - Falls back to appropriate defaults when server metadata is unavailable\n *\n * @param authorizationServerUrl - The authorization server's base URL\n * @param options - Configuration object containing client info, auth code, etc.\n * @returns Promise resolving to OAuth tokens\n * @throws {Error} When token exchange fails or authentication is invalid\n */\nexport async function exchangeAuthorization(authorizationServerUrl, { metadata, clientInformation, authorizationCode, codeVerifier, redirectUri, resource, addClientAuthentication, fetchFn, }) {\n var _a;\n const grantType = \"authorization_code\";\n const tokenUrl = (metadata === null || metadata === void 0 ? void 0 : metadata.token_endpoint)\n ? new URL(metadata.token_endpoint)\n : new URL(\"/token\", authorizationServerUrl);\n if ((metadata === null || metadata === void 0 ? void 0 : metadata.grant_types_supported) &&\n !metadata.grant_types_supported.includes(grantType)) {\n throw new Error(`Incompatible auth server: does not support grant type ${grantType}`);\n }\n // Exchange code for tokens\n const headers = new Headers({\n \"Content-Type\": \"application/x-www-form-urlencoded\",\n \"Accept\": \"application/json\",\n });\n const params = new URLSearchParams({\n grant_type: grantType,\n code: authorizationCode,\n code_verifier: codeVerifier,\n redirect_uri: String(redirectUri),\n });\n if (addClientAuthentication) {\n addClientAuthentication(headers, params, authorizationServerUrl, metadata);\n }\n else {\n // Determine and apply client authentication method\n const supportedMethods = (_a = metadata === null || metadata === void 0 ? void 0 : metadata.token_endpoint_auth_methods_supported) !== null && _a !== void 0 ? _a : [];\n const authMethod = selectClientAuthMethod(clientInformation, supportedMethods);\n applyClientAuthentication(authMethod, clientInformation, headers, params);\n }\n if (resource) {\n params.set(\"resource\", resource.href);\n }\n const response = await (fetchFn !== null && fetchFn !== void 0 ? fetchFn : fetch)(tokenUrl, {\n method: \"POST\",\n headers,\n body: params,\n });\n if (!response.ok) {\n throw await parseErrorResponse(response);\n }\n return OAuthTokensSchema.parse(await response.json());\n}\n/**\n * Exchange a refresh token for an updated access token.\n *\n * Supports multiple client authentication methods as specified in OAuth 2.1:\n * - Automatically selects the best authentication method based on server support\n * - Preserves the original refresh token if a new one is not returned\n *\n * @param authorizationServerUrl - The authorization server's base URL\n * @param options - Configuration object containing client info, refresh token, etc.\n * @returns Promise resolving to OAuth tokens (preserves original refresh_token if not replaced)\n * @throws {Error} When token refresh fails or authentication is invalid\n */\nexport async function refreshAuthorization(authorizationServerUrl, { metadata, clientInformation, refreshToken, resource, addClientAuthentication, fetchFn, }) {\n var _a;\n const grantType = \"refresh_token\";\n let tokenUrl;\n if (metadata) {\n tokenUrl = new URL(metadata.token_endpoint);\n if (metadata.grant_types_supported &&\n !metadata.grant_types_supported.includes(grantType)) {\n throw new Error(`Incompatible auth server: does not support grant type ${grantType}`);\n }\n }\n else {\n tokenUrl = new URL(\"/token\", authorizationServerUrl);\n }\n // Exchange refresh token\n const headers = new Headers({\n \"Content-Type\": \"application/x-www-form-urlencoded\",\n });\n const params = new URLSearchParams({\n grant_type: grantType,\n refresh_token: refreshToken,\n });\n if (addClientAuthentication) {\n addClientAuthentication(headers, params, authorizationServerUrl, metadata);\n }\n else {\n // Determine and apply client authentication method\n const supportedMethods = (_a = metadata === null || metadata === void 0 ? void 0 : metadata.token_endpoint_auth_methods_supported) !== null && _a !== void 0 ? _a : [];\n const authMethod = selectClientAuthMethod(clientInformation, supportedMethods);\n applyClientAuthentication(authMethod, clientInformation, headers, params);\n }\n if (resource) {\n params.set(\"resource\", resource.href);\n }\n const response = await (fetchFn !== null && fetchFn !== void 0 ? fetchFn : fetch)(tokenUrl, {\n method: \"POST\",\n headers,\n body: params,\n });\n if (!response.ok) {\n throw await parseErrorResponse(response);\n }\n return OAuthTokensSchema.parse({ refresh_token: refreshToken, ...(await response.json()) });\n}\n/**\n * Performs OAuth 2.0 Dynamic Client Registration according to RFC 7591.\n */\nexport async function registerClient(authorizationServerUrl, { metadata, clientMetadata, fetchFn, }) {\n let registrationUrl;\n if (metadata) {\n if (!metadata.registration_endpoint) {\n throw new Error(\"Incompatible auth server: does not support dynamic client registration\");\n }\n registrationUrl = new URL(metadata.registration_endpoint);\n }\n else {\n registrationUrl = new URL(\"/register\", authorizationServerUrl);\n }\n const response = await (fetchFn !== null && fetchFn !== void 0 ? fetchFn : fetch)(registrationUrl, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify(clientMetadata),\n });\n if (!response.ok) {\n throw await parseErrorResponse(response);\n }\n return OAuthClientInformationFullSchema.parse(await response.json());\n}\n//# sourceMappingURL=auth.js.map"],"names":[],"mappings":";;;;;;AAMO,MAAM,iBAAiB,SAAS,KAAK,CAAC;AAC7C,IAAI,WAAW,CAAC,OAAO,EAAE;AACzB,QAAQ,KAAK,CAAC,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,MAAM,GAAG,OAAO,GAAG,cAAc,CAAC;AAChF,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,sBAAsB,CAAC,iBAAiB,EAAE,gBAA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I;AACJ,SAAS;AACT,QAAQ,eAAe,GAAG,IAAI,GAAG,CAAC,WAAW,EAAE,sBAAsB,CAAC;AACtE,IAAI;AACJ,IAAI,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,MAAM,GAAG,OAAO,GAAG,KAAK,EAAE,eAAe,EAAE;AACvG,QAAQ,MAAM,EAAE,MAAM;AACtB,QAAQ,OAAO,EAAE;AACjB,YAAY,cAAc,EAAE,kBAAkB;AAC9C,SAAS;AACT,QAAQ,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC;AAC5C,KAAK,CAAC;AACN,IAAI,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE;AACtB,QAAQ,MAAM,MAAM,kBAAkB,CAAC,QAAQ,CAAC;AAChD,IAAI;AACJ,IAAI,OAAO,gCAAgC,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;AACxE;;;;","x_google_ignoreList":[0]}
|
|
@@ -38,7 +38,7 @@ class StreamableHTTPClientTransport {
|
|
|
38
38
|
}
|
|
39
39
|
let result;
|
|
40
40
|
try {
|
|
41
|
-
result = await auth(this._authProvider, { serverUrl: this._url, resourceMetadataUrl: this._resourceMetadataUrl });
|
|
41
|
+
result = await auth(this._authProvider, { serverUrl: this._url, resourceMetadataUrl: this._resourceMetadataUrl, fetchFn: this._fetch });
|
|
42
42
|
}
|
|
43
43
|
catch (error) {
|
|
44
44
|
(_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error);
|
|
@@ -99,7 +99,7 @@ class StreamableHTTPClientTransport {
|
|
|
99
99
|
}
|
|
100
100
|
throw new StreamableHTTPError(response.status, `Failed to open SSE stream: ${response.statusText}`);
|
|
101
101
|
}
|
|
102
|
-
this._handleSseStream(response.body, options);
|
|
102
|
+
this._handleSseStream(response.body, options, true);
|
|
103
103
|
}
|
|
104
104
|
catch (error) {
|
|
105
105
|
(_c = this.onerror) === null || _c === void 0 ? void 0 : _c.call(this, error);
|
|
@@ -159,7 +159,7 @@ class StreamableHTTPClientTransport {
|
|
|
159
159
|
});
|
|
160
160
|
}, delay);
|
|
161
161
|
}
|
|
162
|
-
_handleSseStream(stream, options) {
|
|
162
|
+
_handleSseStream(stream, options, isReconnectable) {
|
|
163
163
|
if (!stream) {
|
|
164
164
|
return;
|
|
165
165
|
}
|
|
@@ -203,19 +203,19 @@ class StreamableHTTPClientTransport {
|
|
|
203
203
|
// Handle stream errors - likely a network disconnect
|
|
204
204
|
(_c = this.onerror) === null || _c === void 0 ? void 0 : _c.call(this, new Error(`SSE stream disconnected: ${error}`));
|
|
205
205
|
// Attempt to reconnect if the stream disconnects unexpectedly and we aren't closing
|
|
206
|
-
if (
|
|
206
|
+
if (isReconnectable &&
|
|
207
|
+
this._abortController &&
|
|
208
|
+
!this._abortController.signal.aborted) {
|
|
207
209
|
// Use the exponential backoff reconnection strategy
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
(_d = this.onerror) === null || _d === void 0 ? void 0 : _d.call(this, new Error(`Failed to reconnect: ${error instanceof Error ? error.message : String(error)}`));
|
|
218
|
-
}
|
|
210
|
+
try {
|
|
211
|
+
this._scheduleReconnection({
|
|
212
|
+
resumptionToken: lastEventId,
|
|
213
|
+
onresumptiontoken,
|
|
214
|
+
replayMessageId
|
|
215
|
+
}, 0);
|
|
216
|
+
}
|
|
217
|
+
catch (error) {
|
|
218
|
+
(_d = this.onerror) === null || _d === void 0 ? void 0 : _d.call(this, new Error(`Failed to reconnect: ${error instanceof Error ? error.message : String(error)}`));
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
221
|
}
|
|
@@ -235,7 +235,7 @@ class StreamableHTTPClientTransport {
|
|
|
235
235
|
if (!this._authProvider) {
|
|
236
236
|
throw new UnauthorizedError("No auth provider");
|
|
237
237
|
}
|
|
238
|
-
const result = await auth(this._authProvider, { serverUrl: this._url, authorizationCode, resourceMetadataUrl: this._resourceMetadataUrl });
|
|
238
|
+
const result = await auth(this._authProvider, { serverUrl: this._url, authorizationCode, resourceMetadataUrl: this._resourceMetadataUrl, fetchFn: this._fetch });
|
|
239
239
|
if (result !== "AUTHORIZED") {
|
|
240
240
|
throw new UnauthorizedError("Failed to authorize");
|
|
241
241
|
}
|
|
@@ -274,7 +274,7 @@ class StreamableHTTPClientTransport {
|
|
|
274
274
|
if (!response.ok) {
|
|
275
275
|
if (response.status === 401 && this._authProvider) {
|
|
276
276
|
this._resourceMetadataUrl = extractResourceMetadataUrl(response);
|
|
277
|
-
const result = await auth(this._authProvider, { serverUrl: this._url, resourceMetadataUrl: this._resourceMetadataUrl });
|
|
277
|
+
const result = await auth(this._authProvider, { serverUrl: this._url, resourceMetadataUrl: this._resourceMetadataUrl, fetchFn: this._fetch });
|
|
278
278
|
if (result !== "AUTHORIZED") {
|
|
279
279
|
throw new UnauthorizedError();
|
|
280
280
|
}
|
|
@@ -304,7 +304,7 @@ class StreamableHTTPClientTransport {
|
|
|
304
304
|
// Handle SSE stream responses for requests
|
|
305
305
|
// We use the same handler as standalone streams, which now supports
|
|
306
306
|
// reconnection with the last event ID
|
|
307
|
-
this._handleSseStream(response.body, { onresumptiontoken });
|
|
307
|
+
this._handleSseStream(response.body, { onresumptiontoken }, false);
|
|
308
308
|
}
|
|
309
309
|
else if (contentType === null || contentType === void 0 ? void 0 : contentType.includes("application/json")) {
|
|
310
310
|
// For non-streaming servers, we might get direct JSON responses
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streamableHttp.js","sources":["../../../../../../../../../node_modules/@modelcontextprotocol/sdk/dist/esm/client/streamableHttp.js"],"sourcesContent":["import { isInitializedNotification, isJSONRPCRequest, isJSONRPCResponse, JSONRPCMessageSchema } from \"../types.js\";\nimport { auth, extractResourceMetadataUrl, UnauthorizedError } from \"./auth.js\";\nimport { EventSourceParserStream } from \"eventsource-parser/stream\";\n// Default reconnection options for StreamableHTTP connections\nconst DEFAULT_STREAMABLE_HTTP_RECONNECTION_OPTIONS = {\n initialReconnectionDelay: 1000,\n maxReconnectionDelay: 30000,\n reconnectionDelayGrowFactor: 1.5,\n maxRetries: 2,\n};\nexport class StreamableHTTPError extends Error {\n constructor(code, message) {\n super(`Streamable HTTP error: ${message}`);\n this.code = code;\n }\n}\n/**\n * Client transport for Streamable HTTP: this implements the MCP Streamable HTTP transport specification.\n * It will connect to a server using HTTP POST for sending messages and HTTP GET with Server-Sent Events\n * for receiving messages.\n */\nexport class StreamableHTTPClientTransport {\n constructor(url, opts) {\n var _a;\n this._url = url;\n this._resourceMetadataUrl = undefined;\n this._requestInit = opts === null || opts === void 0 ? void 0 : opts.requestInit;\n this._authProvider = opts === null || opts === void 0 ? void 0 : opts.authProvider;\n this._fetch = opts === null || opts === void 0 ? void 0 : opts.fetch;\n this._sessionId = opts === null || opts === void 0 ? void 0 : opts.sessionId;\n this._reconnectionOptions = (_a = opts === null || opts === void 0 ? void 0 : opts.reconnectionOptions) !== null && _a !== void 0 ? _a : DEFAULT_STREAMABLE_HTTP_RECONNECTION_OPTIONS;\n }\n async _authThenStart() {\n var _a;\n if (!this._authProvider) {\n throw new UnauthorizedError(\"No auth provider\");\n }\n let result;\n try {\n result = await auth(this._authProvider, { serverUrl: this._url, resourceMetadataUrl: this._resourceMetadataUrl });\n }\n catch (error) {\n (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error);\n throw error;\n }\n if (result !== \"AUTHORIZED\") {\n throw new UnauthorizedError();\n }\n return await this._startOrAuthSse({ resumptionToken: undefined });\n }\n async _commonHeaders() {\n var _a;\n const headers = {};\n if (this._authProvider) {\n const tokens = await this._authProvider.tokens();\n if (tokens) {\n headers[\"Authorization\"] = `Bearer ${tokens.access_token}`;\n }\n }\n if (this._sessionId) {\n headers[\"mcp-session-id\"] = this._sessionId;\n }\n if (this._protocolVersion) {\n headers[\"mcp-protocol-version\"] = this._protocolVersion;\n }\n const extraHeaders = this._normalizeHeaders((_a = this._requestInit) === null || _a === void 0 ? void 0 : _a.headers);\n return new Headers({\n ...headers,\n ...extraHeaders,\n });\n }\n async _startOrAuthSse(options) {\n var _a, _b, _c;\n const { resumptionToken } = options;\n try {\n // Try to open an initial SSE stream with GET to listen for server messages\n // This is optional according to the spec - server may not support it\n const headers = await this._commonHeaders();\n headers.set(\"Accept\", \"text/event-stream\");\n // Include Last-Event-ID header for resumable streams if provided\n if (resumptionToken) {\n headers.set(\"last-event-id\", resumptionToken);\n }\n const response = await ((_a = this._fetch) !== null && _a !== void 0 ? _a : fetch)(this._url, {\n method: \"GET\",\n headers,\n signal: (_b = this._abortController) === null || _b === void 0 ? void 0 : _b.signal,\n });\n if (!response.ok) {\n if (response.status === 401 && this._authProvider) {\n // Need to authenticate\n return await this._authThenStart();\n }\n // 405 indicates that the server does not offer an SSE stream at GET endpoint\n // This is an expected case that should not trigger an error\n if (response.status === 405) {\n return;\n }\n throw new StreamableHTTPError(response.status, `Failed to open SSE stream: ${response.statusText}`);\n }\n this._handleSseStream(response.body, options);\n }\n catch (error) {\n (_c = this.onerror) === null || _c === void 0 ? void 0 : _c.call(this, error);\n throw error;\n }\n }\n /**\n * Calculates the next reconnection delay using backoff algorithm\n *\n * @param attempt Current reconnection attempt count for the specific stream\n * @returns Time to wait in milliseconds before next reconnection attempt\n */\n _getNextReconnectionDelay(attempt) {\n // Access default values directly, ensuring they're never undefined\n const initialDelay = this._reconnectionOptions.initialReconnectionDelay;\n const growFactor = this._reconnectionOptions.reconnectionDelayGrowFactor;\n const maxDelay = this._reconnectionOptions.maxReconnectionDelay;\n // Cap at maximum delay\n return Math.min(initialDelay * Math.pow(growFactor, attempt), maxDelay);\n }\n _normalizeHeaders(headers) {\n if (!headers)\n return {};\n if (headers instanceof Headers) {\n return Object.fromEntries(headers.entries());\n }\n if (Array.isArray(headers)) {\n return Object.fromEntries(headers);\n }\n return { ...headers };\n }\n /**\n * Schedule a reconnection attempt with exponential backoff\n *\n * @param lastEventId The ID of the last received event for resumability\n * @param attemptCount Current reconnection attempt count for this specific stream\n */\n _scheduleReconnection(options, attemptCount = 0) {\n var _a;\n // Use provided options or default options\n const maxRetries = this._reconnectionOptions.maxRetries;\n // Check if we've exceeded maximum retry attempts\n if (maxRetries > 0 && attemptCount >= maxRetries) {\n (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, new Error(`Maximum reconnection attempts (${maxRetries}) exceeded.`));\n return;\n }\n // Calculate next delay based on current attempt count\n const delay = this._getNextReconnectionDelay(attemptCount);\n // Schedule the reconnection\n setTimeout(() => {\n // Use the last event ID to resume where we left off\n this._startOrAuthSse(options).catch(error => {\n var _a;\n (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, new Error(`Failed to reconnect SSE stream: ${error instanceof Error ? error.message : String(error)}`));\n // Schedule another attempt if this one failed, incrementing the attempt counter\n this._scheduleReconnection(options, attemptCount + 1);\n });\n }, delay);\n }\n _handleSseStream(stream, options) {\n if (!stream) {\n return;\n }\n const { onresumptiontoken, replayMessageId } = options;\n let lastEventId;\n const processStream = async () => {\n var _a, _b, _c, _d;\n // this is the closest we can get to trying to catch network errors\n // if something happens reader will throw\n try {\n // Create a pipeline: binary stream -> text decoder -> SSE parser\n const reader = stream\n .pipeThrough(new TextDecoderStream())\n .pipeThrough(new EventSourceParserStream())\n .getReader();\n while (true) {\n const { value: event, done } = await reader.read();\n if (done) {\n break;\n }\n // Update last event ID if provided\n if (event.id) {\n lastEventId = event.id;\n onresumptiontoken === null || onresumptiontoken === void 0 ? void 0 : onresumptiontoken(event.id);\n }\n if (!event.event || event.event === \"message\") {\n try {\n const message = JSONRPCMessageSchema.parse(JSON.parse(event.data));\n if (replayMessageId !== undefined && isJSONRPCResponse(message)) {\n message.id = replayMessageId;\n }\n (_a = this.onmessage) === null || _a === void 0 ? void 0 : _a.call(this, message);\n }\n catch (error) {\n (_b = this.onerror) === null || _b === void 0 ? void 0 : _b.call(this, error);\n }\n }\n }\n }\n catch (error) {\n // Handle stream errors - likely a network disconnect\n (_c = this.onerror) === null || _c === void 0 ? void 0 : _c.call(this, new Error(`SSE stream disconnected: ${error}`));\n // Attempt to reconnect if the stream disconnects unexpectedly and we aren't closing\n if (this._abortController && !this._abortController.signal.aborted) {\n // Use the exponential backoff reconnection strategy\n if (lastEventId !== undefined) {\n try {\n this._scheduleReconnection({\n resumptionToken: lastEventId,\n onresumptiontoken,\n replayMessageId\n }, 0);\n }\n catch (error) {\n (_d = this.onerror) === null || _d === void 0 ? void 0 : _d.call(this, new Error(`Failed to reconnect: ${error instanceof Error ? error.message : String(error)}`));\n }\n }\n }\n }\n };\n processStream();\n }\n async start() {\n if (this._abortController) {\n throw new Error(\"StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.\");\n }\n this._abortController = new AbortController();\n }\n /**\n * Call this method after the user has finished authorizing via their user agent and is redirected back to the MCP client application. This will exchange the authorization code for an access token, enabling the next connection attempt to successfully auth.\n */\n async finishAuth(authorizationCode) {\n if (!this._authProvider) {\n throw new UnauthorizedError(\"No auth provider\");\n }\n const result = await auth(this._authProvider, { serverUrl: this._url, authorizationCode, resourceMetadataUrl: this._resourceMetadataUrl });\n if (result !== \"AUTHORIZED\") {\n throw new UnauthorizedError(\"Failed to authorize\");\n }\n }\n async close() {\n var _a, _b;\n // Abort any pending requests\n (_a = this._abortController) === null || _a === void 0 ? void 0 : _a.abort();\n (_b = this.onclose) === null || _b === void 0 ? void 0 : _b.call(this);\n }\n async send(message, options) {\n var _a, _b, _c, _d;\n try {\n const { resumptionToken, onresumptiontoken } = options || {};\n if (resumptionToken) {\n // If we have at last event ID, we need to reconnect the SSE stream\n this._startOrAuthSse({ resumptionToken, replayMessageId: isJSONRPCRequest(message) ? message.id : undefined }).catch(err => { var _a; return (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, err); });\n return;\n }\n const headers = await this._commonHeaders();\n headers.set(\"content-type\", \"application/json\");\n headers.set(\"accept\", \"application/json, text/event-stream\");\n const init = {\n ...this._requestInit,\n method: \"POST\",\n headers,\n body: JSON.stringify(message),\n signal: (_a = this._abortController) === null || _a === void 0 ? void 0 : _a.signal,\n };\n const response = await ((_b = this._fetch) !== null && _b !== void 0 ? _b : fetch)(this._url, init);\n // Handle session ID received during initialization\n const sessionId = response.headers.get(\"mcp-session-id\");\n if (sessionId) {\n this._sessionId = sessionId;\n }\n if (!response.ok) {\n if (response.status === 401 && this._authProvider) {\n this._resourceMetadataUrl = extractResourceMetadataUrl(response);\n const result = await auth(this._authProvider, { serverUrl: this._url, resourceMetadataUrl: this._resourceMetadataUrl });\n if (result !== \"AUTHORIZED\") {\n throw new UnauthorizedError();\n }\n // Purposely _not_ awaited, so we don't call onerror twice\n return this.send(message);\n }\n const text = await response.text().catch(() => null);\n throw new Error(`Error POSTing to endpoint (HTTP ${response.status}): ${text}`);\n }\n // If the response is 202 Accepted, there's no body to process\n if (response.status === 202) {\n // if the accepted notification is initialized, we start the SSE stream\n // if it's supported by the server\n if (isInitializedNotification(message)) {\n // Start without a lastEventId since this is a fresh connection\n this._startOrAuthSse({ resumptionToken: undefined }).catch(err => { var _a; return (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, err); });\n }\n return;\n }\n // Get original message(s) for detecting request IDs\n const messages = Array.isArray(message) ? message : [message];\n const hasRequests = messages.filter(msg => \"method\" in msg && \"id\" in msg && msg.id !== undefined).length > 0;\n // Check the response type\n const contentType = response.headers.get(\"content-type\");\n if (hasRequests) {\n if (contentType === null || contentType === void 0 ? void 0 : contentType.includes(\"text/event-stream\")) {\n // Handle SSE stream responses for requests\n // We use the same handler as standalone streams, which now supports\n // reconnection with the last event ID\n this._handleSseStream(response.body, { onresumptiontoken });\n }\n else if (contentType === null || contentType === void 0 ? void 0 : contentType.includes(\"application/json\")) {\n // For non-streaming servers, we might get direct JSON responses\n const data = await response.json();\n const responseMessages = Array.isArray(data)\n ? data.map(msg => JSONRPCMessageSchema.parse(msg))\n : [JSONRPCMessageSchema.parse(data)];\n for (const msg of responseMessages) {\n (_c = this.onmessage) === null || _c === void 0 ? void 0 : _c.call(this, msg);\n }\n }\n else {\n throw new StreamableHTTPError(-1, `Unexpected content type: ${contentType}`);\n }\n }\n }\n catch (error) {\n (_d = this.onerror) === null || _d === void 0 ? void 0 : _d.call(this, error);\n throw error;\n }\n }\n get sessionId() {\n return this._sessionId;\n }\n /**\n * Terminates the current session by sending a DELETE request to the server.\n *\n * Clients that no longer need a particular session\n * (e.g., because the user is leaving the client application) SHOULD send an\n * HTTP DELETE to the MCP endpoint with the Mcp-Session-Id header to explicitly\n * terminate the session.\n *\n * The server MAY respond with HTTP 405 Method Not Allowed, indicating that\n * the server does not allow clients to terminate sessions.\n */\n async terminateSession() {\n var _a, _b, _c;\n if (!this._sessionId) {\n return; // No session to terminate\n }\n try {\n const headers = await this._commonHeaders();\n const init = {\n ...this._requestInit,\n method: \"DELETE\",\n headers,\n signal: (_a = this._abortController) === null || _a === void 0 ? void 0 : _a.signal,\n };\n const response = await ((_b = this._fetch) !== null && _b !== void 0 ? _b : fetch)(this._url, init);\n // We specifically handle 405 as a valid response according to the spec,\n // meaning the server does not support explicit session termination\n if (!response.ok && response.status !== 405) {\n throw new StreamableHTTPError(response.status, `Failed to terminate session: ${response.statusText}`);\n }\n this._sessionId = undefined;\n }\n catch (error) {\n (_c = this.onerror) === null || _c === void 0 ? void 0 : _c.call(this, error);\n throw error;\n }\n }\n setProtocolVersion(version) {\n this._protocolVersion = version;\n }\n get protocolVersion() {\n return this._protocolVersion;\n }\n}\n//# sourceMappingURL=streamableHttp.js.map"],"names":[],"mappings":";;;;AAGA;AACA,MAAM,4CAA4C,GAAG;AACrD,IAAI,wBAAwB,EAAE,IAAI;AAClC,IAAI,oBAAoB,EAAE,KAAK;AAC/B,IAAI,2BAA2B,EAAE,GAAG;AACpC,IAAI,UAAU,EAAE,CAAC;AACjB,CAAC;AACM,MAAM,mBAAmB,SAAS,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,CAAC,gBAAgB,GAAG,OAAO;AACvC,IAAI;AACJ,IAAI,IAAI,eAAe,GAAG;AAC1B,QAAQ,OAAO,IAAI,CAAC,gBAAgB;AACpC,IAAI;AACJ;;;;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"streamableHttp.js","sources":["../../../../../../../../../node_modules/@modelcontextprotocol/sdk/dist/esm/client/streamableHttp.js"],"sourcesContent":["import { isInitializedNotification, isJSONRPCRequest, isJSONRPCResponse, JSONRPCMessageSchema } from \"../types.js\";\nimport { auth, extractResourceMetadataUrl, UnauthorizedError } from \"./auth.js\";\nimport { EventSourceParserStream } from \"eventsource-parser/stream\";\n// Default reconnection options for StreamableHTTP connections\nconst DEFAULT_STREAMABLE_HTTP_RECONNECTION_OPTIONS = {\n initialReconnectionDelay: 1000,\n maxReconnectionDelay: 30000,\n reconnectionDelayGrowFactor: 1.5,\n maxRetries: 2,\n};\nexport class StreamableHTTPError extends Error {\n constructor(code, message) {\n super(`Streamable HTTP error: ${message}`);\n this.code = code;\n }\n}\n/**\n * Client transport for Streamable HTTP: this implements the MCP Streamable HTTP transport specification.\n * It will connect to a server using HTTP POST for sending messages and HTTP GET with Server-Sent Events\n * for receiving messages.\n */\nexport class StreamableHTTPClientTransport {\n constructor(url, opts) {\n var _a;\n this._url = url;\n this._resourceMetadataUrl = undefined;\n this._requestInit = opts === null || opts === void 0 ? void 0 : opts.requestInit;\n this._authProvider = opts === null || opts === void 0 ? void 0 : opts.authProvider;\n this._fetch = opts === null || opts === void 0 ? void 0 : opts.fetch;\n this._sessionId = opts === null || opts === void 0 ? void 0 : opts.sessionId;\n this._reconnectionOptions = (_a = opts === null || opts === void 0 ? void 0 : opts.reconnectionOptions) !== null && _a !== void 0 ? _a : DEFAULT_STREAMABLE_HTTP_RECONNECTION_OPTIONS;\n }\n async _authThenStart() {\n var _a;\n if (!this._authProvider) {\n throw new UnauthorizedError(\"No auth provider\");\n }\n let result;\n try {\n result = await auth(this._authProvider, { serverUrl: this._url, resourceMetadataUrl: this._resourceMetadataUrl, fetchFn: this._fetch });\n }\n catch (error) {\n (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error);\n throw error;\n }\n if (result !== \"AUTHORIZED\") {\n throw new UnauthorizedError();\n }\n return await this._startOrAuthSse({ resumptionToken: undefined });\n }\n async _commonHeaders() {\n var _a;\n const headers = {};\n if (this._authProvider) {\n const tokens = await this._authProvider.tokens();\n if (tokens) {\n headers[\"Authorization\"] = `Bearer ${tokens.access_token}`;\n }\n }\n if (this._sessionId) {\n headers[\"mcp-session-id\"] = this._sessionId;\n }\n if (this._protocolVersion) {\n headers[\"mcp-protocol-version\"] = this._protocolVersion;\n }\n const extraHeaders = this._normalizeHeaders((_a = this._requestInit) === null || _a === void 0 ? void 0 : _a.headers);\n return new Headers({\n ...headers,\n ...extraHeaders,\n });\n }\n async _startOrAuthSse(options) {\n var _a, _b, _c;\n const { resumptionToken } = options;\n try {\n // Try to open an initial SSE stream with GET to listen for server messages\n // This is optional according to the spec - server may not support it\n const headers = await this._commonHeaders();\n headers.set(\"Accept\", \"text/event-stream\");\n // Include Last-Event-ID header for resumable streams if provided\n if (resumptionToken) {\n headers.set(\"last-event-id\", resumptionToken);\n }\n const response = await ((_a = this._fetch) !== null && _a !== void 0 ? _a : fetch)(this._url, {\n method: \"GET\",\n headers,\n signal: (_b = this._abortController) === null || _b === void 0 ? void 0 : _b.signal,\n });\n if (!response.ok) {\n if (response.status === 401 && this._authProvider) {\n // Need to authenticate\n return await this._authThenStart();\n }\n // 405 indicates that the server does not offer an SSE stream at GET endpoint\n // This is an expected case that should not trigger an error\n if (response.status === 405) {\n return;\n }\n throw new StreamableHTTPError(response.status, `Failed to open SSE stream: ${response.statusText}`);\n }\n this._handleSseStream(response.body, options, true);\n }\n catch (error) {\n (_c = this.onerror) === null || _c === void 0 ? void 0 : _c.call(this, error);\n throw error;\n }\n }\n /**\n * Calculates the next reconnection delay using backoff algorithm\n *\n * @param attempt Current reconnection attempt count for the specific stream\n * @returns Time to wait in milliseconds before next reconnection attempt\n */\n _getNextReconnectionDelay(attempt) {\n // Access default values directly, ensuring they're never undefined\n const initialDelay = this._reconnectionOptions.initialReconnectionDelay;\n const growFactor = this._reconnectionOptions.reconnectionDelayGrowFactor;\n const maxDelay = this._reconnectionOptions.maxReconnectionDelay;\n // Cap at maximum delay\n return Math.min(initialDelay * Math.pow(growFactor, attempt), maxDelay);\n }\n _normalizeHeaders(headers) {\n if (!headers)\n return {};\n if (headers instanceof Headers) {\n return Object.fromEntries(headers.entries());\n }\n if (Array.isArray(headers)) {\n return Object.fromEntries(headers);\n }\n return { ...headers };\n }\n /**\n * Schedule a reconnection attempt with exponential backoff\n *\n * @param lastEventId The ID of the last received event for resumability\n * @param attemptCount Current reconnection attempt count for this specific stream\n */\n _scheduleReconnection(options, attemptCount = 0) {\n var _a;\n // Use provided options or default options\n const maxRetries = this._reconnectionOptions.maxRetries;\n // Check if we've exceeded maximum retry attempts\n if (maxRetries > 0 && attemptCount >= maxRetries) {\n (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, new Error(`Maximum reconnection attempts (${maxRetries}) exceeded.`));\n return;\n }\n // Calculate next delay based on current attempt count\n const delay = this._getNextReconnectionDelay(attemptCount);\n // Schedule the reconnection\n setTimeout(() => {\n // Use the last event ID to resume where we left off\n this._startOrAuthSse(options).catch(error => {\n var _a;\n (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, new Error(`Failed to reconnect SSE stream: ${error instanceof Error ? error.message : String(error)}`));\n // Schedule another attempt if this one failed, incrementing the attempt counter\n this._scheduleReconnection(options, attemptCount + 1);\n });\n }, delay);\n }\n _handleSseStream(stream, options, isReconnectable) {\n if (!stream) {\n return;\n }\n const { onresumptiontoken, replayMessageId } = options;\n let lastEventId;\n const processStream = async () => {\n var _a, _b, _c, _d;\n // this is the closest we can get to trying to catch network errors\n // if something happens reader will throw\n try {\n // Create a pipeline: binary stream -> text decoder -> SSE parser\n const reader = stream\n .pipeThrough(new TextDecoderStream())\n .pipeThrough(new EventSourceParserStream())\n .getReader();\n while (true) {\n const { value: event, done } = await reader.read();\n if (done) {\n break;\n }\n // Update last event ID if provided\n if (event.id) {\n lastEventId = event.id;\n onresumptiontoken === null || onresumptiontoken === void 0 ? void 0 : onresumptiontoken(event.id);\n }\n if (!event.event || event.event === \"message\") {\n try {\n const message = JSONRPCMessageSchema.parse(JSON.parse(event.data));\n if (replayMessageId !== undefined && isJSONRPCResponse(message)) {\n message.id = replayMessageId;\n }\n (_a = this.onmessage) === null || _a === void 0 ? void 0 : _a.call(this, message);\n }\n catch (error) {\n (_b = this.onerror) === null || _b === void 0 ? void 0 : _b.call(this, error);\n }\n }\n }\n }\n catch (error) {\n // Handle stream errors - likely a network disconnect\n (_c = this.onerror) === null || _c === void 0 ? void 0 : _c.call(this, new Error(`SSE stream disconnected: ${error}`));\n // Attempt to reconnect if the stream disconnects unexpectedly and we aren't closing\n if (isReconnectable &&\n this._abortController &&\n !this._abortController.signal.aborted) {\n // Use the exponential backoff reconnection strategy\n try {\n this._scheduleReconnection({\n resumptionToken: lastEventId,\n onresumptiontoken,\n replayMessageId\n }, 0);\n }\n catch (error) {\n (_d = this.onerror) === null || _d === void 0 ? void 0 : _d.call(this, new Error(`Failed to reconnect: ${error instanceof Error ? error.message : String(error)}`));\n }\n }\n }\n };\n processStream();\n }\n async start() {\n if (this._abortController) {\n throw new Error(\"StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.\");\n }\n this._abortController = new AbortController();\n }\n /**\n * Call this method after the user has finished authorizing via their user agent and is redirected back to the MCP client application. This will exchange the authorization code for an access token, enabling the next connection attempt to successfully auth.\n */\n async finishAuth(authorizationCode) {\n if (!this._authProvider) {\n throw new UnauthorizedError(\"No auth provider\");\n }\n const result = await auth(this._authProvider, { serverUrl: this._url, authorizationCode, resourceMetadataUrl: this._resourceMetadataUrl, fetchFn: this._fetch });\n if (result !== \"AUTHORIZED\") {\n throw new UnauthorizedError(\"Failed to authorize\");\n }\n }\n async close() {\n var _a, _b;\n // Abort any pending requests\n (_a = this._abortController) === null || _a === void 0 ? void 0 : _a.abort();\n (_b = this.onclose) === null || _b === void 0 ? void 0 : _b.call(this);\n }\n async send(message, options) {\n var _a, _b, _c, _d;\n try {\n const { resumptionToken, onresumptiontoken } = options || {};\n if (resumptionToken) {\n // If we have at last event ID, we need to reconnect the SSE stream\n this._startOrAuthSse({ resumptionToken, replayMessageId: isJSONRPCRequest(message) ? message.id : undefined }).catch(err => { var _a; return (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, err); });\n return;\n }\n const headers = await this._commonHeaders();\n headers.set(\"content-type\", \"application/json\");\n headers.set(\"accept\", \"application/json, text/event-stream\");\n const init = {\n ...this._requestInit,\n method: \"POST\",\n headers,\n body: JSON.stringify(message),\n signal: (_a = this._abortController) === null || _a === void 0 ? void 0 : _a.signal,\n };\n const response = await ((_b = this._fetch) !== null && _b !== void 0 ? _b : fetch)(this._url, init);\n // Handle session ID received during initialization\n const sessionId = response.headers.get(\"mcp-session-id\");\n if (sessionId) {\n this._sessionId = sessionId;\n }\n if (!response.ok) {\n if (response.status === 401 && this._authProvider) {\n this._resourceMetadataUrl = extractResourceMetadataUrl(response);\n const result = await auth(this._authProvider, { serverUrl: this._url, resourceMetadataUrl: this._resourceMetadataUrl, fetchFn: this._fetch });\n if (result !== \"AUTHORIZED\") {\n throw new UnauthorizedError();\n }\n // Purposely _not_ awaited, so we don't call onerror twice\n return this.send(message);\n }\n const text = await response.text().catch(() => null);\n throw new Error(`Error POSTing to endpoint (HTTP ${response.status}): ${text}`);\n }\n // If the response is 202 Accepted, there's no body to process\n if (response.status === 202) {\n // if the accepted notification is initialized, we start the SSE stream\n // if it's supported by the server\n if (isInitializedNotification(message)) {\n // Start without a lastEventId since this is a fresh connection\n this._startOrAuthSse({ resumptionToken: undefined }).catch(err => { var _a; return (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, err); });\n }\n return;\n }\n // Get original message(s) for detecting request IDs\n const messages = Array.isArray(message) ? message : [message];\n const hasRequests = messages.filter(msg => \"method\" in msg && \"id\" in msg && msg.id !== undefined).length > 0;\n // Check the response type\n const contentType = response.headers.get(\"content-type\");\n if (hasRequests) {\n if (contentType === null || contentType === void 0 ? void 0 : contentType.includes(\"text/event-stream\")) {\n // Handle SSE stream responses for requests\n // We use the same handler as standalone streams, which now supports\n // reconnection with the last event ID\n this._handleSseStream(response.body, { onresumptiontoken }, false);\n }\n else if (contentType === null || contentType === void 0 ? void 0 : contentType.includes(\"application/json\")) {\n // For non-streaming servers, we might get direct JSON responses\n const data = await response.json();\n const responseMessages = Array.isArray(data)\n ? data.map(msg => JSONRPCMessageSchema.parse(msg))\n : [JSONRPCMessageSchema.parse(data)];\n for (const msg of responseMessages) {\n (_c = this.onmessage) === null || _c === void 0 ? void 0 : _c.call(this, msg);\n }\n }\n else {\n throw new StreamableHTTPError(-1, `Unexpected content type: ${contentType}`);\n }\n }\n }\n catch (error) {\n (_d = this.onerror) === null || _d === void 0 ? void 0 : _d.call(this, error);\n throw error;\n }\n }\n get sessionId() {\n return this._sessionId;\n }\n /**\n * Terminates the current session by sending a DELETE request to the server.\n *\n * Clients that no longer need a particular session\n * (e.g., because the user is leaving the client application) SHOULD send an\n * HTTP DELETE to the MCP endpoint with the Mcp-Session-Id header to explicitly\n * terminate the session.\n *\n * The server MAY respond with HTTP 405 Method Not Allowed, indicating that\n * the server does not allow clients to terminate sessions.\n */\n async terminateSession() {\n var _a, _b, _c;\n if (!this._sessionId) {\n return; // No session to terminate\n }\n try {\n const headers = await this._commonHeaders();\n const init = {\n ...this._requestInit,\n method: \"DELETE\",\n headers,\n signal: (_a = this._abortController) === null || _a === void 0 ? void 0 : _a.signal,\n };\n const response = await ((_b = this._fetch) !== null && _b !== void 0 ? _b : fetch)(this._url, init);\n // We specifically handle 405 as a valid response according to the spec,\n // meaning the server does not support explicit session termination\n if (!response.ok && response.status !== 405) {\n throw new StreamableHTTPError(response.status, `Failed to terminate session: ${response.statusText}`);\n }\n this._sessionId = undefined;\n }\n catch (error) {\n (_c = this.onerror) === null || _c === void 0 ? void 0 : _c.call(this, error);\n throw error;\n }\n }\n setProtocolVersion(version) {\n this._protocolVersion = version;\n }\n get protocolVersion() {\n return this._protocolVersion;\n }\n}\n//# sourceMappingURL=streamableHttp.js.map"],"names":[],"mappings":";;;;AAGA;AACA,MAAM,4CAA4C,GAAG;AACrD,IAAI,wBAAwB,EAAE,IAAI;AAClC,IAAI,oBAAoB,EAAE,KAAK;AAC/B,IAAI,2BAA2B,EAAE,GAAG;AACpC,IAAI,UAAU,EAAE,CAAC;AACjB,CAAC;AACM,MAAM,mBAAmB,SAAS,KAAK,CAAC;AAC/C,IAAI,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE;AAC/B,QAAQ,KAAK,CAAC,CAAC,uBAAuB,EAAE,OAAO,CAAC,CAAC,CAAC;AAClD,QAAQ,IAAI,CAAC,IAAI,GAAG,IAAI;AACxB,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,6BAA6B,CAAC;AAC3C,IAAI,WAAW,CAAC,GAAG,EAAE,IAAI,EAAE;AAC3B,QAAQ,IAAI,EAAE;AACd,QAAQ,IAAI,CAAC,IAAI,GAAG,GAAG;AACvB,QAAQ,IAAI,CAAC,oBAAoB,GAAG,SAAS;AAC7C,QAAQ,IAAI,CAAC,YAAY,GAAG,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC,WAAW;AACxF,QAAQ,IAAI,CAAC,aAAa,GAAG,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC,YAAY;AAC1F,QAAQ,IAAI,CAAC,MAAM,GAAG,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC,KAAK;AAC5E,QAAQ,IAAI,CAAC,UAAU,GAAG,I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IAAI,CAAC,QAAQ,CAAC,EAAE,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE;AACzD,gBAAgB,MAAM,IAAI,mBAAmB,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,6BAA6B,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;AACrH,YAAY;AACZ,YAAY,IAAI,CAAC,UAAU,GAAG,SAAS;AACvC,QAAQ;AACR,QAAQ,OAAO,KAAK,EAAE;AACtB,YAAY,CAAC,EAAE,GAAG,IAAI,CAAC,OAAO,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC;AACzF,YAAY,MAAM,KAAK;AACvB,QAAQ;AACR,IAAI;AACJ,IAAI,kBAAkB,CAAC,OAAO,EAAE;AAChC,QAAQ,IAAI,CAAC,gBAAgB,GAAG,OAAO;AACvC,IAAI;AACJ,IAAI,IAAI,eAAe,GAAG;AAC1B,QAAQ,OAAO,IAAI,CAAC,gBAAgB;AACpC,IAAI;AACJ;;;;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base class for all OAuth errors
|
|
3
|
+
*/
|
|
4
|
+
class OAuthError extends Error {
|
|
5
|
+
constructor(message, errorUri) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.errorUri = errorUri;
|
|
8
|
+
this.name = this.constructor.name;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Converts the error to a standard OAuth error response object
|
|
12
|
+
*/
|
|
13
|
+
toResponseObject() {
|
|
14
|
+
const response = {
|
|
15
|
+
error: this.errorCode,
|
|
16
|
+
error_description: this.message
|
|
17
|
+
};
|
|
18
|
+
if (this.errorUri) {
|
|
19
|
+
response.error_uri = this.errorUri;
|
|
20
|
+
}
|
|
21
|
+
return response;
|
|
22
|
+
}
|
|
23
|
+
get errorCode() {
|
|
24
|
+
return this.constructor.errorCode;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Invalid request error - The request is missing a required parameter,
|
|
29
|
+
* includes an invalid parameter value, includes a parameter more than once,
|
|
30
|
+
* or is otherwise malformed.
|
|
31
|
+
*/
|
|
32
|
+
class InvalidRequestError extends OAuthError {
|
|
33
|
+
}
|
|
34
|
+
InvalidRequestError.errorCode = "invalid_request";
|
|
35
|
+
/**
|
|
36
|
+
* Invalid client error - Client authentication failed (e.g., unknown client, no client
|
|
37
|
+
* authentication included, or unsupported authentication method).
|
|
38
|
+
*/
|
|
39
|
+
class InvalidClientError extends OAuthError {
|
|
40
|
+
}
|
|
41
|
+
InvalidClientError.errorCode = "invalid_client";
|
|
42
|
+
/**
|
|
43
|
+
* Invalid grant error - The provided authorization grant or refresh token is
|
|
44
|
+
* invalid, expired, revoked, does not match the redirection URI used in the
|
|
45
|
+
* authorization request, or was issued to another client.
|
|
46
|
+
*/
|
|
47
|
+
class InvalidGrantError extends OAuthError {
|
|
48
|
+
}
|
|
49
|
+
InvalidGrantError.errorCode = "invalid_grant";
|
|
50
|
+
/**
|
|
51
|
+
* Unauthorized client error - The authenticated client is not authorized to use
|
|
52
|
+
* this authorization grant type.
|
|
53
|
+
*/
|
|
54
|
+
class UnauthorizedClientError extends OAuthError {
|
|
55
|
+
}
|
|
56
|
+
UnauthorizedClientError.errorCode = "unauthorized_client";
|
|
57
|
+
/**
|
|
58
|
+
* Unsupported grant type error - The authorization grant type is not supported
|
|
59
|
+
* by the authorization server.
|
|
60
|
+
*/
|
|
61
|
+
class UnsupportedGrantTypeError extends OAuthError {
|
|
62
|
+
}
|
|
63
|
+
UnsupportedGrantTypeError.errorCode = "unsupported_grant_type";
|
|
64
|
+
/**
|
|
65
|
+
* Invalid scope error - The requested scope is invalid, unknown, malformed, or
|
|
66
|
+
* exceeds the scope granted by the resource owner.
|
|
67
|
+
*/
|
|
68
|
+
class InvalidScopeError extends OAuthError {
|
|
69
|
+
}
|
|
70
|
+
InvalidScopeError.errorCode = "invalid_scope";
|
|
71
|
+
/**
|
|
72
|
+
* Access denied error - The resource owner or authorization server denied the request.
|
|
73
|
+
*/
|
|
74
|
+
class AccessDeniedError extends OAuthError {
|
|
75
|
+
}
|
|
76
|
+
AccessDeniedError.errorCode = "access_denied";
|
|
77
|
+
/**
|
|
78
|
+
* Server error - The authorization server encountered an unexpected condition
|
|
79
|
+
* that prevented it from fulfilling the request.
|
|
80
|
+
*/
|
|
81
|
+
class ServerError extends OAuthError {
|
|
82
|
+
}
|
|
83
|
+
ServerError.errorCode = "server_error";
|
|
84
|
+
/**
|
|
85
|
+
* Temporarily unavailable error - The authorization server is currently unable to
|
|
86
|
+
* handle the request due to a temporary overloading or maintenance of the server.
|
|
87
|
+
*/
|
|
88
|
+
class TemporarilyUnavailableError extends OAuthError {
|
|
89
|
+
}
|
|
90
|
+
TemporarilyUnavailableError.errorCode = "temporarily_unavailable";
|
|
91
|
+
/**
|
|
92
|
+
* Unsupported response type error - The authorization server does not support
|
|
93
|
+
* obtaining an authorization code using this method.
|
|
94
|
+
*/
|
|
95
|
+
class UnsupportedResponseTypeError extends OAuthError {
|
|
96
|
+
}
|
|
97
|
+
UnsupportedResponseTypeError.errorCode = "unsupported_response_type";
|
|
98
|
+
/**
|
|
99
|
+
* Unsupported token type error - The authorization server does not support
|
|
100
|
+
* the requested token type.
|
|
101
|
+
*/
|
|
102
|
+
class UnsupportedTokenTypeError extends OAuthError {
|
|
103
|
+
}
|
|
104
|
+
UnsupportedTokenTypeError.errorCode = "unsupported_token_type";
|
|
105
|
+
/**
|
|
106
|
+
* Invalid token error - The access token provided is expired, revoked, malformed,
|
|
107
|
+
* or invalid for other reasons.
|
|
108
|
+
*/
|
|
109
|
+
class InvalidTokenError extends OAuthError {
|
|
110
|
+
}
|
|
111
|
+
InvalidTokenError.errorCode = "invalid_token";
|
|
112
|
+
/**
|
|
113
|
+
* Method not allowed error - The HTTP method used is not allowed for this endpoint.
|
|
114
|
+
* (Custom, non-standard error)
|
|
115
|
+
*/
|
|
116
|
+
class MethodNotAllowedError extends OAuthError {
|
|
117
|
+
}
|
|
118
|
+
MethodNotAllowedError.errorCode = "method_not_allowed";
|
|
119
|
+
/**
|
|
120
|
+
* Too many requests error - Rate limit exceeded.
|
|
121
|
+
* (Custom, non-standard error based on RFC 6585)
|
|
122
|
+
*/
|
|
123
|
+
class TooManyRequestsError extends OAuthError {
|
|
124
|
+
}
|
|
125
|
+
TooManyRequestsError.errorCode = "too_many_requests";
|
|
126
|
+
/**
|
|
127
|
+
* Invalid client metadata error - The client metadata is invalid.
|
|
128
|
+
* (Custom error for dynamic client registration - RFC 7591)
|
|
129
|
+
*/
|
|
130
|
+
class InvalidClientMetadataError extends OAuthError {
|
|
131
|
+
}
|
|
132
|
+
InvalidClientMetadataError.errorCode = "invalid_client_metadata";
|
|
133
|
+
/**
|
|
134
|
+
* Insufficient scope error - The request requires higher privileges than provided by the access token.
|
|
135
|
+
*/
|
|
136
|
+
class InsufficientScopeError extends OAuthError {
|
|
137
|
+
}
|
|
138
|
+
InsufficientScopeError.errorCode = "insufficient_scope";
|
|
139
|
+
/**
|
|
140
|
+
* A full list of all OAuthErrors, enabling parsing from error responses
|
|
141
|
+
*/
|
|
142
|
+
const OAUTH_ERRORS = {
|
|
143
|
+
[InvalidRequestError.errorCode]: InvalidRequestError,
|
|
144
|
+
[InvalidClientError.errorCode]: InvalidClientError,
|
|
145
|
+
[InvalidGrantError.errorCode]: InvalidGrantError,
|
|
146
|
+
[UnauthorizedClientError.errorCode]: UnauthorizedClientError,
|
|
147
|
+
[UnsupportedGrantTypeError.errorCode]: UnsupportedGrantTypeError,
|
|
148
|
+
[InvalidScopeError.errorCode]: InvalidScopeError,
|
|
149
|
+
[AccessDeniedError.errorCode]: AccessDeniedError,
|
|
150
|
+
[ServerError.errorCode]: ServerError,
|
|
151
|
+
[TemporarilyUnavailableError.errorCode]: TemporarilyUnavailableError,
|
|
152
|
+
[UnsupportedResponseTypeError.errorCode]: UnsupportedResponseTypeError,
|
|
153
|
+
[UnsupportedTokenTypeError.errorCode]: UnsupportedTokenTypeError,
|
|
154
|
+
[InvalidTokenError.errorCode]: InvalidTokenError,
|
|
155
|
+
[MethodNotAllowedError.errorCode]: MethodNotAllowedError,
|
|
156
|
+
[TooManyRequestsError.errorCode]: TooManyRequestsError,
|
|
157
|
+
[InvalidClientMetadataError.errorCode]: InvalidClientMetadataError,
|
|
158
|
+
[InsufficientScopeError.errorCode]: InsufficientScopeError,
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
export { AccessDeniedError, InsufficientScopeError, InvalidClientError, InvalidClientMetadataError, InvalidGrantError, InvalidRequestError, InvalidScopeError, InvalidTokenError, MethodNotAllowedError, OAUTH_ERRORS, OAuthError, ServerError, TemporarilyUnavailableError, TooManyRequestsError, UnauthorizedClientError, UnsupportedGrantTypeError, UnsupportedResponseTypeError, UnsupportedTokenTypeError };
|
|
162
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sources":["../../../../../../../../../../node_modules/@modelcontextprotocol/sdk/dist/esm/server/auth/errors.js"],"sourcesContent":["/**\n * Base class for all OAuth errors\n */\nexport class OAuthError extends Error {\n constructor(message, errorUri) {\n super(message);\n this.errorUri = errorUri;\n this.name = this.constructor.name;\n }\n /**\n * Converts the error to a standard OAuth error response object\n */\n toResponseObject() {\n const response = {\n error: this.errorCode,\n error_description: this.message\n };\n if (this.errorUri) {\n response.error_uri = this.errorUri;\n }\n return response;\n }\n get errorCode() {\n return this.constructor.errorCode;\n }\n}\n/**\n * Invalid request error - The request is missing a required parameter,\n * includes an invalid parameter value, includes a parameter more than once,\n * or is otherwise malformed.\n */\nexport class InvalidRequestError extends OAuthError {\n}\nInvalidRequestError.errorCode = \"invalid_request\";\n/**\n * Invalid client error - Client authentication failed (e.g., unknown client, no client\n * authentication included, or unsupported authentication method).\n */\nexport class InvalidClientError extends OAuthError {\n}\nInvalidClientError.errorCode = \"invalid_client\";\n/**\n * Invalid grant error - The provided authorization grant or refresh token is\n * invalid, expired, revoked, does not match the redirection URI used in the\n * authorization request, or was issued to another client.\n */\nexport class InvalidGrantError extends OAuthError {\n}\nInvalidGrantError.errorCode = \"invalid_grant\";\n/**\n * Unauthorized client error - The authenticated client is not authorized to use\n * this authorization grant type.\n */\nexport class UnauthorizedClientError extends OAuthError {\n}\nUnauthorizedClientError.errorCode = \"unauthorized_client\";\n/**\n * Unsupported grant type error - The authorization grant type is not supported\n * by the authorization server.\n */\nexport class UnsupportedGrantTypeError extends OAuthError {\n}\nUnsupportedGrantTypeError.errorCode = \"unsupported_grant_type\";\n/**\n * Invalid scope error - The requested scope is invalid, unknown, malformed, or\n * exceeds the scope granted by the resource owner.\n */\nexport class InvalidScopeError extends OAuthError {\n}\nInvalidScopeError.errorCode = \"invalid_scope\";\n/**\n * Access denied error - The resource owner or authorization server denied the request.\n */\nexport class AccessDeniedError extends OAuthError {\n}\nAccessDeniedError.errorCode = \"access_denied\";\n/**\n * Server error - The authorization server encountered an unexpected condition\n * that prevented it from fulfilling the request.\n */\nexport class ServerError extends OAuthError {\n}\nServerError.errorCode = \"server_error\";\n/**\n * Temporarily unavailable error - The authorization server is currently unable to\n * handle the request due to a temporary overloading or maintenance of the server.\n */\nexport class TemporarilyUnavailableError extends OAuthError {\n}\nTemporarilyUnavailableError.errorCode = \"temporarily_unavailable\";\n/**\n * Unsupported response type error - The authorization server does not support\n * obtaining an authorization code using this method.\n */\nexport class UnsupportedResponseTypeError extends OAuthError {\n}\nUnsupportedResponseTypeError.errorCode = \"unsupported_response_type\";\n/**\n * Unsupported token type error - The authorization server does not support\n * the requested token type.\n */\nexport class UnsupportedTokenTypeError extends OAuthError {\n}\nUnsupportedTokenTypeError.errorCode = \"unsupported_token_type\";\n/**\n * Invalid token error - The access token provided is expired, revoked, malformed,\n * or invalid for other reasons.\n */\nexport class InvalidTokenError extends OAuthError {\n}\nInvalidTokenError.errorCode = \"invalid_token\";\n/**\n * Method not allowed error - The HTTP method used is not allowed for this endpoint.\n * (Custom, non-standard error)\n */\nexport class MethodNotAllowedError extends OAuthError {\n}\nMethodNotAllowedError.errorCode = \"method_not_allowed\";\n/**\n * Too many requests error - Rate limit exceeded.\n * (Custom, non-standard error based on RFC 6585)\n */\nexport class TooManyRequestsError extends OAuthError {\n}\nTooManyRequestsError.errorCode = \"too_many_requests\";\n/**\n * Invalid client metadata error - The client metadata is invalid.\n * (Custom error for dynamic client registration - RFC 7591)\n */\nexport class InvalidClientMetadataError extends OAuthError {\n}\nInvalidClientMetadataError.errorCode = \"invalid_client_metadata\";\n/**\n * Insufficient scope error - The request requires higher privileges than provided by the access token.\n */\nexport class InsufficientScopeError extends OAuthError {\n}\nInsufficientScopeError.errorCode = \"insufficient_scope\";\n/**\n * A utility class for defining one-off error codes\n */\nexport class CustomOAuthError extends OAuthError {\n constructor(customErrorCode, message, errorUri) {\n super(message, errorUri);\n this.customErrorCode = customErrorCode;\n }\n get errorCode() {\n return this.customErrorCode;\n }\n}\n/**\n * A full list of all OAuthErrors, enabling parsing from error responses\n */\nexport const OAUTH_ERRORS = {\n [InvalidRequestError.errorCode]: InvalidRequestError,\n [InvalidClientError.errorCode]: InvalidClientError,\n [InvalidGrantError.errorCode]: InvalidGrantError,\n [UnauthorizedClientError.errorCode]: UnauthorizedClientError,\n [UnsupportedGrantTypeError.errorCode]: UnsupportedGrantTypeError,\n [InvalidScopeError.errorCode]: InvalidScopeError,\n [AccessDeniedError.errorCode]: AccessDeniedError,\n [ServerError.errorCode]: ServerError,\n [TemporarilyUnavailableError.errorCode]: TemporarilyUnavailableError,\n [UnsupportedResponseTypeError.errorCode]: UnsupportedResponseTypeError,\n [UnsupportedTokenTypeError.errorCode]: UnsupportedTokenTypeError,\n [InvalidTokenError.errorCode]: InvalidTokenError,\n [MethodNotAllowedError.errorCode]: MethodNotAllowedError,\n [TooManyRequestsError.errorCode]: TooManyRequestsError,\n [InvalidClientMetadataError.errorCode]: InvalidClientMetadataError,\n [InsufficientScopeError.errorCode]: InsufficientScopeError,\n};\n//# sourceMappingURL=errors.js.map"],"names":[],"mappings":"AAAA;AACA;AACA;AACO,MAAM,UAAU,SAAS,KAAK,CAAC;AACtC,IAAI,WAAW,CAAC,OAAO,EAAE,QAAQ,EAAE;AACnC,QAAQ,KAAK,CAAC,OAAO,CAAC;AACtB,QAAQ,IAAI,CAAC,QAAQ,GAAG,QAAQ;AAChC,QAAQ,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI;AACzC,IAAI;AACJ;AACA;AACA;AACA,IAAI,gBAAgB,GAAG;AACvB,QAAQ,MAAM,QAAQ,GAAG;AACzB,YAAY,KAAK,EAAE,IAAI,CAAC,SAAS;AACjC,YAAY,iBAAiB,EAAE,IAAI,CAAC;AACpC,SAAS;AACT,QAAQ,IAAI,IAAI,CAAC,QAAQ,EAAE;AAC3B,YAAY,QAAQ,CAAC,SAAS,GAAG,IAAI,CAAC,QAAQ;AAC9C,QAAQ;AACR,QAAQ,OAAO,QAAQ;AACvB,IAAI;AACJ,IAAI,IAAI,SAAS,GAAG;AACpB,QAAQ,OAAO,IAAI,CAAC,WAAW,CAAC,SAAS;AACzC,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,mBAAmB,SAAS,UAAU,CAAC;AACpD;AACA,mBAAmB,CAAC,SAAS,GAAG,iBAAiB;AACjD;AACA;AACA;AACA;AACO,MAAM,kBAAkB,SAAS,UAAU,CAAC;AACnD;AACA,kBAAkB,CAAC,SAAS,GAAG,gBAAgB;AAC/C;AACA;AACA;AACA;AACA;AACO,MAAM,iBAAiB,SAAS,UAAU,CAAC;AAClD;AACA,iBAAiB,CAAC,SAAS,GAAG,eAAe;AAC7C;AACA;AACA;AACA;AACO,MAAM,uBAAuB,SAAS,UAAU,CAAC;AACxD;AACA,uBAAuB,CAAC,SAAS,GAAG,qBAAqB;AACzD;AACA;AACA;AACA;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