@absolutejs/auth 0.54.4 → 0.54.6

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.
@@ -1811,6 +1811,7 @@ var providers = defineProviders({
1811
1811
  }
1812
1812
  },
1813
1813
  withings: {
1814
+ accessTokenPath: ["body", "access_token"],
1814
1815
  authorizationUrl: "https://account.withings.com/oauth2_user/authorize2",
1815
1816
  isOIDC: false,
1816
1817
  isRefreshable: true,
@@ -2665,10 +2666,21 @@ var buildOAuth2Client = async (meta, config) => {
2665
2666
  if (!response.ok)
2666
2667
  throw await createOAuth2FetchError(response);
2667
2668
  const tokenResponse = await response.json();
2669
+ if (!tokenResponse || typeof tokenResponse !== "object") {
2670
+ throw new Error("OAuth token endpoint returned a non-object response");
2671
+ }
2672
+ const oauthError = Reflect.get(tokenResponse, "error");
2673
+ if (typeof oauthError === "string" && oauthError.length > 0) {
2674
+ throw new Error(`OAuth token exchange failed: ${oauthError}`);
2675
+ }
2668
2676
  const nestedToken = meta.accessTokenPath ? readPath(tokenResponse, meta.accessTokenPath) : undefined;
2669
2677
  if (typeof nestedToken === "string" && nestedToken.length > 0 && tokenResponse && typeof tokenResponse === "object") {
2670
2678
  tokenResponse.access_token = nestedToken;
2671
2679
  }
2680
+ const accessToken = Reflect.get(tokenResponse, "access_token");
2681
+ if (typeof accessToken !== "string" || accessToken.length === 0) {
2682
+ throw new Error("OAuth token endpoint returned no access_token");
2683
+ }
2672
2684
  return tokenResponse;
2673
2685
  }
2674
2686
  };
@@ -2761,5 +2773,5 @@ export {
2761
2773
  escapeHtml
2762
2774
  };
2763
2775
 
2764
- //# debugId=4BFD3282038CF96664756E2164756E21
2776
+ //# debugId=D319F7149F34DA4D64756E2164756E21
2765
2777
  //# sourceMappingURL=index.js.map