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 +2 -0
- package/dist/FastMCP.cjs +3 -3
- package/dist/FastMCP.d.cts +2 -2
- package/dist/FastMCP.d.ts +2 -2
- package/dist/FastMCP.js +2 -2
- package/dist/{OAuthProvider-BV6EpF_k.d.cts → OAuthProvider-BS7O-cik.d.cts} +27 -17
- package/dist/{OAuthProvider-BV6EpF_k.d.ts → OAuthProvider-BS7O-cik.d.ts} +27 -17
- package/dist/auth/index.cjs +2 -2
- package/dist/auth/index.d.cts +2 -2
- package/dist/auth/index.d.ts +2 -2
- package/dist/auth/index.js +1 -1
- package/dist/{chunk-JP7QSER3.cjs → chunk-EXZZ3NKL.cjs} +102 -89
- package/dist/chunk-EXZZ3NKL.cjs.map +1 -0
- package/dist/{chunk-UN72PIH2.js → chunk-HGUUOYR4.js} +38 -24
- package/dist/chunk-HGUUOYR4.js.map +1 -0
- package/dist/{chunk-SSVFQCSN.cjs → chunk-OARN6YYK.cjs} +44 -30
- package/dist/chunk-OARN6YYK.cjs.map +1 -0
- package/dist/{chunk-UVX47AE5.js → chunk-TNX4H4LB.js} +102 -89
- package/dist/{chunk-UVX47AE5.js.map → chunk-TNX4H4LB.js.map} +1 -1
- package/dist/examples/custom-routes.cjs +3 -3
- package/dist/examples/custom-routes.js +2 -2
- package/package.json +2 -2
- package/dist/chunk-JP7QSER3.cjs.map +0 -1
- package/dist/chunk-SSVFQCSN.cjs.map +0 -1
- package/dist/chunk-UN72PIH2.js.map +0 -1
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
|
|
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
|
|
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 =
|
|
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
|
package/dist/FastMCP.d.cts
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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
|
|
195
|
+
* the proxy performs an exact per-client match per RFC 6749 §3.1.2.3.
|
|
196
196
|
*
|
|
197
|
-
*
|
|
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
|
-
*
|
|
200
|
-
*
|
|
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
|
-
/**
|
|
298
|
+
/** Primary (first) registered callback URL */
|
|
297
299
|
callbackUrl: string;
|
|
298
|
-
/**
|
|
300
|
+
/** Proxy-issued client ID (not the upstream provider's client_id) */
|
|
299
301
|
clientId: string;
|
|
300
|
-
/**
|
|
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
|
-
*
|
|
570
|
-
*
|
|
571
|
-
*
|
|
572
|
-
*
|
|
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
|
|
575
|
-
*
|
|
576
|
-
*
|
|
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
|
|
195
|
+
* the proxy performs an exact per-client match per RFC 6749 §3.1.2.3.
|
|
196
196
|
*
|
|
197
|
-
*
|
|
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
|
-
*
|
|
200
|
-
*
|
|
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
|
-
/**
|
|
298
|
+
/** Primary (first) registered callback URL */
|
|
297
299
|
callbackUrl: string;
|
|
298
|
-
/**
|
|
300
|
+
/** Proxy-issued client ID (not the upstream provider's client_id) */
|
|
299
301
|
clientId: string;
|
|
300
|
-
/**
|
|
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
|
-
*
|
|
570
|
-
*
|
|
571
|
-
*
|
|
572
|
-
*
|
|
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
|
|
575
|
-
*
|
|
576
|
-
*
|
|
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
|
}
|
package/dist/auth/index.cjs
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
var
|
|
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 =
|
|
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
|
package/dist/auth/index.d.cts
CHANGED
|
@@ -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-
|
|
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-
|
|
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
|
/**
|
package/dist/auth/index.d.ts
CHANGED
|
@@ -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-
|
|
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-
|
|
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
|
/**
|
package/dist/auth/index.js
CHANGED
|
@@ -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
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
error
|
|
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
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
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
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
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
|
-
|
|
1955
|
-
}
|
|
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-
|
|
2123
|
+
//# sourceMappingURL=chunk-EXZZ3NKL.cjs.map
|