@vitemcp/server 1.9.8 → 1.9.10
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 +10 -0
- package/dist/{OAuthProvider-BaPwgWny.d.cts → OAuthProvider-Dt3F-oDh.d.cts} +54 -0
- package/dist/{OAuthProvider-BaPwgWny.d.ts → OAuthProvider-Dt3F-oDh.d.ts} +54 -0
- 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 +10 -2
- package/dist/auth/index.d.ts +10 -2
- package/dist/auth/index.js +1 -1
- package/dist/bin/vitemcp.cjs +31 -2
- package/dist/bin/vitemcp.cjs.map +1 -1
- package/dist/bin/vitemcp.js +31 -2
- package/dist/bin/vitemcp.js.map +1 -1
- package/dist/{chunk-XU7XBDZI.cjs → chunk-2FAJF3V6.cjs} +62 -15
- package/dist/chunk-2FAJF3V6.cjs.map +1 -0
- package/dist/{chunk-NLFL6ISL.cjs → chunk-PNWCRGJY.cjs} +213 -47
- package/dist/chunk-PNWCRGJY.cjs.map +1 -0
- package/dist/{chunk-QZ6S3FM5.js → chunk-UVKIOOZA.js} +57 -10
- package/dist/{chunk-QZ6S3FM5.js.map → chunk-UVKIOOZA.js.map} +1 -1
- package/dist/{chunk-76HUSLES.js → chunk-ZVK5GKEO.js} +213 -47
- package/dist/chunk-ZVK5GKEO.js.map +1 -0
- package/dist/openapi/index.cjs +12 -12
- 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 +7 -2
- package/dist/chunk-76HUSLES.js.map +0 -1
- package/dist/chunk-NLFL6ISL.cjs.map +0 -1
- package/dist/chunk-XU7XBDZI.cjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
withoutTrailingSlash
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ZVK5GKEO.js";
|
|
4
4
|
import {
|
|
5
5
|
formatBytes,
|
|
6
6
|
ownKeysOnly,
|
|
@@ -106,6 +106,27 @@ var noStore = {
|
|
|
106
106
|
"Cache-Control": "no-store",
|
|
107
107
|
Pragma: "no-cache"
|
|
108
108
|
};
|
|
109
|
+
var invalidClientHeaders = {
|
|
110
|
+
...noStore,
|
|
111
|
+
"WWW-Authenticate": 'Basic realm="oauth", charset="UTF-8"'
|
|
112
|
+
};
|
|
113
|
+
var parseBasicCredentials = (authorization) => {
|
|
114
|
+
const decoded = Buffer.from(authorization.slice(6).trim(), "base64").toString(
|
|
115
|
+
"utf8"
|
|
116
|
+
);
|
|
117
|
+
const separator = decoded.indexOf(":");
|
|
118
|
+
if (separator <= 0) {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
try {
|
|
122
|
+
return {
|
|
123
|
+
clientId: decodeURIComponent(decoded.slice(0, separator)),
|
|
124
|
+
clientSecret: decodeURIComponent(decoded.slice(separator + 1))
|
|
125
|
+
};
|
|
126
|
+
} catch {
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
};
|
|
109
130
|
var toSnakeCase = (value) => {
|
|
110
131
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
111
132
|
return value;
|
|
@@ -173,21 +194,47 @@ var createOAuthRouter = (options) => {
|
|
|
173
194
|
const params = Object.fromEntries(new URLSearchParams(text).entries());
|
|
174
195
|
const authHeader = raw.headers.get("authorization");
|
|
175
196
|
if (authHeader?.toLowerCase().startsWith("basic ")) {
|
|
176
|
-
const
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
197
|
+
const credentials = parseBasicCredentials(authHeader);
|
|
198
|
+
if (!credentials) {
|
|
199
|
+
return c.json(
|
|
200
|
+
{
|
|
201
|
+
error: "invalid_client",
|
|
202
|
+
error_description: "Malformed Basic Authorization header"
|
|
203
|
+
},
|
|
204
|
+
401,
|
|
205
|
+
invalidClientHeaders
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
if (params.client_secret !== void 0) {
|
|
209
|
+
return c.json(
|
|
210
|
+
{
|
|
211
|
+
error: "invalid_request",
|
|
212
|
+
error_description: "Send client credentials in the Authorization header or the request body, not both"
|
|
213
|
+
},
|
|
214
|
+
400,
|
|
215
|
+
noStore
|
|
184
216
|
);
|
|
185
217
|
}
|
|
218
|
+
if (params.client_id !== void 0 && params.client_id !== credentials.clientId) {
|
|
219
|
+
return c.json(
|
|
220
|
+
{
|
|
221
|
+
error: "invalid_request",
|
|
222
|
+
error_description: "client_id in the request body does not match the Authorization header"
|
|
223
|
+
},
|
|
224
|
+
400,
|
|
225
|
+
noStore
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
params.client_id = credentials.clientId;
|
|
229
|
+
params.client_secret = credentials.clientSecret;
|
|
186
230
|
}
|
|
187
231
|
const result = params.grant_type === "refresh_token" ? await proxy.exchangeRefreshToken(params) : await proxy.exchangeAuthorizationCode(params);
|
|
188
232
|
return c.json(result, 200, noStore);
|
|
189
233
|
} catch (error) {
|
|
190
234
|
const { body, status } = errorResponse(error);
|
|
235
|
+
if (body.error === "invalid_client") {
|
|
236
|
+
return c.json(body, 401, invalidClientHeaders);
|
|
237
|
+
}
|
|
191
238
|
return c.json(body, status, noStore);
|
|
192
239
|
}
|
|
193
240
|
});
|
|
@@ -1627,4 +1674,4 @@ export {
|
|
|
1627
1674
|
ServerState,
|
|
1628
1675
|
ViteMCP
|
|
1629
1676
|
};
|
|
1630
|
-
//# sourceMappingURL=chunk-
|
|
1677
|
+
//# sourceMappingURL=chunk-UVKIOOZA.js.map
|