ts-mailkit 1.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -42
- package/dist/index.cjs +24 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +24 -27
- package/dist/index.js.map +1 -1
- package/dist/templates/factory.d.ts +13 -13
- package/dist/templates/factory.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -72,11 +72,11 @@ const mailer = createMailKit({
|
|
|
72
72
|
|
|
73
73
|
```ts
|
|
74
74
|
// 1. Create a strongly typed email verification DTO
|
|
75
|
-
const verificationEmail = EmailTemplateFactory.createEmailVerification(
|
|
76
|
-
'Alex',
|
|
77
|
-
'https://app.example.com/verify?token=xyz123',
|
|
78
|
-
'482910'
|
|
79
|
-
);
|
|
75
|
+
const verificationEmail = EmailTemplateFactory.createEmailVerification({
|
|
76
|
+
username: 'Alex',
|
|
77
|
+
verificationUrl: 'https://app.example.com/verify?token=xyz123',
|
|
78
|
+
otp: '482910',
|
|
79
|
+
});
|
|
80
80
|
|
|
81
81
|
// 2. Dispatch via MailKit
|
|
82
82
|
await mailer.send({
|
|
@@ -97,41 +97,41 @@ await mailer.send({
|
|
|
97
97
|
import { EmailTemplateFactory } from 'ts-mailkit';
|
|
98
98
|
|
|
99
99
|
// Email Verification with OTP
|
|
100
|
-
const verifyDto = EmailTemplateFactory.createEmailVerification(
|
|
101
|
-
'Jordan',
|
|
102
|
-
'https://app.com/verify?token=abc',
|
|
103
|
-
'123456'
|
|
104
|
-
);
|
|
100
|
+
const verifyDto = EmailTemplateFactory.createEmailVerification({
|
|
101
|
+
username: 'Jordan',
|
|
102
|
+
verificationUrl: 'https://app.com/verify?token=abc',
|
|
103
|
+
otp: '123456',
|
|
104
|
+
});
|
|
105
105
|
|
|
106
106
|
// Password Reset
|
|
107
|
-
const resetDto = EmailTemplateFactory.createPasswordReset(
|
|
108
|
-
'Jordan',
|
|
109
|
-
'https://app.com/reset?token=abc',
|
|
110
|
-
'654321'
|
|
111
|
-
);
|
|
107
|
+
const resetDto = EmailTemplateFactory.createPasswordReset({
|
|
108
|
+
username: 'Jordan',
|
|
109
|
+
resetUrl: 'https://app.com/reset?token=abc',
|
|
110
|
+
otp: '654321',
|
|
111
|
+
});
|
|
112
112
|
|
|
113
113
|
// Two-Factor Authentication (2FA)
|
|
114
|
-
const twoFactorDto = EmailTemplateFactory.create2FAEmail(
|
|
115
|
-
'Jordan',
|
|
116
|
-
'987654',
|
|
117
|
-
'https://app.com/2fa/magic?token=abc'
|
|
118
|
-
);
|
|
114
|
+
const twoFactorDto = EmailTemplateFactory.create2FAEmail({
|
|
115
|
+
username: 'Jordan',
|
|
116
|
+
otp: '987654',
|
|
117
|
+
magicLink: 'https://app.com/2fa/magic?token=abc',
|
|
118
|
+
});
|
|
119
119
|
|
|
120
120
|
// Magic Link Sign-in
|
|
121
|
-
const magicLinkDto = EmailTemplateFactory.createMagicLinkEmail(
|
|
122
|
-
'Jordan',
|
|
123
|
-
'https://app.com/auth/magic?token=abc'
|
|
124
|
-
);
|
|
121
|
+
const magicLinkDto = EmailTemplateFactory.createMagicLinkEmail({
|
|
122
|
+
username: 'Jordan',
|
|
123
|
+
magicLink: 'https://app.com/auth/magic?token=abc',
|
|
124
|
+
});
|
|
125
125
|
|
|
126
126
|
// Newsletter / Announcement
|
|
127
|
-
const newsDto = EmailTemplateFactory.createNewsLetter(
|
|
128
|
-
'Product Update - Fall 2026',
|
|
129
|
-
'Introducing New Features',
|
|
130
|
-
'Here is what our team shipped this month.',
|
|
131
|
-
'https://cdn.example.com/hero.png',
|
|
132
|
-
'https://app.com/blog/update',
|
|
133
|
-
'Read Release Notes'
|
|
134
|
-
);
|
|
127
|
+
const newsDto = EmailTemplateFactory.createNewsLetter({
|
|
128
|
+
subject: 'Product Update - Fall 2026',
|
|
129
|
+
header: 'Introducing New Features',
|
|
130
|
+
body: 'Here is what our team shipped this month.',
|
|
131
|
+
imageUrl: 'https://cdn.example.com/hero.png',
|
|
132
|
+
actionUrl: 'https://app.com/blog/update',
|
|
133
|
+
actionText: 'Read Release Notes',
|
|
134
|
+
});
|
|
135
135
|
```
|
|
136
136
|
|
|
137
137
|
### 2. Custom Branding & Multi-tenancy
|
|
@@ -146,11 +146,11 @@ const tenantFactory = new EmailTemplateFactory({
|
|
|
146
146
|
footer: (brand) => `© ${new Date().getFullYear()} ${brand}. Authorized educational portal.`,
|
|
147
147
|
});
|
|
148
148
|
|
|
149
|
-
const studentEmail = tenantFactory.createEmailVerification(
|
|
150
|
-
'Student',
|
|
151
|
-
'https://school.edu/verify',
|
|
152
|
-
'554433'
|
|
153
|
-
);
|
|
149
|
+
const studentEmail = tenantFactory.createEmailVerification({
|
|
150
|
+
username: 'Student',
|
|
151
|
+
verificationUrl: 'https://school.edu/verify',
|
|
152
|
+
otp: '554433',
|
|
153
|
+
});
|
|
154
154
|
```
|
|
155
155
|
|
|
156
156
|
Or pass a dynamic tenant resolver to `MailKit`:
|
|
@@ -184,11 +184,11 @@ describe('User Registration Email', () => {
|
|
|
184
184
|
});
|
|
185
185
|
|
|
186
186
|
it('sends verification code to the registered user', async () => {
|
|
187
|
-
const dto = EmailTemplateFactory.createEmailVerification(
|
|
188
|
-
'Sam',
|
|
189
|
-
'https://app.com/verify?token=123',
|
|
190
|
-
'889900'
|
|
191
|
-
);
|
|
187
|
+
const dto = EmailTemplateFactory.createEmailVerification({
|
|
188
|
+
username: 'Sam',
|
|
189
|
+
verificationUrl: 'https://app.com/verify?token=123',
|
|
190
|
+
otp: '889900',
|
|
191
|
+
});
|
|
192
192
|
|
|
193
193
|
await mailer.send({ to: 'sam@example.com', template: dto });
|
|
194
194
|
|
package/dist/index.cjs
CHANGED
|
@@ -605,7 +605,8 @@ var EmailTemplateFactory = class _EmailTemplateFactory {
|
|
|
605
605
|
/**
|
|
606
606
|
* Welcome / email-verification email sent after registration.
|
|
607
607
|
*/
|
|
608
|
-
createEmailVerification(
|
|
608
|
+
createEmailVerification(params) {
|
|
609
|
+
const { username, verificationUrl, otp, brandName } = params;
|
|
609
610
|
const brand = this.resolveBrand(brandName);
|
|
610
611
|
const body = `Hi ${username},<br/>Thank you for signing up. Use the code below or click the button to verify your email address.`;
|
|
611
612
|
return {
|
|
@@ -631,7 +632,8 @@ ${verificationUrl}`
|
|
|
631
632
|
/**
|
|
632
633
|
* Password-reset email with an optional OTP code and action link.
|
|
633
634
|
*/
|
|
634
|
-
createPasswordReset(
|
|
635
|
+
createPasswordReset(params) {
|
|
636
|
+
const { username, resetUrl, otp = "", brandName } = params;
|
|
635
637
|
const brand = this.resolveBrand(brandName);
|
|
636
638
|
const body = `Hi ${username},<br/>We received a request to reset your password. Use the OTP code below or click the button to proceed.`;
|
|
637
639
|
const plainTextOtp = otp ? `
|
|
@@ -658,7 +660,8 @@ ${resetUrl}`
|
|
|
658
660
|
/**
|
|
659
661
|
* Generic plain message email (no action button, no OTP).
|
|
660
662
|
*/
|
|
661
|
-
createSimpleMessage(
|
|
663
|
+
createSimpleMessage(params) {
|
|
664
|
+
const { subject, header, body, brandName } = params;
|
|
662
665
|
const brand = this.resolveBrand(brandName);
|
|
663
666
|
return {
|
|
664
667
|
subject,
|
|
@@ -673,7 +676,8 @@ ${resetUrl}`
|
|
|
673
676
|
/**
|
|
674
677
|
* Newsletter / announcement email with an optional hero image and CTA button.
|
|
675
678
|
*/
|
|
676
|
-
createNewsLetter(
|
|
679
|
+
createNewsLetter(params) {
|
|
680
|
+
const { subject, header, body, imageUrl, actionUrl, actionText, brandName, logoUrl } = params;
|
|
677
681
|
const brand = this.resolveBrand(brandName);
|
|
678
682
|
let noHtmlMessage = htmlToPlainText(body);
|
|
679
683
|
if (actionUrl) {
|
|
@@ -697,7 +701,8 @@ ${actionText || "Learn more"}: ${actionUrl}`;
|
|
|
697
701
|
/**
|
|
698
702
|
* Two-factor authentication email with OTP code and optional magic link.
|
|
699
703
|
*/
|
|
700
|
-
create2FAEmail(
|
|
704
|
+
create2FAEmail(params) {
|
|
705
|
+
const { username, otp, magicLink = "", brandName } = params;
|
|
701
706
|
const brand = this.resolveBrand(brandName);
|
|
702
707
|
const body = `Hi ${username},<br/>Use the code below or click the button to complete your login.`;
|
|
703
708
|
const plainLink = magicLink ? `
|
|
@@ -724,7 +729,8 @@ Your verification code is: ${otp}` + plainLink
|
|
|
724
729
|
/**
|
|
725
730
|
* Magic link sign-in email (no OTP, button only).
|
|
726
731
|
*/
|
|
727
|
-
createMagicLinkEmail(
|
|
732
|
+
createMagicLinkEmail(params) {
|
|
733
|
+
const { username, magicLink, brandName } = params;
|
|
728
734
|
const brand = this.resolveBrand(brandName);
|
|
729
735
|
const body = `Hi ${username},<br/>Click the button below to sign in. No password needed.`;
|
|
730
736
|
return {
|
|
@@ -752,32 +758,23 @@ ${magicLink}`
|
|
|
752
758
|
}
|
|
753
759
|
return this._defaultInstance;
|
|
754
760
|
}
|
|
755
|
-
static createEmailVerification(
|
|
756
|
-
return this.defaultInstance.createEmailVerification(
|
|
761
|
+
static createEmailVerification(params) {
|
|
762
|
+
return this.defaultInstance.createEmailVerification(params);
|
|
757
763
|
}
|
|
758
|
-
static createPasswordReset(
|
|
759
|
-
return this.defaultInstance.createPasswordReset(
|
|
764
|
+
static createPasswordReset(params) {
|
|
765
|
+
return this.defaultInstance.createPasswordReset(params);
|
|
760
766
|
}
|
|
761
|
-
static createSimpleMessage(
|
|
762
|
-
return this.defaultInstance.createSimpleMessage(
|
|
767
|
+
static createSimpleMessage(params) {
|
|
768
|
+
return this.defaultInstance.createSimpleMessage(params);
|
|
763
769
|
}
|
|
764
|
-
static createNewsLetter(
|
|
765
|
-
return this.defaultInstance.createNewsLetter(
|
|
766
|
-
subject,
|
|
767
|
-
header,
|
|
768
|
-
body,
|
|
769
|
-
imageUrl,
|
|
770
|
-
actionUrl,
|
|
771
|
-
actionText,
|
|
772
|
-
brandName,
|
|
773
|
-
logoUrl
|
|
774
|
-
);
|
|
770
|
+
static createNewsLetter(params) {
|
|
771
|
+
return this.defaultInstance.createNewsLetter(params);
|
|
775
772
|
}
|
|
776
|
-
static create2FAEmail(
|
|
777
|
-
return this.defaultInstance.create2FAEmail(
|
|
773
|
+
static create2FAEmail(params) {
|
|
774
|
+
return this.defaultInstance.create2FAEmail(params);
|
|
778
775
|
}
|
|
779
|
-
static createMagicLinkEmail(
|
|
780
|
-
return this.defaultInstance.createMagicLinkEmail(
|
|
776
|
+
static createMagicLinkEmail(params) {
|
|
777
|
+
return this.defaultInstance.createMagicLinkEmail(params);
|
|
781
778
|
}
|
|
782
779
|
};
|
|
783
780
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/core/types.ts","../src/core/errors.ts","../src/renderers/utils/html-to-plaintext.ts","../src/renderers/default/default-renderer.ts","../src/core/client.ts","../src/transports/zeptomail/zeptomail-sender.ts","../src/transports/memory/memory-sender.ts","../src/transports/console/console-sender.ts","../src/templates/factory.ts"],"sourcesContent":["// ─── Core Types, Envelopes & Errors ──────────────────────────────────────────\nexport * from './core/types.js';\nexport * from './core/errors.js';\nexport * from './core/client.js';\n\n// ─── Transport Interface & Implementations ────────────────────────────────────\nexport * from './transports/sender.interface.js';\nexport * from './transports/zeptomail/zeptomail-sender.js';\nexport * from './transports/zeptomail/types.js';\nexport * from './transports/memory/memory-sender.js';\nexport * from './transports/console/console-sender.js';\n\n// ─── Template DTOs & Factory ──────────────────────────────────────────────────\nexport * from './templates/dto/index.js';\nexport * from './templates/factory.js';\n\n// ─── Renderers & Utilities ────────────────────────────────────────────────────\nexport * from './renderers/renderer.interface.js';\nexport * from './renderers/default/default-renderer.js';\nexport * from './renderers/utils/html-to-plaintext.js';\n","/**\n * Standard email address representation with optional display name.\n */\nexport interface EmailAddress {\n address: string;\n name?: string;\n}\n\n/**\n * Flexible recipient representation allowing string ('user@example.com'),\n * EmailAddress ({ address: 'user@example.com', name: 'User' }),\n * or legacy/standard object ({ email: 'user@example.com', name: 'User' }).\n */\nexport type Recipient =\n | string\n | EmailAddress\n | { email: string; name?: string };\n\n/**\n * Parses an RFC 5322 formatted address string into an EmailAddress.\n * Supports formats such as:\n * - \"user@example.com\" -> { address: \"user@example.com\" }\n * - \"Sender Name <sender@example.com>\" -> { name: \"Sender Name\", address: \"sender@example.com\" }\n * - \"\\\"Sender Name\\\" <sender@example.com>\" -> { name: \"Sender Name\", address: \"sender@example.com\" }\n */\nexport function parseEmailAddress(input: string): EmailAddress {\n if (!input || typeof input !== 'string') {\n return { address: '' };\n }\n const trimmed = input.trim();\n const match = trimmed.match(/^(?:[\"']?([^\"']+)[\"']?\\s+)?<?([^\\s<>@]+@[^\\s<>@]+)>?$/);\n if (!match) {\n return { address: trimmed };\n }\n return {\n address: match[2].trim(),\n name: match[1]?.trim() || undefined,\n };\n}\n\n/**\n * Normalizes a Recipient value into a standardized EmailAddress.\n */\nexport function normalizeRecipient(recipient: Recipient): EmailAddress {\n if (typeof recipient === 'string') {\n return { address: recipient.trim() };\n }\n if ('email' in recipient) {\n return {\n address: (recipient.email ?? '').trim(),\n name: recipient.name?.trim(),\n };\n }\n return {\n address: (recipient.address ?? '').trim(),\n name: recipient.name?.trim(),\n };\n}\n\n/**\n * Normalizes a single or array of Recipients into an array of EmailAddress.\n */\nexport function normalizeRecipients(\n recipients?: Recipient | Recipient[]\n): EmailAddress[] {\n if (!recipients) return [];\n const list = Array.isArray(recipients) ? recipients : [recipients];\n return list.map(normalizeRecipient).filter((r) => r.address.length > 0);\n}\n\n/**\n * Email attachment representation.\n */\nexport interface EmailAttachment {\n filename: string;\n /**\n * Content can be base64-encoded string, plain text, or binary Buffer/Uint8Array.\n */\n content: string | Uint8Array;\n mimeType?: string;\n contentType?: string;\n cid?: string;\n}\n\n/**\n * Options for sending an email through a transport adapter.\n */\nexport interface SendMailOptions {\n to: Recipient | Recipient[];\n from?: Recipient;\n subject: string;\n html: string;\n text?: string;\n cc?: Recipient | Recipient[];\n bcc?: Recipient | Recipient[];\n replyTo?: Recipient | Recipient[];\n attachments?: EmailAttachment[];\n headers?: Record<string, string>;\n tags?: string[];\n metadata?: Record<string, string>;\n}\n\n/**\n * Result returned by an IEmailSender upon dispatch.\n */\nexport interface SendResult {\n success: boolean;\n messageId?: string;\n response?: unknown;\n}\n","/**\n * Base error class for all ts-mailkit errors.\n */\nexport class MailKitError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'MailKitError';\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/**\n * Thrown when transport configuration is missing or invalid.\n */\nexport class ConfigurationError extends MailKitError {\n constructor(message: string) {\n super(message);\n this.name = 'ConfigurationError';\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/**\n * Thrown when an email transport fails to dispatch an email.\n */\nexport class TransportError extends MailKitError {\n readonly transportName: string;\n readonly statusCode?: number;\n readonly responseBody?: string;\n readonly cause?: unknown;\n\n constructor(\n message: string,\n options: {\n transportName: string;\n statusCode?: number;\n responseBody?: string;\n cause?: unknown;\n }\n ) {\n super(message);\n this.name = 'TransportError';\n this.transportName = options.transportName;\n this.statusCode = options.statusCode;\n this.responseBody = options.responseBody;\n this.cause = options.cause;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/**\n * Thrown when template rendering or DTO validation fails.\n */\nexport class TemplateError extends MailKitError {\n constructor(message: string) {\n super(message);\n this.name = 'TemplateError';\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","/**\n * Decodes common HTML entities into their plain text equivalents.\n */\nexport function decodeHtmlEntities(text: string): string {\n return text\n .replace(/ /gi, ' ')\n .replace(/&/gi, '&')\n .replace(/</gi, '<')\n .replace(/>/gi, '>')\n .replace(/"/gi, '\"')\n .replace(/'/gi, \"'\")\n .replace(/©/gi, '©')\n .replace(/®/gi, '®')\n .replace(/™/gi, '™');\n}\n\n/**\n * Strips HTML tags and normalizes whitespace into readable plain text.\n * Converts <br>, <p>, and <div> into appropriate line breaks.\n */\nexport function htmlToPlainText(html: string): string {\n if (!html) return '';\n\n return decodeHtmlEntities(\n html\n .replace(/<br\\s*\\/?>/gi, '\\n')\n .replace(/<\\/p>/gi, '\\n\\n')\n .replace(/<\\/div>/gi, '\\n')\n .replace(/<\\/h[1-6]>/gi, '\\n\\n')\n .replace(/<[^>]*>/g, '')\n )\n .replace(/[ \\t]+/g, ' ')\n .replace(/\\n\\s*\\n\\s*\\n+/g, '\\n\\n')\n .trim();\n}\n","import type { EmailTemplateDto } from '../../templates/dto/index.js';\nimport type { IEmailRenderer, RenderedEmail } from '../renderer.interface.js';\nimport { htmlToPlainText } from '../utils/html-to-plaintext.js';\n\nexport interface DefaultRendererOptions {\n /**\n * Primary brand color for buttons and accents.\n * @default '#4f46e5'\n */\n primaryColor?: string;\n\n /**\n * Font stack used in the HTML wrapper.\n * @default \"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif\"\n */\n fontFamily?: string;\n\n /**\n * Container maximum width.\n * @default '600px'\n */\n maxWidth?: string;\n\n /**\n * Default logo URL displayed at the top-center of the email if not provided in the DTO.\n * Must be a valid http(s) URL.\n */\n logoUrl?: string;\n}\n\n/**\n * Validates whether a string is a valid HTTP or HTTPS URL.\n */\nexport function isValidHttpUrl(urlString?: string): boolean {\n if (!urlString || typeof urlString !== 'string') return false;\n try {\n const url = new URL(urlString.trim());\n return (url.protocol === 'http:' || url.protocol === 'https:') && url.hostname.length > 0;\n } catch {\n return false;\n }\n}\n\n/**\n * Builds a plain-text fallback string from an email DTO.\n */\nexport function buildPlainText(dto: EmailTemplateDto): string {\n if (dto.noHtmlMessage) {\n return dto.noHtmlMessage;\n }\n\n const divider = '──────────────────────────────';\n const parts: string[] = [];\n\n if (dto.header) {\n parts.push(dto.header, divider);\n }\n\n if (dto.body) {\n parts.push(htmlToPlainText(dto.body));\n }\n\n if (dto.otpCode) {\n parts.push(`Verification Code: ${dto.otpCode}`);\n }\n\n if (dto.actionText && dto.actionUrl) {\n parts.push(`${dto.actionText}: ${dto.actionUrl}`);\n }\n\n if (dto.extraMessage) {\n parts.push(htmlToPlainText(dto.extraMessage));\n }\n\n if (dto.footer) {\n parts.push(`${divider}\\n${htmlToPlainText(dto.footer)}`);\n }\n\n return parts.join('\\n\\n');\n}\n\n/**\n * Builds a responsive, styled HTML email document from an email DTO.\n */\nexport function buildHtml(dto: EmailTemplateDto, options: DefaultRendererOptions = {}): string {\n const primaryColor = options.primaryColor || '#4f46e5';\n const fontFamily =\n options.fontFamily ||\n \"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif\";\n const maxWidth = options.maxWidth || '600px';\n\n const parts: string[] = [\n `<!DOCTYPE html>`,\n `<html lang=\"en\">`,\n `<head>`,\n `<meta charset=\"UTF-8\">`,\n `<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">`,\n `<title>${dto.subject}</title>`,\n `</head>`,\n `<body style=\"margin:0;padding:24px 16px;background-color:#f9fafb;font-family:${fontFamily};color:#1f2937;line-height:1.6;\">`,\n `<div style=\"max-width:${maxWidth};margin:0 auto;background-color:#ffffff;padding:32px 28px;border-radius:8px;box-shadow:0 1px 3px rgba(0,0,0,0.1);border:1px solid #f3f4f6;\">`,\n ];\n\n const logoCandidate = dto.logoUrl ?? options.logoUrl;\n if (logoCandidate && isValidHttpUrl(logoCandidate)) {\n const validLogo = logoCandidate.trim();\n parts.push(\n `<div style=\"margin-bottom:24px;text-align:center;\">`,\n ` <img src=\"${validLogo}\" alt=\"${dto.fromName || 'Logo'}\" style=\"max-height:48px;max-width:200px;height:auto;width:auto;display:inline-block;border:0;outline:none;text-decoration:none;\" />`,\n `</div>`\n );\n }\n\n if (dto.imageUrl) {\n parts.push(\n `<div style=\"margin-bottom:24px;text-align:center;\">`,\n ` <img src=\"${dto.imageUrl}\" alt=\"Header\" style=\"max-width:100%;height:auto;border-radius:6px;\" />`,\n `</div>`\n );\n }\n\n if (dto.header) {\n parts.push(\n `<h2 style=\"margin:0 0 16px;font-size:1.5rem;font-weight:700;color:#111827;letter-spacing:-0.025em;\">${dto.header}</h2>`\n );\n }\n\n if (dto.body) {\n parts.push(`<div style=\"margin:0 0 20px;font-size:1rem;color:#374151;\">${dto.body}</div>`);\n }\n\n if (dto.otpCode) {\n parts.push(\n `<div style=\"margin:24px 0;padding:20px;background-color:#f3f4f6;border-radius:8px;text-align:center;\">`,\n ` <span style=\"font-size:2rem;letter-spacing:0.5rem;font-weight:700;color:#111827;font-family:monospace;\">${dto.otpCode}</span>`,\n `</div>`\n );\n }\n\n if (dto.actionUrl && dto.actionText) {\n parts.push(\n `<div style=\"margin:24px 0;text-align:center;\">`,\n ` <a href=\"${dto.actionUrl}\" style=\"display:inline-block;padding:12px 28px;background-color:${primaryColor};color:#ffffff;border-radius:6px;text-decoration:none;font-weight:600;font-size:1rem;text-align:center;box-sizing:border-box;\">${dto.actionText}</a>`,\n `</div>`\n );\n }\n\n if (dto.extraMessage) {\n parts.push(\n `<div style=\"margin:20px 0 0;font-size:0.875rem;color:#6b7280;line-height:1.5;\">${dto.extraMessage}</div>`\n );\n }\n\n if (dto.footer) {\n parts.push(\n `<div style=\"margin-top:32px;padding-top:20px;border-top:1px solid #e5e7eb;font-size:0.75rem;color:#9ca3af;text-align:center;\">${dto.footer}</div>`\n );\n }\n\n parts.push(`</div>`, `</body>`, `</html>`);\n return parts.join('\\n');\n}\n\n/**\n * Default HTML and plain-text email renderer for ts-mailkit.\n */\nexport class DefaultEmailRenderer implements IEmailRenderer {\n private readonly options: DefaultRendererOptions;\n\n constructor(options: DefaultRendererOptions = {}) {\n this.options = options;\n }\n\n render(dto: EmailTemplateDto): RenderedEmail {\n return {\n html: buildHtml(dto, this.options),\n text: buildPlainText(dto),\n };\n }\n}\n","import type { IEmailSender } from '../transports/sender.interface.js';\nimport type { IEmailRenderer, RenderedEmail } from '../renderers/renderer.interface.js';\nimport { DefaultEmailRenderer } from '../renderers/default/default-renderer.js';\nimport { htmlToPlainText } from '../renderers/utils/html-to-plaintext.js';\nimport type { EmailTemplateDto } from '../templates/dto/index.js';\nimport {\n normalizeRecipient,\n normalizeRecipients,\n type Recipient,\n type SendMailOptions,\n type SendResult,\n} from './types.js';\nimport { ConfigurationError } from './errors.js';\n\nexport interface SendTemplateOptions {\n /**\n * One or more recipient email addresses.\n */\n to: Recipient | Recipient[];\n /**\n * Templated email DTO to render and send.\n */\n template: EmailTemplateDto;\n /**\n * Optional recipient display name (used when `to` is a plain string).\n */\n toName?: string;\n /**\n * Optional sender display name override for this specific email.\n */\n fromName?: string;\n /**\n * Optional sender email address override.\n */\n from?: Recipient;\n /**\n * Optional CC recipients.\n */\n cc?: Recipient | Recipient[];\n /**\n * Optional BCC recipients.\n */\n bcc?: Recipient | Recipient[];\n /**\n * Optional Reply-To recipients.\n */\n replyTo?: Recipient | Recipient[];\n /**\n * Optional file attachments.\n */\n attachments?: SendMailOptions['attachments'];\n /**\n * Optional custom headers.\n */\n headers?: Record<string, string>;\n /**\n * Optional tags for tracking.\n */\n tags?: string[];\n /**\n * Optional metadata.\n */\n metadata?: Record<string, string>;\n}\n\nexport interface MailKitOptions {\n /**\n * The transport adapter used to dispatch emails (e.g. ZeptoMailHttpSender, MemoryEmailSender).\n */\n transport: IEmailSender;\n /**\n * Custom renderer implementation. Defaults to DefaultEmailRenderer.\n */\n renderer?: IEmailRenderer;\n /**\n * Default sender address or Recipient.\n */\n defaultFrom?: Recipient;\n /**\n * Default brand or application name.\n */\n defaultBrandName?: string;\n /**\n * Optional asynchronous or synchronous resolver to dynamically resolve brand/tenant name.\n * Useful for multitenant applications.\n */\n brandNameResolver?: () => Promise<string> | string;\n}\n\n/**\n * Main email client and orchestration service for ts-mailkit.\n */\nexport class MailKit {\n private readonly transport: IEmailSender;\n private readonly renderer: IEmailRenderer;\n private readonly defaultFrom?: Recipient;\n private readonly defaultBrandName?: string;\n private readonly brandNameResolver?: () => Promise<string> | string;\n\n constructor(options: MailKitOptions) {\n if (!options.transport) {\n throw new ConfigurationError('MailKit: A transport adapter (IEmailSender) is required.');\n }\n this.transport = options.transport;\n this.renderer = options.renderer ?? new DefaultEmailRenderer();\n this.defaultFrom = options.defaultFrom;\n this.defaultBrandName = options.defaultBrandName;\n this.brandNameResolver = options.brandNameResolver;\n }\n\n /**\n * Returns the underlying transport instance.\n */\n getTransport(): IEmailSender {\n return this.transport;\n }\n\n /**\n * Renders an email DTO to HTML and plain text without dispatching.\n */\n async render(template: EmailTemplateDto): Promise<RenderedEmail> {\n return await this.renderer.render(template);\n }\n\n /**\n * Sends an email using a strongly-typed template DTO.\n *\n * Example:\n * ```ts\n * await mailer.send({\n * to: 'user@example.com',\n * template: myDto,\n * });\n * ```\n */\n async send(options: SendTemplateOptions): Promise<SendResult> {\n const template = options.template;\n const recipientName = options.toName ?? template.userName;\n\n // Resolve fromName: explicit option > template.fromName > brand resolver > defaultBrandName\n let resolvedFromName = options.fromName ?? template.fromName;\n if (!resolvedFromName && this.brandNameResolver) {\n resolvedFromName = await this.brandNameResolver();\n }\n if (!resolvedFromName) {\n resolvedFromName = this.defaultBrandName;\n }\n\n // Render template DTO\n const rendered = await this.renderer.render(template);\n const plaintextBody = template.noHtmlMessage ?? rendered.text;\n\n // Format recipients\n let toRecipients: Recipient | Recipient[];\n if (typeof options.to === 'string' && recipientName) {\n toRecipients = { address: options.to, name: recipientName };\n } else {\n toRecipients = options.to;\n }\n\n // Resolve From address\n let from = options.from ?? this.defaultFrom;\n if (resolvedFromName && from) {\n const normalizedFrom = normalizeRecipient(from);\n from = { address: normalizedFrom.address, name: resolvedFromName };\n }\n\n return await this.sendRaw({\n to: toRecipients,\n from,\n subject: template.subject,\n html: rendered.html,\n text: plaintextBody,\n cc: options.cc,\n bcc: options.bcc,\n replyTo: options.replyTo,\n attachments: options.attachments,\n headers: options.headers,\n tags: options.tags,\n metadata: options.metadata,\n });\n }\n\n /**\n * Dispatches a raw, pre-rendered email directly through the transport.\n * If `options.text` is omitted, plain text is automatically derived from `options.html`.\n */\n async sendRaw(options: SendMailOptions): Promise<SendResult> {\n const from = options.from ?? this.defaultFrom;\n const text = options.text ?? (options.html ? htmlToPlainText(options.html) : undefined);\n return await this.transport.send({\n ...options,\n from,\n text,\n });\n }\n}\n\n/**\n * Convenience factory to create a MailKit client instance.\n */\nexport function createMailKit(options: MailKitOptions): MailKit {\n return new MailKit(options);\n}\n","import { ConfigurationError, TransportError } from '../../core/errors.js';\nimport {\n normalizeRecipient,\n normalizeRecipients,\n type SendMailOptions,\n type SendResult,\n} from '../../core/types.js';\nimport type { IEmailSender } from '../sender.interface.js';\nimport type {\n ZeptoMailHttpConfig,\n ZeptoMailSendPayload,\n ZeptoMailAttachmentPayload,\n} from './types.js';\n\n/**\n * ZeptoMail (Zoho Mail transactional email HTTP API) transport adapter.\n *\n * Designed for zero dependencies and universal edge compatibility (Node.js, Bun, Deno, Cloudflare Workers)\n * by utilizing the standard global `fetch` API.\n */\nexport class ZeptoMailHttpSender implements IEmailSender {\n readonly name = 'zeptomail';\n\n private readonly apiUrl: string;\n private readonly authHeader: string;\n private readonly defaultFrom: { address: string; name?: string };\n private readonly fetchImpl: typeof fetch;\n\n constructor(config: ZeptoMailHttpConfig) {\n if (!config.apiToken || typeof config.apiToken !== 'string') {\n throw new ConfigurationError('ZeptoMailHttpSender: Missing or invalid apiToken.');\n }\n if (!config.from) {\n throw new ConfigurationError('ZeptoMailHttpSender: Missing required default from address.');\n }\n\n const host = (config.apiHost || 'api.zeptomail.com').replace(/^https?:\\/\\//, '').replace(/\\/+$/, '');\n this.apiUrl = `https://${host}/v1.1/email`;\n\n // Normalize auth token header. In ZeptoMail, if the user already included \"Zoho-enczapikey \", use as is; otherwise format standard header.\n const token = config.apiToken.trim();\n this.authHeader = token.startsWith('Zoho-') ? token : `Zoho-enczapikey ${token}`;\n\n this.defaultFrom = normalizeRecipient(config.from);\n if (!this.defaultFrom.address) {\n throw new ConfigurationError('ZeptoMailHttpSender: Configured from address must not be empty.');\n }\n\n this.fetchImpl = config.fetch ?? globalThis.fetch;\n if (typeof this.fetchImpl !== 'function') {\n throw new ConfigurationError(\n 'ZeptoMailHttpSender: No global fetch implementation found. Pass a custom fetch to ZeptoMailHttpConfig if running on Node < 18.'\n );\n }\n }\n\n /**\n * Dispatches an email using Zoho ZeptoMail API v1.1.\n */\n async send(options: SendMailOptions): Promise<SendResult> {\n const toRecipients = normalizeRecipients(options.to);\n if (toRecipients.length === 0) {\n throw new TransportError('ZeptoMailHttpSender: At least one recipient (to) must be specified.', {\n transportName: this.name,\n });\n }\n\n const resolvedFrom = options.from ? normalizeRecipient(options.from) : this.defaultFrom;\n\n const payload: ZeptoMailSendPayload = {\n from: {\n address: resolvedFrom.address,\n name: resolvedFrom.name,\n },\n to: toRecipients.map((r) => ({\n email_address: {\n address: r.address,\n name: r.name || '',\n },\n })),\n subject: options.subject,\n htmlbody: options.html,\n textbody: options.text,\n };\n\n if (options.cc) {\n const ccList = normalizeRecipients(options.cc);\n if (ccList.length > 0) {\n payload.cc = ccList.map((r) => ({\n email_address: { address: r.address, name: r.name || '' },\n }));\n }\n }\n\n if (options.bcc) {\n const bccList = normalizeRecipients(options.bcc);\n if (bccList.length > 0) {\n payload.bcc = bccList.map((r) => ({\n email_address: { address: r.address, name: r.name || '' },\n }));\n }\n }\n\n if (options.replyTo) {\n const replyToList = normalizeRecipients(options.replyTo);\n if (replyToList.length > 0) {\n payload.reply_to = replyToList.map((r) => ({\n address: r.address,\n name: r.name,\n }));\n }\n }\n\n if (options.attachments && options.attachments.length > 0) {\n payload.attachments = options.attachments.map((att): ZeptoMailAttachmentPayload => {\n let contentBase64: string;\n if (typeof att.content === 'string') {\n contentBase64 = att.content;\n } else {\n // Buffer or Uint8Array\n if (typeof Buffer !== 'undefined') {\n contentBase64 = Buffer.from(att.content).toString('base64');\n } else {\n // Browser / Edge fallback for Uint8Array\n let binary = '';\n const bytes = new Uint8Array(att.content);\n for (let i = 0; i < bytes.byteLength; i++) {\n binary += String.fromCharCode(bytes[i]);\n }\n contentBase64 = btoa(binary);\n }\n }\n\n return {\n name: att.filename,\n content: contentBase64,\n mime_type: att.mimeType || att.contentType || 'application/octet-stream',\n cid: att.cid,\n };\n });\n }\n\n let response: Response;\n try {\n response = await this.fetchImpl(this.apiUrl, {\n method: 'POST',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n Authorization: this.authHeader,\n },\n body: JSON.stringify(payload),\n });\n } catch (err) {\n throw new TransportError(`ZeptoMailHttpSender: Network request failed: ${err instanceof Error ? err.message : String(err)}`, {\n transportName: this.name,\n cause: err,\n });\n }\n\n const responseText = await response.text();\n let responseData: any;\n try {\n responseData = responseText ? JSON.parse(responseText) : {};\n } catch {\n responseData = { raw: responseText };\n }\n\n if (!response.ok) {\n const errorMessage =\n responseData?.error?.message ||\n responseData?.message ||\n `HTTP ${response.status}: ${responseText || response.statusText}`;\n\n throw new TransportError(`ZeptoMailHttpSender: Failed to send email - ${errorMessage}`, {\n transportName: this.name,\n statusCode: response.status,\n responseBody: responseText,\n });\n }\n\n // Extract message ID from standard ZeptoMail v1.1 response structure:\n // { data: [ { message_id: \"...\" } ] }\n const messageId = responseData?.data?.[0]?.message_id;\n\n return {\n success: true,\n messageId,\n response: responseData,\n };\n }\n}\n","import type { SendMailOptions, SendResult } from '../../core/types.js';\nimport type { IEmailSender } from '../sender.interface.js';\n\n/**\n * In-memory email sender for automated testing, local development, and CI environments.\n * Captures all dispatched emails and provides inspection methods.\n */\nexport class MemoryEmailSender implements IEmailSender {\n readonly name = 'memory';\n\n private sentMails: SendMailOptions[] = [];\n private nextId = 1;\n\n async send(options: SendMailOptions): Promise<SendResult> {\n this.sentMails.push({ ...options });\n const messageId = `mem-${this.nextId++}-${Date.now()}`;\n return {\n success: true,\n messageId,\n response: { id: messageId },\n };\n }\n\n /**\n * Returns a copy of all emails sent through this transport instance.\n */\n getSentMails(): SendMailOptions[] {\n return [...this.sentMails];\n }\n\n /**\n * Returns the most recent email sent, or undefined if no emails have been sent.\n */\n getLastMail(): SendMailOptions | undefined {\n return this.sentMails.length > 0\n ? { ...this.sentMails[this.sentMails.length - 1] }\n : undefined;\n }\n\n /**\n * Clears all recorded sent emails.\n */\n clear(): void {\n this.sentMails = [];\n }\n\n /**\n * Returns the total count of sent emails.\n */\n count(): number {\n return this.sentMails.length;\n }\n}\n","import { normalizeRecipients, type SendMailOptions, type SendResult } from '../../core/types.js';\nimport type { IEmailSender } from '../sender.interface.js';\n\nexport interface ConsoleEmailSenderOptions {\n /**\n * Log level or custom log printer. Defaults to `console.log`.\n */\n logger?: (message: string) => void;\n /**\n * Whether to include the full HTML body in console output.\n * Defaults to false (prints plain text or a summary).\n */\n includeHtml?: boolean;\n}\n\n/**\n * Console logger transport that prints dispatched emails to stdout/stderr.\n * Ideal for development and debugging.\n */\nexport class ConsoleEmailSender implements IEmailSender {\n readonly name = 'console';\n\n private readonly log: (message: string) => void;\n private readonly includeHtml: boolean;\n private nextId = 1;\n\n constructor(options: ConsoleEmailSenderOptions = {}) {\n this.log = options.logger ?? console.log;\n this.includeHtml = options.includeHtml ?? false;\n }\n\n async send(options: SendMailOptions): Promise<SendResult> {\n const to = normalizeRecipients(options.to).map((r) => r.name ? `${r.name} <${r.address}>` : r.address).join(', ');\n const from = options.from ? JSON.stringify(options.from) : '(default)';\n const messageId = `console-${this.nextId++}-${Date.now()}`;\n\n const separator = '─'.repeat(60);\n const lines = [\n `\\n┌${separator}┐`,\n `│ [ts-mailkit:console] DISPATCHED EMAIL (${messageId})`,\n `├${separator}┤`,\n `│ From: ${from}`,\n `│ To: ${to}`,\n `│ Subject: ${options.subject}`,\n `├${separator}┤`,\n ];\n\n if (options.text) {\n lines.push('│ Text Body:');\n for (const line of options.text.split('\\n')) {\n lines.push(`│ ${line}`);\n }\n }\n\n if (this.includeHtml && options.html) {\n lines.push('│ HTML Body:');\n for (const line of options.html.split('\\n')) {\n lines.push(`│ ${line}`);\n }\n }\n\n lines.push(`└${separator}┘\\n`);\n\n this.log(lines.join('\\n'));\n\n return {\n success: true,\n messageId,\n response: { logged: true },\n };\n }\n}\n","import type { EmailTemplateDto } from './dto/index.js';\nimport { htmlToPlainText } from '../renderers/utils/html-to-plaintext.js';\n\nexport interface BrandingConfig {\n /**\n * Default brand, application, or company name.\n * @default 'Application'\n */\n brandName?: string;\n\n /**\n * Optional custom security / disclaimer advisory message.\n */\n securityMessage?: string;\n\n /**\n * Optional custom footer generator or string.\n */\n footer?: string | ((brandName: string) => string);\n\n /**\n * Optional default logo URL to display top-center in templated emails.\n */\n logoUrl?: string;\n}\n\nconst DEFAULT_SECURITY_MESSAGE =\n 'If you did not request this, please ignore this email or contact support if you have concerns.';\n\nfunction defaultFooter(brandName: string): string {\n return `© ${new Date().getFullYear()} ${brandName}. All rights reserved.`;\n}\n\n/**\n * Factory for creating pre-populated, type-safe email template DTOs.\n */\nexport class EmailTemplateFactory {\n private readonly defaultBrandName: string;\n private readonly defaultSecurityMessage: string;\n private readonly footerResolver: (brandName: string) => string;\n private readonly defaultLogoUrl?: string;\n\n constructor(config: BrandingConfig = {}) {\n this.defaultBrandName = config.brandName || 'Application';\n this.defaultSecurityMessage = config.securityMessage || DEFAULT_SECURITY_MESSAGE;\n this.defaultLogoUrl = config.logoUrl;\n if (typeof config.footer === 'function') {\n this.footerResolver = config.footer;\n } else if (typeof config.footer === 'string') {\n const fixedFooter = config.footer;\n this.footerResolver = () => fixedFooter;\n } else {\n this.footerResolver = defaultFooter;\n }\n }\n\n private resolveBrand(override?: string): string {\n return override || this.defaultBrandName;\n }\n\n private buildFooter(brandName: string): string {\n return this.footerResolver(brandName);\n }\n\n /**\n * Welcome / email-verification email sent after registration.\n */\n createEmailVerification(\n username: string,\n verificationUrl: string,\n otp: string,\n brandName?: string\n ): EmailTemplateDto {\n const brand = this.resolveBrand(brandName);\n const body = `Hi ${username},<br/>Thank you for signing up. Use the code below or click the button to verify your email address.`;\n return {\n subject: 'Verify Your Email Address',\n header: `Welcome to ${brand}!`,\n body,\n logoUrl: this.defaultLogoUrl,\n otpCode: otp,\n actionUrl: verificationUrl,\n actionText: 'Verify Email',\n extraMessage: this.defaultSecurityMessage,\n footer: this.buildFooter(brand),\n userName: username,\n fromName: brand,\n noHtmlMessage:\n htmlToPlainText(body) +\n `\\n\\nYour verification code is: ${otp}\\n\\nAlternatively, verify here:\\n${verificationUrl}`,\n };\n }\n\n /**\n * Password-reset email with an optional OTP code and action link.\n */\n createPasswordReset(\n username: string,\n resetUrl: string,\n otp: string = '',\n brandName?: string\n ): EmailTemplateDto {\n const brand = this.resolveBrand(brandName);\n const body = `Hi ${username},<br/>We received a request to reset your password. Use the OTP code below or click the button to proceed.`;\n const plainTextOtp = otp ? `\\n\\nYour OTP code is: ${otp}` : '';\n return {\n subject: 'Password Reset Request',\n header: 'Reset Your Password',\n body,\n logoUrl: this.defaultLogoUrl,\n otpCode: otp || undefined,\n actionUrl: resetUrl,\n actionText: 'Reset Password',\n extraMessage: this.defaultSecurityMessage,\n footer: this.buildFooter(brand),\n userName: username,\n fromName: brand,\n noHtmlMessage:\n htmlToPlainText(body) +\n plainTextOtp +\n `\\n\\nAlternatively, you can use the following link to reset your password:\\n${resetUrl}`,\n };\n }\n\n /**\n * Generic plain message email (no action button, no OTP).\n */\n createSimpleMessage(\n subject: string,\n header: string,\n body: string,\n brandName?: string\n ): EmailTemplateDto {\n const brand = this.resolveBrand(brandName);\n return {\n subject,\n header,\n body,\n logoUrl: this.defaultLogoUrl,\n footer: this.buildFooter(brand),\n fromName: brand,\n noHtmlMessage: htmlToPlainText(body),\n };\n }\n\n /**\n * Newsletter / announcement email with an optional hero image and CTA button.\n */\n createNewsLetter(\n subject: string,\n header: string,\n body: string,\n imageUrl?: string,\n actionUrl?: string,\n actionText?: string,\n brandName?: string,\n logoUrl?: string\n ): EmailTemplateDto {\n const brand = this.resolveBrand(brandName);\n let noHtmlMessage = htmlToPlainText(body);\n if (actionUrl) {\n noHtmlMessage += `\\n\\n${actionText || 'Learn more'}: ${actionUrl}`;\n }\n return {\n subject,\n header,\n body,\n logoUrl: logoUrl || this.defaultLogoUrl,\n imageUrl,\n actionUrl,\n actionText,\n footer: this.buildFooter(brand),\n fromName: brand,\n noHtmlMessage,\n };\n }\n\n /**\n * Two-factor authentication email with OTP code and optional magic link.\n */\n create2FAEmail(\n username: string,\n otp: string,\n magicLink: string = '',\n brandName?: string\n ): EmailTemplateDto {\n const brand = this.resolveBrand(brandName);\n const body = `Hi ${username},<br/>Use the code below or click the button to complete your login.`;\n const plainLink = magicLink ? `\\n\\nAlternatively, verify here:\\n${magicLink}` : '';\n return {\n subject: 'Your Login Verification Code',\n header: 'Two-Factor Authentication',\n body,\n logoUrl: this.defaultLogoUrl,\n otpCode: otp,\n actionUrl: magicLink || undefined,\n actionText: magicLink ? 'Verify Login' : undefined,\n extraMessage: this.defaultSecurityMessage,\n footer: this.buildFooter(brand),\n userName: username,\n fromName: brand,\n noHtmlMessage: htmlToPlainText(body) + `\\n\\nYour verification code is: ${otp}` + plainLink,\n };\n }\n\n /**\n * Magic link sign-in email (no OTP, button only).\n */\n createMagicLinkEmail(\n username: string,\n magicLink: string,\n brandName?: string\n ): EmailTemplateDto {\n const brand = this.resolveBrand(brandName);\n const body = `Hi ${username},<br/>Click the button below to sign in. No password needed.`;\n return {\n subject: 'Your Magic Link',\n header: `Sign In to ${brand}`,\n body,\n logoUrl: this.defaultLogoUrl,\n actionUrl: magicLink,\n actionText: 'Sign In',\n extraMessage: this.defaultSecurityMessage,\n footer: this.buildFooter(brand),\n userName: username,\n fromName: brand,\n noHtmlMessage: htmlToPlainText(body) + `\\n\\nSign in here:\\n${magicLink}`,\n };\n }\n\n // ─── Default Static Instance ──────────────────────────────────────────────\n private static _defaultInstance?: EmailTemplateFactory;\n\n private static get defaultInstance(): EmailTemplateFactory {\n if (!this._defaultInstance) {\n this._defaultInstance = new EmailTemplateFactory();\n }\n return this._defaultInstance;\n }\n\n static createEmailVerification(\n username: string,\n verificationUrl: string,\n otp: string,\n brandName?: string\n ): EmailTemplateDto {\n return this.defaultInstance.createEmailVerification(username, verificationUrl, otp, brandName);\n }\n\n static createPasswordReset(\n username: string,\n resetUrl: string,\n otp?: string,\n brandName?: string\n ): EmailTemplateDto {\n return this.defaultInstance.createPasswordReset(username, resetUrl, otp, brandName);\n }\n\n static createSimpleMessage(\n subject: string,\n header: string,\n body: string,\n brandName?: string\n ): EmailTemplateDto {\n return this.defaultInstance.createSimpleMessage(subject, header, body, brandName);\n }\n\n static createNewsLetter(\n subject: string,\n header: string,\n body: string,\n imageUrl?: string,\n actionUrl?: string,\n actionText?: string,\n brandName?: string,\n logoUrl?: string\n ): EmailTemplateDto {\n return this.defaultInstance.createNewsLetter(\n subject,\n header,\n body,\n imageUrl,\n actionUrl,\n actionText,\n brandName,\n logoUrl\n );\n }\n\n static create2FAEmail(\n username: string,\n otp: string,\n magicLink?: string,\n brandName?: string\n ): EmailTemplateDto {\n return this.defaultInstance.create2FAEmail(username, otp, magicLink, brandName);\n }\n\n static createMagicLinkEmail(\n username: string,\n magicLink: string,\n brandName?: string\n ): EmailTemplateDto {\n return this.defaultInstance.createMagicLinkEmail(username, magicLink, brandName);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACyBO,SAAS,kBAAkB,OAA6B;AAC7D,MAAI,CAAC,SAAS,OAAO,UAAU,UAAU;AACvC,WAAO,EAAE,SAAS,GAAG;AAAA,EACvB;AACA,QAAM,UAAU,MAAM,KAAK;AAC3B,QAAM,QAAQ,QAAQ,MAAM,uDAAuD;AACnF,MAAI,CAAC,OAAO;AACV,WAAO,EAAE,SAAS,QAAQ;AAAA,EAC5B;AACA,SAAO;AAAA,IACL,SAAS,MAAM,CAAC,EAAE,KAAK;AAAA,IACvB,MAAM,MAAM,CAAC,GAAG,KAAK,K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QAAQ,MAAM,SAAS;AAAA,EAClF;AAAA,EAEA,OAAO,iBACL,SACA,QACA,MACA,UACA,WACA,YACA,WACA,SACkB;AAClB,WAAO,KAAK,gBAAgB;AAAA,MAC1B;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA,EAEA,OAAO,eACL,UACA,KACA,WACA,WACkB;AAClB,WAAO,KAAK,gBAAgB,eAAe,UAAU,KAAK,WAAW,SAAS;AAAA,EAChF;AAAA,EAEA,OAAO,qBACL,UACA,WACA,WACkB;AAClB,WAAO,KAAK,gBAAgB,qBAAqB,UAAU,WAAW,SAAS;AAAA,EACjF;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/core/types.ts","../src/core/errors.ts","../src/renderers/utils/html-to-plaintext.ts","../src/renderers/default/default-renderer.ts","../src/core/client.ts","../src/transports/zeptomail/zeptomail-sender.ts","../src/transports/memory/memory-sender.ts","../src/transports/console/console-sender.ts","../src/templates/factory.ts"],"sourcesContent":["// ─── Core Types, Envelopes & Errors ──────────────────────────────────────────\nexport * from './core/types.js';\nexport * from './core/errors.js';\nexport * from './core/client.js';\n\n// ─── Transport Interface & Implementations ────────────────────────────────────\nexport * from './transports/sender.interface.js';\nexport * from './transports/zeptomail/zeptomail-sender.js';\nexport * from './transports/zeptomail/types.js';\nexport * from './transports/memory/memory-sender.js';\nexport * from './transports/console/console-sender.js';\n\n// ─── Template DTOs & Factory ──────────────────────────────────────────────────\nexport * from './templates/dto/index.js';\nexport * from './templates/factory.js';\n\n// ─── Renderers & Utilities ────────────────────────────────────────────────────\nexport * from './renderers/renderer.interface.js';\nexport * from './renderers/default/default-renderer.js';\nexport * from './renderers/utils/html-to-plaintext.js';\n","/**\n * Standard email address representation with optional display name.\n */\nexport interface EmailAddress {\n address: string;\n name?: string;\n}\n\n/**\n * Flexible recipient representation allowing string ('user@example.com'),\n * EmailAddress ({ address: 'user@example.com', name: 'User' }),\n * or legacy/standard object ({ email: 'user@example.com', name: 'User' }).\n */\nexport type Recipient =\n | string\n | EmailAddress\n | { email: string; name?: string };\n\n/**\n * Parses an RFC 5322 formatted address string into an EmailAddress.\n * Supports formats such as:\n * - \"user@example.com\" -> { address: \"user@example.com\" }\n * - \"Sender Name <sender@example.com>\" -> { name: \"Sender Name\", address: \"sender@example.com\" }\n * - \"\\\"Sender Name\\\" <sender@example.com>\" -> { name: \"Sender Name\", address: \"sender@example.com\" }\n */\nexport function parseEmailAddress(input: string): EmailAddress {\n if (!input || typeof input !== 'string') {\n return { address: '' };\n }\n const trimmed = input.trim();\n const match = trimmed.match(/^(?:[\"']?([^\"']+)[\"']?\\s+)?<?([^\\s<>@]+@[^\\s<>@]+)>?$/);\n if (!match) {\n return { address: trimmed };\n }\n return {\n address: match[2].trim(),\n name: match[1]?.trim() || undefined,\n };\n}\n\n/**\n * Normalizes a Recipient value into a standardized EmailAddress.\n */\nexport function normalizeRecipient(recipient: Recipient): EmailAddress {\n if (typeof recipient === 'string') {\n return { address: recipient.trim() };\n }\n if ('email' in recipient) {\n return {\n address: (recipient.email ?? '').trim(),\n name: recipient.name?.trim(),\n };\n }\n return {\n address: (recipient.address ?? '').trim(),\n name: recipient.name?.trim(),\n };\n}\n\n/**\n * Normalizes a single or array of Recipients into an array of EmailAddress.\n */\nexport function normalizeRecipients(\n recipients?: Recipient | Recipient[]\n): EmailAddress[] {\n if (!recipients) return [];\n const list = Array.isArray(recipients) ? recipients : [recipients];\n return list.map(normalizeRecipient).filter((r) => r.address.length > 0);\n}\n\n/**\n * Email attachment representation.\n */\nexport interface EmailAttachment {\n filename: string;\n /**\n * Content can be base64-encoded string, plain text, or binary Buffer/Uint8Array.\n */\n content: string | Uint8Array;\n mimeType?: string;\n contentType?: string;\n cid?: string;\n}\n\n/**\n * Options for sending an email through a transport adapter.\n */\nexport interface SendMailOptions {\n to: Recipient | Recipient[];\n from?: Recipient;\n subject: string;\n html: string;\n text?: string;\n cc?: Recipient | Recipient[];\n bcc?: Recipient | Recipient[];\n replyTo?: Recipient | Recipient[];\n attachments?: EmailAttachment[];\n headers?: Record<string, string>;\n tags?: string[];\n metadata?: Record<string, string>;\n}\n\n/**\n * Result returned by an IEmailSender upon dispatch.\n */\nexport interface SendResult {\n success: boolean;\n messageId?: string;\n response?: unknown;\n}\n","/**\n * Base error class for all ts-mailkit errors.\n */\nexport class MailKitError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'MailKitError';\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/**\n * Thrown when transport configuration is missing or invalid.\n */\nexport class ConfigurationError extends MailKitError {\n constructor(message: string) {\n super(message);\n this.name = 'ConfigurationError';\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/**\n * Thrown when an email transport fails to dispatch an email.\n */\nexport class TransportError extends MailKitError {\n readonly transportName: string;\n readonly statusCode?: number;\n readonly responseBody?: string;\n readonly cause?: unknown;\n\n constructor(\n message: string,\n options: {\n transportName: string;\n statusCode?: number;\n responseBody?: string;\n cause?: unknown;\n }\n ) {\n super(message);\n this.name = 'TransportError';\n this.transportName = options.transportName;\n this.statusCode = options.statusCode;\n this.responseBody = options.responseBody;\n this.cause = options.cause;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/**\n * Thrown when template rendering or DTO validation fails.\n */\nexport class TemplateError extends MailKitError {\n constructor(message: string) {\n super(message);\n this.name = 'TemplateError';\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","/**\n * Decodes common HTML entities into their plain text equivalents.\n */\nexport function decodeHtmlEntities(text: string): string {\n return text\n .replace(/ /gi, ' ')\n .replace(/&/gi, '&')\n .replace(/</gi, '<')\n .replace(/>/gi, '>')\n .replace(/"/gi, '\"')\n .replace(/'/gi, \"'\")\n .replace(/©/gi, '©')\n .replace(/®/gi, '®')\n .replace(/™/gi, '™');\n}\n\n/**\n * Strips HTML tags and normalizes whitespace into readable plain text.\n * Converts <br>, <p>, and <div> into appropriate line breaks.\n */\nexport function htmlToPlainText(html: string): string {\n if (!html) return '';\n\n return decodeHtmlEntities(\n html\n .replace(/<br\\s*\\/?>/gi, '\\n')\n .replace(/<\\/p>/gi, '\\n\\n')\n .replace(/<\\/div>/gi, '\\n')\n .replace(/<\\/h[1-6]>/gi, '\\n\\n')\n .replace(/<[^>]*>/g, '')\n )\n .replace(/[ \\t]+/g, ' ')\n .replace(/\\n\\s*\\n\\s*\\n+/g, '\\n\\n')\n .trim();\n}\n","import type { EmailTemplateDto } from '../../templates/dto/index.js';\nimport type { IEmailRenderer, RenderedEmail } from '../renderer.interface.js';\nimport { htmlToPlainText } from '../utils/html-to-plaintext.js';\n\nexport interface DefaultRendererOptions {\n /**\n * Primary brand color for buttons and accents.\n * @default '#4f46e5'\n */\n primaryColor?: string;\n\n /**\n * Font stack used in the HTML wrapper.\n * @default \"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif\"\n */\n fontFamily?: string;\n\n /**\n * Container maximum width.\n * @default '600px'\n */\n maxWidth?: string;\n\n /**\n * Default logo URL displayed at the top-center of the email if not provided in the DTO.\n * Must be a valid http(s) URL.\n */\n logoUrl?: string;\n}\n\n/**\n * Validates whether a string is a valid HTTP or HTTPS URL.\n */\nexport function isValidHttpUrl(urlString?: string): boolean {\n if (!urlString || typeof urlString !== 'string') return false;\n try {\n const url = new URL(urlString.trim());\n return (url.protocol === 'http:' || url.protocol === 'https:') && url.hostname.length > 0;\n } catch {\n return false;\n }\n}\n\n/**\n * Builds a plain-text fallback string from an email DTO.\n */\nexport function buildPlainText(dto: EmailTemplateDto): string {\n if (dto.noHtmlMessage) {\n return dto.noHtmlMessage;\n }\n\n const divider = '──────────────────────────────';\n const parts: string[] = [];\n\n if (dto.header) {\n parts.push(dto.header, divider);\n }\n\n if (dto.body) {\n parts.push(htmlToPlainText(dto.body));\n }\n\n if (dto.otpCode) {\n parts.push(`Verification Code: ${dto.otpCode}`);\n }\n\n if (dto.actionText && dto.actionUrl) {\n parts.push(`${dto.actionText}: ${dto.actionUrl}`);\n }\n\n if (dto.extraMessage) {\n parts.push(htmlToPlainText(dto.extraMessage));\n }\n\n if (dto.footer) {\n parts.push(`${divider}\\n${htmlToPlainText(dto.footer)}`);\n }\n\n return parts.join('\\n\\n');\n}\n\n/**\n * Builds a responsive, styled HTML email document from an email DTO.\n */\nexport function buildHtml(dto: EmailTemplateDto, options: DefaultRendererOptions = {}): string {\n const primaryColor = options.primaryColor || '#4f46e5';\n const fontFamily =\n options.fontFamily ||\n \"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif\";\n const maxWidth = options.maxWidth || '600px';\n\n const parts: string[] = [\n `<!DOCTYPE html>`,\n `<html lang=\"en\">`,\n `<head>`,\n `<meta charset=\"UTF-8\">`,\n `<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">`,\n `<title>${dto.subject}</title>`,\n `</head>`,\n `<body style=\"margin:0;padding:24px 16px;background-color:#f9fafb;font-family:${fontFamily};color:#1f2937;line-height:1.6;\">`,\n `<div style=\"max-width:${maxWidth};margin:0 auto;background-color:#ffffff;padding:32px 28px;border-radius:8px;box-shadow:0 1px 3px rgba(0,0,0,0.1);border:1px solid #f3f4f6;\">`,\n ];\n\n const logoCandidate = dto.logoUrl ?? options.logoUrl;\n if (logoCandidate && isValidHttpUrl(logoCandidate)) {\n const validLogo = logoCandidate.trim();\n parts.push(\n `<div style=\"margin-bottom:24px;text-align:center;\">`,\n ` <img src=\"${validLogo}\" alt=\"${dto.fromName || 'Logo'}\" style=\"max-height:48px;max-width:200px;height:auto;width:auto;display:inline-block;border:0;outline:none;text-decoration:none;\" />`,\n `</div>`\n );\n }\n\n if (dto.imageUrl) {\n parts.push(\n `<div style=\"margin-bottom:24px;text-align:center;\">`,\n ` <img src=\"${dto.imageUrl}\" alt=\"Header\" style=\"max-width:100%;height:auto;border-radius:6px;\" />`,\n `</div>`\n );\n }\n\n if (dto.header) {\n parts.push(\n `<h2 style=\"margin:0 0 16px;font-size:1.5rem;font-weight:700;color:#111827;letter-spacing:-0.025em;\">${dto.header}</h2>`\n );\n }\n\n if (dto.body) {\n parts.push(`<div style=\"margin:0 0 20px;font-size:1rem;color:#374151;\">${dto.body}</div>`);\n }\n\n if (dto.otpCode) {\n parts.push(\n `<div style=\"margin:24px 0;padding:20px;background-color:#f3f4f6;border-radius:8px;text-align:center;\">`,\n ` <span style=\"font-size:2rem;letter-spacing:0.5rem;font-weight:700;color:#111827;font-family:monospace;\">${dto.otpCode}</span>`,\n `</div>`\n );\n }\n\n if (dto.actionUrl && dto.actionText) {\n parts.push(\n `<div style=\"margin:24px 0;text-align:center;\">`,\n ` <a href=\"${dto.actionUrl}\" style=\"display:inline-block;padding:12px 28px;background-color:${primaryColor};color:#ffffff;border-radius:6px;text-decoration:none;font-weight:600;font-size:1rem;text-align:center;box-sizing:border-box;\">${dto.actionText}</a>`,\n `</div>`\n );\n }\n\n if (dto.extraMessage) {\n parts.push(\n `<div style=\"margin:20px 0 0;font-size:0.875rem;color:#6b7280;line-height:1.5;\">${dto.extraMessage}</div>`\n );\n }\n\n if (dto.footer) {\n parts.push(\n `<div style=\"margin-top:32px;padding-top:20px;border-top:1px solid #e5e7eb;font-size:0.75rem;color:#9ca3af;text-align:center;\">${dto.footer}</div>`\n );\n }\n\n parts.push(`</div>`, `</body>`, `</html>`);\n return parts.join('\\n');\n}\n\n/**\n * Default HTML and plain-text email renderer for ts-mailkit.\n */\nexport class DefaultEmailRenderer implements IEmailRenderer {\n private readonly options: DefaultRendererOptions;\n\n constructor(options: DefaultRendererOptions = {}) {\n this.options = options;\n }\n\n render(dto: EmailTemplateDto): RenderedEmail {\n return {\n html: buildHtml(dto, this.options),\n text: buildPlainText(dto),\n };\n }\n}\n","import type { IEmailSender } from '../transports/sender.interface.js';\nimport type { IEmailRenderer, RenderedEmail } from '../renderers/renderer.interface.js';\nimport { DefaultEmailRenderer } from '../renderers/default/default-renderer.js';\nimport { htmlToPlainText } from '../renderers/utils/html-to-plaintext.js';\nimport type { EmailTemplateDto } from '../templates/dto/index.js';\nimport {\n normalizeRecipient,\n normalizeRecipients,\n type Recipient,\n type SendMailOptions,\n type SendResult,\n} from './types.js';\nimport { ConfigurationError } from './errors.js';\n\nexport interface SendTemplateOptions {\n /**\n * One or more recipient email addresses.\n */\n to: Recipient | Recipient[];\n /**\n * Templated email DTO to render and send.\n */\n template: EmailTemplateDto;\n /**\n * Optional recipient display name (used when `to` is a plain string).\n */\n toName?: string;\n /**\n * Optional sender display name override for this specific email.\n */\n fromName?: string;\n /**\n * Optional sender email address override.\n */\n from?: Recipient;\n /**\n * Optional CC recipients.\n */\n cc?: Recipient | Recipient[];\n /**\n * Optional BCC recipients.\n */\n bcc?: Recipient | Recipient[];\n /**\n * Optional Reply-To recipients.\n */\n replyTo?: Recipient | Recipient[];\n /**\n * Optional file attachments.\n */\n attachments?: SendMailOptions['attachments'];\n /**\n * Optional custom headers.\n */\n headers?: Record<string, string>;\n /**\n * Optional tags for tracking.\n */\n tags?: string[];\n /**\n * Optional metadata.\n */\n metadata?: Record<string, string>;\n}\n\nexport interface MailKitOptions {\n /**\n * The transport adapter used to dispatch emails (e.g. ZeptoMailHttpSender, MemoryEmailSender).\n */\n transport: IEmailSender;\n /**\n * Custom renderer implementation. Defaults to DefaultEmailRenderer.\n */\n renderer?: IEmailRenderer;\n /**\n * Default sender address or Recipient.\n */\n defaultFrom?: Recipient;\n /**\n * Default brand or application name.\n */\n defaultBrandName?: string;\n /**\n * Optional asynchronous or synchronous resolver to dynamically resolve brand/tenant name.\n * Useful for multitenant applications.\n */\n brandNameResolver?: () => Promise<string> | string;\n}\n\n/**\n * Main email client and orchestration service for ts-mailkit.\n */\nexport class MailKit {\n private readonly transport: IEmailSender;\n private readonly renderer: IEmailRenderer;\n private readonly defaultFrom?: Recipient;\n private readonly defaultBrandName?: string;\n private readonly brandNameResolver?: () => Promise<string> | string;\n\n constructor(options: MailKitOptions) {\n if (!options.transport) {\n throw new ConfigurationError('MailKit: A transport adapter (IEmailSender) is required.');\n }\n this.transport = options.transport;\n this.renderer = options.renderer ?? new DefaultEmailRenderer();\n this.defaultFrom = options.defaultFrom;\n this.defaultBrandName = options.defaultBrandName;\n this.brandNameResolver = options.brandNameResolver;\n }\n\n /**\n * Returns the underlying transport instance.\n */\n getTransport(): IEmailSender {\n return this.transport;\n }\n\n /**\n * Renders an email DTO to HTML and plain text without dispatching.\n */\n async render(template: EmailTemplateDto): Promise<RenderedEmail> {\n return await this.renderer.render(template);\n }\n\n /**\n * Sends an email using a strongly-typed template DTO.\n *\n * Example:\n * ```ts\n * await mailer.send({\n * to: 'user@example.com',\n * template: myDto,\n * });\n * ```\n */\n async send(options: SendTemplateOptions): Promise<SendResult> {\n const template = options.template;\n const recipientName = options.toName ?? template.userName;\n\n // Resolve fromName: explicit option > template.fromName > brand resolver > defaultBrandName\n let resolvedFromName = options.fromName ?? template.fromName;\n if (!resolvedFromName && this.brandNameResolver) {\n resolvedFromName = await this.brandNameResolver();\n }\n if (!resolvedFromName) {\n resolvedFromName = this.defaultBrandName;\n }\n\n // Render template DTO\n const rendered = await this.renderer.render(template);\n const plaintextBody = template.noHtmlMessage ?? rendered.text;\n\n // Format recipients\n let toRecipients: Recipient | Recipient[];\n if (typeof options.to === 'string' && recipientName) {\n toRecipients = { address: options.to, name: recipientName };\n } else {\n toRecipients = options.to;\n }\n\n // Resolve From address\n let from = options.from ?? this.defaultFrom;\n if (resolvedFromName && from) {\n const normalizedFrom = normalizeRecipient(from);\n from = { address: normalizedFrom.address, name: resolvedFromName };\n }\n\n return await this.sendRaw({\n to: toRecipients,\n from,\n subject: template.subject,\n html: rendered.html,\n text: plaintextBody,\n cc: options.cc,\n bcc: options.bcc,\n replyTo: options.replyTo,\n attachments: options.attachments,\n headers: options.headers,\n tags: options.tags,\n metadata: options.metadata,\n });\n }\n\n /**\n * Dispatches a raw, pre-rendered email directly through the transport.\n * If `options.text` is omitted, plain text is automatically derived from `options.html`.\n */\n async sendRaw(options: SendMailOptions): Promise<SendResult> {\n const from = options.from ?? this.defaultFrom;\n const text = options.text ?? (options.html ? htmlToPlainText(options.html) : undefined);\n return await this.transport.send({\n ...options,\n from,\n text,\n });\n }\n}\n\n/**\n * Convenience factory to create a MailKit client instance.\n */\nexport function createMailKit(options: MailKitOptions): MailKit {\n return new MailKit(options);\n}\n","import { ConfigurationError, TransportError } from '../../core/errors.js';\nimport {\n normalizeRecipient,\n normalizeRecipients,\n type SendMailOptions,\n type SendResult,\n} from '../../core/types.js';\nimport type { IEmailSender } from '../sender.interface.js';\nimport type {\n ZeptoMailHttpConfig,\n ZeptoMailSendPayload,\n ZeptoMailAttachmentPayload,\n} from './types.js';\n\n/**\n * ZeptoMail (Zoho Mail transactional email HTTP API) transport adapter.\n *\n * Designed for zero dependencies and universal edge compatibility (Node.js, Bun, Deno, Cloudflare Workers)\n * by utilizing the standard global `fetch` API.\n */\nexport class ZeptoMailHttpSender implements IEmailSender {\n readonly name = 'zeptomail';\n\n private readonly apiUrl: string;\n private readonly authHeader: string;\n private readonly defaultFrom: { address: string; name?: string };\n private readonly fetchImpl: typeof fetch;\n\n constructor(config: ZeptoMailHttpConfig) {\n if (!config.apiToken || typeof config.apiToken !== 'string') {\n throw new ConfigurationError('ZeptoMailHttpSender: Missing or invalid apiToken.');\n }\n if (!config.from) {\n throw new ConfigurationError('ZeptoMailHttpSender: Missing required default from address.');\n }\n\n const host = (config.apiHost || 'api.zeptomail.com').replace(/^https?:\\/\\//, '').replace(/\\/+$/, '');\n this.apiUrl = `https://${host}/v1.1/email`;\n\n // Normalize auth token header. In ZeptoMail, if the user already included \"Zoho-enczapikey \", use as is; otherwise format standard header.\n const token = config.apiToken.trim();\n this.authHeader = token.startsWith('Zoho-') ? token : `Zoho-enczapikey ${token}`;\n\n this.defaultFrom = normalizeRecipient(config.from);\n if (!this.defaultFrom.address) {\n throw new ConfigurationError('ZeptoMailHttpSender: Configured from address must not be empty.');\n }\n\n this.fetchImpl = config.fetch ?? globalThis.fetch;\n if (typeof this.fetchImpl !== 'function') {\n throw new ConfigurationError(\n 'ZeptoMailHttpSender: No global fetch implementation found. Pass a custom fetch to ZeptoMailHttpConfig if running on Node < 18.'\n );\n }\n }\n\n /**\n * Dispatches an email using Zoho ZeptoMail API v1.1.\n */\n async send(options: SendMailOptions): Promise<SendResult> {\n const toRecipients = normalizeRecipients(options.to);\n if (toRecipients.length === 0) {\n throw new TransportError('ZeptoMailHttpSender: At least one recipient (to) must be specified.', {\n transportName: this.name,\n });\n }\n\n const resolvedFrom = options.from ? normalizeRecipient(options.from) : this.defaultFrom;\n\n const payload: ZeptoMailSendPayload = {\n from: {\n address: resolvedFrom.address,\n name: resolvedFrom.name,\n },\n to: toRecipients.map((r) => ({\n email_address: {\n address: r.address,\n name: r.name || '',\n },\n })),\n subject: options.subject,\n htmlbody: options.html,\n textbody: options.text,\n };\n\n if (options.cc) {\n const ccList = normalizeRecipients(options.cc);\n if (ccList.length > 0) {\n payload.cc = ccList.map((r) => ({\n email_address: { address: r.address, name: r.name || '' },\n }));\n }\n }\n\n if (options.bcc) {\n const bccList = normalizeRecipients(options.bcc);\n if (bccList.length > 0) {\n payload.bcc = bccList.map((r) => ({\n email_address: { address: r.address, name: r.name || '' },\n }));\n }\n }\n\n if (options.replyTo) {\n const replyToList = normalizeRecipients(options.replyTo);\n if (replyToList.length > 0) {\n payload.reply_to = replyToList.map((r) => ({\n address: r.address,\n name: r.name,\n }));\n }\n }\n\n if (options.attachments && options.attachments.length > 0) {\n payload.attachments = options.attachments.map((att): ZeptoMailAttachmentPayload => {\n let contentBase64: string;\n if (typeof att.content === 'string') {\n contentBase64 = att.content;\n } else {\n // Buffer or Uint8Array\n if (typeof Buffer !== 'undefined') {\n contentBase64 = Buffer.from(att.content).toString('base64');\n } else {\n // Browser / Edge fallback for Uint8Array\n let binary = '';\n const bytes = new Uint8Array(att.content);\n for (let i = 0; i < bytes.byteLength; i++) {\n binary += String.fromCharCode(bytes[i]);\n }\n contentBase64 = btoa(binary);\n }\n }\n\n return {\n name: att.filename,\n content: contentBase64,\n mime_type: att.mimeType || att.contentType || 'application/octet-stream',\n cid: att.cid,\n };\n });\n }\n\n let response: Response;\n try {\n response = await this.fetchImpl(this.apiUrl, {\n method: 'POST',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n Authorization: this.authHeader,\n },\n body: JSON.stringify(payload),\n });\n } catch (err) {\n throw new TransportError(`ZeptoMailHttpSender: Network request failed: ${err instanceof Error ? err.message : String(err)}`, {\n transportName: this.name,\n cause: err,\n });\n }\n\n const responseText = await response.text();\n let responseData: any;\n try {\n responseData = responseText ? JSON.parse(responseText) : {};\n } catch {\n responseData = { raw: responseText };\n }\n\n if (!response.ok) {\n const errorMessage =\n responseData?.error?.message ||\n responseData?.message ||\n `HTTP ${response.status}: ${responseText || response.statusText}`;\n\n throw new TransportError(`ZeptoMailHttpSender: Failed to send email - ${errorMessage}`, {\n transportName: this.name,\n statusCode: response.status,\n responseBody: responseText,\n });\n }\n\n // Extract message ID from standard ZeptoMail v1.1 response structure:\n // { data: [ { message_id: \"...\" } ] }\n const messageId = responseData?.data?.[0]?.message_id;\n\n return {\n success: true,\n messageId,\n response: responseData,\n };\n }\n}\n","import type { SendMailOptions, SendResult } from '../../core/types.js';\nimport type { IEmailSender } from '../sender.interface.js';\n\n/**\n * In-memory email sender for automated testing, local development, and CI environments.\n * Captures all dispatched emails and provides inspection methods.\n */\nexport class MemoryEmailSender implements IEmailSender {\n readonly name = 'memory';\n\n private sentMails: SendMailOptions[] = [];\n private nextId = 1;\n\n async send(options: SendMailOptions): Promise<SendResult> {\n this.sentMails.push({ ...options });\n const messageId = `mem-${this.nextId++}-${Date.now()}`;\n return {\n success: true,\n messageId,\n response: { id: messageId },\n };\n }\n\n /**\n * Returns a copy of all emails sent through this transport instance.\n */\n getSentMails(): SendMailOptions[] {\n return [...this.sentMails];\n }\n\n /**\n * Returns the most recent email sent, or undefined if no emails have been sent.\n */\n getLastMail(): SendMailOptions | undefined {\n return this.sentMails.length > 0\n ? { ...this.sentMails[this.sentMails.length - 1] }\n : undefined;\n }\n\n /**\n * Clears all recorded sent emails.\n */\n clear(): void {\n this.sentMails = [];\n }\n\n /**\n * Returns the total count of sent emails.\n */\n count(): number {\n return this.sentMails.length;\n }\n}\n","import { normalizeRecipients, type SendMailOptions, type SendResult } from '../../core/types.js';\nimport type { IEmailSender } from '../sender.interface.js';\n\nexport interface ConsoleEmailSenderOptions {\n /**\n * Log level or custom log printer. Defaults to `console.log`.\n */\n logger?: (message: string) => void;\n /**\n * Whether to include the full HTML body in console output.\n * Defaults to false (prints plain text or a summary).\n */\n includeHtml?: boolean;\n}\n\n/**\n * Console logger transport that prints dispatched emails to stdout/stderr.\n * Ideal for development and debugging.\n */\nexport class ConsoleEmailSender implements IEmailSender {\n readonly name = 'console';\n\n private readonly log: (message: string) => void;\n private readonly includeHtml: boolean;\n private nextId = 1;\n\n constructor(options: ConsoleEmailSenderOptions = {}) {\n this.log = options.logger ?? console.log;\n this.includeHtml = options.includeHtml ?? false;\n }\n\n async send(options: SendMailOptions): Promise<SendResult> {\n const to = normalizeRecipients(options.to).map((r) => r.name ? `${r.name} <${r.address}>` : r.address).join(', ');\n const from = options.from ? JSON.stringify(options.from) : '(default)';\n const messageId = `console-${this.nextId++}-${Date.now()}`;\n\n const separator = '─'.repeat(60);\n const lines = [\n `\\n┌${separator}┐`,\n `│ [ts-mailkit:console] DISPATCHED EMAIL (${messageId})`,\n `├${separator}┤`,\n `│ From: ${from}`,\n `│ To: ${to}`,\n `│ Subject: ${options.subject}`,\n `├${separator}┤`,\n ];\n\n if (options.text) {\n lines.push('│ Text Body:');\n for (const line of options.text.split('\\n')) {\n lines.push(`│ ${line}`);\n }\n }\n\n if (this.includeHtml && options.html) {\n lines.push('│ HTML Body:');\n for (const line of options.html.split('\\n')) {\n lines.push(`│ ${line}`);\n }\n }\n\n lines.push(`└${separator}┘\\n`);\n\n this.log(lines.join('\\n'));\n\n return {\n success: true,\n messageId,\n response: { logged: true },\n };\n }\n}\n","import type { EmailTemplateDto, EmailVerificationParams, MagicLinkParams, NewsletterParams, PasswordResetParams, SimpleMessageParams, TwoFactorParams,} from './dto/index.js';\nimport { htmlToPlainText } from '../renderers/utils/html-to-plaintext.js';\n\nexport interface BrandingConfig {\n /**\n * Default brand, application, or company name.\n * @default 'Application'\n */\n brandName?: string;\n\n /**\n * Optional custom security / disclaimer advisory message.\n */\n securityMessage?: string;\n\n /**\n * Optional custom footer generator or string.\n */\n footer?: string | ((brandName: string) => string);\n\n /**\n * Optional default logo URL to display top-center in templated emails.\n */\n logoUrl?: string;\n}\n\nconst DEFAULT_SECURITY_MESSAGE =\n 'If you did not request this, please ignore this email or contact support if you have concerns.';\n\nfunction defaultFooter(brandName: string): string {\n return `© ${new Date().getFullYear()} ${brandName}. All rights reserved.`;\n}\n\n/**\n * Factory for creating pre-populated, type-safe email template DTOs.\n */\nexport class EmailTemplateFactory {\n private readonly defaultBrandName: string;\n private readonly defaultSecurityMessage: string;\n private readonly footerResolver: (brandName: string) => string;\n private readonly defaultLogoUrl?: string;\n\n constructor(config: BrandingConfig = {}) {\n this.defaultBrandName = config.brandName || 'Application';\n this.defaultSecurityMessage = config.securityMessage || DEFAULT_SECURITY_MESSAGE;\n this.defaultLogoUrl = config.logoUrl;\n if (typeof config.footer === 'function') {\n this.footerResolver = config.footer;\n } else if (typeof config.footer === 'string') {\n const fixedFooter = config.footer;\n this.footerResolver = () => fixedFooter;\n } else {\n this.footerResolver = defaultFooter;\n }\n }\n\n private resolveBrand(override?: string): string {\n return override || this.defaultBrandName;\n }\n\n private buildFooter(brandName: string): string {\n return this.footerResolver(brandName);\n }\n\n /**\n * Welcome / email-verification email sent after registration.\n */\n createEmailVerification(params: EmailVerificationParams): EmailTemplateDto {\n const { username, verificationUrl, otp, brandName } = params;\n const brand = this.resolveBrand(brandName);\n const body = `Hi ${username},<br/>Thank you for signing up. Use the code below or click the button to verify your email address.`;\n return {\n subject: 'Verify Your Email Address',\n header: `Welcome to ${brand}!`,\n body,\n logoUrl: this.defaultLogoUrl,\n otpCode: otp,\n actionUrl: verificationUrl,\n actionText: 'Verify Email',\n extraMessage: this.defaultSecurityMessage,\n footer: this.buildFooter(brand),\n userName: username,\n fromName: brand,\n noHtmlMessage:\n htmlToPlainText(body) +\n `\\n\\nYour verification code is: ${otp}\\n\\nAlternatively, verify here:\\n${verificationUrl}`,\n };\n }\n\n /**\n * Password-reset email with an optional OTP code and action link.\n */\n createPasswordReset(params: PasswordResetParams): EmailTemplateDto {\n const { username, resetUrl, otp = '', brandName } = params;\n const brand = this.resolveBrand(brandName);\n const body = `Hi ${username},<br/>We received a request to reset your password. Use the OTP code below or click the button to proceed.`;\n const plainTextOtp = otp ? `\\n\\nYour OTP code is: ${otp}` : '';\n return {\n subject: 'Password Reset Request',\n header: 'Reset Your Password',\n body,\n logoUrl: this.defaultLogoUrl,\n otpCode: otp || undefined,\n actionUrl: resetUrl,\n actionText: 'Reset Password',\n extraMessage: this.defaultSecurityMessage,\n footer: this.buildFooter(brand),\n userName: username,\n fromName: brand,\n noHtmlMessage:\n htmlToPlainText(body) +\n plainTextOtp +\n `\\n\\nAlternatively, you can use the following link to reset your password:\\n${resetUrl}`,\n };\n }\n\n /**\n * Generic plain message email (no action button, no OTP).\n */\n createSimpleMessage(params: SimpleMessageParams): EmailTemplateDto {\n const { subject, header, body, brandName } = params;\n const brand = this.resolveBrand(brandName);\n return {\n subject,\n header,\n body,\n logoUrl: this.defaultLogoUrl,\n footer: this.buildFooter(brand),\n fromName: brand,\n noHtmlMessage: htmlToPlainText(body),\n };\n }\n\n /**\n * Newsletter / announcement email with an optional hero image and CTA button.\n */\n createNewsLetter(params: NewsletterParams): EmailTemplateDto {\n const { subject, header, body, imageUrl, actionUrl, actionText, brandName, logoUrl } = params;\n const brand = this.resolveBrand(brandName);\n let noHtmlMessage = htmlToPlainText(body);\n if (actionUrl) {\n noHtmlMessage += `\\n\\n${actionText || 'Learn more'}: ${actionUrl}`;\n }\n return {\n subject,\n header,\n body,\n logoUrl: logoUrl || this.defaultLogoUrl,\n imageUrl,\n actionUrl,\n actionText,\n footer: this.buildFooter(brand),\n fromName: brand,\n noHtmlMessage,\n };\n }\n\n /**\n * Two-factor authentication email with OTP code and optional magic link.\n */\n create2FAEmail(params: TwoFactorParams): EmailTemplateDto {\n const { username, otp, magicLink = '', brandName } = params;\n const brand = this.resolveBrand(brandName);\n const body = `Hi ${username},<br/>Use the code below or click the button to complete your login.`;\n const plainLink = magicLink ? `\\n\\nAlternatively, verify here:\\n${magicLink}` : '';\n return {\n subject: 'Your Login Verification Code',\n header: 'Two-Factor Authentication',\n body,\n logoUrl: this.defaultLogoUrl,\n otpCode: otp,\n actionUrl: magicLink || undefined,\n actionText: magicLink ? 'Verify Login' : undefined,\n extraMessage: this.defaultSecurityMessage,\n footer: this.buildFooter(brand),\n userName: username,\n fromName: brand,\n noHtmlMessage: htmlToPlainText(body) + `\\n\\nYour verification code is: ${otp}` + plainLink,\n };\n }\n\n /**\n * Magic link sign-in email (no OTP, button only).\n */\n createMagicLinkEmail(params: MagicLinkParams): EmailTemplateDto {\n const { username, magicLink, brandName } = params;\n const brand = this.resolveBrand(brandName);\n const body = `Hi ${username},<br/>Click the button below to sign in. No password needed.`;\n return {\n subject: 'Your Magic Link',\n header: `Sign In to ${brand}`,\n body,\n logoUrl: this.defaultLogoUrl,\n actionUrl: magicLink,\n actionText: 'Sign In',\n extraMessage: this.defaultSecurityMessage,\n footer: this.buildFooter(brand),\n userName: username,\n fromName: brand,\n noHtmlMessage: htmlToPlainText(body) + `\\n\\nSign in here:\\n${magicLink}`,\n };\n }\n\n // ─── Default Static Instance ──────────────────────────────────────────────\n private static _defaultInstance?: EmailTemplateFactory;\n\n private static get defaultInstance(): EmailTemplateFactory {\n if (!this._defaultInstance) {\n this._defaultInstance = new EmailTemplateFactory();\n }\n return this._defaultInstance;\n }\n\n static createEmailVerification(params: EmailVerificationParams): EmailTemplateDto {\n return this.defaultInstance.createEmailVerification(params);\n }\n\n static createPasswordReset(params: PasswordResetParams): EmailTemplateDto {\n return this.defaultInstance.createPasswordReset(params);\n }\n\n static createSimpleMessage(params: SimpleMessageParams): EmailTemplateDto {\n return this.defaultInstance.createSimpleMessage(params);\n }\n\n static createNewsLetter(params: NewsletterParams): EmailTemplateDto {\n return this.defaultInstance.createNewsLetter(params);\n }\n\n static create2FAEmail(params: TwoFactorParams): EmailTemplateDto {\n return this.defaultInstance.create2FAEmail(params);\n }\n\n static createMagicLinkEmail(params: MagicLinkParams): EmailTemplateDto {\n return this.defaultInstance.createMagicLinkEmail(params);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACyBO,SAAS,kBAAkB,OAA6B;AAC7D,MAAI,CAAC,SAAS,OAAO,UAAU,UAAU;AACvC,WAAO,EAAE,SAAS,GAAG;AAAA,EACvB;AACA,QAAM,UAAU,MAAM,KAAK;AAC3B,QAAM,QAAQ,QAAQ,MAAM,uDAAuD;AACnF,MAAI,CAAC,OAAO;AACV,WAAO,EAAE,SAAS,QAAQ;AAAA,EAC5B;AACA,SAAO;AAAA,IACL,SAAS,MAAM,CAAC,EAAE,KAAK;AAAA,IACvB,MAAM,MAAM,CAAC,GAAG,KAAK,KAAK;AAAA,EAC5B;AACF;AAKO,SAAS,mBAAmB,WAAoC;AACrE,MAAI,OAAO,cAAc,UAAU;AACjC,WAAO,EAAE,SAAS,UAAU,KAAK,EAAE;AAAA,EACrC;AACA,MAAI,WAAW,WAAW;AACxB,WAAO;AAAA,MACL,UAAU,UAAU,SAAS,IAAI,KAAK;AAAA,MACtC,MAAM,UAAU,MAAM,KAAK;AAAA,IAC7B;AAAA,EACF;AACA,SAAO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Ae,QAA2C;AAC/D,WAAO,KAAK,gBAAgB,eAAe,MAAM;AAAA,EACnD;AAAA,EAEA,OAAO,qBAAqB,QAA2C;AACrE,WAAO,KAAK,gBAAgB,qBAAqB,MAAM;AAAA,EACzD;AACF;","names":[]}
|
package/dist/index.js
CHANGED
|
@@ -561,7 +561,8 @@ var EmailTemplateFactory = class _EmailTemplateFactory {
|
|
|
561
561
|
/**
|
|
562
562
|
* Welcome / email-verification email sent after registration.
|
|
563
563
|
*/
|
|
564
|
-
createEmailVerification(
|
|
564
|
+
createEmailVerification(params) {
|
|
565
|
+
const { username, verificationUrl, otp, brandName } = params;
|
|
565
566
|
const brand = this.resolveBrand(brandName);
|
|
566
567
|
const body = `Hi ${username},<br/>Thank you for signing up. Use the code below or click the button to verify your email address.`;
|
|
567
568
|
return {
|
|
@@ -587,7 +588,8 @@ ${verificationUrl}`
|
|
|
587
588
|
/**
|
|
588
589
|
* Password-reset email with an optional OTP code and action link.
|
|
589
590
|
*/
|
|
590
|
-
createPasswordReset(
|
|
591
|
+
createPasswordReset(params) {
|
|
592
|
+
const { username, resetUrl, otp = "", brandName } = params;
|
|
591
593
|
const brand = this.resolveBrand(brandName);
|
|
592
594
|
const body = `Hi ${username},<br/>We received a request to reset your password. Use the OTP code below or click the button to proceed.`;
|
|
593
595
|
const plainTextOtp = otp ? `
|
|
@@ -614,7 +616,8 @@ ${resetUrl}`
|
|
|
614
616
|
/**
|
|
615
617
|
* Generic plain message email (no action button, no OTP).
|
|
616
618
|
*/
|
|
617
|
-
createSimpleMessage(
|
|
619
|
+
createSimpleMessage(params) {
|
|
620
|
+
const { subject, header, body, brandName } = params;
|
|
618
621
|
const brand = this.resolveBrand(brandName);
|
|
619
622
|
return {
|
|
620
623
|
subject,
|
|
@@ -629,7 +632,8 @@ ${resetUrl}`
|
|
|
629
632
|
/**
|
|
630
633
|
* Newsletter / announcement email with an optional hero image and CTA button.
|
|
631
634
|
*/
|
|
632
|
-
createNewsLetter(
|
|
635
|
+
createNewsLetter(params) {
|
|
636
|
+
const { subject, header, body, imageUrl, actionUrl, actionText, brandName, logoUrl } = params;
|
|
633
637
|
const brand = this.resolveBrand(brandName);
|
|
634
638
|
let noHtmlMessage = htmlToPlainText(body);
|
|
635
639
|
if (actionUrl) {
|
|
@@ -653,7 +657,8 @@ ${actionText || "Learn more"}: ${actionUrl}`;
|
|
|
653
657
|
/**
|
|
654
658
|
* Two-factor authentication email with OTP code and optional magic link.
|
|
655
659
|
*/
|
|
656
|
-
create2FAEmail(
|
|
660
|
+
create2FAEmail(params) {
|
|
661
|
+
const { username, otp, magicLink = "", brandName } = params;
|
|
657
662
|
const brand = this.resolveBrand(brandName);
|
|
658
663
|
const body = `Hi ${username},<br/>Use the code below or click the button to complete your login.`;
|
|
659
664
|
const plainLink = magicLink ? `
|
|
@@ -680,7 +685,8 @@ Your verification code is: ${otp}` + plainLink
|
|
|
680
685
|
/**
|
|
681
686
|
* Magic link sign-in email (no OTP, button only).
|
|
682
687
|
*/
|
|
683
|
-
createMagicLinkEmail(
|
|
688
|
+
createMagicLinkEmail(params) {
|
|
689
|
+
const { username, magicLink, brandName } = params;
|
|
684
690
|
const brand = this.resolveBrand(brandName);
|
|
685
691
|
const body = `Hi ${username},<br/>Click the button below to sign in. No password needed.`;
|
|
686
692
|
return {
|
|
@@ -708,32 +714,23 @@ ${magicLink}`
|
|
|
708
714
|
}
|
|
709
715
|
return this._defaultInstance;
|
|
710
716
|
}
|
|
711
|
-
static createEmailVerification(
|
|
712
|
-
return this.defaultInstance.createEmailVerification(
|
|
717
|
+
static createEmailVerification(params) {
|
|
718
|
+
return this.defaultInstance.createEmailVerification(params);
|
|
713
719
|
}
|
|
714
|
-
static createPasswordReset(
|
|
715
|
-
return this.defaultInstance.createPasswordReset(
|
|
720
|
+
static createPasswordReset(params) {
|
|
721
|
+
return this.defaultInstance.createPasswordReset(params);
|
|
716
722
|
}
|
|
717
|
-
static createSimpleMessage(
|
|
718
|
-
return this.defaultInstance.createSimpleMessage(
|
|
723
|
+
static createSimpleMessage(params) {
|
|
724
|
+
return this.defaultInstance.createSimpleMessage(params);
|
|
719
725
|
}
|
|
720
|
-
static createNewsLetter(
|
|
721
|
-
return this.defaultInstance.createNewsLetter(
|
|
722
|
-
subject,
|
|
723
|
-
header,
|
|
724
|
-
body,
|
|
725
|
-
imageUrl,
|
|
726
|
-
actionUrl,
|
|
727
|
-
actionText,
|
|
728
|
-
brandName,
|
|
729
|
-
logoUrl
|
|
730
|
-
);
|
|
726
|
+
static createNewsLetter(params) {
|
|
727
|
+
return this.defaultInstance.createNewsLetter(params);
|
|
731
728
|
}
|
|
732
|
-
static create2FAEmail(
|
|
733
|
-
return this.defaultInstance.create2FAEmail(
|
|
729
|
+
static create2FAEmail(params) {
|
|
730
|
+
return this.defaultInstance.create2FAEmail(params);
|
|
734
731
|
}
|
|
735
|
-
static createMagicLinkEmail(
|
|
736
|
-
return this.defaultInstance.createMagicLinkEmail(
|
|
732
|
+
static createMagicLinkEmail(params) {
|
|
733
|
+
return this.defaultInstance.createMagicLinkEmail(params);
|
|
737
734
|
}
|
|
738
735
|
};
|
|
739
736
|
export {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/types.ts","../src/core/errors.ts","../src/renderers/utils/html-to-plaintext.ts","../src/renderers/default/default-renderer.ts","../src/core/client.ts","../src/transports/zeptomail/zeptomail-sender.ts","../src/transports/memory/memory-sender.ts","../src/transports/console/console-sender.ts","../src/templates/factory.ts"],"sourcesContent":["/**\n * Standard email address representation with optional display name.\n */\nexport interface EmailAddress {\n address: string;\n name?: string;\n}\n\n/**\n * Flexible recipient representation allowing string ('user@example.com'),\n * EmailAddress ({ address: 'user@example.com', name: 'User' }),\n * or legacy/standard object ({ email: 'user@example.com', name: 'User' }).\n */\nexport type Recipient =\n | string\n | EmailAddress\n | { email: string; name?: string };\n\n/**\n * Parses an RFC 5322 formatted address string into an EmailAddress.\n * Supports formats such as:\n * - \"user@example.com\" -> { address: \"user@example.com\" }\n * - \"Sender Name <sender@example.com>\" -> { name: \"Sender Name\", address: \"sender@example.com\" }\n * - \"\\\"Sender Name\\\" <sender@example.com>\" -> { name: \"Sender Name\", address: \"sender@example.com\" }\n */\nexport function parseEmailAddress(input: string): EmailAddress {\n if (!input || typeof input !== 'string') {\n return { address: '' };\n }\n const trimmed = input.trim();\n const match = trimmed.match(/^(?:[\"']?([^\"']+)[\"']?\\s+)?<?([^\\s<>@]+@[^\\s<>@]+)>?$/);\n if (!match) {\n return { address: trimmed };\n }\n return {\n address: match[2].trim(),\n name: match[1]?.trim() || undefined,\n };\n}\n\n/**\n * Normalizes a Recipient value into a standardized EmailAddress.\n */\nexport function normalizeRecipient(recipient: Recipient): EmailAddress {\n if (typeof recipient === 'string') {\n return { address: recipient.trim() };\n }\n if ('email' in recipient) {\n return {\n address: (recipient.email ?? '').trim(),\n name: recipient.name?.trim(),\n };\n }\n return {\n address: (recipient.address ?? '').trim(),\n name: recipient.name?.trim(),\n };\n}\n\n/**\n * Normalizes a single or array of Recipients into an array of EmailAddress.\n */\nexport function normalizeRecipients(\n recipients?: Recipient | Recipient[]\n): EmailAddress[] {\n if (!recipients) return [];\n const list = Array.isArray(recipients) ? recipients : [recipients];\n return list.map(normalizeRecipient).filter((r) => r.address.length > 0);\n}\n\n/**\n * Email attachment representation.\n */\nexport interface EmailAttachment {\n filename: string;\n /**\n * Content can be base64-encoded string, plain text, or binary Buffer/Uint8Array.\n */\n content: string | Uint8Array;\n mimeType?: string;\n contentType?: string;\n cid?: string;\n}\n\n/**\n * Options for sending an email through a transport adapter.\n */\nexport interface SendMailOptions {\n to: Recipient | Recipient[];\n from?: Recipient;\n subject: string;\n html: string;\n text?: string;\n cc?: Recipient | Recipient[];\n bcc?: Recipient | Recipient[];\n replyTo?: Recipient | Recipient[];\n attachments?: EmailAttachment[];\n headers?: Record<string, string>;\n tags?: string[];\n metadata?: Record<string, string>;\n}\n\n/**\n * Result returned by an IEmailSender upon dispatch.\n */\nexport interface SendResult {\n success: boolean;\n messageId?: string;\n response?: unknown;\n}\n","/**\n * Base error class for all ts-mailkit errors.\n */\nexport class MailKitError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'MailKitError';\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/**\n * Thrown when transport configuration is missing or invalid.\n */\nexport class ConfigurationError extends MailKitError {\n constructor(message: string) {\n super(message);\n this.name = 'ConfigurationError';\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/**\n * Thrown when an email transport fails to dispatch an email.\n */\nexport class TransportError extends MailKitError {\n readonly transportName: string;\n readonly statusCode?: number;\n readonly responseBody?: string;\n readonly cause?: unknown;\n\n constructor(\n message: string,\n options: {\n transportName: string;\n statusCode?: number;\n responseBody?: string;\n cause?: unknown;\n }\n ) {\n super(message);\n this.name = 'TransportError';\n this.transportName = options.transportName;\n this.statusCode = options.statusCode;\n this.responseBody = options.responseBody;\n this.cause = options.cause;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/**\n * Thrown when template rendering or DTO validation fails.\n */\nexport class TemplateError extends MailKitError {\n constructor(message: string) {\n super(message);\n this.name = 'TemplateError';\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","/**\n * Decodes common HTML entities into their plain text equivalents.\n */\nexport function decodeHtmlEntities(text: string): string {\n return text\n .replace(/ /gi, ' ')\n .replace(/&/gi, '&')\n .replace(/</gi, '<')\n .replace(/>/gi, '>')\n .replace(/"/gi, '\"')\n .replace(/'/gi, \"'\")\n .replace(/©/gi, '©')\n .replace(/®/gi, '®')\n .replace(/™/gi, '™');\n}\n\n/**\n * Strips HTML tags and normalizes whitespace into readable plain text.\n * Converts <br>, <p>, and <div> into appropriate line breaks.\n */\nexport function htmlToPlainText(html: string): string {\n if (!html) return '';\n\n return decodeHtmlEntities(\n html\n .replace(/<br\\s*\\/?>/gi, '\\n')\n .replace(/<\\/p>/gi, '\\n\\n')\n .replace(/<\\/div>/gi, '\\n')\n .replace(/<\\/h[1-6]>/gi, '\\n\\n')\n .replace(/<[^>]*>/g, '')\n )\n .replace(/[ \\t]+/g, ' ')\n .replace(/\\n\\s*\\n\\s*\\n+/g, '\\n\\n')\n .trim();\n}\n","import type { EmailTemplateDto } from '../../templates/dto/index.js';\nimport type { IEmailRenderer, RenderedEmail } from '../renderer.interface.js';\nimport { htmlToPlainText } from '../utils/html-to-plaintext.js';\n\nexport interface DefaultRendererOptions {\n /**\n * Primary brand color for buttons and accents.\n * @default '#4f46e5'\n */\n primaryColor?: string;\n\n /**\n * Font stack used in the HTML wrapper.\n * @default \"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif\"\n */\n fontFamily?: string;\n\n /**\n * Container maximum width.\n * @default '600px'\n */\n maxWidth?: string;\n\n /**\n * Default logo URL displayed at the top-center of the email if not provided in the DTO.\n * Must be a valid http(s) URL.\n */\n logoUrl?: string;\n}\n\n/**\n * Validates whether a string is a valid HTTP or HTTPS URL.\n */\nexport function isValidHttpUrl(urlString?: string): boolean {\n if (!urlString || typeof urlString !== 'string') return false;\n try {\n const url = new URL(urlString.trim());\n return (url.protocol === 'http:' || url.protocol === 'https:') && url.hostname.length > 0;\n } catch {\n return false;\n }\n}\n\n/**\n * Builds a plain-text fallback string from an email DTO.\n */\nexport function buildPlainText(dto: EmailTemplateDto): string {\n if (dto.noHtmlMessage) {\n return dto.noHtmlMessage;\n }\n\n const divider = '──────────────────────────────';\n const parts: string[] = [];\n\n if (dto.header) {\n parts.push(dto.header, divider);\n }\n\n if (dto.body) {\n parts.push(htmlToPlainText(dto.body));\n }\n\n if (dto.otpCode) {\n parts.push(`Verification Code: ${dto.otpCode}`);\n }\n\n if (dto.actionText && dto.actionUrl) {\n parts.push(`${dto.actionText}: ${dto.actionUrl}`);\n }\n\n if (dto.extraMessage) {\n parts.push(htmlToPlainText(dto.extraMessage));\n }\n\n if (dto.footer) {\n parts.push(`${divider}\\n${htmlToPlainText(dto.footer)}`);\n }\n\n return parts.join('\\n\\n');\n}\n\n/**\n * Builds a responsive, styled HTML email document from an email DTO.\n */\nexport function buildHtml(dto: EmailTemplateDto, options: DefaultRendererOptions = {}): string {\n const primaryColor = options.primaryColor || '#4f46e5';\n const fontFamily =\n options.fontFamily ||\n \"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif\";\n const maxWidth = options.maxWidth || '600px';\n\n const parts: string[] = [\n `<!DOCTYPE html>`,\n `<html lang=\"en\">`,\n `<head>`,\n `<meta charset=\"UTF-8\">`,\n `<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">`,\n `<title>${dto.subject}</title>`,\n `</head>`,\n `<body style=\"margin:0;padding:24px 16px;background-color:#f9fafb;font-family:${fontFamily};color:#1f2937;line-height:1.6;\">`,\n `<div style=\"max-width:${maxWidth};margin:0 auto;background-color:#ffffff;padding:32px 28px;border-radius:8px;box-shadow:0 1px 3px rgba(0,0,0,0.1);border:1px solid #f3f4f6;\">`,\n ];\n\n const logoCandidate = dto.logoUrl ?? options.logoUrl;\n if (logoCandidate && isValidHttpUrl(logoCandidate)) {\n const validLogo = logoCandidate.trim();\n parts.push(\n `<div style=\"margin-bottom:24px;text-align:center;\">`,\n ` <img src=\"${validLogo}\" alt=\"${dto.fromName || 'Logo'}\" style=\"max-height:48px;max-width:200px;height:auto;width:auto;display:inline-block;border:0;outline:none;text-decoration:none;\" />`,\n `</div>`\n );\n }\n\n if (dto.imageUrl) {\n parts.push(\n `<div style=\"margin-bottom:24px;text-align:center;\">`,\n ` <img src=\"${dto.imageUrl}\" alt=\"Header\" style=\"max-width:100%;height:auto;border-radius:6px;\" />`,\n `</div>`\n );\n }\n\n if (dto.header) {\n parts.push(\n `<h2 style=\"margin:0 0 16px;font-size:1.5rem;font-weight:700;color:#111827;letter-spacing:-0.025em;\">${dto.header}</h2>`\n );\n }\n\n if (dto.body) {\n parts.push(`<div style=\"margin:0 0 20px;font-size:1rem;color:#374151;\">${dto.body}</div>`);\n }\n\n if (dto.otpCode) {\n parts.push(\n `<div style=\"margin:24px 0;padding:20px;background-color:#f3f4f6;border-radius:8px;text-align:center;\">`,\n ` <span style=\"font-size:2rem;letter-spacing:0.5rem;font-weight:700;color:#111827;font-family:monospace;\">${dto.otpCode}</span>`,\n `</div>`\n );\n }\n\n if (dto.actionUrl && dto.actionText) {\n parts.push(\n `<div style=\"margin:24px 0;text-align:center;\">`,\n ` <a href=\"${dto.actionUrl}\" style=\"display:inline-block;padding:12px 28px;background-color:${primaryColor};color:#ffffff;border-radius:6px;text-decoration:none;font-weight:600;font-size:1rem;text-align:center;box-sizing:border-box;\">${dto.actionText}</a>`,\n `</div>`\n );\n }\n\n if (dto.extraMessage) {\n parts.push(\n `<div style=\"margin:20px 0 0;font-size:0.875rem;color:#6b7280;line-height:1.5;\">${dto.extraMessage}</div>`\n );\n }\n\n if (dto.footer) {\n parts.push(\n `<div style=\"margin-top:32px;padding-top:20px;border-top:1px solid #e5e7eb;font-size:0.75rem;color:#9ca3af;text-align:center;\">${dto.footer}</div>`\n );\n }\n\n parts.push(`</div>`, `</body>`, `</html>`);\n return parts.join('\\n');\n}\n\n/**\n * Default HTML and plain-text email renderer for ts-mailkit.\n */\nexport class DefaultEmailRenderer implements IEmailRenderer {\n private readonly options: DefaultRendererOptions;\n\n constructor(options: DefaultRendererOptions = {}) {\n this.options = options;\n }\n\n render(dto: EmailTemplateDto): RenderedEmail {\n return {\n html: buildHtml(dto, this.options),\n text: buildPlainText(dto),\n };\n }\n}\n","import type { IEmailSender } from '../transports/sender.interface.js';\nimport type { IEmailRenderer, RenderedEmail } from '../renderers/renderer.interface.js';\nimport { DefaultEmailRenderer } from '../renderers/default/default-renderer.js';\nimport { htmlToPlainText } from '../renderers/utils/html-to-plaintext.js';\nimport type { EmailTemplateDto } from '../templates/dto/index.js';\nimport {\n normalizeRecipient,\n normalizeRecipients,\n type Recipient,\n type SendMailOptions,\n type SendResult,\n} from './types.js';\nimport { ConfigurationError } from './errors.js';\n\nexport interface SendTemplateOptions {\n /**\n * One or more recipient email addresses.\n */\n to: Recipient | Recipient[];\n /**\n * Templated email DTO to render and send.\n */\n template: EmailTemplateDto;\n /**\n * Optional recipient display name (used when `to` is a plain string).\n */\n toName?: string;\n /**\n * Optional sender display name override for this specific email.\n */\n fromName?: string;\n /**\n * Optional sender email address override.\n */\n from?: Recipient;\n /**\n * Optional CC recipients.\n */\n cc?: Recipient | Recipient[];\n /**\n * Optional BCC recipients.\n */\n bcc?: Recipient | Recipient[];\n /**\n * Optional Reply-To recipients.\n */\n replyTo?: Recipient | Recipient[];\n /**\n * Optional file attachments.\n */\n attachments?: SendMailOptions['attachments'];\n /**\n * Optional custom headers.\n */\n headers?: Record<string, string>;\n /**\n * Optional tags for tracking.\n */\n tags?: string[];\n /**\n * Optional metadata.\n */\n metadata?: Record<string, string>;\n}\n\nexport interface MailKitOptions {\n /**\n * The transport adapter used to dispatch emails (e.g. ZeptoMailHttpSender, MemoryEmailSender).\n */\n transport: IEmailSender;\n /**\n * Custom renderer implementation. Defaults to DefaultEmailRenderer.\n */\n renderer?: IEmailRenderer;\n /**\n * Default sender address or Recipient.\n */\n defaultFrom?: Recipient;\n /**\n * Default brand or application name.\n */\n defaultBrandName?: string;\n /**\n * Optional asynchronous or synchronous resolver to dynamically resolve brand/tenant name.\n * Useful for multitenant applications.\n */\n brandNameResolver?: () => Promise<string> | string;\n}\n\n/**\n * Main email client and orchestration service for ts-mailkit.\n */\nexport class MailKit {\n private readonly transport: IEmailSender;\n private readonly renderer: IEmailRenderer;\n private readonly defaultFrom?: Recipient;\n private readonly defaultBrandName?: string;\n private readonly brandNameResolver?: () => Promise<string> | string;\n\n constructor(options: MailKitOptions) {\n if (!options.transport) {\n throw new ConfigurationError('MailKit: A transport adapter (IEmailSender) is required.');\n }\n this.transport = options.transport;\n this.renderer = options.renderer ?? new DefaultEmailRenderer();\n this.defaultFrom = options.defaultFrom;\n this.defaultBrandName = options.defaultBrandName;\n this.brandNameResolver = options.brandNameResolver;\n }\n\n /**\n * Returns the underlying transport instance.\n */\n getTransport(): IEmailSender {\n return this.transport;\n }\n\n /**\n * Renders an email DTO to HTML and plain text without dispatching.\n */\n async render(template: EmailTemplateDto): Promise<RenderedEmail> {\n return await this.renderer.render(template);\n }\n\n /**\n * Sends an email using a strongly-typed template DTO.\n *\n * Example:\n * ```ts\n * await mailer.send({\n * to: 'user@example.com',\n * template: myDto,\n * });\n * ```\n */\n async send(options: SendTemplateOptions): Promise<SendResult> {\n const template = options.template;\n const recipientName = options.toName ?? template.userName;\n\n // Resolve fromName: explicit option > template.fromName > brand resolver > defaultBrandName\n let resolvedFromName = options.fromName ?? template.fromName;\n if (!resolvedFromName && this.brandNameResolver) {\n resolvedFromName = await this.brandNameResolver();\n }\n if (!resolvedFromName) {\n resolvedFromName = this.defaultBrandName;\n }\n\n // Render template DTO\n const rendered = await this.renderer.render(template);\n const plaintextBody = template.noHtmlMessage ?? rendered.text;\n\n // Format recipients\n let toRecipients: Recipient | Recipient[];\n if (typeof options.to === 'string' && recipientName) {\n toRecipients = { address: options.to, name: recipientName };\n } else {\n toRecipients = options.to;\n }\n\n // Resolve From address\n let from = options.from ?? this.defaultFrom;\n if (resolvedFromName && from) {\n const normalizedFrom = normalizeRecipient(from);\n from = { address: normalizedFrom.address, name: resolvedFromName };\n }\n\n return await this.sendRaw({\n to: toRecipients,\n from,\n subject: template.subject,\n html: rendered.html,\n text: plaintextBody,\n cc: options.cc,\n bcc: options.bcc,\n replyTo: options.replyTo,\n attachments: options.attachments,\n headers: options.headers,\n tags: options.tags,\n metadata: options.metadata,\n });\n }\n\n /**\n * Dispatches a raw, pre-rendered email directly through the transport.\n * If `options.text` is omitted, plain text is automatically derived from `options.html`.\n */\n async sendRaw(options: SendMailOptions): Promise<SendResult> {\n const from = options.from ?? this.defaultFrom;\n const text = options.text ?? (options.html ? htmlToPlainText(options.html) : undefined);\n return await this.transport.send({\n ...options,\n from,\n text,\n });\n }\n}\n\n/**\n * Convenience factory to create a MailKit client instance.\n */\nexport function createMailKit(options: MailKitOptions): MailKit {\n return new MailKit(options);\n}\n","import { ConfigurationError, TransportError } from '../../core/errors.js';\nimport {\n normalizeRecipient,\n normalizeRecipients,\n type SendMailOptions,\n type SendResult,\n} from '../../core/types.js';\nimport type { IEmailSender } from '../sender.interface.js';\nimport type {\n ZeptoMailHttpConfig,\n ZeptoMailSendPayload,\n ZeptoMailAttachmentPayload,\n} from './types.js';\n\n/**\n * ZeptoMail (Zoho Mail transactional email HTTP API) transport adapter.\n *\n * Designed for zero dependencies and universal edge compatibility (Node.js, Bun, Deno, Cloudflare Workers)\n * by utilizing the standard global `fetch` API.\n */\nexport class ZeptoMailHttpSender implements IEmailSender {\n readonly name = 'zeptomail';\n\n private readonly apiUrl: string;\n private readonly authHeader: string;\n private readonly defaultFrom: { address: string; name?: string };\n private readonly fetchImpl: typeof fetch;\n\n constructor(config: ZeptoMailHttpConfig) {\n if (!config.apiToken || typeof config.apiToken !== 'string') {\n throw new ConfigurationError('ZeptoMailHttpSender: Missing or invalid apiToken.');\n }\n if (!config.from) {\n throw new ConfigurationError('ZeptoMailHttpSender: Missing required default from address.');\n }\n\n const host = (config.apiHost || 'api.zeptomail.com').replace(/^https?:\\/\\//, '').replace(/\\/+$/, '');\n this.apiUrl = `https://${host}/v1.1/email`;\n\n // Normalize auth token header. In ZeptoMail, if the user already included \"Zoho-enczapikey \", use as is; otherwise format standard header.\n const token = config.apiToken.trim();\n this.authHeader = token.startsWith('Zoho-') ? token : `Zoho-enczapikey ${token}`;\n\n this.defaultFrom = normalizeRecipient(config.from);\n if (!this.defaultFrom.address) {\n throw new ConfigurationError('ZeptoMailHttpSender: Configured from address must not be empty.');\n }\n\n this.fetchImpl = config.fetch ?? globalThis.fetch;\n if (typeof this.fetchImpl !== 'function') {\n throw new ConfigurationError(\n 'ZeptoMailHttpSender: No global fetch implementation found. Pass a custom fetch to ZeptoMailHttpConfig if running on Node < 18.'\n );\n }\n }\n\n /**\n * Dispatches an email using Zoho ZeptoMail API v1.1.\n */\n async send(options: SendMailOptions): Promise<SendResult> {\n const toRecipients = normalizeRecipients(options.to);\n if (toRecipients.length === 0) {\n throw new TransportError('ZeptoMailHttpSender: At least one recipient (to) must be specified.', {\n transportName: this.name,\n });\n }\n\n const resolvedFrom = options.from ? normalizeRecipient(options.from) : this.defaultFrom;\n\n const payload: ZeptoMailSendPayload = {\n from: {\n address: resolvedFrom.address,\n name: resolvedFrom.name,\n },\n to: toRecipients.map((r) => ({\n email_address: {\n address: r.address,\n name: r.name || '',\n },\n })),\n subject: options.subject,\n htmlbody: options.html,\n textbody: options.text,\n };\n\n if (options.cc) {\n const ccList = normalizeRecipients(options.cc);\n if (ccList.length > 0) {\n payload.cc = ccList.map((r) => ({\n email_address: { address: r.address, name: r.name || '' },\n }));\n }\n }\n\n if (options.bcc) {\n const bccList = normalizeRecipients(options.bcc);\n if (bccList.length > 0) {\n payload.bcc = bccList.map((r) => ({\n email_address: { address: r.address, name: r.name || '' },\n }));\n }\n }\n\n if (options.replyTo) {\n const replyToList = normalizeRecipients(options.replyTo);\n if (replyToList.length > 0) {\n payload.reply_to = replyToList.map((r) => ({\n address: r.address,\n name: r.name,\n }));\n }\n }\n\n if (options.attachments && options.attachments.length > 0) {\n payload.attachments = options.attachments.map((att): ZeptoMailAttachmentPayload => {\n let contentBase64: string;\n if (typeof att.content === 'string') {\n contentBase64 = att.content;\n } else {\n // Buffer or Uint8Array\n if (typeof Buffer !== 'undefined') {\n contentBase64 = Buffer.from(att.content).toString('base64');\n } else {\n // Browser / Edge fallback for Uint8Array\n let binary = '';\n const bytes = new Uint8Array(att.content);\n for (let i = 0; i < bytes.byteLength; i++) {\n binary += String.fromCharCode(bytes[i]);\n }\n contentBase64 = btoa(binary);\n }\n }\n\n return {\n name: att.filename,\n content: contentBase64,\n mime_type: att.mimeType || att.contentType || 'application/octet-stream',\n cid: att.cid,\n };\n });\n }\n\n let response: Response;\n try {\n response = await this.fetchImpl(this.apiUrl, {\n method: 'POST',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n Authorization: this.authHeader,\n },\n body: JSON.stringify(payload),\n });\n } catch (err) {\n throw new TransportError(`ZeptoMailHttpSender: Network request failed: ${err instanceof Error ? err.message : String(err)}`, {\n transportName: this.name,\n cause: err,\n });\n }\n\n const responseText = await response.text();\n let responseData: any;\n try {\n responseData = responseText ? JSON.parse(responseText) : {};\n } catch {\n responseData = { raw: responseText };\n }\n\n if (!response.ok) {\n const errorMessage =\n responseData?.error?.message ||\n responseData?.message ||\n `HTTP ${response.status}: ${responseText || response.statusText}`;\n\n throw new TransportError(`ZeptoMailHttpSender: Failed to send email - ${errorMessage}`, {\n transportName: this.name,\n statusCode: response.status,\n responseBody: responseText,\n });\n }\n\n // Extract message ID from standard ZeptoMail v1.1 response structure:\n // { data: [ { message_id: \"...\" } ] }\n const messageId = responseData?.data?.[0]?.message_id;\n\n return {\n success: true,\n messageId,\n response: responseData,\n };\n }\n}\n","import type { SendMailOptions, SendResult } from '../../core/types.js';\nimport type { IEmailSender } from '../sender.interface.js';\n\n/**\n * In-memory email sender for automated testing, local development, and CI environments.\n * Captures all dispatched emails and provides inspection methods.\n */\nexport class MemoryEmailSender implements IEmailSender {\n readonly name = 'memory';\n\n private sentMails: SendMailOptions[] = [];\n private nextId = 1;\n\n async send(options: SendMailOptions): Promise<SendResult> {\n this.sentMails.push({ ...options });\n const messageId = `mem-${this.nextId++}-${Date.now()}`;\n return {\n success: true,\n messageId,\n response: { id: messageId },\n };\n }\n\n /**\n * Returns a copy of all emails sent through this transport instance.\n */\n getSentMails(): SendMailOptions[] {\n return [...this.sentMails];\n }\n\n /**\n * Returns the most recent email sent, or undefined if no emails have been sent.\n */\n getLastMail(): SendMailOptions | undefined {\n return this.sentMails.length > 0\n ? { ...this.sentMails[this.sentMails.length - 1] }\n : undefined;\n }\n\n /**\n * Clears all recorded sent emails.\n */\n clear(): void {\n this.sentMails = [];\n }\n\n /**\n * Returns the total count of sent emails.\n */\n count(): number {\n return this.sentMails.length;\n }\n}\n","import { normalizeRecipients, type SendMailOptions, type SendResult } from '../../core/types.js';\nimport type { IEmailSender } from '../sender.interface.js';\n\nexport interface ConsoleEmailSenderOptions {\n /**\n * Log level or custom log printer. Defaults to `console.log`.\n */\n logger?: (message: string) => void;\n /**\n * Whether to include the full HTML body in console output.\n * Defaults to false (prints plain text or a summary).\n */\n includeHtml?: boolean;\n}\n\n/**\n * Console logger transport that prints dispatched emails to stdout/stderr.\n * Ideal for development and debugging.\n */\nexport class ConsoleEmailSender implements IEmailSender {\n readonly name = 'console';\n\n private readonly log: (message: string) => void;\n private readonly includeHtml: boolean;\n private nextId = 1;\n\n constructor(options: ConsoleEmailSenderOptions = {}) {\n this.log = options.logger ?? console.log;\n this.includeHtml = options.includeHtml ?? false;\n }\n\n async send(options: SendMailOptions): Promise<SendResult> {\n const to = normalizeRecipients(options.to).map((r) => r.name ? `${r.name} <${r.address}>` : r.address).join(', ');\n const from = options.from ? JSON.stringify(options.from) : '(default)';\n const messageId = `console-${this.nextId++}-${Date.now()}`;\n\n const separator = '─'.repeat(60);\n const lines = [\n `\\n┌${separator}┐`,\n `│ [ts-mailkit:console] DISPATCHED EMAIL (${messageId})`,\n `├${separator}┤`,\n `│ From: ${from}`,\n `│ To: ${to}`,\n `│ Subject: ${options.subject}`,\n `├${separator}┤`,\n ];\n\n if (options.text) {\n lines.push('│ Text Body:');\n for (const line of options.text.split('\\n')) {\n lines.push(`│ ${line}`);\n }\n }\n\n if (this.includeHtml && options.html) {\n lines.push('│ HTML Body:');\n for (const line of options.html.split('\\n')) {\n lines.push(`│ ${line}`);\n }\n }\n\n lines.push(`└${separator}┘\\n`);\n\n this.log(lines.join('\\n'));\n\n return {\n success: true,\n messageId,\n response: { logged: true },\n };\n }\n}\n","import type { EmailTemplateDto } from './dto/index.js';\nimport { htmlToPlainText } from '../renderers/utils/html-to-plaintext.js';\n\nexport interface BrandingConfig {\n /**\n * Default brand, application, or company name.\n * @default 'Application'\n */\n brandName?: string;\n\n /**\n * Optional custom security / disclaimer advisory message.\n */\n securityMessage?: string;\n\n /**\n * Optional custom footer generator or string.\n */\n footer?: string | ((brandName: string) => string);\n\n /**\n * Optional default logo URL to display top-center in templated emails.\n */\n logoUrl?: string;\n}\n\nconst DEFAULT_SECURITY_MESSAGE =\n 'If you did not request this, please ignore this email or contact support if you have concerns.';\n\nfunction defaultFooter(brandName: string): string {\n return `© ${new Date().getFullYear()} ${brandName}. All rights reserved.`;\n}\n\n/**\n * Factory for creating pre-populated, type-safe email template DTOs.\n */\nexport class EmailTemplateFactory {\n private readonly defaultBrandName: string;\n private readonly defaultSecurityMessage: string;\n private readonly footerResolver: (brandName: string) => string;\n private readonly defaultLogoUrl?: string;\n\n constructor(config: BrandingConfig = {}) {\n this.defaultBrandName = config.brandName || 'Application';\n this.defaultSecurityMessage = config.securityMessage || DEFAULT_SECURITY_MESSAGE;\n this.defaultLogoUrl = config.logoUrl;\n if (typeof config.footer === 'function') {\n this.footerResolver = config.footer;\n } else if (typeof config.footer === 'string') {\n const fixedFooter = config.footer;\n this.footerResolver = () => fixedFooter;\n } else {\n this.footerResolver = defaultFooter;\n }\n }\n\n private resolveBrand(override?: string): string {\n return override || this.defaultBrandName;\n }\n\n private buildFooter(brandName: string): string {\n return this.footerResolver(brandName);\n }\n\n /**\n * Welcome / email-verification email sent after registration.\n */\n createEmailVerification(\n username: string,\n verificationUrl: string,\n otp: string,\n brandName?: string\n ): EmailTemplateDto {\n const brand = this.resolveBrand(brandName);\n const body = `Hi ${username},<br/>Thank you for signing up. Use the code below or click the button to verify your email address.`;\n return {\n subject: 'Verify Your Email Address',\n header: `Welcome to ${brand}!`,\n body,\n logoUrl: this.defaultLogoUrl,\n otpCode: otp,\n actionUrl: verificationUrl,\n actionText: 'Verify Email',\n extraMessage: this.defaultSecurityMessage,\n footer: this.buildFooter(brand),\n userName: username,\n fromName: brand,\n noHtmlMessage:\n htmlToPlainText(body) +\n `\\n\\nYour verification code is: ${otp}\\n\\nAlternatively, verify here:\\n${verificationUrl}`,\n };\n }\n\n /**\n * Password-reset email with an optional OTP code and action link.\n */\n createPasswordReset(\n username: string,\n resetUrl: string,\n otp: string = '',\n brandName?: string\n ): EmailTemplateDto {\n const brand = this.resolveBrand(brandName);\n const body = `Hi ${username},<br/>We received a request to reset your password. Use the OTP code below or click the button to proceed.`;\n const plainTextOtp = otp ? `\\n\\nYour OTP code is: ${otp}` : '';\n return {\n subject: 'Password Reset Request',\n header: 'Reset Your Password',\n body,\n logoUrl: this.defaultLogoUrl,\n otpCode: otp || undefined,\n actionUrl: resetUrl,\n actionText: 'Reset Password',\n extraMessage: this.defaultSecurityMessage,\n footer: this.buildFooter(brand),\n userName: username,\n fromName: brand,\n noHtmlMessage:\n htmlToPlainText(body) +\n plainTextOtp +\n `\\n\\nAlternatively, you can use the following link to reset your password:\\n${resetUrl}`,\n };\n }\n\n /**\n * Generic plain message email (no action button, no OTP).\n */\n createSimpleMessage(\n subject: string,\n header: string,\n body: string,\n brandName?: string\n ): EmailTemplateDto {\n const brand = this.resolveBrand(brandName);\n return {\n subject,\n header,\n body,\n logoUrl: this.defaultLogoUrl,\n footer: this.buildFooter(brand),\n fromName: brand,\n noHtmlMessage: htmlToPlainText(body),\n };\n }\n\n /**\n * Newsletter / announcement email with an optional hero image and CTA button.\n */\n createNewsLetter(\n subject: string,\n header: string,\n body: string,\n imageUrl?: string,\n actionUrl?: string,\n actionText?: string,\n brandName?: string,\n logoUrl?: string\n ): EmailTemplateDto {\n const brand = this.resolveBrand(brandName);\n let noHtmlMessage = htmlToPlainText(body);\n if (actionUrl) {\n noHtmlMessage += `\\n\\n${actionText || 'Learn more'}: ${actionUrl}`;\n }\n return {\n subject,\n header,\n body,\n logoUrl: logoUrl || this.defaultLogoUrl,\n imageUrl,\n actionUrl,\n actionText,\n footer: this.buildFooter(brand),\n fromName: brand,\n noHtmlMessage,\n };\n }\n\n /**\n * Two-factor authentication email with OTP code and optional magic link.\n */\n create2FAEmail(\n username: string,\n otp: string,\n magicLink: string = '',\n brandName?: string\n ): EmailTemplateDto {\n const brand = this.resolveBrand(brandName);\n const body = `Hi ${username},<br/>Use the code below or click the button to complete your login.`;\n const plainLink = magicLink ? `\\n\\nAlternatively, verify here:\\n${magicLink}` : '';\n return {\n subject: 'Your Login Verification Code',\n header: 'Two-Factor Authentication',\n body,\n logoUrl: this.defaultLogoUrl,\n otpCode: otp,\n actionUrl: magicLink || undefined,\n actionText: magicLink ? 'Verify Login' : undefined,\n extraMessage: this.defaultSecurityMessage,\n footer: this.buildFooter(brand),\n userName: username,\n fromName: brand,\n noHtmlMessage: htmlToPlainText(body) + `\\n\\nYour verification code is: ${otp}` + plainLink,\n };\n }\n\n /**\n * Magic link sign-in email (no OTP, button only).\n */\n createMagicLinkEmail(\n username: string,\n magicLink: string,\n brandName?: string\n ): EmailTemplateDto {\n const brand = this.resolveBrand(brandName);\n const body = `Hi ${username},<br/>Click the button below to sign in. No password needed.`;\n return {\n subject: 'Your Magic Link',\n header: `Sign In to ${brand}`,\n body,\n logoUrl: this.defaultLogoUrl,\n actionUrl: magicLink,\n actionText: 'Sign In',\n extraMessage: this.defaultSecurityMessage,\n footer: this.buildFooter(brand),\n userName: username,\n fromName: brand,\n noHtmlMessage: htmlToPlainText(body) + `\\n\\nSign in here:\\n${magicLink}`,\n };\n }\n\n // ─── Default Static Instance ──────────────────────────────────────────────\n private static _defaultInstance?: EmailTemplateFactory;\n\n private static get defaultInstance(): EmailTemplateFactory {\n if (!this._defaultInstance) {\n this._defaultInstance = new EmailTemplateFactory();\n }\n return this._defaultInstance;\n }\n\n static createEmailVerification(\n username: string,\n verificationUrl: string,\n otp: string,\n brandName?: string\n ): EmailTemplateDto {\n return this.defaultInstance.createEmailVerification(username, verificationUrl, otp, brandName);\n }\n\n static createPasswordReset(\n username: string,\n resetUrl: string,\n otp?: string,\n brandName?: string\n ): EmailTemplateDto {\n return this.defaultInstance.createPasswordReset(username, resetUrl, otp, brandName);\n }\n\n static createSimpleMessage(\n subject: string,\n header: string,\n body: string,\n brandName?: string\n ): EmailTemplateDto {\n return this.defaultInstance.createSimpleMessage(subject, header, body, brandName);\n }\n\n static createNewsLetter(\n subject: string,\n header: string,\n body: string,\n imageUrl?: string,\n actionUrl?: string,\n actionText?: string,\n brandName?: string,\n logoUrl?: string\n ): EmailTemplateDto {\n return this.defaultInstance.createNewsLetter(\n subject,\n header,\n body,\n imageUrl,\n actionUrl,\n actionText,\n brandName,\n logoUrl\n );\n }\n\n static create2FAEmail(\n username: string,\n otp: string,\n magicLink?: string,\n brandName?: string\n ): EmailTemplateDto {\n return this.defaultInstance.create2FAEmail(username, otp, magicLink, brandName);\n }\n\n static createMagicLinkEmail(\n username: string,\n magicLink: string,\n brandName?: string\n ): EmailTemplateDto {\n return this.defaultInstance.createMagicLinkEmail(username, magicLink, brandName);\n }\n}\n"],"mappings":";AAyBO,SAAS,kBAAkB,OAA6B;AAC7D,MAAI,CAAC,SAAS,OAAO,UAAU,UAAU;AACvC,WAAO,EAAE,SAAS,GAAG;AAAA,EACvB;AACA,QAAM,UAAU,MAAM,KAAK;AAC3B,QAAM,QAAQ,QAAQ,MAAM,uDAAuD;AACnF,MAAI,CAAC,OAAO;AACV,WAAO,EAAE,SAAS,QAAQ;AAAA,EAC5B;AACA,SAAO;AAAA,IACL,SAAS,MAAM,CAAC,EAAE,KAAK;AAAA,IACvB,MAAM,MAAM,CAAC,GAAG,KAAK,KAAK;AAAA,EAC5B;AACF;AAKO,SAAS,mBAAmB,WAAoC;AACrE,MAAI,OAAO,cAAc,UAAU;AACjC,WAAO,EAAE,SAAS,UAAU,KAAK,EAAE;AAAA,EACrC;AACA,MAAI,WAAW,WAAW;AACxB,WAAO;AAAA,MACL,UAAU,UAAU,SAAS,IAAI,KAAK;AAAA,MACtC,MAAM,UAAU,MAAM,KAAK;AAAA,IAC7B;AAAA,EACF;AACA,SAAO;AAAA,IACL,UAAU,UAAU,WAAW,IAA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KAAK,WAAW,SAAS;AAAA,EAChF;AAAA,EAEA,OAAO,qBACL,UACA,WACA,WACkB;AAClB,WAAO,KAAK,gBAAgB,qBAAqB,UAAU,WAAW,SAAS;AAAA,EACjF;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/core/types.ts","../src/core/errors.ts","../src/renderers/utils/html-to-plaintext.ts","../src/renderers/default/default-renderer.ts","../src/core/client.ts","../src/transports/zeptomail/zeptomail-sender.ts","../src/transports/memory/memory-sender.ts","../src/transports/console/console-sender.ts","../src/templates/factory.ts"],"sourcesContent":["/**\n * Standard email address representation with optional display name.\n */\nexport interface EmailAddress {\n address: string;\n name?: string;\n}\n\n/**\n * Flexible recipient representation allowing string ('user@example.com'),\n * EmailAddress ({ address: 'user@example.com', name: 'User' }),\n * or legacy/standard object ({ email: 'user@example.com', name: 'User' }).\n */\nexport type Recipient =\n | string\n | EmailAddress\n | { email: string; name?: string };\n\n/**\n * Parses an RFC 5322 formatted address string into an EmailAddress.\n * Supports formats such as:\n * - \"user@example.com\" -> { address: \"user@example.com\" }\n * - \"Sender Name <sender@example.com>\" -> { name: \"Sender Name\", address: \"sender@example.com\" }\n * - \"\\\"Sender Name\\\" <sender@example.com>\" -> { name: \"Sender Name\", address: \"sender@example.com\" }\n */\nexport function parseEmailAddress(input: string): EmailAddress {\n if (!input || typeof input !== 'string') {\n return { address: '' };\n }\n const trimmed = input.trim();\n const match = trimmed.match(/^(?:[\"']?([^\"']+)[\"']?\\s+)?<?([^\\s<>@]+@[^\\s<>@]+)>?$/);\n if (!match) {\n return { address: trimmed };\n }\n return {\n address: match[2].trim(),\n name: match[1]?.trim() || undefined,\n };\n}\n\n/**\n * Normalizes a Recipient value into a standardized EmailAddress.\n */\nexport function normalizeRecipient(recipient: Recipient): EmailAddress {\n if (typeof recipient === 'string') {\n return { address: recipient.trim() };\n }\n if ('email' in recipient) {\n return {\n address: (recipient.email ?? '').trim(),\n name: recipient.name?.trim(),\n };\n }\n return {\n address: (recipient.address ?? '').trim(),\n name: recipient.name?.trim(),\n };\n}\n\n/**\n * Normalizes a single or array of Recipients into an array of EmailAddress.\n */\nexport function normalizeRecipients(\n recipients?: Recipient | Recipient[]\n): EmailAddress[] {\n if (!recipients) return [];\n const list = Array.isArray(recipients) ? recipients : [recipients];\n return list.map(normalizeRecipient).filter((r) => r.address.length > 0);\n}\n\n/**\n * Email attachment representation.\n */\nexport interface EmailAttachment {\n filename: string;\n /**\n * Content can be base64-encoded string, plain text, or binary Buffer/Uint8Array.\n */\n content: string | Uint8Array;\n mimeType?: string;\n contentType?: string;\n cid?: string;\n}\n\n/**\n * Options for sending an email through a transport adapter.\n */\nexport interface SendMailOptions {\n to: Recipient | Recipient[];\n from?: Recipient;\n subject: string;\n html: string;\n text?: string;\n cc?: Recipient | Recipient[];\n bcc?: Recipient | Recipient[];\n replyTo?: Recipient | Recipient[];\n attachments?: EmailAttachment[];\n headers?: Record<string, string>;\n tags?: string[];\n metadata?: Record<string, string>;\n}\n\n/**\n * Result returned by an IEmailSender upon dispatch.\n */\nexport interface SendResult {\n success: boolean;\n messageId?: string;\n response?: unknown;\n}\n","/**\n * Base error class for all ts-mailkit errors.\n */\nexport class MailKitError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'MailKitError';\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/**\n * Thrown when transport configuration is missing or invalid.\n */\nexport class ConfigurationError extends MailKitError {\n constructor(message: string) {\n super(message);\n this.name = 'ConfigurationError';\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/**\n * Thrown when an email transport fails to dispatch an email.\n */\nexport class TransportError extends MailKitError {\n readonly transportName: string;\n readonly statusCode?: number;\n readonly responseBody?: string;\n readonly cause?: unknown;\n\n constructor(\n message: string,\n options: {\n transportName: string;\n statusCode?: number;\n responseBody?: string;\n cause?: unknown;\n }\n ) {\n super(message);\n this.name = 'TransportError';\n this.transportName = options.transportName;\n this.statusCode = options.statusCode;\n this.responseBody = options.responseBody;\n this.cause = options.cause;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/**\n * Thrown when template rendering or DTO validation fails.\n */\nexport class TemplateError extends MailKitError {\n constructor(message: string) {\n super(message);\n this.name = 'TemplateError';\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","/**\n * Decodes common HTML entities into their plain text equivalents.\n */\nexport function decodeHtmlEntities(text: string): string {\n return text\n .replace(/ /gi, ' ')\n .replace(/&/gi, '&')\n .replace(/</gi, '<')\n .replace(/>/gi, '>')\n .replace(/"/gi, '\"')\n .replace(/'/gi, \"'\")\n .replace(/©/gi, '©')\n .replace(/®/gi, '®')\n .replace(/™/gi, '™');\n}\n\n/**\n * Strips HTML tags and normalizes whitespace into readable plain text.\n * Converts <br>, <p>, and <div> into appropriate line breaks.\n */\nexport function htmlToPlainText(html: string): string {\n if (!html) return '';\n\n return decodeHtmlEntities(\n html\n .replace(/<br\\s*\\/?>/gi, '\\n')\n .replace(/<\\/p>/gi, '\\n\\n')\n .replace(/<\\/div>/gi, '\\n')\n .replace(/<\\/h[1-6]>/gi, '\\n\\n')\n .replace(/<[^>]*>/g, '')\n )\n .replace(/[ \\t]+/g, ' ')\n .replace(/\\n\\s*\\n\\s*\\n+/g, '\\n\\n')\n .trim();\n}\n","import type { EmailTemplateDto } from '../../templates/dto/index.js';\nimport type { IEmailRenderer, RenderedEmail } from '../renderer.interface.js';\nimport { htmlToPlainText } from '../utils/html-to-plaintext.js';\n\nexport interface DefaultRendererOptions {\n /**\n * Primary brand color for buttons and accents.\n * @default '#4f46e5'\n */\n primaryColor?: string;\n\n /**\n * Font stack used in the HTML wrapper.\n * @default \"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif\"\n */\n fontFamily?: string;\n\n /**\n * Container maximum width.\n * @default '600px'\n */\n maxWidth?: string;\n\n /**\n * Default logo URL displayed at the top-center of the email if not provided in the DTO.\n * Must be a valid http(s) URL.\n */\n logoUrl?: string;\n}\n\n/**\n * Validates whether a string is a valid HTTP or HTTPS URL.\n */\nexport function isValidHttpUrl(urlString?: string): boolean {\n if (!urlString || typeof urlString !== 'string') return false;\n try {\n const url = new URL(urlString.trim());\n return (url.protocol === 'http:' || url.protocol === 'https:') && url.hostname.length > 0;\n } catch {\n return false;\n }\n}\n\n/**\n * Builds a plain-text fallback string from an email DTO.\n */\nexport function buildPlainText(dto: EmailTemplateDto): string {\n if (dto.noHtmlMessage) {\n return dto.noHtmlMessage;\n }\n\n const divider = '──────────────────────────────';\n const parts: string[] = [];\n\n if (dto.header) {\n parts.push(dto.header, divider);\n }\n\n if (dto.body) {\n parts.push(htmlToPlainText(dto.body));\n }\n\n if (dto.otpCode) {\n parts.push(`Verification Code: ${dto.otpCode}`);\n }\n\n if (dto.actionText && dto.actionUrl) {\n parts.push(`${dto.actionText}: ${dto.actionUrl}`);\n }\n\n if (dto.extraMessage) {\n parts.push(htmlToPlainText(dto.extraMessage));\n }\n\n if (dto.footer) {\n parts.push(`${divider}\\n${htmlToPlainText(dto.footer)}`);\n }\n\n return parts.join('\\n\\n');\n}\n\n/**\n * Builds a responsive, styled HTML email document from an email DTO.\n */\nexport function buildHtml(dto: EmailTemplateDto, options: DefaultRendererOptions = {}): string {\n const primaryColor = options.primaryColor || '#4f46e5';\n const fontFamily =\n options.fontFamily ||\n \"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif\";\n const maxWidth = options.maxWidth || '600px';\n\n const parts: string[] = [\n `<!DOCTYPE html>`,\n `<html lang=\"en\">`,\n `<head>`,\n `<meta charset=\"UTF-8\">`,\n `<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">`,\n `<title>${dto.subject}</title>`,\n `</head>`,\n `<body style=\"margin:0;padding:24px 16px;background-color:#f9fafb;font-family:${fontFamily};color:#1f2937;line-height:1.6;\">`,\n `<div style=\"max-width:${maxWidth};margin:0 auto;background-color:#ffffff;padding:32px 28px;border-radius:8px;box-shadow:0 1px 3px rgba(0,0,0,0.1);border:1px solid #f3f4f6;\">`,\n ];\n\n const logoCandidate = dto.logoUrl ?? options.logoUrl;\n if (logoCandidate && isValidHttpUrl(logoCandidate)) {\n const validLogo = logoCandidate.trim();\n parts.push(\n `<div style=\"margin-bottom:24px;text-align:center;\">`,\n ` <img src=\"${validLogo}\" alt=\"${dto.fromName || 'Logo'}\" style=\"max-height:48px;max-width:200px;height:auto;width:auto;display:inline-block;border:0;outline:none;text-decoration:none;\" />`,\n `</div>`\n );\n }\n\n if (dto.imageUrl) {\n parts.push(\n `<div style=\"margin-bottom:24px;text-align:center;\">`,\n ` <img src=\"${dto.imageUrl}\" alt=\"Header\" style=\"max-width:100%;height:auto;border-radius:6px;\" />`,\n `</div>`\n );\n }\n\n if (dto.header) {\n parts.push(\n `<h2 style=\"margin:0 0 16px;font-size:1.5rem;font-weight:700;color:#111827;letter-spacing:-0.025em;\">${dto.header}</h2>`\n );\n }\n\n if (dto.body) {\n parts.push(`<div style=\"margin:0 0 20px;font-size:1rem;color:#374151;\">${dto.body}</div>`);\n }\n\n if (dto.otpCode) {\n parts.push(\n `<div style=\"margin:24px 0;padding:20px;background-color:#f3f4f6;border-radius:8px;text-align:center;\">`,\n ` <span style=\"font-size:2rem;letter-spacing:0.5rem;font-weight:700;color:#111827;font-family:monospace;\">${dto.otpCode}</span>`,\n `</div>`\n );\n }\n\n if (dto.actionUrl && dto.actionText) {\n parts.push(\n `<div style=\"margin:24px 0;text-align:center;\">`,\n ` <a href=\"${dto.actionUrl}\" style=\"display:inline-block;padding:12px 28px;background-color:${primaryColor};color:#ffffff;border-radius:6px;text-decoration:none;font-weight:600;font-size:1rem;text-align:center;box-sizing:border-box;\">${dto.actionText}</a>`,\n `</div>`\n );\n }\n\n if (dto.extraMessage) {\n parts.push(\n `<div style=\"margin:20px 0 0;font-size:0.875rem;color:#6b7280;line-height:1.5;\">${dto.extraMessage}</div>`\n );\n }\n\n if (dto.footer) {\n parts.push(\n `<div style=\"margin-top:32px;padding-top:20px;border-top:1px solid #e5e7eb;font-size:0.75rem;color:#9ca3af;text-align:center;\">${dto.footer}</div>`\n );\n }\n\n parts.push(`</div>`, `</body>`, `</html>`);\n return parts.join('\\n');\n}\n\n/**\n * Default HTML and plain-text email renderer for ts-mailkit.\n */\nexport class DefaultEmailRenderer implements IEmailRenderer {\n private readonly options: DefaultRendererOptions;\n\n constructor(options: DefaultRendererOptions = {}) {\n this.options = options;\n }\n\n render(dto: EmailTemplateDto): RenderedEmail {\n return {\n html: buildHtml(dto, this.options),\n text: buildPlainText(dto),\n };\n }\n}\n","import type { IEmailSender } from '../transports/sender.interface.js';\nimport type { IEmailRenderer, RenderedEmail } from '../renderers/renderer.interface.js';\nimport { DefaultEmailRenderer } from '../renderers/default/default-renderer.js';\nimport { htmlToPlainText } from '../renderers/utils/html-to-plaintext.js';\nimport type { EmailTemplateDto } from '../templates/dto/index.js';\nimport {\n normalizeRecipient,\n normalizeRecipients,\n type Recipient,\n type SendMailOptions,\n type SendResult,\n} from './types.js';\nimport { ConfigurationError } from './errors.js';\n\nexport interface SendTemplateOptions {\n /**\n * One or more recipient email addresses.\n */\n to: Recipient | Recipient[];\n /**\n * Templated email DTO to render and send.\n */\n template: EmailTemplateDto;\n /**\n * Optional recipient display name (used when `to` is a plain string).\n */\n toName?: string;\n /**\n * Optional sender display name override for this specific email.\n */\n fromName?: string;\n /**\n * Optional sender email address override.\n */\n from?: Recipient;\n /**\n * Optional CC recipients.\n */\n cc?: Recipient | Recipient[];\n /**\n * Optional BCC recipients.\n */\n bcc?: Recipient | Recipient[];\n /**\n * Optional Reply-To recipients.\n */\n replyTo?: Recipient | Recipient[];\n /**\n * Optional file attachments.\n */\n attachments?: SendMailOptions['attachments'];\n /**\n * Optional custom headers.\n */\n headers?: Record<string, string>;\n /**\n * Optional tags for tracking.\n */\n tags?: string[];\n /**\n * Optional metadata.\n */\n metadata?: Record<string, string>;\n}\n\nexport interface MailKitOptions {\n /**\n * The transport adapter used to dispatch emails (e.g. ZeptoMailHttpSender, MemoryEmailSender).\n */\n transport: IEmailSender;\n /**\n * Custom renderer implementation. Defaults to DefaultEmailRenderer.\n */\n renderer?: IEmailRenderer;\n /**\n * Default sender address or Recipient.\n */\n defaultFrom?: Recipient;\n /**\n * Default brand or application name.\n */\n defaultBrandName?: string;\n /**\n * Optional asynchronous or synchronous resolver to dynamically resolve brand/tenant name.\n * Useful for multitenant applications.\n */\n brandNameResolver?: () => Promise<string> | string;\n}\n\n/**\n * Main email client and orchestration service for ts-mailkit.\n */\nexport class MailKit {\n private readonly transport: IEmailSender;\n private readonly renderer: IEmailRenderer;\n private readonly defaultFrom?: Recipient;\n private readonly defaultBrandName?: string;\n private readonly brandNameResolver?: () => Promise<string> | string;\n\n constructor(options: MailKitOptions) {\n if (!options.transport) {\n throw new ConfigurationError('MailKit: A transport adapter (IEmailSender) is required.');\n }\n this.transport = options.transport;\n this.renderer = options.renderer ?? new DefaultEmailRenderer();\n this.defaultFrom = options.defaultFrom;\n this.defaultBrandName = options.defaultBrandName;\n this.brandNameResolver = options.brandNameResolver;\n }\n\n /**\n * Returns the underlying transport instance.\n */\n getTransport(): IEmailSender {\n return this.transport;\n }\n\n /**\n * Renders an email DTO to HTML and plain text without dispatching.\n */\n async render(template: EmailTemplateDto): Promise<RenderedEmail> {\n return await this.renderer.render(template);\n }\n\n /**\n * Sends an email using a strongly-typed template DTO.\n *\n * Example:\n * ```ts\n * await mailer.send({\n * to: 'user@example.com',\n * template: myDto,\n * });\n * ```\n */\n async send(options: SendTemplateOptions): Promise<SendResult> {\n const template = options.template;\n const recipientName = options.toName ?? template.userName;\n\n // Resolve fromName: explicit option > template.fromName > brand resolver > defaultBrandName\n let resolvedFromName = options.fromName ?? template.fromName;\n if (!resolvedFromName && this.brandNameResolver) {\n resolvedFromName = await this.brandNameResolver();\n }\n if (!resolvedFromName) {\n resolvedFromName = this.defaultBrandName;\n }\n\n // Render template DTO\n const rendered = await this.renderer.render(template);\n const plaintextBody = template.noHtmlMessage ?? rendered.text;\n\n // Format recipients\n let toRecipients: Recipient | Recipient[];\n if (typeof options.to === 'string' && recipientName) {\n toRecipients = { address: options.to, name: recipientName };\n } else {\n toRecipients = options.to;\n }\n\n // Resolve From address\n let from = options.from ?? this.defaultFrom;\n if (resolvedFromName && from) {\n const normalizedFrom = normalizeRecipient(from);\n from = { address: normalizedFrom.address, name: resolvedFromName };\n }\n\n return await this.sendRaw({\n to: toRecipients,\n from,\n subject: template.subject,\n html: rendered.html,\n text: plaintextBody,\n cc: options.cc,\n bcc: options.bcc,\n replyTo: options.replyTo,\n attachments: options.attachments,\n headers: options.headers,\n tags: options.tags,\n metadata: options.metadata,\n });\n }\n\n /**\n * Dispatches a raw, pre-rendered email directly through the transport.\n * If `options.text` is omitted, plain text is automatically derived from `options.html`.\n */\n async sendRaw(options: SendMailOptions): Promise<SendResult> {\n const from = options.from ?? this.defaultFrom;\n const text = options.text ?? (options.html ? htmlToPlainText(options.html) : undefined);\n return await this.transport.send({\n ...options,\n from,\n text,\n });\n }\n}\n\n/**\n * Convenience factory to create a MailKit client instance.\n */\nexport function createMailKit(options: MailKitOptions): MailKit {\n return new MailKit(options);\n}\n","import { ConfigurationError, TransportError } from '../../core/errors.js';\nimport {\n normalizeRecipient,\n normalizeRecipients,\n type SendMailOptions,\n type SendResult,\n} from '../../core/types.js';\nimport type { IEmailSender } from '../sender.interface.js';\nimport type {\n ZeptoMailHttpConfig,\n ZeptoMailSendPayload,\n ZeptoMailAttachmentPayload,\n} from './types.js';\n\n/**\n * ZeptoMail (Zoho Mail transactional email HTTP API) transport adapter.\n *\n * Designed for zero dependencies and universal edge compatibility (Node.js, Bun, Deno, Cloudflare Workers)\n * by utilizing the standard global `fetch` API.\n */\nexport class ZeptoMailHttpSender implements IEmailSender {\n readonly name = 'zeptomail';\n\n private readonly apiUrl: string;\n private readonly authHeader: string;\n private readonly defaultFrom: { address: string; name?: string };\n private readonly fetchImpl: typeof fetch;\n\n constructor(config: ZeptoMailHttpConfig) {\n if (!config.apiToken || typeof config.apiToken !== 'string') {\n throw new ConfigurationError('ZeptoMailHttpSender: Missing or invalid apiToken.');\n }\n if (!config.from) {\n throw new ConfigurationError('ZeptoMailHttpSender: Missing required default from address.');\n }\n\n const host = (config.apiHost || 'api.zeptomail.com').replace(/^https?:\\/\\//, '').replace(/\\/+$/, '');\n this.apiUrl = `https://${host}/v1.1/email`;\n\n // Normalize auth token header. In ZeptoMail, if the user already included \"Zoho-enczapikey \", use as is; otherwise format standard header.\n const token = config.apiToken.trim();\n this.authHeader = token.startsWith('Zoho-') ? token : `Zoho-enczapikey ${token}`;\n\n this.defaultFrom = normalizeRecipient(config.from);\n if (!this.defaultFrom.address) {\n throw new ConfigurationError('ZeptoMailHttpSender: Configured from address must not be empty.');\n }\n\n this.fetchImpl = config.fetch ?? globalThis.fetch;\n if (typeof this.fetchImpl !== 'function') {\n throw new ConfigurationError(\n 'ZeptoMailHttpSender: No global fetch implementation found. Pass a custom fetch to ZeptoMailHttpConfig if running on Node < 18.'\n );\n }\n }\n\n /**\n * Dispatches an email using Zoho ZeptoMail API v1.1.\n */\n async send(options: SendMailOptions): Promise<SendResult> {\n const toRecipients = normalizeRecipients(options.to);\n if (toRecipients.length === 0) {\n throw new TransportError('ZeptoMailHttpSender: At least one recipient (to) must be specified.', {\n transportName: this.name,\n });\n }\n\n const resolvedFrom = options.from ? normalizeRecipient(options.from) : this.defaultFrom;\n\n const payload: ZeptoMailSendPayload = {\n from: {\n address: resolvedFrom.address,\n name: resolvedFrom.name,\n },\n to: toRecipients.map((r) => ({\n email_address: {\n address: r.address,\n name: r.name || '',\n },\n })),\n subject: options.subject,\n htmlbody: options.html,\n textbody: options.text,\n };\n\n if (options.cc) {\n const ccList = normalizeRecipients(options.cc);\n if (ccList.length > 0) {\n payload.cc = ccList.map((r) => ({\n email_address: { address: r.address, name: r.name || '' },\n }));\n }\n }\n\n if (options.bcc) {\n const bccList = normalizeRecipients(options.bcc);\n if (bccList.length > 0) {\n payload.bcc = bccList.map((r) => ({\n email_address: { address: r.address, name: r.name || '' },\n }));\n }\n }\n\n if (options.replyTo) {\n const replyToList = normalizeRecipients(options.replyTo);\n if (replyToList.length > 0) {\n payload.reply_to = replyToList.map((r) => ({\n address: r.address,\n name: r.name,\n }));\n }\n }\n\n if (options.attachments && options.attachments.length > 0) {\n payload.attachments = options.attachments.map((att): ZeptoMailAttachmentPayload => {\n let contentBase64: string;\n if (typeof att.content === 'string') {\n contentBase64 = att.content;\n } else {\n // Buffer or Uint8Array\n if (typeof Buffer !== 'undefined') {\n contentBase64 = Buffer.from(att.content).toString('base64');\n } else {\n // Browser / Edge fallback for Uint8Array\n let binary = '';\n const bytes = new Uint8Array(att.content);\n for (let i = 0; i < bytes.byteLength; i++) {\n binary += String.fromCharCode(bytes[i]);\n }\n contentBase64 = btoa(binary);\n }\n }\n\n return {\n name: att.filename,\n content: contentBase64,\n mime_type: att.mimeType || att.contentType || 'application/octet-stream',\n cid: att.cid,\n };\n });\n }\n\n let response: Response;\n try {\n response = await this.fetchImpl(this.apiUrl, {\n method: 'POST',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n Authorization: this.authHeader,\n },\n body: JSON.stringify(payload),\n });\n } catch (err) {\n throw new TransportError(`ZeptoMailHttpSender: Network request failed: ${err instanceof Error ? err.message : String(err)}`, {\n transportName: this.name,\n cause: err,\n });\n }\n\n const responseText = await response.text();\n let responseData: any;\n try {\n responseData = responseText ? JSON.parse(responseText) : {};\n } catch {\n responseData = { raw: responseText };\n }\n\n if (!response.ok) {\n const errorMessage =\n responseData?.error?.message ||\n responseData?.message ||\n `HTTP ${response.status}: ${responseText || response.statusText}`;\n\n throw new TransportError(`ZeptoMailHttpSender: Failed to send email - ${errorMessage}`, {\n transportName: this.name,\n statusCode: response.status,\n responseBody: responseText,\n });\n }\n\n // Extract message ID from standard ZeptoMail v1.1 response structure:\n // { data: [ { message_id: \"...\" } ] }\n const messageId = responseData?.data?.[0]?.message_id;\n\n return {\n success: true,\n messageId,\n response: responseData,\n };\n }\n}\n","import type { SendMailOptions, SendResult } from '../../core/types.js';\nimport type { IEmailSender } from '../sender.interface.js';\n\n/**\n * In-memory email sender for automated testing, local development, and CI environments.\n * Captures all dispatched emails and provides inspection methods.\n */\nexport class MemoryEmailSender implements IEmailSender {\n readonly name = 'memory';\n\n private sentMails: SendMailOptions[] = [];\n private nextId = 1;\n\n async send(options: SendMailOptions): Promise<SendResult> {\n this.sentMails.push({ ...options });\n const messageId = `mem-${this.nextId++}-${Date.now()}`;\n return {\n success: true,\n messageId,\n response: { id: messageId },\n };\n }\n\n /**\n * Returns a copy of all emails sent through this transport instance.\n */\n getSentMails(): SendMailOptions[] {\n return [...this.sentMails];\n }\n\n /**\n * Returns the most recent email sent, or undefined if no emails have been sent.\n */\n getLastMail(): SendMailOptions | undefined {\n return this.sentMails.length > 0\n ? { ...this.sentMails[this.sentMails.length - 1] }\n : undefined;\n }\n\n /**\n * Clears all recorded sent emails.\n */\n clear(): void {\n this.sentMails = [];\n }\n\n /**\n * Returns the total count of sent emails.\n */\n count(): number {\n return this.sentMails.length;\n }\n}\n","import { normalizeRecipients, type SendMailOptions, type SendResult } from '../../core/types.js';\nimport type { IEmailSender } from '../sender.interface.js';\n\nexport interface ConsoleEmailSenderOptions {\n /**\n * Log level or custom log printer. Defaults to `console.log`.\n */\n logger?: (message: string) => void;\n /**\n * Whether to include the full HTML body in console output.\n * Defaults to false (prints plain text or a summary).\n */\n includeHtml?: boolean;\n}\n\n/**\n * Console logger transport that prints dispatched emails to stdout/stderr.\n * Ideal for development and debugging.\n */\nexport class ConsoleEmailSender implements IEmailSender {\n readonly name = 'console';\n\n private readonly log: (message: string) => void;\n private readonly includeHtml: boolean;\n private nextId = 1;\n\n constructor(options: ConsoleEmailSenderOptions = {}) {\n this.log = options.logger ?? console.log;\n this.includeHtml = options.includeHtml ?? false;\n }\n\n async send(options: SendMailOptions): Promise<SendResult> {\n const to = normalizeRecipients(options.to).map((r) => r.name ? `${r.name} <${r.address}>` : r.address).join(', ');\n const from = options.from ? JSON.stringify(options.from) : '(default)';\n const messageId = `console-${this.nextId++}-${Date.now()}`;\n\n const separator = '─'.repeat(60);\n const lines = [\n `\\n┌${separator}┐`,\n `│ [ts-mailkit:console] DISPATCHED EMAIL (${messageId})`,\n `├${separator}┤`,\n `│ From: ${from}`,\n `│ To: ${to}`,\n `│ Subject: ${options.subject}`,\n `├${separator}┤`,\n ];\n\n if (options.text) {\n lines.push('│ Text Body:');\n for (const line of options.text.split('\\n')) {\n lines.push(`│ ${line}`);\n }\n }\n\n if (this.includeHtml && options.html) {\n lines.push('│ HTML Body:');\n for (const line of options.html.split('\\n')) {\n lines.push(`│ ${line}`);\n }\n }\n\n lines.push(`└${separator}┘\\n`);\n\n this.log(lines.join('\\n'));\n\n return {\n success: true,\n messageId,\n response: { logged: true },\n };\n }\n}\n","import type { EmailTemplateDto, EmailVerificationParams, MagicLinkParams, NewsletterParams, PasswordResetParams, SimpleMessageParams, TwoFactorParams,} from './dto/index.js';\nimport { htmlToPlainText } from '../renderers/utils/html-to-plaintext.js';\n\nexport interface BrandingConfig {\n /**\n * Default brand, application, or company name.\n * @default 'Application'\n */\n brandName?: string;\n\n /**\n * Optional custom security / disclaimer advisory message.\n */\n securityMessage?: string;\n\n /**\n * Optional custom footer generator or string.\n */\n footer?: string | ((brandName: string) => string);\n\n /**\n * Optional default logo URL to display top-center in templated emails.\n */\n logoUrl?: string;\n}\n\nconst DEFAULT_SECURITY_MESSAGE =\n 'If you did not request this, please ignore this email or contact support if you have concerns.';\n\nfunction defaultFooter(brandName: string): string {\n return `© ${new Date().getFullYear()} ${brandName}. All rights reserved.`;\n}\n\n/**\n * Factory for creating pre-populated, type-safe email template DTOs.\n */\nexport class EmailTemplateFactory {\n private readonly defaultBrandName: string;\n private readonly defaultSecurityMessage: string;\n private readonly footerResolver: (brandName: string) => string;\n private readonly defaultLogoUrl?: string;\n\n constructor(config: BrandingConfig = {}) {\n this.defaultBrandName = config.brandName || 'Application';\n this.defaultSecurityMessage = config.securityMessage || DEFAULT_SECURITY_MESSAGE;\n this.defaultLogoUrl = config.logoUrl;\n if (typeof config.footer === 'function') {\n this.footerResolver = config.footer;\n } else if (typeof config.footer === 'string') {\n const fixedFooter = config.footer;\n this.footerResolver = () => fixedFooter;\n } else {\n this.footerResolver = defaultFooter;\n }\n }\n\n private resolveBrand(override?: string): string {\n return override || this.defaultBrandName;\n }\n\n private buildFooter(brandName: string): string {\n return this.footerResolver(brandName);\n }\n\n /**\n * Welcome / email-verification email sent after registration.\n */\n createEmailVerification(params: EmailVerificationParams): EmailTemplateDto {\n const { username, verificationUrl, otp, brandName } = params;\n const brand = this.resolveBrand(brandName);\n const body = `Hi ${username},<br/>Thank you for signing up. Use the code below or click the button to verify your email address.`;\n return {\n subject: 'Verify Your Email Address',\n header: `Welcome to ${brand}!`,\n body,\n logoUrl: this.defaultLogoUrl,\n otpCode: otp,\n actionUrl: verificationUrl,\n actionText: 'Verify Email',\n extraMessage: this.defaultSecurityMessage,\n footer: this.buildFooter(brand),\n userName: username,\n fromName: brand,\n noHtmlMessage:\n htmlToPlainText(body) +\n `\\n\\nYour verification code is: ${otp}\\n\\nAlternatively, verify here:\\n${verificationUrl}`,\n };\n }\n\n /**\n * Password-reset email with an optional OTP code and action link.\n */\n createPasswordReset(params: PasswordResetParams): EmailTemplateDto {\n const { username, resetUrl, otp = '', brandName } = params;\n const brand = this.resolveBrand(brandName);\n const body = `Hi ${username},<br/>We received a request to reset your password. Use the OTP code below or click the button to proceed.`;\n const plainTextOtp = otp ? `\\n\\nYour OTP code is: ${otp}` : '';\n return {\n subject: 'Password Reset Request',\n header: 'Reset Your Password',\n body,\n logoUrl: this.defaultLogoUrl,\n otpCode: otp || undefined,\n actionUrl: resetUrl,\n actionText: 'Reset Password',\n extraMessage: this.defaultSecurityMessage,\n footer: this.buildFooter(brand),\n userName: username,\n fromName: brand,\n noHtmlMessage:\n htmlToPlainText(body) +\n plainTextOtp +\n `\\n\\nAlternatively, you can use the following link to reset your password:\\n${resetUrl}`,\n };\n }\n\n /**\n * Generic plain message email (no action button, no OTP).\n */\n createSimpleMessage(params: SimpleMessageParams): EmailTemplateDto {\n const { subject, header, body, brandName } = params;\n const brand = this.resolveBrand(brandName);\n return {\n subject,\n header,\n body,\n logoUrl: this.defaultLogoUrl,\n footer: this.buildFooter(brand),\n fromName: brand,\n noHtmlMessage: htmlToPlainText(body),\n };\n }\n\n /**\n * Newsletter / announcement email with an optional hero image and CTA button.\n */\n createNewsLetter(params: NewsletterParams): EmailTemplateDto {\n const { subject, header, body, imageUrl, actionUrl, actionText, brandName, logoUrl } = params;\n const brand = this.resolveBrand(brandName);\n let noHtmlMessage = htmlToPlainText(body);\n if (actionUrl) {\n noHtmlMessage += `\\n\\n${actionText || 'Learn more'}: ${actionUrl}`;\n }\n return {\n subject,\n header,\n body,\n logoUrl: logoUrl || this.defaultLogoUrl,\n imageUrl,\n actionUrl,\n actionText,\n footer: this.buildFooter(brand),\n fromName: brand,\n noHtmlMessage,\n };\n }\n\n /**\n * Two-factor authentication email with OTP code and optional magic link.\n */\n create2FAEmail(params: TwoFactorParams): EmailTemplateDto {\n const { username, otp, magicLink = '', brandName } = params;\n const brand = this.resolveBrand(brandName);\n const body = `Hi ${username},<br/>Use the code below or click the button to complete your login.`;\n const plainLink = magicLink ? `\\n\\nAlternatively, verify here:\\n${magicLink}` : '';\n return {\n subject: 'Your Login Verification Code',\n header: 'Two-Factor Authentication',\n body,\n logoUrl: this.defaultLogoUrl,\n otpCode: otp,\n actionUrl: magicLink || undefined,\n actionText: magicLink ? 'Verify Login' : undefined,\n extraMessage: this.defaultSecurityMessage,\n footer: this.buildFooter(brand),\n userName: username,\n fromName: brand,\n noHtmlMessage: htmlToPlainText(body) + `\\n\\nYour verification code is: ${otp}` + plainLink,\n };\n }\n\n /**\n * Magic link sign-in email (no OTP, button only).\n */\n createMagicLinkEmail(params: MagicLinkParams): EmailTemplateDto {\n const { username, magicLink, brandName } = params;\n const brand = this.resolveBrand(brandName);\n const body = `Hi ${username},<br/>Click the button below to sign in. No password needed.`;\n return {\n subject: 'Your Magic Link',\n header: `Sign In to ${brand}`,\n body,\n logoUrl: this.defaultLogoUrl,\n actionUrl: magicLink,\n actionText: 'Sign In',\n extraMessage: this.defaultSecurityMessage,\n footer: this.buildFooter(brand),\n userName: username,\n fromName: brand,\n noHtmlMessage: htmlToPlainText(body) + `\\n\\nSign in here:\\n${magicLink}`,\n };\n }\n\n // ─── Default Static Instance ──────────────────────────────────────────────\n private static _defaultInstance?: EmailTemplateFactory;\n\n private static get defaultInstance(): EmailTemplateFactory {\n if (!this._defaultInstance) {\n this._defaultInstance = new EmailTemplateFactory();\n }\n return this._defaultInstance;\n }\n\n static createEmailVerification(params: EmailVerificationParams): EmailTemplateDto {\n return this.defaultInstance.createEmailVerification(params);\n }\n\n static createPasswordReset(params: PasswordResetParams): EmailTemplateDto {\n return this.defaultInstance.createPasswordReset(params);\n }\n\n static createSimpleMessage(params: SimpleMessageParams): EmailTemplateDto {\n return this.defaultInstance.createSimpleMessage(params);\n }\n\n static createNewsLetter(params: NewsletterParams): EmailTemplateDto {\n return this.defaultInstance.createNewsLetter(params);\n }\n\n static create2FAEmail(params: TwoFactorParams): EmailTemplateDto {\n return this.defaultInstance.create2FAEmail(params);\n }\n\n static createMagicLinkEmail(params: MagicLinkParams): EmailTemplateDto {\n return this.defaultInstance.createMagicLinkEmail(params);\n }\n}\n"],"mappings":";AAyBO,SAAS,kBAAkB,OAA6B;AAC7D,MAAI,CAAC,SAAS,OAAO,UAAU,UAAU;AACvC,WAAO,EAAE,SAAS,GAAG;AAAA,EACvB;AACA,QAAM,UAAU,MAAM,KAAK;AAC3B,QAAM,QAAQ,QAAQ,MAAM,uDAAuD;AACnF,MAAI,CAAC,OAAO;AACV,WAAO,EAAE,SAAS,QAAQ;AAAA,EAC5B;AACA,SAAO;AAAA,IACL,SAAS,MAAM,CAAC,EAAE,KAAK;AAAA,IACvB,MAAM,MAA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B,MAAM;AAAA,EAC5D;AAAA,EAEA,OAAO,oBAAoB,QAA+C;AACxE,WAAO,KAAK,gBAAgB,oBAAoB,MAAM;AAAA,EACxD;AAAA,EAEA,OAAO,oBAAoB,QAA+C;AACxE,WAAO,KAAK,gBAAgB,oBAAoB,MAAM;AAAA,EACxD;AAAA,EAEA,OAAO,iBAAiB,QAA4C;AAClE,WAAO,KAAK,gBAAgB,iBAAiB,MAAM;AAAA,EACrD;AAAA,EAEA,OAAO,eAAe,QAA2C;AAC/D,WAAO,KAAK,gBAAgB,eAAe,MAAM;AAAA,EACnD;AAAA,EAEA,OAAO,qBAAqB,QAA2C;AACrE,WAAO,KAAK,gBAAgB,qBAAqB,MAAM;AAAA,EACzD;AACF;","names":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EmailTemplateDto } from './dto/index.js';
|
|
1
|
+
import type { EmailTemplateDto, EmailVerificationParams, MagicLinkParams, NewsletterParams, PasswordResetParams, SimpleMessageParams, TwoFactorParams } from './dto/index.js';
|
|
2
2
|
export interface BrandingConfig {
|
|
3
3
|
/**
|
|
4
4
|
* Default brand, application, or company name.
|
|
@@ -32,34 +32,34 @@ export declare class EmailTemplateFactory {
|
|
|
32
32
|
/**
|
|
33
33
|
* Welcome / email-verification email sent after registration.
|
|
34
34
|
*/
|
|
35
|
-
createEmailVerification(
|
|
35
|
+
createEmailVerification(params: EmailVerificationParams): EmailTemplateDto;
|
|
36
36
|
/**
|
|
37
37
|
* Password-reset email with an optional OTP code and action link.
|
|
38
38
|
*/
|
|
39
|
-
createPasswordReset(
|
|
39
|
+
createPasswordReset(params: PasswordResetParams): EmailTemplateDto;
|
|
40
40
|
/**
|
|
41
41
|
* Generic plain message email (no action button, no OTP).
|
|
42
42
|
*/
|
|
43
|
-
createSimpleMessage(
|
|
43
|
+
createSimpleMessage(params: SimpleMessageParams): EmailTemplateDto;
|
|
44
44
|
/**
|
|
45
45
|
* Newsletter / announcement email with an optional hero image and CTA button.
|
|
46
46
|
*/
|
|
47
|
-
createNewsLetter(
|
|
47
|
+
createNewsLetter(params: NewsletterParams): EmailTemplateDto;
|
|
48
48
|
/**
|
|
49
49
|
* Two-factor authentication email with OTP code and optional magic link.
|
|
50
50
|
*/
|
|
51
|
-
create2FAEmail(
|
|
51
|
+
create2FAEmail(params: TwoFactorParams): EmailTemplateDto;
|
|
52
52
|
/**
|
|
53
53
|
* Magic link sign-in email (no OTP, button only).
|
|
54
54
|
*/
|
|
55
|
-
createMagicLinkEmail(
|
|
55
|
+
createMagicLinkEmail(params: MagicLinkParams): EmailTemplateDto;
|
|
56
56
|
private static _defaultInstance?;
|
|
57
57
|
private static get defaultInstance();
|
|
58
|
-
static createEmailVerification(
|
|
59
|
-
static createPasswordReset(
|
|
60
|
-
static createSimpleMessage(
|
|
61
|
-
static createNewsLetter(
|
|
62
|
-
static create2FAEmail(
|
|
63
|
-
static createMagicLinkEmail(
|
|
58
|
+
static createEmailVerification(params: EmailVerificationParams): EmailTemplateDto;
|
|
59
|
+
static createPasswordReset(params: PasswordResetParams): EmailTemplateDto;
|
|
60
|
+
static createSimpleMessage(params: SimpleMessageParams): EmailTemplateDto;
|
|
61
|
+
static createNewsLetter(params: NewsletterParams): EmailTemplateDto;
|
|
62
|
+
static create2FAEmail(params: TwoFactorParams): EmailTemplateDto;
|
|
63
|
+
static createMagicLinkEmail(params: MagicLinkParams): EmailTemplateDto;
|
|
64
64
|
}
|
|
65
65
|
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/templates/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/templates/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,eAAe,EAAE,gBAA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MAAM,CAAC,mBAAmB,CAAC,MAAM,EAAE,mBAAmB,GAAG,gBAAgB;IAIzE,MAAM,CAAC,mBAAmB,CAAC,MAAM,EAAE,mBAAmB,GAAG,gBAAgB;IAIzE,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,gBAAgB;IAInE,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,eAAe,GAAG,gBAAgB;IAIhE,MAAM,CAAC,oBAAoB,CAAC,MAAM,EAAE,eAAe,GAAG,gBAAgB;CAGvE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-mailkit",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Strictly typed, modular, and composable email composition and dispatch library for TypeScript and modern edge runtimes.",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|