Files
ThreadCount 0910bc32c1 ThreadCount Community edition
Uniform stock management for healthcare linen rooms: the coordinator app, the phone counter and the staff app, for your own server. Built from 38e16eb on 2026-09-15. Licensed under the Functional Source License (FSL-1.1-ALv2).
2026-09-16 07:57:54 +10:00

15 lines
750 B
TypeScript

/* Print the current six-digit code for a base32 TOTP secret.
*
* TOTP_SECRET=JBSWY3DPEHPK3PXP npx tsx scripts/totp-code.ts
*
* For the end-to-end suites, which enrol a second factor through the real routes and then need a
* live code to sign in with. The secret comes from the environment, never an argument — argv is
* visible to every process on the box. Uses the product's own implementation (lib/totp.ts), which
* scripts/check-totp.ts proves against RFC 6238's published vectors.
*/
import { base32Decode, totp } from "../lib/totp";
const secret = process.env.TOTP_SECRET || "";
if (!secret) { console.error("TOTP_SECRET must be set in the environment"); process.exit(1); }
process.stdout.write(totp(base32Decode(secret)) + "\n");