@absolutejs/auth 0.53.2 → 0.53.4

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.
package/dist/index.js CHANGED
@@ -473,6 +473,20 @@ var providers = defineProviders({
473
473
  url: "https://developer.api.autodesk.com/authentication/v2/token"
474
474
  }
475
475
  },
476
+ azureadb2c: {
477
+ authorizationUrl: (config) => `https://${config.tenantSubdomain}.b2clogin.com/${config.tenantSubdomain}.onmicrosoft.com/${config.policy}/oauth2/v2.0/authorize`,
478
+ isOIDC: true,
479
+ isRefreshable: true,
480
+ PKCEMethod: "S256",
481
+ scopeRequired: false,
482
+ subject: ["sub"],
483
+ subjectType: "string",
484
+ tokenRequest: {
485
+ authIn: "body",
486
+ encoding: "application/x-www-form-urlencoded",
487
+ url: (config) => `https://${config.tenantSubdomain}.b2clogin.com/${config.tenantSubdomain}.onmicrosoft.com/${config.policy}/oauth2/v2.0/token`
488
+ }
489
+ },
476
490
  battlenet: {
477
491
  authorizationUrl: "https://oauth.battle.net/authorize",
478
492
  isOIDC: true,
@@ -1211,6 +1225,20 @@ var providers = defineProviders({
1211
1225
  url: "https://api.mercadopago.com/oauth/token"
1212
1226
  }
1213
1227
  },
1228
+ microsoftentraexternalid: {
1229
+ authorizationUrl: (config) => `https://${config.tenantSubdomain}.ciamlogin.com/${config.tenantId}/oauth2/v2.0/authorize`,
1230
+ isOIDC: true,
1231
+ isRefreshable: true,
1232
+ PKCEMethod: "S256",
1233
+ scopeRequired: false,
1234
+ subject: ["sub"],
1235
+ subjectType: "string",
1236
+ tokenRequest: {
1237
+ authIn: "body",
1238
+ encoding: "application/x-www-form-urlencoded",
1239
+ url: (config) => `https://${config.tenantSubdomain}.ciamlogin.com/${config.tenantId}/oauth2/v2.0/token`
1240
+ }
1241
+ },
1214
1242
  microsoftentraid: {
1215
1243
  authorizationUrl: (config) => `https://login.microsoftonline.com/${config.tenantId}/oauth2/v2.0/authorize`,
1216
1244
  isOIDC: true,
@@ -2244,10 +2272,7 @@ var getWithingsProps = async (config) => {
2244
2272
  nonceUrl.searchParams.set("timestamp", timestamp.toString());
2245
2273
  nonceUrl.searchParams.set("signature", hashedSignature);
2246
2274
  const nonceTarget = nonceUrl.toString();
2247
- const nonceResponse = await fetch(nonceTarget, {
2248
- ...h2IfHttps(nonceTarget),
2249
- method: "POST"
2250
- });
2275
+ const nonceResponse = await fetch(nonceTarget, { method: "POST" });
2251
2276
  const nonceData = await nonceResponse.json();
2252
2277
  if (nonceData.status === 0) {
2253
2278
  return {
@@ -2257,10 +2282,6 @@ var getWithingsProps = async (config) => {
2257
2282
  }
2258
2283
  return;
2259
2284
  };
2260
- var h2IfHttps = (url) => {
2261
- const init = url.startsWith("https://") ? { protocol: "http2" } : {};
2262
- return init;
2263
- };
2264
2285
  var hmacSha256 = async (message, secret) => {
2265
2286
  const encoder = new TextEncoder;
2266
2287
  const key = await crypto.subtle.importKey("raw", encoder.encode(secret), { hash: "SHA-256", name: "HMAC" }, false, ["sign"]);
@@ -2597,6 +2618,9 @@ var buildOAuth2Client = async (meta, config) => {
2597
2618
  },
2598
2619
  async fetchUserProfile(accessToken) {
2599
2620
  const { profileRequest } = meta;
2621
+ if (!profileRequest) {
2622
+ throw new Error("OIDC provider exposes identity through the id_token and does not define a UserInfo endpoint");
2623
+ }
2600
2624
  const {
2601
2625
  url,
2602
2626
  method,
@@ -2631,10 +2655,7 @@ var buildOAuth2Client = async (meta, config) => {
2631
2655
  init.body = encoding === "application/json" ? JSON.stringify(resolvedBody) : new URLSearchParams(resolvedBody).toString();
2632
2656
  }
2633
2657
  const profileTarget = endpoint.toString();
2634
- const response = await fetch(profileTarget, {
2635
- ...h2IfHttps(profileTarget),
2636
- ...init
2637
- });
2658
+ const response = await fetch(profileTarget, init);
2638
2659
  if (!response.ok)
2639
2660
  throw await createOAuth2FetchError(response);
2640
2661
  return response.json();
@@ -2659,9 +2680,7 @@ var buildOAuth2Client = async (meta, config) => {
2659
2680
  encoding,
2660
2681
  url: tokenUrl
2661
2682
  });
2662
- const response = await fetch(request, {
2663
- ...h2IfHttps(request.url)
2664
- });
2683
+ const response = await fetch(request);
2665
2684
  if (!response.ok)
2666
2685
  throw await createOAuth2FetchError(response);
2667
2686
  return response.json();
@@ -2715,9 +2734,7 @@ var buildOAuth2Client = async (meta, config) => {
2715
2734
  url: `${endpoint.toString()}?${tokenParamName}=${token}`
2716
2735
  });
2717
2736
  }
2718
- const response = await fetch(request, {
2719
- ...h2IfHttps(request.url)
2720
- });
2737
+ const response = await fetch(request);
2721
2738
  if (!response.ok)
2722
2739
  throw await createOAuth2FetchError(response);
2723
2740
  },
@@ -2749,9 +2766,7 @@ var buildOAuth2Client = async (meta, config) => {
2749
2766
  encoding,
2750
2767
  url: tokenUrl
2751
2768
  });
2752
- const response = await fetch(request, {
2753
- ...h2IfHttps(request.url)
2754
- });
2769
+ const response = await fetch(request);
2755
2770
  if (!response.ok)
2756
2771
  throw await createOAuth2FetchError(response);
2757
2772
  const tokenResponse = await response.json();
@@ -28075,5 +28090,5 @@ export {
28075
28090
  AuthIdentityConflictError
28076
28091
  };
28077
28092
 
28078
- //# debugId=610457B3BCB89FDE64756E2164756E21
28093
+ //# debugId=7629514A0C6523C464756E2164756E21
28079
28094
  //# sourceMappingURL=index.js.map