@c9up/rover 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/BaseMail.d.ts +30 -1
- package/dist/BaseMail.d.ts.map +1 -1
- package/dist/BaseMail.js +30 -0
- package/dist/BaseMail.js.map +1 -1
- package/dist/Mail.d.ts +32 -1
- package/dist/Mail.d.ts.map +1 -1
- package/dist/Mail.js +35 -1
- package/dist/Mail.js.map +1 -1
- package/dist/MessageBuilder.d.ts +197 -7
- package/dist/MessageBuilder.d.ts.map +1 -1
- package/dist/MessageBuilder.js +402 -8
- package/dist/MessageBuilder.js.map +1 -1
- package/dist/config.d.ts +38 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +34 -0
- package/dist/config.js.map +1 -1
- package/dist/format.d.ts +10 -0
- package/dist/format.d.ts.map +1 -1
- package/dist/format.js +28 -1
- package/dist/format.js.map +1 -1
- package/dist/index.d.ts +18 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -1
- package/dist/index.js.map +1 -1
- package/dist/testing/FakeMail.d.ts +33 -0
- package/dist/testing/FakeMail.d.ts.map +1 -1
- package/dist/testing/FakeMail.js +28 -0
- package/dist/testing/FakeMail.js.map +1 -1
- package/dist/transports/BrevoTransport.d.ts.map +1 -1
- package/dist/transports/BrevoTransport.js +5 -4
- package/dist/transports/BrevoTransport.js.map +1 -1
- package/dist/transports/MailgunTransport.d.ts.map +1 -1
- package/dist/transports/MailgunTransport.js +3 -2
- package/dist/transports/MailgunTransport.js.map +1 -1
- package/dist/transports/ResendTransport.d.ts.map +1 -1
- package/dist/transports/ResendTransport.js +5 -4
- package/dist/transports/ResendTransport.js.map +1 -1
- package/dist/transports/SendGridTransport.d.ts.map +1 -1
- package/dist/transports/SendGridTransport.js +3 -2
- package/dist/transports/SendGridTransport.js.map +1 -1
- package/dist/transports/SesTransport.d.ts.map +1 -1
- package/dist/transports/SesTransport.js +7 -5
- package/dist/transports/SesTransport.js.map +1 -1
- package/dist/transports/SparkPostTransport.d.ts.map +1 -1
- package/dist/transports/SparkPostTransport.js +5 -4
- package/dist/transports/SparkPostTransport.js.map +1 -1
- package/dist/transports/fetchError.d.ts +10 -0
- package/dist/transports/fetchError.d.ts.map +1 -1
- package/dist/transports/fetchError.js +30 -0
- package/dist/transports/fetchError.js.map +1 -1
- package/index.darwin-arm64.node +0 -0
- package/index.darwin-x64.node +0 -0
- package/index.linux-arm64-gnu.node +0 -0
- package/index.linux-x64-gnu.node +0 -0
- package/index.win32-x64-msvc.node +0 -0
- package/package.json +6 -1
- package/src/BaseMail.ts +40 -1
- package/src/Mail.ts +55 -2
- package/src/MessageBuilder.ts +561 -11
- package/src/config.ts +46 -0
- package/src/format.ts +33 -1
- package/src/index.ts +28 -2
- package/src/testing/FakeMail.ts +46 -0
- package/src/transports/BrevoTransport.ts +5 -4
- package/src/transports/MailgunTransport.ts +3 -2
- package/src/transports/ResendTransport.ts +5 -4
- package/src/transports/SendGridTransport.ts +3 -2
- package/src/transports/SesTransport.ts +7 -5
- package/src/transports/SparkPostTransport.ts +15 -10
- package/src/transports/fetchError.ts +39 -0
package/dist/MessageBuilder.js
CHANGED
|
@@ -1,5 +1,88 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { basename } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
1
4
|
import { formatAddress } from "./format.js";
|
|
5
|
+
import { RoverError } from "./RoverError.js";
|
|
2
6
|
import { renderFile as renderTemplateFile } from "./templating/SimpleTemplate.js";
|
|
7
|
+
/** Whether `list` holds `address`, or anything at all when it is omitted. */
|
|
8
|
+
function contains(list, address) {
|
|
9
|
+
if (address === undefined)
|
|
10
|
+
return list.length > 0;
|
|
11
|
+
// Addresses are stored formatted (`"Name" <a@b.c>`), so an assertion on the
|
|
12
|
+
// bare address has to match inside the display form too.
|
|
13
|
+
return list.some((entry) => entry === address || entry.includes(`<${address}>`));
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The parts a transport with no calendar field must send: the declared
|
|
17
|
+
* attachments, plus the invitation rendered as a `text/calendar` part.
|
|
18
|
+
*
|
|
19
|
+
* Only nodemailer has a native `icalEvent`; the provider HTTP APIs carry an
|
|
20
|
+
* invitation the way every mail client reads it anyway — as an attachment with
|
|
21
|
+
* the right media type and `method` parameter.
|
|
22
|
+
*/
|
|
23
|
+
export function attachmentsFor(message) {
|
|
24
|
+
const ical = message.icalEvent;
|
|
25
|
+
if (ical === undefined)
|
|
26
|
+
return message.attachments;
|
|
27
|
+
if (ical.content === undefined) {
|
|
28
|
+
// `icalEventFromUrl` leaves only an href, which nodemailer fetches for
|
|
29
|
+
// SMTP. An HTTP provider takes the bytes, and silently dropping the
|
|
30
|
+
// invitation would be worse than saying so.
|
|
31
|
+
throw new RoverError("ICAL_HREF_UNSUPPORTED", "icalEventFromUrl() is only supported by the SMTP transport, which fetches the URL itself.", {
|
|
32
|
+
hint: "Fetch the ICS yourself and pass it to icalEvent(contents), or use icalEventFromFile().",
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
const method = ical.method ?? "PUBLISH";
|
|
36
|
+
return [
|
|
37
|
+
...message.attachments,
|
|
38
|
+
{
|
|
39
|
+
filename: ical.filename ?? "invite.ics",
|
|
40
|
+
content: ical.content,
|
|
41
|
+
contentType: `text/calendar; charset=utf-8; method=${method}`,
|
|
42
|
+
encoding: ical.encoding,
|
|
43
|
+
},
|
|
44
|
+
];
|
|
45
|
+
}
|
|
46
|
+
/** Read a file declared by `attach()` / `embed()` / `icalEventFromFile()`. */
|
|
47
|
+
async function readAttachment(path, label) {
|
|
48
|
+
try {
|
|
49
|
+
return await readFile(path);
|
|
50
|
+
}
|
|
51
|
+
catch (err) {
|
|
52
|
+
throw new RoverError("ATTACHMENT_UNREADABLE", `Could not read ${label} from "${path}": ${err instanceof Error ? err.message : String(err)}`, {
|
|
53
|
+
hint: "Give an absolute path, or attach the bytes with attachData() / embedData().",
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/** Every URL inside a `List-*` value, whatever nesting form it was written in. */
|
|
58
|
+
function listUrls(value) {
|
|
59
|
+
if (typeof value === "string")
|
|
60
|
+
return [value];
|
|
61
|
+
if (Array.isArray(value))
|
|
62
|
+
return value.flatMap((entry) => listUrls(entry));
|
|
63
|
+
return [value.url];
|
|
64
|
+
}
|
|
65
|
+
/** `unsubscribe` → `Unsubscribe`, `unsubscribe-post` → `Unsubscribe-Post`. */
|
|
66
|
+
function titleCaseKey(key) {
|
|
67
|
+
return key
|
|
68
|
+
.split("-")
|
|
69
|
+
.map((part) => (part ? part[0].toUpperCase() + part.slice(1) : part))
|
|
70
|
+
.join("-");
|
|
71
|
+
}
|
|
72
|
+
/** Render one `List-*` value the way RFC 2369 writes it: `<url> (comment)`. */
|
|
73
|
+
function renderListHeader(value) {
|
|
74
|
+
if (typeof value === "string")
|
|
75
|
+
return `<${value}>`;
|
|
76
|
+
if (Array.isArray(value)) {
|
|
77
|
+
return value.map((entry) => renderListHeader(entry)).join(", ");
|
|
78
|
+
}
|
|
79
|
+
return value.comment ? `<${value.url}> (${value.comment})` : `<${value.url}>`;
|
|
80
|
+
}
|
|
81
|
+
function expect(passed, expectation, actual) {
|
|
82
|
+
if (passed)
|
|
83
|
+
return;
|
|
84
|
+
throw new RoverError("ASSERTION_FAILED", `Expected the message ${expectation}, got ${JSON.stringify(actual)}`);
|
|
85
|
+
}
|
|
3
86
|
export class MessageBuilder {
|
|
4
87
|
#msg = {
|
|
5
88
|
from: "",
|
|
@@ -11,6 +94,158 @@ export class MessageBuilder {
|
|
|
11
94
|
headers: {},
|
|
12
95
|
};
|
|
13
96
|
#pendingView = null;
|
|
97
|
+
#pendingTextView = null;
|
|
98
|
+
/**
|
|
99
|
+
* Render a template as the PLAIN-TEXT body (AdonisJS `textView`).
|
|
100
|
+
*
|
|
101
|
+
* The counterpart of `htmlView`. A message with only an HTML part scores
|
|
102
|
+
* worse with spam filters and is unreadable in a text-only client, which is
|
|
103
|
+
* why upstream offers both.
|
|
104
|
+
*/
|
|
105
|
+
textView(path, data = {}) {
|
|
106
|
+
this.#pendingTextView = { path, data };
|
|
107
|
+
return this;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Override the SMTP envelope — who the message is really from and to, as
|
|
111
|
+
* far as the mail servers are concerned (AdonisJS `envelope`).
|
|
112
|
+
*
|
|
113
|
+
* Distinct from the `From`/`To` HEADERS: a bounce goes to the envelope
|
|
114
|
+
* sender, which is how VERP and mailing lists route failures away from the
|
|
115
|
+
* visible author.
|
|
116
|
+
*/
|
|
117
|
+
envelope(envelope) {
|
|
118
|
+
this.#msg.envelope = envelope;
|
|
119
|
+
return this;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* The message as built so far — what the `has*` / `assert*` helpers read.
|
|
123
|
+
*
|
|
124
|
+
* Exposed because a test asserts against a mail it never sent, and the
|
|
125
|
+
* alternative is rebuilding the message just to look at it.
|
|
126
|
+
*/
|
|
127
|
+
toObject() {
|
|
128
|
+
return this.#msg;
|
|
129
|
+
}
|
|
130
|
+
toJSON() {
|
|
131
|
+
return this.toObject();
|
|
132
|
+
}
|
|
133
|
+
// ── Inspection ────────────────────────────────────────────────────────
|
|
134
|
+
// `has*` answers, `assert*` throws. Both exist because a test reads better
|
|
135
|
+
// as an assertion and a conditional reads better as a question.
|
|
136
|
+
hasTo(address) {
|
|
137
|
+
return contains(this.#msg.to, address);
|
|
138
|
+
}
|
|
139
|
+
hasCc(address) {
|
|
140
|
+
return contains(this.#msg.cc, address);
|
|
141
|
+
}
|
|
142
|
+
hasBcc(address) {
|
|
143
|
+
return contains(this.#msg.bcc, address);
|
|
144
|
+
}
|
|
145
|
+
hasFrom(address) {
|
|
146
|
+
return contains(this.#msg.from ? [this.#msg.from] : [], address);
|
|
147
|
+
}
|
|
148
|
+
hasReplyTo(address) {
|
|
149
|
+
return contains(this.#msg.replyTo ? [this.#msg.replyTo] : [], address);
|
|
150
|
+
}
|
|
151
|
+
hasSubject(subject) {
|
|
152
|
+
if (subject === undefined)
|
|
153
|
+
return this.#msg.subject !== "";
|
|
154
|
+
return this.#msg.subject === subject;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Whether the message carries an attachment — any at all, one with this
|
|
158
|
+
* filename or source path, or one a predicate accepts (AdonisJS
|
|
159
|
+
* `hasAttachment`, whose overloads are the same three).
|
|
160
|
+
*/
|
|
161
|
+
hasAttachment(match) {
|
|
162
|
+
if (match === undefined)
|
|
163
|
+
return this.#msg.attachments.length > 0;
|
|
164
|
+
if (typeof match === "function")
|
|
165
|
+
return this.#msg.attachments.some(match);
|
|
166
|
+
const needle = match instanceof URL ? fileURLToPath(match) : match;
|
|
167
|
+
return this.#msg.attachments.some((a) => a.filename === needle || a.path === needle);
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Whether `address` is a recipient in ANY field (AdonisJS `hasRecipient`).
|
|
171
|
+
* Without one, whether the message has a recipient at all.
|
|
172
|
+
*/
|
|
173
|
+
hasRecipient(address) {
|
|
174
|
+
return this.hasTo(address) || this.hasCc(address) || this.hasBcc(address);
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Whether the given text appears in the HTML body or the plain-text one
|
|
178
|
+
* (AdonisJS `hasContent`). The field-specific assertions are
|
|
179
|
+
* {@link assertHtmlIncludes} and {@link assertTextIncludes}.
|
|
180
|
+
*/
|
|
181
|
+
hasContent(needle) {
|
|
182
|
+
return ((this.#msg.html?.includes(needle) ?? false) ||
|
|
183
|
+
(this.#msg.text?.includes(needle) ?? false));
|
|
184
|
+
}
|
|
185
|
+
/** Whether a `List-<key>` header was defined. */
|
|
186
|
+
hasListHeader(key, url) {
|
|
187
|
+
const value = this.#msg.list?.[key];
|
|
188
|
+
if (value === undefined)
|
|
189
|
+
return false;
|
|
190
|
+
if (url === undefined)
|
|
191
|
+
return true;
|
|
192
|
+
return listUrls(value).includes(url);
|
|
193
|
+
}
|
|
194
|
+
hasHeader(name, value) {
|
|
195
|
+
const found = this.#msg.headers[name];
|
|
196
|
+
if (found === undefined)
|
|
197
|
+
return false;
|
|
198
|
+
if (value === undefined)
|
|
199
|
+
return true;
|
|
200
|
+
return Array.isArray(found) ? found.includes(value) : found === value;
|
|
201
|
+
}
|
|
202
|
+
assertTo(address) {
|
|
203
|
+
expect(this.hasTo(address), `to include "${address}"`, this.#msg.to);
|
|
204
|
+
}
|
|
205
|
+
assertFrom(address) {
|
|
206
|
+
expect(this.hasFrom(address), `from to be "${address}"`, this.#msg.from);
|
|
207
|
+
}
|
|
208
|
+
assertCc(address) {
|
|
209
|
+
expect(this.hasCc(address), `cc to include "${address}"`, this.#msg.cc);
|
|
210
|
+
}
|
|
211
|
+
assertBcc(address) {
|
|
212
|
+
expect(this.hasBcc(address), `bcc to include "${address}"`, this.#msg.bcc);
|
|
213
|
+
}
|
|
214
|
+
assertReplyTo(address) {
|
|
215
|
+
expect(this.hasReplyTo(address), `replyTo to be "${address}"`, this.#msg.replyTo);
|
|
216
|
+
}
|
|
217
|
+
assertSubject(subject) {
|
|
218
|
+
expect(this.hasSubject(subject), `subject to be "${subject}"`, this.#msg.subject);
|
|
219
|
+
}
|
|
220
|
+
assertAttachment(match) {
|
|
221
|
+
expect(this.hasAttachment(match), typeof match === "function"
|
|
222
|
+
? "an attachment matching the predicate"
|
|
223
|
+
: `an attachment named "${String(match)}"`, this.#msg.attachments.map((a) => a.path ?? a.filename));
|
|
224
|
+
}
|
|
225
|
+
/** `address` is a recipient in some field (AdonisJS `assertRecipient`). */
|
|
226
|
+
assertRecipient(address) {
|
|
227
|
+
expect(this.hasRecipient(address), `to reach "${address}"`, {
|
|
228
|
+
to: this.#msg.to,
|
|
229
|
+
cc: this.#msg.cc,
|
|
230
|
+
bcc: this.#msg.bcc,
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
/** The text appears in the HTML or the plain-text body (AdonisJS `assertContent`). */
|
|
234
|
+
assertContent(needle) {
|
|
235
|
+
expect(this.hasContent(needle), `to contain "${needle}"`, {
|
|
236
|
+
html: this.#msg.html,
|
|
237
|
+
text: this.#msg.text,
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
assertHeader(name, value) {
|
|
241
|
+
expect(this.hasHeader(name, value), value === undefined ? `a "${name}" header` : `${name}: ${value}`, this.#msg.headers[name]);
|
|
242
|
+
}
|
|
243
|
+
assertHtmlIncludes(substring) {
|
|
244
|
+
expect((this.#msg.html ?? "").includes(substring), `html to include "${substring}"`, this.#msg.html);
|
|
245
|
+
}
|
|
246
|
+
assertTextIncludes(substring) {
|
|
247
|
+
expect((this.#msg.text ?? "").includes(substring), `text to include "${substring}"`, this.#msg.text);
|
|
248
|
+
}
|
|
14
249
|
from(address, name) {
|
|
15
250
|
this.#msg.from = formatAddress(address, name);
|
|
16
251
|
return this;
|
|
@@ -63,24 +298,160 @@ export class MessageBuilder {
|
|
|
63
298
|
this.#msg.references = messageIds.slice();
|
|
64
299
|
return this;
|
|
65
300
|
}
|
|
66
|
-
|
|
67
|
-
|
|
301
|
+
/**
|
|
302
|
+
* Attach a FILE by path or `file://` URL (AdonisJS `attach`). The bytes are
|
|
303
|
+
* read at {@link build} time, so the fluent chain stays synchronous.
|
|
304
|
+
*
|
|
305
|
+
* The filename defaults to the file's own basename. For bytes you already
|
|
306
|
+
* hold, use {@link attachData}.
|
|
307
|
+
*/
|
|
308
|
+
attach(file, options) {
|
|
309
|
+
const path = file instanceof URL ? fileURLToPath(file) : file;
|
|
310
|
+
this.#msg.attachments.push({
|
|
311
|
+
filename: options?.filename ?? basename(path),
|
|
312
|
+
// Filled in by `build()`; an unread attachment must never ship as an
|
|
313
|
+
// empty part, so `build()` failing to read is an error, not a warning.
|
|
314
|
+
content: "",
|
|
315
|
+
path,
|
|
316
|
+
contentType: options?.contentType,
|
|
317
|
+
contentDisposition: options?.contentDisposition,
|
|
318
|
+
encoding: options?.encoding,
|
|
319
|
+
headers: options?.headers,
|
|
320
|
+
});
|
|
68
321
|
return this;
|
|
69
322
|
}
|
|
70
323
|
/**
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
* path-based `embed(file, cid)` form from `@adonisjs/mail` is a deliberate
|
|
74
|
-
* divergence — pass the bytes directly instead.
|
|
324
|
+
* Attach bytes you already hold (AdonisJS `attachData`). `filename` is
|
|
325
|
+
* required — there is no path to take it from.
|
|
75
326
|
*/
|
|
76
|
-
|
|
77
|
-
this.#msg.attachments.push({
|
|
327
|
+
attachData(content, options) {
|
|
328
|
+
this.#msg.attachments.push({
|
|
329
|
+
filename: options.filename,
|
|
330
|
+
content,
|
|
331
|
+
contentType: options.contentType,
|
|
332
|
+
contentDisposition: options.contentDisposition,
|
|
333
|
+
encoding: options.encoding,
|
|
334
|
+
headers: options.headers,
|
|
335
|
+
});
|
|
336
|
+
return this;
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Embed a FILE inline, referenced by `cid:<cid>` in the HTML body (AdonisJS
|
|
340
|
+
* `embed`). Read at {@link build} time, like {@link attach}.
|
|
341
|
+
*/
|
|
342
|
+
embed(file, cid, options) {
|
|
343
|
+
const path = file instanceof URL ? fileURLToPath(file) : file;
|
|
344
|
+
this.#msg.attachments.push({
|
|
345
|
+
filename: options?.filename ?? basename(path),
|
|
346
|
+
content: "",
|
|
347
|
+
path,
|
|
348
|
+
cid,
|
|
349
|
+
contentType: options?.contentType,
|
|
350
|
+
contentDisposition: options?.contentDisposition ?? "inline",
|
|
351
|
+
encoding: options?.encoding,
|
|
352
|
+
headers: options?.headers,
|
|
353
|
+
});
|
|
354
|
+
return this;
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Embed bytes you already hold, referenced by `cid:<cid>` in the HTML body
|
|
358
|
+
* (AdonisJS `embedData`).
|
|
359
|
+
*/
|
|
360
|
+
embedData(content, cid, options) {
|
|
361
|
+
this.#msg.attachments.push({
|
|
362
|
+
filename: options?.filename ?? cid,
|
|
363
|
+
content,
|
|
364
|
+
cid,
|
|
365
|
+
contentType: options?.contentType,
|
|
366
|
+
contentDisposition: options?.contentDisposition ?? "inline",
|
|
367
|
+
encoding: options?.encoding,
|
|
368
|
+
headers: options?.headers,
|
|
369
|
+
});
|
|
78
370
|
return this;
|
|
79
371
|
}
|
|
80
372
|
header(key, value) {
|
|
81
373
|
this.#msg.headers[key] = value;
|
|
82
374
|
return this;
|
|
83
375
|
}
|
|
376
|
+
/**
|
|
377
|
+
* Body transfer encoding (AdonisJS `encoding`) — `7bit`, `base64`,
|
|
378
|
+
* `quoted-printable`… SMTP only: the provider HTTP APIs encode the payload
|
|
379
|
+
* themselves and expose no equivalent.
|
|
380
|
+
*/
|
|
381
|
+
encoding(encoding) {
|
|
382
|
+
this.#msg.encoding = encoding;
|
|
383
|
+
return this;
|
|
384
|
+
}
|
|
385
|
+
// ── RFC 2369 List-* headers ───────────────────────────────────────────
|
|
386
|
+
/**
|
|
387
|
+
* Define a `List-<key>` header (AdonisJS `addListHeader`). `key` carries no
|
|
388
|
+
* `List-` prefix — `addListHeader('archive', url)` emits `List-Archive`.
|
|
389
|
+
* Calling it again for the same key replaces the value.
|
|
390
|
+
*/
|
|
391
|
+
addListHeader(key, value) {
|
|
392
|
+
this.#msg.list ??= {};
|
|
393
|
+
this.#msg.list[key] = value;
|
|
394
|
+
return this;
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* `List-Unsubscribe` (AdonisJS `listUnsubscribe`).
|
|
398
|
+
*
|
|
399
|
+
* `{ oneClick: true }` also emits the RFC 8058 `List-Unsubscribe-Post`
|
|
400
|
+
* header. Gmail and Yahoo require BOTH for bulk senders, and only a `https:`
|
|
401
|
+
* URL is a valid one-click target — a `mailto:` cannot answer a POST, so
|
|
402
|
+
* pairing them is refused rather than silently shipped.
|
|
403
|
+
*/
|
|
404
|
+
listUnsubscribe(value, options) {
|
|
405
|
+
if (options?.oneClick === true) {
|
|
406
|
+
for (const url of listUrls(value)) {
|
|
407
|
+
if (!url.toLowerCase().startsWith("http")) {
|
|
408
|
+
throw new RoverError("INVALID_LIST_HEADER", `listUnsubscribe({ oneClick: true }) needs an https URL that can answer a POST, got "${url}".`, {
|
|
409
|
+
hint: "Keep the mailto: form without oneClick, or add an https endpoint alongside it.",
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
// A RAW header, not a `List-*` entry: nodemailer wraps every list value
|
|
414
|
+
// in angle brackets, and `<List-Unsubscribe=One-Click>` is not what
|
|
415
|
+
// RFC 8058 specifies — receivers would ignore it.
|
|
416
|
+
this.#msg.headers["List-Unsubscribe-Post"] = "List-Unsubscribe=One-Click";
|
|
417
|
+
}
|
|
418
|
+
return this.addListHeader("unsubscribe", value);
|
|
419
|
+
}
|
|
420
|
+
/** `List-Subscribe` (AdonisJS `listSubscribe`). */
|
|
421
|
+
listSubscribe(value) {
|
|
422
|
+
return this.addListHeader("subscribe", value);
|
|
423
|
+
}
|
|
424
|
+
/** `List-Help` (AdonisJS `listHelp`). */
|
|
425
|
+
listHelp(value) {
|
|
426
|
+
return this.addListHeader("help", value);
|
|
427
|
+
}
|
|
428
|
+
// ── Calendar invitations ──────────────────────────────────────────────
|
|
429
|
+
/**
|
|
430
|
+
* Attach a calendar invitation from an ICS string (AdonisJS `icalEvent`).
|
|
431
|
+
*
|
|
432
|
+
* Named deviation: upstream also accepts a `(calendar: ICalCalendar) => void`
|
|
433
|
+
* builder, which is `ical-generator`'s API. rover carries no such
|
|
434
|
+
* dependency, so it takes the ICS text — produced by whichever generator you
|
|
435
|
+
* prefer. {@link icalEventFromFile} and {@link icalEventFromUrl} are the
|
|
436
|
+
* other two upstream forms, unchanged.
|
|
437
|
+
*/
|
|
438
|
+
icalEvent(contents, options) {
|
|
439
|
+
this.#msg.icalEvent = { ...options, content: contents };
|
|
440
|
+
return this;
|
|
441
|
+
}
|
|
442
|
+
/** Calendar invitation read from a file at {@link build} time (AdonisJS `icalEventFromFile`). */
|
|
443
|
+
icalEventFromFile(file, options) {
|
|
444
|
+
this.#msg.icalEvent = {
|
|
445
|
+
...options,
|
|
446
|
+
path: file instanceof URL ? fileURLToPath(file) : file,
|
|
447
|
+
};
|
|
448
|
+
return this;
|
|
449
|
+
}
|
|
450
|
+
/** Calendar invitation the transport fetches from a URL (AdonisJS `icalEventFromUrl`). */
|
|
451
|
+
icalEventFromUrl(url, options) {
|
|
452
|
+
this.#msg.icalEvent = { ...options, href: url };
|
|
453
|
+
return this;
|
|
454
|
+
}
|
|
84
455
|
/**
|
|
85
456
|
* Queue an HTML template render. The render happens lazily at `build()` time
|
|
86
457
|
* so the fluent chain stays synchronous; `build()` is async and awaits the
|
|
@@ -101,6 +472,29 @@ export class MessageBuilder {
|
|
|
101
472
|
this.#msg.html = await renderTemplateFile(this.#pendingView.path, this.#pendingView.data, undefined, viewsRoot);
|
|
102
473
|
this.#pendingView = null;
|
|
103
474
|
}
|
|
475
|
+
if (this.#pendingTextView !== null) {
|
|
476
|
+
this.#msg.text = await renderTemplateFile(this.#pendingTextView.path, this.#pendingTextView.data, undefined, viewsRoot);
|
|
477
|
+
this.#pendingTextView = null;
|
|
478
|
+
}
|
|
479
|
+
// Path-based attachments and invitations are read here, not when they were
|
|
480
|
+
// declared, so the fluent chain stays synchronous. A read failure raises:
|
|
481
|
+
// an attachment the recipient expects must never ship as an empty part.
|
|
482
|
+
for (const attachment of this.#msg.attachments) {
|
|
483
|
+
if (attachment.path === undefined)
|
|
484
|
+
continue;
|
|
485
|
+
attachment.content = await readAttachment(attachment.path, attachment.filename);
|
|
486
|
+
}
|
|
487
|
+
const ical = this.#msg.icalEvent;
|
|
488
|
+
if (ical?.path !== undefined && ical.content === undefined) {
|
|
489
|
+
ical.content = (await readAttachment(ical.path, "the calendar event")).toString("utf8");
|
|
490
|
+
}
|
|
491
|
+
// `List-*` headers are rendered here, once, rather than in each transport:
|
|
492
|
+
// every transport already forwards `headers`, and only nodemailer has a
|
|
493
|
+
// structured `list` field. `#msg.list` stays as the structured record the
|
|
494
|
+
// `hasListHeader` inspection reads.
|
|
495
|
+
for (const [key, value] of Object.entries(this.#msg.list ?? {})) {
|
|
496
|
+
this.#msg.headers[`List-${titleCaseKey(key)}`] = renderListHeader(value);
|
|
497
|
+
}
|
|
104
498
|
return this.#msg;
|
|
105
499
|
}
|
|
106
500
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageBuilder.js","sourceRoot":"","sources":["../src/MessageBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,UAAU,IAAI,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AA0ClF,MAAM,OAAO,cAAc;IAC1B,IAAI,GAAgB;QACnB,IAAI,EAAE,EAAE;QACR,EAAE,EAAE,EAAE;QACN,EAAE,EAAE,EAAE;QACN,GAAG,EAAE,EAAE;QACP,OAAO,EAAE,EAAE;QACX,WAAW,EAAE,EAAE;QACf,OAAO,EAAE,EAAE;KACX,CAAC;IACF,YAAY,GAA2D,IAAI,CAAC;IAE5E,IAAI,CAAC,OAAe,EAAE,IAAa;QAClC,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAC9C,OAAO,IAAI,CAAC;IACb,CAAC;IAID,EAAE,CAAC,OAA6B,EAAE,IAAa;QAC9C,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;QAC3C,OAAO,IAAI,CAAC;IACb,CAAC;IAID,EAAE,CAAC,OAA6B,EAAE,IAAa;QAC9C,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;QAC3C,OAAO,IAAI,CAAC;IACb,CAAC;IAID,GAAG,CAAC,OAA6B,EAAE,IAAa;QAC/C,aAAa,CA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C,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;AACzC,CAAC"}
|
package/dist/config.d.ts
CHANGED
|
@@ -1,4 +1,42 @@
|
|
|
1
1
|
import type { MailConfig } from "./Mail.js";
|
|
2
|
+
import type { RetryConfig } from "./retry.js";
|
|
2
3
|
export declare function defineConfig(config: MailConfig): MailConfig;
|
|
4
|
+
/** One mailer's settings — the transport name plus whatever it reads. */
|
|
5
|
+
export interface TransportDescriptor {
|
|
6
|
+
transport: string;
|
|
7
|
+
retry?: RetryConfig;
|
|
8
|
+
[key: string]: unknown;
|
|
9
|
+
}
|
|
10
|
+
type Options = Record<string, unknown> & {
|
|
11
|
+
retry?: RetryConfig;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Mailer descriptors for `defineConfig`, matching the AdonisJS call site:
|
|
15
|
+
*
|
|
16
|
+
* defineConfig({
|
|
17
|
+
* default: 'smtp',
|
|
18
|
+
* from: 'noreply@acme.com',
|
|
19
|
+
* mailers: { smtp: transports.smtp({ host: env.get('SMTP_HOST') }) },
|
|
20
|
+
* })
|
|
21
|
+
*
|
|
22
|
+
* Named deviation: upstream returns a config PROVIDER that lazily imports the
|
|
23
|
+
* transport. Rover returns the plain descriptor its config can persist, and the
|
|
24
|
+
* transport registers itself on import.
|
|
25
|
+
*
|
|
26
|
+
* Postmark has no helper here on purpose: rover has no Postmark transport, so a
|
|
27
|
+
* migrated config naming it fails to COMPILE — which says so plainly — instead
|
|
28
|
+
* of throwing at boot.
|
|
29
|
+
*/
|
|
30
|
+
export declare const transports: {
|
|
31
|
+
smtp: (config?: Options) => TransportDescriptor;
|
|
32
|
+
ses: (config?: Options) => TransportDescriptor;
|
|
33
|
+
mailgun: (config?: Options) => TransportDescriptor;
|
|
34
|
+
sparkpost: (config?: Options) => TransportDescriptor;
|
|
35
|
+
resend: (config?: Options) => TransportDescriptor;
|
|
36
|
+
brevo: (config?: Options) => TransportDescriptor;
|
|
37
|
+
sendgrid: (config?: Options) => TransportDescriptor;
|
|
38
|
+
/** Writes to the logger instead of sending — the local-development mailer. */
|
|
39
|
+
log: (config?: Options) => TransportDescriptor;
|
|
40
|
+
};
|
|
3
41
|
export type { MailConfig };
|
|
4
42
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAE3D;AAED,yEAAyE;AACzE,MAAM,WAAW,mBAAmB;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACvB;AAED,KAAK,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAAE,KAAK,CAAC,EAAE,WAAW,CAAA;CAAE,CAAC;AASjE;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,UAAU;oBAvBN,OAAO,KAAQ,mBAAmB;mBAAlC,OAAO,KAAQ,mBAAmB;uBAAlC,OAAO,KAAQ,mBAAmB;yBAAlC,OAAO,KAAQ,mBAAmB;sBAAlC,OAAO,KAAQ,mBAAmB;qBAAlC,OAAO,KAAQ,mBAAmB;wBAAlC,OAAO,KAAQ,mBAAmB;IA+BlD,8EAA8E;mBA/B9D,OAAO,KAAQ,mBAAmB;CAiClD,CAAC;AAEF,YAAY,EAAE,UAAU,EAAE,CAAC"}
|
package/dist/config.js
CHANGED
|
@@ -1,4 +1,38 @@
|
|
|
1
1
|
export function defineConfig(config) {
|
|
2
2
|
return config;
|
|
3
3
|
}
|
|
4
|
+
function describe(transport) {
|
|
5
|
+
return (config = {}) => ({
|
|
6
|
+
...config,
|
|
7
|
+
transport,
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Mailer descriptors for `defineConfig`, matching the AdonisJS call site:
|
|
12
|
+
*
|
|
13
|
+
* defineConfig({
|
|
14
|
+
* default: 'smtp',
|
|
15
|
+
* from: 'noreply@acme.com',
|
|
16
|
+
* mailers: { smtp: transports.smtp({ host: env.get('SMTP_HOST') }) },
|
|
17
|
+
* })
|
|
18
|
+
*
|
|
19
|
+
* Named deviation: upstream returns a config PROVIDER that lazily imports the
|
|
20
|
+
* transport. Rover returns the plain descriptor its config can persist, and the
|
|
21
|
+
* transport registers itself on import.
|
|
22
|
+
*
|
|
23
|
+
* Postmark has no helper here on purpose: rover has no Postmark transport, so a
|
|
24
|
+
* migrated config naming it fails to COMPILE — which says so plainly — instead
|
|
25
|
+
* of throwing at boot.
|
|
26
|
+
*/
|
|
27
|
+
export const transports = {
|
|
28
|
+
smtp: describe("smtp"),
|
|
29
|
+
ses: describe("ses"),
|
|
30
|
+
mailgun: describe("mailgun"),
|
|
31
|
+
sparkpost: describe("sparkpost"),
|
|
32
|
+
resend: describe("resend"),
|
|
33
|
+
brevo: describe("brevo"),
|
|
34
|
+
sendgrid: describe("sendgrid"),
|
|
35
|
+
/** Writes to the logger instead of sending — the local-development mailer. */
|
|
36
|
+
log: describe("log"),
|
|
37
|
+
};
|
|
4
38
|
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,YAAY,CAAC,MAAkB;IAC9C,OAAO,MAAM,CAAC;AACf,CAAC;AAWD,SAAS,QAAQ,CAAC,SAAiB;IAClC,OAAO,CAAC,SAAkB,EAAE,EAAuB,EAAE,CAAC,CAAC;QACtD,GAAG,MAAM;QACT,SAAS;KACT,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACzB,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC;IACtB,GAAG,EAAE,QAAQ,CAAC,KAAK,CAAC;IACpB,OAAO,EAAE,QAAQ,CAAC,SAAS,CAAC;IAC5B,SAAS,EAAE,QAAQ,CAAC,WAAW,CAAC;IAChC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC;IAC1B,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC;IACxB,QAAQ,EAAE,QAAQ,CAAC,UAAU,CAAC;IAC9B,8EAA8E;IAC9E,GAAG,EAAE,QAAQ,CAAC,KAAK,CAAC;CACpB,CAAC"}
|
package/dist/format.d.ts
CHANGED
|
@@ -7,6 +7,16 @@
|
|
|
7
7
|
* Format a recipient address with an optional display name into the
|
|
8
8
|
* `"Name" <address>` form (RFC 5322 quoted display name). A bare address —
|
|
9
9
|
* or an empty/whitespace-only name — is returned unchanged.
|
|
10
|
+
*
|
|
11
|
+
* The display name is a QUOTED string, so a `"` inside it would close the quote
|
|
12
|
+
* early: a name of `x" <evil@example.com>, "y` would otherwise forge a second
|
|
13
|
+
* recipient. Backslash and quote are escaped, which is what a quoted-string
|
|
14
|
+
* allows.
|
|
15
|
+
*
|
|
16
|
+
* A line break cannot be escaped in a header — it ENDS the header — so a value
|
|
17
|
+
* carrying CR, LF or NUL is rejected rather than mangled. Accepting it is how a
|
|
18
|
+
* contact form turns into an open relay: one `\r\nBcc:` and the message goes
|
|
19
|
+
* wherever the attacker asked.
|
|
10
20
|
*/
|
|
11
21
|
export declare function formatAddress(address: string, name?: string): string;
|
|
12
22
|
//# sourceMappingURL=format.d.ts.map
|
package/dist/format.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAQpE"}
|
package/dist/format.js
CHANGED
|
@@ -3,12 +3,39 @@
|
|
|
3
3
|
* so both `BaseMail` and `MessageBuilder` can import it without re-introducing
|
|
4
4
|
* the BaseMail ↔ MessageBuilder value cycle.
|
|
5
5
|
*/
|
|
6
|
+
import { RoverError } from "./RoverError.js";
|
|
7
|
+
/** CR, LF and NUL — the characters that end a header line or a C string. */
|
|
8
|
+
const HEADER_BREAKERS = /[\r\n\0]/;
|
|
6
9
|
/**
|
|
7
10
|
* Format a recipient address with an optional display name into the
|
|
8
11
|
* `"Name" <address>` form (RFC 5322 quoted display name). A bare address —
|
|
9
12
|
* or an empty/whitespace-only name — is returned unchanged.
|
|
13
|
+
*
|
|
14
|
+
* The display name is a QUOTED string, so a `"` inside it would close the quote
|
|
15
|
+
* early: a name of `x" <evil@example.com>, "y` would otherwise forge a second
|
|
16
|
+
* recipient. Backslash and quote are escaped, which is what a quoted-string
|
|
17
|
+
* allows.
|
|
18
|
+
*
|
|
19
|
+
* A line break cannot be escaped in a header — it ENDS the header — so a value
|
|
20
|
+
* carrying CR, LF or NUL is rejected rather than mangled. Accepting it is how a
|
|
21
|
+
* contact form turns into an open relay: one `\r\nBcc:` and the message goes
|
|
22
|
+
* wherever the attacker asked.
|
|
10
23
|
*/
|
|
11
24
|
export function formatAddress(address, name) {
|
|
12
|
-
|
|
25
|
+
assertHeaderSafe(address, "address");
|
|
26
|
+
if (name === undefined || name === "")
|
|
27
|
+
return address;
|
|
28
|
+
assertHeaderSafe(name, "name");
|
|
29
|
+
// Escape the escape character first, or a trailing backslash would swallow
|
|
30
|
+
// the closing quote.
|
|
31
|
+
const quoted = name.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
|
32
|
+
return `"${quoted}" <${address}>`;
|
|
33
|
+
}
|
|
34
|
+
function assertHeaderSafe(value, what) {
|
|
35
|
+
if (!HEADER_BREAKERS.test(value))
|
|
36
|
+
return;
|
|
37
|
+
throw new RoverError("MAIL_HEADER_INJECTION", `The ${what} contains a line break or NUL, which cannot appear in a mail header.`, {
|
|
38
|
+
hint: "Strip CR/LF/NUL from user-supplied names and addresses before building the message.",
|
|
39
|
+
});
|
|
13
40
|
}
|
|
14
41
|
//# sourceMappingURL=format.js.map
|
package/dist/format.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.js","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,4EAA4E;AAC5E,MAAM,eAAe,GAAG,UAAU,CAAC;AAEnC;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,aAAa,CAAC,OAAe,EAAE,IAAa;IAC3D,gBAAgB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IACrC,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,EAAE;QAAE,OAAO,OAAO,CAAC;IACtD,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC/B,2EAA2E;IAC3E,qBAAqB;IACrB,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAChE,OAAO,IAAI,MAAM,MAAM,OAAO,GAAG,CAAC;AACnC,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAa,EAAE,IAAY;IACpD,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO;IACzC,MAAM,IAAI,UAAU,CACnB,uBAAuB,EACvB,OAAO,IAAI,sEAAsE,EACjF;QACC,IAAI,EAAE,qFAAqF;KAC3F,CACD,CAAC;AACH,CAAC"}
|