fastmcp 4.29.2 → 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/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-TN6CWWVW.cjs → chunk-4JEDH2ON.cjs} +5 -5
- package/dist/{chunk-TN6CWWVW.cjs.map → chunk-4JEDH2ON.cjs.map} +1 -1
- package/dist/{chunk-T7EFBHCA.js → chunk-5KA6SOWT.js} +2 -2
- package/dist/{chunk-XP4NENWX.cjs → chunk-CZGQ2WTQ.cjs} +81 -30
- package/dist/chunk-CZGQ2WTQ.cjs.map +1 -0
- package/dist/{chunk-PA3GWZUK.js → chunk-XPTUOWUT.js} +82 -31
- package/dist/{chunk-PA3GWZUK.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-XP4NENWX.cjs.map +0 -1
- /package/dist/{chunk-T7EFBHCA.js.map → chunk-5KA6SOWT.js.map} +0 -0
|
@@ -3261,7 +3261,7 @@ var OAuthProvider = class extends AuthProvider {
|
|
|
3261
3261
|
};
|
|
3262
3262
|
|
|
3263
3263
|
// src/auth/utils/diskStore.ts
|
|
3264
|
-
import { randomUUID } from "crypto";
|
|
3264
|
+
import { createHash as createHash3, randomUUID } from "crypto";
|
|
3265
3265
|
import {
|
|
3266
3266
|
mkdir,
|
|
3267
3267
|
readdir,
|
|
@@ -3273,6 +3273,8 @@ import {
|
|
|
3273
3273
|
} from "fs/promises";
|
|
3274
3274
|
import { join } from "path";
|
|
3275
3275
|
import { setTimeout as delay } from "timers/promises";
|
|
3276
|
+
var MAX_ENCODED_KEY_LENGTH = 180;
|
|
3277
|
+
var MAX_FILE_NAME_BYTES = 255;
|
|
3276
3278
|
var DiskStore = class {
|
|
3277
3279
|
cleanupInterval = null;
|
|
3278
3280
|
directory;
|
|
@@ -3322,12 +3324,13 @@ var DiskStore = 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 rm(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 = 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 readFile(filePath, "utf-8");
|
|
3353
|
+
const entry = JSON.parse(content);
|
|
3354
|
+
if (entry.expiresAt < Date.now()) {
|
|
3355
|
+
await rm(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 = 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 rm(legacyPath, { force: true });
|
|
3395
|
+
}
|
|
3387
3396
|
}
|
|
3388
3397
|
/**
|
|
3389
3398
|
* Get the number of stored items
|
|
@@ -3406,14 +3415,21 @@ var DiskStore = 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}.${randomUUID()}.claim${this.fileExtension}`;
|
|
3421
|
+
try {
|
|
3422
|
+
await rename(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 = 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_${createHash3("sha256").update(key, "utf8").digest("hex")}`;
|
|
3483
|
+
}
|
|
3484
|
+
return join(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 : join(this.directory, name);
|
|
3453
3504
|
}
|
|
3454
3505
|
/**
|
|
3455
3506
|
* Windows can temporarily deny replacing a file that is being read. Retry
|
|
@@ -3637,4 +3688,4 @@ export {
|
|
|
3637
3688
|
DiskStore,
|
|
3638
3689
|
JWKSVerifier
|
|
3639
3690
|
};
|
|
3640
|
-
//# sourceMappingURL=chunk-
|
|
3691
|
+
//# sourceMappingURL=chunk-XPTUOWUT.js.map
|