Function: createSigningKeySet()
createSigningKeySet(
options):SigningKeySet
Defined in: auth-core/src/signingKeySet.ts:69
Builds the asymmetric key set an authorization server signs with and publishes as its JWKS, with rotation:
- Generate a new key with
generateSigningKeyand add it tokeys. - Set
retiredAt: Date.now()on the old one — the new key signs from now on, and the old one stays published so tokens it signed keep verifying. - After
retiredKeyTtlthe old key drops out of the JWKS by itself; remove it from config whenever convenient.
Keys are validated up front, so a malformed secret fails at startup.
Parameters
| Parameter | Type |
|---|---|
options | SigningKeySetOptions |
Returns
Example
const keySet = createSigningKeySet({
keys: JSON.parse(process.env.OAUTH_SIGNING_KEYS!),
retiredKeyTtl: 3600,
});
keySet.jwks(); // => { keys: [{ kty: 'OKP', crv: 'Ed25519', kid, alg: 'EdDSA', … }] }