fastmcp 4.26.1 → 4.26.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 +8 -4
- 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-5T2VSp7V.d.cts → OAuthProvider-B7VDZGyx.d.cts} +21 -2
- package/dist/{OAuthProvider-5T2VSp7V.d.ts → OAuthProvider-B7VDZGyx.d.ts} +21 -2
- 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-GUHJKVLX.js → chunk-ASOZUCE2.js} +119 -6
- package/dist/chunk-ASOZUCE2.js.map +1 -0
- package/dist/{chunk-UNS6EZVP.cjs → chunk-HVKGDRTL.cjs} +87 -14
- package/dist/chunk-HVKGDRTL.cjs.map +1 -0
- package/dist/{chunk-MT5SJOZ5.cjs → chunk-UULT6NOS.cjs} +124 -11
- package/dist/chunk-UULT6NOS.cjs.map +1 -0
- package/dist/{chunk-KYUSH4TQ.js → chunk-W6P57SNV.js} +85 -12
- package/dist/chunk-W6P57SNV.js.map +1 -0
- package/dist/examples/custom-routes.cjs +3 -3
- package/dist/examples/custom-routes.js +2 -2
- package/dist/openapi/index.cjs +8 -8
- package/dist/openapi/index.d.cts +1 -1
- package/dist/openapi/index.d.ts +1 -1
- package/dist/openapi/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-GUHJKVLX.js.map +0 -1
- package/dist/chunk-KYUSH4TQ.js.map +0 -1
- package/dist/chunk-MT5SJOZ5.cjs.map +0 -1
- package/dist/chunk-UNS6EZVP.cjs.map +0 -1
|
@@ -1386,6 +1386,13 @@ var MemoryTokenStorage = (_class3 = class {
|
|
|
1386
1386
|
}, _class3);
|
|
1387
1387
|
|
|
1388
1388
|
// src/auth/OAuthProxy.ts
|
|
1389
|
+
var DEFAULT_PORTS = {
|
|
1390
|
+
"ftp:": "21",
|
|
1391
|
+
"http:": "80",
|
|
1392
|
+
"https:": "443",
|
|
1393
|
+
"ws:": "80",
|
|
1394
|
+
"wss:": "443"
|
|
1395
|
+
};
|
|
1389
1396
|
var CONSENT_COOKIE_VALUE = /^[\w-]{43}$/;
|
|
1390
1397
|
var MAX_CLIENT_REGISTRATION_BYTES = 32 * 1024;
|
|
1391
1398
|
var RESERVED_AUTHORIZATION_PARAMS = /* @__PURE__ */ new Set([
|
|
@@ -1506,6 +1513,12 @@ var OAuthProxy = (_class4 = class {
|
|
|
1506
1513
|
"redirect_uri is not registered for this client"
|
|
1507
1514
|
);
|
|
1508
1515
|
}
|
|
1516
|
+
if (!this.validateRedirectUri(params.redirect_uri)) {
|
|
1517
|
+
throw new OAuthProxyError(
|
|
1518
|
+
"invalid_request",
|
|
1519
|
+
"redirect_uri is no longer allowed"
|
|
1520
|
+
);
|
|
1521
|
+
}
|
|
1509
1522
|
if (params.code_challenge && !params.code_challenge_method) {
|
|
1510
1523
|
throw new OAuthProxyError(
|
|
1511
1524
|
"invalid_request",
|
|
@@ -2572,16 +2585,39 @@ var OAuthProxy = (_class4 = class {
|
|
|
2572
2585
|
return _nullishCoalesce(_optionalChain([registeredClient, 'optionalAccess', _23 => _23.redirectUris, 'access', _24 => _24.includes, 'call', _25 => _25(transaction.clientCallbackUrl)]), () => ( false));
|
|
2573
2586
|
}
|
|
2574
2587
|
/**
|
|
2575
|
-
*
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2588
|
+
* Whether a redirect URI matches a pattern.
|
|
2589
|
+
*
|
|
2590
|
+
* The pattern is a glob over the URI as it is written, and the host the URI
|
|
2591
|
+
* really leads to must match the pattern's host as well: `*` runs past the
|
|
2592
|
+
* end of a host, so the text of `https://*.example.com/*` could otherwise be
|
|
2593
|
+
* found in the path of a URI on any host at all. The URI's host is the one
|
|
2594
|
+
* a browser goes to, which a backslash or a tab can make other than it is
|
|
2595
|
+
* written. The pattern's runs from after `://` to the first `/` or `#`.
|
|
2596
|
+
*
|
|
2597
|
+
* A `?` there may stand for a character, as in `localhost:30??`, or start
|
|
2598
|
+
* the query, as in `https://app.example.com?source=*`, where the host ends.
|
|
2599
|
+
* A URI may match the pattern read any of these ways, if its host matches
|
|
2600
|
+
* the host that reading gives.
|
|
2601
|
+
*/
|
|
2602
|
+
matchesPattern(uri, pattern, parsed) {
|
|
2603
|
+
const scheme = /^[a-z*?][a-z\d+.\-*?]*:\/\//i.exec(pattern);
|
|
2604
|
+
if (!scheme) {
|
|
2605
|
+
return globToRegExp(pattern).test(uri);
|
|
2606
|
+
}
|
|
2607
|
+
const hostStart = scheme[0].length;
|
|
2608
|
+
const length = pattern.slice(hostStart).search(/[/#]/);
|
|
2609
|
+
const hostEnd = length === -1 ? pattern.length : hostStart + length;
|
|
2610
|
+
if (globToRegExp(pattern).test(uri) && leadsToHost(parsed, pattern.slice(hostStart, hostEnd))) {
|
|
2611
|
+
return true;
|
|
2612
|
+
}
|
|
2613
|
+
for (let query = hostStart; query < hostEnd; query++) {
|
|
2614
|
+
if (pattern[query] === "?" && new RegExp(
|
|
2615
|
+
`^${globSource(pattern.slice(0, query))}\\?${globSource(pattern.slice(query + 1))}$`
|
|
2616
|
+
).test(uri) && leadsToHost(parsed, pattern.slice(hostStart, query))) {
|
|
2617
|
+
return true;
|
|
2618
|
+
}
|
|
2619
|
+
}
|
|
2620
|
+
return false;
|
|
2585
2621
|
}
|
|
2586
2622
|
/**
|
|
2587
2623
|
* Parse token response that can be either JSON or URL-encoded
|
|
@@ -2858,7 +2894,7 @@ var OAuthProxy = (_class4 = class {
|
|
|
2858
2894
|
"http://127.0.0.1:*"
|
|
2859
2895
|
]));
|
|
2860
2896
|
return effectivePatterns.some(
|
|
2861
|
-
(pattern) => this.matchesPattern(uri, pattern)
|
|
2897
|
+
(pattern) => this.matchesPattern(uri, pattern, parsed)
|
|
2862
2898
|
);
|
|
2863
2899
|
}
|
|
2864
2900
|
}, _class4);
|
|
@@ -2872,6 +2908,43 @@ var describeUnauthenticatedClient = (client) => {
|
|
|
2872
2908
|
}
|
|
2873
2909
|
return "clients that do not authenticate with their client_secret";
|
|
2874
2910
|
};
|
|
2911
|
+
var leadsToHost = (uri, host) => {
|
|
2912
|
+
const portStart = host.lastIndexOf(":");
|
|
2913
|
+
const hasPort = portStart > host.lastIndexOf("]");
|
|
2914
|
+
const name = writeHostName(
|
|
2915
|
+
uri.protocol,
|
|
2916
|
+
hasPort ? host.slice(0, portStart) : host
|
|
2917
|
+
);
|
|
2918
|
+
const trailing = /[*?]*$/.exec(name)[0];
|
|
2919
|
+
const nameSource = /^\*+$/.test(name) ? ".*" : globSource(name.slice(0, name.length - trailing.length)) + trailing.replace(/\*/g, "[^.]*").replace(/\?/g, "[^.]");
|
|
2920
|
+
const expected = new RegExp(
|
|
2921
|
+
`^${nameSource}${hasPort ? globSource(host.slice(portStart)) : ""}$`
|
|
2922
|
+
);
|
|
2923
|
+
const candidates = [uri.host.toLowerCase()];
|
|
2924
|
+
const defaultPort = DEFAULT_PORTS[uri.protocol];
|
|
2925
|
+
if (uri.port === "" && defaultPort) {
|
|
2926
|
+
candidates.push(`${uri.hostname.toLowerCase()}:${defaultPort}`);
|
|
2927
|
+
}
|
|
2928
|
+
return candidates.some((candidate) => expected.test(candidate));
|
|
2929
|
+
};
|
|
2930
|
+
var writeHostName = (protocol, name) => {
|
|
2931
|
+
if (/[?#/\\@]/.test(name)) {
|
|
2932
|
+
return name.toLowerCase();
|
|
2933
|
+
}
|
|
2934
|
+
try {
|
|
2935
|
+
const { hostname } = new URL(`${protocol}//${name}`);
|
|
2936
|
+
if (hostname.split("*").length === name.split("*").length) {
|
|
2937
|
+
return hostname.toLowerCase();
|
|
2938
|
+
}
|
|
2939
|
+
} catch (e13) {
|
|
2940
|
+
}
|
|
2941
|
+
return name.toLowerCase();
|
|
2942
|
+
};
|
|
2943
|
+
var globSource = (glob) => glob.replace(
|
|
2944
|
+
/[.*+?^${}()|[\]\\]/g,
|
|
2945
|
+
(char) => char === "*" ? ".*" : char === "?" ? "." : "\\" + char
|
|
2946
|
+
);
|
|
2947
|
+
var globToRegExp = (glob) => new RegExp(`^${globSource(glob)}$`);
|
|
2875
2948
|
var isTokenEndpointAuthMethod = (value) => TOKEN_ENDPOINT_AUTH_METHODS.includes(value);
|
|
2876
2949
|
var sha256 = (value) => _crypto.createHash.call(void 0, "sha256").update(value).digest("base64url");
|
|
2877
2950
|
var withoutOptionalWhitespace = (value) => value.replace(/^[ \t]+|[ \t]+$/g, "");
|
|
@@ -3178,7 +3251,7 @@ var DiskStore = (_class5 = class {
|
|
|
3178
3251
|
console.warn(`Failed to read/parse file ${file}, deleting:`, error);
|
|
3179
3252
|
try {
|
|
3180
3253
|
await _promises.rm.call(void 0, _path.join.call(void 0, this.directory, file));
|
|
3181
|
-
} catch (
|
|
3254
|
+
} catch (e14) {
|
|
3182
3255
|
}
|
|
3183
3256
|
}
|
|
3184
3257
|
}
|
|
@@ -3261,7 +3334,7 @@ var DiskStore = (_class5 = class {
|
|
|
3261
3334
|
await this.ensureDirectory();
|
|
3262
3335
|
const files = await _promises.readdir.call(void 0, this.directory);
|
|
3263
3336
|
return files.filter((f) => f.endsWith(this.fileExtension)).length;
|
|
3264
|
-
} catch (
|
|
3337
|
+
} catch (e15) {
|
|
3265
3338
|
return 0;
|
|
3266
3339
|
}
|
|
3267
3340
|
}
|
|
@@ -3506,4 +3579,4 @@ Original error: ${error.message}`
|
|
|
3506
3579
|
|
|
3507
3580
|
|
|
3508
3581
|
exports.cancelResponseBody = cancelResponseBody; exports.getAuthSession = getAuthSession; exports.requireAll = requireAll; exports.requireAny = requireAny; exports.requireAuth = requireAuth; exports.requireRole = requireRole; exports.requireScopes = requireScopes; exports.DEFAULT_ACCESS_TOKEN_TTL = DEFAULT_ACCESS_TOKEN_TTL; exports.DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH = DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH; exports.DEFAULT_REFRESH_TOKEN_TTL = DEFAULT_REFRESH_TOKEN_TTL; exports.TOKEN_ENDPOINT_AUTH_METHODS = TOKEN_ENDPOINT_AUTH_METHODS; exports.DEFAULT_AUTHORIZATION_CODE_TTL = DEFAULT_AUTHORIZATION_CODE_TTL; exports.DEFAULT_TRANSACTION_TTL = DEFAULT_TRANSACTION_TTL; exports.ConsentManager = ConsentManager; exports.JWTIssuer = JWTIssuer; exports.PKCEUtils = PKCEUtils; exports.EncryptedTokenStorage = EncryptedTokenStorage; exports.MemoryTokenStorage = MemoryTokenStorage; exports.OAuthProxy = OAuthProxy; exports.OAuthProxyError = OAuthProxyError; exports.AuthProvider = AuthProvider; exports.AzureProvider = AzureProvider; exports.GitHubProvider = GitHubProvider; exports.GoogleProvider = GoogleProvider; exports.OAuthProvider = OAuthProvider; exports.DiskStore = DiskStore; exports.JWKSVerifier = JWKSVerifier;
|
|
3509
|
-
//# sourceMappingURL=chunk-
|
|
3582
|
+
//# sourceMappingURL=chunk-HVKGDRTL.cjs.map
|