@vitemcp/server 1.6.0 → 1.6.2

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.
@@ -665,7 +665,19 @@ declare class OAuthProxy {
665
665
  */
666
666
  private issueSwappedTokensForRefresh;
667
667
  /**
668
- * Match URI against pattern (supports wildcards)
668
+ * Match a URI against an allow-list glob: `*` spans any run of characters,
669
+ * `?` exactly one, and everything else is literal.
670
+ *
671
+ * "Everything else is literal" is the security-relevant half. Left unescaped,
672
+ * a `.` reaches the RegExp as "any character", so the pattern an operator
673
+ * wrote for one host — `https://client.example.com/*` — also admits
674
+ * `https://clientXexampleYcom/steal`, a name an attacker can register. DCR
675
+ * would accept it and `handleCallback()` would later 302 a fresh
676
+ * authorization code to it, reopening the CWE-601 path this allow-list
677
+ * exists to close. `+ ^ $ ( ) [ ] { } |` widen a pattern the same way.
678
+ *
679
+ * Escaping and wildcard expansion happen in one pass, so a backslash this
680
+ * inserts can never be re-read as the metacharacter of a later pass.
669
681
  */
670
682
  private matchesPattern;
671
683
  /**
@@ -665,7 +665,19 @@ declare class OAuthProxy {
665
665
  */
666
666
  private issueSwappedTokensForRefresh;
667
667
  /**
668
- * Match URI against pattern (supports wildcards)
668
+ * Match a URI against an allow-list glob: `*` spans any run of characters,
669
+ * `?` exactly one, and everything else is literal.
670
+ *
671
+ * "Everything else is literal" is the security-relevant half. Left unescaped,
672
+ * a `.` reaches the RegExp as "any character", so the pattern an operator
673
+ * wrote for one host — `https://client.example.com/*` — also admits
674
+ * `https://clientXexampleYcom/steal`, a name an attacker can register. DCR
675
+ * would accept it and `handleCallback()` would later 302 a fresh
676
+ * authorization code to it, reopening the CWE-601 path this allow-list
677
+ * exists to close. `+ ^ $ ( ) [ ] { } |` widen a pattern the same way.
678
+ *
679
+ * Escaping and wildcard expansion happen in one pass, so a backslash this
680
+ * inserts can never be re-read as the metacharacter of a later pass.
669
681
  */
670
682
  private matchesPattern;
671
683
  /**
package/dist/ViteMCP.cjs CHANGED
@@ -12,7 +12,7 @@
12
12
 
13
13
 
14
14
 
15
- var _chunkXC4BVJQZcjs = require('./chunk-XC4BVJQZ.cjs');
15
+ var _chunk54WICBSYcjs = require('./chunk-54WICBSY.cjs');
16
16
 
17
17
  // src/ViteMCP.ts
18
18
 
@@ -105,6 +105,10 @@ var tooLarge = {
105
105
  error: "invalid_request",
106
106
  error_description: `Request body exceeds ${OAUTH_PROXY_MAX_BODY_SIZE / (1024 * 1024)} MiB`
107
107
  };
108
+ var noStore = {
109
+ "Cache-Control": "no-store",
110
+ Pragma: "no-cache"
111
+ };
108
112
  var toSnakeCase = (value) => {
109
113
  if (!value || typeof value !== "object" || Array.isArray(value)) {
110
114
  return value;
@@ -142,13 +146,13 @@ var createOAuthRouter = (options) => {
142
146
  app.post(`${basePath}/oauth/register`, async (c) => {
143
147
  const body = await readJsonBody(c.req.raw);
144
148
  if (body === null) {
145
- return c.json(tooLarge, 400);
149
+ return c.json(tooLarge, 400, noStore);
146
150
  }
147
151
  try {
148
- return c.json(await proxy.registerClient(body), 201);
152
+ return c.json(await proxy.registerClient(body), 201, noStore);
149
153
  } catch (error) {
150
154
  const { body: errBody, status } = errorResponse(error);
151
- return c.json(errBody, status);
155
+ return c.json(errBody, status, noStore);
152
156
  }
153
157
  });
154
158
  app.get(`${basePath}/oauth/authorize`, async (c) => {
@@ -166,7 +170,7 @@ var createOAuthRouter = (options) => {
166
170
  const raw = c.req.raw;
167
171
  const text = await readCappedBody(raw);
168
172
  if (text === null) {
169
- return c.json(tooLarge, 400);
173
+ return c.json(tooLarge, 400, noStore);
170
174
  }
171
175
  try {
172
176
  const params = Object.fromEntries(new URLSearchParams(text).entries());
@@ -184,10 +188,10 @@ var createOAuthRouter = (options) => {
184
188
  }
185
189
  }
186
190
  const result = params.grant_type === "refresh_token" ? await proxy.exchangeRefreshToken(params) : await proxy.exchangeAuthorizationCode(params);
187
- return c.json(result);
191
+ return c.json(result, 200, noStore);
188
192
  } catch (error) {
189
193
  const { body, status } = errorResponse(error);
190
- return c.json(body, status);
194
+ return c.json(body, status, noStore);
191
195
  }
192
196
  });
193
197
  app.get(
@@ -201,6 +205,17 @@ var createOAuthRouter = (options) => {
201
205
  return app;
202
206
  };
203
207
 
208
+ // src/cancelResponseBody.ts
209
+ var cancelResponseBody = async (response) => {
210
+ if (!response.body) {
211
+ return;
212
+ }
213
+ try {
214
+ await response.body.cancel();
215
+ } catch (e4) {
216
+ }
217
+ };
218
+
204
219
  // src/DiscoveryDocumentCache.ts
205
220
  var DiscoveryDocumentCache = class {
206
221
  get size() {
@@ -288,6 +303,7 @@ var DiscoveryDocumentCache = class {
288
303
  throw error;
289
304
  }
290
305
  if (!res.ok) {
306
+ await cancelResponseBody(res);
291
307
  throw new Error(
292
308
  `Failed to fetch discovery document from ${url}: ${res.status} ${res.statusText}`
293
309
  );
@@ -334,7 +350,7 @@ async function compileSchema(schema) {
334
350
  let ajvModule;
335
351
  try {
336
352
  ajvModule = await Promise.resolve().then(() => _interopRequireWildcard(require("ajv")));
337
- } catch (e4) {
353
+ } catch (e5) {
338
354
  throw new Error(
339
355
  'The "ajv" package is required to validate JSON Schema tool parameters. Install it with: npm install ajv'
340
356
  );
@@ -347,7 +363,7 @@ async function compileSchema(schema) {
347
363
  unwrapDefault(formatsModule)
348
364
  );
349
365
  addFormats(ajv);
350
- } catch (e5) {
366
+ } catch (e6) {
351
367
  }
352
368
  return ajv.compile(schema);
353
369
  }
@@ -395,6 +411,7 @@ var readMedia = async (source, kind) => {
395
411
  signal: AbortSignal.timeout(_nullishCoalesce(source.timeoutMs, () => ( MEDIA_FETCH_TIMEOUT_MS)))
396
412
  });
397
413
  if (!response.ok) {
414
+ await cancelResponseBody(response);
398
415
  throw new Error(`Server responded with status: ${response.status}`);
399
416
  }
400
417
  rawData = Buffer.from(await response.arrayBuffer());
@@ -1335,5 +1352,5 @@ var normalizeToolResult = (result, hasOutputSchema) => {
1335
1352
 
1336
1353
 
1337
1354
 
1338
- exports.AuthProvider = _chunkXC4BVJQZcjs.AuthProvider; exports.AzureProvider = _chunkXC4BVJQZcjs.AzureProvider; exports.DiscoveryDocumentCache = DiscoveryDocumentCache; exports.GitHubProvider = _chunkXC4BVJQZcjs.GitHubProvider; exports.GoogleProvider = _chunkXC4BVJQZcjs.GoogleProvider; exports.MEDIA_FETCH_TIMEOUT_MS = MEDIA_FETCH_TIMEOUT_MS; exports.OAuthProvider = _chunkXC4BVJQZcjs.OAuthProvider; exports.OAuthProxy = _chunkXC4BVJQZcjs.OAuthProxy; exports.OAuthProxyError = _chunkXC4BVJQZcjs.OAuthProxyError; exports.ServerState = ServerState; exports.UnexpectedStateError = UnexpectedStateError; exports.UserError = UserError; exports.ViteMCP = ViteMCP; exports.ViteMCPError = ViteMCPError; exports.audioContent = audioContent; exports.delay = _promises3.setTimeout; exports.getAuthSession = _chunkXC4BVJQZcjs.getAuthSession; exports.imageContent = imageContent; exports.jsonSchemaAdapter = jsonSchemaAdapter; exports.requireAll = _chunkXC4BVJQZcjs.requireAll; exports.requireAny = _chunkXC4BVJQZcjs.requireAny; exports.requireAuth = _chunkXC4BVJQZcjs.requireAuth; exports.requireRole = _chunkXC4BVJQZcjs.requireRole; exports.requireScopes = _chunkXC4BVJQZcjs.requireScopes;
1355
+ exports.AuthProvider = _chunk54WICBSYcjs.AuthProvider; exports.AzureProvider = _chunk54WICBSYcjs.AzureProvider; exports.DiscoveryDocumentCache = DiscoveryDocumentCache; exports.GitHubProvider = _chunk54WICBSYcjs.GitHubProvider; exports.GoogleProvider = _chunk54WICBSYcjs.GoogleProvider; exports.MEDIA_FETCH_TIMEOUT_MS = MEDIA_FETCH_TIMEOUT_MS; exports.OAuthProvider = _chunk54WICBSYcjs.OAuthProvider; exports.OAuthProxy = _chunk54WICBSYcjs.OAuthProxy; exports.OAuthProxyError = _chunk54WICBSYcjs.OAuthProxyError; exports.ServerState = ServerState; exports.UnexpectedStateError = UnexpectedStateError; exports.UserError = UserError; exports.ViteMCP = ViteMCP; exports.ViteMCPError = ViteMCPError; exports.audioContent = audioContent; exports.delay = _promises3.setTimeout; exports.getAuthSession = _chunk54WICBSYcjs.getAuthSession; exports.imageContent = imageContent; exports.jsonSchemaAdapter = jsonSchemaAdapter; exports.requireAll = _chunk54WICBSYcjs.requireAll; exports.requireAny = _chunk54WICBSYcjs.requireAny; exports.requireAuth = _chunk54WICBSYcjs.requireAuth; exports.requireRole = _chunk54WICBSYcjs.requireRole; exports.requireScopes = _chunk54WICBSYcjs.requireScopes;
1339
1356
  //# sourceMappingURL=ViteMCP.cjs.map