fastmcp 4.24.5 → 4.25.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.
Files changed (37) hide show
  1. package/dist/FastMCP.cjs +3 -3
  2. package/dist/FastMCP.d.cts +2 -2
  3. package/dist/FastMCP.d.ts +2 -2
  4. package/dist/FastMCP.js +2 -2
  5. package/dist/{OAuthProvider-84BWWDBF.d.cts → OAuthProvider-BGtNEdC3.d.cts} +14 -0
  6. package/dist/{OAuthProvider-84BWWDBF.d.ts → OAuthProvider-BGtNEdC3.d.ts} +14 -0
  7. package/dist/auth/index.cjs +2 -2
  8. package/dist/auth/index.d.cts +2 -2
  9. package/dist/auth/index.d.ts +2 -2
  10. package/dist/auth/index.js +1 -1
  11. package/dist/bin/fastmcp.cjs +1 -0
  12. package/dist/bin/fastmcp.cjs.map +1 -1
  13. package/dist/bin/fastmcp.js +1 -0
  14. package/dist/bin/fastmcp.js.map +1 -1
  15. package/dist/{chunk-P56ABHAK.cjs → chunk-AJE7ERFM.cjs} +5 -5
  16. package/dist/{chunk-P56ABHAK.cjs.map → chunk-AJE7ERFM.cjs.map} +1 -1
  17. package/dist/{chunk-BV4PWTT6.cjs → chunk-B7IXBMHV.cjs} +32 -1
  18. package/dist/chunk-B7IXBMHV.cjs.map +1 -0
  19. package/dist/{chunk-CAQLTSJ5.js → chunk-JFHOYU3S.js} +32 -1
  20. package/dist/chunk-JFHOYU3S.js.map +1 -0
  21. package/dist/{chunk-UYV7MFKA.js → chunk-PU3JOW7T.js} +2 -2
  22. package/dist/edge/index.cjs +6 -6
  23. package/dist/edge/index.cjs.map +1 -1
  24. package/dist/edge/index.js +6 -6
  25. package/dist/edge/index.js.map +1 -1
  26. package/dist/examples/custom-routes.cjs +3 -3
  27. package/dist/examples/custom-routes.js +2 -2
  28. package/dist/openapi/index.cjs +48 -34
  29. package/dist/openapi/index.cjs.map +1 -1
  30. package/dist/openapi/index.d.cts +8 -3
  31. package/dist/openapi/index.d.ts +8 -3
  32. package/dist/openapi/index.js +26 -12
  33. package/dist/openapi/index.js.map +1 -1
  34. package/package.json +1 -1
  35. package/dist/chunk-BV4PWTT6.cjs.map +0 -1
  36. package/dist/chunk-CAQLTSJ5.js.map +0 -1
  37. /package/dist/{chunk-UYV7MFKA.js.map → chunk-PU3JOW7T.js.map} +0 -0
@@ -2451,6 +2451,10 @@ var OAuthProxy = class {
2451
2451
  if (contentType.includes("application/x-www-form-urlencoded")) {
2452
2452
  const text = await response.text();
2453
2453
  const params = new URLSearchParams(text);
2454
+ this.rejectUpstreamError({
2455
+ error: params.get("error"),
2456
+ error_description: params.get("error_description")
2457
+ });
2454
2458
  const rawData = {
2455
2459
  access_token: params.get("access_token") || "",
2456
2460
  expires_in: params.get("expires_in") ? parseInt(params.get("expires_in")) : void 0,
@@ -2463,6 +2467,7 @@ var OAuthProxy = class {
2463
2467
  return tokenResponseSchema.parse(rawData);
2464
2468
  }
2465
2469
  const rawJson = await response.json();
2470
+ this.rejectUpstreamError(rawJson);
2466
2471
  return tokenResponseSchema.parse(rawJson);
2467
2472
  }
2468
2473
  /**
@@ -2556,6 +2561,32 @@ var OAuthProxy = class {
2556
2561
  tokenType: tokens.token_type || "Bearer"
2557
2562
  };
2558
2563
  }
2564
+ /**
2565
+ * RFC 6749 §5.2: a provider refuses a token request by naming the error in
2566
+ * the response body. The status that carries it is not fixed — GitHub, whose
2567
+ * own branch exists above, answers every refusal with 200 — so a refusal is
2568
+ * recognised here, from the body, rather than left to fail the token schema
2569
+ * parse. Without this the upstream's own diagnosis (`bad_verification_code`,
2570
+ * `invalid_grant`, …) is replaced by a `ZodError`, which the routes answer as
2571
+ * `server_error` (callback) or `invalid_request` (token).
2572
+ *
2573
+ * The upstream's code is kept as the `OAuthProxyError` code, and its
2574
+ * description when it sent one, so the client is told what the provider
2575
+ * actually refused.
2576
+ */
2577
+ rejectUpstreamError(payload) {
2578
+ if (!payload || typeof payload !== "object") {
2579
+ return;
2580
+ }
2581
+ const { error, error_description } = payload;
2582
+ if (typeof error !== "string" || error === "") {
2583
+ return;
2584
+ }
2585
+ throw new OAuthProxyError(
2586
+ error,
2587
+ typeof error_description === "string" ? error_description : void 0
2588
+ );
2589
+ }
2559
2590
  /**
2560
2591
  * Resolve the client behind a `client_id`: a stored registration if there is
2561
2592
  * one, otherwise — when CIMD is enabled — the client's metadata document.
@@ -3324,4 +3355,4 @@ export {
3324
3355
  DiskStore,
3325
3356
  JWKSVerifier
3326
3357
  };
3327
- //# sourceMappingURL=chunk-CAQLTSJ5.js.map
3358
+ //# sourceMappingURL=chunk-JFHOYU3S.js.map