@absolutejs/auth 0.48.1 → 0.48.3

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,44 +427,44 @@ var providers = defineProviders({
427
427
  url: "https://www.bungie.net/Platform/App/OAuth/token"
428
428
  }
429
429
  },
430
- close: {
431
- authorizationUrl: "https://app.close.com/oauth2/authorize/",
430
+ calendly: {
431
+ authorizationUrl: "https://auth.calendly.com/oauth/authorize",
432
+ email: ["resource", "email"],
433
+ fullName: ["resource", "name"],
432
434
  isOIDC: false,
433
435
  isRefreshable: true,
434
436
  profileRequest: {
435
437
  authIn: "header",
436
438
  encoding: "application/json",
437
439
  method: "GET",
438
- url: "https://api.close.com/api/v1/me/"
440
+ url: "https://api.calendly.com/users/me"
439
441
  },
440
- scopeRequired: true,
441
- subject: ["id"],
442
+ scopeRequired: false,
443
+ subject: ["resource", "uri"],
442
444
  subjectType: "string",
443
445
  tokenRequest: {
444
446
  authIn: "body",
445
447
  encoding: "application/x-www-form-urlencoded",
446
- url: "https://api.close.com/oauth2/token/"
448
+ url: "https://auth.calendly.com/oauth/token"
447
449
  }
448
450
  },
449
- calendly: {
450
- authorizationUrl: "https://auth.calendly.com/oauth/authorize",
451
- email: ["resource", "email"],
452
- fullName: ["resource", "name"],
451
+ close: {
452
+ authorizationUrl: "https://app.close.com/oauth2/authorize/",
453
453
  isOIDC: false,
454
454
  isRefreshable: true,
455
455
  profileRequest: {
456
456
  authIn: "header",
457
457
  encoding: "application/json",
458
458
  method: "GET",
459
- url: "https://api.calendly.com/users/me"
459
+ url: "https://api.close.com/api/v1/me/"
460
460
  },
461
- scopeRequired: false,
462
- subject: ["resource", "uri"],
461
+ scopeRequired: true,
462
+ subject: ["id"],
463
463
  subjectType: "string",
464
464
  tokenRequest: {
465
465
  authIn: "body",
466
466
  encoding: "application/x-www-form-urlencoded",
467
- url: "https://auth.calendly.com/oauth/token"
467
+ url: "https://api.close.com/oauth2/token/"
468
468
  }
469
469
  },
470
470
  coinbase: {
@@ -1447,6 +1447,33 @@ var providers = defineProviders({
1447
1447
  url: "https://slack.com/api/openid.connect.token"
1448
1448
  }
1449
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
+ },
1450
1477
  spotify: {
1451
1478
  authorizationUrl: "https://accounts.spotify.com/authorize",
1452
1479
  isOIDC: false,
@@ -2360,6 +2387,7 @@ var providerOptions = Object.keys(providers).filter(isValidProviderOption);
2360
2387
  var refreshableProviderOptions = Object.keys(providers).filter(isRefreshableProviderOption);
2361
2388
  var revocableProviderOptions = Object.keys(providers).filter(isRevocableProviderOption);
2362
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);
2363
2391
  var createOAuth2Client = async (providerName, config) => {
2364
2392
  const meta = providers[providerName];
2365
2393
  const isConfigPropertyFunction = (cfgProp) => typeof cfgProp === "function";
@@ -2381,7 +2409,7 @@ var createOAuth2Client = async (providerName, config) => {
2381
2409
  url.searchParams.set("state", state);
2382
2410
  if (scope.length !== 0) {
2383
2411
  const delimeter = providerName === "withings" ? "," : " ";
2384
- url.searchParams.set("scope", scope.join(delimeter));
2412
+ url.searchParams.set(meta.scopeParamName ?? "scope", scope.join(delimeter));
2385
2413
  }
2386
2414
  if (meta.PKCEMethod !== undefined) {
2387
2415
  if (!codeVerifier) {
@@ -2552,7 +2580,12 @@ var createOAuth2Client = async (providerName, config) => {
2552
2580
  });
2553
2581
  if (!response.ok)
2554
2582
  throw await createOAuth2FetchError(response);
2555
- 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;
2556
2589
  }
2557
2590
  };
2558
2591
  };
@@ -2642,5 +2675,5 @@ export {
2642
2675
  escapeHtml
2643
2676
  };
2644
2677
 
2645
- //# debugId=BAE11A7B44BBB8D664756E2164756E21
2678
+ //# debugId=115348D67515B56F64756E2164756E21
2646
2679
  //# sourceMappingURL=index.js.map