@bumail/queue 0.4.3 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -2
- package/dist/index.js +229 -155
- package/dist/index.js.map +10 -8
- package/dist/queue/attempt.d.ts +14 -0
- package/dist/queue/attempt.d.ts.map +1 -0
- package/dist/queue/deliver.d.ts.map +1 -1
- package/dist/queue/events.d.ts +12 -0
- package/dist/queue/events.d.ts.map +1 -1
- package/dist/queue/fallback.d.ts +25 -0
- package/dist/queue/fallback.d.ts.map +1 -0
- package/dist/queue/options.d.ts +9 -0
- package/dist/queue/options.d.ts.map +1 -1
- package/dist/queue/route.d.ts +1 -1
- package/dist/queue/route.d.ts.map +1 -1
- package/dist/queue/settings/routes.d.ts.map +1 -1
- package/docs/guide.md +57 -1
- package/docs/roadmap.md +10 -1
- package/docs/troubleshooting.md +19 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -110,6 +110,8 @@ createQueue({
|
|
|
110
110
|
},
|
|
111
111
|
// …or only some domains, the rest by MX (which needs the resolver):
|
|
112
112
|
routes: { 'partner.example': { host: 'relay.partner.example' } },
|
|
113
|
+
// …or by MX, with a smarthost only as the way out when MX fails:
|
|
114
|
+
// fallback: { host: 'smtp.provider.example', port: 587, auth: { username: 'mary@example.net', password: smtpPassword } },
|
|
113
115
|
});
|
|
114
116
|
```
|
|
115
117
|
|
|
@@ -122,6 +124,10 @@ says so on the `error` event; it does not bounce them until
|
|
|
122
124
|
`retry.giveUpAfter`, when they fail as `4.4.7` with a DSN like any
|
|
123
125
|
deferred recipient.
|
|
124
126
|
|
|
127
|
+
With `fallback` (a smarthost), a recipient whose session by MX failed by a
|
|
128
|
+
connection failure, a timeout or a reputation refusal goes through that
|
|
129
|
+
smarthost at once (not after the final dot of `DATA`, where the MX may have taken the message); see [Falling back to a smarthost](docs/guide.md#falling-back-to-a-smarthost).
|
|
130
|
+
|
|
125
131
|
## Several workers
|
|
126
132
|
|
|
127
133
|
```ts
|
|
@@ -289,9 +295,9 @@ control character in it.
|
|
|
289
295
|
| export | |
|
|
290
296
|
| --- | --- |
|
|
291
297
|
| `createQueue(options)`, `Queue` | the queue: `enqueue`, `deliverDue`, `start`, `stop`, `on`, `list`, `get`, `retryNow`, `cancel`, `owner` |
|
|
292
|
-
| `QueueOptions`, `Route`, `Smarthost`, `RetrySchedule`, `DsnOptions`, `QueueLimits`, `Clock`, `Sender` | what `createQueue` takes |
|
|
298
|
+
| `QueueOptions` (`route`, `routes`, `fallback`), `Route`, `Smarthost`, `RetrySchedule`, `DsnOptions`, `QueueLimits`, `Clock`, `Sender` | what `createQueue` takes |
|
|
293
299
|
| `MessageSource`, `QueueEnvelope` | what `enqueue` takes |
|
|
294
|
-
| `QueueEvents`, `QueueListener`, `RecipientEvent`, `DeferredEvent`, `DsnEvent`, `QueueErrorEvent` | the events |
|
|
300
|
+
| `QueueEvents`, `QueueListener`, `RecipientEvent` (`route`, `fallback`, `mxReply`), `DeferredEvent`, `DsnEvent`, `QueueErrorEvent` | the events |
|
|
295
301
|
| `QueueStore` | the contract a store answers: `add`, `get`, `list`, `count`, `readMessage`, `claim`, `renew`, `complete`, `reschedule`, `cancel` |
|
|
296
302
|
| `QueueItem`, `RecipientState`, `RecipientStatus`, `FinalStatus`, `Diagnostic`, `Lease` | an item, and where each recipient stands |
|
|
297
303
|
| `NewQueueItem`, `AddOptions`, `ClaimRequest`, `AttemptResult`, `RecipientUpdate`, `QueueListOptions` | what a store takes |
|
package/dist/index.js
CHANGED
|
@@ -236,6 +236,13 @@ function checkRoute(name, route) {
|
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
238
|
function checkRoutes(options) {
|
|
239
|
+
if (options.fallback !== undefined) {
|
|
240
|
+
const fallback = options.fallback;
|
|
241
|
+
if (typeof fallback !== "object" || fallback === null || typeof fallback.host !== "string") {
|
|
242
|
+
throw invalid("fallback must be a smarthost with a host, not an mx route");
|
|
243
|
+
}
|
|
244
|
+
checkRoute("fallback", fallback);
|
|
245
|
+
}
|
|
239
246
|
checkRoute("route", options.route ?? "mx");
|
|
240
247
|
const routes = Object.entries(options.routes ?? {});
|
|
241
248
|
for (const [domain, route] of routes)
|
|
@@ -285,8 +292,218 @@ function settingsOf(options) {
|
|
|
285
292
|
}
|
|
286
293
|
|
|
287
294
|
// src/queue/deliver.ts
|
|
295
|
+
import { isMailbox as isMailbox3 } from "@bumail/smtp/client";
|
|
296
|
+
|
|
297
|
+
// src/queue/attempt.ts
|
|
288
298
|
import { isMailbox as isMailbox2 } from "@bumail/smtp/client";
|
|
289
299
|
|
|
300
|
+
// src/queue/outcome.ts
|
|
301
|
+
var isSmtpError = (error) => error instanceof Error && error.name === "SmtpError" && typeof error.code === "string";
|
|
302
|
+
var isRouteError = (error) => isSmtpError(error) && error.code === "INVALID_OPTION";
|
|
303
|
+
var STATUS = /^[245]\.\d{1,3}\.\d{1,3}$/;
|
|
304
|
+
function diagnosticOf(reply, max, host) {
|
|
305
|
+
const text = typeof reply.text === "string" ? reply.text : reply.text.join(" ");
|
|
306
|
+
return {
|
|
307
|
+
code: reply.code,
|
|
308
|
+
...reply.status && STATUS.test(reply.status) ? { status: reply.status } : {},
|
|
309
|
+
text: cleanText(text, max),
|
|
310
|
+
...host ? { host: cleanText(host, 255) } : {}
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
var ERROR_STATUS = {
|
|
314
|
+
NULL_MX: "1.10",
|
|
315
|
+
DNS_FAILED: "1.2",
|
|
316
|
+
CONNECTION_FAILED: "4.1",
|
|
317
|
+
CONNECTION_LOST: "4.2",
|
|
318
|
+
TIMEOUT: "4.2",
|
|
319
|
+
TLS_UNAVAILABLE: "7.10",
|
|
320
|
+
TLS_FAILED: "7.0",
|
|
321
|
+
AUTH_UNAVAILABLE: "7.0",
|
|
322
|
+
INVALID_OPTION: "3.5"
|
|
323
|
+
};
|
|
324
|
+
function diagnosticOfError(error, temporary, max, host) {
|
|
325
|
+
const text = error instanceof Error ? error.message : String(error);
|
|
326
|
+
const detail = isSmtpError(error) ? ERROR_STATUS[error.code] ?? "0.0" : "0.0";
|
|
327
|
+
return {
|
|
328
|
+
status: `${temporary ? 4 : 5}.${detail}`,
|
|
329
|
+
text: cleanText(text, max),
|
|
330
|
+
...host ? { host: cleanText(host, 255) } : {}
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
function outcomesOf(result, group, max) {
|
|
334
|
+
const host = result.host;
|
|
335
|
+
const updates = new Map;
|
|
336
|
+
for (const { recipient } of result.accepted) {
|
|
337
|
+
updates.set(recipient, {
|
|
338
|
+
address: recipient,
|
|
339
|
+
status: "delivered",
|
|
340
|
+
reply: diagnosticOf(result.reply, max, host)
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
for (const { recipient, reply } of result.rejected) {
|
|
344
|
+
updates.set(recipient, {
|
|
345
|
+
address: recipient,
|
|
346
|
+
status: reply.code >= 500 ? "failed" : "deferred",
|
|
347
|
+
reply: diagnosticOf(reply, max, host)
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
return group.map((address) => updates.get(address) ?? {
|
|
351
|
+
address,
|
|
352
|
+
status: "deferred",
|
|
353
|
+
reply: {
|
|
354
|
+
text: "The delivery said nothing of this recipient",
|
|
355
|
+
...host ? { host: cleanText(host, 255) } : {}
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
function outcomesOfError(error, group, max, host) {
|
|
360
|
+
const rejected = new Map(isSmtpError(error) ? (error.rejected ?? []).map((r) => [r.recipient, r.reply]) : []);
|
|
361
|
+
const temporary = !isSmtpError(error) || error.temporary || isRouteError(error);
|
|
362
|
+
return group.map((address) => {
|
|
363
|
+
const own = rejected.get(address);
|
|
364
|
+
if (own) {
|
|
365
|
+
return {
|
|
366
|
+
address,
|
|
367
|
+
status: own.code >= 500 ? "failed" : "deferred",
|
|
368
|
+
reply: diagnosticOf(own, max, host)
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
const reply = isSmtpError(error) && error.reply ? diagnosticOf(error.reply, max, host) : diagnosticOfError(error, temporary, max, host);
|
|
372
|
+
return { address, status: temporary ? "deferred" : "failed", reply };
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
// src/queue/fallback.ts
|
|
377
|
+
var REPUTATION = /\b(?:block ?list(?:ed)?|black ?list(?:ed)?|deny ?list(?:ed)?|spamhaus|rbl|dnsbl|reputation|banned)\b|\bblocked\b|\blisted (?:in|on|at)\b/i;
|
|
378
|
+
var GREYLIST = /gr[ae]y ?list/i;
|
|
379
|
+
function fallsBack(reply, error) {
|
|
380
|
+
if (!reply)
|
|
381
|
+
return false;
|
|
382
|
+
if (isSmtpError(error) && error.afterData)
|
|
383
|
+
return false;
|
|
384
|
+
if (isSmtpError(error) && error.code.startsWith("TLS_"))
|
|
385
|
+
return false;
|
|
386
|
+
if (GREYLIST.test(reply.text))
|
|
387
|
+
return false;
|
|
388
|
+
if (reply.code === undefined) {
|
|
389
|
+
return reply.status === "4.4.1" || reply.status === "4.4.2";
|
|
390
|
+
}
|
|
391
|
+
if (reply.code < 400)
|
|
392
|
+
return false;
|
|
393
|
+
if (reply.status !== undefined) {
|
|
394
|
+
return /^[45]\.7\.\d+$/.test(reply.status);
|
|
395
|
+
}
|
|
396
|
+
return REPUTATION.test(reply.text);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
// src/queue/route.ts
|
|
400
|
+
function routeOf(settings, domain) {
|
|
401
|
+
return settings.routes.get(domain) ?? settings.options.route ?? "mx";
|
|
402
|
+
}
|
|
403
|
+
function hostOf(route) {
|
|
404
|
+
return route === "mx" ? undefined : route.host;
|
|
405
|
+
}
|
|
406
|
+
function sendOptionsOf(settings, domain, from, to, override) {
|
|
407
|
+
const { options, hostname } = settings;
|
|
408
|
+
const common = {
|
|
409
|
+
from,
|
|
410
|
+
to,
|
|
411
|
+
helo: hostname,
|
|
412
|
+
...options.timeouts ? { timeouts: options.timeouts } : {},
|
|
413
|
+
...options.deadline !== undefined ? { deadline: options.deadline } : {}
|
|
414
|
+
};
|
|
415
|
+
const route = override ?? routeOf(settings, domain);
|
|
416
|
+
if (route === "mx") {
|
|
417
|
+
const resolver = options.resolver;
|
|
418
|
+
if (!resolver)
|
|
419
|
+
throw new Error("unreachable: settings check the resolver");
|
|
420
|
+
return {
|
|
421
|
+
...common,
|
|
422
|
+
domain,
|
|
423
|
+
resolver,
|
|
424
|
+
...options.mxPort !== undefined ? { port: options.mxPort } : {},
|
|
425
|
+
...options.mxTls ? { tls: options.mxTls } : {}
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
return {
|
|
429
|
+
...common,
|
|
430
|
+
host: route.host,
|
|
431
|
+
...route.port !== undefined ? { port: route.port } : {},
|
|
432
|
+
...route.secure !== undefined ? { secure: route.secure } : {},
|
|
433
|
+
...route.tls ? { tls: route.tls } : {},
|
|
434
|
+
...route.auth ? { auth: route.auth } : {},
|
|
435
|
+
...route.ca ? { ca: route.ca } : {}
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
// src/queue/attempt.ts
|
|
440
|
+
var badAddress = (address) => ({
|
|
441
|
+
address,
|
|
442
|
+
status: "failed",
|
|
443
|
+
reply: {
|
|
444
|
+
status: "5.1.3",
|
|
445
|
+
text: "The address is not one SMTP can carry"
|
|
446
|
+
}
|
|
447
|
+
});
|
|
448
|
+
async function session(ctx, item, message, domain, group, route, override) {
|
|
449
|
+
const { settings } = ctx;
|
|
450
|
+
const max = settings.limits.maxReplyText;
|
|
451
|
+
try {
|
|
452
|
+
const options = sendOptionsOf(settings, domain, item.from, group, override);
|
|
453
|
+
const result = await settings.send(message, options);
|
|
454
|
+
return { updates: outcomesOf(result, group, max) };
|
|
455
|
+
} catch (error) {
|
|
456
|
+
if (isRouteError(error))
|
|
457
|
+
ctx.events.emit("error", { error, id: item.id });
|
|
458
|
+
return {
|
|
459
|
+
updates: outcomesOfError(error, group, max, hostOf(route)),
|
|
460
|
+
error
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
function merged(mx, fb) {
|
|
465
|
+
if (mx.status === "deferred" && fb.status === "failed") {
|
|
466
|
+
return { ...fb, status: "deferred" };
|
|
467
|
+
}
|
|
468
|
+
return fb;
|
|
469
|
+
}
|
|
470
|
+
async function attemptGroup(ctx, item, message, domain, recipients, used) {
|
|
471
|
+
const { settings } = ctx;
|
|
472
|
+
const bad = recipients.filter((address) => !isMailbox2(address));
|
|
473
|
+
const group = recipients.filter(isMailbox2);
|
|
474
|
+
if (group.length === 0)
|
|
475
|
+
return bad.map(badAddress);
|
|
476
|
+
const route = routeOf(settings, domain);
|
|
477
|
+
const label = route === "mx" ? "mx" : "smarthost";
|
|
478
|
+
for (const address of group)
|
|
479
|
+
used.set(address, { route: label });
|
|
480
|
+
const first = await session(ctx, item, message, domain, group, route);
|
|
481
|
+
let updates = first.updates;
|
|
482
|
+
const { fallback } = settings.options;
|
|
483
|
+
if (fallback !== undefined && route === "mx") {
|
|
484
|
+
const mx = new Map(updates.filter((u) => u.status !== "delivered" && fallsBack(u.reply, first.error)).map((u) => [u.address, u]));
|
|
485
|
+
if (mx.size > 0) {
|
|
486
|
+
const again = [...mx.keys()];
|
|
487
|
+
const second = await session(ctx, item, message, domain, again, fallback, fallback);
|
|
488
|
+
for (const [address, u] of mx) {
|
|
489
|
+
used.set(address, {
|
|
490
|
+
route: "smarthost",
|
|
491
|
+
fallback: true,
|
|
492
|
+
...u.reply ? { mxReply: u.reply } : {}
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
updates = [
|
|
496
|
+
...updates.filter((u) => !mx.has(u.address)),
|
|
497
|
+
...second.updates.map((u) => {
|
|
498
|
+
const was = mx.get(u.address);
|
|
499
|
+
return was ? merged(was, u) : u;
|
|
500
|
+
})
|
|
501
|
+
];
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
return [...updates, ...bad.map(badAddress)];
|
|
505
|
+
}
|
|
506
|
+
|
|
290
507
|
// src/dsn/build.ts
|
|
291
508
|
import {
|
|
292
509
|
encodeHeaderValue,
|
|
@@ -578,122 +795,6 @@ async function notify(ctx, item, message, kind, recipients, now) {
|
|
|
578
795
|
}
|
|
579
796
|
}
|
|
580
797
|
|
|
581
|
-
// src/queue/outcome.ts
|
|
582
|
-
var isSmtpError = (error) => error instanceof Error && error.name === "SmtpError" && typeof error.code === "string";
|
|
583
|
-
var isRouteError = (error) => isSmtpError(error) && error.code === "INVALID_OPTION";
|
|
584
|
-
var STATUS = /^[245]\.\d{1,3}\.\d{1,3}$/;
|
|
585
|
-
function diagnosticOf(reply, max, host) {
|
|
586
|
-
const text = typeof reply.text === "string" ? reply.text : reply.text.join(" ");
|
|
587
|
-
return {
|
|
588
|
-
code: reply.code,
|
|
589
|
-
...reply.status && STATUS.test(reply.status) ? { status: reply.status } : {},
|
|
590
|
-
text: cleanText(text, max),
|
|
591
|
-
...host ? { host: cleanText(host, 255) } : {}
|
|
592
|
-
};
|
|
593
|
-
}
|
|
594
|
-
var ERROR_STATUS = {
|
|
595
|
-
NULL_MX: "1.10",
|
|
596
|
-
DNS_FAILED: "1.2",
|
|
597
|
-
CONNECTION_FAILED: "4.1",
|
|
598
|
-
CONNECTION_LOST: "4.2",
|
|
599
|
-
TIMEOUT: "4.2",
|
|
600
|
-
TLS_UNAVAILABLE: "7.10",
|
|
601
|
-
TLS_FAILED: "7.0",
|
|
602
|
-
AUTH_UNAVAILABLE: "7.0",
|
|
603
|
-
INVALID_OPTION: "3.5"
|
|
604
|
-
};
|
|
605
|
-
function diagnosticOfError(error, temporary, max, host) {
|
|
606
|
-
const text = error instanceof Error ? error.message : String(error);
|
|
607
|
-
const detail = isSmtpError(error) ? ERROR_STATUS[error.code] ?? "0.0" : "0.0";
|
|
608
|
-
return {
|
|
609
|
-
status: `${temporary ? 4 : 5}.${detail}`,
|
|
610
|
-
text: cleanText(text, max),
|
|
611
|
-
...host ? { host: cleanText(host, 255) } : {}
|
|
612
|
-
};
|
|
613
|
-
}
|
|
614
|
-
function outcomesOf(result, group, max) {
|
|
615
|
-
const host = result.host;
|
|
616
|
-
const updates = new Map;
|
|
617
|
-
for (const { recipient } of result.accepted) {
|
|
618
|
-
updates.set(recipient, {
|
|
619
|
-
address: recipient,
|
|
620
|
-
status: "delivered",
|
|
621
|
-
reply: diagnosticOf(result.reply, max, host)
|
|
622
|
-
});
|
|
623
|
-
}
|
|
624
|
-
for (const { recipient, reply } of result.rejected) {
|
|
625
|
-
updates.set(recipient, {
|
|
626
|
-
address: recipient,
|
|
627
|
-
status: reply.code >= 500 ? "failed" : "deferred",
|
|
628
|
-
reply: diagnosticOf(reply, max, host)
|
|
629
|
-
});
|
|
630
|
-
}
|
|
631
|
-
return group.map((address) => updates.get(address) ?? {
|
|
632
|
-
address,
|
|
633
|
-
status: "deferred",
|
|
634
|
-
reply: {
|
|
635
|
-
text: "The delivery said nothing of this recipient",
|
|
636
|
-
...host ? { host: cleanText(host, 255) } : {}
|
|
637
|
-
}
|
|
638
|
-
});
|
|
639
|
-
}
|
|
640
|
-
function outcomesOfError(error, group, max, host) {
|
|
641
|
-
const rejected = new Map(isSmtpError(error) ? (error.rejected ?? []).map((r) => [r.recipient, r.reply]) : []);
|
|
642
|
-
const temporary = !isSmtpError(error) || error.temporary || isRouteError(error);
|
|
643
|
-
return group.map((address) => {
|
|
644
|
-
const own = rejected.get(address);
|
|
645
|
-
if (own) {
|
|
646
|
-
return {
|
|
647
|
-
address,
|
|
648
|
-
status: own.code >= 500 ? "failed" : "deferred",
|
|
649
|
-
reply: diagnosticOf(own, max, host)
|
|
650
|
-
};
|
|
651
|
-
}
|
|
652
|
-
const reply = isSmtpError(error) && error.reply ? diagnosticOf(error.reply, max, host) : diagnosticOfError(error, temporary, max, host);
|
|
653
|
-
return { address, status: temporary ? "deferred" : "failed", reply };
|
|
654
|
-
});
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
// src/queue/route.ts
|
|
658
|
-
function routeOf(settings, domain) {
|
|
659
|
-
return settings.routes.get(domain) ?? settings.options.route ?? "mx";
|
|
660
|
-
}
|
|
661
|
-
function hostOf(route) {
|
|
662
|
-
return route === "mx" ? undefined : route.host;
|
|
663
|
-
}
|
|
664
|
-
function sendOptionsOf(settings, domain, from, to) {
|
|
665
|
-
const { options, hostname } = settings;
|
|
666
|
-
const common = {
|
|
667
|
-
from,
|
|
668
|
-
to,
|
|
669
|
-
helo: hostname,
|
|
670
|
-
...options.timeouts ? { timeouts: options.timeouts } : {},
|
|
671
|
-
...options.deadline !== undefined ? { deadline: options.deadline } : {}
|
|
672
|
-
};
|
|
673
|
-
const route = routeOf(settings, domain);
|
|
674
|
-
if (route === "mx") {
|
|
675
|
-
const resolver = options.resolver;
|
|
676
|
-
if (!resolver)
|
|
677
|
-
throw new Error("unreachable: settings check the resolver");
|
|
678
|
-
return {
|
|
679
|
-
...common,
|
|
680
|
-
domain,
|
|
681
|
-
resolver,
|
|
682
|
-
...options.mxPort !== undefined ? { port: options.mxPort } : {},
|
|
683
|
-
...options.mxTls ? { tls: options.mxTls } : {}
|
|
684
|
-
};
|
|
685
|
-
}
|
|
686
|
-
return {
|
|
687
|
-
...common,
|
|
688
|
-
host: route.host,
|
|
689
|
-
...route.port !== undefined ? { port: route.port } : {},
|
|
690
|
-
...route.secure !== undefined ? { secure: route.secure } : {},
|
|
691
|
-
...route.tls ? { tls: route.tls } : {},
|
|
692
|
-
...route.auth ? { auth: route.auth } : {},
|
|
693
|
-
...route.ca ? { ca: route.ca } : {}
|
|
694
|
-
};
|
|
695
|
-
}
|
|
696
|
-
|
|
697
798
|
// src/queue/settle.ts
|
|
698
799
|
function expired(update) {
|
|
699
800
|
return {
|
|
@@ -740,14 +841,6 @@ function groupsOf(item) {
|
|
|
740
841
|
}
|
|
741
842
|
return groups;
|
|
742
843
|
}
|
|
743
|
-
var badAddress = (address) => ({
|
|
744
|
-
address,
|
|
745
|
-
status: "failed",
|
|
746
|
-
reply: {
|
|
747
|
-
status: "5.1.3",
|
|
748
|
-
text: "The address is not one SMTP can carry"
|
|
749
|
-
}
|
|
750
|
-
});
|
|
751
844
|
var badSender = (address) => ({
|
|
752
845
|
address,
|
|
753
846
|
status: "failed",
|
|
@@ -765,35 +858,15 @@ var unreadable = (address) => ({
|
|
|
765
858
|
}
|
|
766
859
|
});
|
|
767
860
|
var unreadableError = (id) => new QueueError2("MESSAGE_UNREADABLE", `The message of ${id} is unreadable: the store holds the item but not its message, so every pending recipient failed`);
|
|
768
|
-
|
|
769
|
-
const { settings } = ctx;
|
|
770
|
-
const max = settings.limits.maxReplyText;
|
|
771
|
-
const bad = recipients.filter((address) => !isMailbox2(address));
|
|
772
|
-
const group = recipients.filter(isMailbox2);
|
|
773
|
-
if (group.length === 0)
|
|
774
|
-
return bad.map(badAddress);
|
|
775
|
-
try {
|
|
776
|
-
const options = sendOptionsOf(settings, domain, item.from, group);
|
|
777
|
-
const result = await settings.send(message, options);
|
|
778
|
-
return [...outcomesOf(result, group, max), ...bad.map(badAddress)];
|
|
779
|
-
} catch (error) {
|
|
780
|
-
if (isRouteError(error))
|
|
781
|
-
ctx.events.emit("error", { error, id: item.id });
|
|
782
|
-
const host = hostOf(routeOf(settings, domain));
|
|
783
|
-
return [
|
|
784
|
-
...outcomesOfError(error, group, max, host),
|
|
785
|
-
...bad.map(badAddress)
|
|
786
|
-
];
|
|
787
|
-
}
|
|
788
|
-
}
|
|
789
|
-
function emitOutcomes(events, item, settled) {
|
|
861
|
+
function emitOutcomes(events, item, settled, used) {
|
|
790
862
|
const { attempts, nextAttemptAt } = settled.result;
|
|
791
863
|
const base = (u) => ({
|
|
792
864
|
id: item.id,
|
|
793
865
|
from: item.from,
|
|
794
866
|
recipient: u.address,
|
|
795
867
|
...u.reply ? { reply: u.reply } : {},
|
|
796
|
-
attempts
|
|
868
|
+
attempts,
|
|
869
|
+
...used.get(u.address)
|
|
797
870
|
});
|
|
798
871
|
for (const u of settled.delivered)
|
|
799
872
|
events.emit("delivered", base(u));
|
|
@@ -810,26 +883,27 @@ async function deliverItem(ctx, item) {
|
|
|
810
883
|
if (await store.get(item.id) === undefined)
|
|
811
884
|
return;
|
|
812
885
|
const failed = [...groupsOf(item).values()].flat().map(unreadable);
|
|
813
|
-
await record(ctx, item, failed, false, undefined);
|
|
886
|
+
await record(ctx, item, failed, false, undefined, new Map);
|
|
814
887
|
return;
|
|
815
888
|
}
|
|
816
889
|
const groups = groupsOf(item);
|
|
817
890
|
let skipped = false;
|
|
818
|
-
const
|
|
891
|
+
const used = new Map;
|
|
892
|
+
const outcomes = item.from !== "" && !isMailbox3(item.from) ? [[...groups.values()].flat().map(badSender)] : await Promise.all([...groups].map(async ([domain, group]) => {
|
|
819
893
|
const release = await ctx.domains.acquire(domain);
|
|
820
894
|
try {
|
|
821
895
|
if (ctx.stopping()) {
|
|
822
896
|
skipped = true;
|
|
823
897
|
return [];
|
|
824
898
|
}
|
|
825
|
-
return await attemptGroup(ctx, item, message, domain, group);
|
|
899
|
+
return await attemptGroup(ctx, item, message, domain, group, used);
|
|
826
900
|
} finally {
|
|
827
901
|
release();
|
|
828
902
|
}
|
|
829
903
|
}));
|
|
830
|
-
await record(ctx, item, outcomes.flat(), skipped, message);
|
|
904
|
+
await record(ctx, item, outcomes.flat(), skipped, message, used);
|
|
831
905
|
}
|
|
832
|
-
async function record(ctx, item, updates, skipped, message) {
|
|
906
|
+
async function record(ctx, item, updates, skipped, message, used) {
|
|
833
907
|
const { settings, store, events } = ctx;
|
|
834
908
|
const now = settings.now();
|
|
835
909
|
const settled = settle(item, updates, skipped, now, settings);
|
|
@@ -843,7 +917,7 @@ async function record(ctx, item, updates, skipped, message) {
|
|
|
843
917
|
}
|
|
844
918
|
if (!message)
|
|
845
919
|
return;
|
|
846
|
-
emitOutcomes(events, item, settled);
|
|
920
|
+
emitOutcomes(events, item, settled, used);
|
|
847
921
|
return;
|
|
848
922
|
}
|
|
849
923
|
if (!after) {
|
|
@@ -854,7 +928,7 @@ async function record(ctx, item, updates, skipped, message) {
|
|
|
854
928
|
if (!message) {
|
|
855
929
|
events.emit("error", { error: unreadableError(item.id), id: item.id });
|
|
856
930
|
}
|
|
857
|
-
emitOutcomes(events, item, settled);
|
|
931
|
+
emitOutcomes(events, item, settled, used);
|
|
858
932
|
await notify(ctx, item, message, "failed", settled.failed, now);
|
|
859
933
|
if (settled.delayDsn) {
|
|
860
934
|
await notify(ctx, item, message, "delayed", settled.deferred, now);
|
|
@@ -1150,5 +1224,5 @@ export {
|
|
|
1150
1224
|
createQueue
|
|
1151
1225
|
};
|
|
1152
1226
|
|
|
1153
|
-
//# debugId=
|
|
1227
|
+
//# debugId=5B8123A1C3FD1B4B64756E2164756E21
|
|
1154
1228
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,30 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/queue/envelope.ts", "../src/queue/events.ts", "../src/queue/settings/index.ts", "../src/queue/settings/numbers.ts", "../src/queue/settings/dsn.ts", "../src/queue/settings/limits.ts", "../src/queue/settings/sessions.ts", "../src/queue/settings/routes.ts", "../src/queue/deliver.ts", "../src/
|
|
3
|
+
"sources": ["../src/queue/envelope.ts", "../src/queue/events.ts", "../src/queue/settings/index.ts", "../src/queue/settings/numbers.ts", "../src/queue/settings/dsn.ts", "../src/queue/settings/limits.ts", "../src/queue/settings/sessions.ts", "../src/queue/settings/routes.ts", "../src/queue/deliver.ts", "../src/queue/attempt.ts", "../src/queue/outcome.ts", "../src/queue/fallback.ts", "../src/queue/route.ts", "../src/dsn/build.ts", "../src/dsn/content.ts", "../src/dsn/fields.ts", "../src/queue/retry.ts", "../src/queue/notify.ts", "../src/queue/settle.ts", "../src/queue/lease.ts", "../src/queue/limiter.ts", "../src/queue/worker.ts", "../src/queue/queue.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"import { isMailbox } from '@bumail/smtp/client';\nimport { invalid, QueueError } from '../errors';\nimport { hasControl } from '../text';\n\n/** What `enqueue` takes as the message: its bytes, its text, or a stream of it. */\nexport type MessageSource = Uint8Array | string | ReadableStream<Uint8Array>;\n\n/** The SMTP envelope of a message to send. */\nexport interface QueueEnvelope {\n\t/** The reverse-path, `local@domain`; `''` for the null sender (a bounce of your own). */\n\treadonly from: string;\n\t/** One recipient or more, `local@domain` each. */\n\treadonly to: string | readonly string[];\n}\n\n/**\n * An address as SMTP carries it: a local part, `@`, a domain, 254\n * characters at most (RFC 5321 §4.5.3.1.3's path, less its brackets), with\n * no space, no control character and no angle bracket, so it can never\n * break a command line or a header field — and one `sendMail` takes\n * (`isMailbox`, RFC 5321's grammar), so it is refused here, never at\n * delivery, where it would fail its whole domain's group.\n */\nconst ADDRESS = /^[^\\s<>]{1,64}@[^\\s<>@]{1,253}$/u;\n\nexport function checkAddress(name: string, address: unknown): string {\n\tif (\n\t\ttypeof address !== 'string' ||\n\t\taddress.length > 254 ||\n\t\thasControl(address) ||\n\t\t!ADDRESS.test(address) ||\n\t\t!isMailbox(address)\n\t) {\n\t\tthrow invalid(\n\t\t\t`${name} must be an address, local@domain, not ${JSON.stringify(address)}`,\n\t\t);\n\t}\n\treturn address;\n}\n\n/** The recipient's domain, in lowercase: what deliveries are grouped by. */\nexport const domainOf = (address: string) =>\n\taddress.slice(address.lastIndexOf('@') + 1).toLowerCase();\n\n/** The envelope, checked: the sender, and each recipient once, at most `maxRecipients`. */\nexport function checkEnvelope(\n\tenvelope: QueueEnvelope,\n\tmaxRecipients: number,\n): { from: string; to: string[] } {\n\tif (typeof envelope !== 'object' || envelope === null) {\n\t\tthrow invalid('The envelope is an object: { from, to }');\n\t}\n\tconst from = envelope.from === '' ? '' : checkAddress('from', envelope.from);\n\tconst list = typeof envelope.to === 'string' ? [envelope.to] : envelope.to;\n\tif (!Array.isArray(list) || list.length === 0) {\n\t\tthrow invalid('to must hold one recipient or more');\n\t}\n\tconst seen = new Set<string>();\n\tconst to: string[] = [];\n\tfor (const address of list) {\n\t\tcheckAddress('Each recipient', address);\n\t\tconst key = `${address.slice(0, address.lastIndexOf('@'))}@${domainOf(address)}`;\n\t\tif (seen.has(key)) continue;\n\t\tseen.add(key);\n\t\tto.push(address);\n\t}\n\tif (to.length > maxRecipients) {\n\t\tthrow new QueueError(\n\t\t\t'TOO_MANY_RECIPIENTS',\n\t\t\t`The message has ${to.length} recipients; the limit is ${maxRecipients}`,\n\t\t);\n\t}\n\treturn { from, to };\n}\n\nconst tooBig = (max: number) =>\n\tnew QueueError(\n\t\t'MESSAGE_TOO_BIG',\n\t\t`The message is larger than the limit of ${max} bytes`,\n\t);\n\nconst CR = 0x0d;\nconst LF = 0x0a;\n\n/**\n * Refuses a message with a CR not followed by an LF, or an LF not after a\n * CR: `sendMail` would refuse it at delivery (`BARE_LINE_BREAK`, SMTP\n * smuggling), failing every recipient.\n */\nexport function checkLineEnds(bytes: Uint8Array): void {\n\tfor (let i = 0; i < bytes.length; i++) {\n\t\tconst byte = bytes[i];\n\t\tconst bare =\n\t\t\tbyte === CR\n\t\t\t\t? bytes[i + 1] !== LF\n\t\t\t\t: byte === LF && (i === 0 || bytes[i - 1] !== CR);\n\t\tif (bare) {\n\t\t\tthrow invalid(\n\t\t\t\t`The message has a bare CR or LF at byte ${i}: every line must end in CRLF`,\n\t\t\t);\n\t\t}\n\t}\n}\n\n/** The message's bytes, read to its end but never past `max`: past it, `MESSAGE_TOO_BIG`. */\nexport async function readMessage(\n\tsource: MessageSource,\n\tmax: number,\n): Promise<Uint8Array> {\n\tif (typeof source === 'string') source = new TextEncoder().encode(source);\n\tif (source instanceof Uint8Array) {\n\t\tif (source.length > max) throw tooBig(max);\n\t\treturn source.slice();\n\t}\n\tif (!(source instanceof ReadableStream)) {\n\t\tthrow invalid(\n\t\t\t'The message is a Uint8Array, a string or a ReadableStream<Uint8Array>',\n\t\t);\n\t}\n\tconst chunks: Uint8Array[] = [];\n\tlet size = 0;\n\tconst reader = source.getReader();\n\ttry {\n\t\tfor (;;) {\n\t\t\tconst { done, value } = await reader.read();\n\t\t\tif (done) break;\n\t\t\tif (!(value instanceof Uint8Array)) {\n\t\t\t\tthrow invalid('The message stream must give Uint8Array chunks');\n\t\t\t}\n\t\t\tsize += value.length;\n\t\t\tif (size > max) throw tooBig(max);\n\t\t\tchunks.push(value);\n\t\t}\n\t} catch (error) {\n\t\tawait reader.cancel().catch(() => {});\n\t\tthrow error;\n\t} finally {\n\t\treader.releaseLock();\n\t}\n\tconst bytes = new Uint8Array(size);\n\tlet at = 0;\n\tfor (const chunk of chunks) {\n\t\tbytes.set(chunk, at);\n\t\tat += chunk.length;\n\t}\n\treturn bytes;\n}\n",
|
|
6
|
-
"import type { Diagnostic } from '../contract/types';\n\n/** One recipient's outcome. */\nexport interface RecipientEvent {\n\t/** The item's id. */\n\treadonly id: string;\n\treadonly from: string;\n\treadonly recipient: string;\n\t/** What the other side said, or why nobody said anything. */\n\treadonly reply?: Diagnostic;\n\t/** The attempts made so far, this one included. */\n\treadonly attempts: number;\n}\n\nexport interface DeferredEvent extends RecipientEvent {\n\t/** When the recipient is tried again, in milliseconds since the epoch. */\n\treadonly nextAttemptAt: number;\n}\n\n/** A DSN, enqueued back to the sender. */\nexport interface DsnEvent {\n\treadonly kind: 'delayed' | 'failed';\n\t/** The DSN's own item id. */\n\treadonly id: string;\n\t/** The id of the item it reports on. */\n\treadonly of: string;\n\t/** The original's sender, to whom it goes. */\n\treadonly to: string;\n\treadonly recipients: readonly string[];\n}\n\n/** A failure of the queue itself: the store, a DSN that could not be enqueued, a lease lost. */\nexport interface QueueErrorEvent {\n\treadonly error: unknown;\n\t/** The item it happened to, if any. */\n\treadonly id?: string;\n}\n\nexport interface QueueEvents {\n\tdelivered: RecipientEvent;\n\tdeferred: DeferredEvent;\n\tfailed: RecipientEvent;\n\tdsn: DsnEvent;\n\terror: QueueErrorEvent;\n}\n\nexport type QueueListener<E extends keyof QueueEvents> = (\n\tevent: QueueEvents[E],\n) => void;\n\n/** Listeners by event. One that throws is ignored: it never stops a delivery. */\nexport class Events {\n\treadonly #listeners = new Map<keyof QueueEvents, Set<(e: never) => void>>();\n\n\ton<E extends keyof QueueEvents>(\n\t\tevent: E,\n\t\tlistener: QueueListener<E>,\n\t): () => void {\n\t\tlet set = this.#listeners.get(event);\n\t\tif (!set) {\n\t\t\tset = new Set();\n\t\t\tthis.#listeners.set(event, set);\n\t\t}\n\t\tset.add(listener as (e: never) => void);\n\t\treturn () => {\n\t\t\tset.delete(listener as (e: never) => void);\n\t\t};\n\t}\n\n\temit<E extends keyof QueueEvents>(event: E, payload: QueueEvents[E]): void {\n\t\tfor (const listener of this.#listeners.get(event) ?? []) {\n\t\t\ttry {\n\t\t\t\t(listener as QueueListener<E>)(payload);\n\t\t\t} catch {\n\t\t\t\t// A listener's failure is its own.\n\t\t\t}\n\t\t}\n\t}\n}\n",
|
|
6
|
+
"import type { Diagnostic } from '../contract/types';\n\n/** One recipient's outcome. */\nexport interface RecipientEvent {\n\t/** The item's id. */\n\treadonly id: string;\n\treadonly from: string;\n\treadonly recipient: string;\n\t/** What the other side said, or why nobody said anything. */\n\treadonly reply?: Diagnostic;\n\t/** The attempts made so far, this one included. */\n\treadonly attempts: number;\n\t/**\n\t * The route of this recipient's last session: `'mx'`, or `'smarthost'`\n\t * for a smarthost, a host of a route, or the fallback.\n\t */\n\treadonly route?: 'mx' | 'smarthost';\n\t/** `true` when that session was the fallback, after the one by MX failed. */\n\treadonly fallback?: true;\n\t/**\n\t * With `fallback`, what the MX side said (or why nobody said anything)\n\t * before the smarthost took over: `reply` is the smarthost's.\n\t */\n\treadonly mxReply?: Diagnostic;\n}\n\nexport interface DeferredEvent extends RecipientEvent {\n\t/** When the recipient is tried again, in milliseconds since the epoch. */\n\treadonly nextAttemptAt: number;\n}\n\n/** A DSN, enqueued back to the sender. */\nexport interface DsnEvent {\n\treadonly kind: 'delayed' | 'failed';\n\t/** The DSN's own item id. */\n\treadonly id: string;\n\t/** The id of the item it reports on. */\n\treadonly of: string;\n\t/** The original's sender, to whom it goes. */\n\treadonly to: string;\n\treadonly recipients: readonly string[];\n}\n\n/** A failure of the queue itself: the store, a DSN that could not be enqueued, a lease lost. */\nexport interface QueueErrorEvent {\n\treadonly error: unknown;\n\t/** The item it happened to, if any. */\n\treadonly id?: string;\n}\n\nexport interface QueueEvents {\n\tdelivered: RecipientEvent;\n\tdeferred: DeferredEvent;\n\tfailed: RecipientEvent;\n\tdsn: DsnEvent;\n\terror: QueueErrorEvent;\n}\n\nexport type QueueListener<E extends keyof QueueEvents> = (\n\tevent: QueueEvents[E],\n) => void;\n\n/** Listeners by event. One that throws is ignored: it never stops a delivery. */\nexport class Events {\n\treadonly #listeners = new Map<keyof QueueEvents, Set<(e: never) => void>>();\n\n\ton<E extends keyof QueueEvents>(\n\t\tevent: E,\n\t\tlistener: QueueListener<E>,\n\t): () => void {\n\t\tlet set = this.#listeners.get(event);\n\t\tif (!set) {\n\t\t\tset = new Set();\n\t\t\tthis.#listeners.set(event, set);\n\t\t}\n\t\tset.add(listener as (e: never) => void);\n\t\treturn () => {\n\t\t\tset.delete(listener as (e: never) => void);\n\t\t};\n\t}\n\n\temit<E extends keyof QueueEvents>(event: E, payload: QueueEvents[E]): void {\n\t\tfor (const listener of this.#listeners.get(event) ?? []) {\n\t\t\ttry {\n\t\t\t\t(listener as QueueListener<E>)(payload);\n\t\t\t} catch {\n\t\t\t\t// A listener's failure is its own.\n\t\t\t}\n\t\t}\n\t}\n}\n",
|
|
7
7
|
"import { sendMail } from '@bumail/smtp/client';\nimport { checkOwner } from '../../contract/checks';\nimport { invalid } from '../../errors';\nimport type { QueueOptions, Route, Sender } from '../options';\nimport { type DsnSettings, dsnOf } from './dsn';\nimport {\n\ttype LimitSettings,\n\tlimitsOf,\n\ttype RetrySettings,\n\tretryOf,\n} from './limits';\nimport { MAX_TIMER, MINUTE, numberOf } from './numbers';\nimport { checkRoutes } from './routes';\nimport { checkSessions } from './sessions';\n\nexport type { DsnSettings, LimitSettings, RetrySettings };\n\n/** Every option checked, with its default. */\nexport interface Settings {\n\treadonly options: QueueOptions;\n\treadonly hostname: string;\n\t/** The routes by domain, in lowercase. */\n\treadonly routes: ReadonlyMap<string, Route>;\n\treadonly retry: RetrySettings;\n\treadonly limits: LimitSettings;\n\treadonly dsn: DsnSettings;\n\treadonly concurrency: number;\n\treadonly perDomain: number;\n\treadonly leaseMs: number;\n\treadonly pollInterval: number;\n\treadonly owner: string;\n\treadonly now: () => number;\n\treadonly send: Sender;\n\treadonly random: () => number;\n}\n\nconst HOSTNAME =\n\t/^(?=.{1,253}$)[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?(?:\\.[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?)*$/;\n\n/** The options, checked, with their defaults; `INVALID` names the first wrong one. */\nexport function settingsOf(options: QueueOptions): Settings {\n\tif (typeof options !== 'object' || options === null) {\n\t\tthrow invalid('createQueue() takes an options object');\n\t}\n\tif (typeof options.store?.claim !== 'function') {\n\t\tthrow invalid('store must be a QueueStore, such as MemoryQueueStore');\n\t}\n\tconst { hostname } = options;\n\tif (typeof hostname !== 'string' || !HOSTNAME.test(hostname)) {\n\t\tthrow invalid(\n\t\t\t`hostname must be this server's public host name, not ${hostname}`,\n\t\t);\n\t}\n\tcheckRoutes(options);\n\tcheckSessions(options);\n\tconst owner = checkOwner(options.owner ?? crypto.randomUUID());\n\tconst clock = options.clock;\n\treturn {\n\t\toptions,\n\t\thostname,\n\t\troutes: new Map(\n\t\t\tObject.entries(options.routes ?? {}).map(([d, r]) => [\n\t\t\t\td.toLowerCase(),\n\t\t\t\tr,\n\t\t\t]),\n\t\t),\n\t\tretry: retryOf(options),\n\t\tlimits: limitsOf(options),\n\t\tdsn: dsnOf(options, hostname),\n\t\tconcurrency: numberOf('concurrency', options.concurrency, 20, 1),\n\t\tperDomain: numberOf('perDomain', options.perDomain, 2, 1),\n\t\tleaseMs: numberOf(\n\t\t\t'leaseMs',\n\t\t\toptions.leaseMs,\n\t\t\t10 * MINUTE,\n\t\t\t1000,\n\t\t\t3 * MAX_TIMER,\n\t\t),\n\t\tpollInterval: numberOf(\n\t\t\t'pollInterval',\n\t\t\toptions.pollInterval,\n\t\t\t5000,\n\t\t\t1,\n\t\t\tMAX_TIMER,\n\t\t),\n\t\towner,\n\t\tnow: clock ? () => clock.now() : Date.now,\n\t\tsend: options.send ?? sendMail,\n\t\trandom: options.random ?? Math.random,\n\t};\n}\n",
|
|
8
8
|
"import { invalid } from '../../errors';\n\nexport const MINUTE = 60_000;\nexport const HOUR = 60 * MINUTE;\n/** The longest delay a timer takes: past it, Bun fires after 1 ms. */\nexport const MAX_TIMER = 2_147_483_647;\n\n/** A number in `[min, max]`, integer when asked, or its default. */\nexport function numberOf(\n\tname: string,\n\tvalue: unknown,\n\tfallback: number,\n\tmin: number,\n\tmax = Number.MAX_SAFE_INTEGER,\n\tinteger = true,\n): number {\n\tif (value === undefined) return fallback;\n\tconst ok =\n\t\ttypeof value === 'number' &&\n\t\t(integer ? Number.isInteger(value) : Number.isFinite(value)) &&\n\t\tvalue >= min &&\n\t\tvalue <= max;\n\tif (!ok) {\n\t\tconst kind = integer ? 'an integer' : 'a number';\n\t\tconst range =\n\t\t\tmax === Number.MAX_SAFE_INTEGER\n\t\t\t\t? `of at least ${min}`\n\t\t\t\t: `from ${min} to ${max}`;\n\t\tthrow invalid(`${name} must be ${kind} ${range}, not ${value}`);\n\t}\n\treturn value as number;\n}\n",
|
|
9
9
|
"import { invalid } from '../../errors';\nimport { checkAddress } from '../envelope';\nimport type { QueueOptions } from '../options';\nimport { HOUR, numberOf } from './numbers';\n\nexport interface DsnSettings {\n\treadonly from: string;\n\treadonly delayAfter: number | false;\n\treadonly returnContent: 'headers' | 'full';\n}\n\nexport function dsnOf(options: QueueOptions, hostname: string): DsnSettings {\n\tconst d = options.dsn ?? {};\n\tconst from = checkAddress('dsn.from', d.from ?? `postmaster@${hostname}`);\n\tconst delayAfter =\n\t\td.delayAfter === false\n\t\t\t? false\n\t\t\t: numberOf('dsn.delayAfter', d.delayAfter, 4 * HOUR, 0);\n\tconst returnContent = d.returnContent ?? 'headers';\n\tif (returnContent !== 'headers' && returnContent !== 'full') {\n\t\tthrow invalid(\n\t\t\t`dsn.returnContent must be 'headers' or 'full', not ${returnContent}`,\n\t\t);\n\t}\n\treturn { from, delayAfter, returnContent };\n}\n",
|
|
10
10
|
"import type { QueueOptions } from '../options';\nimport { HOUR, MINUTE, numberOf } from './numbers';\n\nexport interface RetrySettings {\n\treadonly first: number;\n\treadonly factor: number;\n\treadonly max: number;\n\treadonly jitter: number;\n\treadonly giveUpAfter: number;\n}\n\nexport interface LimitSettings {\n\treadonly maxMessageSize: number;\n\treadonly maxRecipients: number;\n\treadonly maxItems: number | undefined;\n\treadonly maxReplyText: number;\n\treadonly maxDsnReturn: number;\n}\n\nexport function retryOf(options: QueueOptions): RetrySettings {\n\tconst r = options.retry ?? {};\n\tconst first = numberOf('retry.first', r.first, 30 * MINUTE, 1);\n\treturn {\n\t\tfirst,\n\t\tfactor: numberOf('retry.factor', r.factor, 2, 1, 100, false),\n\t\tmax: numberOf('retry.max', r.max, Math.max(first, 4 * HOUR), first),\n\t\tjitter: numberOf('retry.jitter', r.jitter, 0.1, 0, 1, false),\n\t\tgiveUpAfter: numberOf('retry.giveUpAfter', r.giveUpAfter, 120 * HOUR, 0),\n\t};\n}\n\nexport function limitsOf(options: QueueOptions): LimitSettings {\n\tconst l = options.limits ?? {};\n\treturn {\n\t\tmaxMessageSize: numberOf(\n\t\t\t'limits.maxMessageSize',\n\t\t\tl.maxMessageSize,\n\t\t\t25 * 1024 * 1024,\n\t\t\t1,\n\t\t),\n\t\tmaxRecipients: numberOf('limits.maxRecipients', l.maxRecipients, 100, 1),\n\t\tmaxItems:\n\t\t\tl.maxItems === undefined\n\t\t\t\t? undefined\n\t\t\t\t: numberOf('limits.maxItems', l.maxItems, 0, 1),\n\t\tmaxReplyText: numberOf('limits.maxReplyText', l.maxReplyText, 512, 64, 900),\n\t\tmaxDsnReturn: numberOf('limits.maxDsnReturn', l.maxDsnReturn, 64 * 1024, 0),\n\t};\n}\n",
|
|
11
11
|
"import { invalid } from '../../errors';\nimport type { QueueOptions } from '../options';\nimport { MAX_TIMER, numberOf } from './numbers';\n\n/** The longest wait `sendMail` takes, in seconds: its timer's own limit. */\nconst MAX_SECONDS = Math.floor(MAX_TIMER / 1000);\n\nfunction checkSeconds(name: string, value: unknown): void {\n\tif (value === undefined) return;\n\tif (\n\t\ttypeof value !== 'number' ||\n\t\t!Number.isFinite(value) ||\n\t\tvalue <= 0 ||\n\t\tvalue > MAX_SECONDS\n\t) {\n\t\tthrow invalid(\n\t\t\t`${name} must be a number of seconds above 0 and at most ${MAX_SECONDS}, not ${value}`,\n\t\t);\n\t}\n}\n\nexport function checkTls(name: string, tls: unknown): void {\n\tif (\n\t\ttls !== undefined &&\n\t\ttls !== 'opportunistic' &&\n\t\ttls !== 'required' &&\n\t\ttls !== 'none'\n\t) {\n\t\tthrow invalid(\n\t\t\t`${name} must be 'opportunistic', 'required' or 'none', not ${tls}`,\n\t\t);\n\t}\n}\n\n/** What every session takes, whatever its route: the MX port and TLS, the timeouts. */\nexport function checkSessions(options: QueueOptions): void {\n\tnumberOf('mxPort', options.mxPort, 25, 1, 65535);\n\tcheckTls('mxTls', options.mxTls);\n\tconst timeouts = options.timeouts;\n\tif (timeouts !== undefined) {\n\t\tif (typeof timeouts !== 'object' || timeouts === null) {\n\t\t\tthrow invalid('timeouts must be an object of seconds');\n\t\t}\n\t\tfor (const [step, value] of Object.entries(timeouts)) {\n\t\t\tcheckSeconds(`timeouts.${step}`, value);\n\t\t}\n\t}\n\tcheckSeconds('deadline', options.deadline);\n}\n",
|
|
12
|
-
"import { invalid } from '../../errors';\nimport type { QueueOptions, Route, Smarthost } from '../options';\nimport { numberOf } from './numbers';\nimport { checkTls } from './sessions';\n\n/**\n * A smarthost `sendMail` will take, checked now rather than at each\n * delivery: a host, a port, a TLS mode, and credentials only over TLS\n * whose certificate is checked — `sendMail`'s own rule\n * (`@bumail/smtp`'s `client/settings.ts`), with no way out for a test.\n */\nfunction checkRoute(name: string, route: Route): void {\n\tif (route === 'mx') return;\n\tconst smarthost = route as Smarthost | undefined;\n\tconst host = smarthost?.host;\n\tif (typeof host !== 'string' || !/^[^\\s/]+$/.test(host)) {\n\t\tthrow invalid(`${name} must be 'mx' or a smarthost with a host`);\n\t}\n\tconst { port, secure, tls, auth } = smarthost as Smarthost;\n\tnumberOf(`${name}.port`, port, 25, 1, 65535);\n\tif (secure !== undefined && typeof secure !== 'boolean') {\n\t\tthrow invalid(`${name}.secure must be true or false, not ${secure}`);\n\t}\n\tcheckTls(`${name}.tls`, tls);\n\tif (tls === 'none' && secure) {\n\t\tthrow invalid(\n\t\t\t`${name}.secure is TLS from the first byte: it cannot go with tls: 'none'`,\n\t\t);\n\t}\n\tif (auth === undefined) return;\n\tif (typeof auth?.username !== 'string' || auth.username === '') {\n\t\tthrow invalid(`${name}.auth.username must be a non-empty string`);\n\t}\n\tif (typeof auth.password !== 'string' || auth.password === '') {\n\t\tthrow invalid(`${name}.auth.password must be a non-empty string`);\n\t}\n\tconst { mechanism } = auth;\n\tif (\n\t\tmechanism !== undefined &&\n\t\tmechanism !== 'PLAIN' &&\n\t\tmechanism !== 'LOGIN'\n\t) {\n\t\tthrow invalid(\n\t\t\t`${name}.auth.mechanism must be 'PLAIN' or 'LOGIN', not ${mechanism}`,\n\t\t);\n\t}\n\tif (tls !== undefined && tls !== 'required') {\n\t\tthrow invalid(\n\t\t\t`${name}.auth needs tls: 'required', the default with auth: with tls: '${tls}' the password would go to a server whose certificate is not checked`,\n\t\t);\n\t}\n}\n\nexport function checkRoutes(options: QueueOptions): void {\n\tcheckRoute('route', options.route ?? 'mx');\n\tconst routes = Object.entries(options.routes ?? {});\n\tfor (const [domain, route] of routes)\n\t\tcheckRoute(`routes[\"${domain}\"]`, route);\n\tconst usesMx =\n\t\t(options.route ?? 'mx') === 'mx' || routes.some(([, r]) => r === 'mx');\n\tif (usesMx && typeof options.resolver?.mx !== 'function') {\n\t\tthrow invalid(\n\t\t\t\"The 'mx' route needs a resolver, such as @bumail/dns's nodeResolver()\",\n\t\t);\n\t}\n}\n",
|
|
13
|
-
"import { isMailbox } from '@bumail/smtp/client';\nimport type { QueueItem, RecipientUpdate } from '../contract/types';\nimport { QueueError } from '../errors';\nimport {
|
|
12
|
+
"import { invalid } from '../../errors';\nimport type { QueueOptions, Route, Smarthost } from '../options';\nimport { numberOf } from './numbers';\nimport { checkTls } from './sessions';\n\n/**\n * A smarthost `sendMail` will take, checked now rather than at each\n * delivery: a host, a port, a TLS mode, and credentials only over TLS\n * whose certificate is checked — `sendMail`'s own rule\n * (`@bumail/smtp`'s `client/settings.ts`), with no way out for a test.\n */\nfunction checkRoute(name: string, route: Route): void {\n\tif (route === 'mx') return;\n\tconst smarthost = route as Smarthost | undefined;\n\tconst host = smarthost?.host;\n\tif (typeof host !== 'string' || !/^[^\\s/]+$/.test(host)) {\n\t\tthrow invalid(`${name} must be 'mx' or a smarthost with a host`);\n\t}\n\tconst { port, secure, tls, auth } = smarthost as Smarthost;\n\tnumberOf(`${name}.port`, port, 25, 1, 65535);\n\tif (secure !== undefined && typeof secure !== 'boolean') {\n\t\tthrow invalid(`${name}.secure must be true or false, not ${secure}`);\n\t}\n\tcheckTls(`${name}.tls`, tls);\n\tif (tls === 'none' && secure) {\n\t\tthrow invalid(\n\t\t\t`${name}.secure is TLS from the first byte: it cannot go with tls: 'none'`,\n\t\t);\n\t}\n\tif (auth === undefined) return;\n\tif (typeof auth?.username !== 'string' || auth.username === '') {\n\t\tthrow invalid(`${name}.auth.username must be a non-empty string`);\n\t}\n\tif (typeof auth.password !== 'string' || auth.password === '') {\n\t\tthrow invalid(`${name}.auth.password must be a non-empty string`);\n\t}\n\tconst { mechanism } = auth;\n\tif (\n\t\tmechanism !== undefined &&\n\t\tmechanism !== 'PLAIN' &&\n\t\tmechanism !== 'LOGIN'\n\t) {\n\t\tthrow invalid(\n\t\t\t`${name}.auth.mechanism must be 'PLAIN' or 'LOGIN', not ${mechanism}`,\n\t\t);\n\t}\n\tif (tls !== undefined && tls !== 'required') {\n\t\tthrow invalid(\n\t\t\t`${name}.auth needs tls: 'required', the default with auth: with tls: '${tls}' the password would go to a server whose certificate is not checked`,\n\t\t);\n\t}\n}\n\nexport function checkRoutes(options: QueueOptions): void {\n\tif (options.fallback !== undefined) {\n\t\tconst fallback = options.fallback as Route | null;\n\t\tif (\n\t\t\ttypeof fallback !== 'object' ||\n\t\t\tfallback === null ||\n\t\t\ttypeof fallback.host !== 'string'\n\t\t) {\n\t\t\tthrow invalid(\n\t\t\t\t'fallback must be a smarthost with a host, not an mx route',\n\t\t\t);\n\t\t}\n\t\tcheckRoute('fallback', fallback);\n\t}\n\tcheckRoute('route', options.route ?? 'mx');\n\tconst routes = Object.entries(options.routes ?? {});\n\tfor (const [domain, route] of routes)\n\t\tcheckRoute(`routes[\"${domain}\"]`, route);\n\tconst usesMx =\n\t\t(options.route ?? 'mx') === 'mx' || routes.some(([, r]) => r === 'mx');\n\tif (usesMx && typeof options.resolver?.mx !== 'function') {\n\t\tthrow invalid(\n\t\t\t\"The 'mx' route needs a resolver, such as @bumail/dns's nodeResolver()\",\n\t\t);\n\t}\n}\n",
|
|
13
|
+
"import { isMailbox } from '@bumail/smtp/client';\nimport type { QueueItem, RecipientUpdate } from '../contract/types';\nimport { QueueError } from '../errors';\nimport { attemptGroup, type Used } from './attempt';\nimport { domainOf } from './envelope';\nimport type { Events } from './events';\nimport type { Lapse } from './lease';\nimport type { KeyedLimiter } from './limiter';\nimport { type NotifyContext, notify } from './notify';\nimport { type Settled, settle } from './settle';\n\nexport interface DeliveryContext extends NotifyContext {\n\treadonly domains: KeyedLimiter;\n\treadonly events: Events;\n\t/** The worker is stopping: a group not started yet is left for later. */\n\treadonly stopping: () => boolean;\n\t/** The outcome is recorded: the lease needs no more renewal. */\n\treadonly recorded: () => void;\n\t/**\n\t * Whether the lease could have passed to another worker by `now`: a\n\t * renewal found it taken, or its last expiry is past. `undefined` while\n\t * it surely held.\n\t */\n\treadonly leaseLapsed: (now: number) => Promise<Lapse | undefined>;\n}\n\n/**\n * Said when the item is gone at `complete` and the lease had lapsed. With\n * no record of who removed it, neither case can tell another worker that\n * finished it from a cancel, so each names both; either way what this\n * worker sent may have been sent again, and it reports no outcome.\n */\nconst goneAfter = (lapse: Lapse, id: string): QueueError =>\n\tnew QueueError(\n\t\t'LEASE_LOST',\n\t\tlapse === 'taken'\n\t\t\t? `The lease on ${id} was lost while it was delivered, and the item is gone: finished by the worker that took it, the message then sent twice, or cancelled`\n\t\t\t: `The lease on ${id} expired before its outcome was recorded, and the item is gone: lost to another worker that finished it, the message then sent twice, or cancelled`,\n\t);\n\n/** The recipients still to deliver, by domain. */\nfunction groupsOf(item: QueueItem): Map<string, string[]> {\n\tconst groups = new Map<string, string[]>();\n\tfor (const r of item.recipients) {\n\t\tif (r.status === 'delivered' || r.status === 'failed') continue;\n\t\tconst domain = domainOf(r.address);\n\t\tconst group = groups.get(domain);\n\t\tif (group) group.push(r.address);\n\t\telse groups.set(domain, [r.address]);\n\t}\n\treturn groups;\n}\n\n/**\n * Every recipient of an item whose sender `sendMail` would refuse — kept\n * by a store written to by other code, since `enqueue` refuses it — fails\n * at once, as X.1.7 (bad sender's mailbox address syntax), rather than be\n * deferred on every attempt until `retry.giveUpAfter`.\n */\nconst badSender = (address: string): RecipientUpdate => ({\n\taddress,\n\tstatus: 'failed',\n\treply: {\n\t\tstatus: '5.1.7',\n\t\ttext: \"The sender's address is not one SMTP can carry\",\n\t},\n});\n\n/**\n * A pending recipient of an item whose message the store no longer gives\n * — a Redis key evicted or deleted, a row removed by hand — fails at once,\n * as X.3.0 (mail system status): no session can send what cannot be read,\n * and an attempt left without an outcome would be claimed again at every\n * lease, forever, keeping its `maxItems` place.\n */\nconst unreadable = (address: string): RecipientUpdate => ({\n\taddress,\n\tstatus: 'failed',\n\treply: {\n\t\tstatus: '5.3.0',\n\t\ttext: 'Message unreadable: the queue store holds the item but not its message',\n\t},\n});\n\nconst unreadableError = (id: string): QueueError =>\n\tnew QueueError(\n\t\t'MESSAGE_UNREADABLE',\n\t\t`The message of ${id} is unreadable: the store holds the item but not its message, so every pending recipient failed`,\n\t);\n\n/** Tells the listeners each recipient's outcome. */\nfunction emitOutcomes(\n\tevents: Events,\n\titem: QueueItem,\n\tsettled: Settled,\n\tused: ReadonlyMap<string, Used>,\n): void {\n\tconst { attempts, nextAttemptAt } = settled.result;\n\tconst base = (u: RecipientUpdate) => ({\n\t\tid: item.id,\n\t\tfrom: item.from,\n\t\trecipient: u.address,\n\t\t...(u.reply ? { reply: u.reply } : {}),\n\t\tattempts,\n\t\t...used.get(u.address),\n\t});\n\tfor (const u of settled.delivered) events.emit('delivered', base(u));\n\tfor (const u of settled.deferred) {\n\t\tevents.emit('deferred', { ...base(u), nextAttemptAt });\n\t}\n\tfor (const u of settled.failed) events.emit('failed', base(u));\n}\n\n/**\n * Delivers a claimed item: one session per recipient domain, at most\n * `perDomain` at once to each — none, and no slot taken, when its sender\n * is one `sendMail` would refuse — then the outcome recorded — which lets go\n * of the lease — then the events and the DSNs. An item whose message the\n * store no longer gives fails every pending recipient, said on the `error`\n * event, its DSN without the original.\n */\nexport async function deliverItem(\n\tctx: DeliveryContext,\n\titem: QueueItem,\n): Promise<void> {\n\tconst { store } = ctx;\n\tconst message = await store.readMessage(item.id);\n\tif (!message) {\n\t\t// Gone with its message: cancelled, or finished by another worker.\n\t\tif ((await store.get(item.id)) === undefined) return;\n\t\tconst failed = [...groupsOf(item).values()].flat().map(unreadable);\n\t\tawait record(ctx, item, failed, false, undefined, new Map());\n\t\treturn;\n\t}\n\tconst groups = groupsOf(item);\n\tlet skipped = false;\n\tconst used = new Map<string, Used>();\n\t// A sender sendMail would refuse: no session, no slot, every recipient at once.\n\tconst outcomes =\n\t\titem.from !== '' && !isMailbox(item.from)\n\t\t\t? [[...groups.values()].flat().map(badSender)]\n\t\t\t: await Promise.all(\n\t\t\t\t\t[...groups].map(async ([domain, group]) => {\n\t\t\t\t\t\tconst release = await ctx.domains.acquire(domain);\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tif (ctx.stopping()) {\n\t\t\t\t\t\t\t\tskipped = true;\n\t\t\t\t\t\t\t\treturn [];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn await attemptGroup(\n\t\t\t\t\t\t\t\tctx,\n\t\t\t\t\t\t\t\titem,\n\t\t\t\t\t\t\t\tmessage,\n\t\t\t\t\t\t\t\tdomain,\n\t\t\t\t\t\t\t\tgroup,\n\t\t\t\t\t\t\t\tused,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} finally {\n\t\t\t\t\t\t\trelease();\n\t\t\t\t\t\t}\n\t\t\t\t\t}),\n\t\t\t\t);\n\tawait record(ctx, item, outcomes.flat(), skipped, message, used);\n}\n\n/**\n * Records an attempt's outcomes — which lets go of the lease — then tells\n * the events and sends the DSNs, the original returned when there is one.\n * With no `message` (the store lost it), the `MESSAGE_UNREADABLE` error\n * comes first of the events, and only once the failures are recorded: a\n * lease lost meanwhile, or a `complete` that throws, says nothing of them,\n * and an item cancelled meanwhile tells nothing at all.\n */\nasync function record(\n\tctx: DeliveryContext,\n\titem: QueueItem,\n\tupdates: readonly RecipientUpdate[],\n\tskipped: boolean,\n\tmessage: Uint8Array | undefined,\n\tused: ReadonlyMap<string, Used>,\n): Promise<void> {\n\tconst { settings, store, events } = ctx;\n\tconst now = settings.now();\n\tconst settled = settle(item, updates, skipped, now, settings);\n\tconst after = await store.complete(item.id, settings.owner, settled.result);\n\tctx.recorded();\n\tif (!after && (await store.get(item.id)) === undefined) {\n\t\tconst lapse = await ctx.leaseLapsed(now);\n\t\tif (lapse) {\n\t\t\t// Lost or cancelled: no outcome told, as when the item is still there.\n\t\t\tevents.emit('error', { error: goneAfter(lapse, item.id), id: item.id });\n\t\t\treturn;\n\t\t}\n\t\t// Cancelled under a lease that held, with no session for a lost\n\t\t// message: nothing happened, and nothing was recorded, so nothing is told.\n\t\tif (!message) return;\n\t\t// Otherwise what the sessions did still happened; no DSN.\n\t\temitOutcomes(events, item, settled, used);\n\t\treturn;\n\t}\n\tif (!after) {\n\t\tconst error = new QueueError(\n\t\t\t'LEASE_LOST',\n\t\t\t`The lease on ${item.id} was lost before its outcome was recorded; another worker will try it again`,\n\t\t);\n\t\tevents.emit('error', { error, id: item.id });\n\t\treturn;\n\t}\n\tif (!message) {\n\t\tevents.emit('error', { error: unreadableError(item.id), id: item.id });\n\t}\n\temitOutcomes(events, item, settled, used);\n\tawait notify(ctx, item, message, 'failed', settled.failed, now);\n\tif (settled.delayDsn) {\n\t\tawait notify(ctx, item, message, 'delayed', settled.deferred, now);\n\t}\n}\n",
|
|
14
|
+
"import { isMailbox } from '@bumail/smtp/client';\nimport type { QueueItem, RecipientUpdate } from '../contract/types';\nimport type { DeliveryContext } from './deliver';\nimport type { RecipientEvent } from './events';\nimport { fallsBack } from './fallback';\nimport type { Route } from './options';\nimport { isRouteError, outcomesOf, outcomesOfError } from './outcome';\nimport { hostOf, routeOf, sendOptionsOf } from './route';\n\n/**\n * A recipient `sendMail` would refuse — kept by a store written to by\n * other code, since `enqueue` refuses it — fails alone, as X.1.3 (bad\n * destination mailbox address syntax), so the session for its domain\n * still goes ahead for the others.\n */\nconst badAddress = (address: string): RecipientUpdate => ({\n\taddress,\n\tstatus: 'failed',\n\treply: {\n\t\tstatus: '5.1.3',\n\t\ttext: 'The address is not one SMTP can carry',\n\t},\n});\n\n/** The route a recipient's last session took, as its events tell it. */\nexport type Used = Pick<RecipientEvent, 'route' | 'fallback' | 'mxReply'>;\n\n/** One session's outcomes, and the error that ended it, if any. */\ninterface Attempt {\n\treadonly updates: RecipientUpdate[];\n\treadonly error?: unknown;\n}\n\n/** One session, by `route` (the domain's own when none is given): each recipient's outcome, whatever happened. */\nasync function session(\n\tctx: DeliveryContext,\n\titem: QueueItem,\n\tmessage: Uint8Array,\n\tdomain: string,\n\tgroup: readonly string[],\n\troute: Route,\n\toverride?: Route,\n): Promise<Attempt> {\n\tconst { settings } = ctx;\n\tconst max = settings.limits.maxReplyText;\n\ttry {\n\t\tconst options = sendOptionsOf(settings, domain, item.from, group, override);\n\t\tconst result = await settings.send(message, options);\n\t\treturn { updates: outcomesOf(result, group, max) };\n\t} catch (error) {\n\t\t// A route sendMail cannot use is the operator's to fix: said, and retried.\n\t\tif (isRouteError(error)) ctx.events.emit('error', { error, id: item.id });\n\t\treturn {\n\t\t\tupdates: outcomesOfError(error, group, max, hostOf(route)),\n\t\t\terror,\n\t\t};\n\t}\n}\n\n/**\n * What a recipient becomes once the fallback answered for its MX outcome.\n * The fallback decides when it delivered, or when the MX refused for good\n * (a `5.7.x`). A smarthost that refuses what the MX only deferred (a bad\n * password, a sender it does not allow) leaves the recipient deferred, with\n * the smarthost's reply as the diagnostic: no DSN, tried again later.\n */\nfunction merged(mx: RecipientUpdate, fb: RecipientUpdate): RecipientUpdate {\n\tif (mx.status === 'deferred' && fb.status === 'failed') {\n\t\treturn { ...fb, status: 'deferred' };\n\t}\n\treturn fb;\n}\n\n/**\n * One delivery for one domain's recipients: each one's outcome, whatever\n * happened, and in `used` the route each took. By MX with a `fallback`,\n * the recipients whose outcome is a connection failure, a timeout or a\n * reputation refusal (`fallsBack`) go at once to the fallback smarthost,\n * in a session of their own, and its outcome replaces the first (`merged`).\n */\nexport async function attemptGroup(\n\tctx: DeliveryContext,\n\titem: QueueItem,\n\tmessage: Uint8Array,\n\tdomain: string,\n\trecipients: readonly string[],\n\tused: Map<string, Used>,\n): Promise<RecipientUpdate[]> {\n\tconst { settings } = ctx;\n\tconst bad = recipients.filter((address) => !isMailbox(address));\n\tconst group = recipients.filter(isMailbox);\n\tif (group.length === 0) return bad.map(badAddress);\n\tconst route = routeOf(settings, domain);\n\tconst label = route === 'mx' ? 'mx' : 'smarthost';\n\tfor (const address of group) used.set(address, { route: label });\n\tconst first = await session(ctx, item, message, domain, group, route);\n\tlet updates = first.updates;\n\tconst { fallback } = settings.options;\n\tif (fallback !== undefined && route === 'mx') {\n\t\tconst mx = new Map(\n\t\t\tupdates\n\t\t\t\t.filter(\n\t\t\t\t\t(u) => u.status !== 'delivered' && fallsBack(u.reply, first.error),\n\t\t\t\t)\n\t\t\t\t.map((u) => [u.address, u]),\n\t\t);\n\t\tif (mx.size > 0) {\n\t\t\tconst again = [...mx.keys()];\n\t\t\tconst second = await session(\n\t\t\t\tctx,\n\t\t\t\titem,\n\t\t\t\tmessage,\n\t\t\t\tdomain,\n\t\t\t\tagain,\n\t\t\t\tfallback,\n\t\t\t\tfallback,\n\t\t\t);\n\t\t\tfor (const [address, u] of mx) {\n\t\t\t\tused.set(address, {\n\t\t\t\t\troute: 'smarthost',\n\t\t\t\t\tfallback: true,\n\t\t\t\t\t...(u.reply ? { mxReply: u.reply } : {}),\n\t\t\t\t});\n\t\t\t}\n\t\t\tupdates = [\n\t\t\t\t...updates.filter((u) => !mx.has(u.address)),\n\t\t\t\t...second.updates.map((u) => {\n\t\t\t\t\tconst was = mx.get(u.address);\n\t\t\t\t\treturn was ? merged(was, u) : u;\n\t\t\t\t}),\n\t\t\t];\n\t\t}\n\t}\n\treturn [...updates, ...bad.map(badAddress)];\n}\n",
|
|
15
|
+
"import type {\n\tReply,\n\tSendMailResult,\n\tSmtpError,\n\tSmtpErrorCode,\n} from '@bumail/smtp/client';\nimport type { Diagnostic, RecipientUpdate } from '../contract/types';\nimport { cleanText } from '../text';\n\n/**\n * An `SmtpError`, read by its `name`: a second copy of `@bumail/smtp` (a\n * different version installed for the app) throws errors of another\n * class, which `instanceof` would take for unknown ones.\n */\nexport const isSmtpError = (error: unknown): error is SmtpError =>\n\terror instanceof Error &&\n\terror.name === 'SmtpError' &&\n\ttypeof (error as { code?: unknown }).code === 'string';\n\n/**\n * `sendMail` refused its options: the route is misconfigured (a smarthost\n * it cannot use, a bad timeout), not the recipient. Retried, never bounced\n * at once: fixing the configuration and restarting delivers the message.\n */\nexport const isRouteError = (error: unknown): boolean =>\n\tisSmtpError(error) && error.code === 'INVALID_OPTION';\n\n/** An enhanced status code, `x.y.z` (RFC 3463 §2). */\nconst STATUS = /^[245]\\.\\d{1,3}\\.\\d{1,3}$/;\n\n/** What a reply says, bounded and cleaned. */\nexport function diagnosticOf(\n\treply: Reply,\n\tmax: number,\n\thost?: string,\n): Diagnostic {\n\tconst text =\n\t\ttypeof reply.text === 'string' ? reply.text : reply.text.join(' ');\n\treturn {\n\t\tcode: reply.code,\n\t\t...(reply.status && STATUS.test(reply.status)\n\t\t\t? { status: reply.status }\n\t\t\t: {}),\n\t\ttext: cleanText(text, max),\n\t\t...(host ? { host: cleanText(host, 255) } : {}),\n\t};\n}\n\n/**\n * The status code an error with no reply stands for (RFC 3463 §3): a null\n * MX is X.1.10 (RFC 7505 §4.2), a domain that cannot be found X.1.2, a\n * host that does not answer X.4.1, a connection lost or timed out X.4.2,\n * TLS X.7.0 (security).\n */\nconst ERROR_STATUS: Partial<Record<SmtpErrorCode, string>> = {\n\tNULL_MX: '1.10',\n\tDNS_FAILED: '1.2',\n\tCONNECTION_FAILED: '4.1',\n\tCONNECTION_LOST: '4.2',\n\tTIMEOUT: '4.2',\n\tTLS_UNAVAILABLE: '7.10',\n\tTLS_FAILED: '7.0',\n\tAUTH_UNAVAILABLE: '7.0',\n\tINVALID_OPTION: '3.5',\n};\n\n/** A failure that never got a reply: an error of the network, the DNS, TLS, or anything else. */\nfunction diagnosticOfError(\n\terror: unknown,\n\ttemporary: boolean,\n\tmax: number,\n\thost?: string,\n): Diagnostic {\n\tconst text = error instanceof Error ? error.message : String(error);\n\tconst detail = isSmtpError(error)\n\t\t? (ERROR_STATUS[error.code] ?? '0.0')\n\t\t: '0.0';\n\treturn {\n\t\tstatus: `${temporary ? 4 : 5}.${detail}`,\n\t\ttext: cleanText(text, max),\n\t\t...(host ? { host: cleanText(host, 255) } : {}),\n\t};\n}\n\n/** Each recipient of a delivery `sendMail` resolved: taken, or refused one by one. */\nexport function outcomesOf(\n\tresult: SendMailResult,\n\tgroup: readonly string[],\n\tmax: number,\n): RecipientUpdate[] {\n\tconst host = result.host;\n\tconst updates = new Map<string, RecipientUpdate>();\n\tfor (const { recipient } of result.accepted) {\n\t\tupdates.set(recipient, {\n\t\t\taddress: recipient,\n\t\t\tstatus: 'delivered',\n\t\t\treply: diagnosticOf(result.reply, max, host),\n\t\t});\n\t}\n\tfor (const { recipient, reply } of result.rejected) {\n\t\tupdates.set(recipient, {\n\t\t\taddress: recipient,\n\t\t\tstatus: reply.code >= 500 ? 'failed' : 'deferred',\n\t\t\treply: diagnosticOf(reply, max, host),\n\t\t});\n\t}\n\t// sendMail names every recipient it was given; a fake may not.\n\treturn group.map(\n\t\t(address) =>\n\t\t\tupdates.get(address) ?? {\n\t\t\t\taddress,\n\t\t\t\tstatus: 'deferred',\n\t\t\t\treply: {\n\t\t\t\t\ttext: 'The delivery said nothing of this recipient',\n\t\t\t\t\t...(host ? { host: cleanText(host, 255) } : {}),\n\t\t\t\t},\n\t\t\t},\n\t);\n}\n\n/**\n * Each recipient of a delivery `sendMail` rejected: by its own reply when\n * the server refused every one, else all alike — deferred when the error\n * is temporary (a 4xx, the network, a timeout) or the route's own\n * (`INVALID_OPTION`, X.3.5), failed otherwise.\n */\nexport function outcomesOfError(\n\terror: unknown,\n\tgroup: readonly string[],\n\tmax: number,\n\thost?: string,\n): RecipientUpdate[] {\n\tconst rejected = new Map(\n\t\tisSmtpError(error)\n\t\t\t? (error.rejected ?? []).map((r) => [r.recipient, r.reply])\n\t\t\t: [],\n\t);\n\tconst temporary =\n\t\t!isSmtpError(error) || error.temporary || isRouteError(error);\n\treturn group.map((address): RecipientUpdate => {\n\t\tconst own = rejected.get(address);\n\t\tif (own) {\n\t\t\treturn {\n\t\t\t\taddress,\n\t\t\t\tstatus: own.code >= 500 ? 'failed' : 'deferred',\n\t\t\t\treply: diagnosticOf(own, max, host),\n\t\t\t};\n\t\t}\n\t\tconst reply =\n\t\t\tisSmtpError(error) && error.reply\n\t\t\t\t? diagnosticOf(error.reply, max, host)\n\t\t\t\t: diagnosticOfError(error, temporary, max, host);\n\t\treturn { address, status: temporary ? 'deferred' : 'failed', reply };\n\t});\n}\n",
|
|
16
|
+
"import type { Diagnostic } from '../contract/types';\nimport { isSmtpError } from './outcome';\n\n/** Words a refusal uses when it names a blocklist or a reputation, for a server that gives no enhanced code. */\nconst REPUTATION =\n\t/\\b(?:block ?list(?:ed)?|black ?list(?:ed)?|deny ?list(?:ed)?|spamhaus|rbl|dnsbl|reputation|banned)\\b|\\bblocked\\b|\\blisted (?:in|on|at)\\b/i;\n\n/** A greylisting: a `4.7.x` that asks to come back, which a smarthost would not change. */\nconst GREYLIST = /gr[ae]y ?list/i;\n\n/**\n * Whether what the other side said (or why nobody said anything) is a\n * reason to try the fallback smarthost rather than wait: a connection\n * that failed or timed out (X.4.1, X.4.2, no reply at all), or a refusal\n * read as a matter of policy or reputation, a `4.7.x` or `5.7.x` (RFC\n * 3463 §3.8, security or policy status) or, with no enhanced code, text\n * that names a blocklist or a reputation.\n *\n * It is not a reason when the message may already be at the MX: an\n * `SmtpError` marked `afterData` (the final dot was written and no reply\n * came, a timeout or a lost connection that reads as 4.4.2) would be one\n * more copy by the smarthost, so the recipient is deferred for the MX retry\n * (RFC 5321 §4.1.5). An `@bumail/smtp` without the field behaves as before.\n *\n * It is not a reason when the smarthost would be refused alike: an\n * unknown or full mailbox (`5.1.x`, `x.2.x`), a domain that does not\n * exist, a null MX, a route that is misconfigured, or a TLS failure of\n * the MX (an `SmtpError` coded `TLS_*`, even one that carries a reply such\n * as a refused STARTTLS `454 4.7.0`), which the operator's TLS policy meant\n * to refuse, or a greylisting (`4.7.x` whose text says so), which the MX\n * retry settles.\n */\nexport function fallsBack(\n\treply: Diagnostic | undefined,\n\terror?: unknown,\n): boolean {\n\tif (!reply) return false;\n\tif (isSmtpError(error) && error.afterData) return false;\n\tif (isSmtpError(error) && error.code.startsWith('TLS_')) return false;\n\tif (GREYLIST.test(reply.text)) return false;\n\tif (reply.code === undefined) {\n\t\treturn reply.status === '4.4.1' || reply.status === '4.4.2';\n\t}\n\tif (reply.code < 400) return false;\n\tif (reply.status !== undefined) {\n\t\treturn /^[45]\\.7\\.\\d+$/.test(reply.status);\n\t}\n\treturn REPUTATION.test(reply.text);\n}\n",
|
|
17
|
+
"import type { SendMailOptions } from '@bumail/smtp/client';\nimport type { Route } from './options';\nimport type { Settings } from './settings';\n\n/** The route for a recipient domain: its own, else the default. */\nexport function routeOf(settings: Settings, domain: string): Route {\n\treturn settings.routes.get(domain) ?? settings.options.route ?? 'mx';\n}\n\n/** The host an attempt goes to, as far as the route says: the smarthost, or nothing for MX. */\nexport function hostOf(route: Route): string | undefined {\n\treturn route === 'mx' ? undefined : route.host;\n}\n\n/** What `sendMail` takes to send one domain's recipients of a message. */\nexport function sendOptionsOf(\n\tsettings: Settings,\n\tdomain: string,\n\tfrom: string,\n\tto: readonly string[],\n\toverride?: Route,\n): SendMailOptions {\n\tconst { options, hostname } = settings;\n\tconst common = {\n\t\tfrom,\n\t\tto,\n\t\thelo: hostname,\n\t\t...(options.timeouts ? { timeouts: options.timeouts } : {}),\n\t\t...(options.deadline !== undefined ? { deadline: options.deadline } : {}),\n\t};\n\tconst route = override ?? routeOf(settings, domain);\n\tif (route === 'mx') {\n\t\tconst resolver = options.resolver;\n\t\tif (!resolver) throw new Error('unreachable: settings check the resolver');\n\t\treturn {\n\t\t\t...common,\n\t\t\tdomain,\n\t\t\tresolver,\n\t\t\t...(options.mxPort !== undefined ? { port: options.mxPort } : {}),\n\t\t\t...(options.mxTls ? { tls: options.mxTls } : {}),\n\t\t};\n\t}\n\treturn {\n\t\t...common,\n\t\thost: route.host,\n\t\t...(route.port !== undefined ? { port: route.port } : {}),\n\t\t...(route.secure !== undefined ? { secure: route.secure } : {}),\n\t\t...(route.tls ? { tls: route.tls } : {}),\n\t\t...(route.auth ? { auth: route.auth } : {}),\n\t\t...(route.ca ? { ca: route.ca } : {}),\n\t};\n}\n",
|
|
14
18
|
"import {\n\tencodeHeaderValue,\n\tencodeQuotedPrintable,\n\tfoldHeader,\n\tformatDate,\n} from '@bumail/mime';\nimport { cleanText, replaceControls } from '../text';\nimport { returned } from './content';\nimport {\n\ttype DsnKind,\n\ttype DsnRecipient,\n\tdeliveryStatus,\n\tstatusOf,\n} from './fields';\n\nexport type { DsnKind, DsnRecipient } from './fields';\n\n/** What a DSN says, about which message, to whom. */\nexport interface DsnInput {\n\treadonly kind: DsnKind;\n\t/** This server's public name: the Reporting-MTA, and the Message-ID's domain. */\n\treadonly reportingMta: string;\n\t/** The DSN's From: the postmaster's address. */\n\treadonly from: string;\n\t/** The original's sender, to whom the DSN goes. */\n\treadonly to: string;\n\t/** When the original was enqueued. */\n\treadonly arrival: Date;\n\t/** When the DSN is written. */\n\treadonly date: Date;\n\treadonly recipients: readonly DsnRecipient[];\n\t/** With `delayed`: when the queue gives up. */\n\treadonly willRetryUntil?: Date;\n\t/**\n\t * The original message, as enqueued; absent when it could not be read,\n\t * and the DSN then has no third part (RFC 6522 §3 makes it optional).\n\t */\n\treadonly original?: Uint8Array;\n\treadonly returnContent: 'headers' | 'full';\n\t/** The most bytes of the original returned. */\n\treadonly maxReturn: number;\n}\n\nconst encoder = new TextEncoder();\nconst strip = (text: string) =>\n\treplaceControls(text, '').replace(/[\\s<>]/g, '');\n\n/** The text a person reads first: what happened, to whom, and why (RFC 3464 §2's first part). */\nfunction humanText(input: DsnInput): string {\n\tconst failed = input.kind === 'failed';\n\tconst lines = failed\n\t\t? [\n\t\t\t\t`This is the mail system at ${input.reportingMta}.`,\n\t\t\t\t'',\n\t\t\t\t'Your message could not be delivered to the recipients below.',\n\t\t\t\t'This is a permanent failure: the message will not be retried.',\n\t\t\t]\n\t\t: [\n\t\t\t\t`This is the mail system at ${input.reportingMta}.`,\n\t\t\t\t'',\n\t\t\t\t'Your message has not been delivered yet to the recipients below.',\n\t\t\t\t'This is a warning only: the message is still being retried',\n\t\t\t\t...(input.willRetryUntil\n\t\t\t\t\t? [`until ${formatDate(input.willRetryUntil)}.`]\n\t\t\t\t\t: []),\n\t\t\t\t'You do not need to send it again.',\n\t\t\t];\n\tif (!input.original) {\n\t\tlines.push(\n\t\t\t'',\n\t\t\t'Your message could not be read from the queue, so it is not returned.',\n\t\t);\n\t}\n\tlines.push('');\n\tfor (const r of input.recipients) {\n\t\tconst said = r.reply\n\t\t\t? `${r.reply.code ?? ''} ${cleanText(r.reply.text, 900)}`.trim()\n\t\t\t: statusOf(input.kind);\n\t\tconst why =\n\t\t\tr.reply?.status === '4.4.7'\n\t\t\t\t? `delivery time expired, still failing: ${said}`\n\t\t\t\t: said;\n\t\tlines.push(`<${cleanText(r.address, 254)}>: ${why}`);\n\t}\n\treturn `${lines.join('\\r\\n')}\\r\\n`;\n}\n\n/** The header fields of the DSN, every value cleaned and folded. */\nfunction headerFields(input: DsnInput, boundary: string): string[] {\n\tconst subject =\n\t\tinput.kind === 'failed'\n\t\t\t? 'Undelivered Mail Returned to Sender'\n\t\t\t: 'Delayed Mail (still being retried)';\n\tconst domain = strip(input.reportingMta);\n\treturn [\n\t\tfoldHeader('Date', formatDate(input.date)),\n\t\tfoldHeader('From', `Mail Delivery System <${strip(input.from)}>`),\n\t\tfoldHeader('To', `<${strip(input.to)}>`),\n\t\tfoldHeader('Subject', encodeHeaderValue(subject)),\n\t\tfoldHeader('Message-ID', `<${crypto.randomUUID()}@${domain}>`),\n\t\t// RFC 3834 §5: an automatic answer, which no one answers automatically.\n\t\tfoldHeader('Auto-Submitted', 'auto-replied'),\n\t\tfoldHeader('MIME-Version', '1.0'),\n\t\tfoldHeader(\n\t\t\t'Content-Type',\n\t\t\t`multipart/report; report-type=delivery-status; boundary=\"${boundary}\"`,\n\t\t),\n\t];\n}\n\nconst concat = (parts: readonly Uint8Array[]): Uint8Array => {\n\tconst out = new Uint8Array(parts.reduce((n, p) => n + p.length, 0));\n\tlet at = 0;\n\tfor (const part of parts) {\n\t\tout.set(part, at);\n\t\tat += part.length;\n\t}\n\treturn out;\n};\n\n/** A boundary that occurs nowhere in what it separates. */\nfunction boundaryFor(content: Uint8Array): string {\n\tconst text = new TextDecoder('latin1').decode(content);\n\tfor (;;) {\n\t\tconst boundary = `=_dsn_${crypto.randomUUID()}`;\n\t\tif (!text.includes(boundary)) return boundary;\n\t}\n}\n\n/**\n * A delivery status notification (RFC 3464): a `multipart/report`\n * (RFC 6522) of `report-type=delivery-status` holding the text a person\n * reads, the `message/delivery-status` fields a program reads, and the\n * original's header fields (or the whole original, when asked and small\n * enough), bounded by `maxReturn` — or, with no `original`, no third\n * part at all. Nothing from the remote server or the\n * envelope reaches a header field raw: control characters, CR and LF are\n * taken out first.\n */\nexport function buildDsn(input: DsnInput): Uint8Array {\n\tconst original = input.original\n\t\t? returned(input.original, input.returnContent, input.maxReturn)\n\t\t: undefined;\n\tconst boundary = boundaryFor(original?.body ?? new Uint8Array());\n\tconst text = encodeQuotedPrintable(humanText(input));\n\tconst status = deliveryStatus({\n\t\tkind: input.kind,\n\t\treportingMta: input.reportingMta,\n\t\tarrival: input.arrival,\n\t\trecipients: input.recipients,\n\t\t...(input.willRetryUntil ? { willRetryUntil: input.willRetryUntil } : {}),\n\t});\n\tconst parts = [\n\t\t...headerFields(input, boundary),\n\t\t'',\n\t\t'This is a MIME-formatted delivery status notification.',\n\t\t'',\n\t\t`--${boundary}`,\n\t\t'Content-Type: text/plain; charset=utf-8',\n\t\t'Content-Transfer-Encoding: quoted-printable',\n\t\t'',\n\t\ttext,\n\t\t`--${boundary}`,\n\t\t'Content-Type: message/delivery-status',\n\t\t'',\n\t\tstatus,\n\t];\n\tconst end = `--${boundary}--\\r\\n`;\n\tif (!original) return encoder.encode(`${parts.join('\\r\\n')}\\r\\n${end}`);\n\tconst head = [\n\t\t...parts,\n\t\t`--${boundary}`,\n\t\t`Content-Type: ${original.type}`,\n\t\t...(original.eightBit ? ['Content-Transfer-Encoding: 8bit'] : []),\n\t\t'',\n\t\t'',\n\t].join('\\r\\n');\n\treturn concat([\n\t\tencoder.encode(head),\n\t\toriginal.body,\n\t\tencoder.encode(`\\r\\n${end}`),\n\t]);\n}\n",
|
|
15
19
|
"/** The part of a DSN that returns the original message (RFC 3464 §2, RFC 6522 §3). */\n\nconst CR = 13;\nconst LF = 10;\n\n/** RFC 5322 §2.1.1: a line is at most 998 characters, its CRLF aside. */\nexport const MAX_LINE = 998;\n\nconst isContinuation = (byte: number | undefined) =>\n\tbyte !== undefined && byte >= 0x80 && byte < 0xc0;\n\n/**\n * Every bare CR or LF as CRLF, and every line cut at 998 bytes, never in\n * the middle of a UTF-8 character: a DSN is sent as lines, whatever the\n * original held, and a longer one would get the DSN itself refused.\n */\nfunction crlf(bytes: Uint8Array): Uint8Array {\n\tconst out: number[] = [];\n\tlet column = 0;\n\tfor (let i = 0; i < bytes.length; i++) {\n\t\tconst byte = bytes[i] as number;\n\t\tif (byte === CR || byte === LF) {\n\t\t\tout.push(CR, LF);\n\t\t\tcolumn = 0;\n\t\t\tif (byte === CR && bytes[i + 1] === LF) i++;\n\t\t} else if (column < MAX_LINE) {\n\t\t\tout.push(byte);\n\t\t\tcolumn++;\n\t\t} else if (column === MAX_LINE) {\n\t\t\t// The first byte cut: drop a character it would leave half written.\n\t\t\tif (isContinuation(byte)) {\n\t\t\t\twhile (isContinuation(out.at(-1))) {\n\t\t\t\t\tout.pop();\n\t\t\t\t}\n\t\t\t\tif ((out.at(-1) ?? 0) >= 0xc0) out.pop();\n\t\t\t}\n\t\t\tcolumn++;\n\t\t}\n\t}\n\treturn Uint8Array.from(out);\n}\n\n/** Where the header block ends: past the blank line, or the whole message when it has none. */\nfunction headerEnd(bytes: Uint8Array): number {\n\tfor (let i = 0; i + 3 < bytes.length; i++) {\n\t\tif (\n\t\t\tbytes[i] === CR &&\n\t\t\tbytes[i + 1] === LF &&\n\t\t\tbytes[i + 2] === CR &&\n\t\t\tbytes[i + 3] === LF\n\t\t) {\n\t\t\treturn i + 2;\n\t\t}\n\t}\n\treturn bytes.length;\n}\n\n/** The first `max` bytes at most, cut after the last whole line. */\nfunction wholeLines(bytes: Uint8Array, max: number): Uint8Array {\n\tif (bytes.length <= max) return bytes;\n\tconst cut = bytes.subarray(0, max).lastIndexOf(LF);\n\treturn bytes.subarray(0, cut + 1);\n}\n\nexport interface Returned {\n\t/** `text/rfc822-headers` or `message/rfc822`. */\n\treadonly type: string;\n\t/** Lines ending in CRLF, the last one included. */\n\treadonly body: Uint8Array;\n\t/** It holds a byte past ASCII: the part says `8bit`. */\n\treadonly eightBit: boolean;\n}\n\n/**\n * The original as a DSN returns it: the whole message when asked and it\n * fits `max` bytes, else its header fields, cut after the last whole line\n * that fits. Never more than `max` bytes.\n */\nexport function returned(\n\toriginal: Uint8Array,\n\tmode: 'headers' | 'full',\n\tmax: number,\n): Returned {\n\tconst message = crlf(original.subarray(0, max * 2 + 2));\n\tconst whole = original.length <= max && message.length <= max;\n\tconst body =\n\t\twhole && mode === 'full'\n\t\t\t? message\n\t\t\t: wholeLines(message.subarray(0, headerEnd(message)), max);\n\treturn {\n\t\ttype: whole && mode === 'full' ? 'message/rfc822' : 'text/rfc822-headers',\n\t\tbody,\n\t\teightBit: body.some((byte) => byte > 0x7f),\n\t};\n}\n",
|
|
16
20
|
"import { foldHeader, formatDate } from '@bumail/mime';\nimport type { Diagnostic } from '../contract/types';\nimport { asciiText, replaceControls } from '../text';\n\n/** One recipient a DSN reports on. */\nexport interface DsnRecipient {\n\treadonly address: string;\n\treadonly reply?: Diagnostic;\n\t/** When it was last tried. */\n\treadonly lastAttempt: Date;\n}\n\nexport type DsnKind = 'delayed' | 'failed';\n\n/** What a delivery-status part reports: who reports, on what, and each recipient. */\nexport interface StatusReport {\n\treadonly kind: DsnKind;\n\t/** This server's name. */\n\treadonly reportingMta: string;\n\t/** When the message was enqueued. */\n\treadonly arrival: Date;\n\treadonly recipients: readonly DsnRecipient[];\n\t/** With `delayed`: when the queue gives up. */\n\treadonly willRetryUntil?: Date;\n}\n\n/** Control characters out, CR and LF first: nothing from outside starts a field of its own. */\nconst strip = (text: string) => replaceControls(text, '');\n\n/** The longest escaped address: with its field name, within 998 characters a line. */\nconst MAX_ESCAPED = 900;\n\n/**\n * An address as a delivery-status field types it: `rfc822; addr` when it\n * is ASCII; otherwise `utf-8;` with each non-ASCII character as\n * `\\x{HEX}` (RFC 6533 §3, utf-8-addr-xtext), so the part stays 7-bit,\n * cut at 900 characters so it always fits a header line.\n */\nexport function typedAddress(address: string): string {\n\tconst clean = strip(address).replace(/[\\s\\\\]/g, '');\n\tif (/^[\\x21-\\x7e]*$/.test(clean)) return `rfc822; ${clean}`;\n\tlet escaped = '';\n\tfor (const c of clean) {\n\t\tconst piece = /[\\x21-\\x7e]/.test(c)\n\t\t\t? c\n\t\t\t: `\\\\x{${(c.codePointAt(0) ?? 0).toString(16).toUpperCase()}}`;\n\t\t// One word, so it must fit a line (RFC 5322 §2.1.1): cut, never lost.\n\t\tif (escaped.length + piece.length > MAX_ESCAPED) break;\n\t\tescaped += piece;\n\t}\n\treturn `utf-8; ${escaped}`;\n}\n\n/** A host name as `dns; host`, or nothing when it is not one. */\nconst remoteMta = (host: string | undefined) =>\n\thost && /^[A-Za-z0-9.:[\\]-]{1,255}$/.test(host) ? `dns; ${host}` : undefined;\n\n/**\n * The status (RFC 3463) of a recipient: the reply's enhanced code; else\n * its class from the reply code; else, with nothing at all, the kind's.\n */\nexport function statusOf(kind: DsnKind, reply?: Diagnostic): string {\n\tif (reply?.status) return reply.status;\n\tif (reply?.code !== undefined) {\n\t\treturn reply.code >= 500 ? '5.0.0' : '4.0.0';\n\t}\n\treturn kind === 'failed' ? '5.0.0' : '4.0.0';\n}\n\n/** The fields of one recipient (RFC 3464 §2.3), folded, no line from outside. */\nfunction recipientFields(\n\treport: StatusReport,\n\trecipient: DsnRecipient,\n): string[] {\n\tconst { reply } = recipient;\n\tconst fields: [string, string][] = [\n\t\t['Final-Recipient', typedAddress(recipient.address)],\n\t\t['Action', report.kind],\n\t\t['Status', statusOf(report.kind, reply)],\n\t];\n\tconst remote = remoteMta(reply?.host);\n\tif (remote) fields.push(['Remote-MTA', remote]);\n\tif (reply) {\n\t\tconst text = asciiText(reply.text, 900);\n\t\tfields.push(\n\t\t\treply.code === undefined\n\t\t\t\t? ['Diagnostic-Code', `X-Bumail; ${text}`]\n\t\t\t\t: ['Diagnostic-Code', `smtp; ${reply.code} ${text}`],\n\t\t);\n\t}\n\tfields.push(['Last-Attempt-Date', formatDate(recipient.lastAttempt)]);\n\tif (report.kind === 'delayed' && report.willRetryUntil) {\n\t\tfields.push(['Will-Retry-Until', formatDate(report.willRetryUntil)]);\n\t}\n\treturn fields.map(([name, value]) => foldHeader(name, value));\n}\n\n/**\n * The body of a `message/delivery-status` part (RFC 3464 §2.1): the\n * per-message fields, then each recipient's, a blank line between, CRLF.\n */\nexport function deliveryStatus(report: StatusReport): string {\n\tconst message = [\n\t\tfoldHeader('Reporting-MTA', `dns; ${strip(report.reportingMta)}`),\n\t\tfoldHeader('Arrival-Date', formatDate(report.arrival)),\n\t].join('\\r\\n');\n\tconst blocks = report.recipients.map((r) =>\n\t\trecipientFields(report, r).join('\\r\\n'),\n\t);\n\treturn `${[message, ...blocks].join('\\r\\n\\r\\n')}\\r\\n`;\n}\n",
|
|
17
21
|
"import type { RetrySettings } from './settings';\n\n/**\n * The wait after the `attempts`-th attempt failed for now: `first`, then\n * `factor` times the wait before, at most `max`, plus up to `jitter` of\n * itself — never less, so RFC 5321 §4.5.4.1's 30 minutes stay a floor.\n */\nexport function retryDelay(\n\tattempts: number,\n\tretry: RetrySettings,\n\trandom: () => number,\n): number {\n\tconst exponent = Math.max(0, attempts - 1);\n\tconst delay = Math.min(retry.first * retry.factor ** exponent, retry.max);\n\treturn delay + delay * retry.jitter * Math.min(1, Math.max(0, random()));\n}\n\n/** When a message's deferred recipients give up: `giveUpAfter` after it was enqueued. */\nexport const giveUpAt = (createdAt: number, retry: RetrySettings) =>\n\tcreatedAt + retry.giveUpAfter;\n\n/**\n * The next attempt after the `attempts`-th, at `now`: the back-off, but no\n * later than the moment of giving up, so the last try falls on it.\n * `undefined` when that moment has come: what is still deferred fails.\n */\nexport function nextAttemptAt(\n\tcreatedAt: number,\n\tnow: number,\n\tattempts: number,\n\tretry: RetrySettings,\n\trandom: () => number,\n): number | undefined {\n\tconst end = giveUpAt(createdAt, retry);\n\tif (now >= end) return undefined;\n\treturn Math.min(now + retryDelay(attempts, retry, random), end);\n}\n",
|
|
18
22
|
"import type { QueueStore } from '../contract/queue-store';\nimport type { QueueItem, RecipientUpdate } from '../contract/types';\nimport { buildDsn, type DsnKind } from '../dsn/build';\nimport type { Events } from './events';\nimport { giveUpAt } from './retry';\nimport type { Settings } from './settings';\n\nexport interface NotifyContext {\n\treadonly settings: Settings;\n\treadonly store: QueueStore;\n\treadonly events: Events;\n}\n\n/**\n * Enqueues a DSN (RFC 3464) back to the item's sender for these\n * recipients, from the null sender, so it never causes one of its own.\n * Nothing for an item from the null sender (RFC 5321 §4.5.5, RFC 3464\n * §2: a DSN is never sent about a DSN). It bypasses `maxItems`: a full\n * queue loses no bounce. A failure goes to the `error` event. With no\n * `message` — the store lost it — the DSN returns nothing of it.\n */\nexport async function notify(\n\tctx: NotifyContext,\n\titem: QueueItem,\n\tmessage: Uint8Array | undefined,\n\tkind: DsnKind,\n\trecipients: readonly RecipientUpdate[],\n\tnow: number,\n): Promise<void> {\n\tif (item.from === '' || recipients.length === 0) return;\n\tconst { settings, store, events } = ctx;\n\ttry {\n\t\tconst lastAttempt = new Date(now);\n\t\tconst dsn = buildDsn({\n\t\t\tkind,\n\t\t\treportingMta: settings.hostname,\n\t\t\tfrom: settings.dsn.from,\n\t\t\tto: item.from,\n\t\t\tarrival: new Date(item.createdAt),\n\t\t\tdate: lastAttempt,\n\t\t\trecipients: recipients.map((r) => ({\n\t\t\t\taddress: r.address,\n\t\t\t\t...(r.reply ? { reply: r.reply } : {}),\n\t\t\t\tlastAttempt,\n\t\t\t})),\n\t\t\t...(kind === 'delayed'\n\t\t\t\t? { willRetryUntil: new Date(giveUpAt(item.createdAt, settings.retry)) }\n\t\t\t\t: {}),\n\t\t\t...(message ? { original: message } : {}),\n\t\t\treturnContent: settings.dsn.returnContent,\n\t\t\tmaxReturn: settings.limits.maxDsnReturn,\n\t\t});\n\t\tconst added = await store.add({\n\t\t\tfrom: '',\n\t\t\tto: [item.from],\n\t\t\tmessage: dsn,\n\t\t\tcreatedAt: now,\n\t\t});\n\t\tevents.emit('dsn', {\n\t\t\tkind,\n\t\t\tid: added.id,\n\t\t\tof: item.id,\n\t\t\tto: item.from,\n\t\t\trecipients: recipients.map((r) => r.address),\n\t\t});\n\t} catch (error) {\n\t\tevents.emit('error', { error, id: item.id });\n\t}\n}\n",
|
|
19
|
-
"import type {\n\tReply,\n\tSendMailResult,\n\tSmtpError,\n\tSmtpErrorCode,\n} from '@bumail/smtp/client';\nimport type { Diagnostic, RecipientUpdate } from '../contract/types';\nimport { cleanText } from '../text';\n\n/**\n * An `SmtpError`, read by its `name`: a second copy of `@bumail/smtp` (a\n * different version installed for the app) throws errors of another\n * class, which `instanceof` would take for unknown ones.\n */\nexport const isSmtpError = (error: unknown): error is SmtpError =>\n\terror instanceof Error &&\n\terror.name === 'SmtpError' &&\n\ttypeof (error as { code?: unknown }).code === 'string';\n\n/**\n * `sendMail` refused its options: the route is misconfigured (a smarthost\n * it cannot use, a bad timeout), not the recipient. Retried, never bounced\n * at once: fixing the configuration and restarting delivers the message.\n */\nexport const isRouteError = (error: unknown): boolean =>\n\tisSmtpError(error) && error.code === 'INVALID_OPTION';\n\n/** An enhanced status code, `x.y.z` (RFC 3463 §2). */\nconst STATUS = /^[245]\\.\\d{1,3}\\.\\d{1,3}$/;\n\n/** What a reply says, bounded and cleaned. */\nexport function diagnosticOf(\n\treply: Reply,\n\tmax: number,\n\thost?: string,\n): Diagnostic {\n\tconst text =\n\t\ttypeof reply.text === 'string' ? reply.text : reply.text.join(' ');\n\treturn {\n\t\tcode: reply.code,\n\t\t...(reply.status && STATUS.test(reply.status)\n\t\t\t? { status: reply.status }\n\t\t\t: {}),\n\t\ttext: cleanText(text, max),\n\t\t...(host ? { host: cleanText(host, 255) } : {}),\n\t};\n}\n\n/**\n * The status code an error with no reply stands for (RFC 3463 §3): a null\n * MX is X.1.10 (RFC 7505 §4.2), a domain that cannot be found X.1.2, a\n * host that does not answer X.4.1, a connection lost or timed out X.4.2,\n * TLS X.7.0 (security).\n */\nconst ERROR_STATUS: Partial<Record<SmtpErrorCode, string>> = {\n\tNULL_MX: '1.10',\n\tDNS_FAILED: '1.2',\n\tCONNECTION_FAILED: '4.1',\n\tCONNECTION_LOST: '4.2',\n\tTIMEOUT: '4.2',\n\tTLS_UNAVAILABLE: '7.10',\n\tTLS_FAILED: '7.0',\n\tAUTH_UNAVAILABLE: '7.0',\n\tINVALID_OPTION: '3.5',\n};\n\n/** A failure that never got a reply: an error of the network, the DNS, TLS, or anything else. */\nfunction diagnosticOfError(\n\terror: unknown,\n\ttemporary: boolean,\n\tmax: number,\n\thost?: string,\n): Diagnostic {\n\tconst text = error instanceof Error ? error.message : String(error);\n\tconst detail = isSmtpError(error)\n\t\t? (ERROR_STATUS[error.code] ?? '0.0')\n\t\t: '0.0';\n\treturn {\n\t\tstatus: `${temporary ? 4 : 5}.${detail}`,\n\t\ttext: cleanText(text, max),\n\t\t...(host ? { host: cleanText(host, 255) } : {}),\n\t};\n}\n\n/** Each recipient of a delivery `sendMail` resolved: taken, or refused one by one. */\nexport function outcomesOf(\n\tresult: SendMailResult,\n\tgroup: readonly string[],\n\tmax: number,\n): RecipientUpdate[] {\n\tconst host = result.host;\n\tconst updates = new Map<string, RecipientUpdate>();\n\tfor (const { recipient } of result.accepted) {\n\t\tupdates.set(recipient, {\n\t\t\taddress: recipient,\n\t\t\tstatus: 'delivered',\n\t\t\treply: diagnosticOf(result.reply, max, host),\n\t\t});\n\t}\n\tfor (const { recipient, reply } of result.rejected) {\n\t\tupdates.set(recipient, {\n\t\t\taddress: recipient,\n\t\t\tstatus: reply.code >= 500 ? 'failed' : 'deferred',\n\t\t\treply: diagnosticOf(reply, max, host),\n\t\t});\n\t}\n\t// sendMail names every recipient it was given; a fake may not.\n\treturn group.map(\n\t\t(address) =>\n\t\t\tupdates.get(address) ?? {\n\t\t\t\taddress,\n\t\t\t\tstatus: 'deferred',\n\t\t\t\treply: {\n\t\t\t\t\ttext: 'The delivery said nothing of this recipient',\n\t\t\t\t\t...(host ? { host: cleanText(host, 255) } : {}),\n\t\t\t\t},\n\t\t\t},\n\t);\n}\n\n/**\n * Each recipient of a delivery `sendMail` rejected: by its own reply when\n * the server refused every one, else all alike — deferred when the error\n * is temporary (a 4xx, the network, a timeout) or the route's own\n * (`INVALID_OPTION`, X.3.5), failed otherwise.\n */\nexport function outcomesOfError(\n\terror: unknown,\n\tgroup: readonly string[],\n\tmax: number,\n\thost?: string,\n): RecipientUpdate[] {\n\tconst rejected = new Map(\n\t\tisSmtpError(error)\n\t\t\t? (error.rejected ?? []).map((r) => [r.recipient, r.reply])\n\t\t\t: [],\n\t);\n\tconst temporary =\n\t\t!isSmtpError(error) || error.temporary || isRouteError(error);\n\treturn group.map((address): RecipientUpdate => {\n\t\tconst own = rejected.get(address);\n\t\tif (own) {\n\t\t\treturn {\n\t\t\t\taddress,\n\t\t\t\tstatus: own.code >= 500 ? 'failed' : 'deferred',\n\t\t\t\treply: diagnosticOf(own, max, host),\n\t\t\t};\n\t\t}\n\t\tconst reply =\n\t\t\tisSmtpError(error) && error.reply\n\t\t\t\t? diagnosticOf(error.reply, max, host)\n\t\t\t\t: diagnosticOfError(error, temporary, max, host);\n\t\treturn { address, status: temporary ? 'deferred' : 'failed', reply };\n\t});\n}\n",
|
|
20
|
-
"import type { SendMailOptions } from '@bumail/smtp/client';\nimport type { Route } from './options';\nimport type { Settings } from './settings';\n\n/** The route for a recipient domain: its own, else the default. */\nexport function routeOf(settings: Settings, domain: string): Route {\n\treturn settings.routes.get(domain) ?? settings.options.route ?? 'mx';\n}\n\n/** The host an attempt goes to, as far as the route says: the smarthost, or nothing for MX. */\nexport function hostOf(route: Route): string | undefined {\n\treturn route === 'mx' ? undefined : route.host;\n}\n\n/** What `sendMail` takes to send one domain's recipients of a message. */\nexport function sendOptionsOf(\n\tsettings: Settings,\n\tdomain: string,\n\tfrom: string,\n\tto: readonly string[],\n): SendMailOptions {\n\tconst { options, hostname } = settings;\n\tconst common = {\n\t\tfrom,\n\t\tto,\n\t\thelo: hostname,\n\t\t...(options.timeouts ? { timeouts: options.timeouts } : {}),\n\t\t...(options.deadline !== undefined ? { deadline: options.deadline } : {}),\n\t};\n\tconst route = routeOf(settings, domain);\n\tif (route === 'mx') {\n\t\tconst resolver = options.resolver;\n\t\tif (!resolver) throw new Error('unreachable: settings check the resolver');\n\t\treturn {\n\t\t\t...common,\n\t\t\tdomain,\n\t\t\tresolver,\n\t\t\t...(options.mxPort !== undefined ? { port: options.mxPort } : {}),\n\t\t\t...(options.mxTls ? { tls: options.mxTls } : {}),\n\t\t};\n\t}\n\treturn {\n\t\t...common,\n\t\thost: route.host,\n\t\t...(route.port !== undefined ? { port: route.port } : {}),\n\t\t...(route.secure !== undefined ? { secure: route.secure } : {}),\n\t\t...(route.tls ? { tls: route.tls } : {}),\n\t\t...(route.auth ? { auth: route.auth } : {}),\n\t\t...(route.ca ? { ca: route.ca } : {}),\n\t};\n}\n",
|
|
21
23
|
"import type {\n\tAttemptResult,\n\tQueueItem,\n\tRecipientUpdate,\n} from '../contract/types';\nimport { nextAttemptAt } from './retry';\nimport type { Settings } from './settings';\n\n/** An attempt's outcomes, sorted, and what to record and send for them. */\nexport interface Settled {\n\treadonly result: AttemptResult;\n\treadonly delivered: readonly RecipientUpdate[];\n\t/** Failed in this attempt: a 5xx, or given up. */\n\treadonly failed: readonly RecipientUpdate[];\n\t/** Still deferred, to try again at `result.nextAttemptAt`. */\n\treadonly deferred: readonly RecipientUpdate[];\n\t/** A \"delayed\" DSN is due for the deferred recipients. */\n\treadonly delayDsn: boolean;\n}\n\n/**\n * A deferred recipient past the moment of giving up: failed, as X.4.7\n * (RFC 3463 §3.5, delivery time expired), the remote reply's code and text\n * kept as they were said.\n */\nfunction expired(update: RecipientUpdate): RecipientUpdate {\n\treturn {\n\t\taddress: update.address,\n\t\tstatus: 'failed',\n\t\treply: { text: '', ...update.reply, status: '4.4.7' },\n\t};\n}\n\n/**\n * What an attempt comes to: the count, the next attempt (RFC 5321\n * §4.5.4.1's back-off, or now when some recipients were left out because\n * the worker is stopping), the deferred recipients that gave up, and\n * whether the \"delayed\" DSN is due — once, for a sender that is not null.\n */\nexport function settle(\n\titem: QueueItem,\n\tupdates: readonly RecipientUpdate[],\n\tskipped: boolean,\n\tnow: number,\n\tsettings: Settings,\n): Settled {\n\tconst attempts = item.attempts + (updates.length > 0 ? 1 : 0);\n\tconst next = nextAttemptAt(\n\t\titem.createdAt,\n\t\tnow,\n\t\tattempts,\n\t\tsettings.retry,\n\t\tsettings.random,\n\t);\n\tconst all = updates.map((u) =>\n\t\tu.status === 'deferred' && next === undefined ? expired(u) : u,\n\t);\n\tconst deferred = all.filter((u) => u.status === 'deferred');\n\tconst { delayAfter } = settings.dsn;\n\tconst delayDsn =\n\t\t!item.delayNotified &&\n\t\titem.from !== '' &&\n\t\tdelayAfter !== false &&\n\t\tdeferred.length > 0 &&\n\t\tnow - item.createdAt >= delayAfter;\n\treturn {\n\t\tresult: {\n\t\t\tnow,\n\t\t\trecipients: all,\n\t\t\t// Left out by a stop with nothing deferred: due at once. Otherwise the\n\t\t\t// back-off holds for the whole item, the left-out domains included.\n\t\t\tnextAttemptAt:\n\t\t\t\tnext === undefined || (skipped && deferred.length === 0) ? now : next,\n\t\t\tattempts,\n\t\t\tdelayNotified: item.delayNotified || delayDsn,\n\t\t},\n\t\tdelivered: all.filter((u) => u.status === 'delivered'),\n\t\tfailed: all.filter((u) => u.status === 'failed'),\n\t\tdeferred,\n\t\tdelayDsn,\n\t};\n}\n",
|
|
22
24
|
"import type { QueueItem } from '../contract/types';\nimport { QueueError } from '../errors';\nimport type { NotifyContext } from './notify';\n\n/**\n * How a lease was lost. `taken`: a renewal found the item still in the\n * store, held by another worker or by none. `expired`: the lease's last\n * expiry passed, so another worker could claim it.\n */\nexport type Lapse = 'taken' | 'expired';\n\n/** What a worker knows of its lease on an item it delivers. */\nexport interface LeaseState {\n\treadonly item: QueueItem;\n\t/** The outcome is recorded, or a renewal was refused: no more renewals count. */\n\tdone: boolean;\n\t/** The lease's last expiry this worker set: the claim's, then each renewal's. */\n\texpiresAt: number;\n\t/** A renewal was refused while the item was still in the store. */\n\ttaken: boolean;\n\t/** The look a refused renewal takes at the item. */\n\tlooking: Promise<void>;\n}\n\nexport function leaseOf(ctx: NotifyContext, item: QueueItem): LeaseState {\n\tconst { settings } = ctx;\n\treturn {\n\t\titem,\n\t\tdone: false,\n\t\texpiresAt: item.lease?.expiresAt ?? settings.now() + settings.leaseMs,\n\t\ttaken: false,\n\t\tlooking: Promise.resolve(),\n\t};\n}\n\n/** After a refused renewal: an item still there was taken, and is said so; a gone one is left to `lapsed`. */\nasync function lookAfterRefusal(\n\tctx: NotifyContext,\n\tlease: LeaseState,\n): Promise<void> {\n\tconst { id } = lease.item;\n\tif ((await ctx.store.get(id)) === undefined) return;\n\tlease.taken = true;\n\tconst error = new QueueError(\n\t\t'LEASE_LOST',\n\t\t`The lease on ${id} was lost while it was delivered`,\n\t);\n\tctx.events.emit('error', { error, id });\n}\n\n/**\n * One renewal. A renewal that is held keeps its expiry, even one that\n * lands after the outcome is recorded. One refused while the item is\n * still there — held by another worker or by none — says so once, and\n * ends the renewals; one refused for an item gone says nothing and ends\n * them: a cancel, or another worker that finished it, which `lapsed` tells\n * apart by the expiry. One that fails (the store busy, unreachable) says\n * so, and the next one tries again: the lease may still be held.\n * Resolves `false` once no more renewals are wanted.\n */\nexport async function renew(\n\tctx: NotifyContext,\n\tlease: LeaseState,\n): Promise<boolean> {\n\tconst { settings, store, events } = ctx;\n\tconst { id } = lease.item;\n\tconst next = settings.now() + settings.leaseMs;\n\tlet held: boolean;\n\ttry {\n\t\theld = await store.renew(id, settings.owner, next);\n\t} catch (error) {\n\t\tif (!lease.done) events.emit('error', { error, id });\n\t\treturn !lease.done;\n\t}\n\tif (held) lease.expiresAt = Math.max(lease.expiresAt, next);\n\tif (lease.done) return false;\n\tif (held) return true;\n\tlease.done = true;\n\tlease.looking = lookAfterRefusal(ctx, lease).catch((error: unknown) => {\n\t\tevents.emit('error', { error, id });\n\t});\n\treturn false;\n}\n\n/**\n * Whether the lease could have passed to another worker by `now`: a\n * renewal found it taken, or its last expiry is past. `undefined` while\n * it surely held, by this worker's clock.\n */\nexport async function lapsed(\n\tlease: LeaseState,\n\tnow: number,\n): Promise<Lapse | undefined> {\n\tawait lease.looking;\n\tif (lease.taken) return 'taken';\n\treturn lease.expiresAt <= now ? 'expired' : undefined;\n}\n\n/** Resolves once the look a refused renewal took at the item is over. */\nexport const settled = (lease: LeaseState): Promise<void> => lease.looking;\n",
|
|
23
25
|
"/** A count of slots: who asks past it waits, first come first served. */\nexport class Limiter {\n\treadonly #size: number;\n\t#used = 0;\n\treadonly #waiting: (() => void)[] = [];\n\n\tconstructor(size: number) {\n\t\tthis.#size = size;\n\t}\n\n\t/** A slot, once one is free; call what it resolves to, once, to give it back. */\n\tasync acquire(): Promise<() => void> {\n\t\tif (this.#used >= this.#size) {\n\t\t\tawait new Promise<void>((resolve) => this.#waiting.push(resolve));\n\t\t} else {\n\t\t\tthis.#used++;\n\t\t}\n\t\tlet released = false;\n\t\treturn () => {\n\t\t\tif (released) return;\n\t\t\treleased = true;\n\t\t\tconst next = this.#waiting.shift();\n\t\t\t// The slot passes to the next in line without being freed in between.\n\t\t\tif (next) next();\n\t\t\telse this.#used--;\n\t\t};\n\t}\n}\n\n/** One `Limiter` per key, made when first asked for and dropped once idle. */\nexport class KeyedLimiter {\n\treadonly #size: number;\n\treadonly #limiters = new Map<string, { limiter: Limiter; users: number }>();\n\n\tconstructor(size: number) {\n\t\tthis.#size = size;\n\t}\n\n\tasync acquire(key: string): Promise<() => void> {\n\t\tlet entry = this.#limiters.get(key);\n\t\tif (!entry) {\n\t\t\tentry = { limiter: new Limiter(this.#size), users: 0 };\n\t\t\tthis.#limiters.set(key, entry);\n\t\t}\n\t\tentry.users++;\n\t\tconst release = await entry.limiter.acquire();\n\t\tconst held = entry;\n\t\treturn () => {\n\t\t\trelease();\n\t\t\tif (--held.users === 0) this.#limiters.delete(key);\n\t\t};\n\t}\n}\n",
|
|
24
26
|
"import type { QueueItem } from '../contract/types';\nimport { deliverItem } from './deliver';\nimport { type LeaseState, lapsed, leaseOf, renew, settled } from './lease';\nimport { KeyedLimiter, Limiter } from './limiter';\nimport type { NotifyContext } from './notify';\n\n/**\n * Claims due items and delivers them, at most `concurrency` at once,\n * renewing each lease while its item is delivered. `start()` runs passes\n * every `pollInterval`, or at once when woken; `stop()` lets every\n * delivery under way finish and gives back what it had not started.\n */\nexport class Worker {\n\treadonly #ctx: NotifyContext;\n\treadonly #slots: Limiter;\n\treadonly #domains: KeyedLimiter;\n\treadonly #inFlight = new Set<Promise<void>>();\n\t#stopping = false;\n\t/** `start()` was called while a `stop()` was under way: start again once it ends. */\n\t#restart = false;\n\t#loop: Promise<void> | undefined;\n\t#wake: (() => void) | undefined;\n\t/** A wake came while no sleep was under way: the next sleep is skipped. */\n\t#woken = false;\n\n\tconstructor(ctx: NotifyContext) {\n\t\tthis.#ctx = ctx;\n\t\tthis.#slots = new Limiter(ctx.settings.concurrency);\n\t\tthis.#domains = new KeyedLimiter(ctx.settings.perDomain);\n\t}\n\n\t/** Renews the lease every third of it until the outcome is recorded, or a renewal ends them. */\n\t#renewing(lease: LeaseState): () => void {\n\t\tconst timer = setInterval(() => {\n\t\t\tvoid renew(this.#ctx, lease).then((more) => {\n\t\t\t\tif (!more) clearInterval(timer);\n\t\t\t});\n\t\t}, this.#ctx.settings.leaseMs / 3);\n\t\ttimer.unref?.();\n\t\treturn () => {\n\t\t\tlease.done = true;\n\t\t\tclearInterval(timer);\n\t\t};\n\t}\n\n\tasync #deliver(item: QueueItem): Promise<void> {\n\t\tconst lease = leaseOf(this.#ctx, item);\n\t\tconst stop = this.#renewing(lease);\n\t\ttry {\n\t\t\tawait deliverItem(\n\t\t\t\t{\n\t\t\t\t\t...this.#ctx,\n\t\t\t\t\tdomains: this.#domains,\n\t\t\t\t\tstopping: () => this.#stopping,\n\t\t\t\t\trecorded: stop,\n\t\t\t\t\tleaseLapsed: (now) => lapsed(lease, now),\n\t\t\t\t},\n\t\t\t\titem,\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tthis.#ctx.events.emit('error', { error, id: item.id });\n\t\t} finally {\n\t\t\tstop();\n\t\t\t// A refused renewal's look at the item ends with the delivery.\n\t\t\tawait settled(lease);\n\t\t}\n\t}\n\n\t/** The next due item, or `undefined` when nothing is, or the worker is stopping. */\n\t#claim(): Promise<QueueItem | undefined> {\n\t\tconst { settings, store } = this.#ctx;\n\t\tif (this.#stopping) return Promise.resolve(undefined);\n\t\treturn store.claim({\n\t\t\towner: settings.owner,\n\t\t\tnow: settings.now(),\n\t\t\tleaseMs: settings.leaseMs,\n\t\t});\n\t}\n\n\t/**\n\t * One pass: claims and delivers every item due, `concurrency` at a time,\n\t * claiming again as each one ends — so a DSN enqueued meanwhile goes in\n\t * the same pass. Resolves once all are done, with how many it claimed.\n\t */\n\tasync deliverDue(): Promise<number> {\n\t\tconst mine = new Set<Promise<void>>();\n\t\tlet claimed = 0;\n\t\twhile (!this.#stopping) {\n\t\t\tconst release = await this.#slots.acquire();\n\t\t\tlet item: QueueItem | undefined;\n\t\t\ttry {\n\t\t\t\titem = await this.#claim();\n\t\t\t} catch (error) {\n\t\t\t\trelease();\n\t\t\t\tawait Promise.all(mine);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tif (!item) {\n\t\t\t\trelease();\n\t\t\t\tif (mine.size === 0) break;\n\t\t\t\tawait Promise.race(mine);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tclaimed++;\n\t\t\tconst delivery: Promise<void> = this.#deliver(item).finally(() => {\n\t\t\t\trelease();\n\t\t\t\tmine.delete(delivery);\n\t\t\t\tthis.#inFlight.delete(delivery);\n\t\t\t});\n\t\t\tmine.add(delivery);\n\t\t\tthis.#inFlight.add(delivery);\n\t\t}\n\t\tawait Promise.all(mine);\n\t\treturn claimed;\n\t}\n\n\t/** Wakes a sleeping `start()` loop, or spares it its next sleep: something was enqueued. */\n\twake(): void {\n\t\tif (this.#wake) this.#wake();\n\t\telse this.#woken = true;\n\t}\n\n\tstart(): void {\n\t\tif (this.#stopping) {\n\t\t\tthis.#restart = true;\n\t\t\treturn;\n\t\t}\n\t\tif (this.#loop) return;\n\t\tthis.#loop = this.#run();\n\t}\n\n\tasync #sleep(): Promise<void> {\n\t\tif (this.#woken) {\n\t\t\tthis.#woken = false;\n\t\t\treturn;\n\t\t}\n\t\tawait new Promise<void>((resolve) => {\n\t\t\tconst timer = setTimeout(resolve, this.#ctx.settings.pollInterval);\n\t\t\tthis.#wake = () => {\n\t\t\t\tclearTimeout(timer);\n\t\t\t\tresolve();\n\t\t\t};\n\t\t});\n\t\tthis.#wake = undefined;\n\t}\n\n\tasync #run(): Promise<void> {\n\t\twhile (!this.#stopping) {\n\t\t\tthis.#woken = false;\n\t\t\ttry {\n\t\t\t\tawait this.deliverDue();\n\t\t\t} catch (error) {\n\t\t\t\tthis.#ctx.events.emit('error', { error });\n\t\t\t}\n\t\t\tif (this.#stopping) break;\n\t\t\tawait this.#sleep();\n\t\t}\n\t}\n\n\t/**\n\t * Claims nothing more, lets every delivery under way end, and gives back\n\t * what was claimed but not started, due at once for the next worker. A\n\t * `start()` called meanwhile starts again once this ends.\n\t */\n\tasync stop(): Promise<void> {\n\t\tthis.#restart = false;\n\t\tthis.#stopping = true;\n\t\tthis.#wake?.();\n\t\tawait this.#loop;\n\t\tawait Promise.all(this.#inFlight);\n\t\tthis.#loop = undefined;\n\t\tthis.#stopping = false;\n\t\tif (this.#restart) {\n\t\t\tthis.#restart = false;\n\t\t\tthis.start();\n\t\t}\n\t}\n}\n",
|
|
25
27
|
"import type { QueueItem, QueueListOptions } from '../contract/types';\nimport {\n\tcheckEnvelope,\n\tcheckLineEnds,\n\ttype MessageSource,\n\ttype QueueEnvelope,\n\treadMessage,\n} from './envelope';\nimport { Events, type QueueEvents, type QueueListener } from './events';\nimport type { QueueOptions } from './options';\nimport { settingsOf } from './settings';\nimport { Worker } from './worker';\n\n/** The outbound queue: what the app enqueues, delivered across restarts. */\nexport interface Queue {\n\t/** This worker's name on its leases. */\n\treadonly owner: string;\n\t/**\n\t * Takes a message to send — already signed, as it will leave — with its\n\t * envelope, and keeps it in the store, every recipient pending, due at\n\t * once. Refuses with `INVALID`, `MESSAGE_TOO_BIG`,\n\t * `TOO_MANY_RECIPIENTS` or `QUEUE_FULL`. The queue sends whatever it is\n\t * given: authenticate the submitter before you enqueue.\n\t */\n\tenqueue(message: MessageSource, envelope: QueueEnvelope): Promise<QueueItem>;\n\t/** One pass by hand: delivers every item due now; resolves with how many it claimed. */\n\tdeliverDue(): Promise<number>;\n\t/** Delivers in the background: a pass every `pollInterval`, and at once after `enqueue`. */\n\tstart(): void;\n\t/** Claims nothing more, lets the deliveries under way end, and gives back the rest. */\n\tstop(): Promise<void>;\n\t/** Listens to an event; returns what stops listening. */\n\ton<E extends keyof QueueEvents>(\n\t\tevent: E,\n\t\tlistener: QueueListener<E>,\n\t): () => void;\n\t/** The items in the queue, the next due first. */\n\tlist(options?: QueueListOptions): Promise<QueueItem[]>;\n\tget(id: string): Promise<QueueItem | undefined>;\n\t/**\n\t * Makes an item due now, and wakes the worker. False when there is no\n\t * such item, or when a worker is delivering it: its outcome sets the\n\t * next attempt, so asking now would change nothing.\n\t */\n\tretryNow(id: string): Promise<boolean>;\n\t/** Drops an item, its message and its recipients, with no DSN; the item as it stood, or `undefined`. */\n\tcancel(id: string): Promise<QueueItem | undefined>;\n}\n\n/**\n * Creates the queue over a store. Nothing is delivered until `start()`,\n * or `deliverDue()` by hand. Several queues — in one process or several —\n * may share a store: each claims items under its own `owner`.\n */\nexport function createQueue(options: QueueOptions): Queue {\n\tconst settings = settingsOf(options);\n\tconst store = options.store;\n\tconst events = new Events();\n\tconst worker = new Worker({ settings, store, events });\n\tconst { limits } = settings;\n\treturn {\n\t\towner: settings.owner,\n\t\tasync enqueue(message, envelope) {\n\t\t\tconst { from, to } = checkEnvelope(envelope, limits.maxRecipients);\n\t\t\tconst bytes = await readMessage(message, limits.maxMessageSize);\n\t\t\tcheckLineEnds(bytes);\n\t\t\tconst item = await store.add(\n\t\t\t\t{ from, to, message: bytes, createdAt: settings.now() },\n\t\t\t\tlimits.maxItems === undefined ? {} : { maxItems: limits.maxItems },\n\t\t\t);\n\t\t\tworker.wake();\n\t\t\treturn item;\n\t\t},\n\t\tdeliverDue: () => worker.deliverDue(),\n\t\tstart: () => worker.start(),\n\t\tstop: () => worker.stop(),\n\t\ton: (event, listener) => events.on(event, listener),\n\t\tlist: (listOptions) => store.list(listOptions),\n\t\tget: (id) => store.get(id),\n\t\tasync retryNow(id) {\n\t\t\tconst now = settings.now();\n\t\t\tconst lease = (await store.get(id))?.lease;\n\t\t\tif (lease && lease.expiresAt > now) return false;\n\t\t\tconst moved = await store.reschedule(id, now);\n\t\t\tif (moved) worker.wake();\n\t\t\treturn moved;\n\t\t},\n\t\tcancel: (id) => store.cancel(id),\n\t};\n}\n"
|
|
26
28
|
],
|
|
27
|
-
"mappings": ";;;;;;;;;;AAAA;AAuBA,IAAM,UAAU;AAET,SAAS,YAAY,CAAC,MAAc,SAA0B;AAAA,EACpE,IACC,OAAO,YAAY,YACnB,QAAQ,SAAS,OACjB,WAAW,OAAO,KAClB,CAAC,QAAQ,KAAK,OAAO,KACrB,CAAC,UAAU,OAAO,GACjB;AAAA,IACD,MAAM,QACL,GAAG,8CAA8C,KAAK,UAAU,OAAO,GACxE;AAAA,EACD;AAAA,EAC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
|
2
|
+
import type { DeliveryContext } from './deliver';
|
|
3
|
+
import type { RecipientEvent } from './events';
|
|
4
|
+
/** The route a recipient's last session took, as its events tell it. */
|
|
5
|
+
export type Used = Pick<RecipientEvent, 'route' | 'fallback' | 'mxReply'>;
|
|
6
|
+
/**
|
|
7
|
+
* One delivery for one domain's recipients: each one's outcome, whatever
|
|
8
|
+
* happened, and in `used` the route each took. By MX with a `fallback`,
|
|
9
|
+
* the recipients whose outcome is a connection failure, a timeout or a
|
|
10
|
+
* reputation refusal (`fallsBack`) go at once to the fallback smarthost,
|
|
11
|
+
* in a session of their own, and its outcome replaces the first (`merged`).
|
|
12
|
+
*/
|
|
13
|
+
export declare function attemptGroup(ctx: DeliveryContext, item: QueueItem, message: Uint8Array, domain: string, recipients: readonly string[], used: Map<string, Used>): Promise<RecipientUpdate[]>;
|
|
14
|
+
//# sourceMappingURL=attempt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attempt.d.ts","sourceRoot":"","sources":["../../src/queue/attempt.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAqB/C,wEAAwE;AACxE,MAAM,MAAM,IAAI,GAAG,IAAI,CAAC,cAAc,EAAE,OAAO,GAAG,UAAU,GAAG,SAAS,CAAC,CAAC;AAgD1E;;;;;;GAMG;AACH,wBAAsB,YAAY,CACjC,GAAG,EAAE,eAAe,EACpB,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,UAAU,EACnB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,SAAS,MAAM,EAAE,EAC7B,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,GACrB,OAAO,CAAC,eAAe,EAAE,CAAC,CA+C5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deliver.d.ts","sourceRoot":"","sources":["../../src/queue/deliver.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAmB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"deliver.d.ts","sourceRoot":"","sources":["../../src/queue/deliver.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAmB,MAAM,mBAAmB,CAAC;AAIpE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,KAAK,aAAa,EAAU,MAAM,UAAU,CAAC;AAGtD,MAAM,WAAW,eAAgB,SAAQ,aAAa;IACrD,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,yEAAyE;IACzE,QAAQ,CAAC,QAAQ,EAAE,MAAM,OAAO,CAAC;IACjC,gEAAgE;IAChE,QAAQ,CAAC,QAAQ,EAAE,MAAM,IAAI,CAAC;IAC9B;;;;OAIG;IACH,QAAQ,CAAC,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC;CAClE;AAyFD;;;;;;;GAOG;AACH,wBAAsB,WAAW,CAChC,GAAG,EAAE,eAAe,EACpB,IAAI,EAAE,SAAS,GACb,OAAO,CAAC,IAAI,CAAC,CAuCf"}
|
package/dist/queue/events.d.ts
CHANGED
|
@@ -9,6 +9,18 @@ export interface RecipientEvent {
|
|
|
9
9
|
readonly reply?: Diagnostic;
|
|
10
10
|
/** The attempts made so far, this one included. */
|
|
11
11
|
readonly attempts: number;
|
|
12
|
+
/**
|
|
13
|
+
* The route of this recipient's last session: `'mx'`, or `'smarthost'`
|
|
14
|
+
* for a smarthost, a host of a route, or the fallback.
|
|
15
|
+
*/
|
|
16
|
+
readonly route?: 'mx' | 'smarthost';
|
|
17
|
+
/** `true` when that session was the fallback, after the one by MX failed. */
|
|
18
|
+
readonly fallback?: true;
|
|
19
|
+
/**
|
|
20
|
+
* With `fallback`, what the MX side said (or why nobody said anything)
|
|
21
|
+
* before the smarthost took over: `reply` is the smarthost's.
|
|
22
|
+
*/
|
|
23
|
+
readonly mxReply?: Diagnostic;
|
|
12
24
|
}
|
|
13
25
|
export interface DeferredEvent extends RecipientEvent {
|
|
14
26
|
/** When the recipient is tried again, in milliseconds since the epoch. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/queue/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,+BAA+B;AAC/B,MAAM,WAAW,cAAc;IAC9B,qBAAqB;IACrB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,6DAA6D;IAC7D,QAAQ,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC;IAC5B,mDAAmD;IACnD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/queue/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,+BAA+B;AAC/B,MAAM,WAAW,cAAc;IAC9B,qBAAqB;IACrB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,6DAA6D;IAC7D,QAAQ,CAAC,KAAK,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,CAAC,CAAC,SAAS,MAAM,WAAW,EAC7B,KAAK,EAAE,CAAC,EACR,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,GACxB,MAAM,IAAI;IAYb,IAAI,CAAC,CAAC,SAAS,MAAM,WAAW,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,IAAI;CAS1E"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Diagnostic } from '../contract/types';
|
|
2
|
+
/**
|
|
3
|
+
* Whether what the other side said (or why nobody said anything) is a
|
|
4
|
+
* reason to try the fallback smarthost rather than wait: a connection
|
|
5
|
+
* that failed or timed out (X.4.1, X.4.2, no reply at all), or a refusal
|
|
6
|
+
* read as a matter of policy or reputation, a `4.7.x` or `5.7.x` (RFC
|
|
7
|
+
* 3463 §3.8, security or policy status) or, with no enhanced code, text
|
|
8
|
+
* that names a blocklist or a reputation.
|
|
9
|
+
*
|
|
10
|
+
* It is not a reason when the message may already be at the MX: an
|
|
11
|
+
* `SmtpError` marked `afterData` (the final dot was written and no reply
|
|
12
|
+
* came, a timeout or a lost connection that reads as 4.4.2) would be one
|
|
13
|
+
* more copy by the smarthost, so the recipient is deferred for the MX retry
|
|
14
|
+
* (RFC 5321 §4.1.5). An `@bumail/smtp` without the field behaves as before.
|
|
15
|
+
*
|
|
16
|
+
* It is not a reason when the smarthost would be refused alike: an
|
|
17
|
+
* unknown or full mailbox (`5.1.x`, `x.2.x`), a domain that does not
|
|
18
|
+
* exist, a null MX, a route that is misconfigured, or a TLS failure of
|
|
19
|
+
* the MX (an `SmtpError` coded `TLS_*`, even one that carries a reply such
|
|
20
|
+
* as a refused STARTTLS `454 4.7.0`), which the operator's TLS policy meant
|
|
21
|
+
* to refuse, or a greylisting (`4.7.x` whose text says so), which the MX
|
|
22
|
+
* retry settles.
|
|
23
|
+
*/
|
|
24
|
+
export declare function fallsBack(reply: Diagnostic | undefined, error?: unknown): boolean;
|
|
25
|
+
//# sourceMappingURL=fallback.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fallback.d.ts","sourceRoot":"","sources":["../../src/queue/fallback.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAUpD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,SAAS,CACxB,KAAK,EAAE,UAAU,GAAG,SAAS,EAC7B,KAAK,CAAC,EAAE,OAAO,GACb,OAAO,CAaT"}
|
package/dist/queue/options.d.ts
CHANGED
|
@@ -78,6 +78,15 @@ export interface QueueOptions {
|
|
|
78
78
|
readonly route?: Route;
|
|
79
79
|
/** A route per recipient domain, over `route`. */
|
|
80
80
|
readonly routes?: Readonly<Record<string, Route>>;
|
|
81
|
+
/**
|
|
82
|
+
* Where a recipient goes at once when its attempt by MX fails by a
|
|
83
|
+
* connection failure, a timeout, or a reply read as a reputation or
|
|
84
|
+
* policy refusal (`4.7.x`, `5.7.x`, a blocklist named): a smarthost, in
|
|
85
|
+
* the same delivery, instead of the usual backoff. Only for the
|
|
86
|
+
* domains whose route is `'mx'`. A plain refusal (an unknown mailbox)
|
|
87
|
+
* does not use it. Default none.
|
|
88
|
+
*/
|
|
89
|
+
readonly fallback?: Smarthost;
|
|
81
90
|
/** Needed by the `'mx'` route: `@bumail/dns`'s resolver, or any of its shape. */
|
|
82
91
|
readonly resolver?: MxResolver;
|
|
83
92
|
/** The port of MX hosts. Default 25; another one is for a test. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/queue/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,UAAU,EACV,YAAY,EACZ,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,OAAO,EACP,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1D,8GAA8G;AAC9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AE,MAAM,CAAC;IACxB,0BAA0B;IAC1B,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;IACvB,mDAAmD;IACnD,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,6CAA6C;IAC7C,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,MAAM,CAAC;CAC/B"}
|
package/dist/queue/route.d.ts
CHANGED
|
@@ -6,5 +6,5 @@ export declare function routeOf(settings: Settings, domain: string): Route;
|
|
|
6
6
|
/** The host an attempt goes to, as far as the route says: the smarthost, or nothing for MX. */
|
|
7
7
|
export declare function hostOf(route: Route): string | undefined;
|
|
8
8
|
/** What `sendMail` takes to send one domain's recipients of a message. */
|
|
9
|
-
export declare function sendOptionsOf(settings: Settings, domain: string, from: string, to: readonly string[]): SendMailOptions;
|
|
9
|
+
export declare function sendOptionsOf(settings: Settings, domain: string, from: string, to: readonly string[], override?: Route): SendMailOptions;
|
|
10
10
|
//# sourceMappingURL=route.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../src/queue/route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,mEAAmE;AACnE,wBAAgB,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,KAAK,CAEjE;AAED,+FAA+F;AAC/F,wBAAgB,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,GAAG,SAAS,CAEvD;AAED,0EAA0E;AAC1E,wBAAgB,aAAa,CAC5B,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,SAAS,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../src/queue/route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,mEAAmE;AACnE,wBAAgB,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,KAAK,CAEjE;AAED,+FAA+F;AAC/F,wBAAgB,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,GAAG,SAAS,CAEvD;AAED,0EAA0E;AAC1E,wBAAgB,aAAa,CAC5B,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,SAAS,MAAM,EAAE,EACrB,QAAQ,CAAC,EAAE,KAAK,GACd,eAAe,CA8BjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../../src/queue/settings/routes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAoB,MAAM,YAAY,CAAC;AAoDjE,wBAAgB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../../src/queue/settings/routes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAoB,MAAM,YAAY,CAAC;AAoDjE,wBAAgB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI,CAyBvD"}
|
package/docs/guide.md
CHANGED
|
@@ -135,6 +135,61 @@ createQueue({
|
|
|
135
135
|
- `routes` maps a recipient domain (compared in lowercase) to its own
|
|
136
136
|
route, over `route`.
|
|
137
137
|
|
|
138
|
+
### Falling back to a smarthost
|
|
139
|
+
|
|
140
|
+
`fallback` is a smarthost (`{ host, port?, secure?, tls?, auth?, ca? }`,
|
|
141
|
+
checked like a route's) that a recipient goes to **at once** when its
|
|
142
|
+
session by MX comes out as one of:
|
|
143
|
+
|
|
144
|
+
- a connection that failed or timed out (no reply, X.4.1 or X.4.2);
|
|
145
|
+
- a refusal read as a matter of policy or reputation: an enhanced status
|
|
146
|
+
`4.7.x` or `5.7.x`, or, with no enhanced status, a reply whose text names
|
|
147
|
+
a blocklist, a deny list, Spamhaus, an RBL or a reputation.
|
|
148
|
+
|
|
149
|
+
The recipient is sent again in a second session of its own, in the same
|
|
150
|
+
delivery, by the fallback; that outcome is the one recorded, and the usual
|
|
151
|
+
back-off applies if it is a `4xx`. One exception: when the MX only deferred
|
|
152
|
+
the recipient and the smarthost refuses it for good (a bad password,
|
|
153
|
+
`5.7.1` sender not allowed, AUTH unavailable), the recipient stays
|
|
154
|
+
deferred, with the smarthost's reply as the diagnostic, and no DSN is sent:
|
|
155
|
+
the operator fixes the smarthost and the next attempt delivers. Per recipient: the others keep the
|
|
156
|
+
outcome of the first session. A plain `5xx` (`5.1.x` unknown mailbox,
|
|
157
|
+
`5.2.x`), a domain that does not exist, a null MX and a TLS failure with
|
|
158
|
+
the MX (an `SmtpError` coded `TLS_*`, a refused STARTTLS `454 4.7.0` under
|
|
159
|
+
`mxTls: 'required'` included) never use it. A greylisting (a `4.7.x` whose
|
|
160
|
+
text says grey/greylist) is the MX's to retry, and does not either. Only
|
|
161
|
+
domains whose route is `'mx'` can fall back.
|
|
162
|
+
|
|
163
|
+
A connection lost or a timeout *after* the final dot of `DATA` does not
|
|
164
|
+
fall back either, though it reads as `4.4.2`: the MX may already have taken
|
|
165
|
+
the message (RFC 5321 §4.1.5), and the smarthost would send it a second
|
|
166
|
+
time. `@bumail/smtp` marks that error `afterData`; the recipient is
|
|
167
|
+
deferred and the next attempt goes to the MX again. A duplicate is still
|
|
168
|
+
possible on that retry, as it is for any sender that did not see the
|
|
169
|
+
reply. And only the attempt's own error counts: if that later attempt
|
|
170
|
+
cannot reach the MX (a connection failure), it can still fall back, and
|
|
171
|
+
the smarthost may send the possible second copy. An `@bumail/smtp` older
|
|
172
|
+
than the field behaves as before.
|
|
173
|
+
|
|
174
|
+
Another risk to know: a `5.7.1` the MX gave and the smarthost accepted may
|
|
175
|
+
still bounce later from the provider, as a DSN to the sender, since the
|
|
176
|
+
provider has its own rules.
|
|
177
|
+
|
|
178
|
+
```ts
|
|
179
|
+
const queue = createQueue({
|
|
180
|
+
store,
|
|
181
|
+
hostname: 'mail.example.net',
|
|
182
|
+
resolver: nodeResolver(),
|
|
183
|
+
fallback: { host: 'smtp.provider.example', port: 587, auth },
|
|
184
|
+
});
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
`delivered`, `deferred` and `failed` events say which route the
|
|
188
|
+
recipient's last session took (`route`: `'mx'` or `'smarthost'`), and
|
|
189
|
+
`fallback: true` when that session was the fallback, with `mxReply`, what
|
|
190
|
+
the MX side said before the smarthost took over (`reply` is the
|
|
191
|
+
smarthost's).
|
|
192
|
+
|
|
138
193
|
### Around a blocked port 25
|
|
139
194
|
|
|
140
195
|
Many cloud and home networks block outbound port 25. Send everything
|
|
@@ -342,7 +397,7 @@ off(); // stops listening
|
|
|
342
397
|
|
|
343
398
|
| event | payload |
|
|
344
399
|
| --- | --- |
|
|
345
|
-
| `delivered` | `{ id, from, recipient, reply?, attempts }` |
|
|
400
|
+
| `delivered` | `{ id, from, recipient, reply?, attempts, route?, fallback?, mxReply? }`: `route` is `'mx'` or `'smarthost'`, `fallback` is `true` after the [fallback](#falling-back-to-a-smarthost), `mxReply` the MX's reply that led to it |
|
|
346
401
|
| `deferred` | the same, and `nextAttemptAt` |
|
|
347
402
|
| `failed` | the same as `delivered` |
|
|
348
403
|
| `dsn` | `{ kind: 'delayed' \| 'failed', id, of, to, recipients }`: `id` is the DSN's own item, `of` the item it reports on |
|
|
@@ -821,6 +876,7 @@ them yet.
|
|
|
821
876
|
| `hostname` | `string` | — | EHLO, Reporting-MTA, the DSN's From |
|
|
822
877
|
| `route` | `'mx' \| Smarthost` | `'mx'` | the default route |
|
|
823
878
|
| `routes` | `Record<string, Route>` | — | a route per recipient domain |
|
|
879
|
+
| `fallback` | `Smarthost` | — | where a recipient goes at once when MX fails by connection, timeout or a reputation refusal; see [Falling back](#falling-back-to-a-smarthost) |
|
|
824
880
|
| `resolver` | `MxResolver` | — | needed by `'mx'` |
|
|
825
881
|
| `mxPort` | `number`, 1–65535 | 25 | the port of MX hosts |
|
|
826
882
|
| `mxTls` | `TlsMode` | `opportunistic` | TLS to MX hosts |
|
package/docs/roadmap.md
CHANGED
|
@@ -6,7 +6,7 @@ only number on it.
|
|
|
6
6
|
|
|
7
7
|
## Now
|
|
8
8
|
|
|
9
|
-
Nothing in progress.
|
|
9
|
+
Nothing in progress.
|
|
10
10
|
|
|
11
11
|
## Next
|
|
12
12
|
|
|
@@ -51,6 +51,15 @@ Nothing in progress. The Redis store shipped in 0.3.0 (see Shipped).
|
|
|
51
51
|
|
|
52
52
|
## Shipped
|
|
53
53
|
|
|
54
|
+
### 0.5.0
|
|
55
|
+
|
|
56
|
+
- **A fallback smarthost** — `fallback`: a recipient
|
|
57
|
+
whose session by MX failed by a connection failure, a timeout or a
|
|
58
|
+
reputation refusal (`4.7.x`, `5.7.x`, a blocklist named) goes through a
|
|
59
|
+
smarthost at once, in the same delivery; a greylisting or a TLS failure
|
|
60
|
+
of the MX never does; the events carry the route and the MX's reply
|
|
61
|
+
(`mxReply`).
|
|
62
|
+
|
|
54
63
|
### 0.4.0
|
|
55
64
|
|
|
56
65
|
- **The PostgreSQL store's writes run at `READ COMMITTED`** — whatever
|
package/docs/troubleshooting.md
CHANGED
|
@@ -21,6 +21,7 @@ parts shown as … vary.
|
|
|
21
21
|
- [`QueueError: The 'mx' route needs a resolver, such as @bumail/dns's nodeResolver()`](#queueerror-the-mx-route-needs-a-resolver-such-as-bumaildnss-noderesolver)
|
|
22
22
|
- [`QueueError: hostname must be this server's public host name, not …`](#queueerror-hostname-must-be-this-servers-public-host-name-not-)
|
|
23
23
|
- [`QueueError: route must be 'mx' or a smarthost with a host`](#queueerror-route-must-be-mx-or-a-smarthost-with-a-host)
|
|
24
|
+
- [`QueueError: fallback must be a smarthost with a host, not an mx route`](#queueerror-fallback-must-be-a-smarthost-with-a-host-not-an-mx-route)
|
|
24
25
|
- [`QueueError: route.auth needs tls: 'required', the default with auth: with tls: '…' the password would go to a server whose certificate is not checked`](#queueerror-routeauth-needs-tls-required-the-default-with-auth-with-tls--the-password-would-go-to-a-server-whose-certificate-is-not-checked)
|
|
25
26
|
- [`QueueError: route.auth.username must be a non-empty string`, and the other smarthost options](#queueerror-routeauthusername-must-be-a-non-empty-string-and-the-other-smarthost-options)
|
|
26
27
|
- [`QueueError: timeouts.… must be a number of seconds above 0 and at most 2147483, not …`](#queueerror-timeouts-must-be-a-number-of-seconds-above-0-and-at-most-2147483-not-)
|
|
@@ -201,6 +202,18 @@ or route everything through a smarthost (`route: { host, port, auth }`).
|
|
|
201
202
|
`host`, a name or an address with no space or slash:
|
|
202
203
|
`{ host: 'smtp.provider.example', port: 587 }`.
|
|
203
204
|
|
|
205
|
+
### `QueueError: fallback must be a smarthost with a host, not an mx route`
|
|
206
|
+
|
|
207
|
+
**Code:** `INVALID`. `fallback` is where a recipient goes when its session
|
|
208
|
+
by MX failed, so it is a smarthost, `{ host, port?, secure?, tls?, auth? }`,
|
|
209
|
+
never `'mx'`.
|
|
210
|
+
|
|
211
|
+
```ts
|
|
212
|
+
createQueue({ store, hostname, resolver, fallback: { host: 'smtp.provider.example', port: 587, auth } });
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
See [Falling back to a smarthost](guide.md#falling-back-to-a-smarthost).
|
|
216
|
+
|
|
204
217
|
### `QueueError: route.auth needs tls: 'required', the default with auth: with tls: '…' the password would go to a server whose certificate is not checked`
|
|
205
218
|
|
|
206
219
|
**Code:** `INVALID`, also as `routes["…"].auth needs …`.
|
|
@@ -714,6 +727,12 @@ const clean = text.replaceAll('\0', '').toWellFormed();
|
|
|
714
727
|
text such as `Could not connect to …`.
|
|
715
728
|
**Why:** usually outbound port 25 is blocked by your network or your
|
|
716
729
|
cloud provider.
|
|
730
|
+
A `4.4.2` from a connection lost or a timeout after the final dot of
|
|
731
|
+
`DATA` is different: the MX may have taken the message, so the recipient
|
|
732
|
+
is deferred for the MX retry, not sent by the `fallback` smarthost in the
|
|
733
|
+
same delivery. A later attempt that cannot reach the MX (a connection
|
|
734
|
+
failure) can still fall back, and the smarthost may then send a second
|
|
735
|
+
copy: the queue keeps no memory of the first attempt's doubt.
|
|
717
736
|
**Fix:** route through a smarthost on port 587 or 465:
|
|
718
737
|
|
|
719
738
|
```ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bumail/queue",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "The outbound mail queue of a mail server: every recipient's state, retries with back-off, delivery status notifications (RFC 3464), leases for several workers, and a memory, a bun:sqlite, a PostgreSQL (Bun.sql) and a Redis (Bun.redis) store, delivering through @bumail/smtp/client",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -65,14 +65,14 @@
|
|
|
65
65
|
]
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@bumail/dns": "^0.
|
|
68
|
+
"@bumail/dns": "^0.2.1",
|
|
69
69
|
"@bumail/mime": "^0.1.2",
|
|
70
|
-
"@bumail/smtp": "^0.
|
|
70
|
+
"@bumail/smtp": "^0.7.0",
|
|
71
71
|
"@types/bun": "^1.4.2"
|
|
72
72
|
},
|
|
73
73
|
"peerDependencies": {
|
|
74
74
|
"@bumail/mime": "^0.1.2",
|
|
75
|
-
"@bumail/smtp": "^0.
|
|
75
|
+
"@bumail/smtp": "^0.7.0",
|
|
76
76
|
"typescript": "^6.0.3 || ^7.0.0"
|
|
77
77
|
},
|
|
78
78
|
"peerDependenciesMeta": {
|