fastmcp 4.12.4 → 4.12.6
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 +8 -5
- 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-B_E71LUD.d.cts → OAuthProvider-B_OJFNC0.d.cts} +25 -5
- package/dist/{OAuthProvider-B_E71LUD.d.ts → OAuthProvider-B_OJFNC0.d.ts} +25 -5
- 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-FKX5QBJV.js → chunk-HIIPZVNY.js} +117 -10
- package/dist/chunk-HIIPZVNY.js.map +1 -0
- package/dist/{chunk-ENMHHQJF.cjs → chunk-RQ6222DU.cjs} +90 -39
- package/dist/chunk-RQ6222DU.cjs.map +1 -0
- package/dist/{chunk-2ZFQSPXZ.js → chunk-SZ4XCW5X.js} +90 -39
- package/dist/chunk-SZ4XCW5X.js.map +1 -0
- package/dist/{chunk-DD63MJG7.cjs → chunk-U36NARZG.cjs} +117 -10
- package/dist/chunk-U36NARZG.cjs.map +1 -0
- package/dist/examples/custom-routes.cjs +3 -3
- package/dist/examples/custom-routes.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-2ZFQSPXZ.js.map +0 -1
- package/dist/chunk-DD63MJG7.cjs.map +0 -1
- package/dist/chunk-ENMHHQJF.cjs.map +0 -1
- package/dist/chunk-FKX5QBJV.js.map +0 -1
package/README.md
CHANGED
|
@@ -2015,20 +2015,23 @@ For more control over OAuth behavior, you can use the `oauth` option directly:
|
|
|
2015
2015
|
import { FastMCP } from "fastmcp";
|
|
2016
2016
|
import { GoogleProvider } from "fastmcp/auth";
|
|
2017
2017
|
|
|
2018
|
-
const
|
|
2019
|
-
clientId: process.env.GOOGLE_CLIENT_ID,
|
|
2020
|
-
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
|
|
2018
|
+
const authProvider = new GoogleProvider({
|
|
2021
2019
|
baseUrl: "https://your-server.com",
|
|
2020
|
+
clientId: process.env.GOOGLE_CLIENT_ID!,
|
|
2021
|
+
clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
|
|
2022
2022
|
scopes: ["openid", "profile", "email"],
|
|
2023
2023
|
});
|
|
2024
2024
|
|
|
2025
2025
|
const server = new FastMCP({
|
|
2026
2026
|
name: "My Server",
|
|
2027
2027
|
oauth: {
|
|
2028
|
+
authorizationServer: authProvider
|
|
2029
|
+
.getProxy()
|
|
2030
|
+
.getAuthorizationServerMetadata(),
|
|
2028
2031
|
enabled: true,
|
|
2029
|
-
|
|
2030
|
-
proxy: authProxy,
|
|
2032
|
+
proxy: authProvider.getProxy(),
|
|
2031
2033
|
},
|
|
2034
|
+
version: "1.0.0",
|
|
2032
2035
|
});
|
|
2033
2036
|
```
|
|
2034
2037
|
|
package/dist/FastMCP.cjs
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _chunkU36NARZGcjs = require('./chunk-U36NARZG.cjs');
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
@@ -24,7 +24,7 @@ var _chunkDD63MJG7cjs = require('./chunk-DD63MJG7.cjs');
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
var
|
|
27
|
+
var _chunkRQ6222DUcjs = require('./chunk-RQ6222DU.cjs');
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
|
|
@@ -49,5 +49,5 @@ var _chunkENMHHQJFcjs = require('./chunk-ENMHHQJF.cjs');
|
|
|
49
49
|
|
|
50
50
|
|
|
51
51
|
|
|
52
|
-
exports.AuthProvider =
|
|
52
|
+
exports.AuthProvider = _chunkRQ6222DUcjs.AuthProvider; exports.AzureProvider = _chunkRQ6222DUcjs.AzureProvider; exports.DiscoveryDocumentCache = _chunkU36NARZGcjs.DiscoveryDocumentCache; exports.FastMCP = _chunkU36NARZGcjs.FastMCP; exports.FastMCPError = _chunkU36NARZGcjs.FastMCPError; exports.FastMCPSession = _chunkU36NARZGcjs.FastMCPSession; exports.GitHubProvider = _chunkRQ6222DUcjs.GitHubProvider; exports.GoogleProvider = _chunkRQ6222DUcjs.GoogleProvider; exports.MEDIA_FETCH_TIMEOUT_MS = _chunkU36NARZGcjs.MEDIA_FETCH_TIMEOUT_MS; exports.OAuthProvider = _chunkRQ6222DUcjs.OAuthProvider; exports.ServerState = _chunkU36NARZGcjs.ServerState; exports.SessionError = _chunkU36NARZGcjs.SessionError; exports.UnexpectedStateError = _chunkU36NARZGcjs.UnexpectedStateError; exports.UserError = _chunkU36NARZGcjs.UserError; exports.audioContent = _chunkU36NARZGcjs.audioContent; exports.getAuthSession = _chunkRQ6222DUcjs.getAuthSession; exports.imageContent = _chunkU36NARZGcjs.imageContent; exports.jsonSchemaAdapter = _chunkU36NARZGcjs.jsonSchemaAdapter; exports.requireAll = _chunkRQ6222DUcjs.requireAll; exports.requireAny = _chunkRQ6222DUcjs.requireAny; exports.requireAuth = _chunkRQ6222DUcjs.requireAuth; exports.requireRole = _chunkRQ6222DUcjs.requireRole; exports.requireScopes = _chunkRQ6222DUcjs.requireScopes;
|
|
53
53
|
//# sourceMappingURL=FastMCP.cjs.map
|
package/dist/FastMCP.d.cts
CHANGED
|
@@ -12,8 +12,8 @@ import { CorsOptions } from 'mcp-proxy';
|
|
|
12
12
|
export { CorsOptions } from 'mcp-proxy';
|
|
13
13
|
import { StrictEventEmitter } from 'strict-event-emitter-types';
|
|
14
14
|
import { z } from 'zod';
|
|
15
|
-
import { A as AuthProvider, O as OAuthSession, a as OAuthProxy } from './OAuthProvider-
|
|
16
|
-
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-
|
|
15
|
+
import { A as AuthProvider, O as OAuthSession, a as OAuthProxy } from './OAuthProvider-B_OJFNC0.cjs';
|
|
16
|
+
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-B_OJFNC0.cjs';
|
|
17
17
|
import 'node:http';
|
|
18
18
|
|
|
19
19
|
declare class DiscoveryDocumentCache {
|
package/dist/FastMCP.d.ts
CHANGED
|
@@ -12,8 +12,8 @@ import { CorsOptions } from 'mcp-proxy';
|
|
|
12
12
|
export { CorsOptions } from 'mcp-proxy';
|
|
13
13
|
import { StrictEventEmitter } from 'strict-event-emitter-types';
|
|
14
14
|
import { z } from 'zod';
|
|
15
|
-
import { A as AuthProvider, O as OAuthSession, a as OAuthProxy } from './OAuthProvider-
|
|
16
|
-
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-
|
|
15
|
+
import { A as AuthProvider, O as OAuthSession, a as OAuthProxy } from './OAuthProvider-B_OJFNC0.js';
|
|
16
|
+
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-B_OJFNC0.js';
|
|
17
17
|
import 'node:http';
|
|
18
18
|
|
|
19
19
|
declare class DiscoveryDocumentCache {
|
package/dist/FastMCP.js
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
audioContent,
|
|
12
12
|
imageContent,
|
|
13
13
|
jsonSchemaAdapter
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-HIIPZVNY.js";
|
|
15
15
|
import {
|
|
16
16
|
AuthProvider,
|
|
17
17
|
AzureProvider,
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
requireAuth,
|
|
25
25
|
requireRole,
|
|
26
26
|
requireScopes
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-SZ4XCW5X.js";
|
|
28
28
|
export {
|
|
29
29
|
AuthProvider,
|
|
30
30
|
AzureProvider,
|
|
@@ -388,11 +388,14 @@ interface TokenStorage {
|
|
|
388
388
|
* Atomically retrieve a value and delete it, returning `null` if the key was
|
|
389
389
|
* absent. At most one caller may observe a given value.
|
|
390
390
|
*
|
|
391
|
-
* Optional, but **required for correctness
|
|
392
|
-
*
|
|
393
|
-
*
|
|
394
|
-
*
|
|
395
|
-
*
|
|
391
|
+
* Optional, but **required for correctness whenever concurrent requests can
|
|
392
|
+
* reach the same record** — which includes a single process, since the check
|
|
393
|
+
* and the delete straddle an await. The OAuth proxy consumes authorization
|
|
394
|
+
* codes, transactions and refresh-token mappings through it, and single-use
|
|
395
|
+
* enforcement depends on the atomicity. Without it the proxy falls back to a
|
|
396
|
+
* non-atomic get + delete, where two concurrent requests can both redeem the
|
|
397
|
+
* same authorization code, or both redeem the same refresh token and walk
|
|
398
|
+
* away with two independent token chains.
|
|
396
399
|
*
|
|
397
400
|
* Most backends expose a suitable primitive: Redis `GETDEL`, DynamoDB
|
|
398
401
|
* `DeleteItem` with `ReturnValues: "ALL_OLD"`, or SQL
|
|
@@ -604,10 +607,27 @@ declare class OAuthProxy {
|
|
|
604
607
|
* Refresh upstream tokens with provider
|
|
605
608
|
*/
|
|
606
609
|
private refreshUpstreamTokens;
|
|
610
|
+
/**
|
|
611
|
+
* Put a claimed refresh-token mapping back after a rotation failed, keeping
|
|
612
|
+
* whatever lifetime it had left.
|
|
613
|
+
*
|
|
614
|
+
* A mapping that is already expired, or that carries no usable expiry, is
|
|
615
|
+
* dropped instead. Inventing a TTL here would extend the lifetime of a
|
|
616
|
+
* credential in a security path, and every mapping this proxy writes records
|
|
617
|
+
* `expiresAt`.
|
|
618
|
+
*/
|
|
619
|
+
private restoreMapping;
|
|
607
620
|
/**
|
|
608
621
|
* Start periodic cleanup of expired transactions and codes
|
|
609
622
|
*/
|
|
610
623
|
private startCleanup;
|
|
624
|
+
/**
|
|
625
|
+
* Atomically claim a token mapping, mirroring `OAuthProxyStateStore`: at most
|
|
626
|
+
* one caller — across all processes sharing the storage — can receive a given
|
|
627
|
+
* mapping, which is what makes single use enforceable. Falls back to a
|
|
628
|
+
* non-atomic get + delete for storages that do not implement `take`.
|
|
629
|
+
*/
|
|
630
|
+
private takeMapping;
|
|
611
631
|
/**
|
|
612
632
|
* Validate a redirect URI against the configured allow-list.
|
|
613
633
|
*
|
|
@@ -388,11 +388,14 @@ interface TokenStorage {
|
|
|
388
388
|
* Atomically retrieve a value and delete it, returning `null` if the key was
|
|
389
389
|
* absent. At most one caller may observe a given value.
|
|
390
390
|
*
|
|
391
|
-
* Optional, but **required for correctness
|
|
392
|
-
*
|
|
393
|
-
*
|
|
394
|
-
*
|
|
395
|
-
*
|
|
391
|
+
* Optional, but **required for correctness whenever concurrent requests can
|
|
392
|
+
* reach the same record** — which includes a single process, since the check
|
|
393
|
+
* and the delete straddle an await. The OAuth proxy consumes authorization
|
|
394
|
+
* codes, transactions and refresh-token mappings through it, and single-use
|
|
395
|
+
* enforcement depends on the atomicity. Without it the proxy falls back to a
|
|
396
|
+
* non-atomic get + delete, where two concurrent requests can both redeem the
|
|
397
|
+
* same authorization code, or both redeem the same refresh token and walk
|
|
398
|
+
* away with two independent token chains.
|
|
396
399
|
*
|
|
397
400
|
* Most backends expose a suitable primitive: Redis `GETDEL`, DynamoDB
|
|
398
401
|
* `DeleteItem` with `ReturnValues: "ALL_OLD"`, or SQL
|
|
@@ -604,10 +607,27 @@ declare class OAuthProxy {
|
|
|
604
607
|
* Refresh upstream tokens with provider
|
|
605
608
|
*/
|
|
606
609
|
private refreshUpstreamTokens;
|
|
610
|
+
/**
|
|
611
|
+
* Put a claimed refresh-token mapping back after a rotation failed, keeping
|
|
612
|
+
* whatever lifetime it had left.
|
|
613
|
+
*
|
|
614
|
+
* A mapping that is already expired, or that carries no usable expiry, is
|
|
615
|
+
* dropped instead. Inventing a TTL here would extend the lifetime of a
|
|
616
|
+
* credential in a security path, and every mapping this proxy writes records
|
|
617
|
+
* `expiresAt`.
|
|
618
|
+
*/
|
|
619
|
+
private restoreMapping;
|
|
607
620
|
/**
|
|
608
621
|
* Start periodic cleanup of expired transactions and codes
|
|
609
622
|
*/
|
|
610
623
|
private startCleanup;
|
|
624
|
+
/**
|
|
625
|
+
* Atomically claim a token mapping, mirroring `OAuthProxyStateStore`: at most
|
|
626
|
+
* one caller — across all processes sharing the storage — can receive a given
|
|
627
|
+
* mapping, which is what makes single use enforceable. Falls back to a
|
|
628
|
+
* non-atomic get + delete for storages that do not implement `take`.
|
|
629
|
+
*/
|
|
630
|
+
private takeMapping;
|
|
611
631
|
/**
|
|
612
632
|
* Validate a redirect URI against the configured allow-list.
|
|
613
633
|
*
|
package/dist/auth/index.cjs
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
var
|
|
27
|
+
var _chunkRQ6222DUcjs = require('../chunk-RQ6222DU.cjs');
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
|
|
@@ -51,5 +51,5 @@ var _chunkENMHHQJFcjs = require('../chunk-ENMHHQJF.cjs');
|
|
|
51
51
|
|
|
52
52
|
|
|
53
53
|
|
|
54
|
-
exports.AuthProvider =
|
|
54
|
+
exports.AuthProvider = _chunkRQ6222DUcjs.AuthProvider; exports.AzureProvider = _chunkRQ6222DUcjs.AzureProvider; exports.ConsentManager = _chunkRQ6222DUcjs.ConsentManager; exports.DEFAULT_ACCESS_TOKEN_TTL = _chunkRQ6222DUcjs.DEFAULT_ACCESS_TOKEN_TTL; exports.DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH = _chunkRQ6222DUcjs.DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH; exports.DEFAULT_AUTHORIZATION_CODE_TTL = _chunkRQ6222DUcjs.DEFAULT_AUTHORIZATION_CODE_TTL; exports.DEFAULT_REFRESH_TOKEN_TTL = _chunkRQ6222DUcjs.DEFAULT_REFRESH_TOKEN_TTL; exports.DEFAULT_TRANSACTION_TTL = _chunkRQ6222DUcjs.DEFAULT_TRANSACTION_TTL; exports.DiskStore = _chunkRQ6222DUcjs.DiskStore; exports.EncryptedTokenStorage = _chunkRQ6222DUcjs.EncryptedTokenStorage; exports.GitHubProvider = _chunkRQ6222DUcjs.GitHubProvider; exports.GoogleProvider = _chunkRQ6222DUcjs.GoogleProvider; exports.JWKSVerifier = _chunkRQ6222DUcjs.JWKSVerifier; exports.JWTIssuer = _chunkRQ6222DUcjs.JWTIssuer; exports.MemoryTokenStorage = _chunkRQ6222DUcjs.MemoryTokenStorage; exports.OAuthProvider = _chunkRQ6222DUcjs.OAuthProvider; exports.OAuthProxy = _chunkRQ6222DUcjs.OAuthProxy; exports.OAuthProxyError = _chunkRQ6222DUcjs.OAuthProxyError; exports.PKCEUtils = _chunkRQ6222DUcjs.PKCEUtils; exports.getAuthSession = _chunkRQ6222DUcjs.getAuthSession; exports.requireAll = _chunkRQ6222DUcjs.requireAll; exports.requireAny = _chunkRQ6222DUcjs.requireAny; exports.requireAuth = _chunkRQ6222DUcjs.requireAuth; exports.requireRole = _chunkRQ6222DUcjs.requireRole; exports.requireScopes = _chunkRQ6222DUcjs.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-B_OJFNC0.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-B_OJFNC0.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-B_OJFNC0.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-B_OJFNC0.js';
|
|
3
3
|
import 'node:http';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/auth/index.js
CHANGED
|
@@ -1462,6 +1462,7 @@ function parseBasicAuthHeader(authHeader) {
|
|
|
1462
1462
|
return null;
|
|
1463
1463
|
}
|
|
1464
1464
|
}
|
|
1465
|
+
var OAUTH_PROXY_MAX_BODY_SIZE = 1024 * 1024;
|
|
1465
1466
|
function stripBasePath(path, basePath) {
|
|
1466
1467
|
if (!basePath) {
|
|
1467
1468
|
return path;
|
|
@@ -2236,11 +2237,47 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2236
2237
|
try {
|
|
2237
2238
|
if (req.method === "POST" && oauthPath === "/oauth/register") {
|
|
2238
2239
|
await new Promise((resolve) => {
|
|
2239
|
-
|
|
2240
|
-
|
|
2240
|
+
const bodyChunks = [];
|
|
2241
|
+
let bodySize = 0;
|
|
2242
|
+
let failed = false;
|
|
2243
|
+
const fail = () => {
|
|
2244
|
+
if (failed || res.headersSent) {
|
|
2245
|
+
resolve();
|
|
2246
|
+
return;
|
|
2247
|
+
}
|
|
2248
|
+
failed = true;
|
|
2249
|
+
res.writeHead(400, {
|
|
2250
|
+
Connection: "close",
|
|
2251
|
+
"Content-Type": "application/json"
|
|
2252
|
+
}).end(
|
|
2253
|
+
JSON.stringify({
|
|
2254
|
+
error: "invalid_request",
|
|
2255
|
+
error_description: "Request body exceeds 1 MiB"
|
|
2256
|
+
})
|
|
2257
|
+
);
|
|
2258
|
+
resolve();
|
|
2259
|
+
};
|
|
2260
|
+
req.on("data", (chunk) => {
|
|
2261
|
+
if (failed) {
|
|
2262
|
+
return;
|
|
2263
|
+
}
|
|
2264
|
+
bodySize += chunk.length;
|
|
2265
|
+
if (bodySize > OAUTH_PROXY_MAX_BODY_SIZE) {
|
|
2266
|
+
fail();
|
|
2267
|
+
return;
|
|
2268
|
+
}
|
|
2269
|
+
bodyChunks.push(chunk);
|
|
2270
|
+
});
|
|
2271
|
+
req.on("aborted", fail);
|
|
2272
|
+
req.on("error", fail);
|
|
2241
2273
|
req.on("end", async () => {
|
|
2274
|
+
if (failed) {
|
|
2275
|
+
return;
|
|
2276
|
+
}
|
|
2242
2277
|
try {
|
|
2243
|
-
const request = JSON.parse(
|
|
2278
|
+
const request = JSON.parse(
|
|
2279
|
+
Buffer.concat(bodyChunks).toString("utf8")
|
|
2280
|
+
);
|
|
2244
2281
|
const response = await oauthProxy.registerClient(request);
|
|
2245
2282
|
res.writeHead(201, { "Content-Type": "application/json" }).end(JSON.stringify(response));
|
|
2246
2283
|
} catch (error) {
|
|
@@ -2306,14 +2343,48 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2306
2343
|
}
|
|
2307
2344
|
if (req.method === "POST" && oauthPath === "/oauth/consent") {
|
|
2308
2345
|
await new Promise((resolve) => {
|
|
2309
|
-
|
|
2310
|
-
|
|
2346
|
+
const bodyChunks = [];
|
|
2347
|
+
let bodySize = 0;
|
|
2348
|
+
let failed = false;
|
|
2349
|
+
const fail = () => {
|
|
2350
|
+
if (failed || res.headersSent) {
|
|
2351
|
+
resolve();
|
|
2352
|
+
return;
|
|
2353
|
+
}
|
|
2354
|
+
failed = true;
|
|
2355
|
+
res.writeHead(400, {
|
|
2356
|
+
Connection: "close",
|
|
2357
|
+
"Content-Type": "application/json"
|
|
2358
|
+
}).end(
|
|
2359
|
+
JSON.stringify({
|
|
2360
|
+
error: "invalid_request",
|
|
2361
|
+
error_description: "Request body exceeds 1 MiB"
|
|
2362
|
+
})
|
|
2363
|
+
);
|
|
2364
|
+
resolve();
|
|
2365
|
+
};
|
|
2366
|
+
req.on("data", (chunk) => {
|
|
2367
|
+
if (failed) {
|
|
2368
|
+
return;
|
|
2369
|
+
}
|
|
2370
|
+
bodySize += chunk.length;
|
|
2371
|
+
if (bodySize > OAUTH_PROXY_MAX_BODY_SIZE) {
|
|
2372
|
+
fail();
|
|
2373
|
+
return;
|
|
2374
|
+
}
|
|
2375
|
+
bodyChunks.push(chunk);
|
|
2376
|
+
});
|
|
2377
|
+
req.on("aborted", fail);
|
|
2378
|
+
req.on("error", fail);
|
|
2311
2379
|
req.on("end", async () => {
|
|
2380
|
+
if (failed) {
|
|
2381
|
+
return;
|
|
2382
|
+
}
|
|
2312
2383
|
try {
|
|
2313
2384
|
const mockRequest = new Request(
|
|
2314
2385
|
`http://${host}${url2.pathname}${url2.search}`,
|
|
2315
2386
|
{
|
|
2316
|
-
body,
|
|
2387
|
+
body: Buffer.concat(bodyChunks).toString("utf8"),
|
|
2317
2388
|
headers: {
|
|
2318
2389
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
2319
2390
|
},
|
|
@@ -2344,11 +2415,47 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2344
2415
|
}
|
|
2345
2416
|
if (req.method === "POST" && oauthPath === "/oauth/token") {
|
|
2346
2417
|
await new Promise((resolve) => {
|
|
2347
|
-
|
|
2348
|
-
|
|
2418
|
+
const bodyChunks = [];
|
|
2419
|
+
let bodySize = 0;
|
|
2420
|
+
let failed = false;
|
|
2421
|
+
const fail = () => {
|
|
2422
|
+
if (failed || res.headersSent) {
|
|
2423
|
+
resolve();
|
|
2424
|
+
return;
|
|
2425
|
+
}
|
|
2426
|
+
failed = true;
|
|
2427
|
+
res.writeHead(400, {
|
|
2428
|
+
Connection: "close",
|
|
2429
|
+
"Content-Type": "application/json"
|
|
2430
|
+
}).end(
|
|
2431
|
+
JSON.stringify({
|
|
2432
|
+
error: "invalid_request",
|
|
2433
|
+
error_description: "Request body exceeds 1 MiB"
|
|
2434
|
+
})
|
|
2435
|
+
);
|
|
2436
|
+
resolve();
|
|
2437
|
+
};
|
|
2438
|
+
req.on("data", (chunk) => {
|
|
2439
|
+
if (failed) {
|
|
2440
|
+
return;
|
|
2441
|
+
}
|
|
2442
|
+
bodySize += chunk.length;
|
|
2443
|
+
if (bodySize > OAUTH_PROXY_MAX_BODY_SIZE) {
|
|
2444
|
+
fail();
|
|
2445
|
+
return;
|
|
2446
|
+
}
|
|
2447
|
+
bodyChunks.push(chunk);
|
|
2448
|
+
});
|
|
2449
|
+
req.on("aborted", fail);
|
|
2450
|
+
req.on("error", fail);
|
|
2349
2451
|
req.on("end", async () => {
|
|
2452
|
+
if (failed) {
|
|
2453
|
+
return;
|
|
2454
|
+
}
|
|
2350
2455
|
try {
|
|
2351
|
-
const params = new URLSearchParams(
|
|
2456
|
+
const params = new URLSearchParams(
|
|
2457
|
+
Buffer.concat(bodyChunks).toString("utf8")
|
|
2458
|
+
);
|
|
2352
2459
|
const grantType = params.get("grant_type");
|
|
2353
2460
|
const basicAuth = parseBasicAuthHeader(
|
|
2354
2461
|
req.headers.authorization
|
|
@@ -2548,4 +2655,4 @@ export {
|
|
|
2548
2655
|
FastMCPSession,
|
|
2549
2656
|
FastMCP
|
|
2550
2657
|
};
|
|
2551
|
-
//# sourceMappingURL=chunk-
|
|
2658
|
+
//# sourceMappingURL=chunk-HIIPZVNY.js.map
|