mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-05-06 19:49:36 +00:00
3e0b8de1b6
Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
55 lines
1.3 KiB
TypeScript
55 lines
1.3 KiB
TypeScript
export function generateScrambledPassword(length: number = 16): string {
|
|
const charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*'
|
|
const array = new Uint8Array(length)
|
|
crypto.getRandomValues(array)
|
|
|
|
let password = ''
|
|
for (let i = 0; i < length; i++) {
|
|
password += charset[array[i] % charset.length]
|
|
}
|
|
|
|
return password
|
|
}
|
|
|
|
export async function simulateEmailSend(
|
|
to: string,
|
|
subject: string,
|
|
body: string,
|
|
smtpConfig?: SMTPConfig
|
|
): Promise<{ success: boolean; message: string }> {
|
|
console.log('=== EMAIL SIMULATION ===')
|
|
console.log(`To: ${to}`)
|
|
console.log(`Subject: ${subject}`)
|
|
console.log(`Body:\n${body}`)
|
|
if (smtpConfig) {
|
|
console.log(`SMTP Host: ${smtpConfig.host}:${smtpConfig.port}`)
|
|
console.log(`From: ${smtpConfig.fromEmail}`)
|
|
}
|
|
console.log('========================')
|
|
|
|
return {
|
|
success: true,
|
|
message: 'Email simulated successfully (check console)'
|
|
}
|
|
}
|
|
|
|
export interface SMTPConfig {
|
|
host: string
|
|
port: number
|
|
secure: boolean
|
|
username: string
|
|
password: string
|
|
fromEmail: string
|
|
fromName: string
|
|
}
|
|
|
|
export const DEFAULT_SMTP_CONFIG: SMTPConfig = {
|
|
host: 'smtp.example.com',
|
|
port: 587,
|
|
secure: false,
|
|
username: '',
|
|
password: '',
|
|
fromEmail: 'noreply@metabuilder.com',
|
|
fromName: 'MetaBuilder System',
|
|
}
|