Skip to Content
🎉 BSH Engine v0.0.7 is out with new features and improvements. See what's new →

Signing Keys Service

The Signing Keys Service lists the JWT signing keys, forces a rotation and expires a leaked key.

These methods require a BSH_ADMIN user, or an API key owned by one. See Signing Keys API.

Methods

list

Lists keys with query parameters. Keys are sorted by activatedAt descending by default.

await bshEngine.signingKeys.list({ queryParams: { page: '0', size: '10', sort: 'activatedAt:desc', filter: 'status:eq:Retired' } });
PropertyTypeRequiredDescription
queryParams.pagestringnoPage number
queryParams.sizestringnoPage size
queryParams.sortstringnoSort, for example activatedAt:desc
queryParams.filterstringnoFilter, for example status:eq:Active

Searches keys with a BSH Search payload.

await bshEngine.signingKeys.search({ payload: { filters: [{ field: 'status', operator: 'eq', value: 'Retired' }] } });

rotate

Replaces the active key now. With expire, the previous key (previous) or every retired key (all) is expired at the same time, and every user holding tokens signed by them is logged out.

// Routine rotation: no one is logged out await bshEngine.signingKeys.rotate({ payload: {} }); // The current key leaked const response = await bshEngine.signingKeys.rotate({ payload: { expire: 'previous', reason: 'Key exposed in application logs' } });
PropertyTypeRequiredDescription
payload.expire'none'|'previous'|'all'noKeys to expire right away.
payload.reasonstringwhen expiringWhy the key needs to expire

expire

Expires a retired key now.

await bshEngine.signingKeys.expire({ kid: 'a82791af-3c4d-4e5f-8a9b-0c1d2e3f4a5b', payload: { reason: 'Key exposed in a backup' } });
PropertyTypeRequiredDescription
kidstringyesThe key id
payload.reasonstringyesAt least 5 characters
Last updated on