@nauth-toolkit/email-nodemailer 0.1.14 → 0.1.18
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/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/nodemailer-email.provider.d.ts +189 -0
- package/dist/nodemailer-email.provider.d.ts.map +1 -1
- package/dist/nodemailer-email.provider.js +149 -0
- package/dist/nodemailer-email.provider.js.map +1 -1
- package/dist/templates/handlebars-template.engine.d.ts +191 -0
- package/dist/templates/handlebars-template.engine.d.ts.map +1 -1
- package/dist/templates/handlebars-template.engine.js +168 -0
- package/dist/templates/handlebars-template.engine.js.map +1 -1
- package/dist/templates/index.d.ts +5 -0
- package/dist/templates/index.d.ts.map +1 -1
- package/dist/templates/index.js +5 -0
- package/dist/templates/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @nauth-toolkit/email-nodemailer
|
|
3
|
+
*
|
|
4
|
+
* Nodemailer email provider for nauth-toolkit.
|
|
5
|
+
* Supports SMTP, Gmail, SendGrid SMTP, AWS SES SMTP, and more.
|
|
6
|
+
*/
|
|
1
7
|
export { NodemailerProvider as NodemailerEmailProvider } from './nodemailer-email.provider';
|
|
2
8
|
export * from './templates';
|
|
3
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,kBAAkB,IAAI,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAC5F,cAAc,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @nauth-toolkit/email-nodemailer
|
|
4
|
+
*
|
|
5
|
+
* Nodemailer email provider for nauth-toolkit.
|
|
6
|
+
* Supports SMTP, Gmail, SendGrid SMTP, AWS SES SMTP, and more.
|
|
7
|
+
*/
|
|
2
8
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
9
|
if (k2 === undefined) k2 = k;
|
|
4
10
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;AAEH,yEAA4F;AAAnF,oIAAA,kBAAkB,OAA2B;AACtD,8CAA4B"}
|
|
@@ -1,8 +1,32 @@
|
|
|
1
1
|
import { EmailProvider, TemplateVariables, LoggerService } from '@nauth-toolkit/core';
|
|
2
|
+
/**
|
|
3
|
+
* Nodemailer Transport Configuration
|
|
4
|
+
*
|
|
5
|
+
* Supports various transport types:
|
|
6
|
+
* - SMTP (generic)
|
|
7
|
+
* - AWS SES
|
|
8
|
+
* - SendGrid
|
|
9
|
+
* - Mailgun
|
|
10
|
+
* - Postmark
|
|
11
|
+
* - Gmail (with OAuth2)
|
|
12
|
+
* - Outlook/Office365
|
|
13
|
+
*/
|
|
2
14
|
export interface NodemailerTransportConfig {
|
|
15
|
+
/**
|
|
16
|
+
* SMTP host (e.g., 'smtp.gmail.com')
|
|
17
|
+
*/
|
|
3
18
|
host?: string;
|
|
19
|
+
/**
|
|
20
|
+
* SMTP port (e.g., 587 for TLS, 465 for SSL)
|
|
21
|
+
*/
|
|
4
22
|
port?: number;
|
|
23
|
+
/**
|
|
24
|
+
* Use secure connection (TLS)
|
|
25
|
+
*/
|
|
5
26
|
secure?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Authentication credentials
|
|
29
|
+
*/
|
|
6
30
|
auth?: {
|
|
7
31
|
user: string;
|
|
8
32
|
pass: string;
|
|
@@ -14,21 +38,129 @@ export interface NodemailerTransportConfig {
|
|
|
14
38
|
refreshToken: string;
|
|
15
39
|
accessToken?: string;
|
|
16
40
|
};
|
|
41
|
+
/**
|
|
42
|
+
* Service name (e.g., 'gmail', 'SendGrid', 'SES')
|
|
43
|
+
*/
|
|
17
44
|
service?: string;
|
|
45
|
+
/**
|
|
46
|
+
* AWS region (for SES)
|
|
47
|
+
*/
|
|
18
48
|
region?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Additional transport options
|
|
51
|
+
*/
|
|
19
52
|
[key: string]: any;
|
|
20
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Nodemailer Provider Configuration
|
|
56
|
+
*/
|
|
21
57
|
export interface NodemailerProviderConfig {
|
|
58
|
+
/**
|
|
59
|
+
* Nodemailer transport configuration
|
|
60
|
+
*/
|
|
22
61
|
transport: NodemailerTransportConfig;
|
|
62
|
+
/**
|
|
63
|
+
* Default email options (from, replyTo, etc.)
|
|
64
|
+
*/
|
|
23
65
|
defaults?: {
|
|
24
66
|
from?: string;
|
|
25
67
|
replyTo?: string;
|
|
26
68
|
[key: string]: any;
|
|
27
69
|
};
|
|
70
|
+
/**
|
|
71
|
+
* Enable template engine (default: true)
|
|
72
|
+
*/
|
|
28
73
|
useTemplates?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Custom template engine (default: HandlebarsTemplateEngine with MJML templates)
|
|
76
|
+
*/
|
|
29
77
|
templateEngine?: any;
|
|
78
|
+
/**
|
|
79
|
+
* Enable preview URL in development (default: false)
|
|
80
|
+
*/
|
|
30
81
|
preview?: boolean;
|
|
31
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Nodemailer Email Provider
|
|
85
|
+
*
|
|
86
|
+
* Production-ready email provider using Nodemailer.
|
|
87
|
+
* Supports multiple transports: SMTP, SES, SendGrid, Mailgun, etc.
|
|
88
|
+
*
|
|
89
|
+
* **Features:**
|
|
90
|
+
* - Multiple transport support (SMTP, SES, SendGrid, etc.)
|
|
91
|
+
* - HTML template rendering with variable injection
|
|
92
|
+
* - Automatic plain text generation
|
|
93
|
+
* - Connection pooling
|
|
94
|
+
* - Retry logic
|
|
95
|
+
* - Preview URLs in development
|
|
96
|
+
*
|
|
97
|
+
* **Phase 2c Implementation**
|
|
98
|
+
*
|
|
99
|
+
* @example SMTP Configuration
|
|
100
|
+
* ```typescript
|
|
101
|
+
* AuthModule.forRoot({
|
|
102
|
+
* email: {
|
|
103
|
+
* provider: new NodemailerProvider({
|
|
104
|
+
* transport: {
|
|
105
|
+
* host: 'smtp.example.com',
|
|
106
|
+
* port: 587,
|
|
107
|
+
* secure: false,
|
|
108
|
+
* auth: {
|
|
109
|
+
* user: process.env.SMTP_USER,
|
|
110
|
+
* pass: process.env.SMTP_PASS,
|
|
111
|
+
* },
|
|
112
|
+
* },
|
|
113
|
+
* defaults: {
|
|
114
|
+
* from: '"My App" <noreply@example.com>',
|
|
115
|
+
* },
|
|
116
|
+
* }),
|
|
117
|
+
* },
|
|
118
|
+
* })
|
|
119
|
+
* ```
|
|
120
|
+
*
|
|
121
|
+
* @example AWS SES Configuration
|
|
122
|
+
* ```typescript
|
|
123
|
+
* new NodemailerProvider({
|
|
124
|
+
* transport: {
|
|
125
|
+
* service: 'SES',
|
|
126
|
+
* auth: {
|
|
127
|
+
* user: process.env.AWS_ACCESS_KEY_ID,
|
|
128
|
+
* pass: process.env.AWS_SECRET_ACCESS_KEY,
|
|
129
|
+
* },
|
|
130
|
+
* region: 'us-east-1',
|
|
131
|
+
* },
|
|
132
|
+
* })
|
|
133
|
+
* ```
|
|
134
|
+
*
|
|
135
|
+
* @example SendGrid Configuration
|
|
136
|
+
* ```typescript
|
|
137
|
+
* new NodemailerProvider({
|
|
138
|
+
* transport: {
|
|
139
|
+
* service: 'SendGrid',
|
|
140
|
+
* auth: {
|
|
141
|
+
* user: 'apikey',
|
|
142
|
+
* pass: process.env.SENDGRID_API_KEY,
|
|
143
|
+
* },
|
|
144
|
+
* },
|
|
145
|
+
* })
|
|
146
|
+
* ```
|
|
147
|
+
*
|
|
148
|
+
* @example Gmail with OAuth2
|
|
149
|
+
* ```typescript
|
|
150
|
+
* new NodemailerProvider({
|
|
151
|
+
* transport: {
|
|
152
|
+
* service: 'gmail',
|
|
153
|
+
* auth: {
|
|
154
|
+
* type: 'OAuth2',
|
|
155
|
+
* user: process.env.GMAIL_USER,
|
|
156
|
+
* clientId: process.env.GMAIL_CLIENT_ID,
|
|
157
|
+
* clientSecret: process.env.GMAIL_CLIENT_SECRET,
|
|
158
|
+
* refreshToken: process.env.GMAIL_REFRESH_TOKEN,
|
|
159
|
+
* },
|
|
160
|
+
* },
|
|
161
|
+
* })
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
32
164
|
export declare class NodemailerProvider implements EmailProvider {
|
|
33
165
|
private logger?;
|
|
34
166
|
private readonly transporter;
|
|
@@ -36,16 +168,73 @@ export declare class NodemailerProvider implements EmailProvider {
|
|
|
36
168
|
private readonly defaults;
|
|
37
169
|
private readonly preview;
|
|
38
170
|
private globalVariables;
|
|
171
|
+
/**
|
|
172
|
+
* Set logger instance (called by AuthModule to inject NAuthLogger)
|
|
173
|
+
* @param logger - Logger instance to use
|
|
174
|
+
*/
|
|
39
175
|
setLogger(logger: LoggerService): void;
|
|
176
|
+
/**
|
|
177
|
+
* Set global template variables (called by AuthModule to inject email config)
|
|
178
|
+
* @param variables - Global variables to merge with all template variables
|
|
179
|
+
*/
|
|
40
180
|
setGlobalVariables(variables: TemplateVariables): void;
|
|
181
|
+
/**
|
|
182
|
+
* Constructor
|
|
183
|
+
*
|
|
184
|
+
* @param config - Nodemailer provider configuration
|
|
185
|
+
*/
|
|
41
186
|
constructor(config: NodemailerProviderConfig);
|
|
187
|
+
/**
|
|
188
|
+
* Verify SMTP connection
|
|
189
|
+
* @private
|
|
190
|
+
*/
|
|
42
191
|
private verifyConnection;
|
|
192
|
+
/**
|
|
193
|
+
* Send verification email with code and/or link
|
|
194
|
+
*
|
|
195
|
+
* @param to - Recipient email address
|
|
196
|
+
* @param code - Verification code (e.g., "123456")
|
|
197
|
+
* @param link - Optional verification link (only rendered if provided)
|
|
198
|
+
*/
|
|
43
199
|
sendVerificationEmail(to: string, code: string, link?: string, expiryMinutes?: number, variables?: TemplateVariables): Promise<void>;
|
|
200
|
+
/**
|
|
201
|
+
* Send password reset email with link
|
|
202
|
+
*
|
|
203
|
+
* @param to - Recipient email address
|
|
204
|
+
* @param token - Password reset token
|
|
205
|
+
* @param link - Password reset link
|
|
206
|
+
*/
|
|
44
207
|
sendPasswordResetEmail(to: string, _token: string, link: string, expiryMinutes?: number, variables?: TemplateVariables): Promise<void>;
|
|
208
|
+
/**
|
|
209
|
+
* Send welcome email to new user
|
|
210
|
+
*
|
|
211
|
+
* @param to - Recipient email address
|
|
212
|
+
* @param name - User's name
|
|
213
|
+
*/
|
|
45
214
|
sendWelcomeEmail(to: string, name: string, variables?: TemplateVariables): Promise<void>;
|
|
215
|
+
/**
|
|
216
|
+
* Send account lockout notification
|
|
217
|
+
*
|
|
218
|
+
* @param to - Recipient email address
|
|
219
|
+
* @param reason - Lockout reason
|
|
220
|
+
* @param duration - Lockout duration in minutes
|
|
221
|
+
*/
|
|
46
222
|
sendLockoutEmail(to: string, reason: string, duration: number, variables?: TemplateVariables): Promise<void>;
|
|
223
|
+
/**
|
|
224
|
+
* Send new device login notification
|
|
225
|
+
*
|
|
226
|
+
* @param to - Recipient email address
|
|
227
|
+
* @param deviceInfo - Device information
|
|
228
|
+
*/
|
|
47
229
|
sendNewDeviceEmail(to: string, deviceInfo: any, variables?: TemplateVariables): Promise<void>;
|
|
230
|
+
/**
|
|
231
|
+
* Send email using Nodemailer
|
|
232
|
+
* @private
|
|
233
|
+
*/
|
|
48
234
|
private sendMail;
|
|
235
|
+
/**
|
|
236
|
+
* Close transporter connection
|
|
237
|
+
*/
|
|
49
238
|
close(): Promise<void>;
|
|
50
239
|
}
|
|
51
240
|
//# sourceMappingURL=nodemailer-email.provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodemailer-email.provider.d.ts","sourceRoot":"","sources":["../src/nodemailer-email.provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAgB,iBAAiB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"nodemailer-email.provider.d.ts","sourceRoot":"","sources":["../src/nodemailer-email.provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAgB,iBAAiB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAKpG;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;OAEG;IACH,IAAI,CAAC,EACD;QACE,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;KACd,GACD;QACE,IAAI,EAAE,QAAQ,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,YAAY,EAAE,MAAM,CAAC;QACrB,YAAY,EAAE,MAAM,CAAC;QACrB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;IAEN;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED;;GAEG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ACV,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,aAAa,GAAE,MAAW,EAC1B,SAAS,GAAE,iBAAsB,GAChC,OAAO,CAAC,IAAI,CAAC;IAoBhB;;;;;OAKG;IACG,gBAAgB,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,GAAE,iBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBlG;;;;;;OAMG;IACG,gBAAgB,CACpB,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,SAAS,GAAE,iBAAsB,GAChC,OAAO,CAAC,IAAI,CAAC;IAoBhB;;;;;OAKG;IACG,kBAAkB,CAAC,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,SAAS,GAAE,iBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAuBvG;;;OAGG;YACW,QAAQ;IAyCtB;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAI7B"}
|
|
@@ -37,6 +37,87 @@ exports.NodemailerProvider = void 0;
|
|
|
37
37
|
const core_1 = require("@nauth-toolkit/core");
|
|
38
38
|
const handlebars_template_engine_1 = require("./templates/handlebars-template.engine");
|
|
39
39
|
const nodemailer = __importStar(require("nodemailer"));
|
|
40
|
+
/**
|
|
41
|
+
* Nodemailer Email Provider
|
|
42
|
+
*
|
|
43
|
+
* Production-ready email provider using Nodemailer.
|
|
44
|
+
* Supports multiple transports: SMTP, SES, SendGrid, Mailgun, etc.
|
|
45
|
+
*
|
|
46
|
+
* **Features:**
|
|
47
|
+
* - Multiple transport support (SMTP, SES, SendGrid, etc.)
|
|
48
|
+
* - HTML template rendering with variable injection
|
|
49
|
+
* - Automatic plain text generation
|
|
50
|
+
* - Connection pooling
|
|
51
|
+
* - Retry logic
|
|
52
|
+
* - Preview URLs in development
|
|
53
|
+
*
|
|
54
|
+
* **Phase 2c Implementation**
|
|
55
|
+
*
|
|
56
|
+
* @example SMTP Configuration
|
|
57
|
+
* ```typescript
|
|
58
|
+
* AuthModule.forRoot({
|
|
59
|
+
* email: {
|
|
60
|
+
* provider: new NodemailerProvider({
|
|
61
|
+
* transport: {
|
|
62
|
+
* host: 'smtp.example.com',
|
|
63
|
+
* port: 587,
|
|
64
|
+
* secure: false,
|
|
65
|
+
* auth: {
|
|
66
|
+
* user: process.env.SMTP_USER,
|
|
67
|
+
* pass: process.env.SMTP_PASS,
|
|
68
|
+
* },
|
|
69
|
+
* },
|
|
70
|
+
* defaults: {
|
|
71
|
+
* from: '"My App" <noreply@example.com>',
|
|
72
|
+
* },
|
|
73
|
+
* }),
|
|
74
|
+
* },
|
|
75
|
+
* })
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
78
|
+
* @example AWS SES Configuration
|
|
79
|
+
* ```typescript
|
|
80
|
+
* new NodemailerProvider({
|
|
81
|
+
* transport: {
|
|
82
|
+
* service: 'SES',
|
|
83
|
+
* auth: {
|
|
84
|
+
* user: process.env.AWS_ACCESS_KEY_ID,
|
|
85
|
+
* pass: process.env.AWS_SECRET_ACCESS_KEY,
|
|
86
|
+
* },
|
|
87
|
+
* region: 'us-east-1',
|
|
88
|
+
* },
|
|
89
|
+
* })
|
|
90
|
+
* ```
|
|
91
|
+
*
|
|
92
|
+
* @example SendGrid Configuration
|
|
93
|
+
* ```typescript
|
|
94
|
+
* new NodemailerProvider({
|
|
95
|
+
* transport: {
|
|
96
|
+
* service: 'SendGrid',
|
|
97
|
+
* auth: {
|
|
98
|
+
* user: 'apikey',
|
|
99
|
+
* pass: process.env.SENDGRID_API_KEY,
|
|
100
|
+
* },
|
|
101
|
+
* },
|
|
102
|
+
* })
|
|
103
|
+
* ```
|
|
104
|
+
*
|
|
105
|
+
* @example Gmail with OAuth2
|
|
106
|
+
* ```typescript
|
|
107
|
+
* new NodemailerProvider({
|
|
108
|
+
* transport: {
|
|
109
|
+
* service: 'gmail',
|
|
110
|
+
* auth: {
|
|
111
|
+
* type: 'OAuth2',
|
|
112
|
+
* user: process.env.GMAIL_USER,
|
|
113
|
+
* clientId: process.env.GMAIL_CLIENT_ID,
|
|
114
|
+
* clientSecret: process.env.GMAIL_CLIENT_SECRET,
|
|
115
|
+
* refreshToken: process.env.GMAIL_REFRESH_TOKEN,
|
|
116
|
+
* },
|
|
117
|
+
* },
|
|
118
|
+
* })
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
40
121
|
class NodemailerProvider {
|
|
41
122
|
logger;
|
|
42
123
|
transporter;
|
|
@@ -44,25 +125,47 @@ class NodemailerProvider {
|
|
|
44
125
|
defaults;
|
|
45
126
|
preview;
|
|
46
127
|
globalVariables = {};
|
|
128
|
+
/**
|
|
129
|
+
* Set logger instance (called by AuthModule to inject NAuthLogger)
|
|
130
|
+
* @param logger - Logger instance to use
|
|
131
|
+
*/
|
|
47
132
|
setLogger(logger) {
|
|
48
133
|
this.logger = logger;
|
|
49
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* Set global template variables (called by AuthModule to inject email config)
|
|
137
|
+
* @param variables - Global variables to merge with all template variables
|
|
138
|
+
*/
|
|
50
139
|
setGlobalVariables(variables) {
|
|
51
140
|
this.globalVariables = variables || {};
|
|
52
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* Constructor
|
|
144
|
+
*
|
|
145
|
+
* @param config - Nodemailer provider configuration
|
|
146
|
+
*/
|
|
53
147
|
constructor(config) {
|
|
148
|
+
// Log configuration (sanitized)
|
|
54
149
|
this.logger?.debug?.('Initializing NodemailerProvider', {
|
|
55
150
|
host: config.transport.host,
|
|
56
151
|
port: config.transport.port,
|
|
57
152
|
secure: config.transport.secure,
|
|
58
153
|
from: config.defaults?.from,
|
|
59
154
|
});
|
|
155
|
+
// Create Nodemailer transporter
|
|
60
156
|
this.transporter = nodemailer.createTransport(config.transport);
|
|
157
|
+
// Initialize template engine
|
|
61
158
|
this.templateEngine = config.templateEngine || new handlebars_template_engine_1.HandlebarsTemplateEngine();
|
|
159
|
+
// Set defaults
|
|
62
160
|
this.defaults = config.defaults || {};
|
|
63
161
|
this.preview = config.preview || false;
|
|
162
|
+
// Verify connection
|
|
64
163
|
this.verifyConnection();
|
|
65
164
|
}
|
|
165
|
+
/**
|
|
166
|
+
* Verify SMTP connection
|
|
167
|
+
* @private
|
|
168
|
+
*/
|
|
66
169
|
async verifyConnection() {
|
|
67
170
|
try {
|
|
68
171
|
this.logger?.debug?.('Verifying SMTP connection...');
|
|
@@ -78,9 +181,17 @@ class NodemailerProvider {
|
|
|
78
181
|
if (error?.command) {
|
|
79
182
|
this.logger?.error?.(`Failed at command: ${error.command}`);
|
|
80
183
|
}
|
|
184
|
+
// Log full error for debugging
|
|
81
185
|
this.logger?.debug?.('Full error object:', error);
|
|
82
186
|
}
|
|
83
187
|
}
|
|
188
|
+
/**
|
|
189
|
+
* Send verification email with code and/or link
|
|
190
|
+
*
|
|
191
|
+
* @param to - Recipient email address
|
|
192
|
+
* @param code - Verification code (e.g., "123456")
|
|
193
|
+
* @param link - Optional verification link (only rendered if provided)
|
|
194
|
+
*/
|
|
84
195
|
async sendVerificationEmail(to, code, link, expiryMinutes = 60, variables = {}) {
|
|
85
196
|
const templateVariables = {
|
|
86
197
|
...this.globalVariables,
|
|
@@ -90,6 +201,7 @@ class NodemailerProvider {
|
|
|
90
201
|
expiryMinutes,
|
|
91
202
|
...variables,
|
|
92
203
|
};
|
|
204
|
+
// Only include link if provided
|
|
93
205
|
if (link) {
|
|
94
206
|
templateVariables.link = link;
|
|
95
207
|
}
|
|
@@ -101,6 +213,13 @@ class NodemailerProvider {
|
|
|
101
213
|
text: email.text,
|
|
102
214
|
});
|
|
103
215
|
}
|
|
216
|
+
/**
|
|
217
|
+
* Send password reset email with link
|
|
218
|
+
*
|
|
219
|
+
* @param to - Recipient email address
|
|
220
|
+
* @param token - Password reset token
|
|
221
|
+
* @param link - Password reset link
|
|
222
|
+
*/
|
|
104
223
|
async sendPasswordResetEmail(to, _token, link, expiryMinutes = 60, variables = {}) {
|
|
105
224
|
const templateVariables = {
|
|
106
225
|
...this.globalVariables,
|
|
@@ -118,6 +237,12 @@ class NodemailerProvider {
|
|
|
118
237
|
text: email.text,
|
|
119
238
|
});
|
|
120
239
|
}
|
|
240
|
+
/**
|
|
241
|
+
* Send welcome email to new user
|
|
242
|
+
*
|
|
243
|
+
* @param to - Recipient email address
|
|
244
|
+
* @param name - User's name
|
|
245
|
+
*/
|
|
121
246
|
async sendWelcomeEmail(to, name, variables = {}) {
|
|
122
247
|
const templateVariables = {
|
|
123
248
|
...this.globalVariables,
|
|
@@ -133,6 +258,13 @@ class NodemailerProvider {
|
|
|
133
258
|
text: email.text,
|
|
134
259
|
});
|
|
135
260
|
}
|
|
261
|
+
/**
|
|
262
|
+
* Send account lockout notification
|
|
263
|
+
*
|
|
264
|
+
* @param to - Recipient email address
|
|
265
|
+
* @param reason - Lockout reason
|
|
266
|
+
* @param duration - Lockout duration in minutes
|
|
267
|
+
*/
|
|
136
268
|
async sendLockoutEmail(to, reason, duration, variables = {}) {
|
|
137
269
|
const templateVariables = {
|
|
138
270
|
...this.globalVariables,
|
|
@@ -150,6 +282,12 @@ class NodemailerProvider {
|
|
|
150
282
|
text: email.text,
|
|
151
283
|
});
|
|
152
284
|
}
|
|
285
|
+
/**
|
|
286
|
+
* Send new device login notification
|
|
287
|
+
*
|
|
288
|
+
* @param to - Recipient email address
|
|
289
|
+
* @param deviceInfo - Device information
|
|
290
|
+
*/
|
|
153
291
|
async sendNewDeviceEmail(to, deviceInfo, variables = {}) {
|
|
154
292
|
const templateVariables = {
|
|
155
293
|
...this.globalVariables,
|
|
@@ -170,21 +308,29 @@ class NodemailerProvider {
|
|
|
170
308
|
text: email.text,
|
|
171
309
|
});
|
|
172
310
|
}
|
|
311
|
+
/**
|
|
312
|
+
* Send email using Nodemailer
|
|
313
|
+
* @private
|
|
314
|
+
*/
|
|
173
315
|
async sendMail(mailOptions) {
|
|
174
316
|
try {
|
|
317
|
+
// Merge with defaults
|
|
175
318
|
const options = {
|
|
176
319
|
...this.defaults,
|
|
177
320
|
...mailOptions,
|
|
178
321
|
};
|
|
322
|
+
// Log email details (sanitized)
|
|
179
323
|
this.logger?.debug?.('Sending email:', {
|
|
180
324
|
to: options.to,
|
|
181
325
|
from: options.from,
|
|
182
326
|
subject: options.subject,
|
|
183
327
|
});
|
|
328
|
+
// Send email
|
|
184
329
|
const info = await this.transporter.sendMail(options);
|
|
185
330
|
this.logger?.log?.(`Email sent successfully`);
|
|
186
331
|
this.logger?.debug?.(`Message ID: ${info.messageId}`);
|
|
187
332
|
this.logger?.debug?.(`Response: ${info.response}`);
|
|
333
|
+
// Preview URL in development
|
|
188
334
|
if (this.preview) {
|
|
189
335
|
const previewUrl = nodemailer.getTestMessageUrl(info);
|
|
190
336
|
if (previewUrl) {
|
|
@@ -203,6 +349,9 @@ class NodemailerProvider {
|
|
|
203
349
|
throw error;
|
|
204
350
|
}
|
|
205
351
|
}
|
|
352
|
+
/**
|
|
353
|
+
* Close transporter connection
|
|
354
|
+
*/
|
|
206
355
|
async close() {
|
|
207
356
|
this.transporter.close();
|
|
208
357
|
this.logger?.log?.('Nodemailer transporter closed');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodemailer-email.provider.js","sourceRoot":"","sources":["../src/nodemailer-email.provider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAoG;AACpG,uFAAkF;AAClF,uDAAyC;
|
|
1
|
+
{"version":3,"file":"nodemailer-email.provider.js","sourceRoot":"","sources":["../src/nodemailer-email.provider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAoG;AACpG,uFAAkF;AAClF,uDAAyC;AAkGzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgFG;AACH,MAAa,kBA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AM,EAAE,GAAG,EAAE,CAAC,gBAAgB,UAAU,EAAE,CAAC,CAAC;gBACnD,CAAC;YACH,CAAC;QACH,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,sBAAsB,CAAC,CAAC;YAC7C,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,OAAO,WAAW,CAAC,EAAE,EAAE,CAAC,CAAC;YAC9C,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,UAAU,KAAK,EAAE,OAAO,IAAI,eAAe,EAAE,CAAC,CAAC;YACpE,IAAI,KAAK,EAAE,IAAI,EAAE,CAAC;gBAChB,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,eAAe,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;YACpD,CAAC;YACD,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAAC;YAClD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,+BAA+B,CAAC,CAAC;IACtD,CAAC;CACF;AA3RD,gDA2RC"}
|
|
@@ -1,35 +1,226 @@
|
|
|
1
1
|
import { TemplateEngine, TemplateType, TemplateVariables, EmailTemplate } from '@nauth-toolkit/core';
|
|
2
2
|
import * as Handlebars from 'handlebars';
|
|
3
|
+
/**
|
|
4
|
+
* Template Source
|
|
5
|
+
*
|
|
6
|
+
* Defines how template content can be provided - as a string or file path
|
|
7
|
+
*/
|
|
3
8
|
export interface TemplateSource {
|
|
9
|
+
/**
|
|
10
|
+
* Template content as a string
|
|
11
|
+
*/
|
|
4
12
|
content?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Path to template file (relative or absolute)
|
|
15
|
+
* Supports .hbs, .html, .txt, etc.
|
|
16
|
+
*/
|
|
5
17
|
filePath?: string;
|
|
6
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Template Files Configuration
|
|
21
|
+
*
|
|
22
|
+
* Defines template sources for subject, HTML, and text content.
|
|
23
|
+
* Supports both inline content and file paths.
|
|
24
|
+
*/
|
|
7
25
|
export interface TemplateFiles {
|
|
26
|
+
/**
|
|
27
|
+
* Subject line template source
|
|
28
|
+
*/
|
|
8
29
|
subject: TemplateSource;
|
|
30
|
+
/**
|
|
31
|
+
* HTML content template source
|
|
32
|
+
*/
|
|
9
33
|
html: TemplateSource;
|
|
34
|
+
/**
|
|
35
|
+
* Plain text content template source (optional)
|
|
36
|
+
*/
|
|
10
37
|
text?: TemplateSource;
|
|
11
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Handlebars Template Engine Options
|
|
41
|
+
*/
|
|
12
42
|
export interface HandlebarsTemplateEngineOptions {
|
|
43
|
+
/**
|
|
44
|
+
* Base directory for resolving relative template paths
|
|
45
|
+
* @default process.cwd()
|
|
46
|
+
*/
|
|
13
47
|
baseDir?: string;
|
|
48
|
+
/**
|
|
49
|
+
* Whether to load built-in default templates
|
|
50
|
+
* @default true
|
|
51
|
+
*/
|
|
14
52
|
useDefaultTemplates?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Custom Handlebars helpers
|
|
55
|
+
*/
|
|
15
56
|
helpers?: Record<string, Handlebars.HelperDelegate>;
|
|
57
|
+
/**
|
|
58
|
+
* Handlebars compile options
|
|
59
|
+
*/
|
|
16
60
|
compileOptions?: CompileOptions;
|
|
17
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Handlebars Template Engine
|
|
64
|
+
*
|
|
65
|
+
* Powerful template engine using Handlebars.js for email templates.
|
|
66
|
+
* Supports:
|
|
67
|
+
* - File-based templates (.hbs files)
|
|
68
|
+
* - Inline string templates
|
|
69
|
+
* - Full Handlebars syntax (if/each/unless/with, etc.)
|
|
70
|
+
* - Custom helpers
|
|
71
|
+
* - Partials support
|
|
72
|
+
* - Built-in default templates
|
|
73
|
+
*
|
|
74
|
+
* Consumer apps can easily customize templates by:
|
|
75
|
+
* 1. Providing custom .hbs files
|
|
76
|
+
* 2. Providing HTML/text as strings
|
|
77
|
+
* 3. Using Handlebars helpers for complex logic
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* // Using default templates
|
|
82
|
+
* const engine = new HandlebarsTemplateEngine();
|
|
83
|
+
*
|
|
84
|
+
* // Using custom templates from files
|
|
85
|
+
* const engine = new HandlebarsTemplateEngine({
|
|
86
|
+
* baseDir: './my-templates',
|
|
87
|
+
* useDefaultTemplates: false
|
|
88
|
+
* });
|
|
89
|
+
*
|
|
90
|
+
* await engine.registerTemplateFromSources(TemplateType.WELCOME, {
|
|
91
|
+
* subject: { filePath: 'welcome.subject.hbs' },
|
|
92
|
+
* html: { filePath: 'welcome.html.hbs' },
|
|
93
|
+
* text: { filePath: 'welcome.text.hbs' }
|
|
94
|
+
* });
|
|
95
|
+
*
|
|
96
|
+
* // Using inline templates
|
|
97
|
+
* engine.registerTemplate(TemplateType.CUSTOM, {
|
|
98
|
+
* subject: 'Hello {{name}}',
|
|
99
|
+
* html: '<h1>Hello {{name}}</h1>',
|
|
100
|
+
* text: 'Hello {{name}}'
|
|
101
|
+
* });
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
18
104
|
export declare class HandlebarsTemplateEngine implements TemplateEngine {
|
|
105
|
+
/**
|
|
106
|
+
* Storage for compiled templates
|
|
107
|
+
* Maps template type to compiled Handlebars functions
|
|
108
|
+
*/
|
|
19
109
|
private templates;
|
|
110
|
+
/**
|
|
111
|
+
* Handlebars instance
|
|
112
|
+
*/
|
|
20
113
|
private readonly handlebars;
|
|
114
|
+
/**
|
|
115
|
+
* Base directory for template files
|
|
116
|
+
*/
|
|
21
117
|
private readonly baseDir;
|
|
118
|
+
/**
|
|
119
|
+
* Constructor
|
|
120
|
+
*
|
|
121
|
+
* @param options - Template engine configuration options
|
|
122
|
+
*/
|
|
22
123
|
constructor(options?: HandlebarsTemplateEngineOptions);
|
|
124
|
+
/**
|
|
125
|
+
* Render a template with variables
|
|
126
|
+
*
|
|
127
|
+
* @param type - Template type to render
|
|
128
|
+
* @param variables - Variables to inject
|
|
129
|
+
* @returns Rendered email template
|
|
130
|
+
* @throws {NAuthException} If template type not found
|
|
131
|
+
*/
|
|
23
132
|
render(type: TemplateType | string, variables: TemplateVariables): Promise<EmailTemplate>;
|
|
133
|
+
/**
|
|
134
|
+
* Register a custom template from inline strings
|
|
135
|
+
*
|
|
136
|
+
* @param type - Template type identifier
|
|
137
|
+
* @param template - Template definition with inline content
|
|
138
|
+
*/
|
|
24
139
|
registerTemplate(type: TemplateType | string, template: EmailTemplate): void;
|
|
140
|
+
/**
|
|
141
|
+
* Register a custom template from a single file
|
|
142
|
+
*
|
|
143
|
+
* Loads HTML template with frontmatter for subject.
|
|
144
|
+
* Format:
|
|
145
|
+
* ```
|
|
146
|
+
* ---
|
|
147
|
+
* subject: Email Subject {{variable}}
|
|
148
|
+
* ---
|
|
149
|
+
* <html>...</html>
|
|
150
|
+
* ```
|
|
151
|
+
*
|
|
152
|
+
* @param type - Template type identifier
|
|
153
|
+
* @param htmlFilePath - Path to HTML template file (relative to baseDir)
|
|
154
|
+
* @param textFilePath - Optional path to plain text template
|
|
155
|
+
*/
|
|
25
156
|
registerTemplateFromFile(type: TemplateType | string, htmlFilePath: string, textFilePath?: string): Promise<void>;
|
|
157
|
+
/**
|
|
158
|
+
* Register a custom template from mixed sources (strings or files)
|
|
159
|
+
*
|
|
160
|
+
* @param type - Template type identifier
|
|
161
|
+
* @param templateSources - Template sources (content or file paths)
|
|
162
|
+
*/
|
|
26
163
|
registerTemplateFromSources(type: TemplateType | string, templateSources: TemplateFiles): Promise<void>;
|
|
164
|
+
/**
|
|
165
|
+
* Get all available template types
|
|
166
|
+
*
|
|
167
|
+
* @returns Array of template type identifiers
|
|
168
|
+
*/
|
|
27
169
|
getAvailableTemplates(): string[];
|
|
170
|
+
/**
|
|
171
|
+
* Check if a template exists
|
|
172
|
+
*
|
|
173
|
+
* @param type - Template type to check
|
|
174
|
+
* @returns True if template is registered
|
|
175
|
+
*/
|
|
28
176
|
hasTemplate(type: TemplateType | string): boolean;
|
|
177
|
+
/**
|
|
178
|
+
* Parse frontmatter from template file
|
|
179
|
+
*
|
|
180
|
+
* Extracts YAML frontmatter (subject) from template HTML.
|
|
181
|
+
* Format:
|
|
182
|
+
* ```
|
|
183
|
+
* ---
|
|
184
|
+
* subject: Email Subject
|
|
185
|
+
* ---
|
|
186
|
+
* HTML content
|
|
187
|
+
* ```
|
|
188
|
+
*
|
|
189
|
+
* @param content - File content
|
|
190
|
+
* @returns Parsed subject and HTML
|
|
191
|
+
* @private
|
|
192
|
+
*/
|
|
29
193
|
private parseFrontmatter;
|
|
194
|
+
/**
|
|
195
|
+
* Load template content from source (file or inline content)
|
|
196
|
+
*
|
|
197
|
+
* @param source - Template source
|
|
198
|
+
* @returns Template content as string
|
|
199
|
+
* @private
|
|
200
|
+
*/
|
|
30
201
|
private loadTemplateSource;
|
|
202
|
+
/**
|
|
203
|
+
* Convert HTML to plain text
|
|
204
|
+
*
|
|
205
|
+
* Simple conversion: strips HTML tags and decodes entities.
|
|
206
|
+
*
|
|
207
|
+
* @param html - HTML content
|
|
208
|
+
* @returns Plain text
|
|
209
|
+
* @private
|
|
210
|
+
*/
|
|
31
211
|
private htmlToText;
|
|
212
|
+
/**
|
|
213
|
+
* Register default Handlebars helpers
|
|
214
|
+
*
|
|
215
|
+
* @private
|
|
216
|
+
*/
|
|
32
217
|
private registerDefaultHelpers;
|
|
218
|
+
/**
|
|
219
|
+
* Register default templates from built-in files
|
|
220
|
+
*
|
|
221
|
+
* Loads templates from the default templates directory.
|
|
222
|
+
* @private
|
|
223
|
+
*/
|
|
33
224
|
private registerDefaultTemplates;
|
|
34
225
|
}
|
|
35
226
|
//# sourceMappingURL=handlebars-template.engine.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handlebars-template.engine.d.ts","sourceRoot":"","sources":["../../src/templates/handlebars-template.engine.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,YAAY,EACZ,iBAAiB,EACjB,aAAa,EAGd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,UAAU,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"handlebars-template.engine.d.ts","sourceRoot":"","sources":["../../src/templates/handlebars-template.engine.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,YAAY,EACZ,iBAAiB,EACjB,aAAa,EAGd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,UAAU,MAAM,YAAY,CAAC;AAIzC;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,OAAO,EAAE,cAAc,CAAC;IAExB;;OAEG;IACH,IAAI,EAAE,cAAc,CAAC;IAErB;;OAEG;IACH,IAAI,CAAC,EAAE,cAAc,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,+BAA+B;IAC9C;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,cAAc,CAAC,CAAC;IAEpD;;OAEG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,qBAAa,wBAAyB,YAAW,cAAc;IAC7D;;;OAGG;IACH,OAAO,CAAC,SAAS,CAOH;IAEd;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAoB;IAE/C;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IAEjC;;;;OAIG;gBACS,OAAO,GAAE,+BAAoC;IAkBzD;;;;;;;OAOG;IACG,MAAM,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,EAAE,SAAS,EAAE,iBAAiB,GAAG,OAAO,CAAC,aAAa,CAAC;IAwB/F;;;;;OAKG;IACH,gBAAgB,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI;IAQ5E;;;;;;;;;;;;;;;OAeG;IACG,wBAAwB,CAC5B,IAAI,EAAE,YAAY,GAAG,MAAM,EAC3B,YAAY,EAAE,MAAM,EACpB,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,IAAI,CAAC;IA0BhB;;;;;OAKG;IACG,2BAA2B,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,EAAE,eAAe,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAY7G;;;;OAIG;IACH,qBAAqB,IAAI,MAAM,EAAE;IAIjC;;;;;OAKG;IACH,WAAW,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,GAAG,OAAO;IAIjD;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,gBAAgB;IA0BxB;;;;;;OAMG;YACW,kBAAkB;IAoBhC;;;;;;;;OAQG;IACH,OAAO,CAAC,UAAU;IAkBlB;;;;OAIG;IACH,OAAO,CAAC,sBAAsB;IA2C9B;;;;;OAKG;IACH,OAAO,CAAC,wBAAwB;CAqCjC"}
|
|
@@ -38,37 +38,112 @@ const core_1 = require("@nauth-toolkit/core");
|
|
|
38
38
|
const Handlebars = __importStar(require("handlebars"));
|
|
39
39
|
const fs_1 = require("fs");
|
|
40
40
|
const path_1 = require("path");
|
|
41
|
+
/**
|
|
42
|
+
* Handlebars Template Engine
|
|
43
|
+
*
|
|
44
|
+
* Powerful template engine using Handlebars.js for email templates.
|
|
45
|
+
* Supports:
|
|
46
|
+
* - File-based templates (.hbs files)
|
|
47
|
+
* - Inline string templates
|
|
48
|
+
* - Full Handlebars syntax (if/each/unless/with, etc.)
|
|
49
|
+
* - Custom helpers
|
|
50
|
+
* - Partials support
|
|
51
|
+
* - Built-in default templates
|
|
52
|
+
*
|
|
53
|
+
* Consumer apps can easily customize templates by:
|
|
54
|
+
* 1. Providing custom .hbs files
|
|
55
|
+
* 2. Providing HTML/text as strings
|
|
56
|
+
* 3. Using Handlebars helpers for complex logic
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* // Using default templates
|
|
61
|
+
* const engine = new HandlebarsTemplateEngine();
|
|
62
|
+
*
|
|
63
|
+
* // Using custom templates from files
|
|
64
|
+
* const engine = new HandlebarsTemplateEngine({
|
|
65
|
+
* baseDir: './my-templates',
|
|
66
|
+
* useDefaultTemplates: false
|
|
67
|
+
* });
|
|
68
|
+
*
|
|
69
|
+
* await engine.registerTemplateFromSources(TemplateType.WELCOME, {
|
|
70
|
+
* subject: { filePath: 'welcome.subject.hbs' },
|
|
71
|
+
* html: { filePath: 'welcome.html.hbs' },
|
|
72
|
+
* text: { filePath: 'welcome.text.hbs' }
|
|
73
|
+
* });
|
|
74
|
+
*
|
|
75
|
+
* // Using inline templates
|
|
76
|
+
* engine.registerTemplate(TemplateType.CUSTOM, {
|
|
77
|
+
* subject: 'Hello {{name}}',
|
|
78
|
+
* html: '<h1>Hello {{name}}</h1>',
|
|
79
|
+
* text: 'Hello {{name}}'
|
|
80
|
+
* });
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
41
83
|
class HandlebarsTemplateEngine {
|
|
84
|
+
/**
|
|
85
|
+
* Storage for compiled templates
|
|
86
|
+
* Maps template type to compiled Handlebars functions
|
|
87
|
+
*/
|
|
42
88
|
templates = new Map();
|
|
89
|
+
/**
|
|
90
|
+
* Handlebars instance
|
|
91
|
+
*/
|
|
43
92
|
handlebars;
|
|
93
|
+
/**
|
|
94
|
+
* Base directory for template files
|
|
95
|
+
*/
|
|
44
96
|
baseDir;
|
|
97
|
+
/**
|
|
98
|
+
* Constructor
|
|
99
|
+
*
|
|
100
|
+
* @param options - Template engine configuration options
|
|
101
|
+
*/
|
|
45
102
|
constructor(options = {}) {
|
|
46
103
|
this.baseDir = options.baseDir || process.cwd();
|
|
47
104
|
this.handlebars = Handlebars.create();
|
|
105
|
+
// Register custom helpers
|
|
48
106
|
this.registerDefaultHelpers();
|
|
49
107
|
if (options.helpers) {
|
|
50
108
|
Object.entries(options.helpers).forEach(([name, helper]) => {
|
|
51
109
|
this.handlebars.registerHelper(name, helper);
|
|
52
110
|
});
|
|
53
111
|
}
|
|
112
|
+
// Load default templates if enabled
|
|
54
113
|
if (options.useDefaultTemplates !== false) {
|
|
55
114
|
this.registerDefaultTemplates();
|
|
56
115
|
}
|
|
57
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* Render a template with variables
|
|
119
|
+
*
|
|
120
|
+
* @param type - Template type to render
|
|
121
|
+
* @param variables - Variables to inject
|
|
122
|
+
* @returns Rendered email template
|
|
123
|
+
* @throws {NAuthException} If template type not found
|
|
124
|
+
*/
|
|
58
125
|
async render(type, variables) {
|
|
59
126
|
const template = this.templates.get(type);
|
|
60
127
|
if (!template) {
|
|
61
128
|
throw new core_1.NAuthException(core_1.AuthErrorCode.INTERNAL_ERROR, `Template "${type}" not found. Available templates: ${Array.from(this.templates.keys()).join(', ')}`);
|
|
62
129
|
}
|
|
130
|
+
// Merge with default variables
|
|
63
131
|
const allVariables = {
|
|
64
132
|
currentYear: new Date().getFullYear(),
|
|
65
133
|
...variables,
|
|
66
134
|
};
|
|
135
|
+
// Render subject, HTML, and text
|
|
67
136
|
const subject = template.subject(allVariables);
|
|
68
137
|
const html = template.html(allVariables);
|
|
69
138
|
const text = template.text ? template.text(allVariables) : this.htmlToText(html);
|
|
70
139
|
return { subject, html, text };
|
|
71
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* Register a custom template from inline strings
|
|
143
|
+
*
|
|
144
|
+
* @param type - Template type identifier
|
|
145
|
+
* @param template - Template definition with inline content
|
|
146
|
+
*/
|
|
72
147
|
registerTemplate(type, template) {
|
|
73
148
|
this.templates.set(type, {
|
|
74
149
|
subject: this.handlebars.compile(template.subject),
|
|
@@ -76,6 +151,22 @@ class HandlebarsTemplateEngine {
|
|
|
76
151
|
text: template.text ? this.handlebars.compile(template.text) : undefined,
|
|
77
152
|
});
|
|
78
153
|
}
|
|
154
|
+
/**
|
|
155
|
+
* Register a custom template from a single file
|
|
156
|
+
*
|
|
157
|
+
* Loads HTML template with frontmatter for subject.
|
|
158
|
+
* Format:
|
|
159
|
+
* ```
|
|
160
|
+
* ---
|
|
161
|
+
* subject: Email Subject {{variable}}
|
|
162
|
+
* ---
|
|
163
|
+
* <html>...</html>
|
|
164
|
+
* ```
|
|
165
|
+
*
|
|
166
|
+
* @param type - Template type identifier
|
|
167
|
+
* @param htmlFilePath - Path to HTML template file (relative to baseDir)
|
|
168
|
+
* @param textFilePath - Optional path to plain text template
|
|
169
|
+
*/
|
|
79
170
|
async registerTemplateFromFile(type, htmlFilePath, textFilePath) {
|
|
80
171
|
const fullHtmlPath = (0, path_1.resolve)(this.baseDir, htmlFilePath);
|
|
81
172
|
try {
|
|
@@ -96,6 +187,12 @@ class HandlebarsTemplateEngine {
|
|
|
96
187
|
throw new core_1.NAuthException(core_1.AuthErrorCode.INTERNAL_ERROR, `Failed to load template file: ${fullHtmlPath}. Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
97
188
|
}
|
|
98
189
|
}
|
|
190
|
+
/**
|
|
191
|
+
* Register a custom template from mixed sources (strings or files)
|
|
192
|
+
*
|
|
193
|
+
* @param type - Template type identifier
|
|
194
|
+
* @param templateSources - Template sources (content or file paths)
|
|
195
|
+
*/
|
|
99
196
|
async registerTemplateFromSources(type, templateSources) {
|
|
100
197
|
const subject = await this.loadTemplateSource(templateSources.subject);
|
|
101
198
|
const html = await this.loadTemplateSource(templateSources.html);
|
|
@@ -106,12 +203,39 @@ class HandlebarsTemplateEngine {
|
|
|
106
203
|
text: text ? this.handlebars.compile(text) : undefined,
|
|
107
204
|
});
|
|
108
205
|
}
|
|
206
|
+
/**
|
|
207
|
+
* Get all available template types
|
|
208
|
+
*
|
|
209
|
+
* @returns Array of template type identifiers
|
|
210
|
+
*/
|
|
109
211
|
getAvailableTemplates() {
|
|
110
212
|
return Array.from(this.templates.keys());
|
|
111
213
|
}
|
|
214
|
+
/**
|
|
215
|
+
* Check if a template exists
|
|
216
|
+
*
|
|
217
|
+
* @param type - Template type to check
|
|
218
|
+
* @returns True if template is registered
|
|
219
|
+
*/
|
|
112
220
|
hasTemplate(type) {
|
|
113
221
|
return this.templates.has(type);
|
|
114
222
|
}
|
|
223
|
+
/**
|
|
224
|
+
* Parse frontmatter from template file
|
|
225
|
+
*
|
|
226
|
+
* Extracts YAML frontmatter (subject) from template HTML.
|
|
227
|
+
* Format:
|
|
228
|
+
* ```
|
|
229
|
+
* ---
|
|
230
|
+
* subject: Email Subject
|
|
231
|
+
* ---
|
|
232
|
+
* HTML content
|
|
233
|
+
* ```
|
|
234
|
+
*
|
|
235
|
+
* @param content - File content
|
|
236
|
+
* @returns Parsed subject and HTML
|
|
237
|
+
* @private
|
|
238
|
+
*/
|
|
115
239
|
parseFrontmatter(content) {
|
|
116
240
|
const frontmatterRegex = /^---\s*\n([\s\S]*?)\n---\s*\n([\s\S]*)$/;
|
|
117
241
|
const match = content.match(frontmatterRegex);
|
|
@@ -120,6 +244,7 @@ class HandlebarsTemplateEngine {
|
|
|
120
244
|
}
|
|
121
245
|
const frontmatter = match[1];
|
|
122
246
|
const html = match[2];
|
|
247
|
+
// Simple YAML parsing for subject line
|
|
123
248
|
const subjectMatch = frontmatter.match(/subject:\s*(.+)/);
|
|
124
249
|
if (!subjectMatch) {
|
|
125
250
|
throw new core_1.NAuthException(core_1.AuthErrorCode.INTERNAL_ERROR, 'Template frontmatter must include "subject" field');
|
|
@@ -129,6 +254,13 @@ class HandlebarsTemplateEngine {
|
|
|
129
254
|
html: html.trim(),
|
|
130
255
|
};
|
|
131
256
|
}
|
|
257
|
+
/**
|
|
258
|
+
* Load template content from source (file or inline content)
|
|
259
|
+
*
|
|
260
|
+
* @param source - Template source
|
|
261
|
+
* @returns Template content as string
|
|
262
|
+
* @private
|
|
263
|
+
*/
|
|
132
264
|
async loadTemplateSource(source) {
|
|
133
265
|
if (source.content) {
|
|
134
266
|
return source.content;
|
|
@@ -144,38 +276,64 @@ class HandlebarsTemplateEngine {
|
|
|
144
276
|
}
|
|
145
277
|
throw new core_1.NAuthException(core_1.AuthErrorCode.INTERNAL_ERROR, 'Template source must have either content or filePath');
|
|
146
278
|
}
|
|
279
|
+
/**
|
|
280
|
+
* Convert HTML to plain text
|
|
281
|
+
*
|
|
282
|
+
* Simple conversion: strips HTML tags and decodes entities.
|
|
283
|
+
*
|
|
284
|
+
* @param html - HTML content
|
|
285
|
+
* @returns Plain text
|
|
286
|
+
* @private
|
|
287
|
+
*/
|
|
147
288
|
htmlToText(html) {
|
|
289
|
+
// Strip HTML tags
|
|
148
290
|
let text = html.replace(/<[^>]*>/g, '');
|
|
291
|
+
// Decode common HTML entities
|
|
149
292
|
text = text.replace(/ /g, ' ');
|
|
150
293
|
text = text.replace(/</g, '<');
|
|
151
294
|
text = text.replace(/>/g, '>');
|
|
152
295
|
text = text.replace(/"/g, '"');
|
|
153
296
|
text = text.replace(/'/g, "'");
|
|
154
297
|
text = text.replace(/&/g, '&');
|
|
298
|
+
// Normalize whitespace
|
|
155
299
|
text = text.replace(/\s+/g, ' ').trim();
|
|
156
300
|
return text;
|
|
157
301
|
}
|
|
302
|
+
/**
|
|
303
|
+
* Register default Handlebars helpers
|
|
304
|
+
*
|
|
305
|
+
* @private
|
|
306
|
+
*/
|
|
158
307
|
registerDefaultHelpers() {
|
|
308
|
+
// Equality helper
|
|
159
309
|
this.handlebars.registerHelper('eq', function (a, b) {
|
|
160
310
|
return a === b;
|
|
161
311
|
});
|
|
312
|
+
// Not equal helper
|
|
162
313
|
this.handlebars.registerHelper('ne', function (a, b) {
|
|
163
314
|
return a !== b;
|
|
164
315
|
});
|
|
316
|
+
// Greater than helper
|
|
165
317
|
this.handlebars.registerHelper('gt', function (a, b) {
|
|
166
318
|
return a > b;
|
|
167
319
|
});
|
|
320
|
+
// Less than helper
|
|
168
321
|
this.handlebars.registerHelper('lt', function (a, b) {
|
|
169
322
|
return a < b;
|
|
170
323
|
});
|
|
324
|
+
// And helper
|
|
171
325
|
this.handlebars.registerHelper('and', function (...args) {
|
|
326
|
+
// Remove Handlebars options object from end
|
|
172
327
|
const values = args.slice(0, -1);
|
|
173
328
|
return values.every((v) => !!v);
|
|
174
329
|
});
|
|
330
|
+
// Or helper
|
|
175
331
|
this.handlebars.registerHelper('or', function (...args) {
|
|
332
|
+
// Remove Handlebars options object from end
|
|
176
333
|
const values = args.slice(0, -1);
|
|
177
334
|
return values.some((v) => !!v);
|
|
178
335
|
});
|
|
336
|
+
// Format date helper
|
|
179
337
|
this.handlebars.registerHelper('formatDate', function (date) {
|
|
180
338
|
if (!date)
|
|
181
339
|
return '';
|
|
@@ -183,8 +341,15 @@ class HandlebarsTemplateEngine {
|
|
|
183
341
|
return d.toLocaleDateString();
|
|
184
342
|
});
|
|
185
343
|
}
|
|
344
|
+
/**
|
|
345
|
+
* Register default templates from built-in files
|
|
346
|
+
*
|
|
347
|
+
* Loads templates from the default templates directory.
|
|
348
|
+
* @private
|
|
349
|
+
*/
|
|
186
350
|
registerDefaultTemplates() {
|
|
187
351
|
const defaultTemplatesDir = (0, path_1.join)(__dirname, 'default');
|
|
352
|
+
// Template type to file name mapping (using kebab-case for files)
|
|
188
353
|
const templateFileMapping = {
|
|
189
354
|
[core_1.TemplateType.VERIFICATION]: 'verification',
|
|
190
355
|
[core_1.TemplateType.PASSWORD_RESET]: 'password-reset',
|
|
@@ -195,6 +360,7 @@ class HandlebarsTemplateEngine {
|
|
|
195
360
|
[core_1.TemplateType.EMAIL_CHANGED]: 'email-changed',
|
|
196
361
|
[core_1.TemplateType.MFA_ENABLED]: 'mfa-enabled',
|
|
197
362
|
};
|
|
363
|
+
// Register all default templates
|
|
198
364
|
Object.entries(templateFileMapping).forEach(([templateType, fileName]) => {
|
|
199
365
|
try {
|
|
200
366
|
const htmlPath = (0, path_1.join)(defaultTemplatesDir, `${fileName}.html.hbs`);
|
|
@@ -209,6 +375,8 @@ class HandlebarsTemplateEngine {
|
|
|
209
375
|
});
|
|
210
376
|
}
|
|
211
377
|
catch (error) {
|
|
378
|
+
// If default templates are missing, just skip them
|
|
379
|
+
// This allows the package to work even if templates are not bundled
|
|
212
380
|
console.warn(`Warning: Could not load default template for ${templateType}:`, error);
|
|
213
381
|
}
|
|
214
382
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handlebars-template.engine.js","sourceRoot":"","sources":["../../src/templates/handlebars-template.engine.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAO6B;AAC7B,uDAAyC;AACzC,2BAAkC;AAClC,+BAAqC;
|
|
1
|
+
{"version":3,"file":"handlebars-template.engine.js","sourceRoot":"","sources":["../../src/templates/handlebars-template.engine.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAO6B;AAC7B,uDAAyC;AACzC,2BAAkC;AAClC,+BAAqC;AAsErC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,MAAa,wBAAwB;IACnC;;;OAGG;IACK,SAAS,GAOb,IAAI,GAAG,EAAE,CAAC;IAEd;;OAEG;IACc,UAAU,CAAoB;IAE/C;;OAEG;IACc,OAAO,CAAS;IAEjC;;;;OAIG;IACH,YAAY,UAA2C,EAAE;QACvD,IAAI,CAAC,OAAO,GA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AC,CAAC;gBAEnE,MAAM,WAAW,GAAG,IAAA,iBAAY,EAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;gBACpD,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;gBAC7D,MAAM,IAAI,GAAG,IAAA,iBAAY,EAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;gBAE7C,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,YAAY,EAAE;oBAC/B,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC;oBACzC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC;oBACnC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC;iBACpC,CAAC,CAAC;YACL,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,mDAAmD;gBACnD,oEAAoE;gBACpE,OAAO,CAAC,IAAI,CAAC,gDAAgD,YAAY,GAAG,EAAE,KAAK,CAAC,CAAC;YACvF,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA3WD,4DA2WC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/templates/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/templates/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,8BAA8B,CAAC"}
|
package/dist/templates/index.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Email Template System Exports
|
|
4
|
+
*
|
|
5
|
+
* Provides template engines and utilities for email notifications.
|
|
6
|
+
*/
|
|
2
7
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
8
|
if (k2 === undefined) k2 = k;
|
|
4
9
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/templates/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/templates/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;AAEH,+DAA6C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nauth-toolkit/email-nodemailer",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.18",
|
|
4
4
|
"description": "Nodemailer email provider for nauth-toolkit",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -23,16 +23,16 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"handlebars": "^4.7.8",
|
|
26
|
-
"nodemailer": "^
|
|
26
|
+
"nodemailer": "^7.0.11"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"@nauth-toolkit/core": "^0.1.
|
|
29
|
+
"@nauth-toolkit/core": "^0.1.18"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/handlebars": "^4.1.0",
|
|
33
33
|
"@types/mjml": "^4.7.4",
|
|
34
34
|
"@types/node": "^22.0.0",
|
|
35
|
-
"@types/nodemailer": "^
|
|
35
|
+
"@types/nodemailer": "^7.0.4",
|
|
36
36
|
"mjml": "^4.17.1",
|
|
37
37
|
"typescript": "^5.5.0"
|
|
38
38
|
},
|