Skip to main content

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:

  1. Generate a new key with generateSigningKey and add it to keys.
  2. 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.
  3. After retiredKeyTtl the 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​

ParameterType
optionsSigningKeySetOptions

Returns​

SigningKeySet

Example​

const keySet = createSigningKeySet({
keys: JSON.parse(process.env.OAUTH_SIGNING_KEYS!),
retiredKeyTtl: 3600,
});
keySet.jwks(); // => { keys: [{ kty: 'OKP', crv: 'Ed25519', kid, alg: 'EdDSA', … }] }