fastmcp 4.26.2 → 4.28.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 (45) hide show
  1. package/dist/FastMCP.cjs +4 -4
  2. package/dist/FastMCP.d.cts +2 -2
  3. package/dist/FastMCP.d.ts +2 -2
  4. package/dist/FastMCP.js +3 -3
  5. package/dist/{OAuthProvider-B7VDZGyx.d.cts → OAuthProvider-BnQsqcsL.d.cts} +13 -3
  6. package/dist/{OAuthProvider-B7VDZGyx.d.ts → OAuthProvider-BnQsqcsL.d.ts} +13 -3
  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/chunk-2NZFMD6I.cjs +120 -0
  12. package/dist/chunk-2NZFMD6I.cjs.map +1 -0
  13. package/dist/{chunk-W6P57SNV.js → chunk-4ZSNKIR3.js} +37 -5
  14. package/dist/chunk-4ZSNKIR3.js.map +1 -0
  15. package/dist/{chunk-UULT6NOS.cjs → chunk-AAPHX5IG.cjs} +28 -13
  16. package/dist/chunk-AAPHX5IG.cjs.map +1 -0
  17. package/dist/chunk-AM3HVK4Z.js +120 -0
  18. package/dist/chunk-AM3HVK4Z.js.map +1 -0
  19. package/dist/{chunk-ASOZUCE2.js → chunk-EI3KPYSZ.js} +22 -7
  20. package/dist/chunk-EI3KPYSZ.js.map +1 -0
  21. package/dist/{chunk-HVKGDRTL.cjs → chunk-VVAKRLCY.cjs} +37 -5
  22. package/dist/chunk-VVAKRLCY.cjs.map +1 -0
  23. package/dist/edge/index.cjs +61 -43
  24. package/dist/edge/index.cjs.map +1 -1
  25. package/dist/edge/index.d.cts +0 -6
  26. package/dist/edge/index.d.ts +0 -6
  27. package/dist/edge/index.js +59 -41
  28. package/dist/edge/index.js.map +1 -1
  29. package/dist/examples/custom-routes.cjs +4 -4
  30. package/dist/examples/custom-routes.js +3 -3
  31. package/dist/openapi/index.cjs +98 -36
  32. package/dist/openapi/index.cjs.map +1 -1
  33. package/dist/openapi/index.d.cts +4 -4
  34. package/dist/openapi/index.d.ts +4 -4
  35. package/dist/openapi/index.js +88 -26
  36. package/dist/openapi/index.js.map +1 -1
  37. package/package.json +1 -1
  38. package/dist/chunk-6TDYSPLC.cjs +0 -44
  39. package/dist/chunk-6TDYSPLC.cjs.map +0 -1
  40. package/dist/chunk-ASOZUCE2.js.map +0 -1
  41. package/dist/chunk-HVKGDRTL.cjs.map +0 -1
  42. package/dist/chunk-OKKFL2M4.js +0 -44
  43. package/dist/chunk-OKKFL2M4.js.map +0 -1
  44. package/dist/chunk-UULT6NOS.cjs.map +0 -1
  45. package/dist/chunk-W6P57SNV.js.map +0 -1
@@ -120,6 +120,7 @@ var clientCodeStorageSchema = _zod.z.object({
120
120
  codeChallengeMethod: _zod.z.string(),
121
121
  createdAt: storedDateSchema,
122
122
  expiresAt: storedDateSchema,
123
+ redirectUri: _zod.z.string().optional(),
123
124
  transactionId: _zod.z.string(),
124
125
  upstreamTokens: upstreamTokenSetStorageSchema,
125
126
  used: _zod.z.boolean().optional()
@@ -1610,6 +1611,21 @@ var OAuthProxy = (_class4 = class {
1610
1611
  "Authorization code was issued to another client"
1611
1612
  );
1612
1613
  }
1614
+ if (clientCode.redirectUri !== void 0) {
1615
+ if (request.redirect_uri) {
1616
+ if (request.redirect_uri !== clientCode.redirectUri) {
1617
+ throw new OAuthProxyError(
1618
+ "invalid_grant",
1619
+ "redirect_uri does not match the authorization request"
1620
+ );
1621
+ }
1622
+ } else if (!clientCode.codeChallenge) {
1623
+ throw new OAuthProxyError(
1624
+ "invalid_request",
1625
+ "redirect_uri is required for a code issued without PKCE"
1626
+ );
1627
+ }
1628
+ }
1613
1629
  if (!authenticated && (!clientCode.codeChallenge || clientCode.codeChallengeMethod !== "S256")) {
1614
1630
  throw new OAuthProxyError(
1615
1631
  "invalid_grant",
@@ -1637,6 +1653,11 @@ var OAuthProxy = (_class4 = class {
1637
1653
  if (!valid) {
1638
1654
  throw new OAuthProxyError("invalid_grant", "Invalid PKCE verifier");
1639
1655
  }
1656
+ } else if (request.code_verifier) {
1657
+ throw new OAuthProxyError(
1658
+ "invalid_request",
1659
+ "code_verifier provided without a code_challenge"
1660
+ );
1640
1661
  }
1641
1662
  if (this.config.enableTokenSwap && this.jwtIssuer) {
1642
1663
  return await this.issueSwappedTokens(
@@ -1647,7 +1668,7 @@ var OAuthProxy = (_class4 = class {
1647
1668
  } else {
1648
1669
  const response = {
1649
1670
  access_token: clientCode.upstreamTokens.accessToken,
1650
- expires_in: clientCode.upstreamTokens.expiresIn,
1671
+ expires_in: clientCode.upstreamTokens.expiresIn || 3600,
1651
1672
  token_type: clientCode.upstreamTokens.tokenType
1652
1673
  };
1653
1674
  if (clientCode.upstreamTokens.refreshToken) {
@@ -1707,6 +1728,12 @@ var OAuthProxy = (_class4 = class {
1707
1728
  ]
1708
1729
  };
1709
1730
  }
1731
+ /**
1732
+ * Get the configured OAuth callback path, including the default.
1733
+ */
1734
+ getRedirectPath() {
1735
+ return this.config.redirectPath;
1736
+ }
1710
1737
  /**
1711
1738
  * Handle OAuth callback from upstream provider
1712
1739
  */
@@ -2105,7 +2132,7 @@ var OAuthProxy = (_class4 = class {
2105
2132
  const tokens = await this.parseTokenResponse(tokenResponse);
2106
2133
  return {
2107
2134
  accessToken: tokens.access_token,
2108
- expiresIn: tokens.expires_in || 3600,
2135
+ expiresIn: _nullishCoalesce(tokens.expires_in, () => ( 0)),
2109
2136
  idToken: tokens.id_token,
2110
2137
  issuedAt: /* @__PURE__ */ new Date(),
2111
2138
  refreshExpiresIn: tokens.refresh_expires_in,
@@ -2197,6 +2224,7 @@ var OAuthProxy = (_class4 = class {
2197
2224
  expiresAt: new Date(
2198
2225
  Date.now() + (this.config.authorizationCodeTtl || 300) * 1e3
2199
2226
  ),
2227
+ redirectUri: transaction.clientCallbackUrl,
2200
2228
  transactionId: transaction.id,
2201
2229
  upstreamTokens
2202
2230
  };
@@ -2631,7 +2659,11 @@ var OAuthProxy = (_class4 = class {
2631
2659
  id_token: _zod.z.string().optional(),
2632
2660
  refresh_expires_in: _zod.z.coerce.number().int().positive().optional(),
2633
2661
  refresh_token: _zod.z.string().optional(),
2634
- scope: _zod.z.string().optional(),
2662
+ // GitHub separates scopes with commas; RFC 6749 allows commas inside
2663
+ // a scope token, so other providers must keep them unchanged.
2664
+ scope: _zod.z.string().transform(
2665
+ (scope) => this.config.upstreamTokenEndpoint === "https://github.com/login/oauth/access_token" ? scope.split(/[ ,]+/).filter(Boolean).join(" ") : scope
2666
+ ).optional(),
2635
2667
  token_type: _zod.z.string().optional()
2636
2668
  });
2637
2669
  if (contentType.includes("application/x-www-form-urlencoded")) {
@@ -2738,7 +2770,7 @@ var OAuthProxy = (_class4 = class {
2738
2770
  const tokens = await this.parseTokenResponse(tokenResponse);
2739
2771
  return {
2740
2772
  accessToken: tokens.access_token,
2741
- expiresIn: tokens.expires_in || 3600,
2773
+ expiresIn: _nullishCoalesce(tokens.expires_in, () => ( 0)),
2742
2774
  idToken: tokens.id_token,
2743
2775
  issuedAt: /* @__PURE__ */ new Date(),
2744
2776
  refreshExpiresIn: tokens.refresh_expires_in,
@@ -3579,4 +3611,4 @@ Original error: ${error.message}`
3579
3611
 
3580
3612
 
3581
3613
  exports.cancelResponseBody = cancelResponseBody; exports.getAuthSession = getAuthSession; exports.requireAll = requireAll; exports.requireAny = requireAny; exports.requireAuth = requireAuth; exports.requireRole = requireRole; exports.requireScopes = requireScopes; exports.DEFAULT_ACCESS_TOKEN_TTL = DEFAULT_ACCESS_TOKEN_TTL; exports.DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH = DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH; exports.DEFAULT_REFRESH_TOKEN_TTL = DEFAULT_REFRESH_TOKEN_TTL; exports.TOKEN_ENDPOINT_AUTH_METHODS = TOKEN_ENDPOINT_AUTH_METHODS; exports.DEFAULT_AUTHORIZATION_CODE_TTL = DEFAULT_AUTHORIZATION_CODE_TTL; exports.DEFAULT_TRANSACTION_TTL = DEFAULT_TRANSACTION_TTL; exports.ConsentManager = ConsentManager; exports.JWTIssuer = JWTIssuer; exports.PKCEUtils = PKCEUtils; exports.EncryptedTokenStorage = EncryptedTokenStorage; exports.MemoryTokenStorage = MemoryTokenStorage; exports.OAuthProxy = OAuthProxy; exports.OAuthProxyError = OAuthProxyError; exports.AuthProvider = AuthProvider; exports.AzureProvider = AzureProvider; exports.GitHubProvider = GitHubProvider; exports.GoogleProvider = GoogleProvider; exports.OAuthProvider = OAuthProvider; exports.DiskStore = DiskStore; exports.JWKSVerifier = JWKSVerifier;
3582
- //# sourceMappingURL=chunk-HVKGDRTL.cjs.map
3614
+ //# sourceMappingURL=chunk-VVAKRLCY.cjs.map