MCPcopy Index your code
hub / github.com/simstudioai/sim / generateUnsubscribeToken

Function generateUnsubscribeToken

apps/sim/lib/messaging/email/unsubscribe.ts:22–27  ·  view source on GitHub ↗
(email: string, emailType = 'marketing')

Source from the content-addressed store, hash-verified

20 * Generate a secure unsubscribe token for an email address
21 */
22export 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

Callers 2

Calls 2

sha256HexFunction · 0.90
toStringMethod · 0.45

Tested by

no test coverage detected