fastmcp 4.0.0 → 4.0.2

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/README.md CHANGED
@@ -2270,3 +2270,5 @@ Refer to this [issue](https://github.com/punkpeye/fastmcp/issues/25#issuecomment
2270
2270
  - FastMCP is inspired by the [Python implementation](https://github.com/jlowin/fastmcp) by [Jonathan Lowin](https://github.com/jlowin).
2271
2271
  - Parts of codebase were adopted from [LiteMCP](https://github.com/wong2/litemcp).
2272
2272
  - Parts of codebase were adopted from [Model Context protocolでSSEをやってみる](https://dev.classmethod.jp/articles/mcp-sse/).
2273
+
2274
+ This project is tested with BrowserStack.
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 _chunkSSVFQCSNcjs = require('./chunk-SSVFQCSN.cjs');
23
+ var _chunkOARN6YYKcjs = require('./chunk-OARN6YYK.cjs');
24
24
 
25
25
 
26
26
 
@@ -41,5 +41,5 @@ var _chunkSSVFQCSNcjs = require('./chunk-SSVFQCSN.cjs');
41
41
 
42
42
 
43
43
 
44
- exports.AuthProvider = _chunkSSVFQCSNcjs.AuthProvider; exports.AzureProvider = _chunkSSVFQCSNcjs.AzureProvider; exports.DiscoveryDocumentCache = _chunkJP7QSER3cjs.DiscoveryDocumentCache; exports.FastMCP = _chunkJP7QSER3cjs.FastMCP; exports.FastMCPSession = _chunkJP7QSER3cjs.FastMCPSession; exports.GitHubProvider = _chunkSSVFQCSNcjs.GitHubProvider; exports.GoogleProvider = _chunkSSVFQCSNcjs.GoogleProvider; exports.OAuthProvider = _chunkSSVFQCSNcjs.OAuthProvider; exports.ServerState = _chunkJP7QSER3cjs.ServerState; exports.UnexpectedStateError = _chunkJP7QSER3cjs.UnexpectedStateError; exports.UserError = _chunkJP7QSER3cjs.UserError; exports.audioContent = _chunkJP7QSER3cjs.audioContent; exports.getAuthSession = _chunkSSVFQCSNcjs.getAuthSession; exports.imageContent = _chunkJP7QSER3cjs.imageContent; exports.requireAll = _chunkSSVFQCSNcjs.requireAll; exports.requireAny = _chunkSSVFQCSNcjs.requireAny; exports.requireAuth = _chunkSSVFQCSNcjs.requireAuth; exports.requireRole = _chunkSSVFQCSNcjs.requireRole; exports.requireScopes = _chunkSSVFQCSNcjs.requireScopes;
44
+ exports.AuthProvider = _chunkOARN6YYKcjs.AuthProvider; exports.AzureProvider = _chunkOARN6YYKcjs.AzureProvider; exports.DiscoveryDocumentCache = _chunkEXZZ3NKLcjs.DiscoveryDocumentCache; exports.FastMCP = _chunkEXZZ3NKLcjs.FastMCP; exports.FastMCPSession = _chunkEXZZ3NKLcjs.FastMCPSession; exports.GitHubProvider = _chunkOARN6YYKcjs.GitHubProvider; exports.GoogleProvider = _chunkOARN6YYKcjs.GoogleProvider; exports.OAuthProvider = _chunkOARN6YYKcjs.OAuthProvider; exports.ServerState = _chunkEXZZ3NKLcjs.ServerState; exports.UnexpectedStateError = _chunkEXZZ3NKLcjs.UnexpectedStateError; exports.UserError = _chunkEXZZ3NKLcjs.UserError; exports.audioContent = _chunkEXZZ3NKLcjs.audioContent; exports.getAuthSession = _chunkOARN6YYKcjs.getAuthSession; exports.imageContent = _chunkEXZZ3NKLcjs.imageContent; exports.requireAll = _chunkOARN6YYKcjs.requireAll; exports.requireAny = _chunkOARN6YYKcjs.requireAny; exports.requireAuth = _chunkOARN6YYKcjs.requireAuth; exports.requireRole = _chunkOARN6YYKcjs.requireRole; exports.requireScopes = _chunkOARN6YYKcjs.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-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';
13
+ import { A as AuthProvider, O as OAuthSession, a as OAuthProxy } from './OAuthProvider-BS7O-cik.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-BS7O-cik.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-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';
13
+ import { A as AuthProvider, O as OAuthSession, a as OAuthProxy } from './OAuthProvider-BS7O-cik.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-BS7O-cik.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-UN72PIH2.js";
23
+ } from "./chunk-HGUUOYR4.js";
24
24
  export {
25
25
  AuthProvider,
26
26
  AzureProvider,
@@ -192,15 +192,17 @@ interface OAuthProxyConfig {
192
192
  * matches one of these patterns (exact string or glob with `*` / `?`);
193
193
  * otherwise the registration is rejected with `invalid_redirect_uri`. Once
194
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.
195
+ * the proxy performs an exact per-client match per RFC 6749 §3.1.2.3.
196
196
  *
197
- * Default: `[]` (DCR rejects everything — explicit opt-in required).
197
+ * Behaviour by value:
198
+ * - `undefined` (default): allow `http://localhost:*` and `http://127.0.0.1:*`
199
+ * only. Covers the standard MCP use-case of dynamic loopback ports.
200
+ * - `[]` (empty array): DCR rejects every URI — use for deployments that
201
+ * configure patterns explicitly and want no implicit fallback.
202
+ * - `["pattern", ...]`: accept URIs matching any glob pattern in the list.
198
203
  *
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
+ * Do not widen the default beyond loopback addresses — allowing arbitrary
205
+ * https URLs enables CWE-601 open-redirect / authorization-code theft.
204
206
  */
205
207
  allowedRedirectUriPatterns?: string[];
206
208
  /** Authorization code TTL in seconds (default: 300) */
@@ -293,14 +295,16 @@ interface PKCEPair {
293
295
  * Dynamic client registration data
294
296
  */
295
297
  interface ProxyDCRClient {
296
- /** Registered callback URL */
298
+ /** Primary (first) registered callback URL */
297
299
  callbackUrl: string;
298
- /** Generated or assigned client ID */
300
+ /** Proxy-issued client ID (not the upstream provider's client_id) */
299
301
  clientId: string;
300
- /** Client secret (optional) */
302
+ /** Proxy-issued client secret (not the upstream provider's client_secret) */
301
303
  clientSecret?: string;
302
304
  /** Client metadata from registration request */
303
305
  metadata?: DCRClientMetadata;
306
+ /** All redirect URIs registered by this client */
307
+ redirectUris: string[];
304
308
  /** Client registration timestamp */
305
309
  registeredAt: Date;
306
310
  }
@@ -419,7 +423,10 @@ declare class OAuthProxy {
419
423
  private config;
420
424
  private consentManager;
421
425
  private jwtIssuer?;
426
+ /** Keyed by redirect_uri for defence-in-depth checks in handleCallback/handleConsent */
422
427
  private registeredClients;
428
+ /** Keyed by proxy-issued client_id for authorize/token-exchange lookups */
429
+ private registeredClientsByClientId;
423
430
  private tokenStorage;
424
431
  private transactions;
425
432
  constructor(config: OAuthProxyConfig);
@@ -566,14 +573,17 @@ declare class OAuthProxy {
566
573
  /**
567
574
  * Validate a redirect URI against the configured allow-list.
568
575
  *
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.
576
+ * Behaviour by configuration value:
577
+ * - `undefined` (not set): allow localhost/127.0.0.1 only safe default
578
+ * that covers the common MCP use-case of dynamic loopback ports without
579
+ * opening the proxy to arbitrary redirect URIs.
580
+ * - `[]` (empty array): reject every URI — opt-in strict mode for deployments
581
+ * that want full control and will configure patterns explicitly.
582
+ * - `["pattern", ...]`: accept URIs matching any of the glob patterns.
573
583
  *
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.
584
+ * Prior versions defaulted to `["https://*", "http://localhost:*"]` which
585
+ * matched any https URL, enabling CWE-601 open-redirect / authorization-code
586
+ * theft. Do not loosen the default beyond loopback addresses.
577
587
  */
578
588
  private validateRedirectUri;
579
589
  }
@@ -192,15 +192,17 @@ interface OAuthProxyConfig {
192
192
  * matches one of these patterns (exact string or glob with `*` / `?`);
193
193
  * otherwise the registration is rejected with `invalid_redirect_uri`. Once
194
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.
195
+ * the proxy performs an exact per-client match per RFC 6749 §3.1.2.3.
196
196
  *
197
- * Default: `[]` (DCR rejects everything — explicit opt-in required).
197
+ * Behaviour by value:
198
+ * - `undefined` (default): allow `http://localhost:*` and `http://127.0.0.1:*`
199
+ * only. Covers the standard MCP use-case of dynamic loopback ports.
200
+ * - `[]` (empty array): DCR rejects every URI — use for deployments that
201
+ * configure patterns explicitly and want no implicit fallback.
202
+ * - `["pattern", ...]`: accept URIs matching any glob pattern in the list.
198
203
  *
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
+ * Do not widen the default beyond loopback addresses — allowing arbitrary
205
+ * https URLs enables CWE-601 open-redirect / authorization-code theft.
204
206
  */
205
207
  allowedRedirectUriPatterns?: string[];
206
208
  /** Authorization code TTL in seconds (default: 300) */
@@ -293,14 +295,16 @@ interface PKCEPair {
293
295
  * Dynamic client registration data
294
296
  */
295
297
  interface ProxyDCRClient {
296
- /** Registered callback URL */
298
+ /** Primary (first) registered callback URL */
297
299
  callbackUrl: string;
298
- /** Generated or assigned client ID */
300
+ /** Proxy-issued client ID (not the upstream provider's client_id) */
299
301
  clientId: string;
300
- /** Client secret (optional) */
302
+ /** Proxy-issued client secret (not the upstream provider's client_secret) */
301
303
  clientSecret?: string;
302
304
  /** Client metadata from registration request */
303
305
  metadata?: DCRClientMetadata;
306
+ /** All redirect URIs registered by this client */
307
+ redirectUris: string[];
304
308
  /** Client registration timestamp */
305
309
  registeredAt: Date;
306
310
  }
@@ -419,7 +423,10 @@ declare class OAuthProxy {
419
423
  private config;
420
424
  private consentManager;
421
425
  private jwtIssuer?;
426
+ /** Keyed by redirect_uri for defence-in-depth checks in handleCallback/handleConsent */
422
427
  private registeredClients;
428
+ /** Keyed by proxy-issued client_id for authorize/token-exchange lookups */
429
+ private registeredClientsByClientId;
423
430
  private tokenStorage;
424
431
  private transactions;
425
432
  constructor(config: OAuthProxyConfig);
@@ -566,14 +573,17 @@ declare class OAuthProxy {
566
573
  /**
567
574
  * Validate a redirect URI against the configured allow-list.
568
575
  *
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.
576
+ * Behaviour by configuration value:
577
+ * - `undefined` (not set): allow localhost/127.0.0.1 only safe default
578
+ * that covers the common MCP use-case of dynamic loopback ports without
579
+ * opening the proxy to arbitrary redirect URIs.
580
+ * - `[]` (empty array): reject every URI — opt-in strict mode for deployments
581
+ * that want full control and will configure patterns explicitly.
582
+ * - `["pattern", ...]`: accept URIs matching any of the glob patterns.
573
583
  *
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.
584
+ * Prior versions defaulted to `["https://*", "http://localhost:*"]` which
585
+ * matched any https URL, enabling CWE-601 open-redirect / authorization-code
586
+ * theft. Do not loosen the default beyond loopback addresses.
577
587
  */
578
588
  private validateRedirectUri;
579
589
  }
@@ -24,7 +24,7 @@
24
24
 
25
25
 
26
26
 
27
- var _chunkSSVFQCSNcjs = require('../chunk-SSVFQCSN.cjs');
27
+ var _chunkOARN6YYKcjs = require('../chunk-OARN6YYK.cjs');
28
28
 
29
29
 
30
30
 
@@ -51,5 +51,5 @@ var _chunkSSVFQCSNcjs = require('../chunk-SSVFQCSN.cjs');
51
51
 
52
52
 
53
53
 
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;
54
+ exports.AuthProvider = _chunkOARN6YYKcjs.AuthProvider; exports.AzureProvider = _chunkOARN6YYKcjs.AzureProvider; exports.ConsentManager = _chunkOARN6YYKcjs.ConsentManager; exports.DEFAULT_ACCESS_TOKEN_TTL = _chunkOARN6YYKcjs.DEFAULT_ACCESS_TOKEN_TTL; exports.DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH = _chunkOARN6YYKcjs.DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH; exports.DEFAULT_AUTHORIZATION_CODE_TTL = _chunkOARN6YYKcjs.DEFAULT_AUTHORIZATION_CODE_TTL; exports.DEFAULT_REFRESH_TOKEN_TTL = _chunkOARN6YYKcjs.DEFAULT_REFRESH_TOKEN_TTL; exports.DEFAULT_TRANSACTION_TTL = _chunkOARN6YYKcjs.DEFAULT_TRANSACTION_TTL; exports.DiskStore = _chunkOARN6YYKcjs.DiskStore; exports.EncryptedTokenStorage = _chunkOARN6YYKcjs.EncryptedTokenStorage; exports.GitHubProvider = _chunkOARN6YYKcjs.GitHubProvider; exports.GoogleProvider = _chunkOARN6YYKcjs.GoogleProvider; exports.JWKSVerifier = _chunkOARN6YYKcjs.JWKSVerifier; exports.JWTIssuer = _chunkOARN6YYKcjs.JWTIssuer; exports.MemoryTokenStorage = _chunkOARN6YYKcjs.MemoryTokenStorage; exports.OAuthProvider = _chunkOARN6YYKcjs.OAuthProvider; exports.OAuthProxy = _chunkOARN6YYKcjs.OAuthProxy; exports.OAuthProxyError = _chunkOARN6YYKcjs.OAuthProxyError; exports.PKCEUtils = _chunkOARN6YYKcjs.PKCEUtils; exports.getAuthSession = _chunkOARN6YYKcjs.getAuthSession; exports.requireAll = _chunkOARN6YYKcjs.requireAll; exports.requireAny = _chunkOARN6YYKcjs.requireAny; exports.requireAuth = _chunkOARN6YYKcjs.requireAuth; exports.requireRole = _chunkOARN6YYKcjs.requireRole; exports.requireScopes = _chunkOARN6YYKcjs.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-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';
1
+ import { p as OAuthTransaction, C as ConsentData, T as TokenStorage, q as TokenVerifier, s as TokenVerificationResult, P as PKCEPair } from '../OAuthProvider-BS7O-cik.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-BS7O-cik.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-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';
1
+ import { p as OAuthTransaction, C as ConsentData, T as TokenStorage, q as TokenVerifier, s as TokenVerificationResult, P as PKCEPair } from '../OAuthProvider-BS7O-cik.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-BS7O-cik.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-UN72PIH2.js";
27
+ } from "../chunk-HGUUOYR4.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