15 lines
396 B
TypeScript
15 lines
396 B
TypeScript
import { randomBytes } from "node:crypto";
|
|
|
|
/**
|
|
* Operation QR tokens are opaque, URL-safe, high-entropy identifiers
|
|
* printed on traveler cards. 24 bytes = 192 bits of entropy, encoded
|
|
* as base64url -> 32 characters.
|
|
*/
|
|
export function generateQrToken(): string {
|
|
return randomBytes(24)
|
|
.toString("base64")
|
|
.replace(/\+/g, "-")
|
|
.replace(/\//g, "_")
|
|
.replace(/=+$/, "");
|
|
}
|