import jwt from 'jsonwebtoken';
export function generateUnsubscribeToken(email, jwtSecret) {
    return jwt.sign({ email, action: 'unsubscribe' }, jwtSecret, { expiresIn: '90d' });
}
export function generateUnsubscribeUrl(email, jwtSecret, serverUrl) {
    const token = generateUnsubscribeToken(email, jwtSecret);
    return `${serverUrl}/api/email/unsubscribe/${token}`;
}
export function injectUnsubscribeFooter(htmlBody, unsubscribeUrl) {
    const footer = `<div style="margin-top:32px;padding-top:16px;border-top:1px solid #e0e0e0;text-align:center;font-size:12px;color:#888;">
  <a href="${unsubscribeUrl}" style="color:#888;text-decoration:underline;">unsubscribe</a>
</div>`;
    if (htmlBody.includes('</body>')) {
        return htmlBody.replace('</body>', `${footer}</body>`);
    }
    return htmlBody + footer;
}
export function getUnsubscribeHeaders(unsubscribeUrl) {
    return {
        'List-Unsubscribe': `<${unsubscribeUrl}>`,
        'List-Unsubscribe-Post': 'List-Unsubscribe=One-Click',
    };
}
//# sourceMappingURL=email-utils.js.map