fastmcp 4.0.1 → 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 +2 -2
- package/dist/FastMCP.d.cts +2 -2
- package/dist/FastMCP.d.ts +2 -2
- package/dist/FastMCP.js +1 -1
- 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-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/examples/custom-routes.cjs +1 -1
- package/dist/examples/custom-routes.js +1 -1
- package/package.json +1 -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
|
@@ -20,7 +20,7 @@ var _chunkEXZZ3NKLcjs = require('./chunk-EXZZ3NKL.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
|
@@ -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
|
@@ -858,16 +858,14 @@ var OAuthProxy = class {
|
|
|
858
858
|
config;
|
|
859
859
|
consentManager;
|
|
860
860
|
jwtIssuer;
|
|
861
|
+
/** Keyed by redirect_uri for defence-in-depth checks in handleCallback/handleConsent */
|
|
861
862
|
registeredClients = /* @__PURE__ */ new Map();
|
|
863
|
+
/** Keyed by proxy-issued client_id for authorize/token-exchange lookups */
|
|
864
|
+
registeredClientsByClientId = /* @__PURE__ */ new Map();
|
|
862
865
|
tokenStorage;
|
|
863
866
|
transactions = /* @__PURE__ */ new Map();
|
|
864
867
|
constructor(config) {
|
|
865
868
|
this.config = {
|
|
866
|
-
// Empty by default. Framework users must explicitly configure the URIs they
|
|
867
|
-
// trust, per RFC 6819 §4.1.5. The previous default (`["https://*", "http://localhost:*"]`)
|
|
868
|
-
// allowed open DCR registration of any https URL, enabling CWE-601 open-redirect
|
|
869
|
-
// attacks against /oauth/authorize.
|
|
870
|
-
allowedRedirectUriPatterns: [],
|
|
871
869
|
authorizationCodeTtl: DEFAULT_AUTHORIZATION_CODE_TTL,
|
|
872
870
|
consentRequired: true,
|
|
873
871
|
enableTokenSwap: true,
|
|
@@ -917,10 +915,13 @@ var OAuthProxy = class {
|
|
|
917
915
|
"Only 'code' response type is supported"
|
|
918
916
|
);
|
|
919
917
|
}
|
|
920
|
-
|
|
918
|
+
const registeredClient = this.registeredClientsByClientId.get(
|
|
919
|
+
params.client_id
|
|
920
|
+
);
|
|
921
|
+
if (!registeredClient) {
|
|
921
922
|
throw new OAuthProxyError("invalid_client", "Unknown client_id");
|
|
922
923
|
}
|
|
923
|
-
if (!
|
|
924
|
+
if (!registeredClient.redirectUris.includes(params.redirect_uri)) {
|
|
924
925
|
throw new OAuthProxyError(
|
|
925
926
|
"invalid_request",
|
|
926
927
|
"redirect_uri is not registered for this client"
|
|
@@ -952,6 +953,7 @@ var OAuthProxy = class {
|
|
|
952
953
|
this.transactions.clear();
|
|
953
954
|
this.clientCodes.clear();
|
|
954
955
|
this.registeredClients.clear();
|
|
956
|
+
this.registeredClientsByClientId.clear();
|
|
955
957
|
}
|
|
956
958
|
/**
|
|
957
959
|
* Token endpoint - exchange authorization code for tokens
|
|
@@ -963,7 +965,7 @@ var OAuthProxy = class {
|
|
|
963
965
|
"Only authorization_code grant type is supported"
|
|
964
966
|
);
|
|
965
967
|
}
|
|
966
|
-
if (request.client_id
|
|
968
|
+
if (!this.registeredClientsByClientId.has(request.client_id)) {
|
|
967
969
|
throw new OAuthProxyError("invalid_client", "Unknown client_id");
|
|
968
970
|
}
|
|
969
971
|
const clientCode = this.clientCodes.get(request.code);
|
|
@@ -1185,11 +1187,12 @@ var OAuthProxy = class {
|
|
|
1185
1187
|
);
|
|
1186
1188
|
}
|
|
1187
1189
|
}
|
|
1188
|
-
const
|
|
1190
|
+
const proxyClientId = randomBytes4(16).toString("hex");
|
|
1191
|
+
const proxyClientSecret = randomBytes4(32).toString("base64url");
|
|
1189
1192
|
const client = {
|
|
1190
1193
|
callbackUrl: request.redirect_uris[0],
|
|
1191
|
-
clientId,
|
|
1192
|
-
clientSecret:
|
|
1194
|
+
clientId: proxyClientId,
|
|
1195
|
+
clientSecret: proxyClientSecret,
|
|
1193
1196
|
metadata: {
|
|
1194
1197
|
client_name: request.client_name,
|
|
1195
1198
|
client_uri: request.client_uri,
|
|
@@ -1203,17 +1206,19 @@ var OAuthProxy = class {
|
|
|
1203
1206
|
software_version: request.software_version,
|
|
1204
1207
|
tos_uri: request.tos_uri
|
|
1205
1208
|
},
|
|
1209
|
+
redirectUris: request.redirect_uris,
|
|
1206
1210
|
registeredAt: /* @__PURE__ */ new Date()
|
|
1207
1211
|
};
|
|
1212
|
+
this.registeredClientsByClientId.set(proxyClientId, client);
|
|
1208
1213
|
for (const uri of request.redirect_uris) {
|
|
1209
1214
|
this.registeredClients.set(uri, client);
|
|
1210
1215
|
}
|
|
1211
1216
|
const response = {
|
|
1212
|
-
client_id:
|
|
1217
|
+
client_id: proxyClientId,
|
|
1213
1218
|
client_id_issued_at: Math.floor(Date.now() / 1e3),
|
|
1214
1219
|
// Echo back optional metadata
|
|
1215
1220
|
client_name: request.client_name,
|
|
1216
|
-
client_secret:
|
|
1221
|
+
client_secret: proxyClientSecret,
|
|
1217
1222
|
client_secret_expires_at: 0,
|
|
1218
1223
|
// Never expires
|
|
1219
1224
|
client_uri: request.client_uri,
|
|
@@ -1812,14 +1817,17 @@ var OAuthProxy = class {
|
|
|
1812
1817
|
/**
|
|
1813
1818
|
* Validate a redirect URI against the configured allow-list.
|
|
1814
1819
|
*
|
|
1815
|
-
*
|
|
1816
|
-
*
|
|
1817
|
-
*
|
|
1818
|
-
*
|
|
1820
|
+
* Behaviour by configuration value:
|
|
1821
|
+
* - `undefined` (not set): allow localhost/127.0.0.1 only — safe default
|
|
1822
|
+
* that covers the common MCP use-case of dynamic loopback ports without
|
|
1823
|
+
* opening the proxy to arbitrary redirect URIs.
|
|
1824
|
+
* - `[]` (empty array): reject every URI — opt-in strict mode for deployments
|
|
1825
|
+
* that want full control and will configure patterns explicitly.
|
|
1826
|
+
* - `["pattern", ...]`: accept URIs matching any of the glob patterns.
|
|
1819
1827
|
*
|
|
1820
|
-
* Prior versions
|
|
1821
|
-
*
|
|
1822
|
-
*
|
|
1828
|
+
* Prior versions defaulted to `["https://*", "http://localhost:*"]` which
|
|
1829
|
+
* matched any https URL, enabling CWE-601 open-redirect / authorization-code
|
|
1830
|
+
* theft. Do not loosen the default beyond loopback addresses.
|
|
1823
1831
|
*/
|
|
1824
1832
|
validateRedirectUri(uri) {
|
|
1825
1833
|
try {
|
|
@@ -1827,11 +1835,17 @@ var OAuthProxy = class {
|
|
|
1827
1835
|
} catch {
|
|
1828
1836
|
return false;
|
|
1829
1837
|
}
|
|
1830
|
-
const patterns = this.config.allowedRedirectUriPatterns
|
|
1831
|
-
if (patterns.length === 0) {
|
|
1838
|
+
const patterns = this.config.allowedRedirectUriPatterns;
|
|
1839
|
+
if (Array.isArray(patterns) && patterns.length === 0) {
|
|
1832
1840
|
return false;
|
|
1833
1841
|
}
|
|
1834
|
-
|
|
1842
|
+
const effectivePatterns = patterns ?? [
|
|
1843
|
+
"http://localhost:*",
|
|
1844
|
+
"http://127.0.0.1:*"
|
|
1845
|
+
];
|
|
1846
|
+
return effectivePatterns.some(
|
|
1847
|
+
(pattern) => this.matchesPattern(uri, pattern)
|
|
1848
|
+
);
|
|
1835
1849
|
}
|
|
1836
1850
|
};
|
|
1837
1851
|
var OAuthProxyError = class extends Error {
|
|
@@ -2378,4 +2392,4 @@ export {
|
|
|
2378
2392
|
DiskStore,
|
|
2379
2393
|
JWKSVerifier
|
|
2380
2394
|
};
|
|
2381
|
-
//# sourceMappingURL=chunk-
|
|
2395
|
+
//# sourceMappingURL=chunk-HGUUOYR4.js.map
|