fastmcp 3.35.0 → 4.0.1

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/FastMCP.cjs CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
 
9
9
 
10
- var _chunkJP7QSER3cjs = require('./chunk-JP7QSER3.cjs');
10
+ var _chunkEXZZ3NKLcjs = require('./chunk-EXZZ3NKL.cjs');
11
11
 
12
12
 
13
13
 
@@ -20,7 +20,7 @@ var _chunkJP7QSER3cjs = require('./chunk-JP7QSER3.cjs');
20
20
 
21
21
 
22
22
 
23
- var _chunk7UDY4VFQcjs = require('./chunk-7UDY4VFQ.cjs');
23
+ var _chunkSSVFQCSNcjs = require('./chunk-SSVFQCSN.cjs');
24
24
 
25
25
 
26
26
 
@@ -41,5 +41,5 @@ var _chunk7UDY4VFQcjs = require('./chunk-7UDY4VFQ.cjs');
41
41
 
42
42
 
43
43
 
44
- exports.AuthProvider = _chunk7UDY4VFQcjs.AuthProvider; exports.AzureProvider = _chunk7UDY4VFQcjs.AzureProvider; exports.DiscoveryDocumentCache = _chunkJP7QSER3cjs.DiscoveryDocumentCache; exports.FastMCP = _chunkJP7QSER3cjs.FastMCP; exports.FastMCPSession = _chunkJP7QSER3cjs.FastMCPSession; exports.GitHubProvider = _chunk7UDY4VFQcjs.GitHubProvider; exports.GoogleProvider = _chunk7UDY4VFQcjs.GoogleProvider; exports.OAuthProvider = _chunk7UDY4VFQcjs.OAuthProvider; exports.ServerState = _chunkJP7QSER3cjs.ServerState; exports.UnexpectedStateError = _chunkJP7QSER3cjs.UnexpectedStateError; exports.UserError = _chunkJP7QSER3cjs.UserError; exports.audioContent = _chunkJP7QSER3cjs.audioContent; exports.getAuthSession = _chunk7UDY4VFQcjs.getAuthSession; exports.imageContent = _chunkJP7QSER3cjs.imageContent; exports.requireAll = _chunk7UDY4VFQcjs.requireAll; exports.requireAny = _chunk7UDY4VFQcjs.requireAny; exports.requireAuth = _chunk7UDY4VFQcjs.requireAuth; exports.requireRole = _chunk7UDY4VFQcjs.requireRole; exports.requireScopes = _chunk7UDY4VFQcjs.requireScopes;
44
+ exports.AuthProvider = _chunkSSVFQCSNcjs.AuthProvider; exports.AzureProvider = _chunkSSVFQCSNcjs.AzureProvider; exports.DiscoveryDocumentCache = _chunkEXZZ3NKLcjs.DiscoveryDocumentCache; exports.FastMCP = _chunkEXZZ3NKLcjs.FastMCP; exports.FastMCPSession = _chunkEXZZ3NKLcjs.FastMCPSession; exports.GitHubProvider = _chunkSSVFQCSNcjs.GitHubProvider; exports.GoogleProvider = _chunkSSVFQCSNcjs.GoogleProvider; exports.OAuthProvider = _chunkSSVFQCSNcjs.OAuthProvider; exports.ServerState = _chunkEXZZ3NKLcjs.ServerState; exports.UnexpectedStateError = _chunkEXZZ3NKLcjs.UnexpectedStateError; exports.UserError = _chunkEXZZ3NKLcjs.UserError; exports.audioContent = _chunkEXZZ3NKLcjs.audioContent; exports.getAuthSession = _chunkSSVFQCSNcjs.getAuthSession; exports.imageContent = _chunkEXZZ3NKLcjs.imageContent; exports.requireAll = _chunkSSVFQCSNcjs.requireAll; exports.requireAny = _chunkSSVFQCSNcjs.requireAny; exports.requireAuth = _chunkSSVFQCSNcjs.requireAuth; exports.requireRole = _chunkSSVFQCSNcjs.requireRole; exports.requireScopes = _chunkSSVFQCSNcjs.requireScopes;
45
45
  //# sourceMappingURL=FastMCP.cjs.map
@@ -10,8 +10,8 @@ import { Hono } from 'hono';
10
10
  import http from 'http';
11
11
  import { StrictEventEmitter } from 'strict-event-emitter-types';
12
12
  import { z } from 'zod';
13
- import { A as AuthProvider, O as OAuthSession, a as OAuthProxy } from './OAuthProvider-R8buLRa8.cjs';
14
- export { j as AuthProviderConfig, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, d as OAuthProvider, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from './OAuthProvider-R8buLRa8.cjs';
13
+ import { A as AuthProvider, O as OAuthSession, a as OAuthProxy } from './OAuthProvider-BV6EpF_k.cjs';
14
+ export { j as AuthProviderConfig, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, d as OAuthProvider, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from './OAuthProvider-BV6EpF_k.cjs';
15
15
  import 'node:http';
16
16
 
17
17
  declare class DiscoveryDocumentCache {
package/dist/FastMCP.d.ts CHANGED
@@ -10,8 +10,8 @@ import { Hono } from 'hono';
10
10
  import http from 'http';
11
11
  import { StrictEventEmitter } from 'strict-event-emitter-types';
12
12
  import { z } from 'zod';
13
- import { A as AuthProvider, O as OAuthSession, a as OAuthProxy } from './OAuthProvider-R8buLRa8.js';
14
- export { j as AuthProviderConfig, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, d as OAuthProvider, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from './OAuthProvider-R8buLRa8.js';
13
+ import { A as AuthProvider, O as OAuthSession, a as OAuthProxy } from './OAuthProvider-BV6EpF_k.js';
14
+ export { j as AuthProviderConfig, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, d as OAuthProvider, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from './OAuthProvider-BV6EpF_k.js';
15
15
  import 'node:http';
16
16
 
17
17
  declare class DiscoveryDocumentCache {
package/dist/FastMCP.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  UserError,
8
8
  audioContent,
9
9
  imageContent
10
- } from "./chunk-UVX47AE5.js";
10
+ } from "./chunk-TNX4H4LB.js";
11
11
  import {
12
12
  AuthProvider,
13
13
  AzureProvider,
@@ -20,7 +20,7 @@ import {
20
20
  requireAuth,
21
21
  requireRole,
22
22
  requireScopes
23
- } from "./chunk-H4VC4YTC.js";
23
+ } from "./chunk-UN72PIH2.js";
24
24
  export {
25
25
  AuthProvider,
26
26
  AzureProvider,
@@ -185,7 +185,23 @@ interface OAuthProviderConfig {
185
185
  interface OAuthProxyConfig {
186
186
  /** Access token TTL in seconds (default: 3600) */
187
187
  accessTokenTtl?: number;
188
- /** Allowed redirect URI patterns for client registration */
188
+ /**
189
+ * Allow-list of redirect URI patterns accepted by Dynamic Client Registration.
190
+ *
191
+ * A client calling POST /oauth/register must present a `redirect_uri` that
192
+ * matches one of these patterns (exact string or glob with `*` / `?`);
193
+ * otherwise the registration is rejected with `invalid_redirect_uri`. Once
194
+ * registered, the same exact URI must be echoed back at /oauth/authorize —
195
+ * the proxy performs exact string comparison per RFC 6749 §3.1.2.3.
196
+ *
197
+ * Default: `[]` (DCR rejects everything — explicit opt-in required).
198
+ *
199
+ * Prior versions defaulted to `["https://*", "http://localhost:*"]` with an
200
+ * implicit fallback that allowed any https URL. This enabled CWE-601
201
+ * open-redirect / authorization-code theft: an attacker could DCR their own
202
+ * URL and then steal victim codes via /oauth/authorize. Do not loosen this
203
+ * default without understanding that threat model.
204
+ */
189
205
  allowedRedirectUriPatterns?: string[];
190
206
  /** Authorization code TTL in seconds (default: 300) */
191
207
  authorizationCodeTtl?: number;
@@ -548,7 +564,16 @@ declare class OAuthProxy {
548
564
  */
549
565
  private startCleanup;
550
566
  /**
551
- * Validate redirect URI against allowed patterns
567
+ * Validate a redirect URI against the configured allow-list.
568
+ *
569
+ * Returns `true` only if the URI is syntactically valid AND matches one of
570
+ * the explicitly configured `allowedRedirectUriPatterns`. An empty or unset
571
+ * pattern list means DCR will reject every URI — framework users must
572
+ * opt-in by listing the exact URIs (or wildcards) they trust.
573
+ *
574
+ * Prior versions also fell back to allowing any https URL or localhost,
575
+ * which enabled attackers to DCR an arbitrary URL and then abuse it via
576
+ * /oauth/authorize (CWE-601). Do not re-introduce that fallback.
552
577
  */
553
578
  private validateRedirectUri;
554
579
  }
@@ -573,7 +598,17 @@ declare class OAuthProxyError extends Error {
573
598
  * Configuration common to all OAuth providers.
574
599
  */
575
600
  interface AuthProviderConfig {
576
- /** Allowed redirect URI patterns (default: ["http://localhost:*", "https://*"]) */
601
+ /**
602
+ * Allow-list of redirect URI patterns accepted by Dynamic Client
603
+ * Registration. Required for any deployment that exposes /oauth/register
604
+ * or /oauth/authorize — an empty/unset list rejects every URI.
605
+ *
606
+ * Example: `["https://yourapp.example.com/*"]`
607
+ *
608
+ * Prior versions defaulted to `["http://localhost:*", "https://*"]`, which
609
+ * enabled CWE-601 open-redirect / authorization-code theft. See the
610
+ * SECURITY advisory before loosening this.
611
+ */
577
612
  allowedRedirectUriPatterns?: string[];
578
613
  /** Base URL where the MCP server is accessible */
579
614
  baseUrl: string;
@@ -185,7 +185,23 @@ interface OAuthProviderConfig {
185
185
  interface OAuthProxyConfig {
186
186
  /** Access token TTL in seconds (default: 3600) */
187
187
  accessTokenTtl?: number;
188
- /** Allowed redirect URI patterns for client registration */
188
+ /**
189
+ * Allow-list of redirect URI patterns accepted by Dynamic Client Registration.
190
+ *
191
+ * A client calling POST /oauth/register must present a `redirect_uri` that
192
+ * matches one of these patterns (exact string or glob with `*` / `?`);
193
+ * otherwise the registration is rejected with `invalid_redirect_uri`. Once
194
+ * registered, the same exact URI must be echoed back at /oauth/authorize —
195
+ * the proxy performs exact string comparison per RFC 6749 §3.1.2.3.
196
+ *
197
+ * Default: `[]` (DCR rejects everything — explicit opt-in required).
198
+ *
199
+ * Prior versions defaulted to `["https://*", "http://localhost:*"]` with an
200
+ * implicit fallback that allowed any https URL. This enabled CWE-601
201
+ * open-redirect / authorization-code theft: an attacker could DCR their own
202
+ * URL and then steal victim codes via /oauth/authorize. Do not loosen this
203
+ * default without understanding that threat model.
204
+ */
189
205
  allowedRedirectUriPatterns?: string[];
190
206
  /** Authorization code TTL in seconds (default: 300) */
191
207
  authorizationCodeTtl?: number;
@@ -548,7 +564,16 @@ declare class OAuthProxy {
548
564
  */
549
565
  private startCleanup;
550
566
  /**
551
- * Validate redirect URI against allowed patterns
567
+ * Validate a redirect URI against the configured allow-list.
568
+ *
569
+ * Returns `true` only if the URI is syntactically valid AND matches one of
570
+ * the explicitly configured `allowedRedirectUriPatterns`. An empty or unset
571
+ * pattern list means DCR will reject every URI — framework users must
572
+ * opt-in by listing the exact URIs (or wildcards) they trust.
573
+ *
574
+ * Prior versions also fell back to allowing any https URL or localhost,
575
+ * which enabled attackers to DCR an arbitrary URL and then abuse it via
576
+ * /oauth/authorize (CWE-601). Do not re-introduce that fallback.
552
577
  */
553
578
  private validateRedirectUri;
554
579
  }
@@ -573,7 +598,17 @@ declare class OAuthProxyError extends Error {
573
598
  * Configuration common to all OAuth providers.
574
599
  */
575
600
  interface AuthProviderConfig {
576
- /** Allowed redirect URI patterns (default: ["http://localhost:*", "https://*"]) */
601
+ /**
602
+ * Allow-list of redirect URI patterns accepted by Dynamic Client
603
+ * Registration. Required for any deployment that exposes /oauth/register
604
+ * or /oauth/authorize — an empty/unset list rejects every URI.
605
+ *
606
+ * Example: `["https://yourapp.example.com/*"]`
607
+ *
608
+ * Prior versions defaulted to `["http://localhost:*", "https://*"]`, which
609
+ * enabled CWE-601 open-redirect / authorization-code theft. See the
610
+ * SECURITY advisory before loosening this.
611
+ */
577
612
  allowedRedirectUriPatterns?: string[];
578
613
  /** Base URL where the MCP server is accessible */
579
614
  baseUrl: string;
@@ -24,7 +24,7 @@
24
24
 
25
25
 
26
26
 
27
- var _chunk7UDY4VFQcjs = require('../chunk-7UDY4VFQ.cjs');
27
+ var _chunkSSVFQCSNcjs = require('../chunk-SSVFQCSN.cjs');
28
28
 
29
29
 
30
30
 
@@ -51,5 +51,5 @@ var _chunk7UDY4VFQcjs = require('../chunk-7UDY4VFQ.cjs');
51
51
 
52
52
 
53
53
 
54
- exports.AuthProvider = _chunk7UDY4VFQcjs.AuthProvider; exports.AzureProvider = _chunk7UDY4VFQcjs.AzureProvider; exports.ConsentManager = _chunk7UDY4VFQcjs.ConsentManager; exports.DEFAULT_ACCESS_TOKEN_TTL = _chunk7UDY4VFQcjs.DEFAULT_ACCESS_TOKEN_TTL; exports.DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH = _chunk7UDY4VFQcjs.DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH; exports.DEFAULT_AUTHORIZATION_CODE_TTL = _chunk7UDY4VFQcjs.DEFAULT_AUTHORIZATION_CODE_TTL; exports.DEFAULT_REFRESH_TOKEN_TTL = _chunk7UDY4VFQcjs.DEFAULT_REFRESH_TOKEN_TTL; exports.DEFAULT_TRANSACTION_TTL = _chunk7UDY4VFQcjs.DEFAULT_TRANSACTION_TTL; exports.DiskStore = _chunk7UDY4VFQcjs.DiskStore; exports.EncryptedTokenStorage = _chunk7UDY4VFQcjs.EncryptedTokenStorage; exports.GitHubProvider = _chunk7UDY4VFQcjs.GitHubProvider; exports.GoogleProvider = _chunk7UDY4VFQcjs.GoogleProvider; exports.JWKSVerifier = _chunk7UDY4VFQcjs.JWKSVerifier; exports.JWTIssuer = _chunk7UDY4VFQcjs.JWTIssuer; exports.MemoryTokenStorage = _chunk7UDY4VFQcjs.MemoryTokenStorage; exports.OAuthProvider = _chunk7UDY4VFQcjs.OAuthProvider; exports.OAuthProxy = _chunk7UDY4VFQcjs.OAuthProxy; exports.OAuthProxyError = _chunk7UDY4VFQcjs.OAuthProxyError; exports.PKCEUtils = _chunk7UDY4VFQcjs.PKCEUtils; exports.getAuthSession = _chunk7UDY4VFQcjs.getAuthSession; exports.requireAll = _chunk7UDY4VFQcjs.requireAll; exports.requireAny = _chunk7UDY4VFQcjs.requireAny; exports.requireAuth = _chunk7UDY4VFQcjs.requireAuth; exports.requireRole = _chunk7UDY4VFQcjs.requireRole; exports.requireScopes = _chunk7UDY4VFQcjs.requireScopes;
54
+ exports.AuthProvider = _chunkSSVFQCSNcjs.AuthProvider; exports.AzureProvider = _chunkSSVFQCSNcjs.AzureProvider; exports.ConsentManager = _chunkSSVFQCSNcjs.ConsentManager; exports.DEFAULT_ACCESS_TOKEN_TTL = _chunkSSVFQCSNcjs.DEFAULT_ACCESS_TOKEN_TTL; exports.DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH = _chunkSSVFQCSNcjs.DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH; exports.DEFAULT_AUTHORIZATION_CODE_TTL = _chunkSSVFQCSNcjs.DEFAULT_AUTHORIZATION_CODE_TTL; exports.DEFAULT_REFRESH_TOKEN_TTL = _chunkSSVFQCSNcjs.DEFAULT_REFRESH_TOKEN_TTL; exports.DEFAULT_TRANSACTION_TTL = _chunkSSVFQCSNcjs.DEFAULT_TRANSACTION_TTL; exports.DiskStore = _chunkSSVFQCSNcjs.DiskStore; exports.EncryptedTokenStorage = _chunkSSVFQCSNcjs.EncryptedTokenStorage; exports.GitHubProvider = _chunkSSVFQCSNcjs.GitHubProvider; exports.GoogleProvider = _chunkSSVFQCSNcjs.GoogleProvider; exports.JWKSVerifier = _chunkSSVFQCSNcjs.JWKSVerifier; exports.JWTIssuer = _chunkSSVFQCSNcjs.JWTIssuer; exports.MemoryTokenStorage = _chunkSSVFQCSNcjs.MemoryTokenStorage; exports.OAuthProvider = _chunkSSVFQCSNcjs.OAuthProvider; exports.OAuthProxy = _chunkSSVFQCSNcjs.OAuthProxy; exports.OAuthProxyError = _chunkSSVFQCSNcjs.OAuthProxyError; exports.PKCEUtils = _chunkSSVFQCSNcjs.PKCEUtils; exports.getAuthSession = _chunkSSVFQCSNcjs.getAuthSession; exports.requireAll = _chunkSSVFQCSNcjs.requireAll; exports.requireAny = _chunkSSVFQCSNcjs.requireAny; exports.requireAuth = _chunkSSVFQCSNcjs.requireAuth; exports.requireRole = _chunkSSVFQCSNcjs.requireRole; exports.requireScopes = _chunkSSVFQCSNcjs.requireScopes;
55
55
  //# sourceMappingURL=index.cjs.map
@@ -1,5 +1,5 @@
1
- import { p as OAuthTransaction, C as ConsentData, T as TokenStorage, q as TokenVerifier, s as TokenVerificationResult, P as PKCEPair } from '../OAuthProvider-R8buLRa8.cjs';
2
- export { A as AuthProvider, j as AuthProviderConfig, y as AuthorizationParams, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, z as ClientCode, B as DCRClientMetadata, E as DCRRequest, F as DCRResponse, D as DEFAULT_ACCESS_TOKEN_TTL, u as DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH, v as DEFAULT_AUTHORIZATION_CODE_TTL, w as DEFAULT_REFRESH_TOKEN_TTL, x as DEFAULT_TRANSACTION_TTL, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, H as OAuthError, d as OAuthProvider, I as OAuthProviderConfig, a as OAuthProxy, J as OAuthProxyConfig, t as OAuthProxyError, O as OAuthSession, K as ProxyDCRClient, R as RefreshRequest, L as TokenMapping, M as TokenRequest, N as TokenResponse, U as UpstreamTokenSet, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from '../OAuthProvider-R8buLRa8.cjs';
1
+ import { p as OAuthTransaction, C as ConsentData, T as TokenStorage, q as TokenVerifier, s as TokenVerificationResult, P as PKCEPair } from '../OAuthProvider-BV6EpF_k.cjs';
2
+ export { A as AuthProvider, j as AuthProviderConfig, y as AuthorizationParams, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, z as ClientCode, B as DCRClientMetadata, E as DCRRequest, F as DCRResponse, D as DEFAULT_ACCESS_TOKEN_TTL, u as DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH, v as DEFAULT_AUTHORIZATION_CODE_TTL, w as DEFAULT_REFRESH_TOKEN_TTL, x as DEFAULT_TRANSACTION_TTL, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, H as OAuthError, d as OAuthProvider, I as OAuthProviderConfig, a as OAuthProxy, J as OAuthProxyConfig, t as OAuthProxyError, O as OAuthSession, K as ProxyDCRClient, R as RefreshRequest, L as TokenMapping, M as TokenRequest, N as TokenResponse, U as UpstreamTokenSet, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from '../OAuthProvider-BV6EpF_k.cjs';
3
3
  import 'node:http';
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
- import { p as OAuthTransaction, C as ConsentData, T as TokenStorage, q as TokenVerifier, s as TokenVerificationResult, P as PKCEPair } from '../OAuthProvider-R8buLRa8.js';
2
- export { A as AuthProvider, j as AuthProviderConfig, y as AuthorizationParams, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, z as ClientCode, B as DCRClientMetadata, E as DCRRequest, F as DCRResponse, D as DEFAULT_ACCESS_TOKEN_TTL, u as DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH, v as DEFAULT_AUTHORIZATION_CODE_TTL, w as DEFAULT_REFRESH_TOKEN_TTL, x as DEFAULT_TRANSACTION_TTL, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, H as OAuthError, d as OAuthProvider, I as OAuthProviderConfig, a as OAuthProxy, J as OAuthProxyConfig, t as OAuthProxyError, O as OAuthSession, K as ProxyDCRClient, R as RefreshRequest, L as TokenMapping, M as TokenRequest, N as TokenResponse, U as UpstreamTokenSet, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from '../OAuthProvider-R8buLRa8.js';
1
+ import { p as OAuthTransaction, C as ConsentData, T as TokenStorage, q as TokenVerifier, s as TokenVerificationResult, P as PKCEPair } from '../OAuthProvider-BV6EpF_k.js';
2
+ export { A as AuthProvider, j as AuthProviderConfig, y as AuthorizationParams, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, z as ClientCode, B as DCRClientMetadata, E as DCRRequest, F as DCRResponse, D as DEFAULT_ACCESS_TOKEN_TTL, u as DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH, v as DEFAULT_AUTHORIZATION_CODE_TTL, w as DEFAULT_REFRESH_TOKEN_TTL, x as DEFAULT_TRANSACTION_TTL, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, H as OAuthError, d as OAuthProvider, I as OAuthProviderConfig, a as OAuthProxy, J as OAuthProxyConfig, t as OAuthProxyError, O as OAuthSession, K as ProxyDCRClient, R as RefreshRequest, L as TokenMapping, M as TokenRequest, N as TokenResponse, U as UpstreamTokenSet, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from '../OAuthProvider-BV6EpF_k.js';
3
3
  import 'node:http';
4
4
 
5
5
  /**
@@ -24,7 +24,7 @@ import {
24
24
  requireAuth,
25
25
  requireRole,
26
26
  requireScopes
27
- } from "../chunk-H4VC4YTC.js";
27
+ } from "../chunk-UN72PIH2.js";
28
28
  export {
29
29
  AuthProvider,
30
30
  AzureProvider,
@@ -1819,23 +1819,26 @@ var FastMCP = class extends FastMCPEventEmitter {
1819
1819
  const url2 = new URL(req.url || "", `http://${host}`);
1820
1820
  try {
1821
1821
  if (req.method === "POST" && url2.pathname === "/oauth/register") {
1822
- let body = "";
1823
- req.on("data", (chunk) => body += chunk);
1824
- req.on("end", async () => {
1825
- try {
1826
- const request = JSON.parse(body);
1827
- const response = await oauthProxy.registerClient(request);
1828
- res.writeHead(201, { "Content-Type": "application/json" }).end(JSON.stringify(response));
1829
- } catch (error) {
1830
- const statusCode = error.statusCode || 400;
1831
- res.writeHead(statusCode, { "Content-Type": "application/json" }).end(
1832
- JSON.stringify(
1833
- _optionalChain([error, 'access', _44 => _44.toJSON, 'optionalCall', _45 => _45()]) || {
1834
- error: "invalid_request"
1835
- }
1836
- )
1837
- );
1838
- }
1822
+ await new Promise((resolve) => {
1823
+ let body = "";
1824
+ req.on("data", (chunk) => body += chunk);
1825
+ req.on("end", async () => {
1826
+ try {
1827
+ const request = JSON.parse(body);
1828
+ const response = await oauthProxy.registerClient(request);
1829
+ res.writeHead(201, { "Content-Type": "application/json" }).end(JSON.stringify(response));
1830
+ } catch (error) {
1831
+ const statusCode = error.statusCode || 400;
1832
+ res.writeHead(statusCode, { "Content-Type": "application/json" }).end(
1833
+ JSON.stringify(
1834
+ _optionalChain([error, 'access', _44 => _44.toJSON, 'optionalCall', _45 => _45()]) || {
1835
+ error: "invalid_request"
1836
+ }
1837
+ )
1838
+ );
1839
+ }
1840
+ resolve();
1841
+ });
1839
1842
  });
1840
1843
  return;
1841
1844
  }
@@ -1886,82 +1889,93 @@ var FastMCP = class extends FastMCPEventEmitter {
1886
1889
  return;
1887
1890
  }
1888
1891
  if (req.method === "POST" && url2.pathname === "/oauth/consent") {
1889
- let body = "";
1890
- req.on("data", (chunk) => body += chunk);
1891
- req.on("end", async () => {
1892
- try {
1893
- const mockRequest = new Request(`http://${host}/oauth/consent`, {
1894
- body,
1895
- headers: {
1896
- "Content-Type": "application/x-www-form-urlencoded"
1897
- },
1898
- method: "POST"
1899
- });
1900
- const response = await oauthProxy.handleConsent(mockRequest);
1901
- const location = response.headers.get("Location");
1902
- if (location) {
1903
- res.writeHead(response.status, { Location: location }).end();
1904
- } else {
1905
- const text = await response.text();
1906
- res.writeHead(response.status).end(text);
1907
- }
1908
- } catch (error) {
1909
- res.writeHead(400, { "Content-Type": "application/json" }).end(
1910
- JSON.stringify(
1911
- _optionalChain([error, 'access', _50 => _50.toJSON, 'optionalCall', _51 => _51()]) || {
1912
- error: "server_error"
1892
+ await new Promise((resolve) => {
1893
+ let body = "";
1894
+ req.on("data", (chunk) => body += chunk);
1895
+ req.on("end", async () => {
1896
+ try {
1897
+ const mockRequest = new Request(
1898
+ `http://${host}/oauth/consent`,
1899
+ {
1900
+ body,
1901
+ headers: {
1902
+ "Content-Type": "application/x-www-form-urlencoded"
1903
+ },
1904
+ method: "POST"
1913
1905
  }
1914
- )
1915
- );
1916
- }
1906
+ );
1907
+ const response = await oauthProxy.handleConsent(mockRequest);
1908
+ const location = response.headers.get("Location");
1909
+ if (location) {
1910
+ res.writeHead(response.status, { Location: location }).end();
1911
+ } else {
1912
+ const text = await response.text();
1913
+ res.writeHead(response.status).end(text);
1914
+ }
1915
+ } catch (error) {
1916
+ res.writeHead(400, { "Content-Type": "application/json" }).end(
1917
+ JSON.stringify(
1918
+ _optionalChain([error, 'access', _50 => _50.toJSON, 'optionalCall', _51 => _51()]) || {
1919
+ error: "server_error"
1920
+ }
1921
+ )
1922
+ );
1923
+ }
1924
+ resolve();
1925
+ });
1917
1926
  });
1918
1927
  return;
1919
1928
  }
1920
1929
  if (req.method === "POST" && url2.pathname === "/oauth/token") {
1921
- let body = "";
1922
- req.on("data", (chunk) => body += chunk);
1923
- req.on("end", async () => {
1924
- try {
1925
- const params = new URLSearchParams(body);
1926
- const grantType = params.get("grant_type");
1927
- const basicAuth = parseBasicAuthHeader(req.headers.authorization);
1928
- const clientId = _optionalChain([basicAuth, 'optionalAccess', _52 => _52.clientId]) || params.get("client_id") || "";
1929
- const clientSecret = _nullishCoalesce(_nullishCoalesce(_optionalChain([basicAuth, 'optionalAccess', _53 => _53.clientSecret]), () => ( params.get("client_secret"))), () => ( void 0));
1930
- let response;
1931
- if (grantType === "authorization_code") {
1932
- response = await oauthProxy.exchangeAuthorizationCode({
1933
- client_id: clientId,
1934
- client_secret: clientSecret,
1935
- code: params.get("code") || "",
1936
- code_verifier: params.get("code_verifier") || void 0,
1937
- grant_type: "authorization_code",
1938
- redirect_uri: params.get("redirect_uri") || ""
1939
- });
1940
- } else if (grantType === "refresh_token") {
1941
- response = await oauthProxy.exchangeRefreshToken({
1942
- client_id: clientId,
1943
- client_secret: clientSecret,
1944
- grant_type: "refresh_token",
1945
- refresh_token: params.get("refresh_token") || "",
1946
- scope: params.get("scope") || void 0
1947
- });
1948
- } else {
1949
- throw {
1950
- statusCode: 400,
1951
- toJSON: () => ({ error: "unsupported_grant_type" })
1952
- };
1930
+ await new Promise((resolve) => {
1931
+ let body = "";
1932
+ req.on("data", (chunk) => body += chunk);
1933
+ req.on("end", async () => {
1934
+ try {
1935
+ const params = new URLSearchParams(body);
1936
+ const grantType = params.get("grant_type");
1937
+ const basicAuth = parseBasicAuthHeader(
1938
+ req.headers.authorization
1939
+ );
1940
+ const clientId = _optionalChain([basicAuth, 'optionalAccess', _52 => _52.clientId]) || params.get("client_id") || "";
1941
+ const clientSecret = _nullishCoalesce(_nullishCoalesce(_optionalChain([basicAuth, 'optionalAccess', _53 => _53.clientSecret]), () => ( params.get("client_secret"))), () => ( void 0));
1942
+ let response;
1943
+ if (grantType === "authorization_code") {
1944
+ response = await oauthProxy.exchangeAuthorizationCode({
1945
+ client_id: clientId,
1946
+ client_secret: clientSecret,
1947
+ code: params.get("code") || "",
1948
+ code_verifier: params.get("code_verifier") || void 0,
1949
+ grant_type: "authorization_code",
1950
+ redirect_uri: params.get("redirect_uri") || ""
1951
+ });
1952
+ } else if (grantType === "refresh_token") {
1953
+ response = await oauthProxy.exchangeRefreshToken({
1954
+ client_id: clientId,
1955
+ client_secret: clientSecret,
1956
+ grant_type: "refresh_token",
1957
+ refresh_token: params.get("refresh_token") || "",
1958
+ scope: params.get("scope") || void 0
1959
+ });
1960
+ } else {
1961
+ throw {
1962
+ statusCode: 400,
1963
+ toJSON: () => ({ error: "unsupported_grant_type" })
1964
+ };
1965
+ }
1966
+ res.writeHead(200, { "Content-Type": "application/json" }).end(JSON.stringify(response));
1967
+ } catch (error) {
1968
+ const statusCode = error.statusCode || 400;
1969
+ res.writeHead(statusCode, { "Content-Type": "application/json" }).end(
1970
+ JSON.stringify(
1971
+ _optionalChain([error, 'access', _54 => _54.toJSON, 'optionalCall', _55 => _55()]) || {
1972
+ error: "invalid_request"
1973
+ }
1974
+ )
1975
+ );
1953
1976
  }
1954
- res.writeHead(200, { "Content-Type": "application/json" }).end(JSON.stringify(response));
1955
- } catch (error) {
1956
- const statusCode = error.statusCode || 400;
1957
- res.writeHead(statusCode, { "Content-Type": "application/json" }).end(
1958
- JSON.stringify(
1959
- _optionalChain([error, 'access', _54 => _54.toJSON, 'optionalCall', _55 => _55()]) || {
1960
- error: "invalid_request"
1961
- }
1962
- )
1963
- );
1964
- }
1977
+ resolve();
1978
+ });
1965
1979
  });
1966
1980
  return;
1967
1981
  }
@@ -1971,7 +1985,6 @@ var FastMCP = class extends FastMCPEventEmitter {
1971
1985
  return;
1972
1986
  }
1973
1987
  }
1974
- res.writeHead(404).end();
1975
1988
  };
1976
1989
  /**
1977
1990
  * Converts Node.js IncomingMessage to Web Request for Hono
@@ -2107,4 +2120,4 @@ var FastMCP = class extends FastMCPEventEmitter {
2107
2120
 
2108
2121
 
2109
2122
  exports.DiscoveryDocumentCache = DiscoveryDocumentCache; exports.imageContent = imageContent; exports.audioContent = audioContent; exports.UnexpectedStateError = UnexpectedStateError; exports.UserError = UserError; exports.ServerState = ServerState; exports.FastMCPSession = FastMCPSession; exports.FastMCP = FastMCP;
2110
- //# sourceMappingURL=chunk-JP7QSER3.cjs.map
2123
+ //# sourceMappingURL=chunk-EXZZ3NKL.cjs.map