Skip to content

Graphorin API reference v0.1.0


Graphorin API reference / @graphorin/security / / rotatePepper

Function: rotatePepper()

ts
function rotatePepper(options): Promise<{
  skipped: number;
  updated: number;
}>;

Defined in: packages/security/src/auth/crud.ts:194

Re-HMAC every token row with a new pepper. The previous pepper is required to derive the per-row plaintext via re-hashing — the function therefore only supports the rolling-deployment use case where the framework still holds the old pepper at the time of rotation.

The store update is per-row; the caller is responsible for running the helper inside an outer transaction when atomicity matters.

Returns the number of rows the helper would update; when dryRun: true the store is not touched.

Parameters

ParameterType
options{ dryRun?: boolean; newPepper: SecretValue; oldHashLookup: (id) => Promise&lt;string | null&gt;; recomputeHash: (id, oldHashHex) => Promise&lt;string | null&gt;; tokenStore: AuthTokenStore; }
options.dryRun?boolean
options.newPepperSecretValue
options.oldHashLookup(id) => Promise&lt;string | null&gt;
options.recomputeHash(id, oldHashHex) => Promise&lt;string | null&gt;
options.tokenStoreAuthTokenStore

Returns

Promise<{ skipped: number; updated: number; }>

Stable