@bumail/queue 0.7.2 → 0.9.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.
Files changed (77) hide show
  1. package/README.md +27 -3
  2. package/dist/chunks/{index-3pt7rc59.js → index-9yp15arf.js} +98 -25
  3. package/dist/chunks/index-9yp15arf.js.map +14 -0
  4. package/dist/chunks/index-r8wb840a.js +24 -0
  5. package/dist/chunks/index-r8wb840a.js.map +10 -0
  6. package/dist/contract/checks.d.ts +2 -6
  7. package/dist/contract/checks.d.ts.map +1 -1
  8. package/dist/contract/dsn-checks.d.ts +4 -0
  9. package/dist/contract/dsn-checks.d.ts.map +1 -0
  10. package/dist/contract/dsn-column.d.ts +12 -0
  11. package/dist/contract/dsn-column.d.ts.map +1 -0
  12. package/dist/contract/queue-store.d.ts +2 -1
  13. package/dist/contract/queue-store.d.ts.map +1 -1
  14. package/dist/contract/storable.d.ts +7 -0
  15. package/dist/contract/storable.d.ts.map +1 -0
  16. package/dist/contract/types.d.ts +52 -0
  17. package/dist/contract/types.d.ts.map +1 -1
  18. package/dist/dsn/build.d.ts +2 -0
  19. package/dist/dsn/build.d.ts.map +1 -1
  20. package/dist/dsn/delivered.d.ts +39 -0
  21. package/dist/dsn/delivered.d.ts.map +1 -0
  22. package/dist/dsn/fields.d.ts +11 -2
  23. package/dist/dsn/fields.d.ts.map +1 -1
  24. package/dist/dsn/human.d.ts +7 -0
  25. package/dist/dsn/human.d.ts.map +1 -0
  26. package/dist/dsn/policy.d.ts +17 -0
  27. package/dist/dsn/policy.d.ts.map +1 -0
  28. package/dist/index.d.ts +2 -1
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +474 -300
  31. package/dist/index.js.map +20 -15
  32. package/dist/memory/index.js +1 -1
  33. package/dist/memory/index.js.map +1 -1
  34. package/dist/postgres/index.js +17 -9
  35. package/dist/postgres/index.js.map +6 -6
  36. package/dist/postgres/rows.d.ts +6 -1
  37. package/dist/postgres/rows.d.ts.map +1 -1
  38. package/dist/postgres/schema.d.ts.map +1 -1
  39. package/dist/postgres/statements.d.ts +9 -8
  40. package/dist/postgres/statements.d.ts.map +1 -1
  41. package/dist/postgres/store.d.ts.map +1 -1
  42. package/dist/queue/attempt.d.ts +7 -7
  43. package/dist/queue/attempt.d.ts.map +1 -1
  44. package/dist/queue/deliver.d.ts.map +1 -1
  45. package/dist/queue/envelope.d.ts +24 -4
  46. package/dist/queue/envelope.d.ts.map +1 -1
  47. package/dist/queue/events.d.ts +8 -1
  48. package/dist/queue/events.d.ts.map +1 -1
  49. package/dist/queue/fallback-session.d.ts +22 -0
  50. package/dist/queue/fallback-session.d.ts.map +1 -0
  51. package/dist/queue/notify.d.ts +6 -3
  52. package/dist/queue/notify.d.ts.map +1 -1
  53. package/dist/queue/outcome.d.ts.map +1 -1
  54. package/dist/queue/queue.d.ts.map +1 -1
  55. package/dist/queue/route.d.ts +7 -0
  56. package/dist/queue/route.d.ts.map +1 -1
  57. package/dist/queue/session.d.ts +14 -0
  58. package/dist/queue/session.d.ts.map +1 -0
  59. package/dist/queue/settle.d.ts.map +1 -1
  60. package/dist/redis/index.js +26 -13
  61. package/dist/redis/index.js.map +5 -5
  62. package/dist/redis/items.d.ts +2 -0
  63. package/dist/redis/items.d.ts.map +1 -1
  64. package/dist/redis/scripts.d.ts +1 -1
  65. package/dist/redis/scripts.d.ts.map +1 -1
  66. package/dist/redis/store.d.ts.map +1 -1
  67. package/dist/sqlite/index.js +15 -8
  68. package/dist/sqlite/index.js.map +5 -5
  69. package/dist/sqlite/rows.d.ts +2 -1
  70. package/dist/sqlite/rows.d.ts.map +1 -1
  71. package/dist/sqlite/schema.d.ts.map +1 -1
  72. package/dist/sqlite/store.d.ts.map +1 -1
  73. package/docs/guide.md +97 -7
  74. package/docs/roadmap.md +14 -7
  75. package/docs/troubleshooting.md +52 -1
  76. package/package.json +3 -3
  77. package/dist/chunks/index-3pt7rc59.js.map +0 -12
package/dist/index.js.map CHANGED
@@ -1,32 +1,37 @@
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/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"],
3
+ "sources": ["../src/dsn/build.ts", "../src/dsn/content.ts", "../src/dsn/fields.ts", "../src/dsn/human.ts", "../src/dsn/policy.ts", "../src/dsn/delivered.ts", "../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/queue/session.ts", "../src/queue/fallback-session.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
- "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\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\t/**\n\t * Only on `deferred` and `failed`: `true` when a session by MX ended\n\t * after the final dot with no reply, so the MX may hold a copy and the\n\t * queue never fell back to a smarthost for this recipient on its own.\n\t */\n\treadonly mayHaveReachedMx?: true;\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",
5
+ "import {\n\tencodeHeaderValue,\n\tencodeQuotedPrintable,\n\tfoldHeader,\n\tformatDate,\n} from '@bumail/mime';\nimport { replaceControls } from '../text';\nimport { returned } from './content';\nimport { type DsnKind, type DsnRecipient, deliveryStatus } from './fields';\nimport { humanText, SUBJECTS } from './human';\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\t/** `ENVID` of the original, decoded: echoed as `Original-Envelope-Id`. */\n\treadonly envid?: string;\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 header fields of the DSN, every value cleaned and folded. */\nfunction headerFields(input: DsnInput, boundary: string): string[] {\n\tconst subject = SUBJECTS[input.kind];\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\t...(input.envid === undefined ? {} : { envid: input.envid }),\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",
6
+ "/** 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",
7
+ "import { foldHeader, formatDate } from '@bumail/mime';\nimport type { Diagnostic, OriginalRecipient } 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\t/** `ORCPT`: the recipient as the sender named it (RFC 3464 §2.3.1). */\n\treadonly orcpt?: OriginalRecipient;\n}\n\n/**\n * The `Action` of the report (RFC 3464 §2.3.3): `failed` and `delayed` for\n * what went wrong, `relayed` for a message handed to a next hop that sends\n * no DSN (RFC 3461 §5.2.2), `delivered` for one put in a local mailbox.\n */\nexport type DsnKind = 'delayed' | 'failed' | 'relayed' | 'delivered';\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\t/** `ENVID` of the original, decoded (RFC 3464 §2.2.1). */\n\treadonly envid?: string;\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 = cleanAddress(address);\n\tif (isAscii(clean)) return `rfc822; ${clean}`;\n\t// One word, so it must fit a line (RFC 5322 §2.1.1): cut, never lost.\n\treturn `utf-8; ${escapedAddress(clean).slice(0, MAX_ESCAPED)}`;\n}\n\nconst cleanAddress = (address: string) => strip(address).replace(/[\\s\\\\]/g, '');\nconst isAscii = (text: string) => /^[\\x21-\\x7e]*$/.test(text);\n\n/** The whole of an address with each non-ASCII character as `\\x{HEX}`, uncut. */\nfunction escapedAddress(clean: string): string {\n\tlet escaped = '';\n\tfor (const c of clean) {\n\t\tescaped += /[\\x21-\\x7e]/.test(c)\n\t\t\t? c\n\t\t\t: `\\\\x{${(c.codePointAt(0) ?? 0).toString(16).toUpperCase()}}`;\n\t}\n\treturn 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\tif (reply.code < 400) return '2.0.0';\n\t\treturn reply.code >= 500 ? '5.0.0' : '4.0.0';\n\t}\n\tif (kind === 'relayed' || kind === 'delivered') return '2.0.0';\n\treturn kind === 'failed' ? '5.0.0' : '4.0.0';\n}\n\n/**\n * `Original-Recipient` (RFC 3464 §2.3.1): `rfc822` addresses as the final\n * recipient's are typed; another address type is kept when its type is a\n * token and its address plain ASCII, else the field is left out; so is one\n * longer than a line holds.\n */\nfunction originalRecipient(orcpt: OriginalRecipient): string | undefined {\n\tconst type = orcpt.type.toLowerCase();\n\tif (type === 'rfc822' || type === 'utf-8') {\n\t\t// An ORCPT over the line limit leaves the field out: a field that cannot\n\t\t// be folded would lose the whole DSN, every recipient's.\n\t\tconst clean = cleanAddress(orcpt.address);\n\t\tconst whole = isAscii(clean) ? clean : escapedAddress(clean);\n\t\treturn whole.length > MAX_ESCAPED ? undefined : typedAddress(orcpt.address);\n\t}\n\tconst address = strip(orcpt.address).replace(/\\s/g, '');\n\tif (\n\t\t!/^[A-Za-z0-9-]{1,20}$/.test(orcpt.type) ||\n\t\t!/^[\\x21-\\x7e]{1,900}$/.test(address)\n\t) {\n\t\treturn undefined;\n\t}\n\treturn `${orcpt.type.toLowerCase()}; ${address}`;\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 original = recipient.orcpt && originalRecipient(recipient.orcpt);\n\tconst fields: [string, string][] = [\n\t\t...(original\n\t\t\t? ([['Original-Recipient', original]] as [string, string][])\n\t\t\t: []),\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 envid = strip(report.envid ?? '').trim();\n\tconst message = [\n\t\t...(envid === '' ? [] : [foldHeader('Original-Envelope-Id', envid)]),\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",
8
+ "import { formatDate } from '@bumail/mime';\nimport { cleanText } from '../text';\nimport type { DsnInput } from './build';\nimport { type DsnKind, statusOf } from './fields';\n\n/** The Subject of each kind of DSN. */\nexport const SUBJECTS: Record<DsnKind, string> = {\n\tfailed: 'Undelivered Mail Returned to Sender',\n\tdelayed: 'Delayed Mail (still being retried)',\n\trelayed: 'Mail Relayed (delivery not confirmed)',\n\tdelivered: 'Mail Delivered',\n};\n\n/** The sentences each kind opens with, after the greeting. */\nfunction opening(input: DsnInput): string[] {\n\tswitch (input.kind) {\n\t\tcase 'failed':\n\t\t\treturn [\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\tcase 'delayed':\n\t\t\treturn [\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\t\tcase 'relayed':\n\t\t\treturn [\n\t\t\t\t'Your message was passed on to the recipients below, whose server',\n\t\t\t\t'does not report delivery status (RFC 3461 §5.2.2).',\n\t\t\t\t'This server can say no more: no further notice will follow.',\n\t\t\t];\n\t\tcase 'delivered':\n\t\t\treturn ['Your message was delivered to the recipients below.'];\n\t}\n}\n\n/** The text a person reads first: what happened, to whom, and why (RFC 3464 §2's first part). */\nexport function humanText(input: DsnInput): string {\n\tconst lines = [\n\t\t`This is the mail system at ${input.reportingMta}.`,\n\t\t'',\n\t\t...opening(input),\n\t];\n\tif (!input.original && input.kind !== 'delivered') {\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",
9
+ "import type { RecipientNotify, RetMode } from '../contract/types';\nimport type { DsnKind } from './fields';\n\n/**\n * Whether a recipient asked for a DSN of this kind (RFC 3461 §4.1).\n * `NEVER` asks for none. With no `NOTIFY`, failures and delays are\n * reported (§4.1: the default) and a success is not. With a list, only the\n * events it names: `relayed` and `delivered` stand for `SUCCESS` (§5.2.2,\n * §5.2.3).\n */\nexport function asked(kind: DsnKind, notify: RecipientNotify | undefined) {\n\tif (notify === 'NEVER') return false;\n\tif (notify === undefined) return kind === 'failed' || kind === 'delayed';\n\tconst event = {\n\t\tfailed: 'FAILURE',\n\t\tdelayed: 'DELAY',\n\t\trelayed: 'SUCCESS',\n\t\tdelivered: 'SUCCESS',\n\t} as const;\n\treturn notify.includes(event[kind]);\n}\n\n/**\n * What a DSN returns of the original (RFC 3461 §4.3): `RET=HDRS` the\n * header fields only, `RET=FULL` the whole message, else the queue's own\n * setting.\n */\nexport const returnOf = (\n\tret: RetMode | undefined,\n\tfallback: 'headers' | 'full',\n): 'headers' | 'full' =>\n\tret === 'HDRS' ? 'headers' : ret === 'FULL' ? 'full' : fallback;\n",
10
+ "import type { OriginalRecipient, RecipientNotify } from '../contract/types';\nimport { buildDsn } from './build';\nimport { asked } from './policy';\n\n/** One recipient the application put in a local mailbox. */\nexport interface DeliveredRecipient {\n\t/** `local@domain`, the mailbox it was delivered to. */\n\treadonly address: string;\n\t/** Its `NOTIFY`; a `delivered` DSN goes only when `SUCCESS` was asked (RFC 3461 §5.2.3). */\n\treadonly notify?: RecipientNotify;\n\t/** Its `ORCPT`, echoed as `Original-Recipient`. */\n\treadonly orcpt?: OriginalRecipient;\n}\n\n/** What `deliveredDsn` takes. */\nexport interface DeliveredDsnInput {\n\t/** This server's public name: the Reporting-MTA. */\n\treadonly reportingMta: string;\n\t/** The DSN's From: the postmaster's address. */\n\treadonly from: string;\n\t/** The original's reverse-path; `''` (the null sender) gets no DSN. */\n\treadonly to: string;\n\t/** When the original was received. */\n\treadonly arrival: Date;\n\t/** When it was delivered. Default: now. */\n\treadonly date?: Date;\n\treadonly recipients: readonly DeliveredRecipient[];\n\treadonly envid?: string;\n\t/** The original as received; without it the DSN returns nothing of it. */\n\treadonly original?: Uint8Array;\n\t/** The most bytes of the original returned. Default 64 KiB. */\n\treadonly maxReturn?: number;\n}\n\n/**\n * The `delivered` DSN (RFC 3464 `Action: delivered`, RFC 3461 §5.2.3) for a\n * message the application put in local mailboxes: the bytes to\n * `enqueue` from the null sender to `to`, or `undefined` when there is\n * nothing to send — the original came from the null sender, or no\n * recipient asked for `SUCCESS`. Only the recipients that asked are\n * listed.\n */\nexport function deliveredDsn(input: DeliveredDsnInput): Uint8Array | undefined {\n\tconst wanted = input.recipients.filter((r) => asked('delivered', r.notify));\n\tif (input.to === '' || wanted.length === 0) return undefined;\n\tconst date = input.date ?? new Date();\n\treturn buildDsn({\n\t\tkind: 'delivered',\n\t\treportingMta: input.reportingMta,\n\t\tfrom: input.from,\n\t\tto: input.to,\n\t\tarrival: input.arrival,\n\t\tdate,\n\t\t...(input.envid === undefined ? {} : { envid: input.envid }),\n\t\trecipients: wanted.map((r) => ({\n\t\t\taddress: r.address,\n\t\t\tlastAttempt: date,\n\t\t\t...(r.orcpt ? { orcpt: r.orcpt } : {}),\n\t\t})),\n\t\t...(input.original ? { original: input.original } : {}),\n\t\t// RET speaks of failure DSNs (RFC 3461 §4.3): this one returns headers.\n\t\treturnContent: 'headers',\n\t\tmaxReturn: input.maxReturn ?? 64 * 1024,\n\t});\n}\n",
11
+ "import { isMailbox } from '@bumail/smtp/client';\nimport type { RecipientDsn, RetMode } from '../contract/types';\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\t/**\n\t * `RET` (RFC 3461 §4.3): what a DSN returns of the message, `HDRS` the\n\t * header fields only, `FULL` the whole message (still bounded by\n\t * `limits.maxDsnReturn`). Absent: the queue's `dsn.returnContent`.\n\t */\n\treadonly ret?: RetMode;\n\t/** `ENVID` (RFC 3461 §4.4), decoded: 1 to 100 printable ASCII characters. Passed on and echoed in a DSN. */\n\treadonly envid?: string;\n\t/**\n\t * `NOTIFY` and `ORCPT` (RFC 3461 §4.1, §4.2) of the recipients that carry\n\t * some, matched to `to` by address (the SMTP server's\n\t * `Envelope.recipients` fits as it is).\n\t */\n\treadonly recipients?: readonly RecipientDsn[];\n}\n\n/** What `checkEnvelope` returns: the envelope without its duplicates. */\nexport interface CheckedEnvelope {\n\treadonly from: string;\n\treadonly to: string[];\n\treadonly ret?: RetMode;\n\treadonly envid?: string;\n\treadonly recipients?: readonly RecipientDsn[];\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): CheckedEnvelope {\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\t// An entry for a spelling dropped as a duplicate moves to the kept one\n\t// (the first with an entry wins); any other is the store's to check\n\t// (an address not in `to` is `INVALID`).\n\tconst keyOf = (a: string) =>\n\t\t`${a.slice(0, a.lastIndexOf('@'))}@${domainOf(a)}`;\n\tconst kept = new Map(to.map((a) => [keyOf(a), a]));\n\tconst recipients = Array.isArray(envelope.recipients)\n\t\t? envelope.recipients\n\t\t\t\t.map((r) => {\n\t\t\t\t\tconst target =\n\t\t\t\t\t\ttypeof r?.address === 'string' && list.includes(r.address)\n\t\t\t\t\t\t\t? kept.get(keyOf(r.address))\n\t\t\t\t\t\t\t: undefined;\n\t\t\t\t\treturn target === undefined ? r : { ...r, address: target };\n\t\t\t\t})\n\t\t\t\t.filter(\n\t\t\t\t\t(r, i, all) => all.findIndex((o) => o?.address === r?.address) === i,\n\t\t\t\t)\n\t\t: envelope.recipients;\n\treturn {\n\t\tfrom,\n\t\tto,\n\t\t...(envelope.ret === undefined ? {} : { ret: envelope.ret }),\n\t\t...(envelope.envid === undefined ? {} : { envid: envelope.envid }),\n\t\t...(recipients === undefined ? {} : { recipients }),\n\t};\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",
12
+ "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\t/**\n\t * Only on `deferred` and `failed`: `true` when a session by MX ended\n\t * after the final dot with no reply, so the MX may hold a copy and the\n\t * queue never fell back to a smarthost for this recipient on its own.\n\t */\n\treadonly mayHaveReachedMx?: true;\n\t/**\n\t * Only on `deferred` and `failed`: `true` when the fallback smarthost's\n\t * session ended after the final dot with no reply, so it may hold a copy\n\t * and the next attempt goes to it again instead of the MX.\n\t */\n\treadonly mayHaveReachedFallback?: true;\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\t/** `relayed`: SUCCESS was asked and the next hop sends no DSN (RFC 3461 §5.2.2). */\n\treadonly kind: 'delayed' | 'failed' | 'relayed';\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
13
  "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
14
  "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
15
  "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
16
  "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
17
  "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
18
  "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\tconst marked = (u: RecipientUpdate) =>\n\t\tu.mayHaveReachedMx ? { mayHaveReachedMx: true as const } : {};\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), ...marked(u), nextAttemptAt });\n\t}\n\tfor (const u of settled.failed) {\n\t\tevents.emit('failed', { ...base(u), ...marked(u) });\n\t}\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 {\n\tisRouteError,\n\tisSmtpError,\n\toutcomesOf,\n\toutcomesOfError,\n} 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/** A deferred or failed outcome, marked: the MX may hold the message. */\nconst marked = (u: RecipientUpdate): RecipientUpdate =>\n\tu.status === 'delivered' ? u : { ...u, mayHaveReachedMx: true };\n\n/**\n * The outcomes of a session that failed after the final dot, marked: the\n * MX may hold a copy for every recipient it did not refuse at RCPT. A\n * recipient it refused there never had one, and keeps its own outcome. An\n * error with no envelope (an older `@bumail/smtp`) leaves every recipient\n * in doubt.\n */\nfunction doubtful(\n\tupdates: RecipientUpdate[],\n\terror: {\n\t\treadonly accepted?: readonly { recipient: string }[];\n\t\treadonly rejected?: readonly { recipient: string }[];\n\t},\n): RecipientUpdate[] {\n\tif (!error.accepted) return updates.map(marked);\n\t// Only a refusal at RCPT proves there is no copy: any other recipient is in\n\t// doubt, one listed as both accepted and refused (a malformed envelope) too.\n\tconst taken = new Set(error.accepted.map((r) => r.recipient));\n\tconst refused = new Set(\n\t\t(error.rejected ?? []).map((r) => r.recipient).filter((a) => !taken.has(a)),\n\t);\n\treturn updates.map((u) => (refused.has(u.address) ? u : marked(u)));\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\tconst updates = outcomesOfError(error, group, max, hostOf(route));\n\t\t// The final dot was written and no reply came: the MX may hold a copy.\n\t\tconst doubt = route === 'mx' && isSmtpError(error) && error.afterData;\n\t\treturn { updates: doubt ? doubtful(updates, error) : updates, error };\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\t// Recorded by an earlier attempt: the MX may hold a copy, so no automatic fallback.\n\tconst doubtful = new Set(\n\t\titem.recipients.filter((r) => r.mayHaveReachedMx).map((r) => r.address),\n\t);\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) =>\n\t\t\t\t\t\tu.status !== 'delivered' &&\n\t\t\t\t\t\t!u.mayHaveReachedMx &&\n\t\t\t\t\t\t!doubtful.has(u.address) &&\n\t\t\t\t\t\tfallsBack(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/**\n * A failure that never got a reply. Whether the MX may nonetheless hold a\n * copy (`SmtpError.afterData`) is not said here: `attemptGroup` marks the\n * outcomes `mayHaveReachedMx` from the error.\n */\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",
19
+ "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\tconst marked = (u: RecipientUpdate) => ({\n\t\t...(u.mayHaveReachedMx ? { mayHaveReachedMx: true as const } : {}),\n\t\t...(u.mayHaveReachedFallback\n\t\t\t? { mayHaveReachedFallback: true as const }\n\t\t\t: {}),\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), ...marked(u), nextAttemptAt });\n\t}\n\tfor (const u of settled.failed) {\n\t\tevents.emit('failed', { ...base(u), ...marked(u) });\n\t}\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\t// SUCCESS asked, and the next hop listed no DSN: responsibility stays here (RFC 3461 §5.2.2).\n\tconst relayed = settled.delivered.filter((u) => u.dsnOffered === false);\n\tawait notify(ctx, item, message, 'relayed', relayed, now);\n\tif (settled.delayDsn) {\n\t\tawait notify(ctx, item, message, 'delayed', settled.deferred, now);\n\t}\n}\n",
20
+ "import { isMailbox } from '@bumail/smtp/client';\nimport type { QueueItem, RecipientUpdate } from '../contract/types';\nimport type { DeliveryContext } from './deliver';\nimport {\n\tdeliverHeld,\n\tfallBackAtOnce,\n\theldAtFallback,\n} from './fallback-session';\nimport { routeOf } from './route';\nimport { session, type Used } from './session';\n\nexport type { Used } from './session';\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/**\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 the smarthost may already hold (`mayHaveReachedFallback`)\n * go to it first, skipping the MX (`deliverHeld`); the others go by MX, and\n * those whose outcome is a connection failure, a timeout or a reputation\n * refusal go at once to the fallback smarthost (`fallBackAtOnce`).\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 { fallback } = settings.options;\n\tconst held = heldAtFallback(item, group, route === 'mx', fallback);\n\t// First, so these do not wait behind an MX timeout.\n\tconst kept =\n\t\tfallback === undefined\n\t\t\t? []\n\t\t\t: await deliverHeld(ctx, item, message, domain, held, fallback, used);\n\tconst viaMx = group.filter((address) => !held.includes(address));\n\tlet updates: RecipientUpdate[] = [];\n\tif (viaMx.length > 0) {\n\t\tconst first = await session(ctx, item, message, domain, viaMx, route);\n\t\tupdates =\n\t\t\tfallback !== undefined && route === 'mx'\n\t\t\t\t? await fallBackAtOnce(\n\t\t\t\t\t\tctx,\n\t\t\t\t\t\titem,\n\t\t\t\t\t\tmessage,\n\t\t\t\t\t\tdomain,\n\t\t\t\t\t\tfirst,\n\t\t\t\t\t\tfallback,\n\t\t\t\t\t\tused,\n\t\t\t\t\t)\n\t\t\t\t: first.updates;\n\t}\n\treturn [...kept, ...updates, ...bad.map(badAddress)];\n}\n",
21
+ "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/**\n * A failure that never got a reply. Whether the MX or the fallback smarthost\n * may nonetheless hold a copy (`SmtpError.afterData`) is not said here:\n * `session` marks the outcomes `mayHaveReachedMx` or `mayHaveReachedFallback`\n * from the error.\n */\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\t// Only a plain `false` means no DSN at the next hop (an older sender says nothing).\n\t\t\t...(result.dsnOffered === false ? { dsnOffered: false } : {}),\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
22
  "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) and marked `mayHaveReachedMx`, which keeps every later\n * attempt from falling back on its own (`attemptGroup`). When the error\n * carries the envelope (`accepted`, `rejected`), the caller has marked\n * every recipient the MX did not refuse at `RCPT`; a refused one is judged\n * by its own `RCPT` reply, as before `DATA`. An `@bumail/smtp` without the\n * 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 && !error.accepted) 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",
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",
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",
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",
23
+ "import type { SendMailOptions } from '@bumail/smtp/client';\nimport type { QueueItem } from '../contract/types';\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/**\n * The DSN parameters `sendMail` passes on (RFC 3461 §4): the item's `RET`\n * and `ENVID`, and the `NOTIFY` and `ORCPT` of the recipients of this\n * session that carry some. Nothing for an item that has none.\n */\nexport function dsnOptionsOf(\n\titem: QueueItem,\n\tgroup: readonly string[],\n): Pick<SendMailOptions, 'ret' | 'envid' | 'recipients'> {\n\tconst only = new Set(group);\n\tconst recipients = item.recipients\n\t\t.filter(\n\t\t\t(r) =>\n\t\t\t\tonly.has(r.address) &&\n\t\t\t\t(r.notify !== undefined || r.orcpt !== undefined),\n\t\t)\n\t\t.map((r) => ({\n\t\t\taddress: r.address,\n\t\t\t...(r.notify === undefined ? {} : { notify: r.notify }),\n\t\t\t...(r.orcpt === undefined ? {} : { orcpt: r.orcpt }),\n\t\t}));\n\treturn {\n\t\t...(item.ret === undefined ? {} : { ret: item.ret }),\n\t\t...(item.envid === undefined ? {} : { envid: item.envid }),\n\t\t...(recipients.length === 0 ? {} : { recipients }),\n\t};\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",
24
+ "import type { QueueItem, RecipientUpdate } from '../contract/types';\nimport type { DeliveryContext } from './deliver';\nimport type { RecipientEvent } from './events';\nimport type { Route } from './options';\nimport {\n\tisRouteError,\n\tisSmtpError,\n\toutcomesOf,\n\toutcomesOfError,\n} from './outcome';\nimport { dsnOptionsOf, hostOf, sendOptionsOf } from './route';\n\n/** Which server may hold the message: the MX, or the fallback smarthost. */\ntype Doubt = 'mayHaveReachedMx' | 'mayHaveReachedFallback';\n\n/** A deferred or failed outcome, marked: that server may hold the message. */\nconst marked = (u: RecipientUpdate, key: Doubt): RecipientUpdate =>\n\tu.status === 'delivered' ? u : { ...u, [key]: true };\n\n/**\n * The outcomes of a session that failed after the final dot, marked: the\n * server (`key`) may hold a copy for every recipient it did not refuse at RCPT. A\n * recipient it refused there never had one, and keeps its own outcome. An\n * error with no envelope (an older `@bumail/smtp`) leaves every recipient\n * in doubt.\n */\nfunction doubtful(\n\tupdates: RecipientUpdate[],\n\terror: {\n\t\treadonly accepted?: readonly { recipient: string }[];\n\t\treadonly rejected?: readonly { recipient: string }[];\n\t},\n\tkey: Doubt,\n): RecipientUpdate[] {\n\tif (!error.accepted) return updates.map((u) => marked(u, key));\n\t// Only a refusal at RCPT proves there is no copy: any other recipient is in\n\t// doubt, one listed as both accepted and refused (a malformed envelope) too.\n\tconst taken = new Set(error.accepted.map((r) => r.recipient));\n\tconst refused = new Set(\n\t\t(error.rejected ?? []).map((r) => r.recipient).filter((a) => !taken.has(a)),\n\t);\n\treturn updates.map((u) => (refused.has(u.address) ? u : marked(u, key)));\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. */\nexport interface 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. */\nexport async 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 = {\n\t\t\t...sendOptionsOf(settings, domain, item.from, group, override),\n\t\t\t...dsnOptionsOf(item, group),\n\t\t};\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\tconst updates = outcomesOfError(error, group, max, hostOf(route));\n\t\t// The final dot was written and no reply came: that server may hold a copy.\n\t\tconst key = route === 'mx' ? 'mayHaveReachedMx' : 'mayHaveReachedFallback';\n\t\tconst doubt =\n\t\t\t(route === 'mx' || override !== undefined) &&\n\t\t\tisSmtpError(error) &&\n\t\t\terror.afterData;\n\t\treturn { updates: doubt ? doubtful(updates, error, key) : updates, error };\n\t}\n}\n",
25
+ "import type { QueueItem, RecipientUpdate } from '../contract/types';\nimport type { DeliveryContext } from './deliver';\nimport { fallsBack } from './fallback';\nimport type { Route } from './options';\nimport { type Attempt, session, type Used } from './session';\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 * A recipient the smarthost may already hold stays deferred when it\n * refuses: its earlier copy may still arrive, so no DSN (as `merged`).\n */\nconst stillHeld = (u: RecipientUpdate): RecipientUpdate =>\n\tu.status === 'failed' ? { ...u, status: 'deferred' } : u;\n\n/**\n * The automatic fallback, after the MX session: the recipients whose MX\n * outcome is a connection failure, a timeout or a reputation refusal\n * (`fallsBack`) go at once to the fallback smarthost, in a session of their\n * own, and its outcome replaces the first (`merged`). A recipient marked\n * `mayHaveReachedMx` never does. Returns every update, replaced or not.\n */\nexport async function fallBackAtOnce(\n\tctx: DeliveryContext,\n\titem: QueueItem,\n\tmessage: Uint8Array,\n\tdomain: string,\n\tfirst: Attempt,\n\tfallback: Route,\n\tused: Map<string, Used>,\n): Promise<RecipientUpdate[]> {\n\t// Recorded by an earlier attempt: the MX may hold a copy, so no automatic fallback.\n\tconst mxHeld = new Set(\n\t\titem.recipients.filter((r) => r.mayHaveReachedMx).map((r) => r.address),\n\t);\n\tconst mx = new Map(\n\t\tfirst.updates\n\t\t\t.filter(\n\t\t\t\t(u) =>\n\t\t\t\t\tu.status !== 'delivered' &&\n\t\t\t\t\t!u.mayHaveReachedMx &&\n\t\t\t\t\t!mxHeld.has(u.address) &&\n\t\t\t\t\tfallsBack(u.reply, first.error),\n\t\t\t)\n\t\t\t.map((u) => [u.address, u]),\n\t);\n\tif (mx.size === 0) return first.updates;\n\tconst second = await session(\n\t\tctx,\n\t\titem,\n\t\tmessage,\n\t\tdomain,\n\t\t[...mx.keys()],\n\t\tfallback,\n\t\tfallback,\n\t);\n\tfor (const [address, u] of mx) {\n\t\tused.set(address, {\n\t\t\troute: 'smarthost',\n\t\t\tfallback: true,\n\t\t\t...(u.reply ? { mxReply: u.reply } : {}),\n\t\t});\n\t}\n\treturn [\n\t\t...first.updates.filter((u) => !mx.has(u.address)),\n\t\t...second.updates.map((u) => {\n\t\t\tconst was = mx.get(u.address);\n\t\t\treturn was ? merged(was, u) : u;\n\t\t}),\n\t];\n}\n\n/**\n * The recipients marked `mayHaveReachedFallback` (and not `mayHaveReachedMx`)\n * while a `fallback` is configured and the domain goes by MX: the smarthost\n * may hold a copy, so they skip the MX and go to it again, in one session of\n * their own. A refusal leaves them deferred (`stillHeld`).\n */\nexport function heldAtFallback(\n\titem: QueueItem,\n\tgroup: readonly string[],\n\tbyMx: boolean,\n\tfallback: Route | undefined,\n): string[] {\n\tif (!byMx || fallback === undefined) return [];\n\tconst held = new Set(\n\t\titem.recipients\n\t\t\t.filter((r) => r.mayHaveReachedFallback && !r.mayHaveReachedMx)\n\t\t\t.map((r) => r.address),\n\t);\n\treturn group.filter((address) => held.has(address));\n}\n\n/** The held recipients' session at the fallback smarthost. */\nexport async function deliverHeld(\n\tctx: DeliveryContext,\n\titem: QueueItem,\n\tmessage: Uint8Array,\n\tdomain: string,\n\theld: readonly string[],\n\tfallback: Route,\n\tused: Map<string, Used>,\n): Promise<RecipientUpdate[]> {\n\tif (held.length === 0) return [];\n\tfor (const address of held) {\n\t\tused.set(address, { route: 'smarthost', fallback: true });\n\t}\n\tconst second = await session(\n\t\tctx,\n\t\titem,\n\t\tmessage,\n\t\tdomain,\n\t\theld,\n\t\tfallback,\n\t\tfallback,\n\t);\n\treturn second.updates.map(stillHeld);\n}\n",
21
26
  "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",
22
- "import type { QueueStore } from '../contract/queue-store';\nimport type { Diagnostic, 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/** Said in a failed DSN of a recipient whose message the MX may hold. */\nconst MAY_HAVE_REACHED =\n\t'An earlier attempt may have reached the receiving server, so the message may have been delivered.';\n\n/** The reply a DSN reports: a failed recipient's, with a sentence more when the MX may hold the message. */\nfunction reported(r: RecipientUpdate, kind: DsnKind): Diagnostic | undefined {\n\tif (kind !== 'failed' || !r.mayHaveReachedMx) return r.reply;\n\tconst reply: Diagnostic = r.reply ?? { text: '' };\n\treturn {\n\t\t...reply,\n\t\ttext:\n\t\t\treply.text === ''\n\t\t\t\t? MAY_HAVE_REACHED\n\t\t\t\t: `${reply.text} ${MAY_HAVE_REACHED}`,\n\t};\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\tconst reply = reported(r, kind);\n\t\t\t\treturn { address: r.address, ...(reply ? { reply } : {}), lastAttempt };\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",
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\t...(update.mayHaveReachedMx ? { mayHaveReachedMx: true as const } : {}),\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\t// A recipient the MX may hold keeps its mark in what is recorded and told, whatever route or path made this outcome.\n\tconst doubtful = new Set(\n\t\titem.recipients.filter((r) => r.mayHaveReachedMx).map((r) => r.address),\n\t);\n\tconst all = updates\n\t\t.map(\n\t\t\t(u): RecipientUpdate =>\n\t\t\t\tdoubtful.has(u.address) && u.status !== 'delivered'\n\t\t\t\t\t? { ...u, mayHaveReachedMx: true }\n\t\t\t\t\t: u,\n\t\t)\n\t\t.map((u) =>\n\t\t\tu.status === 'deferred' && next === undefined ? expired(u) : u,\n\t\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",
27
+ "import type { QueueStore } from '../contract/queue-store';\nimport type { Diagnostic, QueueItem, RecipientUpdate } from '../contract/types';\nimport { buildDsn, type DsnKind } from '../dsn/build';\nimport { asked, returnOf } from '../dsn/policy';\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/** Said in a failed DSN of a recipient whose message the MX may hold. */\nconst MAY_HAVE_REACHED =\n\t'An earlier attempt may have reached the receiving server, so the message may have been delivered.';\n\n/** Said in a failed DSN of a recipient whose message the fallback smarthost may hold. */\nconst MAY_HAVE_REACHED_FALLBACK =\n\t'An earlier attempt may have reached the fallback smarthost, so the message may have been delivered.';\n\n/** The reply a DSN reports: a failed recipient's, with a sentence more for each server that may hold the message. */\nfunction reported(r: RecipientUpdate, kind: DsnKind): Diagnostic | undefined {\n\tconst said = [\n\t\t...(r.mayHaveReachedMx ? [MAY_HAVE_REACHED] : []),\n\t\t...(r.mayHaveReachedFallback ? [MAY_HAVE_REACHED_FALLBACK] : []),\n\t];\n\tif (kind !== 'failed' || said.length === 0) return r.reply;\n\tconst reply: Diagnostic = r.reply ?? { text: '' };\n\treturn {\n\t\t...reply,\n\t\ttext: [reply.text, ...said].filter((t) => t !== '').join(' '),\n\t};\n}\n\n/**\n * Enqueues a DSN (RFC 3464) back to the item's sender for those of these\n * recipients that asked for one of this kind (`NOTIFY`, RFC 3461 §4.1:\n * `NEVER`, or the events listed; failure and delay when absent), from the\n * null sender, so it never causes one of its own. `ret` and `envid` of the\n * item shape its content and name the original (RFC 3461 §4.3, §4.4).\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: Exclude<DsnKind, 'delivered'>,\n\trecipients: readonly RecipientUpdate[],\n\tnow: number,\n): Promise<void> {\n\tconst states = new Map(item.recipients.map((r) => [r.address, r]));\n\tconst wanted = recipients.filter((r) =>\n\t\tasked(kind, states.get(r.address)?.notify),\n\t);\n\tif (item.from === '' || wanted.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\t...(item.envid === undefined ? {} : { envid: item.envid }),\n\t\t\trecipients: wanted.map((r) => {\n\t\t\t\tconst reply = reported(r, kind);\n\t\t\t\tconst orcpt = states.get(r.address)?.orcpt;\n\t\t\t\treturn {\n\t\t\t\t\taddress: r.address,\n\t\t\t\t\t...(reply ? { reply } : {}),\n\t\t\t\t\tlastAttempt,\n\t\t\t\t\t...(orcpt ? { orcpt } : {}),\n\t\t\t\t};\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\t// RET speaks of failure DSNs (RFC 3461 §4.3): a relayed one returns headers.\n\t\t\treturnContent:\n\t\t\t\tkind === 'relayed'\n\t\t\t\t\t? 'headers'\n\t\t\t\t\t: returnOf(item.ret, 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: wanted.map((r) => r.address),\n\t\t});\n\t} catch (error) {\n\t\tevents.emit('error', { error, id: item.id });\n\t}\n}\n",
28
+ "import type {\n\tAttemptResult,\n\tQueueItem,\n\tRecipientUpdate,\n} from '../contract/types';\nimport { asked } from '../dsn/policy';\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\t...(update.mayHaveReachedMx ? { mayHaveReachedMx: true as const } : {}),\n\t\t...(update.mayHaveReachedFallback\n\t\t\t? { mayHaveReachedFallback: true as const }\n\t\t\t: {}),\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\t// A recipient the MX or the fallback smarthost may hold keeps its marks in what is recorded and told, whatever route or path made this outcome.\n\tconst was = new Map(item.recipients.map((r) => [r.address, r]));\n\tconst all = updates\n\t\t.map((u): RecipientUpdate => {\n\t\t\tconst r = was.get(u.address);\n\t\t\tif (!r || u.status === 'delivered') return u;\n\t\t\treturn {\n\t\t\t\t...u,\n\t\t\t\t...(r.mayHaveReachedMx ? { mayHaveReachedMx: true as const } : {}),\n\t\t\t\t...(r.mayHaveReachedFallback\n\t\t\t\t\t? { mayHaveReachedFallback: true as const }\n\t\t\t\t\t: {}),\n\t\t\t};\n\t\t})\n\t\t.map((u) =>\n\t\t\tu.status === 'deferred' && next === undefined ? expired(u) : u,\n\t\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\tdeferred.some((u) => asked('delayed', was.get(u.address)?.notify)) &&\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",
24
29
  "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",
25
30
  "/** 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",
26
31
  "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",
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"
32
+ "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, ...dsn } = checkEnvelope(\n\t\t\t\tenvelope,\n\t\t\t\tlimits.maxRecipients,\n\t\t\t);\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(), ...dsn },\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"
28
33
  ],
29
- "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,EACA,OAAO;AAAA;AAID,IAAM,WAAW,CAAC,YACxB,QAAQ,MAAM,QAAQ,YAAY,GAAG,IAAI,CAAC,EAAE,YAAY;AAGlD,SAAS,aAAa,CAC5B,UACA,eACiC;AAAA,EACjC,IAAI,OAAO,aAAa,YAAY,aAAa,MAAM;AAAA,IACtD,MAAM,QAAQ,yCAAyC;AAAA,EACxD;AAAA,EACA,MAAM,OAAO,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