@vitemcp/server 1.9.17 → 1.10.1
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 +60 -1
- package/dist/ViteMCP.cjs +4 -4
- package/dist/ViteMCP.d.cts +18 -1
- package/dist/ViteMCP.d.ts +18 -1
- package/dist/ViteMCP.js +3 -3
- package/dist/auth/index.cjs +2 -2
- package/dist/auth/index.d.cts +21 -1
- package/dist/auth/index.d.ts +21 -1
- package/dist/auth/index.js +1 -1
- package/dist/{chunk-B3LLXB6O.js → chunk-3W6VP3KX.js} +32 -11
- package/dist/chunk-3W6VP3KX.js.map +1 -0
- package/dist/{chunk-ZEYQBA72.cjs → chunk-4LU4AXU4.cjs} +83 -39
- package/dist/chunk-4LU4AXU4.cjs.map +1 -0
- package/dist/{chunk-JMDI672G.js → chunk-BLXUZUZ4.js} +16 -1
- package/dist/chunk-BLXUZUZ4.js.map +1 -0
- package/dist/{chunk-TNT3APOK.cjs → chunk-FSPSPB7Y.cjs} +37 -16
- package/dist/chunk-FSPSPB7Y.cjs.map +1 -0
- package/dist/{chunk-4BX2CT5Z.js → chunk-NLBRDP5F.js} +84 -40
- package/dist/{chunk-4BX2CT5Z.js.map → chunk-NLBRDP5F.js.map} +1 -1
- package/dist/{chunk-QPVEGWOL.cjs → chunk-NZGRSB2D.cjs} +17 -2
- package/dist/chunk-NZGRSB2D.cjs.map +1 -0
- package/dist/edge/index.cjs +23 -10
- package/dist/edge/index.cjs.map +1 -1
- package/dist/edge/index.d.cts +11 -0
- package/dist/edge/index.d.ts +11 -0
- package/dist/edge/index.js +19 -6
- package/dist/edge/index.js.map +1 -1
- package/dist/openapi/index.cjs +43 -43
- package/dist/openapi/index.cjs.map +1 -1
- package/dist/openapi/index.js +33 -33
- package/dist/openapi/index.js.map +1 -1
- package/package.json +4 -4
- package/dist/chunk-B3LLXB6O.js.map +0 -1
- package/dist/chunk-JMDI672G.js.map +0 -1
- package/dist/chunk-QPVEGWOL.cjs.map +0 -1
- package/dist/chunk-TNT3APOK.cjs.map +0 -1
- package/dist/chunk-ZEYQBA72.cjs.map +0 -1
|
@@ -1254,6 +1254,7 @@ function loopbackRedirectMatches(declared, requested) {
|
|
|
1254
1254
|
|
|
1255
1255
|
// src/auth/utils/pkce.ts
|
|
1256
1256
|
import { createHash as createHash2, randomBytes as randomBytes2, timingSafeEqual as timingSafeEqual3 } from "crypto";
|
|
1257
|
+
var CODE_VERIFIER = /^[A-Za-z0-9._~-]{43,128}$/;
|
|
1257
1258
|
var PKCEUtils = class _PKCEUtils {
|
|
1258
1259
|
/**
|
|
1259
1260
|
* Generate a code challenge from a verifier
|
|
@@ -1309,6 +1310,9 @@ var PKCEUtils = class _PKCEUtils {
|
|
|
1309
1310
|
if (!verifier || !challenge) {
|
|
1310
1311
|
return false;
|
|
1311
1312
|
}
|
|
1313
|
+
if (!CODE_VERIFIER.test(verifier)) {
|
|
1314
|
+
return false;
|
|
1315
|
+
}
|
|
1312
1316
|
if (method === "plain") {
|
|
1313
1317
|
return equalsConstantTime(verifier, challenge);
|
|
1314
1318
|
}
|
|
@@ -3486,7 +3490,7 @@ var OAuthProvider = class extends AuthProvider {
|
|
|
3486
3490
|
};
|
|
3487
3491
|
|
|
3488
3492
|
// src/auth/utils/diskStore.ts
|
|
3489
|
-
import { randomUUID } from "crypto";
|
|
3493
|
+
import { createHash as createHash4, randomUUID } from "crypto";
|
|
3490
3494
|
import {
|
|
3491
3495
|
mkdir,
|
|
3492
3496
|
readdir,
|
|
@@ -3498,6 +3502,7 @@ import {
|
|
|
3498
3502
|
} from "fs/promises";
|
|
3499
3503
|
import { join } from "path";
|
|
3500
3504
|
import { setTimeout as delay } from "timers/promises";
|
|
3505
|
+
var MAX_FILE_NAME_BYTES = 255;
|
|
3501
3506
|
var DiskStore = class {
|
|
3502
3507
|
cleanupInFlight = null;
|
|
3503
3508
|
cleanupInterval = null;
|
|
@@ -3532,12 +3537,13 @@ var DiskStore = class {
|
|
|
3532
3537
|
* Delete a value
|
|
3533
3538
|
*/
|
|
3534
3539
|
async delete(key) {
|
|
3535
|
-
const filePath
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3540
|
+
for (const filePath of this.getFilePaths(key)) {
|
|
3541
|
+
try {
|
|
3542
|
+
await rm(filePath);
|
|
3543
|
+
} catch (error) {
|
|
3544
|
+
if (error.code !== "ENOENT") {
|
|
3545
|
+
console.error(`Failed to delete key ${key}:`, error);
|
|
3546
|
+
}
|
|
3541
3547
|
}
|
|
3542
3548
|
}
|
|
3543
3549
|
}
|
|
@@ -3554,22 +3560,24 @@ var DiskStore = class {
|
|
|
3554
3560
|
* Retrieve a value
|
|
3555
3561
|
*/
|
|
3556
3562
|
async get(key) {
|
|
3557
|
-
const filePath
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3563
|
+
for (const filePath of this.getFilePaths(key)) {
|
|
3564
|
+
try {
|
|
3565
|
+
const content = await readFile(filePath, "utf-8");
|
|
3566
|
+
const entry = JSON.parse(content);
|
|
3567
|
+
if (entry.expiresAt < Date.now()) {
|
|
3568
|
+
await rm(filePath, { force: true });
|
|
3569
|
+
return null;
|
|
3570
|
+
}
|
|
3571
|
+
return entry.value;
|
|
3572
|
+
} catch (error) {
|
|
3573
|
+
if (error.code === "ENOENT") {
|
|
3574
|
+
continue;
|
|
3575
|
+
}
|
|
3576
|
+
console.error(`Failed to read key ${key}:`, error);
|
|
3568
3577
|
return null;
|
|
3569
3578
|
}
|
|
3570
|
-
console.error(`Failed to read key ${key}:`, error);
|
|
3571
|
-
return null;
|
|
3572
3579
|
}
|
|
3580
|
+
return null;
|
|
3573
3581
|
}
|
|
3574
3582
|
/**
|
|
3575
3583
|
* Save a value with optional TTL
|
|
@@ -3594,6 +3602,10 @@ var DiskStore = class {
|
|
|
3594
3602
|
console.error(`Failed to save key ${key}:`, error);
|
|
3595
3603
|
throw error;
|
|
3596
3604
|
}
|
|
3605
|
+
const legacyPath = this.getLegacyFilePath(key);
|
|
3606
|
+
if (legacyPath !== void 0) {
|
|
3607
|
+
await rm(legacyPath, { force: true });
|
|
3608
|
+
}
|
|
3597
3609
|
}
|
|
3598
3610
|
/**
|
|
3599
3611
|
* Get the number of stored items
|
|
@@ -3616,14 +3628,21 @@ var DiskStore = class {
|
|
|
3616
3628
|
* process shares the directory.
|
|
3617
3629
|
*/
|
|
3618
3630
|
async take(key) {
|
|
3619
|
-
|
|
3620
|
-
const
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3631
|
+
let claimPath;
|
|
3632
|
+
for (const filePath of this.getFilePaths(key)) {
|
|
3633
|
+
const candidate = `${filePath}.${randomUUID()}.claim${this.fileExtension}`;
|
|
3634
|
+
try {
|
|
3635
|
+
await rename(filePath, candidate);
|
|
3636
|
+
claimPath = candidate;
|
|
3637
|
+
break;
|
|
3638
|
+
} catch (error) {
|
|
3639
|
+
if (error.code !== "ENOENT") {
|
|
3640
|
+
console.error(`Failed to take key ${key}:`, error);
|
|
3641
|
+
return null;
|
|
3642
|
+
}
|
|
3626
3643
|
}
|
|
3644
|
+
}
|
|
3645
|
+
if (claimPath === void 0) {
|
|
3627
3646
|
return null;
|
|
3628
3647
|
}
|
|
3629
3648
|
try {
|
|
@@ -3655,11 +3674,37 @@ var DiskStore = class {
|
|
|
3655
3674
|
}
|
|
3656
3675
|
}
|
|
3657
3676
|
/**
|
|
3658
|
-
* Get file path for a key
|
|
3677
|
+
* Get file path for a key.
|
|
3678
|
+
*
|
|
3679
|
+
* Named after the key's SHA-256 digest, not the key itself. A digest cannot
|
|
3680
|
+
* climb out of the directory, gives distinct keys distinct files (letter
|
|
3681
|
+
* case included, which macOS and Windows fold by default), always fits the
|
|
3682
|
+
* 255-byte file name limit, and keeps a directory listing from giving the
|
|
3683
|
+
* keys away. The `.` sets it apart from every name an earlier version
|
|
3684
|
+
* wrote, none of which has one before the extension.
|
|
3659
3685
|
*/
|
|
3660
3686
|
getFilePath(key) {
|
|
3661
|
-
const
|
|
3662
|
-
return join(this.directory,
|
|
3687
|
+
const digest = createHash4("sha256").update(key).digest("hex");
|
|
3688
|
+
return join(this.directory, `sha256.${digest}${this.fileExtension}`);
|
|
3689
|
+
}
|
|
3690
|
+
/**
|
|
3691
|
+
* Where a key's entry may be: its own file, then the one an earlier version
|
|
3692
|
+
* would have written, so that entries persisted before an upgrade survive
|
|
3693
|
+
* it.
|
|
3694
|
+
*/
|
|
3695
|
+
getFilePaths(key) {
|
|
3696
|
+
const legacyPath = this.getLegacyFilePath(key);
|
|
3697
|
+
return legacyPath === void 0 ? [this.getFilePath(key)] : [this.getFilePath(key), legacyPath];
|
|
3698
|
+
}
|
|
3699
|
+
/**
|
|
3700
|
+
* The file an earlier version stored a key in, or `undefined` when its name
|
|
3701
|
+
* is too long to have ever been written. Every character outside
|
|
3702
|
+
* `[a-zA-Z0-9_-]` became `_`, so `client:a.b` and `client:a_b` shared a
|
|
3703
|
+
* file, and a key over the limit failed with `ENAMETOOLONG`.
|
|
3704
|
+
*/
|
|
3705
|
+
getLegacyFilePath(key) {
|
|
3706
|
+
const name = `${key.replace(/[^a-zA-Z0-9_-]/g, "_")}${this.fileExtension}`;
|
|
3707
|
+
return Buffer.byteLength(name) > MAX_FILE_NAME_BYTES ? void 0 : join(this.directory, name);
|
|
3663
3708
|
}
|
|
3664
3709
|
/**
|
|
3665
3710
|
* One directory sweep. Always call through {@link cleanup}, which keeps
|
|
@@ -3808,16 +3853,9 @@ var JWKSVerifier = class {
|
|
|
3808
3853
|
if (this.joseLoaded) {
|
|
3809
3854
|
return;
|
|
3810
3855
|
}
|
|
3856
|
+
let jose;
|
|
3811
3857
|
try {
|
|
3812
|
-
|
|
3813
|
-
this.joseLoaded = true;
|
|
3814
|
-
this.jwksCache = this.jose.createRemoteJWKSet(
|
|
3815
|
-
new URL(this.config.jwksUri),
|
|
3816
|
-
{
|
|
3817
|
-
cacheMaxAge: this.config.cacheDuration,
|
|
3818
|
-
cooldownDuration: this.config.cooldownDuration
|
|
3819
|
-
}
|
|
3820
|
-
);
|
|
3858
|
+
jose = await import("jose");
|
|
3821
3859
|
} catch (error) {
|
|
3822
3860
|
throw new Error(
|
|
3823
3861
|
`JWKS verification requires the 'jose' package.
|
|
@@ -3828,6 +3866,12 @@ If you don't need JWKS support, use HS256 signing instead (default).
|
|
|
3828
3866
|
Original error: ${error.message}`
|
|
3829
3867
|
);
|
|
3830
3868
|
}
|
|
3869
|
+
this.jwksCache = jose.createRemoteJWKSet(new URL(this.config.jwksUri), {
|
|
3870
|
+
cacheMaxAge: this.config.cacheDuration,
|
|
3871
|
+
cooldownDuration: this.config.cooldownDuration
|
|
3872
|
+
});
|
|
3873
|
+
this.jose = jose;
|
|
3874
|
+
this.joseLoaded = true;
|
|
3831
3875
|
}
|
|
3832
3876
|
/**
|
|
3833
3877
|
* Parse scope from token payload
|
|
@@ -3875,4 +3919,4 @@ export {
|
|
|
3875
3919
|
DiskStore,
|
|
3876
3920
|
JWKSVerifier
|
|
3877
3921
|
};
|
|
3878
|
-
//# sourceMappingURL=chunk-
|
|
3922
|
+
//# sourceMappingURL=chunk-NLBRDP5F.js.map
|