@absolutejs/auth 0.56.12 → 0.56.13

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/README.md CHANGED
@@ -167,6 +167,14 @@ can therefore keep private key material non-exportable in a KMS or HSM. The
167
167
  adapter must return the 64-byte JOSE ES256 signature (`r || s`); DER conversion
168
168
  belongs at the KMS boundary.
169
169
 
170
+ OIDC providers can retain bounded `previousSigningKeys` containing public
171
+ identity only. The JWKS endpoint publishes the active key first and the
172
+ previous keys behind it, while every new token remains signed exclusively by
173
+ the active key. Provider token exchange, introspection, userinfo, logout hints,
174
+ and agent credential verification select the exact verification key named by
175
+ the JWT `kid`. Remove each previous key only after the longest issued token
176
+ using it has expired; duplicate key IDs fail closed.
177
+
170
178
  ### Features
171
179
 
172
180
  - **Authorization**: Handles the authorization process by generating the authorization URL and redirecting the user to the authentication provider.
@@ -274,6 +274,26 @@ var verifyJwt = async (token, publicJwk) => {
274
274
  payload
275
275
  };
276
276
  };
277
+ var signingVerificationKeys = (active, previous = []) => {
278
+ const keys = [active, ...previous];
279
+ const keyIds = new Set(keys.map(({ kid }) => kid));
280
+ if (keyIds.size !== keys.length)
281
+ throw new Error("OIDC signing key IDs must be unique");
282
+ return keys;
283
+ };
284
+ var verifyJwtWithKeys = async (token, keys) => {
285
+ const [headerSegment] = token.split(".");
286
+ if (!headerSegment)
287
+ return;
288
+ const header = decodeSegment(headerSegment);
289
+ const kid = header?.kid;
290
+ if (typeof kid !== "string" || kid.length === 0)
291
+ return;
292
+ const key = keys.find((candidate) => candidate.kid === kid);
293
+ if (!key)
294
+ return;
295
+ return verifyJwt(token, key.publicJwk);
296
+ };
277
297
 
278
298
  // src/agents/registration.ts
279
299
  var AGENT_CLAIM_GRANT_TYPE = "urn:workos:agent-auth:grant-type:claim";
@@ -1336,6 +1356,7 @@ var createOidcAgentCredentialVerifier = ({
1336
1356
  isUsedDpopJti,
1337
1357
  maxDpopAgeMs,
1338
1358
  publicJwk,
1359
+ publicKeys,
1339
1360
  requireDpop = false,
1340
1361
  resource
1341
1362
  }) => {
@@ -1347,13 +1368,14 @@ var createOidcAgentCredentialVerifier = ({
1347
1368
  const token = authorization.slice(authorization.indexOf(" ") + 1).trim();
1348
1369
  if (token.length === 0)
1349
1370
  return;
1350
- const verified = await verifyJwt(token, publicJwk);
1371
+ const verified = publicKeys ? await verifyJwtWithKeys(token, publicKeys) : await verifyJwt(token, publicJwk);
1351
1372
  const payload = verified?.payload;
1352
1373
  if (payload === undefined || payload.iss !== issuer || typeof payload.exp !== "number" || payload.exp <= Math.floor(Date.now() / MS_PER_SECOND) || !readAudience(payload.aud).includes(resource) || typeof payload.client_id !== "string") {
1353
1374
  return;
1354
1375
  }
1355
1376
  const confirmation = payload.cnf;
1356
- const boundJkt = typeof confirmation === "object" && confirmation !== null && typeof confirmation.jkt === "string" ? confirmation.jkt : undefined;
1377
+ const boundJktValue = typeof confirmation === "object" && confirmation !== null ? Reflect.get(confirmation, "jkt") : undefined;
1378
+ const boundJkt = typeof boundJktValue === "string" ? boundJktValue : undefined;
1357
1379
  if (boundJkt !== undefined || requireDpop) {
1358
1380
  if (!authorization.startsWith("DPoP "))
1359
1381
  return;
@@ -13598,5 +13620,5 @@ export {
13598
13620
  AGENT_CLAIM_GRANT_TYPE
13599
13621
  };
13600
13622
 
13601
- //# debugId=5036CB994778D6CC64756E2164756E21
13623
+ //# debugId=3257C9C351E3F2FA64756E2164756E21
13602
13624
  //# sourceMappingURL=index.js.map