@strapi/provider-email-nodemailer 5.61.1 → 5.62.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.
@@ -0,0 +1,393 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * RFC-compliant Email Address Utilities for Nodemailer Provider
5
+ *
6
+ * Provides utilities for parsing and formatting email addresses
7
+ * according to RFC 5322, RFC 2047, and related standards.
8
+ *
9
+ * @module @strapi/provider-email-nodemailer/utils
10
+ */ /**
11
+ * Normalizes an email address to lowercase.
12
+ *
13
+ * Per RFC 5321 section 2.4, the domain part of an email address is
14
+ * case-insensitive. While the local part is technically case-sensitive,
15
+ * in practice virtually all mail systems treat it as case-insensitive.
16
+ * Major providers (Gmail, Outlook, Yahoo, etc.) all normalize to lowercase.
17
+ *
18
+ * @see https://datatracker.ietf.org/doc/html/rfc5321#section-2.4
19
+ */ const normalizeEmail = (email)=>{
20
+ if (!email) return email;
21
+ return email.toLowerCase();
22
+ };
23
+ /**
24
+ * Decodes RFC 2047 encoded-words
25
+ * Supports both Base64 (B) and Quoted-Printable (Q) encodings
26
+ *
27
+ * @example
28
+ * decodeRfc2047('=?UTF-8?B?U3RyYXBp?=')
29
+ * // 'Strapi'
30
+ *
31
+ * @example
32
+ * decodeRfc2047('=?UTF-8?Q?M=C3=BCller?=')
33
+ * // 'Müller'
34
+ *
35
+ * @see https://datatracker.ietf.org/doc/html/rfc2047
36
+ */ const decodeRfc2047 = (encoded)=>{
37
+ const rfc2047Pattern = /=\?([^?]+)\?([BbQq])\?([^?]*)\?=/g;
38
+ return encoded.replace(rfc2047Pattern, (match, charset, encoding, text)=>{
39
+ try {
40
+ const upperEncoding = encoding.toUpperCase();
41
+ // RFC 2231 allows a language suffix, e.g. "UTF-8*en"
42
+ const decoder = new TextDecoder(charset.split('*')[0]);
43
+ if (upperEncoding === 'B') {
44
+ return decoder.decode(Buffer.from(text, 'base64'));
45
+ }
46
+ if (upperEncoding === 'Q') {
47
+ const withSpaces = text.replace(/_/g, ' ');
48
+ const decoded = withSpaces.replace(/=([0-9A-Fa-f]{2})/g, (_, hex)=>String.fromCharCode(parseInt(hex, 16)));
49
+ const bytes = Buffer.from(decoded, 'binary');
50
+ return decoder.decode(bytes);
51
+ }
52
+ return match;
53
+ } catch {
54
+ return match;
55
+ }
56
+ });
57
+ };
58
+ /**
59
+ * Encodes a string as RFC 2047 Base64 encoded-word
60
+ * Use this when the display name contains non-ASCII characters
61
+ *
62
+ * @example
63
+ * encodeRfc2047Base64('Müller')
64
+ * // '=?UTF-8?B?TcO8bGxlcg==?='
65
+ *
66
+ * @see https://datatracker.ietf.org/doc/html/rfc2047
67
+ */ const encodeRfc2047Base64 = (str)=>{
68
+ // eslint-disable-next-line no-control-regex
69
+ if (!/[^\x00-\x7F]/.test(str)) {
70
+ return str;
71
+ }
72
+ const bytes = Buffer.from(str, 'utf-8');
73
+ // RFC 2047 Section 2: encoded-word max 75 chars total
74
+ // =?UTF-8?B?...?= overhead is 12 chars, leaving 63 for base64 payload
75
+ // 63 base64 chars encode 47 bytes (floor(63 * 3 / 4) = 47)
76
+ const maxBytesPerChunk = 45; // conservative (produces 60 base64 chars = 72 total)
77
+ if (bytes.length <= maxBytesPerChunk) {
78
+ return `=?UTF-8?B?${bytes.toString('base64')}?=`;
79
+ }
80
+ const parts = [];
81
+ let offset = 0;
82
+ while(offset < bytes.length){
83
+ let chunkEnd = Math.min(offset + maxBytesPerChunk, bytes.length);
84
+ // Avoid splitting in the middle of a multi-byte UTF-8 character
85
+ // UTF-8 continuation bytes start with 10xxxxxx (0x80-0xBF)
86
+ while(chunkEnd < bytes.length && bytes[chunkEnd] >= 0x80 && bytes[chunkEnd] < 0xc0){
87
+ chunkEnd -= 1;
88
+ }
89
+ const chunk = bytes.subarray(offset, chunkEnd);
90
+ parts.push(`=?UTF-8?B?${chunk.toString('base64')}?=`);
91
+ offset = chunkEnd;
92
+ }
93
+ return parts.join(' ');
94
+ };
95
+ /**
96
+ * Encodes a string as RFC 2047 Quoted-Printable encoded-word
97
+ *
98
+ * @example
99
+ * encodeRfc2047QuotedPrintable('Müller')
100
+ * // '=?UTF-8?Q?M=C3=BCller?='
101
+ */ const encodeRfc2047QuotedPrintable = (str)=>{
102
+ // Check if encoding is needed
103
+ // eslint-disable-next-line no-control-regex
104
+ if (!/[^\x00-\x7F]/.test(str)) {
105
+ return str;
106
+ }
107
+ const bytes = Buffer.from(str, 'utf-8');
108
+ let result = '';
109
+ for (const byte of bytes){
110
+ // Printable ASCII (except = ? _ and space)
111
+ if (byte >= 33 && byte <= 126 && byte !== 61 && byte !== 63 && byte !== 95 || byte === 32) {
112
+ result += byte === 32 ? '_' : String.fromCharCode(byte);
113
+ } else {
114
+ result += `=${byte.toString(16).toUpperCase().padStart(2, '0')}`;
115
+ }
116
+ }
117
+ return `=?UTF-8?Q?${result}?=`;
118
+ };
119
+ /**
120
+ * Extracts RFC 5322 comments from an email string
121
+ * Comments are enclosed in parentheses
122
+ *
123
+ * @example
124
+ * extractComments('email@example.com (Support Team)')
125
+ * // { text: 'email@example.com', comments: ['Support Team'] }
126
+ */ const extractComments = (str)=>{
127
+ const comments = [];
128
+ let result = '';
129
+ let depth = 0;
130
+ let currentComment = '';
131
+ let inQuotes = false;
132
+ let escape = false;
133
+ for (const char of str){
134
+ if (escape) {
135
+ if (depth > 0) {
136
+ currentComment += char;
137
+ } else {
138
+ result += char;
139
+ }
140
+ escape = false;
141
+ } else if (char === '\\') {
142
+ escape = true;
143
+ if (depth > 0) {
144
+ currentComment += char;
145
+ } else {
146
+ result += char;
147
+ }
148
+ } else if (char === '"' && depth === 0) {
149
+ inQuotes = !inQuotes;
150
+ result += char;
151
+ } else if (!inQuotes && char === '(') {
152
+ if (depth === 0) {
153
+ currentComment = '';
154
+ } else {
155
+ currentComment += char;
156
+ }
157
+ depth += 1;
158
+ } else if (!inQuotes && char === ')') {
159
+ if (depth <= 0) {
160
+ result += char;
161
+ } else {
162
+ depth -= 1;
163
+ if (depth === 0) {
164
+ comments.push(currentComment.trim());
165
+ currentComment = '';
166
+ } else {
167
+ currentComment += char;
168
+ }
169
+ }
170
+ } else if (depth > 0) {
171
+ currentComment += char;
172
+ } else {
173
+ result += char;
174
+ }
175
+ }
176
+ return {
177
+ text: result.trim(),
178
+ comments
179
+ };
180
+ };
181
+ /**
182
+ * Unquotes a RFC 5322 quoted string
183
+ *
184
+ * @example
185
+ * unquoteString('"Doe, John"')
186
+ * // 'Doe, John'
187
+ */ const unquoteString = (str)=>{
188
+ const trimmed = str.trim();
189
+ if (!trimmed.startsWith('"') || !trimmed.endsWith('"')) {
190
+ return trimmed;
191
+ }
192
+ const inner = trimmed.slice(1, -1);
193
+ let result = '';
194
+ let escape = false;
195
+ for (const char of inner){
196
+ if (escape) {
197
+ result += char;
198
+ escape = false;
199
+ } else if (char === '\\') {
200
+ escape = true;
201
+ } else {
202
+ result += char;
203
+ }
204
+ }
205
+ return result;
206
+ };
207
+ /**
208
+ * Parses an email address string according to RFC 5322
209
+ *
210
+ * Supported formats:
211
+ * - Simple: "email@example.com"
212
+ * - With name: "Name <email@example.com>"
213
+ * - Quoted name: "\"Doe, John\" <email@example.com>"
214
+ * - RFC 2047 encoded: "=?UTF-8?B?...?= <email@example.com>"
215
+ * - With comment: "email@example.com (Display Name)"
216
+ *
217
+ * @example
218
+ * parseEmailAddress('Strapi <no-reply@strapi.io>')
219
+ * // { name: 'Strapi', email: 'no-reply@strapi.io', original: '...' }
220
+ *
221
+ * @example
222
+ * parseEmailAddress('=?UTF-8?B?U3RyYXBp?= <no-reply@strapi.io>')
223
+ * // { name: 'Strapi', email: 'no-reply@strapi.io', original: '...' }
224
+ */ const parseEmailAddress = (emailString)=>{
225
+ if (!emailString || typeof emailString !== 'string') {
226
+ return {
227
+ name: null,
228
+ email: '',
229
+ original: emailString || ''
230
+ };
231
+ }
232
+ const original = emailString;
233
+ // Step 1: Decode RFC 2047 encoded-words
234
+ let decoded = decodeRfc2047(emailString);
235
+ // Step 2: Extract comments
236
+ const { text: withoutComments, comments } = extractComments(decoded);
237
+ decoded = withoutComments;
238
+ // Step 3: Parse "Name <email>" format
239
+ const angleMatch = decoded.match(/^(.*?)\s*<([^>]+)>\s*$/);
240
+ if (angleMatch) {
241
+ let name = angleMatch[1].trim();
242
+ const email = normalizeEmail(angleMatch[2].trim());
243
+ if (name) {
244
+ name = unquoteString(name);
245
+ name = decodeRfc2047(name);
246
+ }
247
+ if (!name && comments.length > 0) {
248
+ name = comments[0];
249
+ }
250
+ return {
251
+ name: name || null,
252
+ email,
253
+ original
254
+ };
255
+ }
256
+ // Step 4: Handle "email (comment)" format
257
+ const trimmedDecoded = decoded.trim();
258
+ if (trimmedDecoded.includes('@')) {
259
+ return {
260
+ name: comments.length > 0 ? comments[0] : null,
261
+ email: normalizeEmail(trimmedDecoded),
262
+ original
263
+ };
264
+ }
265
+ return {
266
+ name: null,
267
+ email: trimmedDecoded,
268
+ original
269
+ };
270
+ };
271
+ /**
272
+ * Formats an email address according to RFC 5322
273
+ *
274
+ * Automatically quotes names containing special characters
275
+ * and encodes non-ASCII characters using RFC 2047.
276
+ *
277
+ * @example
278
+ * formatEmailAddress('Strapi', 'no-reply@strapi.io')
279
+ * // 'Strapi <no-reply@strapi.io>'
280
+ *
281
+ * @example
282
+ * formatEmailAddress('Doe, John', 'john@example.com')
283
+ * // '"Doe, John" <john@example.com>'
284
+ *
285
+ * @example
286
+ * formatEmailAddress('Müller', 'mueller@example.com')
287
+ * // '=?UTF-8?B?TcO8bGxlcg==?= <mueller@example.com>'
288
+ */ const formatEmailAddress = (name, email, options = {})=>{
289
+ const { encodeNonAscii = true } = options;
290
+ const normalizedEmail = normalizeEmail(email);
291
+ if (!name) {
292
+ return normalizedEmail;
293
+ }
294
+ let formattedName = name;
295
+ // Check for non-ASCII characters and encode if needed
296
+ // eslint-disable-next-line no-control-regex
297
+ if (encodeNonAscii && /[^\x00-\x7F]/.test(name)) {
298
+ formattedName = encodeRfc2047Base64(name);
299
+ return `${formattedName} <${normalizedEmail}>`;
300
+ }
301
+ // Check if name needs quoting (special characters)
302
+ const needsQuoting = /[()<>@,;:\\".[\]]/.test(formattedName);
303
+ if (needsQuoting && !formattedName.startsWith('"')) {
304
+ const escaped = formattedName.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
305
+ return `"${escaped}" <${normalizedEmail}>`;
306
+ }
307
+ return `${formattedName} <${normalizedEmail}>`;
308
+ };
309
+ /**
310
+ * Validates an email address according to RFC 5322
311
+ *
312
+ * @example
313
+ * isValidEmail('user@example.com')
314
+ * // true
315
+ *
316
+ * @example
317
+ * isValidEmail('invalid')
318
+ * // false
319
+ */ const isValidEmail = (email)=>{
320
+ if (!email || typeof email !== 'string') {
321
+ return false;
322
+ }
323
+ // RFC 5321 length limits: local max 64, domain max 255, total max 320
324
+ const atIndex = email.indexOf('@');
325
+ if (atIndex < 1 || atIndex > 64) return false;
326
+ const domain = email.slice(atIndex + 1);
327
+ if (domain.length === 0 || domain.length > 255) return false;
328
+ if (email.length > 320) return false;
329
+ // No leading/trailing/consecutive dots in the local part (RFC 5321)
330
+ const local = email.slice(0, atIndex);
331
+ if (local.startsWith('.') || local.endsWith('.') || local.includes('..')) return false;
332
+ const emailPattern = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~\u0080-\uFFFF-]+@[a-zA-Z0-9\u0080-\uFFFF](?:[a-zA-Z0-9\u0080-\uFFFF-]{0,61}[a-zA-Z0-9\u0080-\uFFFF])?(?:\.[a-zA-Z0-9\u0080-\uFFFF](?:[a-zA-Z0-9\u0080-\uFFFF-]{0,61}[a-zA-Z0-9\u0080-\uFFFF])?)*$/;
333
+ return emailPattern.test(email);
334
+ };
335
+ /**
336
+ * Parses multiple comma-separated email addresses
337
+ *
338
+ * @example
339
+ * parseMultipleEmailAddresses('a@example.com, "Doe, John" <b@example.com>')
340
+ * // [{ name: null, email: 'a@example.com' }, { name: 'Doe, John', email: 'b@example.com' }]
341
+ */ const parseMultipleEmailAddresses = (emailsString)=>{
342
+ if (!emailsString || typeof emailsString !== 'string') {
343
+ return [];
344
+ }
345
+ const addresses = [];
346
+ let current = '';
347
+ let inQuotes = false;
348
+ let depth = 0;
349
+ let escaped = false;
350
+ for (const char of emailsString){
351
+ if (escaped) {
352
+ current += char;
353
+ escaped = false;
354
+ } else if (char === '\\') {
355
+ escaped = true;
356
+ current += char;
357
+ } else if (char === '"') {
358
+ inQuotes = !inQuotes;
359
+ current += char;
360
+ } else if (!inQuotes && (char === '<' || char === '(')) {
361
+ depth += 1;
362
+ current += char;
363
+ } else if (!inQuotes && (char === '>' || char === ')')) {
364
+ depth -= 1;
365
+ current += char;
366
+ } else if (!inQuotes && char === ',' && depth === 0) {
367
+ const trimmed = current.trim();
368
+ if (trimmed) {
369
+ addresses.push(trimmed);
370
+ }
371
+ current = '';
372
+ } else {
373
+ current += char;
374
+ }
375
+ }
376
+ const trimmed = current.trim();
377
+ if (trimmed) {
378
+ addresses.push(trimmed);
379
+ }
380
+ return addresses.map(parseEmailAddress);
381
+ };
382
+
383
+ exports.decodeRfc2047 = decodeRfc2047;
384
+ exports.encodeRfc2047Base64 = encodeRfc2047Base64;
385
+ exports.encodeRfc2047QuotedPrintable = encodeRfc2047QuotedPrintable;
386
+ exports.extractComments = extractComments;
387
+ exports.formatEmailAddress = formatEmailAddress;
388
+ exports.isValidEmail = isValidEmail;
389
+ exports.normalizeEmail = normalizeEmail;
390
+ exports.parseEmailAddress = parseEmailAddress;
391
+ exports.parseMultipleEmailAddresses = parseMultipleEmailAddresses;
392
+ exports.unquoteString = unquoteString;
393
+ //# sourceMappingURL=email-address.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"email-address.js","sources":["../../src/utils/email-address.ts"],"sourcesContent":["/**\n * RFC-compliant Email Address Utilities for Nodemailer Provider\n *\n * Provides utilities for parsing and formatting email addresses\n * according to RFC 5322, RFC 2047, and related standards.\n *\n * @module @strapi/provider-email-nodemailer/utils\n */\n\nexport interface ParsedEmailAddress {\n /** Display name (decoded if RFC 2047 encoded) */\n name: string | null;\n /** Email address (normalized to lowercase per RFC 5321) */\n email: string;\n /** Original unparsed string */\n original: string;\n}\n\n/**\n * Normalizes an email address to lowercase.\n *\n * Per RFC 5321 section 2.4, the domain part of an email address is\n * case-insensitive. While the local part is technically case-sensitive,\n * in practice virtually all mail systems treat it as case-insensitive.\n * Major providers (Gmail, Outlook, Yahoo, etc.) all normalize to lowercase.\n *\n * @see https://datatracker.ietf.org/doc/html/rfc5321#section-2.4\n */\nexport const normalizeEmail = (email: string): string => {\n if (!email) return email;\n return email.toLowerCase();\n};\n\n/**\n * Decodes RFC 2047 encoded-words\n * Supports both Base64 (B) and Quoted-Printable (Q) encodings\n *\n * @example\n * decodeRfc2047('=?UTF-8?B?U3RyYXBp?=')\n * // 'Strapi'\n *\n * @example\n * decodeRfc2047('=?UTF-8?Q?M=C3=BCller?=')\n * // 'Müller'\n *\n * @see https://datatracker.ietf.org/doc/html/rfc2047\n */\nexport const decodeRfc2047 = (encoded: string): string => {\n const rfc2047Pattern = /=\\?([^?]+)\\?([BbQq])\\?([^?]*)\\?=/g;\n\n return encoded.replace(rfc2047Pattern, (match, charset, encoding, text) => {\n try {\n const upperEncoding = encoding.toUpperCase();\n // RFC 2231 allows a language suffix, e.g. \"UTF-8*en\"\n const decoder = new TextDecoder(charset.split('*')[0]);\n\n if (upperEncoding === 'B') {\n return decoder.decode(Buffer.from(text, 'base64'));\n }\n\n if (upperEncoding === 'Q') {\n const withSpaces = text.replace(/_/g, ' ');\n const decoded = withSpaces.replace(/=([0-9A-Fa-f]{2})/g, (_: string, hex: string) =>\n String.fromCharCode(parseInt(hex, 16))\n );\n const bytes = Buffer.from(decoded, 'binary');\n return decoder.decode(bytes);\n }\n\n return match;\n } catch {\n return match;\n }\n });\n};\n\n/**\n * Encodes a string as RFC 2047 Base64 encoded-word\n * Use this when the display name contains non-ASCII characters\n *\n * @example\n * encodeRfc2047Base64('Müller')\n * // '=?UTF-8?B?TcO8bGxlcg==?='\n *\n * @see https://datatracker.ietf.org/doc/html/rfc2047\n */\nexport const encodeRfc2047Base64 = (str: string): string => {\n // eslint-disable-next-line no-control-regex\n if (!/[^\\x00-\\x7F]/.test(str)) {\n return str;\n }\n\n const bytes = Buffer.from(str, 'utf-8');\n // RFC 2047 Section 2: encoded-word max 75 chars total\n // =?UTF-8?B?...?= overhead is 12 chars, leaving 63 for base64 payload\n // 63 base64 chars encode 47 bytes (floor(63 * 3 / 4) = 47)\n const maxBytesPerChunk = 45; // conservative (produces 60 base64 chars = 72 total)\n\n if (bytes.length <= maxBytesPerChunk) {\n return `=?UTF-8?B?${bytes.toString('base64')}?=`;\n }\n\n const parts: string[] = [];\n let offset = 0;\n\n while (offset < bytes.length) {\n let chunkEnd = Math.min(offset + maxBytesPerChunk, bytes.length);\n\n // Avoid splitting in the middle of a multi-byte UTF-8 character\n // UTF-8 continuation bytes start with 10xxxxxx (0x80-0xBF)\n while (chunkEnd < bytes.length && bytes[chunkEnd] >= 0x80 && bytes[chunkEnd] < 0xc0) {\n chunkEnd -= 1;\n }\n\n const chunk = bytes.subarray(offset, chunkEnd);\n parts.push(`=?UTF-8?B?${chunk.toString('base64')}?=`);\n offset = chunkEnd;\n }\n\n return parts.join(' ');\n};\n\n/**\n * Encodes a string as RFC 2047 Quoted-Printable encoded-word\n *\n * @example\n * encodeRfc2047QuotedPrintable('Müller')\n * // '=?UTF-8?Q?M=C3=BCller?='\n */\nexport const encodeRfc2047QuotedPrintable = (str: string): string => {\n // Check if encoding is needed\n // eslint-disable-next-line no-control-regex\n if (!/[^\\x00-\\x7F]/.test(str)) {\n return str;\n }\n\n const bytes = Buffer.from(str, 'utf-8');\n let result = '';\n\n for (const byte of bytes) {\n // Printable ASCII (except = ? _ and space)\n if ((byte >= 33 && byte <= 126 && byte !== 61 && byte !== 63 && byte !== 95) || byte === 32) {\n result += byte === 32 ? '_' : String.fromCharCode(byte);\n } else {\n result += `=${byte.toString(16).toUpperCase().padStart(2, '0')}`;\n }\n }\n\n return `=?UTF-8?Q?${result}?=`;\n};\n\n/**\n * Extracts RFC 5322 comments from an email string\n * Comments are enclosed in parentheses\n *\n * @example\n * extractComments('email@example.com (Support Team)')\n * // { text: 'email@example.com', comments: ['Support Team'] }\n */\nexport const extractComments = (str: string): { text: string; comments: string[] } => {\n const comments: string[] = [];\n let result = '';\n let depth = 0;\n let currentComment = '';\n let inQuotes = false;\n let escape = false;\n\n for (const char of str) {\n if (escape) {\n if (depth > 0) {\n currentComment += char;\n } else {\n result += char;\n }\n escape = false;\n } else if (char === '\\\\') {\n escape = true;\n if (depth > 0) {\n currentComment += char;\n } else {\n result += char;\n }\n } else if (char === '\"' && depth === 0) {\n inQuotes = !inQuotes;\n result += char;\n } else if (!inQuotes && char === '(') {\n if (depth === 0) {\n currentComment = '';\n } else {\n currentComment += char;\n }\n depth += 1;\n } else if (!inQuotes && char === ')') {\n if (depth <= 0) {\n result += char;\n } else {\n depth -= 1;\n if (depth === 0) {\n comments.push(currentComment.trim());\n currentComment = '';\n } else {\n currentComment += char;\n }\n }\n } else if (depth > 0) {\n currentComment += char;\n } else {\n result += char;\n }\n }\n\n return { text: result.trim(), comments };\n};\n\n/**\n * Unquotes a RFC 5322 quoted string\n *\n * @example\n * unquoteString('\"Doe, John\"')\n * // 'Doe, John'\n */\nexport const unquoteString = (str: string): string => {\n const trimmed = str.trim();\n\n if (!trimmed.startsWith('\"') || !trimmed.endsWith('\"')) {\n return trimmed;\n }\n\n const inner = trimmed.slice(1, -1);\n let result = '';\n let escape = false;\n\n for (const char of inner) {\n if (escape) {\n result += char;\n escape = false;\n } else if (char === '\\\\') {\n escape = true;\n } else {\n result += char;\n }\n }\n\n return result;\n};\n\n/**\n * Parses an email address string according to RFC 5322\n *\n * Supported formats:\n * - Simple: \"email@example.com\"\n * - With name: \"Name <email@example.com>\"\n * - Quoted name: \"\\\"Doe, John\\\" <email@example.com>\"\n * - RFC 2047 encoded: \"=?UTF-8?B?...?= <email@example.com>\"\n * - With comment: \"email@example.com (Display Name)\"\n *\n * @example\n * parseEmailAddress('Strapi <no-reply@strapi.io>')\n * // { name: 'Strapi', email: 'no-reply@strapi.io', original: '...' }\n *\n * @example\n * parseEmailAddress('=?UTF-8?B?U3RyYXBp?= <no-reply@strapi.io>')\n * // { name: 'Strapi', email: 'no-reply@strapi.io', original: '...' }\n */\nexport const parseEmailAddress = (emailString: string | undefined | null): ParsedEmailAddress => {\n if (!emailString || typeof emailString !== 'string') {\n return { name: null, email: '', original: emailString || '' };\n }\n\n const original = emailString;\n\n // Step 1: Decode RFC 2047 encoded-words\n let decoded = decodeRfc2047(emailString);\n\n // Step 2: Extract comments\n const { text: withoutComments, comments } = extractComments(decoded);\n decoded = withoutComments;\n\n // Step 3: Parse \"Name <email>\" format\n const angleMatch = decoded.match(/^(.*?)\\s*<([^>]+)>\\s*$/);\n\n if (angleMatch) {\n let name = angleMatch[1].trim();\n const email = normalizeEmail(angleMatch[2].trim());\n\n if (name) {\n name = unquoteString(name);\n name = decodeRfc2047(name);\n }\n\n if (!name && comments.length > 0) {\n name = comments[0];\n }\n\n return {\n name: name || null,\n email,\n original,\n };\n }\n\n // Step 4: Handle \"email (comment)\" format\n const trimmedDecoded = decoded.trim();\n\n if (trimmedDecoded.includes('@')) {\n return {\n name: comments.length > 0 ? comments[0] : null,\n email: normalizeEmail(trimmedDecoded),\n original,\n };\n }\n\n return {\n name: null,\n email: trimmedDecoded,\n original,\n };\n};\n\n/**\n * Formats an email address according to RFC 5322\n *\n * Automatically quotes names containing special characters\n * and encodes non-ASCII characters using RFC 2047.\n *\n * @example\n * formatEmailAddress('Strapi', 'no-reply@strapi.io')\n * // 'Strapi <no-reply@strapi.io>'\n *\n * @example\n * formatEmailAddress('Doe, John', 'john@example.com')\n * // '\"Doe, John\" <john@example.com>'\n *\n * @example\n * formatEmailAddress('Müller', 'mueller@example.com')\n * // '=?UTF-8?B?TcO8bGxlcg==?= <mueller@example.com>'\n */\nexport const formatEmailAddress = (\n name: string | null,\n email: string,\n options: { encodeNonAscii?: boolean } = {}\n): string => {\n const { encodeNonAscii = true } = options;\n const normalizedEmail = normalizeEmail(email);\n\n if (!name) {\n return normalizedEmail;\n }\n\n let formattedName = name;\n\n // Check for non-ASCII characters and encode if needed\n // eslint-disable-next-line no-control-regex\n if (encodeNonAscii && /[^\\x00-\\x7F]/.test(name)) {\n formattedName = encodeRfc2047Base64(name);\n return `${formattedName} <${normalizedEmail}>`;\n }\n\n // Check if name needs quoting (special characters)\n const needsQuoting = /[()<>@,;:\\\\\".[\\]]/.test(formattedName);\n\n if (needsQuoting && !formattedName.startsWith('\"')) {\n const escaped = formattedName.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"');\n return `\"${escaped}\" <${normalizedEmail}>`;\n }\n\n return `${formattedName} <${normalizedEmail}>`;\n};\n\n/**\n * Validates an email address according to RFC 5322\n *\n * @example\n * isValidEmail('user@example.com')\n * // true\n *\n * @example\n * isValidEmail('invalid')\n * // false\n */\nexport const isValidEmail = (email: string): boolean => {\n if (!email || typeof email !== 'string') {\n return false;\n }\n\n // RFC 5321 length limits: local max 64, domain max 255, total max 320\n const atIndex = email.indexOf('@');\n if (atIndex < 1 || atIndex > 64) return false;\n\n const domain = email.slice(atIndex + 1);\n if (domain.length === 0 || domain.length > 255) return false;\n if (email.length > 320) return false;\n\n // No leading/trailing/consecutive dots in the local part (RFC 5321)\n const local = email.slice(0, atIndex);\n if (local.startsWith('.') || local.endsWith('.') || local.includes('..')) return false;\n\n const emailPattern =\n /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~\\u0080-\\uFFFF-]+@[a-zA-Z0-9\\u0080-\\uFFFF](?:[a-zA-Z0-9\\u0080-\\uFFFF-]{0,61}[a-zA-Z0-9\\u0080-\\uFFFF])?(?:\\.[a-zA-Z0-9\\u0080-\\uFFFF](?:[a-zA-Z0-9\\u0080-\\uFFFF-]{0,61}[a-zA-Z0-9\\u0080-\\uFFFF])?)*$/;\n\n return emailPattern.test(email);\n};\n\n/**\n * Parses multiple comma-separated email addresses\n *\n * @example\n * parseMultipleEmailAddresses('a@example.com, \"Doe, John\" <b@example.com>')\n * // [{ name: null, email: 'a@example.com' }, { name: 'Doe, John', email: 'b@example.com' }]\n */\nexport const parseMultipleEmailAddresses = (\n emailsString: string | undefined | null\n): ParsedEmailAddress[] => {\n if (!emailsString || typeof emailsString !== 'string') {\n return [];\n }\n\n const addresses: string[] = [];\n let current = '';\n let inQuotes = false;\n let depth = 0;\n let escaped = false;\n\n for (const char of emailsString) {\n if (escaped) {\n current += char;\n escaped = false;\n } else if (char === '\\\\') {\n escaped = true;\n current += char;\n } else if (char === '\"') {\n inQuotes = !inQuotes;\n current += char;\n } else if (!inQuotes && (char === '<' || char === '(')) {\n depth += 1;\n current += char;\n } else if (!inQuotes && (char === '>' || char === ')')) {\n depth -= 1;\n current += char;\n } else if (!inQuotes && char === ',' && depth === 0) {\n const trimmed = current.trim();\n if (trimmed) {\n addresses.push(trimmed);\n }\n current = '';\n } else {\n current += char;\n }\n }\n\n const trimmed = current.trim();\n if (trimmed) {\n addresses.push(trimmed);\n }\n\n return addresses.map(parseEmailAddress);\n};\n"],"names":["normalizeEmail","email","toLowerCase","decodeRfc2047","encoded","rfc2047Pattern","replace","match","charset","encoding","text","upperEncoding","toUpperCase","decoder","TextDecoder","split","decode","Buffer","from","withSpaces","decoded","_","hex","String","fromCharCode","parseInt","bytes","encodeRfc2047Base64","str","test","maxBytesPerChunk","length","toString","parts","offset","chunkEnd","Math","min","chunk","subarray","push","join","encodeRfc2047QuotedPrintable","result","byte","padStart","extractComments","comments","depth","currentComment","inQuotes","escape","char","trim","unquoteString","trimmed","startsWith","endsWith","inner","slice","parseEmailAddress","emailString","name","original","withoutComments","angleMatch","trimmedDecoded","includes","formatEmailAddress","options","encodeNonAscii","normalizedEmail","formattedName","needsQuoting","escaped","isValidEmail","atIndex","indexOf","domain","local","emailPattern","parseMultipleEmailAddresses","emailsString","addresses","current","map"],"mappings":";;AAAA;;;;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,IAAItB,SAAS,IAAA,EAAM;YACxBsB,OAAAA,GAAU,IAAA;YACVU,OAAAA,IAAWhC,IAAAA;QACb,CAAA,MAAO,IAAIA,SAAS,GAAA,EAAK;AACvBF,YAAAA,QAAAA,GAAW,CAACA,QAAAA;YACZkC,OAAAA,IAAWhC,IAAAA;QACb,CAAA,MAAO,IAAI,CAACF,QAAAA,KAAaE,SAAS,GAAA,IAAOA,IAAAA,KAAS,GAAE,CAAA,EAAI;YACtDJ,KAAAA,IAAS,CAAA;YACToC,OAAAA,IAAWhC,IAAAA;QACb,CAAA,MAAO,IAAI,CAACF,QAAAA,KAAaE,SAAS,GAAA,IAAOA,IAAAA,KAAS,GAAE,CAAA,EAAI;YACtDJ,KAAAA,IAAS,CAAA;YACToC,OAAAA,IAAWhC,IAAAA;AACb,QAAA,CAAA,MAAO,IAAI,CAACF,QAAAA,IAAYE,IAAAA,KAAS,GAAA,IAAOJ,UAAU,CAAA,EAAG;YACnD,MAAMO,OAAAA,GAAU6B,QAAQ/B,IAAI,EAAA;AAC5B,YAAA,IAAIE,OAAAA,EAAS;AACX4B,gBAAAA,SAAAA,CAAU3C,IAAI,CAACe,OAAAA,CAAAA;AACjB,YAAA;YACA6B,OAAAA,GAAU,EAAA;QACZ,CAAA,MAAO;YACLA,OAAAA,IAAWhC,IAAAA;AACb,QAAA;AACF,IAAA;IAEA,MAAMG,OAAAA,GAAU6B,QAAQ/B,IAAI,EAAA;AAC5B,IAAA,IAAIE,OAAAA,EAAS;AACX4B,QAAAA,SAAAA,CAAU3C,IAAI,CAACe,OAAAA,CAAAA;AACjB,IAAA;IAEA,OAAO4B,SAAAA,CAAUE,GAAG,CAACzB,iBAAAA,CAAAA;AACvB;;;;;;;;;;;;;"}
@@ -0,0 +1,382 @@
1
+ /**
2
+ * RFC-compliant Email Address Utilities for Nodemailer Provider
3
+ *
4
+ * Provides utilities for parsing and formatting email addresses
5
+ * according to RFC 5322, RFC 2047, and related standards.
6
+ *
7
+ * @module @strapi/provider-email-nodemailer/utils
8
+ */ /**
9
+ * Normalizes an email address to lowercase.
10
+ *
11
+ * Per RFC 5321 section 2.4, the domain part of an email address is
12
+ * case-insensitive. While the local part is technically case-sensitive,
13
+ * in practice virtually all mail systems treat it as case-insensitive.
14
+ * Major providers (Gmail, Outlook, Yahoo, etc.) all normalize to lowercase.
15
+ *
16
+ * @see https://datatracker.ietf.org/doc/html/rfc5321#section-2.4
17
+ */ const normalizeEmail = (email)=>{
18
+ if (!email) return email;
19
+ return email.toLowerCase();
20
+ };
21
+ /**
22
+ * Decodes RFC 2047 encoded-words
23
+ * Supports both Base64 (B) and Quoted-Printable (Q) encodings
24
+ *
25
+ * @example
26
+ * decodeRfc2047('=?UTF-8?B?U3RyYXBp?=')
27
+ * // 'Strapi'
28
+ *
29
+ * @example
30
+ * decodeRfc2047('=?UTF-8?Q?M=C3=BCller?=')
31
+ * // 'Müller'
32
+ *
33
+ * @see https://datatracker.ietf.org/doc/html/rfc2047
34
+ */ const decodeRfc2047 = (encoded)=>{
35
+ const rfc2047Pattern = /=\?([^?]+)\?([BbQq])\?([^?]*)\?=/g;
36
+ return encoded.replace(rfc2047Pattern, (match, charset, encoding, text)=>{
37
+ try {
38
+ const upperEncoding = encoding.toUpperCase();
39
+ // RFC 2231 allows a language suffix, e.g. "UTF-8*en"
40
+ const decoder = new TextDecoder(charset.split('*')[0]);
41
+ if (upperEncoding === 'B') {
42
+ return decoder.decode(Buffer.from(text, 'base64'));
43
+ }
44
+ if (upperEncoding === 'Q') {
45
+ const withSpaces = text.replace(/_/g, ' ');
46
+ const decoded = withSpaces.replace(/=([0-9A-Fa-f]{2})/g, (_, hex)=>String.fromCharCode(parseInt(hex, 16)));
47
+ const bytes = Buffer.from(decoded, 'binary');
48
+ return decoder.decode(bytes);
49
+ }
50
+ return match;
51
+ } catch {
52
+ return match;
53
+ }
54
+ });
55
+ };
56
+ /**
57
+ * Encodes a string as RFC 2047 Base64 encoded-word
58
+ * Use this when the display name contains non-ASCII characters
59
+ *
60
+ * @example
61
+ * encodeRfc2047Base64('Müller')
62
+ * // '=?UTF-8?B?TcO8bGxlcg==?='
63
+ *
64
+ * @see https://datatracker.ietf.org/doc/html/rfc2047
65
+ */ const encodeRfc2047Base64 = (str)=>{
66
+ // eslint-disable-next-line no-control-regex
67
+ if (!/[^\x00-\x7F]/.test(str)) {
68
+ return str;
69
+ }
70
+ const bytes = Buffer.from(str, 'utf-8');
71
+ // RFC 2047 Section 2: encoded-word max 75 chars total
72
+ // =?UTF-8?B?...?= overhead is 12 chars, leaving 63 for base64 payload
73
+ // 63 base64 chars encode 47 bytes (floor(63 * 3 / 4) = 47)
74
+ const maxBytesPerChunk = 45; // conservative (produces 60 base64 chars = 72 total)
75
+ if (bytes.length <= maxBytesPerChunk) {
76
+ return `=?UTF-8?B?${bytes.toString('base64')}?=`;
77
+ }
78
+ const parts = [];
79
+ let offset = 0;
80
+ while(offset < bytes.length){
81
+ let chunkEnd = Math.min(offset + maxBytesPerChunk, bytes.length);
82
+ // Avoid splitting in the middle of a multi-byte UTF-8 character
83
+ // UTF-8 continuation bytes start with 10xxxxxx (0x80-0xBF)
84
+ while(chunkEnd < bytes.length && bytes[chunkEnd] >= 0x80 && bytes[chunkEnd] < 0xc0){
85
+ chunkEnd -= 1;
86
+ }
87
+ const chunk = bytes.subarray(offset, chunkEnd);
88
+ parts.push(`=?UTF-8?B?${chunk.toString('base64')}?=`);
89
+ offset = chunkEnd;
90
+ }
91
+ return parts.join(' ');
92
+ };
93
+ /**
94
+ * Encodes a string as RFC 2047 Quoted-Printable encoded-word
95
+ *
96
+ * @example
97
+ * encodeRfc2047QuotedPrintable('Müller')
98
+ * // '=?UTF-8?Q?M=C3=BCller?='
99
+ */ const encodeRfc2047QuotedPrintable = (str)=>{
100
+ // Check if encoding is needed
101
+ // eslint-disable-next-line no-control-regex
102
+ if (!/[^\x00-\x7F]/.test(str)) {
103
+ return str;
104
+ }
105
+ const bytes = Buffer.from(str, 'utf-8');
106
+ let result = '';
107
+ for (const byte of bytes){
108
+ // Printable ASCII (except = ? _ and space)
109
+ if (byte >= 33 && byte <= 126 && byte !== 61 && byte !== 63 && byte !== 95 || byte === 32) {
110
+ result += byte === 32 ? '_' : String.fromCharCode(byte);
111
+ } else {
112
+ result += `=${byte.toString(16).toUpperCase().padStart(2, '0')}`;
113
+ }
114
+ }
115
+ return `=?UTF-8?Q?${result}?=`;
116
+ };
117
+ /**
118
+ * Extracts RFC 5322 comments from an email string
119
+ * Comments are enclosed in parentheses
120
+ *
121
+ * @example
122
+ * extractComments('email@example.com (Support Team)')
123
+ * // { text: 'email@example.com', comments: ['Support Team'] }
124
+ */ const extractComments = (str)=>{
125
+ const comments = [];
126
+ let result = '';
127
+ let depth = 0;
128
+ let currentComment = '';
129
+ let inQuotes = false;
130
+ let escape = false;
131
+ for (const char of str){
132
+ if (escape) {
133
+ if (depth > 0) {
134
+ currentComment += char;
135
+ } else {
136
+ result += char;
137
+ }
138
+ escape = false;
139
+ } else if (char === '\\') {
140
+ escape = true;
141
+ if (depth > 0) {
142
+ currentComment += char;
143
+ } else {
144
+ result += char;
145
+ }
146
+ } else if (char === '"' && depth === 0) {
147
+ inQuotes = !inQuotes;
148
+ result += char;
149
+ } else if (!inQuotes && char === '(') {
150
+ if (depth === 0) {
151
+ currentComment = '';
152
+ } else {
153
+ currentComment += char;
154
+ }
155
+ depth += 1;
156
+ } else if (!inQuotes && char === ')') {
157
+ if (depth <= 0) {
158
+ result += char;
159
+ } else {
160
+ depth -= 1;
161
+ if (depth === 0) {
162
+ comments.push(currentComment.trim());
163
+ currentComment = '';
164
+ } else {
165
+ currentComment += char;
166
+ }
167
+ }
168
+ } else if (depth > 0) {
169
+ currentComment += char;
170
+ } else {
171
+ result += char;
172
+ }
173
+ }
174
+ return {
175
+ text: result.trim(),
176
+ comments
177
+ };
178
+ };
179
+ /**
180
+ * Unquotes a RFC 5322 quoted string
181
+ *
182
+ * @example
183
+ * unquoteString('"Doe, John"')
184
+ * // 'Doe, John'
185
+ */ const unquoteString = (str)=>{
186
+ const trimmed = str.trim();
187
+ if (!trimmed.startsWith('"') || !trimmed.endsWith('"')) {
188
+ return trimmed;
189
+ }
190
+ const inner = trimmed.slice(1, -1);
191
+ let result = '';
192
+ let escape = false;
193
+ for (const char of inner){
194
+ if (escape) {
195
+ result += char;
196
+ escape = false;
197
+ } else if (char === '\\') {
198
+ escape = true;
199
+ } else {
200
+ result += char;
201
+ }
202
+ }
203
+ return result;
204
+ };
205
+ /**
206
+ * Parses an email address string according to RFC 5322
207
+ *
208
+ * Supported formats:
209
+ * - Simple: "email@example.com"
210
+ * - With name: "Name <email@example.com>"
211
+ * - Quoted name: "\"Doe, John\" <email@example.com>"
212
+ * - RFC 2047 encoded: "=?UTF-8?B?...?= <email@example.com>"
213
+ * - With comment: "email@example.com (Display Name)"
214
+ *
215
+ * @example
216
+ * parseEmailAddress('Strapi <no-reply@strapi.io>')
217
+ * // { name: 'Strapi', email: 'no-reply@strapi.io', original: '...' }
218
+ *
219
+ * @example
220
+ * parseEmailAddress('=?UTF-8?B?U3RyYXBp?= <no-reply@strapi.io>')
221
+ * // { name: 'Strapi', email: 'no-reply@strapi.io', original: '...' }
222
+ */ const parseEmailAddress = (emailString)=>{
223
+ if (!emailString || typeof emailString !== 'string') {
224
+ return {
225
+ name: null,
226
+ email: '',
227
+ original: emailString || ''
228
+ };
229
+ }
230
+ const original = emailString;
231
+ // Step 1: Decode RFC 2047 encoded-words
232
+ let decoded = decodeRfc2047(emailString);
233
+ // Step 2: Extract comments
234
+ const { text: withoutComments, comments } = extractComments(decoded);
235
+ decoded = withoutComments;
236
+ // Step 3: Parse "Name <email>" format
237
+ const angleMatch = decoded.match(/^(.*?)\s*<([^>]+)>\s*$/);
238
+ if (angleMatch) {
239
+ let name = angleMatch[1].trim();
240
+ const email = normalizeEmail(angleMatch[2].trim());
241
+ if (name) {
242
+ name = unquoteString(name);
243
+ name = decodeRfc2047(name);
244
+ }
245
+ if (!name && comments.length > 0) {
246
+ name = comments[0];
247
+ }
248
+ return {
249
+ name: name || null,
250
+ email,
251
+ original
252
+ };
253
+ }
254
+ // Step 4: Handle "email (comment)" format
255
+ const trimmedDecoded = decoded.trim();
256
+ if (trimmedDecoded.includes('@')) {
257
+ return {
258
+ name: comments.length > 0 ? comments[0] : null,
259
+ email: normalizeEmail(trimmedDecoded),
260
+ original
261
+ };
262
+ }
263
+ return {
264
+ name: null,
265
+ email: trimmedDecoded,
266
+ original
267
+ };
268
+ };
269
+ /**
270
+ * Formats an email address according to RFC 5322
271
+ *
272
+ * Automatically quotes names containing special characters
273
+ * and encodes non-ASCII characters using RFC 2047.
274
+ *
275
+ * @example
276
+ * formatEmailAddress('Strapi', 'no-reply@strapi.io')
277
+ * // 'Strapi <no-reply@strapi.io>'
278
+ *
279
+ * @example
280
+ * formatEmailAddress('Doe, John', 'john@example.com')
281
+ * // '"Doe, John" <john@example.com>'
282
+ *
283
+ * @example
284
+ * formatEmailAddress('Müller', 'mueller@example.com')
285
+ * // '=?UTF-8?B?TcO8bGxlcg==?= <mueller@example.com>'
286
+ */ const formatEmailAddress = (name, email, options = {})=>{
287
+ const { encodeNonAscii = true } = options;
288
+ const normalizedEmail = normalizeEmail(email);
289
+ if (!name) {
290
+ return normalizedEmail;
291
+ }
292
+ let formattedName = name;
293
+ // Check for non-ASCII characters and encode if needed
294
+ // eslint-disable-next-line no-control-regex
295
+ if (encodeNonAscii && /[^\x00-\x7F]/.test(name)) {
296
+ formattedName = encodeRfc2047Base64(name);
297
+ return `${formattedName} <${normalizedEmail}>`;
298
+ }
299
+ // Check if name needs quoting (special characters)
300
+ const needsQuoting = /[()<>@,;:\\".[\]]/.test(formattedName);
301
+ if (needsQuoting && !formattedName.startsWith('"')) {
302
+ const escaped = formattedName.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
303
+ return `"${escaped}" <${normalizedEmail}>`;
304
+ }
305
+ return `${formattedName} <${normalizedEmail}>`;
306
+ };
307
+ /**
308
+ * Validates an email address according to RFC 5322
309
+ *
310
+ * @example
311
+ * isValidEmail('user@example.com')
312
+ * // true
313
+ *
314
+ * @example
315
+ * isValidEmail('invalid')
316
+ * // false
317
+ */ const isValidEmail = (email)=>{
318
+ if (!email || typeof email !== 'string') {
319
+ return false;
320
+ }
321
+ // RFC 5321 length limits: local max 64, domain max 255, total max 320
322
+ const atIndex = email.indexOf('@');
323
+ if (atIndex < 1 || atIndex > 64) return false;
324
+ const domain = email.slice(atIndex + 1);
325
+ if (domain.length === 0 || domain.length > 255) return false;
326
+ if (email.length > 320) return false;
327
+ // No leading/trailing/consecutive dots in the local part (RFC 5321)
328
+ const local = email.slice(0, atIndex);
329
+ if (local.startsWith('.') || local.endsWith('.') || local.includes('..')) return false;
330
+ const emailPattern = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~\u0080-\uFFFF-]+@[a-zA-Z0-9\u0080-\uFFFF](?:[a-zA-Z0-9\u0080-\uFFFF-]{0,61}[a-zA-Z0-9\u0080-\uFFFF])?(?:\.[a-zA-Z0-9\u0080-\uFFFF](?:[a-zA-Z0-9\u0080-\uFFFF-]{0,61}[a-zA-Z0-9\u0080-\uFFFF])?)*$/;
331
+ return emailPattern.test(email);
332
+ };
333
+ /**
334
+ * Parses multiple comma-separated email addresses
335
+ *
336
+ * @example
337
+ * parseMultipleEmailAddresses('a@example.com, "Doe, John" <b@example.com>')
338
+ * // [{ name: null, email: 'a@example.com' }, { name: 'Doe, John', email: 'b@example.com' }]
339
+ */ const parseMultipleEmailAddresses = (emailsString)=>{
340
+ if (!emailsString || typeof emailsString !== 'string') {
341
+ return [];
342
+ }
343
+ const addresses = [];
344
+ let current = '';
345
+ let inQuotes = false;
346
+ let depth = 0;
347
+ let escaped = false;
348
+ for (const char of emailsString){
349
+ if (escaped) {
350
+ current += char;
351
+ escaped = false;
352
+ } else if (char === '\\') {
353
+ escaped = true;
354
+ current += char;
355
+ } else if (char === '"') {
356
+ inQuotes = !inQuotes;
357
+ current += char;
358
+ } else if (!inQuotes && (char === '<' || char === '(')) {
359
+ depth += 1;
360
+ current += char;
361
+ } else if (!inQuotes && (char === '>' || char === ')')) {
362
+ depth -= 1;
363
+ current += char;
364
+ } else if (!inQuotes && char === ',' && depth === 0) {
365
+ const trimmed = current.trim();
366
+ if (trimmed) {
367
+ addresses.push(trimmed);
368
+ }
369
+ current = '';
370
+ } else {
371
+ current += char;
372
+ }
373
+ }
374
+ const trimmed = current.trim();
375
+ if (trimmed) {
376
+ addresses.push(trimmed);
377
+ }
378
+ return addresses.map(parseEmailAddress);
379
+ };
380
+
381
+ export { decodeRfc2047, encodeRfc2047Base64, encodeRfc2047QuotedPrintable, extractComments, formatEmailAddress, isValidEmail, normalizeEmail, parseEmailAddress, parseMultipleEmailAddresses, unquoteString };
382
+ //# sourceMappingURL=email-address.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"email-address.mjs","sources":["../../src/utils/email-address.ts"],"sourcesContent":["/**\n * RFC-compliant Email Address Utilities for Nodemailer Provider\n *\n * Provides utilities for parsing and formatting email addresses\n * according to RFC 5322, RFC 2047, and related standards.\n *\n * @module @strapi/provider-email-nodemailer/utils\n */\n\nexport interface ParsedEmailAddress {\n /** Display name (decoded if RFC 2047 encoded) */\n name: string | null;\n /** Email address (normalized to lowercase per RFC 5321) */\n email: string;\n /** Original unparsed string */\n original: string;\n}\n\n/**\n * Normalizes an email address to lowercase.\n *\n * Per RFC 5321 section 2.4, the domain part of an email address is\n * case-insensitive. While the local part is technically case-sensitive,\n * in practice virtually all mail systems treat it as case-insensitive.\n * Major providers (Gmail, Outlook, Yahoo, etc.) all normalize to lowercase.\n *\n * @see https://datatracker.ietf.org/doc/html/rfc5321#section-2.4\n */\nexport const normalizeEmail = (email: string): string => {\n if (!email) return email;\n return email.toLowerCase();\n};\n\n/**\n * Decodes RFC 2047 encoded-words\n * Supports both Base64 (B) and Quoted-Printable (Q) encodings\n *\n * @example\n * decodeRfc2047('=?UTF-8?B?U3RyYXBp?=')\n * // 'Strapi'\n *\n * @example\n * decodeRfc2047('=?UTF-8?Q?M=C3=BCller?=')\n * // 'Müller'\n *\n * @see https://datatracker.ietf.org/doc/html/rfc2047\n */\nexport const decodeRfc2047 = (encoded: string): string => {\n const rfc2047Pattern = /=\\?([^?]+)\\?([BbQq])\\?([^?]*)\\?=/g;\n\n return encoded.replace(rfc2047Pattern, (match, charset, encoding, text) => {\n try {\n const upperEncoding = encoding.toUpperCase();\n // RFC 2231 allows a language suffix, e.g. \"UTF-8*en\"\n const decoder = new TextDecoder(charset.split('*')[0]);\n\n if (upperEncoding === 'B') {\n return decoder.decode(Buffer.from(text, 'base64'));\n }\n\n if (upperEncoding === 'Q') {\n const withSpaces = text.replace(/_/g, ' ');\n const decoded = withSpaces.replace(/=([0-9A-Fa-f]{2})/g, (_: string, hex: string) =>\n String.fromCharCode(parseInt(hex, 16))\n );\n const bytes = Buffer.from(decoded, 'binary');\n return decoder.decode(bytes);\n }\n\n return match;\n } catch {\n return match;\n }\n });\n};\n\n/**\n * Encodes a string as RFC 2047 Base64 encoded-word\n * Use this when the display name contains non-ASCII characters\n *\n * @example\n * encodeRfc2047Base64('Müller')\n * // '=?UTF-8?B?TcO8bGxlcg==?='\n *\n * @see https://datatracker.ietf.org/doc/html/rfc2047\n */\nexport const encodeRfc2047Base64 = (str: string): string => {\n // eslint-disable-next-line no-control-regex\n if (!/[^\\x00-\\x7F]/.test(str)) {\n return str;\n }\n\n const bytes = Buffer.from(str, 'utf-8');\n // RFC 2047 Section 2: encoded-word max 75 chars total\n // =?UTF-8?B?...?= overhead is 12 chars, leaving 63 for base64 payload\n // 63 base64 chars encode 47 bytes (floor(63 * 3 / 4) = 47)\n const maxBytesPerChunk = 45; // conservative (produces 60 base64 chars = 72 total)\n\n if (bytes.length <= maxBytesPerChunk) {\n return `=?UTF-8?B?${bytes.toString('base64')}?=`;\n }\n\n const parts: string[] = [];\n let offset = 0;\n\n while (offset < bytes.length) {\n let chunkEnd = Math.min(offset + maxBytesPerChunk, bytes.length);\n\n // Avoid splitting in the middle of a multi-byte UTF-8 character\n // UTF-8 continuation bytes start with 10xxxxxx (0x80-0xBF)\n while (chunkEnd < bytes.length && bytes[chunkEnd] >= 0x80 && bytes[chunkEnd] < 0xc0) {\n chunkEnd -= 1;\n }\n\n const chunk = bytes.subarray(offset, chunkEnd);\n parts.push(`=?UTF-8?B?${chunk.toString('base64')}?=`);\n offset = chunkEnd;\n }\n\n return parts.join(' ');\n};\n\n/**\n * Encodes a string as RFC 2047 Quoted-Printable encoded-word\n *\n * @example\n * encodeRfc2047QuotedPrintable('Müller')\n * // '=?UTF-8?Q?M=C3=BCller?='\n */\nexport const encodeRfc2047QuotedPrintable = (str: string): string => {\n // Check if encoding is needed\n // eslint-disable-next-line no-control-regex\n if (!/[^\\x00-\\x7F]/.test(str)) {\n return str;\n }\n\n const bytes = Buffer.from(str, 'utf-8');\n let result = '';\n\n for (const byte of bytes) {\n // Printable ASCII (except = ? _ and space)\n if ((byte >= 33 && byte <= 126 && byte !== 61 && byte !== 63 && byte !== 95) || byte === 32) {\n result += byte === 32 ? '_' : String.fromCharCode(byte);\n } else {\n result += `=${byte.toString(16).toUpperCase().padStart(2, '0')}`;\n }\n }\n\n return `=?UTF-8?Q?${result}?=`;\n};\n\n/**\n * Extracts RFC 5322 comments from an email string\n * Comments are enclosed in parentheses\n *\n * @example\n * extractComments('email@example.com (Support Team)')\n * // { text: 'email@example.com', comments: ['Support Team'] }\n */\nexport const extractComments = (str: string): { text: string; comments: string[] } => {\n const comments: string[] = [];\n let result = '';\n let depth = 0;\n let currentComment = '';\n let inQuotes = false;\n let escape = false;\n\n for (const char of str) {\n if (escape) {\n if (depth > 0) {\n currentComment += char;\n } else {\n result += char;\n }\n escape = false;\n } else if (char === '\\\\') {\n escape = true;\n if (depth > 0) {\n currentComment += char;\n } else {\n result += char;\n }\n } else if (char === '\"' && depth === 0) {\n inQuotes = !inQuotes;\n result += char;\n } else if (!inQuotes && char === '(') {\n if (depth === 0) {\n currentComment = '';\n } else {\n currentComment += char;\n }\n depth += 1;\n } else if (!inQuotes && char === ')') {\n if (depth <= 0) {\n result += char;\n } else {\n depth -= 1;\n if (depth === 0) {\n comments.push(currentComment.trim());\n currentComment = '';\n } else {\n currentComment += char;\n }\n }\n } else if (depth > 0) {\n currentComment += char;\n } else {\n result += char;\n }\n }\n\n return { text: result.trim(), comments };\n};\n\n/**\n * Unquotes a RFC 5322 quoted string\n *\n * @example\n * unquoteString('\"Doe, John\"')\n * // 'Doe, John'\n */\nexport const unquoteString = (str: string): string => {\n const trimmed = str.trim();\n\n if (!trimmed.startsWith('\"') || !trimmed.endsWith('\"')) {\n return trimmed;\n }\n\n const inner = trimmed.slice(1, -1);\n let result = '';\n let escape = false;\n\n for (const char of inner) {\n if (escape) {\n result += char;\n escape = false;\n } else if (char === '\\\\') {\n escape = true;\n } else {\n result += char;\n }\n }\n\n return result;\n};\n\n/**\n * Parses an email address string according to RFC 5322\n *\n * Supported formats:\n * - Simple: \"email@example.com\"\n * - With name: \"Name <email@example.com>\"\n * - Quoted name: \"\\\"Doe, John\\\" <email@example.com>\"\n * - RFC 2047 encoded: \"=?UTF-8?B?...?= <email@example.com>\"\n * - With comment: \"email@example.com (Display Name)\"\n *\n * @example\n * parseEmailAddress('Strapi <no-reply@strapi.io>')\n * // { name: 'Strapi', email: 'no-reply@strapi.io', original: '...' }\n *\n * @example\n * parseEmailAddress('=?UTF-8?B?U3RyYXBp?= <no-reply@strapi.io>')\n * // { name: 'Strapi', email: 'no-reply@strapi.io', original: '...' }\n */\nexport const parseEmailAddress = (emailString: string | undefined | null): ParsedEmailAddress => {\n if (!emailString || typeof emailString !== 'string') {\n return { name: null, email: '', original: emailString || '' };\n }\n\n const original = emailString;\n\n // Step 1: Decode RFC 2047 encoded-words\n let decoded = decodeRfc2047(emailString);\n\n // Step 2: Extract comments\n const { text: withoutComments, comments } = extractComments(decoded);\n decoded = withoutComments;\n\n // Step 3: Parse \"Name <email>\" format\n const angleMatch = decoded.match(/^(.*?)\\s*<([^>]+)>\\s*$/);\n\n if (angleMatch) {\n let name = angleMatch[1].trim();\n const email = normalizeEmail(angleMatch[2].trim());\n\n if (name) {\n name = unquoteString(name);\n name = decodeRfc2047(name);\n }\n\n if (!name && comments.length > 0) {\n name = comments[0];\n }\n\n return {\n name: name || null,\n email,\n original,\n };\n }\n\n // Step 4: Handle \"email (comment)\" format\n const trimmedDecoded = decoded.trim();\n\n if (trimmedDecoded.includes('@')) {\n return {\n name: comments.length > 0 ? comments[0] : null,\n email: normalizeEmail(trimmedDecoded),\n original,\n };\n }\n\n return {\n name: null,\n email: trimmedDecoded,\n original,\n };\n};\n\n/**\n * Formats an email address according to RFC 5322\n *\n * Automatically quotes names containing special characters\n * and encodes non-ASCII characters using RFC 2047.\n *\n * @example\n * formatEmailAddress('Strapi', 'no-reply@strapi.io')\n * // 'Strapi <no-reply@strapi.io>'\n *\n * @example\n * formatEmailAddress('Doe, John', 'john@example.com')\n * // '\"Doe, John\" <john@example.com>'\n *\n * @example\n * formatEmailAddress('Müller', 'mueller@example.com')\n * // '=?UTF-8?B?TcO8bGxlcg==?= <mueller@example.com>'\n */\nexport const formatEmailAddress = (\n name: string | null,\n email: string,\n options: { encodeNonAscii?: boolean } = {}\n): string => {\n const { encodeNonAscii = true } = options;\n const normalizedEmail = normalizeEmail(email);\n\n if (!name) {\n return normalizedEmail;\n }\n\n let formattedName = name;\n\n // Check for non-ASCII characters and encode if needed\n // eslint-disable-next-line no-control-regex\n if (encodeNonAscii && /[^\\x00-\\x7F]/.test(name)) {\n formattedName = encodeRfc2047Base64(name);\n return `${formattedName} <${normalizedEmail}>`;\n }\n\n // Check if name needs quoting (special characters)\n const needsQuoting = /[()<>@,;:\\\\\".[\\]]/.test(formattedName);\n\n if (needsQuoting && !formattedName.startsWith('\"')) {\n const escaped = formattedName.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"');\n return `\"${escaped}\" <${normalizedEmail}>`;\n }\n\n return `${formattedName} <${normalizedEmail}>`;\n};\n\n/**\n * Validates an email address according to RFC 5322\n *\n * @example\n * isValidEmail('user@example.com')\n * // true\n *\n * @example\n * isValidEmail('invalid')\n * // false\n */\nexport const isValidEmail = (email: string): boolean => {\n if (!email || typeof email !== 'string') {\n return false;\n }\n\n // RFC 5321 length limits: local max 64, domain max 255, total max 320\n const atIndex = email.indexOf('@');\n if (atIndex < 1 || atIndex > 64) return false;\n\n const domain = email.slice(atIndex + 1);\n if (domain.length === 0 || domain.length > 255) return false;\n if (email.length > 320) return false;\n\n // No leading/trailing/consecutive dots in the local part (RFC 5321)\n const local = email.slice(0, atIndex);\n if (local.startsWith('.') || local.endsWith('.') || local.includes('..')) return false;\n\n const emailPattern =\n /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~\\u0080-\\uFFFF-]+@[a-zA-Z0-9\\u0080-\\uFFFF](?:[a-zA-Z0-9\\u0080-\\uFFFF-]{0,61}[a-zA-Z0-9\\u0080-\\uFFFF])?(?:\\.[a-zA-Z0-9\\u0080-\\uFFFF](?:[a-zA-Z0-9\\u0080-\\uFFFF-]{0,61}[a-zA-Z0-9\\u0080-\\uFFFF])?)*$/;\n\n return emailPattern.test(email);\n};\n\n/**\n * Parses multiple comma-separated email addresses\n *\n * @example\n * parseMultipleEmailAddresses('a@example.com, \"Doe, John\" <b@example.com>')\n * // [{ name: null, email: 'a@example.com' }, { name: 'Doe, John', email: 'b@example.com' }]\n */\nexport const parseMultipleEmailAddresses = (\n emailsString: string | undefined | null\n): ParsedEmailAddress[] => {\n if (!emailsString || typeof emailsString !== 'string') {\n return [];\n }\n\n const addresses: string[] = [];\n let current = '';\n let inQuotes = false;\n let depth = 0;\n let escaped = false;\n\n for (const char of emailsString) {\n if (escaped) {\n current += char;\n escaped = false;\n } else if (char === '\\\\') {\n escaped = true;\n current += char;\n } else if (char === '\"') {\n inQuotes = !inQuotes;\n current += char;\n } else if (!inQuotes && (char === '<' || char === '(')) {\n depth += 1;\n current += char;\n } else if (!inQuotes && (char === '>' || char === ')')) {\n depth -= 1;\n current += char;\n } else if (!inQuotes && char === ',' && depth === 0) {\n const trimmed = current.trim();\n if (trimmed) {\n addresses.push(trimmed);\n }\n current = '';\n } else {\n current += char;\n }\n }\n\n const trimmed = current.trim();\n if (trimmed) {\n addresses.push(trimmed);\n }\n\n return addresses.map(parseEmailAddress);\n};\n"],"names":["normalizeEmail","email","toLowerCase","decodeRfc2047","encoded","rfc2047Pattern","replace","match","charset","encoding","text","upperEncoding","toUpperCase","decoder","TextDecoder","split","decode","Buffer","from","withSpaces","decoded","_","hex","String","fromCharCode","parseInt","bytes","encodeRfc2047Base64","str","test","maxBytesPerChunk","length","toString","parts","offset","chunkEnd","Math","min","chunk","subarray","push","join","encodeRfc2047QuotedPrintable","result","byte","padStart","extractComments","comments","depth","currentComment","inQuotes","escape","char","trim","unquoteString","trimmed","startsWith","endsWith","inner","slice","parseEmailAddress","emailString","name","original","withoutComments","angleMatch","trimmedDecoded","includes","formatEmailAddress","options","encodeNonAscii","normalizedEmail","formattedName","needsQuoting","escaped","isValidEmail","atIndex","indexOf","domain","local","emailPattern","parseMultipleEmailAddresses","emailsString","addresses","current","map"],"mappings":"AAAA;;;;;;;;;;;;;;;;IA4BO,MAAMA,cAAAA,GAAiB,CAACC,KAAAA,GAAAA;IAC7B,IAAI,CAACA,OAAO,OAAOA,KAAAA;AACnB,IAAA,OAAOA,MAAMC,WAAW,EAAA;AAC1B;AAEA;;;;;;;;;;;;;IAcO,MAAMC,aAAAA,GAAgB,CAACC,OAAAA,GAAAA;AAC5B,IAAA,MAAMC,cAAAA,GAAiB,mCAAA;AAEvB,IAAA,OAAOD,QAAQE,OAAO,CAACD,gBAAgB,CAACE,KAAAA,EAAOC,SAASC,QAAAA,EAAUC,IAAAA,GAAAA;QAChE,IAAI;YACF,MAAMC,aAAAA,GAAgBF,SAASG,WAAW,EAAA;;YAE1C,MAAMC,OAAAA,GAAU,IAAIC,WAAAA,CAAYN,OAAAA,CAAQO,KAAK,CAA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;AACb,QAAA,CAAA,MAAO,IAAI,CAACF,QAAAA,IAAYE,IAAAA,KAAS,GAAA,IAAOJ,UAAU,CAAA,EAAG;YACnD,MAAMO,OAAAA,GAAU6B,QAAQ/B,IAAI,EAAA;AAC5B,YAAA,IAAIE,OAAAA,EAAS;AACX4B,gBAAAA,SAAAA,CAAU3C,IAAI,CAACe,OAAAA,CAAAA;AACjB,YAAA;YACA6B,OAAAA,GAAU,EAAA;QACZ,CAAA,MAAO;YACLA,OAAAA,IAAWhC,IAAAA;AACb,QAAA;AACF,IAAA;IAEA,MAAMG,OAAAA,GAAU6B,QAAQ/B,IAAI,EAAA;AAC5B,IAAA,IAAIE,OAAAA,EAAS;AACX4B,QAAAA,SAAAA,CAAU3C,IAAI,CAACe,OAAAA,CAAAA;AACjB,IAAA;IAEA,OAAO4B,SAAAA,CAAUE,GAAG,CAACzB,iBAAAA,CAAAA;AACvB;;;;"}
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ var emailAddress = require('./email-address.js');
4
+
5
+
6
+
7
+ exports.decodeRfc2047 = emailAddress.decodeRfc2047;
8
+ exports.encodeRfc2047Base64 = emailAddress.encodeRfc2047Base64;
9
+ exports.encodeRfc2047QuotedPrintable = emailAddress.encodeRfc2047QuotedPrintable;
10
+ exports.extractComments = emailAddress.extractComments;
11
+ exports.formatEmailAddress = emailAddress.formatEmailAddress;
12
+ exports.isValidEmail = emailAddress.isValidEmail;
13
+ exports.normalizeEmail = emailAddress.normalizeEmail;
14
+ exports.parseEmailAddress = emailAddress.parseEmailAddress;
15
+ exports.parseMultipleEmailAddresses = emailAddress.parseMultipleEmailAddresses;
16
+ exports.unquoteString = emailAddress.unquoteString;
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;"}
@@ -0,0 +1,2 @@
1
+ export { decodeRfc2047, encodeRfc2047Base64, encodeRfc2047QuotedPrintable, extractComments, formatEmailAddress, isValidEmail, normalizeEmail, parseEmailAddress, parseMultipleEmailAddresses, unquoteString } from './email-address.mjs';
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/provider-email-nodemailer",
3
- "version": "5.61.1",
3
+ "version": "5.62.0",
4
4
  "description": "Nodemailer provider for Strapi",
5
5
  "keywords": [
6
6
  "strapi",
@@ -74,14 +74,15 @@
74
74
  "watch": "run -T rollup -c -w"
75
75
  },
76
76
  "dependencies": {
77
- "nodemailer": "10.0.9"
77
+ "nodemailer": "10.1.4"
78
78
  },
79
79
  "devDependencies": {
80
80
  "@types/node": "22.20.0",
81
- "eslint-config-custom": "5.61.1",
82
- "tsconfig": "5.61.1",
81
+ "@types/nodemailer": "7.0.11",
82
+ "eslint-config-custom": "5.62.0",
83
+ "tsconfig": "5.62.0",
83
84
  "vitest": "catalog:",
84
- "vitest-config": "5.61.1"
85
+ "vitest-config": "5.62.0"
85
86
  },
86
87
  "engines": {
87
88
  "node": ">=22.0.0 <=26.x.x",