Files
NextChair/manager/src/lib/random.ts
T
Stefan Lazic e9e28a243f
CI / ci (push) Canceled after 0s
Installation
install token now shown in dashboard until install completes.
2026-09-06 20:14:25 +01:00

15 lines
611 B
TypeScript

import { randomBytes } from "node:crypto";
/**
* Cryptographically secure hex string of `bytes` random bytes (i.e.
* `bytes * 2` hex characters) — the one generator used for every secret
* this app creates on a business's behalf (database password,
* `AUTH_SECRET`, `INSTALLATION_TOKEN`, `CRON_SECRET`). Pulled out of
* provisioning.ts into its own module so a later rotate/regenerate
* action (e.g. re-issuing `INSTALLATION_TOKEN`) reuses this exact
* mechanism instead of a second, duplicate one.
*/
export function randomHex(bytes: number): string {
return randomBytes(bytes).toString("hex");
}