| |
| |
|
|
|
|
| import crypto from 'crypto';
|
|
|
| const FIRST_NAMES = [
|
| "James", "John", "Robert", "Michael", "William", "David", "Richard", "Joseph",
|
| "Thomas", "Charles", "Daniel", "Matthew", "Anthony", "Mark", "Steven", "Paul",
|
| "Andrew", "Joshua", "Kenneth", "Kevin", "Jacob", "Benjamin", "Nathan", "Samuel",
|
| "Ethan", "Noah", "Alexander", "Logan", "Lucas", "Mason", "Jack", "Henry",
|
| "Mary", "Jennifer", "Elizabeth", "Jessica", "Sarah", "Lisa", "Ashley", "Emily",
|
| "Emma", "Olivia", "Sophia", "Grace", "Isabella", "Charlotte", "Natalie",
|
| "Carlos", "Miguel", "Sofia", "Valentina", "Hans", "Stefan", "Marco", "Luca",
|
| ];
|
|
|
| const LAST_NAMES = [
|
| "Smith", "Johnson", "Williams", "Brown", "Jones", "Garcia", "Miller", "Davis",
|
| "Rodriguez", "Martinez", "Wilson", "Anderson", "Thomas", "Taylor", "Moore",
|
| "Jackson", "Martin", "Lee", "Thompson", "White", "Harris", "Clark",
|
| "Lewis", "Robinson", "Walker", "Young", "Allen", "King", "Wright",
|
| "Hill", "Green", "Adams", "Nelson", "Baker", "Hall", "Rivera",
|
| "Campbell", "Mitchell", "Carter", "Roberts", "Turner", "Phillips",
|
| "Morgan", "Cooper", "Reed", "Bailey", "Bell", "Howard",
|
| "Mueller", "Schmidt", "Rossi", "Ferrari", "Wang", "Li", "Kim", "Patel",
|
| ];
|
|
|
| export function generatePassword(length = 14) {
|
| const lowercase = 'abcdefghijklmnopqrstuvwxyz';
|
| const uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
| const digits = '0123456789';
|
| const special = '!@#$%^&*';
|
|
|
| const password = [
|
| lowercase[Math.floor(Math.random() * lowercase.length)],
|
| uppercase[Math.floor(Math.random() * uppercase.length)],
|
| digits[Math.floor(Math.random() * digits.length)],
|
| special[Math.floor(Math.random() * special.length)],
|
| ];
|
|
|
| const allChars = lowercase + uppercase + digits + special;
|
| for (let i = 4; i < length; i++) {
|
| password.push(allChars[Math.floor(Math.random() * allChars.length)]);
|
| }
|
|
|
|
|
| for (let i = password.length - 1; i > 0; i--) {
|
| const j = Math.floor(Math.random() * (i + 1));
|
| [password[i], password[j]] = [password[j], password[i]];
|
| }
|
|
|
| return password.join('');
|
| }
|
|
|
| export function generateName() {
|
| const firstName = FIRST_NAMES[Math.floor(Math.random() * FIRST_NAMES.length)];
|
| const lastName = LAST_NAMES[Math.floor(Math.random() * LAST_NAMES.length)];
|
| return { firstName, lastName };
|
| }
|
|
|
| export function generateAccountInfo() {
|
| const { firstName, lastName } = generateName();
|
| const password = generatePassword();
|
| return {
|
| password,
|
| firstName,
|
| lastName,
|
| fullName: `${firstName} ${lastName}`,
|
| };
|
| }
|
|
|