(email: string, emailType = 'marketing')
| 20 | * Generate a secure unsubscribe token for an email address |
| 21 | */ |
| 22 | export function generateUnsubscribeToken(email: string, emailType = 'marketing'): string { |
| 23 | const salt = randomBytes(16).toString('hex') |
| 24 | const hash = sha256Hex(`${email}:${salt}:${emailType}:${env.BETTER_AUTH_SECRET}`) |
| 25 | |
| 26 | return `${salt}:${hash}:${emailType}` |
| 27 | } |
| 28 | |
| 29 | /** |
| 30 | * Verify an unsubscribe token for an email address and return email type |
no test coverage detected