MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / randomRecoveryCode

Function randomRecoveryCode

packages/auth/src/totp.ts:60–71  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

58const RECOVERY_ALPHABET = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789';
59
60function randomRecoveryCode(): string {
61 const bytes = new Uint8Array(10);
62 crypto.getRandomValues(bytes);
63 let out = '';
64 for (let i = 0; i < bytes.length; i++) {
65 out += RECOVERY_ALPHABET[bytes[i]! % RECOVERY_ALPHABET.length];
66 if (i === 4) {
67 out += '-';
68 }
69 }
70 return out;
71}
72
73export function generateRecoveryCodes(count = 10): string[] {
74 return Array.from({ length: count }, randomRecoveryCode);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected