@vitemcp/server 1.9.12 → 1.9.14
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/{OAuthProvider-B78zmLtB.d.cts → OAuthProvider-CXNATtVg.d.cts} +22 -3
- package/dist/{OAuthProvider-B78zmLtB.d.ts → OAuthProvider-CXNATtVg.d.ts} +22 -3
- package/dist/ViteMCP.cjs +3 -3
- package/dist/ViteMCP.d.cts +2 -2
- package/dist/ViteMCP.d.ts +2 -2
- package/dist/ViteMCP.js +2 -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-WBP37JPX.js → chunk-2O5Y2H74.js} +3 -3
- package/dist/{chunk-WBP37JPX.js.map → chunk-2O5Y2H74.js.map} +1 -1
- package/dist/{chunk-7T5D57AM.cjs → chunk-7MAOWIMR.cjs} +4 -4
- package/dist/{chunk-7T5D57AM.cjs.map → chunk-7MAOWIMR.cjs.map} +1 -1
- package/dist/{chunk-NZ34AKP4.js → chunk-F37DGG7F.js} +42 -8
- package/dist/chunk-F37DGG7F.js.map +1 -0
- package/dist/{chunk-2X4JCSQQ.cjs → chunk-T7EJGNI3.cjs} +42 -8
- package/dist/chunk-T7EJGNI3.cjs.map +1 -0
- package/dist/openapi/index.cjs +99 -35
- package/dist/openapi/index.cjs.map +1 -1
- package/dist/openapi/index.d.cts +2 -2
- package/dist/openapi/index.d.ts +2 -2
- package/dist/openapi/index.js +82 -18
- package/dist/openapi/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-2X4JCSQQ.cjs.map +0 -1
- package/dist/chunk-NZ34AKP4.js.map +0 -1
|
@@ -378,6 +378,7 @@ var clientCodeStorageSchema = z.object({
|
|
|
378
378
|
codeChallengeMethod: z.string(),
|
|
379
379
|
createdAt: storedDateSchema,
|
|
380
380
|
expiresAt: storedDateSchema,
|
|
381
|
+
redirectUri: z.string().optional(),
|
|
381
382
|
transactionId: z.string(),
|
|
382
383
|
upstreamTokens: upstreamTokenSetStorageSchema,
|
|
383
384
|
used: z.boolean().optional()
|
|
@@ -1460,6 +1461,8 @@ var MemoryTokenStorage = class {
|
|
|
1460
1461
|
var withoutTrailingSlash = (url) => url.replace(/\/+$/, "");
|
|
1461
1462
|
|
|
1462
1463
|
// src/auth/OAuthProxy.ts
|
|
1464
|
+
var DEFAULT_REDIRECT_PATH = "/oauth/callback";
|
|
1465
|
+
var GITHUB_TOKEN_ENDPOINT = "https://github.com/login/oauth/access_token";
|
|
1463
1466
|
var RESERVED_AUTHORIZATION_PARAMS = /* @__PURE__ */ new Set([
|
|
1464
1467
|
"client_id",
|
|
1465
1468
|
"code_challenge",
|
|
@@ -1504,7 +1507,7 @@ var OAuthProxy = class {
|
|
|
1504
1507
|
consentRequired: true,
|
|
1505
1508
|
enableTokenSwap: true,
|
|
1506
1509
|
// Enabled by default for security
|
|
1507
|
-
redirectPath:
|
|
1510
|
+
redirectPath: DEFAULT_REDIRECT_PATH,
|
|
1508
1511
|
transactionTtl: DEFAULT_TRANSACTION_TTL,
|
|
1509
1512
|
upstreamRequestTimeoutMs: DEFAULT_UPSTREAM_REQUEST_TIMEOUT_MS,
|
|
1510
1513
|
upstreamTokenEndpointAuthMethod: "client_secret_basic",
|
|
@@ -1655,6 +1658,12 @@ var OAuthProxy = class {
|
|
|
1655
1658
|
"Authorization code was issued to another client"
|
|
1656
1659
|
);
|
|
1657
1660
|
}
|
|
1661
|
+
if (request2.redirect_uri && clientCode.redirectUri !== void 0 && request2.redirect_uri !== clientCode.redirectUri) {
|
|
1662
|
+
throw new OAuthProxyError(
|
|
1663
|
+
"invalid_grant",
|
|
1664
|
+
"redirect_uri does not match the authorization request"
|
|
1665
|
+
);
|
|
1666
|
+
}
|
|
1658
1667
|
if (!authenticated && (!clientCode.codeChallenge || clientCode.codeChallengeMethod !== "S256")) {
|
|
1659
1668
|
throw new OAuthProxyError(
|
|
1660
1669
|
"invalid_grant",
|
|
@@ -1676,6 +1685,11 @@ var OAuthProxy = class {
|
|
|
1676
1685
|
if (!valid) {
|
|
1677
1686
|
throw new OAuthProxyError("invalid_grant", "Invalid PKCE verifier");
|
|
1678
1687
|
}
|
|
1688
|
+
} else if (request2.code_verifier) {
|
|
1689
|
+
throw new OAuthProxyError(
|
|
1690
|
+
"invalid_request",
|
|
1691
|
+
"code_verifier provided without a code_challenge"
|
|
1692
|
+
);
|
|
1679
1693
|
}
|
|
1680
1694
|
if (this.config.enableTokenSwap && this.jwtIssuer) {
|
|
1681
1695
|
return await this.issueSwappedTokens(
|
|
@@ -1686,7 +1700,7 @@ var OAuthProxy = class {
|
|
|
1686
1700
|
} else {
|
|
1687
1701
|
const response = {
|
|
1688
1702
|
access_token: clientCode.upstreamTokens.accessToken,
|
|
1689
|
-
expires_in: clientCode.upstreamTokens.expiresIn,
|
|
1703
|
+
expires_in: clientCode.upstreamTokens.expiresIn || 3600,
|
|
1690
1704
|
token_type: clientCode.upstreamTokens.tokenType
|
|
1691
1705
|
};
|
|
1692
1706
|
if (clientCode.upstreamTokens.refreshToken) {
|
|
@@ -1748,6 +1762,15 @@ var OAuthProxy = class {
|
|
|
1748
1762
|
tokenEndpointAuthMethodsSupported: [...TOKEN_ENDPOINT_AUTH_METHODS]
|
|
1749
1763
|
};
|
|
1750
1764
|
}
|
|
1765
|
+
/**
|
|
1766
|
+
* The path the upstream provider redirects back to: `redirectPath`, or
|
|
1767
|
+
* `/oauth/callback` when none is set. The router serves the callback here
|
|
1768
|
+
* and the proxy sends `{baseUrl}{path}` upstream as the `redirect_uri`, so
|
|
1769
|
+
* both read it from this one place and cannot disagree.
|
|
1770
|
+
*/
|
|
1771
|
+
getRedirectPath() {
|
|
1772
|
+
return this.config.redirectPath ?? DEFAULT_REDIRECT_PATH;
|
|
1773
|
+
}
|
|
1751
1774
|
/**
|
|
1752
1775
|
* Handle OAuth callback from upstream provider
|
|
1753
1776
|
*/
|
|
@@ -2060,7 +2083,7 @@ var OAuthProxy = class {
|
|
|
2060
2083
|
code,
|
|
2061
2084
|
code_verifier: transaction.proxyCodeVerifier,
|
|
2062
2085
|
grant_type: "authorization_code",
|
|
2063
|
-
redirect_uri: `${this.config.baseUrl}${this.
|
|
2086
|
+
redirect_uri: `${this.config.baseUrl}${this.getRedirectPath()}`
|
|
2064
2087
|
};
|
|
2065
2088
|
if (!useBasicAuth) {
|
|
2066
2089
|
bodyParams.client_id = this.config.upstreamClientId;
|
|
@@ -2088,7 +2111,10 @@ var OAuthProxy = class {
|
|
|
2088
2111
|
const tokens = await this.parseTokenResponse(tokenResponse);
|
|
2089
2112
|
return {
|
|
2090
2113
|
accessToken: tokens.access_token,
|
|
2091
|
-
|
|
2114
|
+
// 0 when the upstream did not say, so `accessTokenTtl` and the defaults
|
|
2115
|
+
// apply. An hour substituted here made every such token look as though
|
|
2116
|
+
// the upstream had set it, and neither was ever reached.
|
|
2117
|
+
expiresIn: tokens.expires_in ?? 0,
|
|
2092
2118
|
idToken: tokens.id_token,
|
|
2093
2119
|
issuedAt: /* @__PURE__ */ new Date(),
|
|
2094
2120
|
refreshExpiresIn: tokens.refresh_expires_in,
|
|
@@ -2180,6 +2206,7 @@ var OAuthProxy = class {
|
|
|
2180
2206
|
expiresAt: new Date(
|
|
2181
2207
|
Date.now() + (this.config.authorizationCodeTtl || 300) * 1e3
|
|
2182
2208
|
),
|
|
2209
|
+
redirectUri: transaction.clientCallbackUrl,
|
|
2183
2210
|
transactionId: transaction.id,
|
|
2184
2211
|
upstreamTokens
|
|
2185
2212
|
};
|
|
@@ -2623,7 +2650,13 @@ var OAuthProxy = class {
|
|
|
2623
2650
|
id_token: z2.string().optional(),
|
|
2624
2651
|
refresh_expires_in: z2.coerce.number().int().positive().optional(),
|
|
2625
2652
|
refresh_token: z2.string().optional(),
|
|
2626
|
-
|
|
2653
|
+
// GitHub lists the scopes it granted with commas, `read:user,user:email`,
|
|
2654
|
+
// which read as one scope that no check matched. RFC 6749 §3.3 separates
|
|
2655
|
+
// scopes with spaces and allows a comma inside one, so only GitHub's are
|
|
2656
|
+
// split.
|
|
2657
|
+
scope: z2.string().transform(
|
|
2658
|
+
(scope) => this.config.upstreamTokenEndpoint === GITHUB_TOKEN_ENDPOINT ? scope.split(/[ ,]+/).filter(Boolean).join(" ") : scope
|
|
2659
|
+
).optional(),
|
|
2627
2660
|
token_type: z2.string().optional()
|
|
2628
2661
|
});
|
|
2629
2662
|
if (contentType.includes("application/x-www-form-urlencoded")) {
|
|
@@ -2674,7 +2707,7 @@ var OAuthProxy = class {
|
|
|
2674
2707
|
authUrl.searchParams.set("client_id", this.config.upstreamClientId);
|
|
2675
2708
|
authUrl.searchParams.set(
|
|
2676
2709
|
"redirect_uri",
|
|
2677
|
-
`${this.config.baseUrl}${this.
|
|
2710
|
+
`${this.config.baseUrl}${this.getRedirectPath()}`
|
|
2678
2711
|
);
|
|
2679
2712
|
authUrl.searchParams.set("response_type", "code");
|
|
2680
2713
|
authUrl.searchParams.set("state", transaction.id);
|
|
@@ -2731,7 +2764,8 @@ var OAuthProxy = class {
|
|
|
2731
2764
|
const tokens = await this.parseTokenResponse(tokenResponse);
|
|
2732
2765
|
return {
|
|
2733
2766
|
accessToken: tokens.access_token,
|
|
2734
|
-
|
|
2767
|
+
// 0 when the upstream did not say, as on the code exchange.
|
|
2768
|
+
expiresIn: tokens.expires_in ?? 0,
|
|
2735
2769
|
idToken: tokens.id_token,
|
|
2736
2770
|
issuedAt: /* @__PURE__ */ new Date(),
|
|
2737
2771
|
refreshExpiresIn: tokens.refresh_expires_in,
|
|
@@ -3661,4 +3695,4 @@ export {
|
|
|
3661
3695
|
DiskStore,
|
|
3662
3696
|
JWKSVerifier
|
|
3663
3697
|
};
|
|
3664
|
-
//# sourceMappingURL=chunk-
|
|
3698
|
+
//# sourceMappingURL=chunk-F37DGG7F.js.map
|