(wordCount = WORD_COUNT_DEFAULT)
| 37 | } |
| 38 | |
| 39 | export function generateRecoveryCode(wordCount = WORD_COUNT_DEFAULT) { |
| 40 | const bytes = new Uint8Array(wordCount * 2); |
| 41 | crypto.getRandomValues(bytes); |
| 42 | const words = []; |
| 43 | for (let i = 0; i < wordCount; i++) { |
| 44 | words.push(bytesToWord(bytes[i * 2], bytes[i * 2 + 1])); |
| 45 | } |
| 46 | return words.join('-'); |
| 47 | } |
| 48 | |
| 49 | export function normalizeRecoveryCode(input) { |
| 50 | if (!input) return ''; |
no test coverage detected