All files / src/shared generatePassword.ts

100% Statements 5/5
100% Branches 0/0
100% Functions 1/1
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 91x   1x 35x     35x    
import { randomBytes } from './randomBytes'
 
export const generatePassword = async (): Promise<string> => {
  const randomPassword = (await randomBytes(32)).toString('hex')
  // Make first found letter uppercase because hex string doesn't meet password requirements
  // Special characters at the end of password to make comply with cognito requirements
  return randomPassword.replace(/[a-f]/, 'A') + '!'
}