@diffra-ai/mcp 0.0.0-stage → 0.1.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/CHANGELOG.md +7 -0
- package/LICENSE +22 -0
- package/README.md +190 -2
- package/THIRD_PARTY_NOTICES/modelcontextprotocol-typescript-sdk.txt +21 -0
- package/dist/auth-provider.d.ts +19 -0
- package/dist/auth-provider.d.ts.map +1 -0
- package/dist/auth-provider.js +2 -0
- package/dist/auth-provider.js.map +1 -0
- package/dist/client.d.ts +89 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +461 -0
- package/dist/client.js.map +1 -0
- package/dist/config.d.ts +117 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +153 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/input-schema.d.ts +7 -0
- package/dist/input-schema.d.ts.map +1 -0
- package/dist/input-schema.js +13 -0
- package/dist/input-schema.js.map +1 -0
- package/dist/model-content.d.ts +19 -0
- package/dist/model-content.d.ts.map +1 -0
- package/dist/model-content.js +67 -0
- package/dist/model-content.js.map +1 -0
- package/dist/naming.d.ts +23 -0
- package/dist/naming.d.ts.map +1 -0
- package/dist/naming.js +37 -0
- package/dist/naming.js.map +1 -0
- package/dist/oauth/auth-provider.d.ts +52 -0
- package/dist/oauth/auth-provider.d.ts.map +1 -0
- package/dist/oauth/auth-provider.js +97 -0
- package/dist/oauth/auth-provider.js.map +1 -0
- package/dist/oauth/callback.d.ts +48 -0
- package/dist/oauth/callback.d.ts.map +1 -0
- package/dist/oauth/callback.js +119 -0
- package/dist/oauth/callback.js.map +1 -0
- package/dist/oauth/client-settings.d.ts +107 -0
- package/dist/oauth/client-settings.d.ts.map +1 -0
- package/dist/oauth/client-settings.js +114 -0
- package/dist/oauth/client-settings.js.map +1 -0
- package/dist/oauth/discovery.d.ts +30 -0
- package/dist/oauth/discovery.d.ts.map +1 -0
- package/dist/oauth/discovery.js +156 -0
- package/dist/oauth/discovery.js.map +1 -0
- package/dist/oauth/errors.d.ts +32 -0
- package/dist/oauth/errors.d.ts.map +1 -0
- package/dist/oauth/errors.js +58 -0
- package/dist/oauth/errors.js.map +1 -0
- package/dist/oauth/flow.d.ts +112 -0
- package/dist/oauth/flow.d.ts.map +1 -0
- package/dist/oauth/flow.js +360 -0
- package/dist/oauth/flow.js.map +1 -0
- package/dist/oauth/index.d.ts +11 -0
- package/dist/oauth/index.d.ts.map +1 -0
- package/dist/oauth/index.js +9 -0
- package/dist/oauth/index.js.map +1 -0
- package/dist/oauth/loopback.d.ts +51 -0
- package/dist/oauth/loopback.d.ts.map +1 -0
- package/dist/oauth/loopback.js +98 -0
- package/dist/oauth/loopback.js.map +1 -0
- package/dist/oauth/provider.d.ts +62 -0
- package/dist/oauth/provider.d.ts.map +1 -0
- package/dist/oauth/provider.js +118 -0
- package/dist/oauth/provider.js.map +1 -0
- package/dist/oauth/sign-in.d.ts +73 -0
- package/dist/oauth/sign-in.d.ts.map +1 -0
- package/dist/oauth/sign-in.js +182 -0
- package/dist/oauth/sign-in.js.map +1 -0
- package/dist/oauth/types.d.ts +83 -0
- package/dist/oauth/types.d.ts.map +1 -0
- package/dist/oauth/types.js +113 -0
- package/dist/oauth/types.js.map +1 -0
- package/dist/output-limit.d.ts +24 -0
- package/dist/output-limit.d.ts.map +1 -0
- package/dist/output-limit.js +58 -0
- package/dist/output-limit.js.map +1 -0
- package/dist/protocol/content.d.ts +83 -0
- package/dist/protocol/content.d.ts.map +1 -0
- package/dist/protocol/content.js +41 -0
- package/dist/protocol/content.js.map +1 -0
- package/dist/protocol/jsonrpc.d.ts +59 -0
- package/dist/protocol/jsonrpc.d.ts.map +1 -0
- package/dist/protocol/jsonrpc.js +67 -0
- package/dist/protocol/jsonrpc.js.map +1 -0
- package/dist/protocol/types.d.ts +123 -0
- package/dist/protocol/types.d.ts.map +1 -0
- package/dist/protocol/types.js +7 -0
- package/dist/protocol/types.js.map +1 -0
- package/dist/result-schema.d.ts +10 -0
- package/dist/result-schema.d.ts.map +1 -0
- package/dist/result-schema.js +78 -0
- package/dist/result-schema.js.map +1 -0
- package/dist/testing/index.d.ts +2 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +2 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/transports/in-memory.d.ts +19 -0
- package/dist/transports/in-memory.d.ts.map +1 -0
- package/dist/transports/in-memory.js +50 -0
- package/dist/transports/in-memory.js.map +1 -0
- package/dist/transports/lines.d.ts +34 -0
- package/dist/transports/lines.d.ts.map +1 -0
- package/dist/transports/lines.js +85 -0
- package/dist/transports/lines.js.map +1 -0
- package/dist/transports/pipe.d.ts +49 -0
- package/dist/transports/pipe.d.ts.map +1 -0
- package/dist/transports/pipe.js +96 -0
- package/dist/transports/pipe.js.map +1 -0
- package/dist/transports/stdio.d.ts +29 -0
- package/dist/transports/stdio.d.ts.map +1 -0
- package/dist/transports/stdio.js +170 -0
- package/dist/transports/stdio.js.map +1 -0
- package/dist/transports/streamable-http.d.ts +103 -0
- package/dist/transports/streamable-http.d.ts.map +1 -0
- package/dist/transports/streamable-http.js +531 -0
- package/dist/transports/streamable-http.js.map +1 -0
- package/dist/transports/transport.d.ts +36 -0
- package/dist/transports/transport.d.ts.map +1 -0
- package/dist/transports/transport.js +38 -0
- package/dist/transports/transport.js.map +1 -0
- package/package.json +59 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-settings.js","sourceRoot":"","sources":["../../src/oauth/client-settings.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,OAAO,EAAE,gBAAgB,EAA2B,MAAM,eAAe,CAAC;AA2E1E,0GAA0G;AAC1G,MAAM,UAAU,yBAAyB,CACxC,OAA8B,EAC9B,WAAmB,EACnB,UAAU,GAAuB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AI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,YAAY,CAAC;IACjE,IAAI,gBAAoC,CAAC;IACzC,iGAAiG;IACjG,IAAI,GAAG,CAAC,IAAI;QAAE,gBAAgB,GAAG,QAAQ,CAAC,WAAW,CAAC;SACjD,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QAC7B,GAAG,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;QACxB,gBAAgB,GAAG,GAAG,CAAC,IAAI,CAAC;IAC7B,CAAC;IACD,OAAO;QACN,GAAG,EAAE,UAAU;QACf,iFAAiF;QACjF,IAAI,EAAE,OAAO,KAAK,WAAW,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,OAAO;QACvD,YAAY,EAAE,OAAO;QACrB,IAAI;QACJ,IAAI,EAAE,GAAG,CAAC,QAAQ;QAClB,gBAAgB;KAChB,CAAC;AACH,CAAC","sourcesContent":["/**\n * The OAuth client that sign-in and refreshes use for one MCP server: its settings, how it identifies\n * itself (a pre-registered client, a Client ID Metadata Document, or dynamic client registration), and\n * the `McpOAuthProvider` built from them.\n */\n\nimport { createHash } from \"node:crypto\";\nimport type { McpFetch } from \"../auth-provider.ts\";\nimport type { OAuthClientMetadataDocument } from \"./flow.ts\";\nimport { McpOAuthProvider, type McpOAuthStateStore } from \"./provider.ts\";\nimport type { AuthorizationServerMetadata, OAuthClientInformationMixed } from \"./types.ts\";\n\n/** Client settings of one MCP server, usually from the application's configuration. */\nexport interface McpOAuthSettings {\n\t/** Pre-registered client id. Without it, sign-in uses a Client ID Metadata Document or registers a client. */\n\tclientId?: string;\n\t/** Already resolved. */\n\tclientSecret?: string;\n\t/**\n\t * Port of the loopback callback server, for clients registered with a fixed redirect URI. Without\n\t * `callbackUrl`, the redirect URI is `http://127.0.0.1:<port>/callback`. Only `listenForLoopbackSignIn`\n\t * and the redirect URI of refreshes use it; `startMcpSignIn` and `completeMcpSignIn` take theirs from\n\t * the caller.\n\t */\n\tcallbackPort?: number;\n\t/**\n\t * Loopback redirect URI registered for `clientId`, for example `http://localhost:8080/oauth/callback`.\n\t * Without a port, the callback server listens on `callbackPort` or a free port, which is added to the\n\t * URI (RFC 8252). Default: `http://127.0.0.1/callback`. Like `callbackPort`, only `listenForLoopbackSignIn`\n\t * and refreshes use it.\n\t */\n\tcallbackUrl?: string;\n\t/** Scopes to request, separated by spaces. Default: the scopes the server advertises. */\n\tscope?: string;\n\t/** `client_name` for dynamic client registration. Default: the application's `clientName`. */\n\tclientName?: string;\n\t/**\n\t * How to identify without `clientId`. `auto` (default): a Client ID Metadata Document when the\n\t * authorization server supports them for public clients and the documents list the redirect URI,\n\t * otherwise dynamic client registration; with `clientName`, always dynamic client registration.\n\t * `cimd`: always the document, and sign-in fails without support. `dcr`: always dynamic client\n\t * registration.\n\t */\n\tclientRegistration?: \"auto\" | \"dcr\" | \"cimd\";\n\t/**\n\t * Authorization server metadata document to use instead of discovery through the server, for servers\n\t * that advertise a wrong authorization server or none. It is trusted as configured.\n\t */\n\tauthServerMetadataUrl?: URL;\n}\n\n/**\n * The Client ID Metadata Documents an application publishes: `<baseUrl>/client.json`, and for each MCP\n * server `<baseUrl>/<callback ID>/client.json`, whose redirect URIs carry the path `<path>/<callback ID>`.\n */\nexport interface McpClientMetadataDocuments {\n\t/** For example `https://pi.dev/oauth`. */\n\tbaseUrl: string;\n\t/** Whether the documents list `redirectUrl`. Loopback redirect URIs match on any port (RFC 8252). */\n\tlistsRedirectUrl(redirectUrl: string): boolean;\n}\n\n/** State store of one MCP server, with a lock that keeps other processes from refreshing at the same time. */\nexport interface McpOAuthServerStore extends McpOAuthStateStore {\n\t/**\n\t * Run `fn` while no other process refreshes the server's tokens. Not reentrant: `startMcpSignIn` and\n\t * `createMcpAuthProvider` take it themselves, so never call them from `fn`. Throw\n\t * `McpRefreshLockBusyError` when another process holds the lock for the whole wait: `startMcpSignIn`\n\t * then goes to the browser step. Any other error fails the sign-in or refresh.\n\t */\n\twithRefreshLock<T>(fn: () => Promise<T>): Promise<T>;\n}\n\n/** The OAuth client of one MCP server: where its state lives, its settings, and the application's identity. */\nexport interface McpOAuthClientOptions {\n\tserverUrl: string;\n\tstore: McpOAuthServerStore;\n\tsettings: McpOAuthSettings;\n\t/** `client_name` for dynamic client registration unless `settings.clientName` names another: the application. */\n\tclientName: string;\n\t/** Omitted: dynamic client registration only. */\n\tclientMetadataDocuments?: McpClientMetadataDocuments;\n}\n\n/** An `McpOAuthProvider` for the client, redirecting to `redirectUrl` or the document's variant of it. */\nexport function createOAuthClientProvider(\n\toptions: McpOAuthClientOptions,\n\tredirectUrl: string,\n\tonRedirect: (url: URL) => void = () => {},\n): McpOAuthProvider {\n\tconst { serverUrl, settings, clientMetadataDocuments: documents } = options;\n\treturn new McpOAuthProvider({\n\t\tserverUrl,\n\t\tredirectUrl,\n\t\tclientMetadata: { client_name: settings.clientName ?? options.clientName },\n\t\tclientMetadataDocument: offersClientMetadataDocument(settings, documents, redirectUrl)\n\t\t\t? (metadata) => {\n\t\t\t\t\tif (!documents?.listsRedirectUrl(redirectUrl)) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`oauth.clientRegistration \"cimd\" needs Client ID Metadata Documents that list the redirect URI ${redirectUrl}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tconst document = clientMetadataDocument(serverUrl, redirectUrl, metadata, documents.baseUrl);\n\t\t\t\t\tif (!document && settings.clientRegistration === \"cimd\") {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t'The authorization server does not support Client ID Metadata Documents for public clients; remove oauth.clientRegistration \"cimd\"',\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn document;\n\t\t\t\t}\n\t\t\t: undefined,\n\t\tclientId: settings.clientId,\n\t\tclientSecret: settings.clientSecret,\n\t\tstore: options.store,\n\t\tonRedirect,\n\t});\n}\n\n/**\n * Whether the client may identify with a Client ID Metadata Document instead of registering. `auto`\n * registers when the user asked for a client name or the documents do not list the redirect URI.\n */\nexport function offersClientMetadataDocument(\n\tsettings: McpOAuthSettings,\n\tdocuments: McpClientMetadataDocuments | undefined,\n\tredirectUrl: string,\n): boolean {\n\tconst registration = settings.clientRegistration ?? \"auto\";\n\tif (registration !== \"auto\") return registration === \"cimd\";\n\treturn !settings.clientId && !settings.clientName && documents?.listsRedirectUrl(redirectUrl) === true;\n}\n\n/**\n * The Client ID Metadata Document to use, chosen like Codex chooses its own, or `undefined` when the\n * authorization server does not support documents for public clients. Without the `iss` parameter in\n * authorization responses (RFC 9207), the redirect URI and the document are specific to the MCP server,\n * so a response cannot be mixed up with one from another authorization server (RFC 9700 section 4.4.2.2).\n */\nfunction clientMetadataDocument(\n\tserverUrl: string,\n\tredirectUrl: string,\n\tmetadata: AuthorizationServerMetadata | undefined,\n\tbaseUrl: string,\n): OAuthClientMetadataDocument | undefined {\n\tif (\n\t\t!metadata?.client_id_metadata_document_supported ||\n\t\t!metadata.token_endpoint_auth_methods_supported?.includes(\"none\")\n\t) {\n\t\treturn undefined;\n\t}\n\tif (metadata.authorization_response_iss_parameter_supported) return { url: `${baseUrl}/client.json`, redirectUrl };\n\tconst redirect = new URL(redirectUrl);\n\tredirect.pathname = serverSpecificPath(redirect.pathname, serverUrl);\n\treturn { url: `${baseUrl}/${callbackId(serverUrl)}/client.json`, redirectUrl: redirect.href };\n}\n\n/** The path of the redirect URI of a server-specific Client ID Metadata Document: `<path>/<callback ID>`. */\nexport function serverSpecificPath(path: string, serverUrl: string): string {\n\treturn `${path.replace(/\\/$/, \"\")}/${callbackId(serverUrl)}`;\n}\n\n/** 12 characters identifying an MCP server URL in callback paths, computed like Codex does. */\nfunction callbackId(serverUrl: string): string {\n\tconst url = new URL(serverUrl);\n\turl.hash = \"\";\n\treturn createHash(\"sha256\").update(url.href).digest().subarray(0, 9).toString(\"base64url\");\n}\n\n/** Redirect URIs a stored client was registered with. */\nexport function registeredRedirectUrls(client: OAuthClientInformationMixed | undefined): string[] {\n\treturn client && \"redirect_uris\" in client ? client.redirect_uris : [];\n}\n\n/**\n * Bounds each request to the authorization server, so an unresponsive one cannot hold the refresh lock,\n * delay shutdown, or keep a sign-in waiting for long.\n */\nconst OAUTH_REQUEST_TIMEOUT_MS = 15_000;\n\n/** `fetch` with `OAUTH_REQUEST_TIMEOUT_MS` per request, on top of the request's own signal. */\nexport function timedFetch(fetch: McpFetch = globalThis.fetch): McpFetch {\n\treturn (input, init) => {\n\t\tconst timeout = AbortSignal.timeout(OAUTH_REQUEST_TIMEOUT_MS);\n\t\treturn fetch(input, { ...init, signal: init?.signal ? AbortSignal.any([init.signal, timeout]) : timeout });\n\t};\n}\n\nconst CALLBACK_HOST = \"127.0.0.1\";\nconst CALLBACK_PATH = \"/callback\";\n\n/** Redirect URI when the settings name none and no client is stored. */\nexport const DEFAULT_REDIRECT_URL = `http://${CALLBACK_HOST}${CALLBACK_PATH}`;\n\n/** Where the loopback callback server listens and the redirect URI it serves, from `callbackUrl` and `callbackPort`. */\nexport interface LoopbackSettings {\n\t/** The redirect URI, without the port unless one is configured. */\n\turl: string;\n\t/** Address to listen on. */\n\thost: string;\n\t/** Host name in the redirect URI. */\n\tredirectHost: string;\n\tport: number | undefined;\n\tpath: string;\n\t/** The exact redirect URI, when the port is fixed. */\n\tfixedRedirectUrl: string | undefined;\n}\n\n/** The loopback callback settings of `settings`. */\nexport function loopbackSettings(settings: McpOAuthSettings): LoopbackSettings {\n\tconst configured = settings.callbackUrl ?? DEFAULT_REDIRECT_URL;\n\tconst url = new URL(configured);\n\tconst address = url.hostname.replace(/^\\[|\\]$/g, \"\");\n\tconst port = url.port ? Number(url.port) : settings.callbackPort;\n\tlet fixedRedirectUrl: string | undefined;\n\t// A configured URI with a port is sent exactly as written, since servers compare it as a string.\n\tif (url.port) fixedRedirectUrl = settings.callbackUrl;\n\telse if (port !== undefined) {\n\t\turl.port = String(port);\n\t\tfixedRedirectUrl = url.href;\n\t}\n\treturn {\n\t\turl: configured,\n\t\t// `localhost` is served on 127.0.0.1; browsers fall back to it when ::1 refuses.\n\t\thost: address === \"localhost\" ? CALLBACK_HOST : address,\n\t\tredirectHost: address,\n\t\tport,\n\t\tpath: url.pathname,\n\t\tfixedRedirectUrl,\n\t};\n}\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { McpFetch } from "../auth-provider.ts";
|
|
2
|
+
import { type AuthorizationServerMetadata, type OAuthChallenge, type OAuthProtectedResourceMetadata, type OAuthServerInfo } from "./types.ts";
|
|
3
|
+
export declare function parseWwwAuthenticate(header: string | null): OAuthChallenge;
|
|
4
|
+
export declare function discoverProtectedResourceMetadata(serverUrl: string | URL, options?: {
|
|
5
|
+
resourceMetadataUrl?: string | URL;
|
|
6
|
+
protocolVersion?: string;
|
|
7
|
+
fetch?: McpFetch;
|
|
8
|
+
signal?: AbortSignal;
|
|
9
|
+
}): Promise<OAuthProtectedResourceMetadata>;
|
|
10
|
+
export declare function buildAuthorizationServerDiscoveryUrls(authorizationServerUrl: string | URL): {
|
|
11
|
+
url: URL;
|
|
12
|
+
type: "oauth" | "oidc";
|
|
13
|
+
}[];
|
|
14
|
+
export declare function discoverAuthorizationServerMetadata(authorizationServerUrl: string | URL, options?: {
|
|
15
|
+
fetch?: McpFetch;
|
|
16
|
+
protocolVersion?: string;
|
|
17
|
+
skipIssuerValidation?: boolean;
|
|
18
|
+
signal?: AbortSignal;
|
|
19
|
+
}): Promise<AuthorizationServerMetadata | undefined>;
|
|
20
|
+
export declare function discoverOAuthServerInfo(serverUrl: string | URL, options?: {
|
|
21
|
+
resourceMetadataUrl?: URL;
|
|
22
|
+
/** Metadata document to use instead of discovery. It is trusted as configured, so its issuer is not checked. */
|
|
23
|
+
authorizationServerMetadataUrl?: URL;
|
|
24
|
+
fetch?: McpFetch;
|
|
25
|
+
skipIssuerValidation?: boolean;
|
|
26
|
+
signal?: AbortSignal;
|
|
27
|
+
}): Promise<OAuthServerInfo>;
|
|
28
|
+
export declare function resourceUrlFromServerUrl(value: string | URL): URL;
|
|
29
|
+
export declare function selectResource(serverUrl: string | URL, metadata?: OAuthProtectedResourceMetadata): string | undefined;
|
|
30
|
+
//# sourceMappingURL=discovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../src/oauth/discovery.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,EACN,KAAK,2BAA2B,EAChC,KAAK,cAAc,EACnB,KAAK,8BAA8B,EACnC,KAAK,eAAe,EAGpB,MAAM,YAAY,CAAC;AAsBpB,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,cAAc,CAiB1E;AAcD,wBAAsB,iCAAiC,CACtD,SAAS,EAAE,MAAM,GAAG,GAAG,EACvB,OAAO,GAAE;IACR,mBAAmB,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;IACnC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,MAAM,CAAC,EAAE,WAAW,CAAC;CAChB,GACJ,OAAO,CAAC,8BAA8B,CAAC,CA0BzC;AAED,wBAAgB,qCAAqC,CACpD,sBAAsB,EAAE,MAAM,GAAG,GAAG,GAClC;IAAE,GAAG,EAAE,GAAG,CAAC;IAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAAA;CAAE,EAAE,CASxC;AAED,wBAAsB,mCAAmC,CACxD,sBAAsB,EAAE,MAAM,GAAG,GAAG,EACpC,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,QAAQ,CAAC;IAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAAC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,WAAW,CAAA;CAAO,GAChH,OAAO,CAAC,2BAA2B,GAAG,SAAS,CAAC,CAwBlD;AAED,wBAAsB,uBAAuB,CAC5C,SAAS,EAAE,MAAM,GAAG,GAAG,EACvB,OAAO,GAAE;IACR,mBAAmB,CAAC,EAAE,GAAG,CAAC;IAC1B,gHAAgH;IAChH,8BAA8B,CAAC,EAAE,GAAG,CAAC;IACrC,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,MAAM,CAAC,EAAE,WAAW,CAAC;CAChB,GACJ,OAAO,CAAC,eAAe,CAAC,CAoC1B;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,GAAG,GAAG,CAIjE;AAED,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,GAAG,EAAE,QAAQ,CAAC,EAAE,8BAA8B,GAAG,MAAM,GAAG,SAAS,CAarH"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Adapted from modelcontextprotocol/typescript-sdk v1.29.0 src/client/auth.ts.
|
|
3
|
+
* Copyright (c) 2024 Anthropic, PBC. Licensed under MIT; see THIRD_PARTY_NOTICES/.
|
|
4
|
+
* Modified to remove Zod/CORS shims and enforce authorization-server issuer validation.
|
|
5
|
+
*/
|
|
6
|
+
import { LATEST_PROTOCOL_VERSION } from "../protocol/types.js";
|
|
7
|
+
import { OAuthIssuerMismatchError } from "./errors.js";
|
|
8
|
+
import { parseAuthorizationServerMetadata, parseProtectedResourceMetadata, } from "./types.js";
|
|
9
|
+
function discard(response) {
|
|
10
|
+
void response?.body?.cancel().catch(() => { });
|
|
11
|
+
}
|
|
12
|
+
/** 4xx and 502 mean "not here", so discovery tries the next candidate URL. */
|
|
13
|
+
function isDiscoveryMiss(status) {
|
|
14
|
+
return (status >= 400 && status < 500) || status === 502;
|
|
15
|
+
}
|
|
16
|
+
/** Path suffix for `/.well-known/<kind><path>`; empty for the root path. */
|
|
17
|
+
function pathSuffix(pathname) {
|
|
18
|
+
return pathname.endsWith("/") ? pathname.slice(0, -1) : pathname;
|
|
19
|
+
}
|
|
20
|
+
function field(header, name) {
|
|
21
|
+
const match = header.match(new RegExp(String.raw `(?:^|[,\s])${name}=(?:"([^"]*)"|([^\s,]+))`, "i"));
|
|
22
|
+
// An empty value (`scope=""`) carries no information, so it counts as absent.
|
|
23
|
+
return match?.[1] || match?.[2] || undefined;
|
|
24
|
+
}
|
|
25
|
+
export function parseWwwAuthenticate(header) {
|
|
26
|
+
if (!header)
|
|
27
|
+
return {};
|
|
28
|
+
const scheme = header.trimStart().split(/\s+/, 1)[0]?.toLowerCase();
|
|
29
|
+
if (scheme !== "bearer" && scheme !== "dpop")
|
|
30
|
+
return {};
|
|
31
|
+
const resourceMetadata = field(header, "resource_metadata");
|
|
32
|
+
let resourceMetadataUrl;
|
|
33
|
+
if (resourceMetadata) {
|
|
34
|
+
try {
|
|
35
|
+
resourceMetadataUrl = new URL(resourceMetadata);
|
|
36
|
+
}
|
|
37
|
+
catch { }
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
resourceMetadataUrl,
|
|
41
|
+
scope: field(header, "scope"),
|
|
42
|
+
error: field(header, "error"),
|
|
43
|
+
errorDescription: field(header, "error_description"),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
async function fetchMetadata(url, fetch, protocolVersion, signal) {
|
|
47
|
+
return fetch(url, {
|
|
48
|
+
headers: { Accept: "application/json", "MCP-Protocol-Version": protocolVersion },
|
|
49
|
+
signal,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
export async function discoverProtectedResourceMetadata(serverUrl, options = {}) {
|
|
53
|
+
const server = new URL(serverUrl);
|
|
54
|
+
const fetch = options.fetch ?? globalThis.fetch;
|
|
55
|
+
const version = options.protocolVersion ?? LATEST_PROTOCOL_VERSION;
|
|
56
|
+
let response = await fetchMetadata(options.resourceMetadataUrl
|
|
57
|
+
? new URL(options.resourceMetadataUrl)
|
|
58
|
+
: new URL(`/.well-known/oauth-protected-resource${pathSuffix(server.pathname)}`, server.origin), fetch, version, options.signal);
|
|
59
|
+
if (!options.resourceMetadataUrl && server.pathname !== "/" && isDiscoveryMiss(response.status)) {
|
|
60
|
+
discard(response);
|
|
61
|
+
response = await fetchMetadata(new URL("/.well-known/oauth-protected-resource", server.origin), fetch, version, options.signal);
|
|
62
|
+
}
|
|
63
|
+
if (!response.ok) {
|
|
64
|
+
discard(response);
|
|
65
|
+
throw new Error(`HTTP ${response.status} loading OAuth protected resource metadata`);
|
|
66
|
+
}
|
|
67
|
+
return parseProtectedResourceMetadata(await response.json());
|
|
68
|
+
}
|
|
69
|
+
export function buildAuthorizationServerDiscoveryUrls(authorizationServerUrl) {
|
|
70
|
+
const issuer = new URL(authorizationServerUrl);
|
|
71
|
+
const path = pathSuffix(issuer.pathname);
|
|
72
|
+
const urls = [
|
|
73
|
+
{ url: new URL(`/.well-known/oauth-authorization-server${path}`, issuer.origin), type: "oauth" },
|
|
74
|
+
{ url: new URL(`/.well-known/openid-configuration${path}`, issuer.origin), type: "oidc" },
|
|
75
|
+
];
|
|
76
|
+
if (path)
|
|
77
|
+
urls.push({ url: new URL(`${path}/.well-known/openid-configuration`, issuer.origin), type: "oidc" });
|
|
78
|
+
return urls;
|
|
79
|
+
}
|
|
80
|
+
export async function discoverAuthorizationServerMetadata(authorizationServerUrl, options = {}) {
|
|
81
|
+
const fetch = options.fetch ?? globalThis.fetch;
|
|
82
|
+
for (const { url } of buildAuthorizationServerDiscoveryUrls(authorizationServerUrl)) {
|
|
83
|
+
const response = await fetchMetadata(url, fetch, options.protocolVersion ?? LATEST_PROTOCOL_VERSION, options.signal);
|
|
84
|
+
if (!response.ok) {
|
|
85
|
+
discard(response);
|
|
86
|
+
if (isDiscoveryMiss(response.status))
|
|
87
|
+
continue;
|
|
88
|
+
throw new Error(`HTTP ${response.status} loading authorization server metadata from ${url}`);
|
|
89
|
+
}
|
|
90
|
+
const metadata = parseAuthorizationServerMetadata(await response.json());
|
|
91
|
+
if (!options.skipIssuerValidation) {
|
|
92
|
+
const expected = String(authorizationServerUrl);
|
|
93
|
+
// URL parsing adds a trailing slash to bare origins, so compare without one on either side.
|
|
94
|
+
const trim = (value) => (value.endsWith("/") ? value.slice(0, -1) : value);
|
|
95
|
+
if (trim(metadata.issuer) !== trim(expected))
|
|
96
|
+
throw new OAuthIssuerMismatchError(expected, metadata.issuer);
|
|
97
|
+
}
|
|
98
|
+
return metadata;
|
|
99
|
+
}
|
|
100
|
+
return undefined;
|
|
101
|
+
}
|
|
102
|
+
export async function discoverOAuthServerInfo(serverUrl, options = {}) {
|
|
103
|
+
let resourceMetadata;
|
|
104
|
+
try {
|
|
105
|
+
resourceMetadata = await discoverProtectedResourceMetadata(serverUrl, {
|
|
106
|
+
resourceMetadataUrl: options.resourceMetadataUrl,
|
|
107
|
+
fetch: options.fetch,
|
|
108
|
+
signal: options.signal,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
if (error instanceof TypeError)
|
|
113
|
+
throw error;
|
|
114
|
+
}
|
|
115
|
+
if (options.authorizationServerMetadataUrl) {
|
|
116
|
+
const url = options.authorizationServerMetadataUrl;
|
|
117
|
+
const response = await fetchMetadata(url, options.fetch ?? globalThis.fetch, LATEST_PROTOCOL_VERSION, options.signal);
|
|
118
|
+
if (!response.ok) {
|
|
119
|
+
discard(response);
|
|
120
|
+
throw new Error(`HTTP ${response.status} loading authorization server metadata from ${url}`);
|
|
121
|
+
}
|
|
122
|
+
const metadata = parseAuthorizationServerMetadata(await response.json());
|
|
123
|
+
return { authorizationServerUrl: metadata.issuer, authorizationServerMetadata: metadata, resourceMetadata };
|
|
124
|
+
}
|
|
125
|
+
const authorizationServerUrl = resourceMetadata?.authorization_servers?.[0] ?? String(new URL("/", serverUrl));
|
|
126
|
+
return {
|
|
127
|
+
authorizationServerUrl,
|
|
128
|
+
authorizationServerMetadata: await discoverAuthorizationServerMetadata(authorizationServerUrl, {
|
|
129
|
+
fetch: options.fetch,
|
|
130
|
+
skipIssuerValidation: options.skipIssuerValidation,
|
|
131
|
+
signal: options.signal,
|
|
132
|
+
}),
|
|
133
|
+
resourceMetadata,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
export function resourceUrlFromServerUrl(value) {
|
|
137
|
+
const url = new URL(value);
|
|
138
|
+
url.hash = "";
|
|
139
|
+
return url;
|
|
140
|
+
}
|
|
141
|
+
export function selectResource(serverUrl, metadata) {
|
|
142
|
+
if (!metadata)
|
|
143
|
+
return undefined;
|
|
144
|
+
const requested = resourceUrlFromServerUrl(serverUrl);
|
|
145
|
+
const configured = new URL(metadata.resource);
|
|
146
|
+
if (requested.origin !== configured.origin) {
|
|
147
|
+
throw new Error(`Protected resource ${metadata.resource} does not match MCP server ${requested}`);
|
|
148
|
+
}
|
|
149
|
+
const requestedPath = requested.pathname.endsWith("/") ? requested.pathname : `${requested.pathname}/`;
|
|
150
|
+
const configuredPath = configured.pathname.endsWith("/") ? configured.pathname : `${configured.pathname}/`;
|
|
151
|
+
if (!requestedPath.startsWith(configuredPath)) {
|
|
152
|
+
throw new Error(`Protected resource ${metadata.resource} does not match MCP server ${requested}`);
|
|
153
|
+
}
|
|
154
|
+
return metadata.resource;
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=discovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery.js","sourceRoot":"","sources":["../../src/oauth/discovery.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAKN,gCAAgC,EAChC,8BAA8B,GAC9B,MAAM,YAAY,CAAC;AAEpB,SAAS,OAAO,CAAC,QAA8B;IAC9C,KAAK,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;AAC/C,CAAC;AAED,8EAA8E;A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n * Copyright (c) 2024 Anthropic, PBC. Licensed under MIT; see THIRD_PARTY_NOTICES/.\n * Modified to remove Zod/CORS shims and enforce authorization-server issuer validation.\n */\n\nimport type { McpFetch } from \"../auth-provider.ts\";\nimport { LATEST_PROTOCOL_VERSION } from \"../protocol/types.ts\";\nimport { OAuthIssuerMismatchError } from \"./errors.ts\";\nimport {\n\ttype AuthorizationServerMetadata,\n\ttype OAuthChallenge,\n\ttype OAuthProtectedResourceMetadata,\n\ttype OAuthServerInfo,\n\tparseAuthorizationServerMetadata,\n\tparseProtectedResourceMetadata,\n} from \"./types.ts\";\n\nfunction discard(response: Response | undefined): void {\n\tvoid response?.body?.cancel().catch(() => {});\n}\n\n/** 4xx and 502 mean \"not here\", so discovery tries the next candidate URL. */\nfunction isDiscoveryMiss(status: number): boolean {\n\treturn (status >= 400 && status < 500) || status === 502;\n}\n\n/** Path suffix for `/.well-known/<kind><path>`; empty for the root path. */\nfunction pathSuffix(pathname: string): string {\n\treturn pathname.endsWith(\"/\") ? pathname.slice(0, -1) : pathname;\n}\n\nfunction field(header: string, name: string): string | undefined {\n\tconst match = header.match(new RegExp(String.raw`(?:^|[,\\s])${name}=(?:\"([^\"]*)\"|([^\\s,]+))`, \"i\"));\n\t// An empty value (`scope=\"\"`) carries no information, so it counts as absent.\n\treturn match?.[1] || match?.[2] || undefined;\n}\n\nexport function parseWwwAuthenticate(header: string | null): OAuthChallenge {\n\tif (!header) return {};\n\tconst scheme = header.trimStart().split(/\\s+/, 1)[0]?.toLowerCase();\n\tif (scheme !== \"bearer\" && scheme !== \"dpop\") return {};\n\tconst resourceMetadata = field(header, \"resource_metadata\");\n\tlet resourceMetadataUrl: URL | undefined;\n\tif (resourceMetadata) {\n\t\ttry {\n\t\t\tresourceMetadataUrl = new URL(resourceMetadata);\n\t\t} catch {}\n\t}\n\treturn {\n\t\tresourceMetadataUrl,\n\t\tscope: field(header, \"scope\"),\n\t\terror: field(header, \"error\"),\n\t\terrorDescription: field(header, \"error_description\"),\n\t};\n}\n\nasync function fetchMetadata(\n\turl: URL,\n\tfetch: McpFetch,\n\tprotocolVersion: string,\n\tsignal: AbortSignal | undefined,\n): Promise<Response> {\n\treturn fetch(url, {\n\t\theaders: { Accept: \"application/json\", \"MCP-Protocol-Version\": protocolVersion },\n\t\tsignal,\n\t});\n}\n\nexport async function discoverProtectedResourceMetadata(\n\tserverUrl: string | URL,\n\toptions: {\n\t\tresourceMetadataUrl?: string | URL;\n\t\tprotocolVersion?: string;\n\t\tfetch?: McpFetch;\n\t\tsignal?: AbortSignal;\n\t} = {},\n): Promise<OAuthProtectedResourceMetadata> {\n\tconst server = new URL(serverUrl);\n\tconst fetch = options.fetch ?? globalThis.fetch;\n\tconst version = options.protocolVersion ?? LATEST_PROTOCOL_VERSION;\n\tlet response = await fetchMetadata(\n\t\toptions.resourceMetadataUrl\n\t\t\t? new URL(options.resourceMetadataUrl)\n\t\t\t: new URL(`/.well-known/oauth-protected-resource${pathSuffix(server.pathname)}`, server.origin),\n\t\tfetch,\n\t\tversion,\n\t\toptions.signal,\n\t);\n\tif (!options.resourceMetadataUrl && server.pathname !== \"/\" && isDiscoveryMiss(response.status)) {\n\t\tdiscard(response);\n\t\tresponse = await fetchMetadata(\n\t\t\tnew URL(\"/.well-known/oauth-protected-resource\", server.origin),\n\t\t\tfetch,\n\t\t\tversion,\n\t\t\toptions.signal,\n\t\t);\n\t}\n\tif (!response.ok) {\n\t\tdiscard(response);\n\t\tthrow new Error(`HTTP ${response.status} loading OAuth protected resource metadata`);\n\t}\n\treturn parseProtectedResourceMetadata(await response.json());\n}\n\nexport function buildAuthorizationServerDiscoveryUrls(\n\tauthorizationServerUrl: string | URL,\n): { url: URL; type: \"oauth\" | \"oidc\" }[] {\n\tconst issuer = new URL(authorizationServerUrl);\n\tconst path = pathSuffix(issuer.pathname);\n\tconst urls: { url: URL; type: \"oauth\" | \"oidc\" }[] = [\n\t\t{ url: new URL(`/.well-known/oauth-authorization-server${path}`, issuer.origin), type: \"oauth\" },\n\t\t{ url: new URL(`/.well-known/openid-configuration${path}`, issuer.origin), type: \"oidc\" },\n\t];\n\tif (path) urls.push({ url: new URL(`${path}/.well-known/openid-configuration`, issuer.origin), type: \"oidc\" });\n\treturn urls;\n}\n\nexport async function discoverAuthorizationServerMetadata(\n\tauthorizationServerUrl: string | URL,\n\toptions: { fetch?: McpFetch; protocolVersion?: string; skipIssuerValidation?: boolean; signal?: AbortSignal } = {},\n): Promise<AuthorizationServerMetadata | undefined> {\n\tconst fetch = options.fetch ?? globalThis.fetch;\n\tfor (const { url } of buildAuthorizationServerDiscoveryUrls(authorizationServerUrl)) {\n\t\tconst response = await fetchMetadata(\n\t\t\turl,\n\t\t\tfetch,\n\t\t\toptions.protocolVersion ?? LATEST_PROTOCOL_VERSION,\n\t\t\toptions.signal,\n\t\t);\n\t\tif (!response.ok) {\n\t\t\tdiscard(response);\n\t\t\tif (isDiscoveryMiss(response.status)) continue;\n\t\t\tthrow new Error(`HTTP ${response.status} loading authorization server metadata from ${url}`);\n\t\t}\n\t\tconst metadata = parseAuthorizationServerMetadata(await response.json());\n\t\tif (!options.skipIssuerValidation) {\n\t\t\tconst expected = String(authorizationServerUrl);\n\t\t\t// URL parsing adds a trailing slash to bare origins, so compare without one on either side.\n\t\t\tconst trim = (value: string) => (value.endsWith(\"/\") ? value.slice(0, -1) : value);\n\t\t\tif (trim(metadata.issuer) !== trim(expected)) throw new OAuthIssuerMismatchError(expected, metadata.issuer);\n\t\t}\n\t\treturn metadata;\n\t}\n\treturn undefined;\n}\n\nexport async function discoverOAuthServerInfo(\n\tserverUrl: string | URL,\n\toptions: {\n\t\tresourceMetadataUrl?: URL;\n\t\t/** Metadata document to use instead of discovery. It is trusted as configured, so its issuer is not checked. */\n\t\tauthorizationServerMetadataUrl?: URL;\n\t\tfetch?: McpFetch;\n\t\tskipIssuerValidation?: boolean;\n\t\tsignal?: AbortSignal;\n\t} = {},\n): Promise<OAuthServerInfo> {\n\tlet resourceMetadata: OAuthProtectedResourceMetadata | undefined;\n\ttry {\n\t\tresourceMetadata = await discoverProtectedResourceMetadata(serverUrl, {\n\t\t\tresourceMetadataUrl: options.resourceMetadataUrl,\n\t\t\tfetch: options.fetch,\n\t\t\tsignal: options.signal,\n\t\t});\n\t} catch (error) {\n\t\tif (error instanceof TypeError) throw error;\n\t}\n\tif (options.authorizationServerMetadataUrl) {\n\t\tconst url = options.authorizationServerMetadataUrl;\n\t\tconst response = await fetchMetadata(\n\t\t\turl,\n\t\t\toptions.fetch ?? globalThis.fetch,\n\t\t\tLATEST_PROTOCOL_VERSION,\n\t\t\toptions.signal,\n\t\t);\n\t\tif (!response.ok) {\n\t\t\tdiscard(response);\n\t\t\tthrow new Error(`HTTP ${response.status} loading authorization server metadata from ${url}`);\n\t\t}\n\t\tconst metadata = parseAuthorizationServerMetadata(await response.json());\n\t\treturn { authorizationServerUrl: metadata.issuer, authorizationServerMetadata: metadata, resourceMetadata };\n\t}\n\tconst authorizationServerUrl = resourceMetadata?.authorization_servers?.[0] ?? String(new URL(\"/\", serverUrl));\n\treturn {\n\t\tauthorizationServerUrl,\n\t\tauthorizationServerMetadata: await discoverAuthorizationServerMetadata(authorizationServerUrl, {\n\t\t\tfetch: options.fetch,\n\t\t\tskipIssuerValidation: options.skipIssuerValidation,\n\t\t\tsignal: options.signal,\n\t\t}),\n\t\tresourceMetadata,\n\t};\n}\n\nexport function resourceUrlFromServerUrl(value: string | URL): URL {\n\tconst url = new URL(value);\n\turl.hash = \"\";\n\treturn url;\n}\n\nexport function selectResource(serverUrl: string | URL, metadata?: OAuthProtectedResourceMetadata): string | undefined {\n\tif (!metadata) return undefined;\n\tconst requested = resourceUrlFromServerUrl(serverUrl);\n\tconst configured = new URL(metadata.resource);\n\tif (requested.origin !== configured.origin) {\n\t\tthrow new Error(`Protected resource ${metadata.resource} does not match MCP server ${requested}`);\n\t}\n\tconst requestedPath = requested.pathname.endsWith(\"/\") ? requested.pathname : `${requested.pathname}/`;\n\tconst configuredPath = configured.pathname.endsWith(\"/\") ? configured.pathname : `${configured.pathname}/`;\n\tif (!requestedPath.startsWith(configuredPath)) {\n\t\tthrow new Error(`Protected resource ${metadata.resource} does not match MCP server ${requested}`);\n\t}\n\treturn metadata.resource;\n}\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export declare class OAuthError extends Error {
|
|
2
|
+
readonly code: string;
|
|
3
|
+
readonly errorUri: string | undefined;
|
|
4
|
+
constructor(code: string, message: string, errorUri?: string);
|
|
5
|
+
}
|
|
6
|
+
export declare class OAuthIssuerMismatchError extends Error {
|
|
7
|
+
/** `undefined` when no authorization server metadata was discovered. */
|
|
8
|
+
readonly expected: string | undefined;
|
|
9
|
+
/** `undefined` when an authorization response lacks the `iss` parameter its server promised (RFC 9207). */
|
|
10
|
+
readonly received: string | undefined;
|
|
11
|
+
constructor(expected: string | undefined, received: string | undefined);
|
|
12
|
+
}
|
|
13
|
+
export declare class OAuthInsecureEndpointError extends Error {
|
|
14
|
+
readonly endpoint: string;
|
|
15
|
+
constructor(endpoint: string);
|
|
16
|
+
}
|
|
17
|
+
export declare class OAuthRegistrationError extends Error {
|
|
18
|
+
readonly status: number;
|
|
19
|
+
readonly body: string;
|
|
20
|
+
constructor(status: number, body: string);
|
|
21
|
+
}
|
|
22
|
+
export declare class McpOAuthAuthorizationRequiredError extends Error {
|
|
23
|
+
constructor();
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Thrown by `McpOAuthServerStore.withRefreshLock()` when another process holds the refresh lock for the
|
|
27
|
+
* whole wait. `startMcpSignIn()` then skips the refresh and goes to the browser step.
|
|
28
|
+
*/
|
|
29
|
+
export declare class McpRefreshLockBusyError extends Error {
|
|
30
|
+
constructor();
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/oauth/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,UAAW,SAAQ,KAAK;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAEtC,YAAY,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAK3D;CACD;AAED,qBAAa,wBAAyB,SAAQ,KAAK;IAClD,wEAAwE;IACxE,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,2GAA2G;IAC3G,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAEtC,YAAY,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,EAMrE;CACD;AAED,qBAAa,0BAA2B,SAAQ,KAAK;IACpD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B,YAAY,QAAQ,EAAE,MAAM,EAI3B;CACD;AAED,qBAAa,sBAAuB,SAAQ,KAAK;IAChD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,YAAY,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAKvC;CACD;AAED,qBAAa,kCAAmC,SAAQ,KAAK;IAC5D,cAGC;CACD;AAED;;;GAGG;AACH,qBAAa,uBAAwB,SAAQ,KAAK;IACjD,cAGC;CACD"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export class OAuthError extends Error {
|
|
2
|
+
code;
|
|
3
|
+
errorUri;
|
|
4
|
+
constructor(code, message, errorUri) {
|
|
5
|
+
super(message || code);
|
|
6
|
+
this.name = "OAuthError";
|
|
7
|
+
this.code = code;
|
|
8
|
+
this.errorUri = errorUri;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export class OAuthIssuerMismatchError extends Error {
|
|
12
|
+
/** `undefined` when no authorization server metadata was discovered. */
|
|
13
|
+
expected;
|
|
14
|
+
/** `undefined` when an authorization response lacks the `iss` parameter its server promised (RFC 9207). */
|
|
15
|
+
received;
|
|
16
|
+
constructor(expected, received) {
|
|
17
|
+
const format = (issuer) => (issuer === undefined ? "none" : JSON.stringify(issuer));
|
|
18
|
+
super(`OAuth issuer mismatch: expected ${format(expected)}, received ${format(received)}`);
|
|
19
|
+
this.name = "OAuthIssuerMismatchError";
|
|
20
|
+
this.expected = expected;
|
|
21
|
+
this.received = received;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export class OAuthInsecureEndpointError extends Error {
|
|
25
|
+
endpoint;
|
|
26
|
+
constructor(endpoint) {
|
|
27
|
+
super(`Refusing to send OAuth credentials to non-HTTPS endpoint ${endpoint}`);
|
|
28
|
+
this.name = "OAuthInsecureEndpointError";
|
|
29
|
+
this.endpoint = endpoint;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export class OAuthRegistrationError extends Error {
|
|
33
|
+
status;
|
|
34
|
+
body;
|
|
35
|
+
constructor(status, body) {
|
|
36
|
+
super(`OAuth dynamic client registration failed with status ${status}: ${body}`);
|
|
37
|
+
this.name = "OAuthRegistrationError";
|
|
38
|
+
this.status = status;
|
|
39
|
+
this.body = body;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export class McpOAuthAuthorizationRequiredError extends Error {
|
|
43
|
+
constructor() {
|
|
44
|
+
super("MCP OAuth authorization requires user interaction");
|
|
45
|
+
this.name = "McpOAuthAuthorizationRequiredError";
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Thrown by `McpOAuthServerStore.withRefreshLock()` when another process holds the refresh lock for the
|
|
50
|
+
* whole wait. `startMcpSignIn()` then skips the refresh and goes to the browser step.
|
|
51
|
+
*/
|
|
52
|
+
export class McpRefreshLockBusyError extends Error {
|
|
53
|
+
constructor() {
|
|
54
|
+
super("Another process is refreshing the MCP server's tokens");
|
|
55
|
+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G,4BAA4B,CAAC;QACzC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC1B,CAAC;CACD;AAED,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IACvC,MAAM,CAAS;IACf,IAAI,CAAS;IAEtB,YAAY,MAAc,EAAE,IAAY;QACvC,KAAK,CAAC,wDAAwD,MAAM,KAAK,IAAI,EAAE,CAAC,CAAC;QACjF,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;QACrC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAClB,CAAC;CACD;AAED,MAAM,OAAO,kCAAmC,SAAQ,KAAK;IAC5D;QACC,KAAK,CAAC,mDAAmD,CAAC,CAAC;QAC3D,IAAI,CAAC,IAAI,GAAG,oCAAoC,CAAC;IAClD,CAAC;CACD;AAED;;;GAGG;AACH,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IACjD;QACC,KAAK,CAAC,uDAAuD,CAAC,CAAC;QAC/D,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;IACvC,CAAC;CACD","sourcesContent":["export class OAuthError extends Error {\n\treadonly code: string;\n\treadonly errorUri: string | undefined;\n\n\tconstructor(code: string, message: string, errorUri?: string) {\n\t\tsuper(message || code);\n\t\tthis.name = \"OAuthError\";\n\t\tthis.code = code;\n\t\tthis.errorUri = errorUri;\n\t}\n}\n\nexport class OAuthIssuerMismatchError extends Error {\n\t/** `undefined` when no authorization server metadata was discovered. */\n\treadonly expected: string | undefined;\n\t/** `undefined` when an authorization response lacks the `iss` parameter its server promised (RFC 9207). */\n\treadonly received: string | undefined;\n\n\tconstructor(expected: string | undefined, received: string | undefined) {\n\t\tconst format = (issuer: string | undefined) => (issuer === undefined ? \"none\" : JSON.stringify(issuer));\n\t\tsuper(`OAuth issuer mismatch: expected ${format(expected)}, received ${format(received)}`);\n\t\tthis.name = \"OAuthIssuerMismatchError\";\n\t\tthis.expected = expected;\n\t\tthis.received = received;\n\t}\n}\n\nexport class OAuthInsecureEndpointError extends Error {\n\treadonly endpoint: string;\n\n\tconstructor(endpoint: string) {\n\t\tsuper(`Refusing to send OAuth credentials to non-HTTPS endpoint ${endpoint}`);\n\t\tthis.name = \"OAuthInsecureEndpointError\";\n\t\tthis.endpoint = endpoint;\n\t}\n}\n\nexport class OAuthRegistrationError extends Error {\n\treadonly status: number;\n\treadonly body: string;\n\n\tconstructor(status: number, body: string) {\n\t\tsuper(`OAuth dynamic client registration failed with status ${status}: ${body}`);\n\t\tthis.name = \"OAuthRegistrationError\";\n\t\tthis.status = status;\n\t\tthis.body = body;\n\t}\n}\n\nexport class McpOAuthAuthorizationRequiredError extends Error {\n\tconstructor() {\n\t\tsuper(\"MCP OAuth authorization requires user interaction\");\n\t\tthis.name = \"McpOAuthAuthorizationRequiredError\";\n\t}\n}\n\n/**\n * Thrown by `McpOAuthServerStore.withRefreshLock()` when another process holds the refresh lock for the\n * whole wait. `startMcpSignIn()` then skips the refresh and goes to the browser step.\n */\nexport class McpRefreshLockBusyError extends Error {\n\tconstructor() {\n\t\tsuper(\"Another process is refreshing the MCP server's tokens\");\n\t\tthis.name = \"McpRefreshLockBusyError\";\n\t}\n}\n"]}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { AuthProvider, McpFetch } from "../auth-provider.ts";
|
|
2
|
+
import { type AuthorizationServerMetadata, type OAuthClientInformationFull, type OAuthClientInformationMixed, type OAuthClientMetadata, type OAuthDiscoveryState, type OAuthTokens } from "./types.ts";
|
|
3
|
+
export type AddClientAuthentication = (headers: Headers, params: URLSearchParams, url: string | URL, metadata?: AuthorizationServerMetadata) => void | Promise<void>;
|
|
4
|
+
/** A Client ID Metadata Document: an https URL used as `client_id`, and a redirect URI it lists. */
|
|
5
|
+
export interface OAuthClientMetadataDocument {
|
|
6
|
+
url: string;
|
|
7
|
+
redirectUrl: string;
|
|
8
|
+
}
|
|
9
|
+
export interface OAuthClientProvider {
|
|
10
|
+
readonly redirectUrl: string | URL;
|
|
11
|
+
readonly clientMetadata: OAuthClientMetadata;
|
|
12
|
+
/**
|
|
13
|
+
* Client ID Metadata Document to identify as instead of registering dynamically, or `undefined` to
|
|
14
|
+
* register. Called when no client information is stored; the document is not stored. `metadata` is
|
|
15
|
+
* `undefined` when the authorization server has none; check `client_id_metadata_document_supported`.
|
|
16
|
+
*/
|
|
17
|
+
clientMetadataDocument?(metadata: AuthorizationServerMetadata | undefined): OAuthClientMetadataDocument | undefined;
|
|
18
|
+
state?(): string | Promise<string>;
|
|
19
|
+
clientInformation(): OAuthClientInformationMixed | undefined | Promise<OAuthClientInformationMixed | undefined>;
|
|
20
|
+
saveClientInformation?(information: OAuthClientInformationMixed): void | Promise<void>;
|
|
21
|
+
tokens(): OAuthTokens | undefined | Promise<OAuthTokens | undefined>;
|
|
22
|
+
saveTokens(tokens: OAuthTokens): void | Promise<void>;
|
|
23
|
+
redirectToAuthorization(url: URL): void | Promise<void>;
|
|
24
|
+
saveCodeVerifier(verifier: string): void | Promise<void>;
|
|
25
|
+
codeVerifier(): string | Promise<string>;
|
|
26
|
+
addClientAuthentication?: AddClientAuthentication;
|
|
27
|
+
invalidateCredentials?(kind: "all" | "client" | "tokens" | "verifier" | "discovery"): void | Promise<void>;
|
|
28
|
+
saveDiscoveryState?(state: OAuthDiscoveryState): void | Promise<void>;
|
|
29
|
+
discoveryState?(): OAuthDiscoveryState | undefined | Promise<OAuthDiscoveryState | undefined>;
|
|
30
|
+
}
|
|
31
|
+
export interface OAuthFlowOptions {
|
|
32
|
+
serverUrl: string | URL;
|
|
33
|
+
authorizationCode?: string;
|
|
34
|
+
/** `iss` parameter of the authorization response that delivered `authorizationCode` (RFC 9207). */
|
|
35
|
+
iss?: string;
|
|
36
|
+
scope?: string;
|
|
37
|
+
resourceMetadataUrl?: URL;
|
|
38
|
+
/**
|
|
39
|
+
* Authorization server metadata document to use instead of discovery, for servers that advertise a
|
|
40
|
+
* wrong authorization server or none. It is trusted as configured. Must use https, except on loopback.
|
|
41
|
+
*/
|
|
42
|
+
authorizationServerMetadataUrl?: URL;
|
|
43
|
+
fetch?: McpFetch;
|
|
44
|
+
/** Aborts every request of the flow. Requests have no time limit of their own; combine with a timeout as needed. */
|
|
45
|
+
signal?: AbortSignal;
|
|
46
|
+
skipIssuerValidation?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Go straight to the authorization redirect instead of refreshing stored tokens, for example when the
|
|
49
|
+
* server asks for scopes the current grant lacks (a refresh keeps the old scope).
|
|
50
|
+
*/
|
|
51
|
+
skipRefresh?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Only refresh the stored tokens: return `REDIRECT` instead of registering a client or preparing an
|
|
54
|
+
* authorization request, so a pending authorization (its `state` and PKCE verifier) stays usable.
|
|
55
|
+
*/
|
|
56
|
+
refreshOnly?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* With `authorizationCode`: the redirect URI the authorization request used. The exchange fails before
|
|
59
|
+
* sending the code when the flow would send another one (RFC 6749 section 4.1.3 requires the same).
|
|
60
|
+
*/
|
|
61
|
+
authorizationRedirectUrl?: string;
|
|
62
|
+
}
|
|
63
|
+
export type OAuthFlowResult = "AUTHORIZED" | "REDIRECT";
|
|
64
|
+
export interface TokenRequestOptions {
|
|
65
|
+
metadata?: AuthorizationServerMetadata;
|
|
66
|
+
clientInformation: OAuthClientInformationMixed;
|
|
67
|
+
resource?: string;
|
|
68
|
+
addClientAuthentication?: AddClientAuthentication;
|
|
69
|
+
fetch?: McpFetch;
|
|
70
|
+
signal?: AbortSignal;
|
|
71
|
+
}
|
|
72
|
+
export declare function startAuthorization(authorizationServerUrl: string | URL, options: {
|
|
73
|
+
metadata?: AuthorizationServerMetadata;
|
|
74
|
+
clientInformation: OAuthClientInformationMixed;
|
|
75
|
+
redirectUrl: string | URL;
|
|
76
|
+
scope?: string;
|
|
77
|
+
state?: string;
|
|
78
|
+
resource?: string;
|
|
79
|
+
}): Promise<{
|
|
80
|
+
authorizationUrl: URL;
|
|
81
|
+
codeVerifier: string;
|
|
82
|
+
}>;
|
|
83
|
+
export declare function registerClient(authorizationServerUrl: string | URL, options: {
|
|
84
|
+
metadata?: AuthorizationServerMetadata;
|
|
85
|
+
clientMetadata: OAuthClientMetadata;
|
|
86
|
+
scope?: string;
|
|
87
|
+
fetch?: McpFetch;
|
|
88
|
+
signal?: AbortSignal;
|
|
89
|
+
}): Promise<OAuthClientInformationFull>;
|
|
90
|
+
export declare function exchangeAuthorizationCode(authorizationServerUrl: string | URL, options: TokenRequestOptions & {
|
|
91
|
+
code: string;
|
|
92
|
+
codeVerifier: string;
|
|
93
|
+
redirectUrl: string | URL;
|
|
94
|
+
}): Promise<OAuthTokens>;
|
|
95
|
+
export declare function refreshAuthorization(authorizationServerUrl: string | URL, options: TokenRequestOptions & {
|
|
96
|
+
refreshToken: string;
|
|
97
|
+
}): Promise<OAuthTokens>;
|
|
98
|
+
/**
|
|
99
|
+
* Scopes for a step-up authorization: the challenged scopes plus the ones granted so far, since a
|
|
100
|
+
* challenge may list only the missing scopes and a token with just those would lose access the old
|
|
101
|
+
* one had (SEP-2350). Without challenged scopes, `undefined` lets the flow pick its default.
|
|
102
|
+
*/
|
|
103
|
+
export declare function stepUpScope(granted: string | undefined, challenged: string | undefined): string | undefined;
|
|
104
|
+
export declare function authorizeMcp(provider: OAuthClientProvider, options: OAuthFlowOptions): Promise<OAuthFlowResult>;
|
|
105
|
+
/**
|
|
106
|
+
* Auth provider for `StreamableHttpTransport`. After a 401 it refreshes the tokens, or throws
|
|
107
|
+
* `McpOAuthAuthorizationRequiredError` when the user has to authorize (again). Concurrent 401s share
|
|
108
|
+
* one refresh, and a request whose token was already replaced is just retried: with rotating refresh
|
|
109
|
+
* tokens, a second refresh with the old refresh token would fail and discard the new grant.
|
|
110
|
+
*/
|
|
111
|
+
export declare function adaptOAuthProvider(provider: OAuthClientProvider): AuthProvider;
|
|
112
|
+
//# sourceMappingURL=flow.d.ts.map
|
|
@@ -0,0 +1 @@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