fastmcp 4.29.1 → 4.30.0
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 +0 -7
- package/dist/FastMCP.cjs +3 -3
- package/dist/FastMCP.js +2 -2
- package/dist/auth/index.cjs +2 -2
- package/dist/auth/index.d.cts +22 -1
- package/dist/auth/index.d.ts +22 -1
- package/dist/auth/index.js +1 -1
- package/dist/{chunk-5EEESM57.cjs → chunk-4JEDH2ON.cjs} +5 -5
- package/dist/{chunk-5EEESM57.cjs.map → chunk-4JEDH2ON.cjs.map} +1 -1
- package/dist/{chunk-VN5SZ6IE.js → chunk-5KA6SOWT.js} +2 -2
- package/dist/{chunk-UHJQUSUX.cjs → chunk-CZGQ2WTQ.cjs} +89 -39
- package/dist/chunk-CZGQ2WTQ.cjs.map +1 -0
- package/dist/{chunk-RWPENEKV.js → chunk-XPTUOWUT.js} +90 -40
- package/dist/{chunk-RWPENEKV.js.map → chunk-XPTUOWUT.js.map} +1 -1
- package/dist/examples/custom-routes.cjs +3 -3
- package/dist/examples/custom-routes.js +2 -2
- package/dist/openapi/index.cjs +66 -10
- package/dist/openapi/index.cjs.map +1 -1
- package/dist/openapi/index.d.cts +2 -0
- package/dist/openapi/index.d.ts +2 -0
- package/dist/openapi/index.js +60 -4
- package/dist/openapi/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-UHJQUSUX.cjs.map +0 -1
- /package/dist/{chunk-VN5SZ6IE.js.map → chunk-5KA6SOWT.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
cancelResponseBody
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-XPTUOWUT.js";
|
|
4
4
|
import {
|
|
5
5
|
objectRootSchema,
|
|
6
6
|
strictInputSchema,
|
|
@@ -3699,4 +3699,4 @@ export {
|
|
|
3699
3699
|
FastMCPSession,
|
|
3700
3700
|
FastMCP
|
|
3701
3701
|
};
|
|
3702
|
-
//# sourceMappingURL=chunk-
|
|
3702
|
+
//# sourceMappingURL=chunk-5KA6SOWT.js.map
|
|
@@ -3273,6 +3273,8 @@ var OAuthProvider = class extends AuthProvider {
|
|
|
3273
3273
|
var _promises = require('fs/promises');
|
|
3274
3274
|
var _path = require('path');
|
|
3275
3275
|
var _promises3 = require('timers/promises');
|
|
3276
|
+
var MAX_ENCODED_KEY_LENGTH = 180;
|
|
3277
|
+
var MAX_FILE_NAME_BYTES = 255;
|
|
3276
3278
|
var DiskStore = (_class5 = class {
|
|
3277
3279
|
__init9() {this.cleanupInterval = null}
|
|
3278
3280
|
|
|
@@ -3322,12 +3324,13 @@ var DiskStore = (_class5 = class {
|
|
|
3322
3324
|
* Delete a value
|
|
3323
3325
|
*/
|
|
3324
3326
|
async delete(key) {
|
|
3325
|
-
const filePath
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3327
|
+
for (const filePath of this.getFilePaths(key)) {
|
|
3328
|
+
try {
|
|
3329
|
+
await _promises.rm.call(void 0, filePath);
|
|
3330
|
+
} catch (error) {
|
|
3331
|
+
if (error.code !== "ENOENT") {
|
|
3332
|
+
console.error(`Failed to delete key ${key}:`, error);
|
|
3333
|
+
}
|
|
3331
3334
|
}
|
|
3332
3335
|
}
|
|
3333
3336
|
}
|
|
@@ -3344,22 +3347,24 @@ var DiskStore = (_class5 = class {
|
|
|
3344
3347
|
* Retrieve a value
|
|
3345
3348
|
*/
|
|
3346
3349
|
async get(key) {
|
|
3347
|
-
const filePath
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3350
|
+
for (const filePath of this.getFilePaths(key)) {
|
|
3351
|
+
try {
|
|
3352
|
+
const content = await _promises.readFile.call(void 0, filePath, "utf-8");
|
|
3353
|
+
const entry = JSON.parse(content);
|
|
3354
|
+
if (entry.expiresAt < Date.now()) {
|
|
3355
|
+
await _promises.rm.call(void 0, filePath);
|
|
3356
|
+
return null;
|
|
3357
|
+
}
|
|
3358
|
+
return entry.value;
|
|
3359
|
+
} catch (error) {
|
|
3360
|
+
if (error.code === "ENOENT") {
|
|
3361
|
+
continue;
|
|
3362
|
+
}
|
|
3363
|
+
console.error(`Failed to read key ${key}:`, error);
|
|
3358
3364
|
return null;
|
|
3359
3365
|
}
|
|
3360
|
-
console.error(`Failed to read key ${key}:`, error);
|
|
3361
|
-
return null;
|
|
3362
3366
|
}
|
|
3367
|
+
return null;
|
|
3363
3368
|
}
|
|
3364
3369
|
/**
|
|
3365
3370
|
* Save a value with optional TTL
|
|
@@ -3384,6 +3389,10 @@ var DiskStore = (_class5 = class {
|
|
|
3384
3389
|
console.error(`Failed to save key ${key}:`, error);
|
|
3385
3390
|
throw error;
|
|
3386
3391
|
}
|
|
3392
|
+
const legacyPath = this.getLegacyFilePath(key);
|
|
3393
|
+
if (legacyPath !== void 0 && legacyPath !== filePath) {
|
|
3394
|
+
await _promises.rm.call(void 0, legacyPath, { force: true });
|
|
3395
|
+
}
|
|
3387
3396
|
}
|
|
3388
3397
|
/**
|
|
3389
3398
|
* Get the number of stored items
|
|
@@ -3406,14 +3415,21 @@ var DiskStore = (_class5 = class {
|
|
|
3406
3415
|
* process shares the directory.
|
|
3407
3416
|
*/
|
|
3408
3417
|
async take(key) {
|
|
3409
|
-
|
|
3410
|
-
const
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3418
|
+
let claimPath;
|
|
3419
|
+
for (const filePath of this.getFilePaths(key)) {
|
|
3420
|
+
const candidate = `${filePath}.${_crypto.randomUUID.call(void 0, )}.claim${this.fileExtension}`;
|
|
3421
|
+
try {
|
|
3422
|
+
await _promises.rename.call(void 0, filePath, candidate);
|
|
3423
|
+
claimPath = candidate;
|
|
3424
|
+
break;
|
|
3425
|
+
} catch (error) {
|
|
3426
|
+
if (error.code !== "ENOENT") {
|
|
3427
|
+
console.error(`Failed to take key ${key}:`, error);
|
|
3428
|
+
return null;
|
|
3429
|
+
}
|
|
3416
3430
|
}
|
|
3431
|
+
}
|
|
3432
|
+
if (claimPath === void 0) {
|
|
3417
3433
|
return null;
|
|
3418
3434
|
}
|
|
3419
3435
|
try {
|
|
@@ -3445,11 +3461,46 @@ var DiskStore = (_class5 = class {
|
|
|
3445
3461
|
}
|
|
3446
3462
|
}
|
|
3447
3463
|
/**
|
|
3448
|
-
* Get file path for a key
|
|
3464
|
+
* Get file path for a key.
|
|
3465
|
+
*
|
|
3466
|
+
* The file name must not let a key escape the directory, and distinct keys
|
|
3467
|
+
* must get distinct files, also on case-insensitive filesystems (the macOS
|
|
3468
|
+
* and Windows defaults). Lowercase letters, digits and `-` are kept; every
|
|
3469
|
+
* other UTF-8 byte, uppercase letters and `_` included, becomes `_` and two
|
|
3470
|
+
* lowercase hex digits, so neither `client:a.b` and `client:a_b` nor
|
|
3471
|
+
* `code:A` and `code:a` share a file. Names that would get too long for
|
|
3472
|
+
* common filesystems are replaced by a SHA-256 digest, under a prefix the
|
|
3473
|
+
* escaping above never produces.
|
|
3449
3474
|
*/
|
|
3450
3475
|
getFilePath(key) {
|
|
3451
|
-
|
|
3452
|
-
|
|
3476
|
+
let name = "";
|
|
3477
|
+
for (const byte of Buffer.from(key, "utf8")) {
|
|
3478
|
+
const char = String.fromCharCode(byte);
|
|
3479
|
+
name += /[a-z0-9-]/.test(char) ? char : `_${byte.toString(16).padStart(2, "0")}`;
|
|
3480
|
+
}
|
|
3481
|
+
if (name.length > MAX_ENCODED_KEY_LENGTH) {
|
|
3482
|
+
name = `_sha256_${_crypto.createHash.call(void 0, "sha256").update(key, "utf8").digest("hex")}`;
|
|
3483
|
+
}
|
|
3484
|
+
return _path.join.call(void 0, this.directory, `${name}${this.fileExtension}`);
|
|
3485
|
+
}
|
|
3486
|
+
/**
|
|
3487
|
+
* The paths a key's entry may be stored at: its current file, then the
|
|
3488
|
+
* file name earlier versions used. The earlier scheme replaced every other
|
|
3489
|
+
* character with `_`, so distinct keys could share a file; it is still read
|
|
3490
|
+
* so that entries persisted before an upgrade survive it.
|
|
3491
|
+
*/
|
|
3492
|
+
getFilePaths(key) {
|
|
3493
|
+
const filePath = this.getFilePath(key);
|
|
3494
|
+
const legacyPath = this.getLegacyFilePath(key);
|
|
3495
|
+
return legacyPath === void 0 || legacyPath === filePath ? [filePath] : [filePath, legacyPath];
|
|
3496
|
+
}
|
|
3497
|
+
/**
|
|
3498
|
+
* The file name earlier versions stored a key under, or `undefined` when
|
|
3499
|
+
* that name is too long to have ever been written.
|
|
3500
|
+
*/
|
|
3501
|
+
getLegacyFilePath(key) {
|
|
3502
|
+
const name = `${key.replace(/[^a-zA-Z0-9_-]/g, "_")}${this.fileExtension}`;
|
|
3503
|
+
return Buffer.byteLength(name) > MAX_FILE_NAME_BYTES ? void 0 : _path.join.call(void 0, this.directory, name);
|
|
3453
3504
|
}
|
|
3454
3505
|
/**
|
|
3455
3506
|
* Windows can temporarily deny replacing a file that is being read. Retry
|
|
@@ -3570,16 +3621,9 @@ var JWKSVerifier = (_class6 = class {
|
|
|
3570
3621
|
if (this.joseLoaded) {
|
|
3571
3622
|
return;
|
|
3572
3623
|
}
|
|
3624
|
+
let jose;
|
|
3573
3625
|
try {
|
|
3574
|
-
|
|
3575
|
-
this.joseLoaded = true;
|
|
3576
|
-
this.jwksCache = this.jose.createRemoteJWKSet(
|
|
3577
|
-
new URL(this.config.jwksUri),
|
|
3578
|
-
{
|
|
3579
|
-
cacheMaxAge: this.config.cacheDuration,
|
|
3580
|
-
cooldownDuration: this.config.cooldownDuration
|
|
3581
|
-
}
|
|
3582
|
-
);
|
|
3626
|
+
jose = await Promise.resolve().then(() => _interopRequireWildcard(require("jose")));
|
|
3583
3627
|
} catch (error) {
|
|
3584
3628
|
throw new Error(
|
|
3585
3629
|
`JWKS verification requires the 'jose' package.
|
|
@@ -3590,6 +3634,12 @@ If you don't need JWKS support, use HS256 signing instead (default).
|
|
|
3590
3634
|
Original error: ${error.message}`
|
|
3591
3635
|
);
|
|
3592
3636
|
}
|
|
3637
|
+
this.jwksCache = jose.createRemoteJWKSet(new URL(this.config.jwksUri), {
|
|
3638
|
+
cacheMaxAge: this.config.cacheDuration,
|
|
3639
|
+
cooldownDuration: this.config.cooldownDuration
|
|
3640
|
+
});
|
|
3641
|
+
this.jose = jose;
|
|
3642
|
+
this.joseLoaded = true;
|
|
3593
3643
|
}
|
|
3594
3644
|
/**
|
|
3595
3645
|
* Parse scope from token payload
|
|
@@ -3638,4 +3688,4 @@ Original error: ${error.message}`
|
|
|
3638
3688
|
|
|
3639
3689
|
|
|
3640
3690
|
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;
|
|
3641
|
-
//# sourceMappingURL=chunk-
|
|
3691
|
+
//# sourceMappingURL=chunk-CZGQ2WTQ.cjs.map
|