@absolutejs/auth 0.52.1 → 0.53.0

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
@@ -4868,6 +4868,11 @@ var REFRESH_TTL_DAYS = 30;
4868
4868
  var DEFAULT_ACCESS_TOKEN_TTL_MS2 = MILLISECONDS_IN_AN_HOUR;
4869
4869
  var DEFAULT_ID_TOKEN_TTL_MS = MILLISECONDS_IN_AN_HOUR;
4870
4870
  var DEFAULT_REFRESH_TOKEN_TTL_MS = MILLISECONDS_IN_A_DAY * REFRESH_TTL_DAYS;
4871
+ var resolveAccessTtl = (ttl, scopes) => {
4872
+ if (typeof ttl === "function")
4873
+ return ttl({ scopes });
4874
+ return ttl ?? DEFAULT_ACCESS_TOKEN_TTL_MS2;
4875
+ };
4871
4876
  var nowSeconds = (milliseconds) => Math.floor(milliseconds / MS_PER_SECOND);
4872
4877
  var narrowScopes = (available, requested) => requested === undefined || requested.length === 0 ? available : requested.filter((scope) => available.includes(scope));
4873
4878
  var RESERVED_ACCESS_CLAIMS = new Set([
@@ -4941,7 +4946,7 @@ var exchangeToken = async ({
4941
4946
  return { error: "invalid_scope", ok: false };
4942
4947
  }
4943
4948
  const scopes = narrowScopes(available, requestedScopes);
4944
- const ttl = config.accessTokenTtlMs ?? DEFAULT_ACCESS_TOKEN_TTL_MS2;
4949
+ const ttl = resolveAccessTtl(config.accessTokenTtlMs, scopes);
4945
4950
  const extraClaims = await config.getAccessTokenClaims?.({
4946
4951
  audience,
4947
4952
  clientId: actorClientId,
@@ -4978,7 +4983,7 @@ var issueTokenSet = async ({
4978
4983
  scopes,
4979
4984
  sub
4980
4985
  }) => {
4981
- const accessTtl = config.accessTokenTtlMs ?? DEFAULT_ACCESS_TOKEN_TTL_MS2;
4986
+ const accessTtl = resolveAccessTtl(config.accessTokenTtlMs, scopes);
4982
4987
  const idTtl = config.idTokenTtlMs ?? DEFAULT_ID_TOKEN_TTL_MS;
4983
4988
  const refreshTtl = config.refreshTokenTtlMs ?? DEFAULT_REFRESH_TOKEN_TTL_MS;
4984
4989
  const accessExtra = await config.getAccessTokenClaims?.({
@@ -28054,5 +28059,5 @@ export {
28054
28059
  AuthIdentityConflictError
28055
28060
  };
28056
28061
 
28057
- //# debugId=9E1C46257073267B64756E2164756E21
28062
+ //# debugId=1AA6ADB109ED877964756E2164756E21
28058
28063
  //# sourceMappingURL=index.js.map