@vitemcp/server 1.9.10 → 1.9.11

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.
@@ -2624,6 +2624,10 @@ var OAuthProxy = (_class4 = class {
2624
2624
  if (contentType.includes("application/x-www-form-urlencoded")) {
2625
2625
  const text = await response.text();
2626
2626
  const params = new URLSearchParams(text);
2627
+ this.rejectUpstreamError({
2628
+ error: params.get("error"),
2629
+ error_description: params.get("error_description")
2630
+ });
2627
2631
  const rawData = {
2628
2632
  access_token: params.get("access_token") || "",
2629
2633
  expires_in: params.get("expires_in") ? parseInt(params.get("expires_in")) : void 0,
@@ -2636,6 +2640,7 @@ var OAuthProxy = (_class4 = class {
2636
2640
  return tokenResponseSchema.parse(rawData);
2637
2641
  }
2638
2642
  const rawJson = await response.json();
2643
+ this.rejectUpstreamError(rawJson);
2639
2644
  return tokenResponseSchema.parse(rawJson);
2640
2645
  }
2641
2646
  /**
@@ -2730,6 +2735,29 @@ var OAuthProxy = (_class4 = class {
2730
2735
  tokenType: tokens.token_type || "Bearer"
2731
2736
  };
2732
2737
  }
2738
+ /**
2739
+ * Throws the error a provider's token response reports, if it reports one.
2740
+ *
2741
+ * RFC 6749 §5.2 fixes the fields of a refusal, not the status that carries
2742
+ * it, and GitHub answers a refused token request with a 200. Read as a
2743
+ * token, that body failed the schema for want of an access token, and the
2744
+ * client was told its own request was malformed (`invalid_request`) instead
2745
+ * of what the provider refused. The provider's code and description are
2746
+ * passed on, as the non-2xx paths already do.
2747
+ */
2748
+ rejectUpstreamError(payload) {
2749
+ if (!payload || typeof payload !== "object") {
2750
+ return;
2751
+ }
2752
+ const { error, error_description } = payload;
2753
+ if (typeof error !== "string" || error === "") {
2754
+ return;
2755
+ }
2756
+ throw new OAuthProxyError(
2757
+ error,
2758
+ typeof error_description === "string" ? error_description : void 0
2759
+ );
2760
+ }
2733
2761
  /**
2734
2762
  * The client behind a client_id, on whichever leg of the flow asks.
2735
2763
  *
@@ -3628,4 +3656,4 @@ Original error: ${error.message}`
3628
3656
 
3629
3657
 
3630
3658
  exports.withoutTrailingSlash = withoutTrailingSlash; 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.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;
3631
- //# sourceMappingURL=chunk-PNWCRGJY.cjs.map
3659
+ //# sourceMappingURL=chunk-XGRRYN5Y.cjs.map