@absolutejs/auth 0.48.0 → 0.48.2

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.
@@ -427,6 +427,27 @@ var providers = defineProviders({
427
427
  url: "https://www.bungie.net/Platform/App/OAuth/token"
428
428
  }
429
429
  },
430
+ calendly: {
431
+ authorizationUrl: "https://auth.calendly.com/oauth/authorize",
432
+ email: ["resource", "email"],
433
+ fullName: ["resource", "name"],
434
+ isOIDC: false,
435
+ isRefreshable: true,
436
+ profileRequest: {
437
+ authIn: "header",
438
+ encoding: "application/json",
439
+ method: "GET",
440
+ url: "https://api.calendly.com/users/me"
441
+ },
442
+ scopeRequired: false,
443
+ subject: ["resource", "uri"],
444
+ subjectType: "string",
445
+ tokenRequest: {
446
+ authIn: "body",
447
+ encoding: "application/x-www-form-urlencoded",
448
+ url: "https://auth.calendly.com/oauth/token"
449
+ }
450
+ },
430
451
  close: {
431
452
  authorizationUrl: "https://app.close.com/oauth2/authorize/",
432
453
  isOIDC: false,
@@ -1426,6 +1447,33 @@ var providers = defineProviders({
1426
1447
  url: "https://slack.com/api/openid.connect.token"
1427
1448
  }
1428
1449
  },
1450
+ slackuser: {
1451
+ accessTokenPath: ["authed_user", "access_token"],
1452
+ authorizationUrl: "https://slack.com/oauth/v2/authorize",
1453
+ isOIDC: false,
1454
+ isRefreshable: false,
1455
+ profileRequest: {
1456
+ authIn: "header",
1457
+ encoding: "application/json",
1458
+ method: "POST",
1459
+ url: "https://slack.com/api/auth.test"
1460
+ },
1461
+ revocationRequest: {
1462
+ authIn: "body",
1463
+ encoding: "application/json",
1464
+ tokenParamName: "token",
1465
+ url: "https://slack.com/api/auth.revoke"
1466
+ },
1467
+ scopeParamName: "user_scope",
1468
+ scopeRequired: true,
1469
+ subject: ["user_id"],
1470
+ subjectType: "string",
1471
+ tokenRequest: {
1472
+ authIn: "body",
1473
+ encoding: "application/x-www-form-urlencoded",
1474
+ url: "https://slack.com/api/oauth.v2.access"
1475
+ }
1476
+ },
1429
1477
  spotify: {
1430
1478
  authorizationUrl: "https://accounts.spotify.com/authorize",
1431
1479
  isOIDC: false,
@@ -2339,6 +2387,7 @@ var providerOptions = Object.keys(providers).filter(isValidProviderOption);
2339
2387
  var refreshableProviderOptions = Object.keys(providers).filter(isRefreshableProviderOption);
2340
2388
  var revocableProviderOptions = Object.keys(providers).filter(isRevocableProviderOption);
2341
2389
  var scopeRequiredProviderOptions = Object.keys(providers).filter(isScopeRequiredProviderOption);
2390
+ var readPath = (value, path) => path.reduce((cursor, key) => cursor && typeof cursor === "object" ? Reflect.get(cursor, key) : undefined, value);
2342
2391
  var createOAuth2Client = async (providerName, config) => {
2343
2392
  const meta = providers[providerName];
2344
2393
  const isConfigPropertyFunction = (cfgProp) => typeof cfgProp === "function";
@@ -2360,7 +2409,7 @@ var createOAuth2Client = async (providerName, config) => {
2360
2409
  url.searchParams.set("state", state);
2361
2410
  if (scope.length !== 0) {
2362
2411
  const delimeter = providerName === "withings" ? "," : " ";
2363
- url.searchParams.set("scope", scope.join(delimeter));
2412
+ url.searchParams.set(meta.scopeParamName ?? "scope", scope.join(delimeter));
2364
2413
  }
2365
2414
  if (meta.PKCEMethod !== undefined) {
2366
2415
  if (!codeVerifier) {
@@ -2531,7 +2580,12 @@ var createOAuth2Client = async (providerName, config) => {
2531
2580
  });
2532
2581
  if (!response.ok)
2533
2582
  throw await createOAuth2FetchError(response);
2534
- return response.json();
2583
+ const tokenResponse = await response.json();
2584
+ const nestedToken = meta.accessTokenPath ? readPath(tokenResponse, meta.accessTokenPath) : undefined;
2585
+ if (typeof nestedToken === "string" && nestedToken.length > 0 && tokenResponse && typeof tokenResponse === "object") {
2586
+ tokenResponse.access_token = nestedToken;
2587
+ }
2588
+ return tokenResponse;
2535
2589
  }
2536
2590
  };
2537
2591
  };
@@ -2621,5 +2675,5 @@ export {
2621
2675
  escapeHtml
2622
2676
  };
2623
2677
 
2624
- //# debugId=1B6BFEB492458D1364756E2164756E21
2678
+ //# debugId=115348D67515B56F64756E2164756E21
2625
2679
  //# sourceMappingURL=index.js.map