Enrollment + almost all auth

This commit is contained in:
mdares
2026-01-03 20:18:39 +00:00
parent 0ad2451dd4
commit a0ed517047
40 changed files with 3559 additions and 31 deletions

16
lib/pairingCode.ts Normal file
View File

@@ -0,0 +1,16 @@
import { randomBytes } from "crypto";
const PAIRING_ALPHABET = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789";
export function generatePairingCode(length = 5) {
const bytes = randomBytes(length);
let code = "";
for (let i = 0; i < length; i += 1) {
code += PAIRING_ALPHABET[bytes[i] % PAIRING_ALPHABET.length];
}
return code;
}
export function normalizePairingCode(input: string) {
return input.trim().toUpperCase().replace(/[^A-Z0-9]/g, "");
}