@bumail/smtp 0.6.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -481,7 +481,7 @@ host; a 5xx stops. A null MX (RFC 7505) fails at once with `NULL_MX`.
481
481
  | `SmtpServer` | `listen({ port, hostname? })` (once; again, even before the first resolved, throws `ALREADY_LISTENING`; on implicit TLS, a key or certificate it cannot read or use throws `INVALID_OPTION`), `setTls({ key, cert })` (a renewed pair for new STARTTLS upgrades and new implicit TLS connections; open sessions keep theirs; a pair that cannot be used throws `INVALID_OPTION` and the old one stays), `stop(closeConnections?)` (`true` hangs up on every client, after STARTTLS too), `connections` |
482
482
  | `SmtpServerOptions` | `hostname`, `mode`, `localDomains`, `tls`, `implicitTls`, `authenticate`, the limits (`maxConnectionsPerClient` among them), `hookTimeout`, `handshakeTimeout`, `greetingDelay`, `proxyProtocol`, `onError`, and the hooks |
483
483
  | `ProxyProtocolOptions` | `trusted`: the proxies' IPv4 and IPv6 addresses and CIDRs, the only peers whose PROXY header (v1 or v2) is read |
484
- | `SmtpError`, `SmtpErrorCode` | `code`: `INVALID_OPTION`, `ALREADY_LISTENING`, `STOPPED` (a `stop()` came before `listen` resolved), and what a content stream or `onError` can get: `MESSAGE_TOO_BIG`, `BARE_LINE_BREAK`, `CONNECTION_LOST`, `HOOK_TIMEOUT`, `INVALID_HOOK_REPLY`, `MESSAGE_NOT_READ`; `sendMail`'s are listed below. `temporary`, `reply` and `rejected` are set for `sendMail`'s errors |
484
+ | `SmtpError`, `SmtpErrorCode` | `code`: `INVALID_OPTION`, `ALREADY_LISTENING`, `STOPPED` (a `stop()` came before `listen` resolved), and what a content stream or `onError` can get: `MESSAGE_TOO_BIG`, `BARE_LINE_BREAK`, `CONNECTION_LOST`, `HOOK_TIMEOUT`, `INVALID_HOOK_REPLY`, `MESSAGE_NOT_READ`; `sendMail`'s are listed below. `temporary`, `reply` and `rejected` are set for `sendMail`'s errors, and `afterData` when the final dot was written and no reply came (the server may have taken the message) |
485
485
  | `SmtpHooks` | `onConnect`, `onMailFrom`, `onRcptTo`, `onData` |
486
486
  | `HookResult` | what a hook returns: `undefined` to accept, a `Reply` to refuse |
487
487
  | `Session` | `id`, `remoteAddress`, `secure`, `helo`, `esmtp`, `user`, and `data` for your own state |
@@ -14,6 +14,7 @@ class SmtpError2 extends Error {
14
14
  temporary;
15
15
  reply;
16
16
  rejected;
17
+ afterData;
17
18
  constructor(code, message, details = {}) {
18
19
  super(message, details.cause === undefined ? undefined : { cause: details.cause });
19
20
  this.code = code;
@@ -22,6 +23,8 @@ class SmtpError2 extends Error {
22
23
  this.reply = details.reply;
23
24
  if (details.rejected)
24
25
  this.rejected = details.rejected;
26
+ if (details.afterData)
27
+ this.afterData = true;
25
28
  }
26
29
  }
27
30
 
@@ -144,53 +147,6 @@ function encodeLoginStep(text) {
144
147
  return base64(text);
145
148
  }
146
149
 
147
- // src/io/outgoing.ts
148
- class Outgoing {
149
- #write;
150
- #queue = [];
151
- #waiters = [];
152
- constructor(write) {
153
- this.#write = write;
154
- }
155
- get empty() {
156
- return this.#queue.length === 0;
157
- }
158
- write(bytes) {
159
- if (this.#queue.length > 0) {
160
- this.#queue.push(bytes);
161
- return;
162
- }
163
- const written = this.#write(bytes);
164
- if (written < bytes.length) {
165
- this.#queue.push(bytes.subarray(Math.max(written, 0)));
166
- }
167
- }
168
- drain() {
169
- while (this.#queue.length > 0) {
170
- const bytes = this.#queue[0];
171
- const written = this.#write(bytes);
172
- if (written < bytes.length) {
173
- this.#queue[0] = bytes.subarray(Math.max(written, 0));
174
- return false;
175
- }
176
- this.#queue.shift();
177
- }
178
- for (const wake of this.#waiters.splice(0))
179
- wake();
180
- return true;
181
- }
182
- drained() {
183
- if (this.#queue.length === 0)
184
- return Promise.resolve();
185
- return new Promise((wake) => this.#waiters.push(wake));
186
- }
187
- clear() {
188
- this.#queue = [];
189
- for (const wake of this.#waiters.splice(0))
190
- wake();
191
- }
192
- }
193
-
194
150
  // src/protocol/lines.ts
195
151
  var MAX_LINE = 2048;
196
152
 
@@ -249,7 +205,54 @@ function concat(a, b) {
249
205
  return out;
250
206
  }
251
207
 
208
+ // src/io/outgoing.ts
209
+ class Outgoing {
210
+ #write;
211
+ #queue = [];
212
+ #waiters = [];
213
+ constructor(write) {
214
+ this.#write = write;
215
+ }
216
+ get empty() {
217
+ return this.#queue.length === 0;
218
+ }
219
+ write(bytes) {
220
+ if (this.#queue.length > 0) {
221
+ this.#queue.push(bytes);
222
+ return;
223
+ }
224
+ const written = this.#write(bytes);
225
+ if (written < bytes.length) {
226
+ this.#queue.push(bytes.subarray(Math.max(written, 0)));
227
+ }
228
+ }
229
+ drain() {
230
+ while (this.#queue.length > 0) {
231
+ const bytes = this.#queue[0];
232
+ const written = this.#write(bytes);
233
+ if (written < bytes.length) {
234
+ this.#queue[0] = bytes.subarray(Math.max(written, 0));
235
+ return false;
236
+ }
237
+ this.#queue.shift();
238
+ }
239
+ for (const wake of this.#waiters.splice(0))
240
+ wake();
241
+ return true;
242
+ }
243
+ drained() {
244
+ if (this.#queue.length === 0)
245
+ return Promise.resolve();
246
+ return new Promise((wake) => this.#waiters.push(wake));
247
+ }
248
+ clear() {
249
+ this.#queue = [];
250
+ for (const wake of this.#waiters.splice(0))
251
+ wake();
252
+ }
253
+ }
254
+
252
255
  export { SmtpError2, POSTMASTER, isHelloName, parsePath2, decodePlain2, decodeLoginStep2, encodePlain, encodeLoginStep, MAX_LINE, LineSplitter, Outgoing };
253
256
 
254
- //# debugId=C64F62A0D2105F3A64756E2164756E21
255
- //# sourceMappingURL=index-n4xwep5m.js.map
257
+ //# debugId=6AFC48FB7973019764756E2164756E21
258
+ //# sourceMappingURL=index-5228egp5.js.map
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/errors.ts", "../src/protocol/path.ts", "../src/protocol/sasl.ts", "../src/io/outgoing.ts", "../src/protocol/lines.ts"],
3
+ "sources": ["../src/errors.ts", "../src/protocol/path.ts", "../src/protocol/sasl.ts", "../src/protocol/lines.ts", "../src/io/outgoing.ts"],
4
4
  "sourcesContent": [
5
- "import type { Reply } from './protocol/reply';\n\n/** Why the server refused an option, why a message stream ended in error, or why `sendMail` failed. */\nexport type SmtpErrorCode =\n\t| 'INVALID_OPTION'\n\t| 'ALREADY_LISTENING'\n\t| 'STOPPED'\n\t| 'MESSAGE_TOO_BIG'\n\t| 'BARE_LINE_BREAK'\n\t| 'CONNECTION_LOST'\n\t| 'HOOK_TIMEOUT'\n\t| 'INVALID_HOOK_REPLY'\n\t| 'MESSAGE_NOT_READ'\n\t| 'CONNECTION_FAILED'\n\t| 'TIMEOUT'\n\t| 'BAD_REPLY'\n\t| 'REFUSED'\n\t| 'RECIPIENTS_REFUSED'\n\t| 'TLS_UNAVAILABLE'\n\t| 'TLS_FAILED'\n\t| 'AUTH_UNAVAILABLE'\n\t| 'EXTENSION_MISSING'\n\t| 'NULL_MX'\n\t| 'DNS_FAILED';\n\n/** One recipient and the server's reply to its `RCPT TO`. */\nexport interface RecipientReply {\n\treadonly recipient: string;\n\treadonly reply: Reply;\n}\n\n/** What `sendMail` adds to an error: whether to try again, and the reply behind it. */\nexport interface SmtpErrorDetails {\n\t/** Trying again later may succeed: a 4xx, the network, a timeout. */\n\treadonly temporary?: boolean;\n\t/** The server's reply that failed the delivery, enhanced status code included. */\n\treadonly reply?: Reply;\n\t/** With `RECIPIENTS_REFUSED`: each recipient, and why it was refused. */\n\treadonly rejected?: readonly RecipientReply[];\n\t/** The error behind this one, as `Error`'s `cause`. */\n\treadonly cause?: unknown;\n}\n\n/** The codes that are temporary unless a reply or `details` says otherwise. */\nconst TEMPORARY = new Set<SmtpErrorCode>([\n\t'CONNECTION_LOST',\n\t'CONNECTION_FAILED',\n\t'TIMEOUT',\n\t'BAD_REPLY',\n\t'TLS_UNAVAILABLE',\n\t'TLS_FAILED',\n]);\n\n/**\n * Thrown by `createSmtpServer` and `listen` for a wrong option or call; the\n * error a message's `content` stream ends with when the message must not be\n * delivered; what `onError` is given for a hook that broke a rule; and what\n * `sendMail` rejects with. `temporary` tells a failure worth trying again\n * later (a 4xx, the network, a timeout) from a permanent one (a 5xx, a null\n * MX, a message the server can never take).\n */\nexport class SmtpError extends Error {\n\toverride readonly name = 'SmtpError';\n\treadonly code: SmtpErrorCode;\n\t/** Trying again later may succeed. Meaningful for `sendMail`'s errors. */\n\treadonly temporary: boolean;\n\t/** The server reply behind a `sendMail` failure, enhanced status code included. */\n\treadonly reply?: Reply;\n\t/** With `RECIPIENTS_REFUSED`: each recipient, and the reply that refused it. */\n\treadonly rejected?: readonly RecipientReply[];\n\n\tconstructor(\n\t\tcode: SmtpErrorCode,\n\t\tmessage: string,\n\t\tdetails: SmtpErrorDetails = {},\n\t) {\n\t\tsuper(\n\t\t\tmessage,\n\t\t\tdetails.cause === undefined ? undefined : { cause: details.cause },\n\t\t);\n\t\tthis.code = code;\n\t\tthis.temporary =\n\t\t\tdetails.temporary ??\n\t\t\t(details.reply ? details.reply.code < 500 : TEMPORARY.has(code));\n\t\tif (details.reply) this.reply = details.reply;\n\t\tif (details.rejected) this.rejected = details.rejected;\n\t}\n}\n",
5
+ "import type { Reply } from './protocol/reply';\n\n/** Why the server refused an option, why a message stream ended in error, or why `sendMail` failed. */\nexport type SmtpErrorCode =\n\t| 'INVALID_OPTION'\n\t| 'ALREADY_LISTENING'\n\t| 'STOPPED'\n\t| 'MESSAGE_TOO_BIG'\n\t| 'BARE_LINE_BREAK'\n\t| 'CONNECTION_LOST'\n\t| 'HOOK_TIMEOUT'\n\t| 'INVALID_HOOK_REPLY'\n\t| 'MESSAGE_NOT_READ'\n\t| 'CONNECTION_FAILED'\n\t| 'TIMEOUT'\n\t| 'BAD_REPLY'\n\t| 'REFUSED'\n\t| 'RECIPIENTS_REFUSED'\n\t| 'TLS_UNAVAILABLE'\n\t| 'TLS_FAILED'\n\t| 'AUTH_UNAVAILABLE'\n\t| 'EXTENSION_MISSING'\n\t| 'NULL_MX'\n\t| 'DNS_FAILED';\n\n/** One recipient and the server's reply to its `RCPT TO`. */\nexport interface RecipientReply {\n\treadonly recipient: string;\n\treadonly reply: Reply;\n}\n\n/** What `sendMail` adds to an error: whether to try again, and the reply behind it. */\nexport interface SmtpErrorDetails {\n\t/** Trying again later may succeed: a 4xx, the network, a timeout. */\n\treadonly temporary?: boolean;\n\t/** The server's reply that failed the delivery, enhanced status code included. */\n\treadonly reply?: Reply;\n\t/** With `RECIPIENTS_REFUSED`: each recipient, and why it was refused. */\n\treadonly rejected?: readonly RecipientReply[];\n\t/** The error behind this one, as `Error`'s `cause`. */\n\treadonly cause?: unknown;\n\t/**\n\t * The final dot of the message was written and no reply to it came (a\n\t * timeout, a lost connection, a reply that is not one): the server may\n\t * have taken the message. See `SmtpError.afterData`.\n\t */\n\treadonly afterData?: boolean;\n}\n\n/** The codes that are temporary unless a reply or `details` says otherwise. */\nconst TEMPORARY = new Set<SmtpErrorCode>([\n\t'CONNECTION_LOST',\n\t'CONNECTION_FAILED',\n\t'TIMEOUT',\n\t'BAD_REPLY',\n\t'TLS_UNAVAILABLE',\n\t'TLS_FAILED',\n]);\n\n/**\n * Thrown by `createSmtpServer` and `listen` for a wrong option or call; the\n * error a message's `content` stream ends with when the message must not be\n * delivered; what `onError` is given for a hook that broke a rule; and what\n * `sendMail` rejects with. `temporary` tells a failure worth trying again\n * later (a 4xx, the network, a timeout) from a permanent one (a 5xx, a null\n * MX, a message the server can never take).\n */\nexport class SmtpError extends Error {\n\toverride readonly name = 'SmtpError';\n\treadonly code: SmtpErrorCode;\n\t/** Trying again later may succeed. Meaningful for `sendMail`'s errors. */\n\treadonly temporary: boolean;\n\t/** The server reply behind a `sendMail` failure, enhanced status code included. */\n\treadonly reply?: Reply;\n\t/** With `RECIPIENTS_REFUSED`: each recipient, and the reply that refused it. */\n\treadonly rejected?: readonly RecipientReply[];\n\t/**\n\t * `true` when `sendMail` wrote the message's final dot and then got no\n\t * reply to it (a `TIMEOUT`, a `CONNECTION_LOST`, a `BAD_REPLY`): the\n\t * server may already have taken the message (RFC 5321 §4.1.5), so a\n\t * retry, or a delivery by another route, can duplicate it. Absent for a\n\t * failure before the dot (the server drops a message with no dot) and for\n\t * a reply that refused the message (a 4xx or 5xx says it was not taken).\n\t */\n\treadonly afterData?: boolean;\n\n\tconstructor(\n\t\tcode: SmtpErrorCode,\n\t\tmessage: string,\n\t\tdetails: SmtpErrorDetails = {},\n\t) {\n\t\tsuper(\n\t\t\tmessage,\n\t\t\tdetails.cause === undefined ? undefined : { cause: details.cause },\n\t\t);\n\t\tthis.code = code;\n\t\tthis.temporary =\n\t\t\tdetails.temporary ??\n\t\t\t(details.reply ? details.reply.code < 500 : TEMPORARY.has(code));\n\t\tif (details.reply) this.reply = details.reply;\n\t\tif (details.rejected) this.rejected = details.rejected;\n\t\tif (details.afterData) this.afterData = true;\n\t}\n}\n",
6
6
  "/** An envelope address, as `MAIL FROM` and `RCPT TO` give it. */\nexport interface Path {\n\t/**\n\t * `local@domain`; `''` for the null reverse-path `<>`; `'postmaster'`\n\t * for `RCPT TO:<postmaster>`, which has no domain.\n\t */\n\treadonly address: string;\n\treadonly local: string;\n\t/** Lower case; `''` for `<>` and for `<postmaster>`. */\n\treadonly domain: string;\n\t/**\n\t * `true` for `RCPT TO:<postmaster>`, in any case, with no domain (RFC\n\t * 5321 §4.5.1): the postmaster of this server, whatever domains it\n\t * hosts. Absent for every other path, `<postmaster@domain>` included.\n\t */\n\treadonly postmaster?: true;\n}\n\n/** The bare `<postmaster>` path `RCPT TO` takes (RFC 5321 §4.1.1.3, §4.5.1). */\nexport const POSTMASTER: Path = Object.freeze({\n\taddress: 'postmaster',\n\tlocal: 'postmaster',\n\tdomain: '',\n\tpostmaster: true,\n});\n\nconst ATOM = /^[A-Za-z0-9!#$%&'*+\\-/=?^_`{|}~\\u0080-\\u{10ffff}]+$/u;\nconst LABEL =\n\t/^(?:[A-Za-z0-9\\u0080-\\u{10ffff}](?:[A-Za-z0-9\\-\\u0080-\\u{10ffff}]*[A-Za-z0-9\\u0080-\\u{10ffff}])?)$/u;\n\n/**\n * C1 controls, Unicode format characters (zero-width, bidi, BOM), the\n * line and paragraph separators, and lone surrogates: none has a place in\n * an address, and each would land as it is in the Received field and the\n * app's records — a lone surrogate as U+FFFD, once encoded for the wire.\n */\nconst INVISIBLE = /[\\u0080-\\u009f\\u2028\\u2029\\p{Cf}\\p{Cs}]/u;\n\n/**\n * C0 controls (CR, LF and NUL among them), DEL and `>`, anywhere in the\n * path, quoted or not: a CR or an LF would end the command line and start\n * another, and a `>` would end the path where a reader of the line stops.\n */\nfunction hasControl(text: string): boolean {\n\tfor (let i = 0; i < text.length; i++) {\n\t\tconst code = text.charCodeAt(i);\n\t\tif (code < 0x20 || code === 0x7f || code === 0x3e) return true;\n\t}\n\treturn false;\n}\n\n/** One hop of a source route, `@domain`, and what follows it: `,` or `:`. */\nconst HOP = /^@(\\[[^\\]]*\\]|[^,:@[\\]]*)([,:])/;\n\nfunction isDotString(text: string): boolean {\n\treturn text.split('.').every((atom) => ATOM.test(atom));\n}\n\nfunction isQuotedString(text: string): boolean {\n\treturn /^\"(?:[\\x20\\x21\\x23-\\x5b\\x5d-\\x7e\\u0080-\\u{10ffff}]|\\\\[\\x20-\\x7e])*\"$/u.test(\n\t\ttext,\n\t);\n}\n\n/**\n * An address literal (§4.1.3): `[IPv6:…]`, its tag in any case (a quoted\n * string in RFC 5234 is), or `[a.b.c.d]` with each octet at most 255.\n */\nexport function isAddressLiteral(text: string): boolean {\n\tif (/^\\[IPv6:[0-9a-f:.]+\\]$/i.test(text)) return true;\n\tconst ipv4 = /^\\[(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\]$/.exec(text);\n\treturn ipv4?.slice(1).every((octet) => Number(octet) <= 255) === true;\n}\n\n/**\n * The argument of EHLO or HELO (RFC 5321 §4.1.1.1): a host name of\n * letters, digits and hyphens, or an address literal.\n */\nexport function isHelloName(text: string): boolean {\n\treturn (\n\t\t/^[A-Za-z0-9-]+(?:\\.[A-Za-z0-9-]+)*$/.test(text) || isAddressLiteral(text)\n\t);\n}\n\nfunction isDomain(domain: string): boolean {\n\tif (isAddressLiteral(domain)) return true;\n\treturn (\n\t\tdomain.length <= 255 &&\n\t\tdomain.split('.').every((label) => label.length <= 63 && LABEL.test(label))\n\t);\n}\n\n/**\n * What `parsePath` does with a source route (`<@a,@b:local@domain>`, RFC 5321\n * Appendix C): a server accepts and discards it (`'discard'`), a client\n * refuses it, as §4.1.1.3 says clients should not send one (`'refuse'`).\n */\nexport type SourceRoute = 'discard' | 'refuse';\n\n/**\n * The mailbox after a source route, each of whose hops must be\n * `@domain` with a valid domain; `undefined` for any other route.\n */\nfunction afterRoute(inner: string): string | undefined {\n\tlet rest = inner;\n\tfor (;;) {\n\t\tconst hop = HOP.exec(rest);\n\t\tif (!hop || !isDomain(hop[1] as string)) return undefined;\n\t\trest = rest.slice(hop[0].length);\n\t\tif (hop[2] === ':') return rest;\n\t}\n}\n\n/**\n * Parses the `<path>` of RFC 5321 §4.1.2: `<local@domain>`, or `<>` when\n * `allowNull`. A source route (`<@a,@b:local@domain>`, §C) is dropped when\n * `sourceRoute` is `'discard'`, the default, provided each hop is\n * `@domain`; with `'refuse'` the path is not one. A C0 control (CR, LF,\n * NUL…), DEL or `>` anywhere refuses the path, as do C1 controls,\n * U+2028 and U+2029, Unicode format characters and lone surrogates. An IPv4 address literal\n * takes octets up to 255.\n * Non-ASCII is allowed: whether the session may use it is SMTPUTF8's\n * question (RFC 6531), not the grammar's. `undefined` when it is not a path.\n *\n * The local part is kept as written, quotes included: `\"v@x.example\"` and\n * `v%x.example` are local parts of the domain after the last `@`, not\n * addresses elsewhere. Code that delivers must not split on the first `@`.\n */\nexport function parsePath(\n\ttext: string,\n\tallowNull: boolean,\n\tsourceRoute: SourceRoute = 'discard',\n): Path | undefined {\n\tif (!text.startsWith('<') || !text.endsWith('>')) return undefined;\n\tlet inner: string | undefined = text.slice(1, -1);\n\tif (hasControl(inner) || INVISIBLE.test(inner)) return undefined;\n\tif (inner === '')\n\t\treturn allowNull ? { address: '', local: '', domain: '' } : undefined;\n\tif (inner.startsWith('@')) {\n\t\tif (sourceRoute === 'refuse') return undefined;\n\t\tinner = afterRoute(inner);\n\t\tif (inner === undefined) return undefined;\n\t}\n\tconst at = inner.lastIndexOf('@');\n\tif (at <= 0) return undefined;\n\tconst local = inner.slice(0, at);\n\tconst domain = inner.slice(at + 1);\n\tif (local.length > 64 || !(isDotString(local) || isQuotedString(local)))\n\t\treturn undefined;\n\tif (!isDomain(domain)) return undefined;\n\treturn {\n\t\taddress: `${local}@${domain.toLowerCase()}`,\n\t\tlocal,\n\t\tdomain: domain.toLowerCase(),\n\t};\n}\n",
7
7
  "/** Credentials a client gave with `AUTH`. */\nexport interface Credentials {\n\treadonly mechanism: 'PLAIN' | 'LOGIN';\n\treadonly username: string;\n\treadonly password: string;\n\t/**\n\t * PLAIN's authorization identity, when it differs from the username.\n\t * The server refuses such credentials before `authenticate` is asked.\n\t */\n\treadonly authorizationId?: string;\n}\n\nfunction base64ToText(text: string): string | undefined {\n\tif (!/^[A-Za-z0-9+/]*={0,2}$/.test(text) || text.length % 4 !== 0)\n\t\treturn undefined;\n\ttry {\n\t\treturn new TextDecoder('utf-8', { fatal: true }).decode(\n\t\t\tUint8Array.fromBase64(text),\n\t\t);\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/** PLAIN (RFC 4616): `authzid NUL authcid NUL passwd`, in base64. */\nexport function decodePlain(response: string): Credentials | undefined {\n\tconst text = base64ToText(response);\n\tif (text === undefined) return undefined;\n\tconst parts = text.split('\\0');\n\tif (parts.length !== 3) return undefined;\n\tconst [authorizationId = '', username = '', password = ''] = parts;\n\tif (username === '' || password === '') return undefined;\n\treturn {\n\t\tmechanism: 'PLAIN',\n\t\tusername,\n\t\tpassword,\n\t\t...(authorizationId === '' || authorizationId === username\n\t\t\t? {}\n\t\t\t: { authorizationId }),\n\t};\n}\n\n/** One step of LOGIN: a base64 line to its text. */\nexport function decodeLoginStep(response: string): string | undefined {\n\treturn base64ToText(response);\n}\n\nconst base64 = (text: string) => new TextEncoder().encode(text).toBase64();\n\n/** A client's PLAIN response (RFC 4616): `NUL username NUL password`, in base64, no authorization identity. */\nexport function encodePlain(username: string, password: string): string {\n\treturn base64(`\\0${username}\\0${password}`);\n}\n\n/** One step of LOGIN, the username or the password, in base64. */\nexport function encodeLoginStep(text: string): string {\n\treturn base64(text);\n}\n",
8
- "/**\n * What waits to leave a Bun socket. Bun's sockets do not buffer: `write`\n * takes what the kernel takes and says how much. The rest waits here for\n * the socket's `drain` event, so nothing written is lost to a peer that\n * reads slowly. The server's transport and the client's socket share it.\n */\nexport class Outgoing {\n\treadonly #write: (bytes: Uint8Array) => number;\n\t#queue: Uint8Array[] = [];\n\t#waiters: (() => void)[] = [];\n\n\tconstructor(write: (bytes: Uint8Array) => number) {\n\t\tthis.#write = write;\n\t}\n\n\t/** Nothing waits to leave. */\n\tget empty(): boolean {\n\t\treturn this.#queue.length === 0;\n\t}\n\n\t/** Writes what the socket takes now, and keeps the rest for `drain`. */\n\twrite(bytes: Uint8Array): void {\n\t\tif (this.#queue.length > 0) {\n\t\t\tthis.#queue.push(bytes);\n\t\t\treturn;\n\t\t}\n\t\tconst written = this.#write(bytes);\n\t\tif (written < bytes.length) {\n\t\t\tthis.#queue.push(bytes.subarray(Math.max(written, 0)));\n\t\t}\n\t}\n\n\t/** The socket's `drain`: it can take more. True once everything has left. */\n\tdrain(): boolean {\n\t\twhile (this.#queue.length > 0) {\n\t\t\tconst bytes = this.#queue[0] as Uint8Array;\n\t\t\tconst written = this.#write(bytes);\n\t\t\tif (written < bytes.length) {\n\t\t\t\tthis.#queue[0] = bytes.subarray(Math.max(written, 0));\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tthis.#queue.shift();\n\t\t}\n\t\tfor (const wake of this.#waiters.splice(0)) wake();\n\t\treturn true;\n\t}\n\n\t/** Resolves once everything written has left, or the socket closed. */\n\tdrained(): Promise<void> {\n\t\tif (this.#queue.length === 0) return Promise.resolve();\n\t\treturn new Promise((wake) => this.#waiters.push(wake));\n\t}\n\n\t/** The socket closed: nothing more will leave. */\n\tclear(): void {\n\t\tthis.#queue = [];\n\t\tfor (const wake of this.#waiters.splice(0)) wake();\n\t}\n}\n",
9
- "/**\n * The longest line taken, CRLF included: a command (RFC 5321 §4.5.3.1.4\n * asks for 512 at least) or a reply line (§4.5.3.1.5, 512 too).\n */\nexport const MAX_LINE = 2048;\n\n/** One line from the peer, or a line that was too long and was skipped. */\nexport type LineEvent = { line: string } | { tooLong: true };\n\n/**\n * Cuts a peer's bytes into lines — a client's commands, a server's\n * replies — ending at LF with or without CR. It holds one partial line at most: past `MAX_LINE`, the line is\n * skipped to its end and reported once.\n */\nexport class LineSplitter {\n\t#held: Uint8Array = new Uint8Array(0);\n\t#skipping = false;\n\t#rest: Uint8Array = new Uint8Array(0);\n\n\t/** Starts on a chunk; read its lines with `next`. */\n\tpush(chunk: Uint8Array): void {\n\t\tthis.#rest = this.#held.length > 0 ? concat(this.#held, chunk) : chunk;\n\t\tthis.#held = new Uint8Array(0);\n\t}\n\n\t/** The next line of the current chunk, or `undefined` when it has no more. */\n\tnext(): LineEvent | undefined {\n\t\tfor (;;) {\n\t\t\tconst data = this.#rest;\n\t\t\tconst lf = data.indexOf(0x0a);\n\t\t\tif (lf < 0) {\n\t\t\t\tthis.#rest = new Uint8Array(0);\n\t\t\t\tif (this.#skipping) return undefined;\n\t\t\t\tif (data.length > MAX_LINE) {\n\t\t\t\t\tthis.#skipping = true;\n\t\t\t\t\treturn { tooLong: true };\n\t\t\t\t}\n\t\t\t\tthis.#held = data.slice();\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tconst end = lf > 0 && data[lf - 1] === 0x0d ? lf - 1 : lf;\n\t\t\tthis.#rest = data.subarray(lf + 1);\n\t\t\tif (this.#skipping) {\n\t\t\t\tthis.#skipping = false;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (end > MAX_LINE) return { tooLong: true };\n\t\t\treturn { line: new TextDecoder().decode(data.subarray(0, end)) };\n\t\t}\n\t}\n\n\t/** Bytes are held or left: a line begun, or lines not yet read. */\n\tget holding(): boolean {\n\t\treturn this.#held.length > 0 || this.#rest.length > 0;\n\t}\n\n\t/** What is left of the current chunk: message content pipelined after DATA. */\n\ttakeRest(): Uint8Array {\n\t\tconst rest = this.#rest;\n\t\tthis.#rest = new Uint8Array(0);\n\t\treturn rest;\n\t}\n\n\t/** Forgets everything held: after STARTTLS, or after a refused DATA. */\n\tclear(): void {\n\t\tthis.#held = new Uint8Array(0);\n\t\tthis.#rest = new Uint8Array(0);\n\t\tthis.#skipping = false;\n\t}\n}\n\nfunction concat(a: Uint8Array, b: Uint8Array): Uint8Array {\n\tconst out = new Uint8Array(a.length + b.length);\n\tout.set(a, 0);\n\tout.set(b, a.length);\n\treturn out;\n}\n"
8
+ "/**\n * The longest line taken, CRLF included: a command (RFC 5321 §4.5.3.1.4\n * asks for 512 at least) or a reply line (§4.5.3.1.5, 512 too).\n */\nexport const MAX_LINE = 2048;\n\n/** One line from the peer, or a line that was too long and was skipped. */\nexport type LineEvent = { line: string } | { tooLong: true };\n\n/**\n * Cuts a peer's bytes into lines — a client's commands, a server's\n * replies — ending at LF with or without CR. It holds one partial line at most: past `MAX_LINE`, the line is\n * skipped to its end and reported once.\n */\nexport class LineSplitter {\n\t#held: Uint8Array = new Uint8Array(0);\n\t#skipping = false;\n\t#rest: Uint8Array = new Uint8Array(0);\n\n\t/** Starts on a chunk; read its lines with `next`. */\n\tpush(chunk: Uint8Array): void {\n\t\tthis.#rest = this.#held.length > 0 ? concat(this.#held, chunk) : chunk;\n\t\tthis.#held = new Uint8Array(0);\n\t}\n\n\t/** The next line of the current chunk, or `undefined` when it has no more. */\n\tnext(): LineEvent | undefined {\n\t\tfor (;;) {\n\t\t\tconst data = this.#rest;\n\t\t\tconst lf = data.indexOf(0x0a);\n\t\t\tif (lf < 0) {\n\t\t\t\tthis.#rest = new Uint8Array(0);\n\t\t\t\tif (this.#skipping) return undefined;\n\t\t\t\tif (data.length > MAX_LINE) {\n\t\t\t\t\tthis.#skipping = true;\n\t\t\t\t\treturn { tooLong: true };\n\t\t\t\t}\n\t\t\t\tthis.#held = data.slice();\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tconst end = lf > 0 && data[lf - 1] === 0x0d ? lf - 1 : lf;\n\t\t\tthis.#rest = data.subarray(lf + 1);\n\t\t\tif (this.#skipping) {\n\t\t\t\tthis.#skipping = false;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (end > MAX_LINE) return { tooLong: true };\n\t\t\treturn { line: new TextDecoder().decode(data.subarray(0, end)) };\n\t\t}\n\t}\n\n\t/** Bytes are held or left: a line begun, or lines not yet read. */\n\tget holding(): boolean {\n\t\treturn this.#held.length > 0 || this.#rest.length > 0;\n\t}\n\n\t/** What is left of the current chunk: message content pipelined after DATA. */\n\ttakeRest(): Uint8Array {\n\t\tconst rest = this.#rest;\n\t\tthis.#rest = new Uint8Array(0);\n\t\treturn rest;\n\t}\n\n\t/** Forgets everything held: after STARTTLS, or after a refused DATA. */\n\tclear(): void {\n\t\tthis.#held = new Uint8Array(0);\n\t\tthis.#rest = new Uint8Array(0);\n\t\tthis.#skipping = false;\n\t}\n}\n\nfunction concat(a: Uint8Array, b: Uint8Array): Uint8Array {\n\tconst out = new Uint8Array(a.length + b.length);\n\tout.set(a, 0);\n\tout.set(b, a.length);\n\treturn out;\n}\n",
9
+ "/**\n * What waits to leave a Bun socket. Bun's sockets do not buffer: `write`\n * takes what the kernel takes and says how much. The rest waits here for\n * the socket's `drain` event, so nothing written is lost to a peer that\n * reads slowly. The server's transport and the client's socket share it.\n */\nexport class Outgoing {\n\treadonly #write: (bytes: Uint8Array) => number;\n\t#queue: Uint8Array[] = [];\n\t#waiters: (() => void)[] = [];\n\n\tconstructor(write: (bytes: Uint8Array) => number) {\n\t\tthis.#write = write;\n\t}\n\n\t/** Nothing waits to leave. */\n\tget empty(): boolean {\n\t\treturn this.#queue.length === 0;\n\t}\n\n\t/** Writes what the socket takes now, and keeps the rest for `drain`. */\n\twrite(bytes: Uint8Array): void {\n\t\tif (this.#queue.length > 0) {\n\t\t\tthis.#queue.push(bytes);\n\t\t\treturn;\n\t\t}\n\t\tconst written = this.#write(bytes);\n\t\tif (written < bytes.length) {\n\t\t\tthis.#queue.push(bytes.subarray(Math.max(written, 0)));\n\t\t}\n\t}\n\n\t/** The socket's `drain`: it can take more. True once everything has left. */\n\tdrain(): boolean {\n\t\twhile (this.#queue.length > 0) {\n\t\t\tconst bytes = this.#queue[0] as Uint8Array;\n\t\t\tconst written = this.#write(bytes);\n\t\t\tif (written < bytes.length) {\n\t\t\t\tthis.#queue[0] = bytes.subarray(Math.max(written, 0));\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tthis.#queue.shift();\n\t\t}\n\t\tfor (const wake of this.#waiters.splice(0)) wake();\n\t\treturn true;\n\t}\n\n\t/** Resolves once everything written has left, or the socket closed. */\n\tdrained(): Promise<void> {\n\t\tif (this.#queue.length === 0) return Promise.resolve();\n\t\treturn new Promise((wake) => this.#waiters.push(wake));\n\t}\n\n\t/** The socket closed: nothing more will leave. */\n\tclear(): void {\n\t\tthis.#queue = [];\n\t\tfor (const wake of this.#waiters.splice(0)) wake();\n\t}\n}\n"
10
10
  ],
11
- "mappings": ";AA4CA,IAAM,YAAY,IAAI,IAAmB;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,CAAC;AAAA;AAUM,MAAM,mBAAkB,MAAM;AAAA,EAClB,OAAO;AAAA,EAChB;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAET,WAAW,CACV,MACA,SACA,UAA4B,CAAC,GAC5B;AAAA,IACD,MACC,SACA,QAAQ,UAAU,YAAY,YAAY,EAAE,OAAO,QAA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13
13
  "names": []
14
14
  }
@@ -7,7 +7,7 @@ import {
7
7
  MAX_LINE,
8
8
  LineSplitter,
9
9
  Outgoing
10
- } from "../chunks/index-n4xwep5m.js";
10
+ } from "../chunks/index-5228egp5.js";
11
11
  // src/client/address.ts
12
12
  function isMailbox(address) {
13
13
  return typeof address === "string" && parsePath2(`<${address}>`, false, "refuse") !== undefined;
@@ -302,6 +302,16 @@ var badReply = (host, what) => new SmtpError2("BAD_REPLY", `${host} sent ${what}
302
302
  var lost = (host, what) => new SmtpError2("CONNECTION_LOST", what === undefined ? `The connection to ${host} closed while the message was sent` : `The connection to ${host} closed before ${what}`);
303
303
  var timedOut = (host, what, seconds, deadline) => new SmtpError2("TIMEOUT", deadline === undefined ? `Timed out after ${seconds} s waiting for ${what} (${host})` : `The deadline of ${deadline} s passed waiting for ${what} (${host})`);
304
304
  var tlsFailed = (host, why) => new SmtpError2("TLS_FAILED", `TLS with ${host} failed: ${why}`);
305
+ function afterDot(error) {
306
+ if (!(error instanceof SmtpError2) || error.afterData || error.reply)
307
+ return error;
308
+ return new SmtpError2(error.code, error.message, {
309
+ temporary: error.temporary,
310
+ afterData: true,
311
+ ...error.rejected ? { rejected: error.rejected } : {},
312
+ ...error.cause === undefined ? {} : { cause: error.cause }
313
+ });
314
+ }
305
315
 
306
316
  // src/protocol/ehlo.ts
307
317
  function parseEhlo(lines) {
@@ -705,15 +715,22 @@ class ClientSocket {
705
715
  }
706
716
  }
707
717
  within(promise, seconds, what) {
718
+ const over = new AbortController;
708
719
  const gone = this.#gone.promise.then(() => {
709
- throw this.#hungUp(lost(this.host, what));
720
+ if (!over.signal.aborted)
721
+ throw this.#hungUp(lost(this.host, what));
722
+ });
723
+ const race = Promise.race([promise, gone]);
724
+ race.catch(() => {
725
+ return;
710
726
  });
711
- return this.#race(Promise.race([promise, gone]), seconds, what);
727
+ return this.#race(race, seconds, what).finally(() => over.abort());
712
728
  }
713
729
  write(data) {
714
730
  if (this.#failure || this.#closed)
715
- return;
731
+ return false;
716
732
  this.#outgoing.write(typeof data === "string" ? new TextEncoder().encode(data) : data);
733
+ return true;
717
734
  }
718
735
  async drained(seconds) {
719
736
  await this.#race(this.#outgoing.drained(), seconds, "the server to take the message");
@@ -840,8 +857,10 @@ async function data(socket, settings, content, ready) {
840
857
  socket.close(true);
841
858
  throw error;
842
859
  }
843
- socket.write(tail);
844
- const end = await socket.reply("the reply to the final dot", timeouts.dataEnd);
860
+ const dotSent = socket.write(tail);
861
+ const end = await socket.reply("the reply to the final dot", timeouts.dataEnd).catch((error) => {
862
+ throw dotSent ? afterDot(error) : error;
863
+ });
845
864
  if (end.code !== 250)
846
865
  throw refused(host, "the message", end);
847
866
  return end;
@@ -951,5 +970,5 @@ export {
951
970
  sendMail
952
971
  };
953
972
 
954
- //# debugId=6054CCD3D7858E7364756E2164756E21
973
+ //# debugId=F9FE8E458D7309C564756E2164756E21
955
974
  //# sourceMappingURL=index.js.map
@@ -7,17 +7,17 @@
7
7
  "const CR = 0x0d;\nconst LF = 0x0a;\nconst DOT = 0x2e;\n\n/**\n * Writes the content of `DATA` (RFC 5321 §4.1.1.4), the other half of\n * `DataReader`: a dot is added before every line that starts with one\n * (§4.5.2), and `end` closes the message with `<CRLF>.<CRLF>`. One pass,\n * one byte at a time, whatever the chunks.\n *\n * A bare CR or LF is counted in `bareLineBreaks`, as `DataReader` counts\n * it, for the caller to refuse the message: a server that reads one as a\n * line end is the SMTP smuggling a server refuses. With `normalize`, each\n * becomes CRLF instead. `eightBit` says whether a byte above 127 was seen.\n */\nexport class DataWriter {\n\treadonly #normalize: boolean;\n\t#lineStart = true;\n\t#heldCr = false;\n\tbareLineBreaks = 0;\n\teightBit = false;\n\n\tconstructor(normalize = false) {\n\t\tthis.#normalize = normalize;\n\t}\n\n\t/** A bare CR or LF: CRLF when normalising, else counted and kept as it is. */\n\t#bare(out: Uint8Array, n: number, byte: number): number {\n\t\tif (this.#normalize) {\n\t\t\tout[n++] = CR;\n\t\t\tout[n++] = LF;\n\t\t\tthis.#lineStart = true;\n\t\t\treturn n;\n\t\t}\n\t\tthis.bareLineBreaks++;\n\t\tout[n++] = byte;\n\t\tthis.#lineStart = false;\n\t\treturn n;\n\t}\n\n\t/** The next bytes of the message, stuffed. */\n\twrite(chunk: Uint8Array): Uint8Array {\n\t\t// At worst every byte doubles: a dot or a bare line break each.\n\t\tconst out = new Uint8Array(chunk.length * 2 + 2);\n\t\tlet n = 0;\n\t\tfor (let i = 0; i < chunk.length; i++) {\n\t\t\tconst byte = chunk[i] as number;\n\t\t\tif (this.#heldCr) {\n\t\t\t\tthis.#heldCr = false;\n\t\t\t\tif (byte === LF) {\n\t\t\t\t\tout[n++] = CR;\n\t\t\t\t\tout[n++] = LF;\n\t\t\t\t\tthis.#lineStart = true;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tn = this.#bare(out, n, CR);\n\t\t\t}\n\t\t\tif (byte === CR) {\n\t\t\t\tthis.#heldCr = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (byte === LF) {\n\t\t\t\tn = this.#bare(out, n, LF);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (byte === DOT && this.#lineStart) out[n++] = DOT;\n\t\t\tif (byte > 0x7f) this.eightBit = true;\n\t\t\tout[n++] = byte;\n\t\t\tthis.#lineStart = false;\n\t\t}\n\t\treturn out.subarray(0, n);\n\t}\n\n\t/** The end of the message: a CRLF if its last line has none, then `.` CRLF. */\n\tend(): Uint8Array {\n\t\tconst out = new Uint8Array(7);\n\t\tlet n = 0;\n\t\tif (this.#heldCr) {\n\t\t\tthis.#heldCr = false;\n\t\t\tn = this.#bare(out, n, CR);\n\t\t}\n\t\tif (!this.#lineStart) {\n\t\t\tout[n++] = CR;\n\t\t\tout[n++] = LF;\n\t\t}\n\t\tout[n++] = DOT;\n\t\tout[n++] = CR;\n\t\tout[n++] = LF;\n\t\treturn out.subarray(0, n);\n\t}\n}\n",
8
8
  "import { SmtpError } from '../errors';\nimport { DataWriter } from '../protocol/data-writer';\nimport type { MessageSource } from './options';\n\n/** The slice of a message in memory sent at once. */\nconst SLICE = 64 * 1024;\n\n/** The message's bytes, one slice at a time; `undefined` once they end. */\nexport interface Chunks {\n\tnext(): Promise<Uint8Array | undefined>;\n\t/** Stops reading: a delivery that failed half-way. */\n\tcancel(): void;\n}\n\n/** A message ready to send: what is known of it before the first byte, and its bytes. */\nexport interface Content {\n\t/** Bytes, when known before sending: SIZE declares it. */\n\treadonly size?: number;\n\t/** A byte above 127, when known before sending: it needs 8BITMIME. */\n\treadonly eightBit: boolean;\n\tchunks(): Chunks;\n}\n\n/** The error for a bare CR or LF in the message: a server must refuse it, and this client does first. */\nexport const bareLineBreak = () =>\n\tnew SmtpError(\n\t\t'BARE_LINE_BREAK',\n\t\t'sendMail(): the message holds a bare CR or LF, which a server must refuse (SMTP smuggling); end every line with CRLF, or pass normalizeLineEnds: true',\n\t);\n\n/** Bytes in `SLICE`s, so no chunk sent at once is larger. */\nfunction sliced(next: () => Promise<Uint8Array | undefined>) {\n\tlet held: Uint8Array | undefined;\n\treturn async (): Promise<Uint8Array | undefined> => {\n\t\tif (!held || held.length === 0) held = await next();\n\t\tif (!held) return undefined;\n\t\tconst slice = held.subarray(0, SLICE);\n\t\theld = held.subarray(SLICE);\n\t\treturn slice;\n\t};\n}\n\nfunction fromBytes(bytes: Uint8Array): Chunks {\n\tlet given = false;\n\tconst next = sliced(async () => {\n\t\tif (given) return undefined;\n\t\tgiven = true;\n\t\treturn bytes;\n\t});\n\treturn { next, cancel() {} };\n}\n\nfunction fromStream(stream: ReadableStream<Uint8Array>): Chunks {\n\tconst reader = stream.getReader();\n\tconst next = sliced(async () => {\n\t\tconst { done, value } = await reader.read();\n\t\tif (done) return undefined;\n\t\tif (!(value instanceof Uint8Array)) {\n\t\t\tthrow new SmtpError(\n\t\t\t\t'INVALID_OPTION',\n\t\t\t\t'sendMail(): a message stream must give Uint8Array chunks',\n\t\t\t);\n\t\t}\n\t\treturn value;\n\t});\n\treturn {\n\t\tnext,\n\t\tcancel: () => void reader.cancel().catch(() => {}),\n\t};\n}\n\n/**\n * The message, checked before any connection when it is in memory: a bare\n * CR or LF is refused here (unless normalised), and its size and 8-bit\n * bytes are known for MAIL FROM. A stream is checked as it is sent.\n */\nexport function contentOf(\n\tmessage: MessageSource,\n\tnormalize: boolean,\n\tsize: number | undefined,\n): Content {\n\tif (message instanceof ReadableStream) {\n\t\tlet read = false;\n\t\treturn {\n\t\t\t...(size === undefined ? {} : { size }),\n\t\t\teightBit: false,\n\t\t\tchunks() {\n\t\t\t\tif (read) {\n\t\t\t\t\tthrow new SmtpError(\n\t\t\t\t\t\t'INVALID_OPTION',\n\t\t\t\t\t\t'sendMail(): a message stream can be sent once only',\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tread = true;\n\t\t\t\treturn fromStream(message);\n\t\t\t},\n\t\t};\n\t}\n\tlet bytes: Uint8Array;\n\tif (typeof message === 'string') bytes = new TextEncoder().encode(message);\n\telse if (message instanceof Uint8Array) bytes = message;\n\telse {\n\t\tthrow new SmtpError(\n\t\t\t'INVALID_OPTION',\n\t\t\t'sendMail(): the message must be a Uint8Array, a string or a ReadableStream',\n\t\t);\n\t}\n\t// One dry run: what the server will be sent, its size as normalised.\n\tconst writer = new DataWriter(normalize);\n\tlet sent = 0;\n\tfor (let at = 0; at < bytes.length; at += SLICE) {\n\t\tsent += writer.write(bytes.subarray(at, at + SLICE)).length;\n\t}\n\twriter.end();\n\tif (writer.bareLineBreaks > 0) throw bareLineBreak();\n\treturn {\n\t\tsize: sent,\n\t\teightBit: writer.eightBit,\n\t\tchunks: () => fromBytes(bytes),\n\t};\n}\n",
9
9
  "import type { Reply } from './reply';\n\n/** The most lines one reply may have; an EHLO reply has a dozen or so. */\nexport const MAX_REPLY_LINES = 100;\n\n/** A reply line's parts: `250-text` or `250 text`, or a bare `250`. */\ninterface ReplyLine {\n\treadonly code: number;\n\treadonly last: boolean;\n\treadonly text: string;\n}\n\nconst isDigit = (c: number) => c >= 0x30 && c <= 0x39;\n\n/** RFC 5321 §4.2: three digits, the first 2 to 5, then a space, a hyphen, or nothing. */\nfunction parseLine(line: string): ReplyLine | undefined {\n\tif (line.length < 3) return undefined;\n\tconst a = line.charCodeAt(0);\n\tif (a < 0x32 || a > 0x35) return undefined;\n\tif (!isDigit(line.charCodeAt(1)) || !isDigit(line.charCodeAt(2)))\n\t\treturn undefined;\n\tconst code = Number(line.slice(0, 3));\n\tif (line.length === 3) return { code, last: true, text: '' };\n\tconst separator = line[3];\n\tif (separator !== ' ' && separator !== '-') return undefined;\n\treturn { code, last: separator === ' ', text: line.slice(4) };\n}\n\n/** `x.y.z` of RFC 3463, its class the reply's own first digit. */\nfunction statusOf(code: number, text: string): string | undefined {\n\tconst space = text.indexOf(' ');\n\tconst token = space < 0 ? text : text.slice(0, space);\n\tif (token.length > 11 || !/^[245]\\.\\d{1,3}\\.\\d{1,3}$/.test(token))\n\t\treturn undefined;\n\treturn token[0] === String(code)[0] ? token : undefined;\n}\n\n/** A reply put together: the enhanced status taken off every line that starts with it. */\nfunction build(code: number, lines: readonly string[]): Reply {\n\tconst status = statusOf(code, lines[0] ?? '');\n\tconst text = status\n\t\t? lines.map((line) =>\n\t\t\t\tline.startsWith(`${status} `)\n\t\t\t\t\t? line.slice(status.length + 1)\n\t\t\t\t\t: line === status\n\t\t\t\t\t\t? ''\n\t\t\t\t\t\t: line,\n\t\t\t)\n\t\t: [...lines];\n\tconst body = text.length === 1 ? (text[0] as string) : text;\n\treturn status === undefined\n\t\t? { code, text: body }\n\t\t: { code, status, text: body };\n}\n\n/**\n * Puts a server's reply lines together (RFC 5321 §4.2.1): `code-` lines,\n * then a `code ` line, all with the same code. Each line costs one pass,\n * and a reply holds `MAX_REPLY_LINES` at most; what is not a reply is an\n * error, never guessed at.\n */\nexport class ReplyReader {\n\t#lines: string[] = [];\n\t#code = 0;\n\n\t/** One line, CRLF taken off: the reply it completes, `undefined` while it goes on, or why it is not one. */\n\tline(text: string): Reply | { readonly error: string } | undefined {\n\t\tconst parsed = parseLine(text);\n\t\tif (!parsed) {\n\t\t\tconst shown = text.length > 40 ? `${text.slice(0, 40)}…` : text;\n\t\t\treturn {\n\t\t\t\terror: `a line that is not an SMTP reply: ${JSON.stringify(shown)}`,\n\t\t\t};\n\t\t}\n\t\tif (this.#lines.length > 0 && parsed.code !== this.#code) {\n\t\t\treturn {\n\t\t\t\terror: `a reply whose lines change code, from ${this.#code} to ${parsed.code}`,\n\t\t\t};\n\t\t}\n\t\tif (this.#lines.length >= MAX_REPLY_LINES) {\n\t\t\treturn { error: `a reply of more than ${MAX_REPLY_LINES} lines` };\n\t\t}\n\t\tthis.#code = parsed.code;\n\t\tthis.#lines.push(parsed.text);\n\t\tif (!parsed.last) return undefined;\n\t\tconst lines = this.#lines;\n\t\tthis.#lines = [];\n\t\treturn build(parsed.code, lines);\n\t}\n}\n\n/** A reply's text as one line: its lines joined with a space. */\nexport function replyText(reply: Reply): string {\n\treturn typeof reply.text === 'string' ? reply.text : reply.text.join(' ');\n}\n",
10
- "import { SmtpError } from '../errors';\nimport type { Reply } from '../protocol/reply';\nimport { replyText } from '../protocol/reply-reader';\n\n/** A reply as an error message shows it: code, status, text, cut at 200 characters. */\nexport function shown(reply: Reply): string {\n\tconst text = replyText(reply);\n\tconst line = `${reply.code}${reply.status ? ` ${reply.status}` : ''} ${text}`;\n\treturn line.length > 200 ? `${line.slice(0, 200)}…` : line;\n}\n\n/** `REFUSED`, temporary for a 4xx: the server said no to `what`. */\nexport function refused(host: string, what: string, reply: Reply): SmtpError {\n\treturn new SmtpError('REFUSED', `${host} refused ${what}: ${shown(reply)}`, {\n\t\treply,\n\t});\n}\n\n/** `BAD_REPLY`: what the server sent is not a reply, or too much of one. */\nexport const badReply = (host: string, what: string) =>\n\tnew SmtpError('BAD_REPLY', `${host} sent ${what}`);\n\n/** `CONNECTION_LOST` while waiting for `what`, or while the message was sent. */\nexport const lost = (host: string, what?: string) =>\n\tnew SmtpError(\n\t\t'CONNECTION_LOST',\n\t\twhat === undefined\n\t\t\t? `The connection to ${host} closed while the message was sent`\n\t\t\t: `The connection to ${host} closed before ${what}`,\n\t);\n\n/** `TIMEOUT`: a step's own, or the whole delivery's deadline when `deadline` is given. */\nexport const timedOut = (\n\thost: string,\n\twhat: string,\n\tseconds: number,\n\tdeadline?: number,\n) =>\n\tnew SmtpError(\n\t\t'TIMEOUT',\n\t\tdeadline === undefined\n\t\t\t? `Timed out after ${seconds} s waiting for ${what} (${host})`\n\t\t\t: `The deadline of ${deadline} s passed waiting for ${what} (${host})`,\n\t);\n\n/** `TLS_FAILED`: the handshake, or the certificate's check. */\nexport const tlsFailed = (host: string, why: string) =>\n\tnew SmtpError('TLS_FAILED', `TLS with ${host} failed: ${why}`);\n",
10
+ "import { SmtpError } from '../errors';\nimport type { Reply } from '../protocol/reply';\nimport { replyText } from '../protocol/reply-reader';\n\n/** A reply as an error message shows it: code, status, text, cut at 200 characters. */\nexport function shown(reply: Reply): string {\n\tconst text = replyText(reply);\n\tconst line = `${reply.code}${reply.status ? ` ${reply.status}` : ''} ${text}`;\n\treturn line.length > 200 ? `${line.slice(0, 200)}…` : line;\n}\n\n/** `REFUSED`, temporary for a 4xx: the server said no to `what`. */\nexport function refused(host: string, what: string, reply: Reply): SmtpError {\n\treturn new SmtpError('REFUSED', `${host} refused ${what}: ${shown(reply)}`, {\n\t\treply,\n\t});\n}\n\n/** `BAD_REPLY`: what the server sent is not a reply, or too much of one. */\nexport const badReply = (host: string, what: string) =>\n\tnew SmtpError('BAD_REPLY', `${host} sent ${what}`);\n\n/** `CONNECTION_LOST` while waiting for `what`, or while the message was sent. */\nexport const lost = (host: string, what?: string) =>\n\tnew SmtpError(\n\t\t'CONNECTION_LOST',\n\t\twhat === undefined\n\t\t\t? `The connection to ${host} closed while the message was sent`\n\t\t\t: `The connection to ${host} closed before ${what}`,\n\t);\n\n/** `TIMEOUT`: a step's own, or the whole delivery's deadline when `deadline` is given. */\nexport const timedOut = (\n\thost: string,\n\twhat: string,\n\tseconds: number,\n\tdeadline?: number,\n) =>\n\tnew SmtpError(\n\t\t'TIMEOUT',\n\t\tdeadline === undefined\n\t\t\t? `Timed out after ${seconds} s waiting for ${what} (${host})`\n\t\t\t: `The deadline of ${deadline} s passed waiting for ${what} (${host})`,\n\t);\n\n/** `TLS_FAILED`: the handshake, or the certificate's check. */\nexport const tlsFailed = (host: string, why: string) =>\n\tnew SmtpError('TLS_FAILED', `TLS with ${host} failed: ${why}`);\n\n/**\n * `error` as it is, marked `afterData` when it is an `SmtpError` of a\n * missing reply to the final dot: the same code, message, `temporary`,\n * `rejected` and `cause`.\n */\nexport function afterDot(error: unknown): unknown {\n\tif (!(error instanceof SmtpError) || error.afterData || error.reply)\n\t\treturn error; // a reply is the server's word: it did not take the message\n\treturn new SmtpError(error.code, error.message, {\n\t\ttemporary: error.temporary,\n\t\tafterData: true,\n\t\t...(error.rejected ? { rejected: error.rejected } : {}),\n\t\t...(error.cause === undefined ? {} : { cause: error.cause }),\n\t});\n}\n",
11
11
  "/**\n * The extensions an EHLO reply names (RFC 5321 §4.1.1.1): every line after\n * the first is a keyword, then its parameters. Keywords in upper case,\n * parameters as written, spaces around them dropped.\n */\nexport function parseEhlo(\n\tlines: readonly string[],\n): ReadonlyMap<string, string> {\n\tconst extensions = new Map<string, string>();\n\tfor (const line of lines.slice(1)) {\n\t\tconst text = line.trim();\n\t\tconst space = text.indexOf(' ');\n\t\tconst keyword = (space < 0 ? text : text.slice(0, space)).toUpperCase();\n\t\tif (keyword === '') continue;\n\t\textensions.set(keyword, space < 0 ? '' : text.slice(space + 1).trim());\n\t}\n\treturn extensions;\n}\n",
12
12
  "import { SmtpError } from '../errors';\nimport { parseEhlo } from '../protocol/ehlo';\nimport { encodeLoginStep, encodePlain } from '../protocol/sasl';\nimport { refused, shown } from './refusal';\nimport type { ClientSettings } from './settings';\nimport type { ClientSocket } from './socket';\nimport type { TlsTarget } from './target';\n\n/** A session past its greeting, EHLO, STARTTLS and AUTH: what the server offers. */\nexport interface Ready {\n\treadonly extensions: ReadonlyMap<string, string>;\n\treadonly authenticated: boolean;\n}\n\n/** EHLO, or HELO when the server refuses EHLO with a 5xx (RFC 5321 §4.1.4). */\nasync function hello(\n\tsocket: ClientSocket,\n\tsettings: ClientSettings,\n\tallowHelo: boolean,\n): Promise<ReadonlyMap<string, string>> {\n\tconst seconds = settings.timeouts.command;\n\tsocket.write(`EHLO ${settings.helo}\\r\\n`);\n\tconst ehlo = await socket.reply('the reply to EHLO', seconds);\n\tif (ehlo.code === 250) {\n\t\treturn parseEhlo(typeof ehlo.text === 'string' ? [ehlo.text] : ehlo.text);\n\t}\n\tif (ehlo.code < 500 || !allowHelo) throw refused(socket.host, 'EHLO', ehlo);\n\tsocket.write(`HELO ${settings.helo}\\r\\n`);\n\tconst helo = await socket.reply('the reply to HELO', seconds);\n\tif (helo.code !== 250) throw refused(socket.host, 'HELO', helo);\n\treturn new Map();\n}\n\n/** STARTTLS when offered (RFC 3207); `required` fails without it, `opportunistic` goes on in clear. */\nasync function startTls(\n\tsocket: ClientSocket,\n\tsettings: ClientSettings,\n\ttls: TlsTarget,\n\textensions: ReadonlyMap<string, string>,\n): Promise<ReadonlyMap<string, string>> {\n\tconst required = settings.tls === 'required';\n\tif (!extensions.has('STARTTLS')) {\n\t\tif (!required) return extensions;\n\t\tthrow new SmtpError(\n\t\t\t'TLS_UNAVAILABLE',\n\t\t\t`${socket.host} does not offer STARTTLS, and tls is 'required'`,\n\t\t);\n\t}\n\tsocket.write('STARTTLS\\r\\n');\n\tconst answer = await socket.reply(\n\t\t'the reply to STARTTLS',\n\t\tsettings.timeouts.command,\n\t);\n\tif (answer.code !== 220) {\n\t\tif (!required) return extensions;\n\t\tthrow new SmtpError(\n\t\t\t'TLS_UNAVAILABLE',\n\t\t\t`${socket.host} refused STARTTLS, and tls is 'required': ${shown(answer)}`,\n\t\t\t{ reply: answer, temporary: true },\n\t\t);\n\t}\n\tawait socket.startTls(tls, settings.timeouts.connect);\n\t// RFC 3207 §4.2: what was learnt in clear is forgotten; EHLO again.\n\treturn hello(socket, settings, false);\n}\n\n/** AUTH PLAIN or LOGIN (RFC 4954), over TLS unless `allowPlaintextAuth`. */\nasync function authenticate(\n\tsocket: ClientSocket,\n\tsettings: ClientSettings,\n\textensions: ReadonlyMap<string, string>,\n): Promise<void> {\n\tconst { auth } = settings;\n\tif (!auth) return;\n\tconst { host } = socket;\n\tif (!socket.secure && !settings.allowPlaintextAuth) {\n\t\tthrow new SmtpError(\n\t\t\t'AUTH_UNAVAILABLE',\n\t\t\t`Refusing to send credentials to ${host} in clear: it did not start TLS (allowPlaintextAuth is for a local test server only)`,\n\t\t);\n\t}\n\tconst offered = (extensions.get('AUTH') ?? '').toUpperCase().split(' ');\n\tconst mechanism =\n\t\tauth.mechanism ??\n\t\t(offered.includes('PLAIN')\n\t\t\t? 'PLAIN'\n\t\t\t: offered.includes('LOGIN')\n\t\t\t\t? 'LOGIN'\n\t\t\t\t: undefined);\n\tif (!mechanism || !offered.includes(mechanism)) {\n\t\tthrow new SmtpError(\n\t\t\t'AUTH_UNAVAILABLE',\n\t\t\t`${host} offers no AUTH mechanism this client speaks (${auth.mechanism ?? 'PLAIN, LOGIN'}): AUTH ${extensions.get('AUTH') ?? 'is not offered'}`,\n\t\t);\n\t}\n\tconst seconds = settings.timeouts.command;\n\tconst steps =\n\t\tmechanism === 'PLAIN'\n\t\t\t? [`AUTH PLAIN ${encodePlain(auth.username, auth.password)}`]\n\t\t\t: [\n\t\t\t\t\t'AUTH LOGIN',\n\t\t\t\t\tencodeLoginStep(auth.username),\n\t\t\t\t\tencodeLoginStep(auth.password),\n\t\t\t\t];\n\tfor (const [i, step] of steps.entries()) {\n\t\tsocket.write(`${step}\\r\\n`);\n\t\tconst answer = await socket.reply('the reply to AUTH', seconds);\n\t\tconst last = i === steps.length - 1;\n\t\tif (answer.code === (last ? 235 : 334)) continue;\n\t\tthrow refused(host, `AUTH ${mechanism}`, answer);\n\t}\n}\n\n/** The greeting, EHLO, STARTTLS and AUTH: a session ready for MAIL FROM. */\nexport async function open(\n\tsocket: ClientSocket,\n\tsettings: ClientSettings,\n\ttls: TlsTarget,\n): Promise<Ready> {\n\tconst greeting = await socket.reply(\n\t\t'the greeting',\n\t\tsettings.timeouts.greeting,\n\t);\n\tif (greeting.code !== 220) {\n\t\tthrow refused(socket.host, 'the connection', greeting);\n\t}\n\tlet extensions = await hello(socket, settings, true);\n\tif (!socket.secure && settings.tls !== 'none') {\n\t\textensions = await startTls(socket, settings, tls, extensions);\n\t}\n\tawait authenticate(socket, settings, extensions);\n\treturn { extensions, authenticated: settings.auth !== undefined };\n}\n",
13
13
  "import { hostname as machineName } from 'node:os';\nimport { SmtpError } from '../errors';\nimport { isHelloName, parsePath } from '../protocol/path';\nimport { isMailbox } from './address';\nimport type {\n\tMxDestination,\n\tSendMailAuth,\n\tSendMailEnvelope,\n\tSendMailOptions,\n\tSendMailTimeouts,\n\tTlsMode,\n} from './options';\n\n/** The longest delay `setTimeout` takes, in seconds: past 2^31 − 1 ms it fires after 1 ms. */\nexport const MAX_SECONDS = Math.floor(2_147_483_647 / 1000);\n\n/** RFC 5321 §4.5.3.2's timeouts; `connect` is this client's own. */\nconst TIMEOUTS: Required<SendMailTimeouts> = {\n\tconnect: 30,\n\tgreeting: 300,\n\tcommand: 300,\n\tmail: 300,\n\trcpt: 300,\n\tdataStart: 120,\n\tdataBlock: 180,\n\tdataEnd: 600,\n};\n\n/** The options, checked, with their defaults; timeouts in seconds. */\nexport interface ClientSettings {\n\treadonly from: string;\n\treadonly to: readonly string[];\n\treadonly helo: string;\n\treadonly tls: TlsMode;\n\treadonly secure: boolean;\n\treadonly ca?: readonly string[];\n\treadonly auth?: SendMailAuth;\n\treadonly allowPlaintextAuth: boolean;\n\treadonly size?: number;\n\t/** An address is not ASCII, or `smtputf8` asked for it. */\n\treadonly smtputf8: boolean;\n\treadonly normalizeLineEnds: boolean;\n\treadonly timeouts: Required<SendMailTimeouts>;\n\treadonly deadline: number;\n}\n\n/** `INVALID_OPTION`, for an option `sendMail` cannot take. */\nexport const invalid = (message: string) =>\n\tnew SmtpError('INVALID_OPTION', `sendMail(): ${message}`);\n\nfunction seconds(name: string, value: unknown, fallback: number): number {\n\tif (value === undefined) return fallback;\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 ${String(value)}`,\n\t\t);\n\t}\n\treturn value;\n}\n\nfunction timeoutsOf(given: SendMailTimeouts = {}): Required<SendMailTimeouts> {\n\tconst out: Record<string, number> = {};\n\tfor (const [name, fallback] of Object.entries(TIMEOUTS)) {\n\t\tout[name] = seconds(\n\t\t\t`timeouts.${name}`,\n\t\t\tgiven[name as keyof SendMailTimeouts],\n\t\t\tfallback,\n\t\t);\n\t}\n\treturn out as Required<SendMailTimeouts>;\n}\n\n/**\n * `from` or a recipient, checked as an RFC 5321 path, since it is written\n * into `MAIL FROM:<…>` or `RCPT TO:<…>` as it is. A source route is refused\n * (§4.1.1.3: clients should not send one), with a message of its own when\n * the route is otherwise valid. What it takes, past the null sender, is\n * exactly what `isMailbox` says yes to: the two share one predicate.\n */\nfunction address(value: unknown, allowNull: boolean): string {\n\tif (allowNull && value === '') return '';\n\tif (isMailbox(value)) return value;\n\tconst text = typeof value === 'string' ? value : '';\n\tconst routed = typeof value === 'string' && parsePath(`<${text}>`, false);\n\tif (routed) {\n\t\tthrow invalid(\n\t\t\t`${JSON.stringify(value)} holds a source route (@host:), which RFC 5321 says a client should not send: pass ${JSON.stringify(`${routed.local}@${text.slice(text.lastIndexOf('@') + 1)}`)} alone`,\n\t\t);\n\t}\n\tthrow invalid(\n\t\t`${JSON.stringify(value)} is not an address (local@domain${allowNull ? \", or '' for a bounce\" : ''})`,\n\t);\n}\n\n/**\n * `helo`, checked. By MX it is required: the machine's name (such as\n * `laptop.local`) is rarely a name that resolves back to the sender, which\n * receiving hosts penalise, and it would tell them the machine's name.\n */\nfunction heloOf(value: string | undefined, byMx: boolean): string {\n\tif (value !== undefined) {\n\t\tif (!isHelloName(value))\n\t\t\tthrow invalid(`helo \"${value}\" is not a host name`);\n\t\treturn value;\n\t}\n\tif (byMx)\n\t\tthrow invalid(\n\t\t\t\"helo is required for delivery by MX: pass your server's public name, such as helo: 'mail.example.com'\",\n\t\t);\n\tconst name = machineName();\n\treturn isHelloName(name) ? name : 'localhost';\n}\n\nfunction authOf(auth: SendMailAuth | undefined): SendMailAuth | undefined {\n\tif (auth === undefined) return undefined;\n\tconst { username, password, mechanism } = auth;\n\tif (typeof username !== 'string' || username === '')\n\t\tthrow invalid('auth.username must be a non-empty string');\n\tif (typeof password !== 'string' || password === '')\n\t\tthrow invalid('auth.password must be a non-empty string');\n\tif (mechanism !== undefined && mechanism !== 'PLAIN' && mechanism !== 'LOGIN')\n\t\tthrow invalid(\n\t\t\t`auth.mechanism must be 'PLAIN' or 'LOGIN', not ${mechanism}`,\n\t\t);\n\treturn auth;\n}\n\nfunction tlsOf(options: SendMailOptions, plaintextAuth: boolean): TlsMode {\n\tconst secure = options.secure === true;\n\tconst tls =\n\t\toptions.tls ??\n\t\t(secure || (options.auth && !plaintextAuth) ? 'required' : 'opportunistic');\n\tif (tls !== 'opportunistic' && tls !== 'required' && tls !== 'none')\n\t\tthrow invalid(\n\t\t\t`tls must be 'opportunistic', 'required' or 'none', not ${tls}`,\n\t\t);\n\tif (tls === 'none' && secure)\n\t\tthrow invalid(\n\t\t\t\"secure is TLS from the first byte: it cannot go with tls: 'none'\",\n\t\t);\n\tif (tls === 'none' && options.auth && !plaintextAuth)\n\t\tthrow invalid(\n\t\t\t\"auth with tls: 'none' would send the password in clear; pass allowPlaintextAuth: true for a local test server\",\n\t\t);\n\tif (tls === 'opportunistic' && options.auth && !plaintextAuth)\n\t\tthrow invalid(\n\t\t\t\"auth with tls: 'opportunistic' would send the password to a server whose certificate is not checked; leave tls out to check it, or pass allowPlaintextAuth: true for a local test server\",\n\t\t);\n\treturn tls;\n}\n\n/** Checks every option; throws an `SmtpError` (`INVALID_OPTION`) on the first wrong one. */\nexport function settingsOf(options: SendMailOptions): ClientSettings {\n\tif (typeof options !== 'object' || options === null)\n\t\tthrow invalid('options must be an object');\n\tconst from = address(options.from, true);\n\tconst list = typeof options.to === 'string' ? [options.to] : options.to;\n\tif (!Array.isArray(list) || list.length === 0)\n\t\tthrow invalid('to must name one recipient or more');\n\tconst to = list.map((recipient) => address(recipient, false));\n\tconst allowPlaintextAuth = options.allowPlaintextAuth === true;\n\tconst { size } = options;\n\tif (size !== undefined && (!Number.isSafeInteger(size) || size < 0))\n\t\tthrow invalid(`size must be a number of bytes, not ${size}`);\n\tconst ca = options.ca === undefined ? undefined : [options.ca].flat();\n\tconst auth = authOf(options.auth);\n\treturn {\n\t\tfrom,\n\t\tto,\n\t\thelo: heloOf(options.helo, byMx(options)),\n\t\ttls: tlsOf(options, allowPlaintextAuth),\n\t\tsecure: options.secure === true,\n\t\t...(ca ? { ca } : {}),\n\t\t...(auth ? { auth } : {}),\n\t\tallowPlaintextAuth,\n\t\t...(size === undefined ? {} : { size }),\n\t\tsmtputf8:\n\t\t\toptions.smtputf8 === true ||\n\t\t\t[from, ...to].some((text) => /[^ -~]/.test(text)),\n\t\tnormalizeLineEnds: options.normalizeLineEnds === true,\n\t\ttimeouts: timeoutsOf(options.timeouts),\n\t\tdeadline: seconds('deadline', options.deadline, 1800),\n\t};\n}\n\n/** Whether the options name a domain to deliver to by MX, not a host. */\nexport const byMx = (\n\toptions: SendMailOptions,\n): options is SendMailEnvelope & MxDestination =>\n\t!('host' in options && options.host !== undefined);\n\n/** A port: an integer from 1 to 65535. */\nexport function portOf(port: number | undefined, fallback: number): number {\n\tif (port === undefined) return fallback;\n\tif (!Number.isInteger(port) || port < 1 || port > 65535)\n\t\tthrow invalid(`port must be an integer from 1 to 65535, not ${port}`);\n\treturn port;\n}\n",
14
14
  "import { LineSplitter, MAX_LINE } from '../protocol/lines';\nimport type { Reply } from '../protocol/reply';\nimport { ReplyReader } from '../protocol/reply-reader';\n\n/** The most bytes a server may send in one session, every reply together. */\nexport const MAX_REPLY_BYTES = 1024 * 1024;\n\n/**\n * What a server sent, put together into replies, each bounded: `MAX_LINE`\n * a line, `MAX_REPLY_LINES` a reply, `MAX_REPLY_BYTES` in all. One pass\n * over the bytes, whatever the chunks.\n */\nexport class Inbox {\n\treadonly #lines = new LineSplitter();\n\treadonly #reader = new ReplyReader();\n\treadonly #replies: Reply[] = [];\n\t#received = 0;\n\n\t/** Takes the next bytes; says what is wrong with them, if they are not replies. */\n\tpush(chunk: Uint8Array): string | undefined {\n\t\tthis.#received += chunk.length;\n\t\tif (this.#received > MAX_REPLY_BYTES) {\n\t\t\treturn `more than ${MAX_REPLY_BYTES} bytes of replies`;\n\t\t}\n\t\tthis.#lines.push(chunk);\n\t\tfor (let event = this.#lines.next(); event; event = this.#lines.next()) {\n\t\t\tif ('tooLong' in event)\n\t\t\t\treturn `a reply line longer than ${MAX_LINE} bytes`;\n\t\t\tconst result = this.#reader.line(event.line);\n\t\t\tif (result === undefined) continue;\n\t\t\tif ('error' in result) return result.error;\n\t\t\tthis.#replies.push(result);\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/** The next complete reply. */\n\tshift(): Reply | undefined {\n\t\treturn this.#replies.shift();\n\t}\n\n\t/** Bytes or replies not yet read. */\n\tget holding(): boolean {\n\t\treturn this.#lines.holding || this.#replies.length > 0;\n\t}\n}\n",
15
15
  "import type { TLSOptions } from 'bun';\n\n/** Where to connect: `host` names the server in errors, and is what TLS checks. */\nexport interface Endpoint {\n\treadonly host: string;\n\treadonly address: string;\n\treadonly port: number;\n}\n\n/** How to start TLS: check the certificate against `servername`, or not. */\nexport interface TlsTarget {\n\treadonly servername: string;\n\treadonly verify: boolean;\n\treadonly ca?: readonly string[];\n}\n\n/** Bun's TLS options for a target: `rejectUnauthorized` only when checking (RFC 7435 otherwise). */\nexport const tlsOptions = (tls: TlsTarget): TLSOptions => ({\n\tserverName: tls.servername,\n\trejectUnauthorized: tls.verify,\n\t...(tls.ca ? { ca: [...tls.ca] } : {}),\n});\n\n/** Why a connection or a handshake failed, from what Bun gave: its code, else its message. */\nexport const reason = (error: unknown): string =>\n\t(error as { code?: string } | null)?.code ??\n\t(error as Error | null)?.message ??\n\t'the handshake failed';\n\n/** The whole delivery's deadline. */\nexport class Clock {\n\treadonly seconds: number;\n\treadonly #end: number;\n\n\tconstructor(seconds: number) {\n\t\tthis.seconds = seconds;\n\t\tthis.#end = performance.now() + seconds * 1000;\n\t}\n\n\t/**\n\t * `promise`, or what `expire` gives, thrown once `ms` passed or the\n\t * deadline did, whichever comes first; `deadline` says which it was.\n\t */\n\tasync race<T>(\n\t\tpromise: Promise<T>,\n\t\tms: number,\n\t\texpire: (deadline: boolean) => Error,\n\t): Promise<T> {\n\t\tconst left = this.#end - performance.now();\n\t\tconst deadline = left < ms;\n\t\tms = Math.min(ms, left);\n\t\tif (ms <= 0) throw expire(deadline);\n\t\tlet timer: Timer | undefined;\n\t\tconst expired = new Promise<never>((_, reject) => {\n\t\t\ttimer = setTimeout(() => reject(expire(deadline)), ms);\n\t\t});\n\t\ttry {\n\t\t\treturn await Promise.race([promise, expired]);\n\t\t} finally {\n\t\t\tclearTimeout(timer);\n\t\t}\n\t}\n}\n",
16
- "import type { Socket, SocketHandler } from 'bun';\nimport { SmtpError } from '../errors';\nimport { Outgoing } from '../io/outgoing';\nimport type { Reply } from '../protocol/reply';\nimport { Inbox } from './inbox';\nimport { badReply, lost, refused, timedOut, tlsFailed } from './refusal';\nimport {\n\ttype Clock,\n\ttype Endpoint,\n\treason,\n\ttype TlsTarget,\n\ttlsOptions,\n} from './target';\n\n/**\n * A connection to an SMTP server: replies read as they come into an\n * `Inbox`, which bounds them; every wait bounded by its timeout and the\n * deadline. Whatever the server does ends in a reply or an `SmtpError`,\n * never in an exception of Bun's.\n */\nexport class ClientSocket {\n\treadonly host: string;\n\treadonly #clock: Clock;\n\t#socket: Socket<undefined> | undefined;\n\t#outgoing = new Outgoing(() => 0);\n\t/** Which socket's events count: the TLS one's after STARTTLS. */\n\t#tls = false;\n\treadonly #inbox = new Inbox();\n\t#failure: SmtpError | undefined;\n\t#closed = false;\n\t#wake: (() => void) | undefined;\n\t#handshaking: ((ok: boolean, error: unknown) => void) | undefined;\n\t/** Resolves when the connection is gone. */\n\treadonly #gone = Promise.withResolvers<void>();\n\tsecure = false;\n\t/** The certificate checked out against the host name. */\n\tverified = false;\n\n\tprivate constructor(host: string, clock: Clock) {\n\t\tthis.host = host;\n\t\tthis.#clock = clock;\n\t}\n\n\t/** Connects, with TLS from the first byte when `tls` is given. */\n\tstatic async open(\n\t\tendpoint: Endpoint,\n\t\ttls: TlsTarget | undefined,\n\t\tseconds: number,\n\t\tclock: Clock,\n\t): Promise<ClientSocket> {\n\t\tconst client = new ClientSocket(endpoint.host, clock);\n\t\tclient.#tls = tls !== undefined;\n\t\tconst handshake = tls ? client.#expectHandshake(tls) : undefined;\n\t\thandshake?.catch(() => {});\n\t\tconst { address, port } = endpoint;\n\t\tconst connecting = Bun.connect({\n\t\t\thostname: address,\n\t\t\tport,\n\t\t\t...(tls ? { tls: tlsOptions(tls) } : {}),\n\t\t\tsocket: client.#handlers(tls !== undefined),\n\t\t});\n\t\ttry {\n\t\t\tclient.#use(await client.#race(connecting, seconds, 'the connection'));\n\t\t} catch (error) {\n\t\t\tconnecting.then(\n\t\t\t\t(socket) => socket.terminate(),\n\t\t\t\t() => {},\n\t\t\t);\n\t\t\tif (error instanceof SmtpError) throw error;\n\t\t\tthrow new SmtpError(\n\t\t\t\t'CONNECTION_FAILED',\n\t\t\t\t`Could not connect to ${endpoint.host} (${address}:${port}): ${reason(error)}`,\n\t\t\t);\n\t\t}\n\t\tif (handshake) {\n\t\t\t// A handshake that failed before the connection resolved left it open.\n\t\t\tawait client.#race(handshake, seconds, 'the TLS handshake').catch((e) => {\n\t\t\t\tclient.close(true);\n\t\t\t\tthrow e;\n\t\t\t});\n\t\t}\n\t\treturn client;\n\t}\n\n\t#use(socket: Socket<undefined>): void {\n\t\tthis.#socket = socket;\n\t\tthis.#outgoing = new Outgoing((bytes) => socket.write(bytes));\n\t}\n\n\t/** Bun's events for one socket: only the live one's count, the clear one's or, after STARTTLS, the TLS one's. */\n\t#handlers(tls: boolean): SocketHandler<undefined> {\n\t\tconst live =\n\t\t\t<A extends unknown[]>(run: (...args: A) => void) =>\n\t\t\t(...args: A) => {\n\t\t\t\tif (this.#tls === tls) run(...args);\n\t\t\t};\n\t\treturn {\n\t\t\tdata: live((_, chunk: Uint8Array) => this.#receive(chunk)),\n\t\t\tdrain: live(() => this.#outgoing.drain()),\n\t\t\tclose: live(() => this.#lost()),\n\t\t\terror: live(() => this.#lost()),\n\t\t\thandshake: live((_, ok: boolean, error: Error | null) =>\n\t\t\t\tthis.#handshaking?.(ok, error),\n\t\t\t),\n\t\t};\n\t}\n\n\t#expectHandshake(tls: TlsTarget): Promise<void> {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tthis.#handshaking = (ok, error) => {\n\t\t\t\tthis.#handshaking = undefined;\n\t\t\t\tif (this.#closed || (tls.verify && !ok)) {\n\t\t\t\t\tconst why = this.#closed ? 'the connection closed' : reason(error);\n\t\t\t\t\treturn reject(this.#fail(tlsFailed(this.host, why)));\n\t\t\t\t}\n\t\t\t\tthis.secure = true;\n\t\t\t\tthis.verified = ok && error === null;\n\t\t\t\tresolve();\n\t\t\t};\n\t\t});\n\t}\n\n\t#receive(chunk: Uint8Array): void {\n\t\tif (this.#failure || this.#closed) return;\n\t\tconst wrong = this.#inbox.push(chunk);\n\t\tif (wrong) this.#fail(badReply(this.host, wrong));\n\t\telse this.#wakeUp();\n\t}\n\n\t#wakeUp(): void {\n\t\tconst wake = this.#wake;\n\t\tthis.#wake = undefined;\n\t\twake?.();\n\t}\n\n\t#lost(): void {\n\t\tthis.#closed = true;\n\t\tthis.#gone.resolve();\n\t\tthis.#outgoing.clear();\n\t\tthis.#handshaking?.(false, null);\n\t\tthis.#wakeUp();\n\t}\n\n\t/** Records the first failure, hangs up, and returns it to throw. */\n\t#fail(error: SmtpError): SmtpError {\n\t\tthis.#failure ??= error;\n\t\tthis.#socket?.terminate();\n\t\tthis.#lost();\n\t\treturn this.#failure;\n\t}\n\n\t/**\n\t * `promise`, or a `TIMEOUT` once `seconds` passed since `start` (now by\n\t * default), or the deadline did, whichever comes first.\n\t */\n\t#race<T>(\n\t\tpromise: Promise<T>,\n\t\tseconds: number,\n\t\twhat: string,\n\t\tstart = performance.now(),\n\t): Promise<T> {\n\t\tconst ms = start + seconds * 1000 - performance.now();\n\t\tconst { host } = this;\n\t\tconst deadline = this.#clock.seconds;\n\t\treturn this.#clock.race(promise, ms, (passed) =>\n\t\t\tthis.#fail(timedOut(host, what, seconds, passed ? deadline : undefined)),\n\t\t);\n\t}\n\n\t/** The next reply, within `seconds` all told; `what` names it in errors: `the greeting`, `the reply to MAIL FROM`. */\n\tasync reply(what: string, seconds: number): Promise<Reply> {\n\t\tconst start = performance.now();\n\t\tfor (;;) {\n\t\t\tconst next = this.#inbox.shift();\n\t\t\tif (next) return next;\n\t\t\tif (this.#failure) throw this.#failure;\n\t\t\tif (this.#closed) throw this.#fail(lost(this.host, what));\n\t\t\tawait this.#race(\n\t\t\t\tnew Promise<void>((wake) => {\n\t\t\t\t\tthis.#wake = wake;\n\t\t\t\t}),\n\t\t\t\tseconds,\n\t\t\t\twhat,\n\t\t\t\tstart,\n\t\t\t);\n\t\t}\n\t}\n\n\t/** One of the caller's promises — the message stream's next part — bounded as a reply is, and cut short if the connection goes. */\n\twithin<T>(promise: Promise<T>, seconds: number, what: string): Promise<T> {\n\t\tconst gone = this.#gone.promise.then((): never => {\n\t\t\tthrow this.#hungUp(lost(this.host, what));\n\t\t});\n\t\treturn this.#race(Promise.race([promise, gone]), seconds, what);\n\t}\n\n\t/** Queues bytes for the server; nothing once the connection failed. */\n\twrite(data: Uint8Array | string): void {\n\t\tif (this.#failure || this.#closed) return;\n\t\tthis.#outgoing.write(\n\t\t\ttypeof data === 'string' ? new TextEncoder().encode(data) : data,\n\t\t);\n\t}\n\n\t/** Waits until the server took everything written. */\n\tasync drained(seconds: number): Promise<void> {\n\t\tawait this.#race(\n\t\t\tthis.#outgoing.drained(),\n\t\t\tseconds,\n\t\t\t'the server to take the message',\n\t\t);\n\t\tif (this.#failure || this.#closed) throw this.#hungUp(lost(this.host));\n\t}\n\n\t/** Why the connection is gone during DATA: its failure, the refusal a server sent before hanging up, or `lost`. */\n\t#hungUp(otherwise: SmtpError): SmtpError {\n\t\tif (this.#failure) return this.#failure;\n\t\tconst said = this.#inbox.shift();\n\t\treturn this.#fail(\n\t\t\tsaid ? refused(this.host, 'the message', said) : otherwise,\n\t\t);\n\t}\n\n\t/** After the 220 to STARTTLS: TLS on this connection. Anything the server sent past the 220 is an attack. */\n\tasync startTls(tls: TlsTarget, seconds: number): Promise<void> {\n\t\tconst socket = this.#socket;\n\t\tif (this.#inbox.holding || !socket) {\n\t\t\tthrow this.#fail(badReply(this.host, 'more after its 220 to STARTTLS'));\n\t\t}\n\t\tconst handshake = this.#expectHandshake(tls);\n\t\thandshake.catch(() => {});\n\t\tthis.#tls = true;\n\t\tconst [, encrypted] = socket.upgradeTLS<undefined>({\n\t\t\ttls: tlsOptions(tls),\n\t\t\tsocket: this.#handlers(true),\n\t\t});\n\t\tthis.#use(encrypted);\n\t\tawait this.#race(handshake, seconds, 'the TLS handshake');\n\t}\n\n\t/** Hangs up; `now` at once, so a message cut short is not delivered. */\n\tclose(now = false): void {\n\t\tthis.#closed = true;\n\t\tif (now) this.#socket?.terminate();\n\t\telse this.#socket?.end();\n\t}\n}\n",
17
- "import { type RecipientReply, SmtpError } from '../errors';\nimport { DataWriter } from '../protocol/data-writer';\nimport type { Reply } from '../protocol/reply';\nimport { bareLineBreak, type Content } from './content';\nimport { refused, shown } from './refusal';\nimport type { Ready } from './session';\nimport type { ClientSettings } from './settings';\nimport type { ClientSocket } from './socket';\n\n/** What the server said to the envelope and the message. */\nexport interface Delivered {\n\treadonly accepted: readonly RecipientReply[];\n\treadonly rejected: readonly RecipientReply[];\n\treadonly reply: Reply;\n}\n\nconst missing = (host: string, extension: string, why: string) =>\n\tnew SmtpError(\n\t\t'EXTENSION_MISSING',\n\t\t`${host} does not offer ${extension}, which ${why}`,\n\t);\n\n/** MAIL FROM's parameters: SIZE (RFC 1870), BODY (RFC 6152), SMTPUTF8 (RFC 6531). */\nfunction mailParameters(\n\thost: string,\n\tsettings: ClientSettings,\n\tcontent: Content,\n\textensions: ReadonlyMap<string, string>,\n): string {\n\tlet parameters = '';\n\tconst size = extensions.get('SIZE');\n\tif (size !== undefined && content.size !== undefined) {\n\t\tconst max = Number(size);\n\t\tif (Number.isSafeInteger(max) && max > 0 && content.size > max) {\n\t\t\tthrow new SmtpError(\n\t\t\t\t'MESSAGE_TOO_BIG',\n\t\t\t\t`The message (${content.size} bytes) is larger than the ${max} bytes ${host} takes (SIZE)`,\n\t\t\t\t{ temporary: false },\n\t\t\t);\n\t\t}\n\t\tparameters += ` SIZE=${content.size}`;\n\t}\n\tif (extensions.has('8BITMIME')) parameters += ' BODY=8BITMIME';\n\telse if (content.eightBit) {\n\t\tthrow missing(host, '8BITMIME', 'the message needs: it has 8-bit bytes');\n\t}\n\tif (settings.smtputf8) {\n\t\tif (!extensions.has('SMTPUTF8')) {\n\t\t\tthrow missing(\n\t\t\t\thost,\n\t\t\t\t'SMTPUTF8',\n\t\t\t\t'an address that is not ASCII needs (or smtputf8 asked for)',\n\t\t\t);\n\t\t}\n\t\tparameters += ' SMTPUTF8';\n\t}\n\treturn parameters;\n}\n\n/** MAIL FROM and every RCPT TO: in one write with PIPELINING (RFC 2920), else one by one. */\nasync function envelope(\n\tsocket: ClientSocket,\n\tsettings: ClientSettings,\n\tcontent: Content,\n\tready: Ready,\n): Promise<{ accepted: RecipientReply[]; rejected: RecipientReply[] }> {\n\tconst { host } = socket;\n\tconst { timeouts } = settings;\n\tconst mail = `MAIL FROM:<${settings.from}>${mailParameters(host, settings, content, ready.extensions)}\\r\\n`;\n\tconst rcpts = settings.to.map((to) => `RCPT TO:<${to}>\\r\\n`);\n\tconst pipelining = ready.extensions.has('PIPELINING');\n\tsocket.write(pipelining ? mail + rcpts.join('') : mail);\n\tconst from = await socket.reply('the reply to MAIL FROM', timeouts.mail);\n\tif (from.code !== 250) throw refused(host, 'the sender', from);\n\tconst accepted: RecipientReply[] = [];\n\tconst rejected: RecipientReply[] = [];\n\tfor (const [i, recipient] of settings.to.entries()) {\n\t\tif (!pipelining) socket.write(rcpts[i] as string);\n\t\tconst reply = await socket.reply('the reply to RCPT TO', timeouts.rcpt);\n\t\tconst into = reply.code === 250 || reply.code === 251 ? accepted : rejected;\n\t\tinto.push({ recipient, reply });\n\t}\n\tif (accepted.length === 0) {\n\t\tconst first = rejected[0] as RecipientReply;\n\t\tthrow new SmtpError(\n\t\t\t'RECIPIENTS_REFUSED',\n\t\t\t`${host} refused every recipient, ${first.recipient} with ${shown(first.reply)}`,\n\t\t\t{\n\t\t\t\treply: first.reply,\n\t\t\t\trejected,\n\t\t\t\ttemporary: rejected.some(({ reply }) => reply.code < 500),\n\t\t\t},\n\t\t);\n\t}\n\treturn { accepted, rejected };\n}\n\n/** The message, stuffed, block by block as the server takes it; a bad stream hangs up before the dot. */\nasync function data(\n\tsocket: ClientSocket,\n\tsettings: ClientSettings,\n\tcontent: Content,\n\tready: Ready,\n): Promise<Reply> {\n\tconst { host } = socket;\n\tconst { timeouts } = settings;\n\tsocket.write('DATA\\r\\n');\n\tconst start = await socket.reply('the reply to DATA', timeouts.dataStart);\n\tif (start.code !== 354) throw refused(host, 'DATA', start);\n\tconst writer = new DataWriter(settings.normalizeLineEnds);\n\tconst eightBitOk = ready.extensions.has('8BITMIME');\n\tconst chunks = content.chunks();\n\tlet tail: Uint8Array;\n\ttry {\n\t\tfor (;;) {\n\t\t\t// The caller's stream is bounded as the server is: a stalled one times out.\n\t\t\tconst chunk = await socket.within(\n\t\t\t\tchunks.next(),\n\t\t\t\ttimeouts.dataBlock,\n\t\t\t\t'the next part of the message',\n\t\t\t);\n\t\t\tif (!chunk) break;\n\t\t\tconst bytes = writer.write(chunk);\n\t\t\tif (writer.bareLineBreaks > 0) throw bareLineBreak();\n\t\t\tif (writer.eightBit && !eightBitOk) {\n\t\t\t\tthrow missing(\n\t\t\t\t\thost,\n\t\t\t\t\t'8BITMIME',\n\t\t\t\t\t'the message needs: it has 8-bit bytes',\n\t\t\t\t);\n\t\t\t}\n\t\t\tsocket.write(bytes);\n\t\t\tawait socket.drained(timeouts.dataBlock);\n\t\t}\n\t\t// A CR held at the very end is bare only now: still no dot for it.\n\t\ttail = writer.end();\n\t\tif (writer.bareLineBreaks > 0) throw bareLineBreak();\n\t} catch (error) {\n\t\t// No final dot: the server drops what it has of the message.\n\t\tchunks.cancel();\n\t\tsocket.close(true);\n\t\tthrow error;\n\t}\n\tsocket.write(tail);\n\tconst end = await socket.reply(\n\t\t'the reply to the final dot',\n\t\ttimeouts.dataEnd,\n\t);\n\tif (end.code !== 250) throw refused(host, 'the message', end);\n\treturn end;\n}\n\n/** One message: the envelope, then the content. */\nexport async function transact(\n\tsocket: ClientSocket,\n\tsettings: ClientSettings,\n\tcontent: Content,\n\tready: Ready,\n): Promise<Delivered> {\n\tconst { accepted, rejected } = await envelope(\n\t\tsocket,\n\t\tsettings,\n\t\tcontent,\n\t\tready,\n\t);\n\tconst reply = await data(socket, settings, content, ready);\n\treturn { accepted, rejected, reply };\n}\n",
16
+ "import type { Socket, SocketHandler } from 'bun';\nimport { SmtpError } from '../errors';\nimport { Outgoing } from '../io/outgoing';\nimport type { Reply } from '../protocol/reply';\nimport { Inbox } from './inbox';\nimport { badReply, lost, refused, timedOut, tlsFailed } from './refusal';\nimport {\n\ttype Clock,\n\ttype Endpoint,\n\treason,\n\ttype TlsTarget,\n\ttlsOptions,\n} from './target';\n\n/**\n * A connection to an SMTP server: replies read as they come into an\n * `Inbox`, which bounds them; every wait bounded by its timeout and the\n * deadline. Whatever the server does ends in a reply or an `SmtpError`,\n * never in an exception of Bun's.\n */\nexport class ClientSocket {\n\treadonly host: string;\n\treadonly #clock: Clock;\n\t#socket: Socket<undefined> | undefined;\n\t#outgoing = new Outgoing(() => 0);\n\t/** Which socket's events count: the TLS one's after STARTTLS. */\n\t#tls = false;\n\treadonly #inbox = new Inbox();\n\t#failure: SmtpError | undefined;\n\t#closed = false;\n\t#wake: (() => void) | undefined;\n\t#handshaking: ((ok: boolean, error: unknown) => void) | undefined;\n\t/** Resolves when the connection is gone. */\n\treadonly #gone = Promise.withResolvers<void>();\n\tsecure = false;\n\t/** The certificate checked out against the host name. */\n\tverified = false;\n\n\tprivate constructor(host: string, clock: Clock) {\n\t\tthis.host = host;\n\t\tthis.#clock = clock;\n\t}\n\n\t/** Connects, with TLS from the first byte when `tls` is given. */\n\tstatic async open(\n\t\tendpoint: Endpoint,\n\t\ttls: TlsTarget | undefined,\n\t\tseconds: number,\n\t\tclock: Clock,\n\t): Promise<ClientSocket> {\n\t\tconst client = new ClientSocket(endpoint.host, clock);\n\t\tclient.#tls = tls !== undefined;\n\t\tconst handshake = tls ? client.#expectHandshake(tls) : undefined;\n\t\thandshake?.catch(() => {});\n\t\tconst { address, port } = endpoint;\n\t\tconst connecting = Bun.connect({\n\t\t\thostname: address,\n\t\t\tport,\n\t\t\t...(tls ? { tls: tlsOptions(tls) } : {}),\n\t\t\tsocket: client.#handlers(tls !== undefined),\n\t\t});\n\t\ttry {\n\t\t\tclient.#use(await client.#race(connecting, seconds, 'the connection'));\n\t\t} catch (error) {\n\t\t\tconnecting.then(\n\t\t\t\t(socket) => socket.terminate(),\n\t\t\t\t() => {},\n\t\t\t);\n\t\t\tif (error instanceof SmtpError) throw error;\n\t\t\tthrow new SmtpError(\n\t\t\t\t'CONNECTION_FAILED',\n\t\t\t\t`Could not connect to ${endpoint.host} (${address}:${port}): ${reason(error)}`,\n\t\t\t);\n\t\t}\n\t\tif (handshake) {\n\t\t\t// A handshake that failed before the connection resolved left it open.\n\t\t\tawait client.#race(handshake, seconds, 'the TLS handshake').catch((e) => {\n\t\t\t\tclient.close(true);\n\t\t\t\tthrow e;\n\t\t\t});\n\t\t}\n\t\treturn client;\n\t}\n\n\t#use(socket: Socket<undefined>): void {\n\t\tthis.#socket = socket;\n\t\tthis.#outgoing = new Outgoing((bytes) => socket.write(bytes));\n\t}\n\n\t/** Bun's events for one socket: only the live one's count, the clear one's or, after STARTTLS, the TLS one's. */\n\t#handlers(tls: boolean): SocketHandler<undefined> {\n\t\tconst live =\n\t\t\t<A extends unknown[]>(run: (...args: A) => void) =>\n\t\t\t(...args: A) => {\n\t\t\t\tif (this.#tls === tls) run(...args);\n\t\t\t};\n\t\treturn {\n\t\t\tdata: live((_, chunk: Uint8Array) => this.#receive(chunk)),\n\t\t\tdrain: live(() => this.#outgoing.drain()),\n\t\t\tclose: live(() => this.#lost()),\n\t\t\terror: live(() => this.#lost()),\n\t\t\thandshake: live((_, ok: boolean, error: Error | null) =>\n\t\t\t\tthis.#handshaking?.(ok, error),\n\t\t\t),\n\t\t};\n\t}\n\n\t#expectHandshake(tls: TlsTarget): Promise<void> {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tthis.#handshaking = (ok, error) => {\n\t\t\t\tthis.#handshaking = undefined;\n\t\t\t\tif (this.#closed || (tls.verify && !ok)) {\n\t\t\t\t\tconst why = this.#closed ? 'the connection closed' : reason(error);\n\t\t\t\t\treturn reject(this.#fail(tlsFailed(this.host, why)));\n\t\t\t\t}\n\t\t\t\tthis.secure = true;\n\t\t\t\tthis.verified = ok && error === null;\n\t\t\t\tresolve();\n\t\t\t};\n\t\t});\n\t}\n\n\t#receive(chunk: Uint8Array): void {\n\t\tif (this.#failure || this.#closed) return;\n\t\tconst wrong = this.#inbox.push(chunk);\n\t\tif (wrong) this.#fail(badReply(this.host, wrong));\n\t\telse this.#wakeUp();\n\t}\n\n\t#wakeUp(): void {\n\t\tconst wake = this.#wake;\n\t\tthis.#wake = undefined;\n\t\twake?.();\n\t}\n\n\t#lost(): void {\n\t\tthis.#closed = true;\n\t\tthis.#gone.resolve();\n\t\tthis.#outgoing.clear();\n\t\tthis.#handshaking?.(false, null);\n\t\tthis.#wakeUp();\n\t}\n\n\t/** Records the first failure, hangs up, and returns it to throw. */\n\t#fail(error: SmtpError): SmtpError {\n\t\tthis.#failure ??= error;\n\t\tthis.#socket?.terminate();\n\t\tthis.#lost();\n\t\treturn this.#failure;\n\t}\n\n\t/**\n\t * `promise`, or a `TIMEOUT` once `seconds` passed since `start` (now by\n\t * default), or the deadline did, whichever comes first.\n\t */\n\t#race<T>(\n\t\tpromise: Promise<T>,\n\t\tseconds: number,\n\t\twhat: string,\n\t\tstart = performance.now(),\n\t): Promise<T> {\n\t\tconst ms = start + seconds * 1000 - performance.now();\n\t\tconst { host } = this;\n\t\tconst deadline = this.#clock.seconds;\n\t\treturn this.#clock.race(promise, ms, (passed) =>\n\t\t\tthis.#fail(timedOut(host, what, seconds, passed ? deadline : undefined)),\n\t\t);\n\t}\n\n\t/** The next reply, within `seconds` all told; `what` names it in errors: `the greeting`, `the reply to MAIL FROM`. */\n\tasync reply(what: string, seconds: number): Promise<Reply> {\n\t\tconst start = performance.now();\n\t\tfor (;;) {\n\t\t\tconst next = this.#inbox.shift();\n\t\t\tif (next) return next;\n\t\t\tif (this.#failure) throw this.#failure;\n\t\t\tif (this.#closed) throw this.#fail(lost(this.host, what));\n\t\t\tawait this.#race(\n\t\t\t\tnew Promise<void>((wake) => {\n\t\t\t\t\tthis.#wake = wake;\n\t\t\t\t}),\n\t\t\t\tseconds,\n\t\t\t\twhat,\n\t\t\t\tstart,\n\t\t\t);\n\t\t}\n\t}\n\n\t/** One of the caller's promises — the message stream's next part — bounded as a reply is, and cut short if the connection goes (a hang-up after it settled is none of its business). */\n\twithin<T>(promise: Promise<T>, seconds: number, what: string): Promise<T> {\n\t\tconst over = new AbortController();\n\t\tconst gone = this.#gone.promise.then(() => {\n\t\t\tif (!over.signal.aborted) throw this.#hungUp(lost(this.host, what));\n\t\t});\n\t\tconst race = Promise.race([promise, gone]) as Promise<T>;\n\t\t// Once the deadline passed, the clock throws before it listens to `race`, and its expiry hangs up (`#fail`), which rejects `gone` and so `race` unheard.\n\t\trace.catch(() => undefined);\n\t\treturn this.#race(race, seconds, what).finally(() => over.abort());\n\t}\n\n\t/** Queues bytes for the server; nothing once the connection failed. Whether it did queue them. */\n\twrite(data: Uint8Array | string): boolean {\n\t\tif (this.#failure || this.#closed) return false;\n\t\tthis.#outgoing.write(\n\t\t\ttypeof data === 'string' ? new TextEncoder().encode(data) : data,\n\t\t);\n\t\treturn true;\n\t}\n\n\t/** Waits until the server took everything written. */\n\tasync drained(seconds: number): Promise<void> {\n\t\tawait this.#race(\n\t\t\tthis.#outgoing.drained(),\n\t\t\tseconds,\n\t\t\t'the server to take the message',\n\t\t);\n\t\tif (this.#failure || this.#closed) throw this.#hungUp(lost(this.host));\n\t}\n\n\t/** Why the connection is gone during DATA: its failure, the refusal a server sent before hanging up, or `lost`. */\n\t#hungUp(otherwise: SmtpError): SmtpError {\n\t\tif (this.#failure) return this.#failure;\n\t\tconst said = this.#inbox.shift();\n\t\treturn this.#fail(\n\t\t\tsaid ? refused(this.host, 'the message', said) : otherwise,\n\t\t);\n\t}\n\n\t/** After the 220 to STARTTLS: TLS on this connection. Anything the server sent past the 220 is an attack. */\n\tasync startTls(tls: TlsTarget, seconds: number): Promise<void> {\n\t\tconst socket = this.#socket;\n\t\tif (this.#inbox.holding || !socket) {\n\t\t\tthrow this.#fail(badReply(this.host, 'more after its 220 to STARTTLS'));\n\t\t}\n\t\tconst handshake = this.#expectHandshake(tls);\n\t\thandshake.catch(() => {});\n\t\tthis.#tls = true;\n\t\tconst [, encrypted] = socket.upgradeTLS<undefined>({\n\t\t\ttls: tlsOptions(tls),\n\t\t\tsocket: this.#handlers(true),\n\t\t});\n\t\tthis.#use(encrypted);\n\t\tawait this.#race(handshake, seconds, 'the TLS handshake');\n\t}\n\n\t/** Hangs up; `now` at once, so a message cut short is not delivered. */\n\tclose(now = false): void {\n\t\tthis.#closed = true;\n\t\tif (now) this.#socket?.terminate();\n\t\telse this.#socket?.end();\n\t}\n}\n",
17
+ "import { type RecipientReply, SmtpError } from '../errors';\nimport { DataWriter } from '../protocol/data-writer';\nimport type { Reply } from '../protocol/reply';\nimport { bareLineBreak, type Content } from './content';\nimport { afterDot, refused, shown } from './refusal';\nimport type { Ready } from './session';\nimport type { ClientSettings } from './settings';\nimport type { ClientSocket } from './socket';\n\n/** What the server said to the envelope and the message. */\nexport interface Delivered {\n\treadonly accepted: readonly RecipientReply[];\n\treadonly rejected: readonly RecipientReply[];\n\treadonly reply: Reply;\n}\n\nconst missing = (host: string, extension: string, why: string) =>\n\tnew SmtpError(\n\t\t'EXTENSION_MISSING',\n\t\t`${host} does not offer ${extension}, which ${why}`,\n\t);\n\n/** MAIL FROM's parameters: SIZE (RFC 1870), BODY (RFC 6152), SMTPUTF8 (RFC 6531). */\nfunction mailParameters(\n\thost: string,\n\tsettings: ClientSettings,\n\tcontent: Content,\n\textensions: ReadonlyMap<string, string>,\n): string {\n\tlet parameters = '';\n\tconst size = extensions.get('SIZE');\n\tif (size !== undefined && content.size !== undefined) {\n\t\tconst max = Number(size);\n\t\tif (Number.isSafeInteger(max) && max > 0 && content.size > max) {\n\t\t\tthrow new SmtpError(\n\t\t\t\t'MESSAGE_TOO_BIG',\n\t\t\t\t`The message (${content.size} bytes) is larger than the ${max} bytes ${host} takes (SIZE)`,\n\t\t\t\t{ temporary: false },\n\t\t\t);\n\t\t}\n\t\tparameters += ` SIZE=${content.size}`;\n\t}\n\tif (extensions.has('8BITMIME')) parameters += ' BODY=8BITMIME';\n\telse if (content.eightBit) {\n\t\tthrow missing(host, '8BITMIME', 'the message needs: it has 8-bit bytes');\n\t}\n\tif (settings.smtputf8) {\n\t\tif (!extensions.has('SMTPUTF8')) {\n\t\t\tthrow missing(\n\t\t\t\thost,\n\t\t\t\t'SMTPUTF8',\n\t\t\t\t'an address that is not ASCII needs (or smtputf8 asked for)',\n\t\t\t);\n\t\t}\n\t\tparameters += ' SMTPUTF8';\n\t}\n\treturn parameters;\n}\n\n/** MAIL FROM and every RCPT TO: in one write with PIPELINING (RFC 2920), else one by one. */\nasync function envelope(\n\tsocket: ClientSocket,\n\tsettings: ClientSettings,\n\tcontent: Content,\n\tready: Ready,\n): Promise<{ accepted: RecipientReply[]; rejected: RecipientReply[] }> {\n\tconst { host } = socket;\n\tconst { timeouts } = settings;\n\tconst mail = `MAIL FROM:<${settings.from}>${mailParameters(host, settings, content, ready.extensions)}\\r\\n`;\n\tconst rcpts = settings.to.map((to) => `RCPT TO:<${to}>\\r\\n`);\n\tconst pipelining = ready.extensions.has('PIPELINING');\n\tsocket.write(pipelining ? mail + rcpts.join('') : mail);\n\tconst from = await socket.reply('the reply to MAIL FROM', timeouts.mail);\n\tif (from.code !== 250) throw refused(host, 'the sender', from);\n\tconst accepted: RecipientReply[] = [];\n\tconst rejected: RecipientReply[] = [];\n\tfor (const [i, recipient] of settings.to.entries()) {\n\t\tif (!pipelining) socket.write(rcpts[i] as string);\n\t\tconst reply = await socket.reply('the reply to RCPT TO', timeouts.rcpt);\n\t\tconst into = reply.code === 250 || reply.code === 251 ? accepted : rejected;\n\t\tinto.push({ recipient, reply });\n\t}\n\tif (accepted.length === 0) {\n\t\tconst first = rejected[0] as RecipientReply;\n\t\tthrow new SmtpError(\n\t\t\t'RECIPIENTS_REFUSED',\n\t\t\t`${host} refused every recipient, ${first.recipient} with ${shown(first.reply)}`,\n\t\t\t{\n\t\t\t\treply: first.reply,\n\t\t\t\trejected,\n\t\t\t\ttemporary: rejected.some(({ reply }) => reply.code < 500),\n\t\t\t},\n\t\t);\n\t}\n\treturn { accepted, rejected };\n}\n\n/** The message, stuffed, block by block as the server takes it; a bad stream hangs up before the dot. */\nasync function data(\n\tsocket: ClientSocket,\n\tsettings: ClientSettings,\n\tcontent: Content,\n\tready: Ready,\n): Promise<Reply> {\n\tconst { host } = socket;\n\tconst { timeouts } = settings;\n\tsocket.write('DATA\\r\\n');\n\tconst start = await socket.reply('the reply to DATA', timeouts.dataStart);\n\tif (start.code !== 354) throw refused(host, 'DATA', start);\n\tconst writer = new DataWriter(settings.normalizeLineEnds);\n\tconst eightBitOk = ready.extensions.has('8BITMIME');\n\tconst chunks = content.chunks();\n\tlet tail: Uint8Array;\n\ttry {\n\t\tfor (;;) {\n\t\t\t// The caller's stream is bounded as the server is: a stalled one times out.\n\t\t\tconst chunk = await socket.within(\n\t\t\t\tchunks.next(),\n\t\t\t\ttimeouts.dataBlock,\n\t\t\t\t'the next part of the message',\n\t\t\t);\n\t\t\tif (!chunk) break;\n\t\t\tconst bytes = writer.write(chunk);\n\t\t\tif (writer.bareLineBreaks > 0) throw bareLineBreak();\n\t\t\tif (writer.eightBit && !eightBitOk) {\n\t\t\t\tthrow missing(\n\t\t\t\t\thost,\n\t\t\t\t\t'8BITMIME',\n\t\t\t\t\t'the message needs: it has 8-bit bytes',\n\t\t\t\t);\n\t\t\t}\n\t\t\tsocket.write(bytes);\n\t\t\tawait socket.drained(timeouts.dataBlock);\n\t\t}\n\t\t// A CR held at the very end is bare only now: still no dot for it.\n\t\ttail = writer.end();\n\t\tif (writer.bareLineBreaks > 0) throw bareLineBreak();\n\t} catch (error) {\n\t\t// No final dot: the server drops what it has of the message.\n\t\tchunks.cancel();\n\t\tsocket.close(true);\n\t\tthrow error;\n\t}\n\t// A connection that failed already took no dot: its error is not afterData.\n\tconst dotSent = socket.write(tail);\n\tconst end = await socket\n\t\t.reply('the reply to the final dot', timeouts.dataEnd)\n\t\t.catch((error: unknown) => {\n\t\t\t// No reply to the dot: the server may have taken the message.\n\t\t\tthrow dotSent ? afterDot(error) : error;\n\t\t});\n\tif (end.code !== 250) throw refused(host, 'the message', end);\n\treturn end;\n}\n\n/** One message: the envelope, then the content. */\nexport async function transact(\n\tsocket: ClientSocket,\n\tsettings: ClientSettings,\n\tcontent: Content,\n\tready: Ready,\n): Promise<Delivered> {\n\tconst { accepted, rejected } = await envelope(\n\t\tsocket,\n\t\tsettings,\n\t\tcontent,\n\t\tready,\n\t);\n\tconst reply = await data(socket, settings, content, ready);\n\treturn { accepted, rejected, reply };\n}\n",
18
18
  "import { SmtpError } from '../errors';\nimport { type Content, contentOf } from './content';\nimport { addressesOf, noAddress, resolveMx } from './mx';\nimport type {\n\tMessageSource,\n\tMxDestination,\n\tSendMailOptions,\n\tSendMailResult,\n} from './options';\nimport { timedOut } from './refusal';\nimport { open } from './session';\nimport {\n\tbyMx,\n\ttype ClientSettings,\n\tinvalid,\n\tportOf,\n\tsettingsOf,\n} from './settings';\nimport { ClientSocket } from './socket';\nimport { Clock, type Endpoint, type TlsTarget } from './target';\nimport { transact } from './transaction';\n\n/** The most addresses one delivery tries, every MX host together; and the most MX hosts it looks up. */\nexport const MAX_ADDRESSES = 10;\n\n/** Seconds to wait for the 221 to QUIT once the message was taken. */\nconst QUIT_WAIT = 5;\n\n/** Errors from before MAIL FROM: another MX host may do better. */\nconst early = new WeakSet<object>();\n\n/** One session with one server, from the connection to QUIT. */\nasync function attempt(\n\tendpoint: Endpoint,\n\tsettings: ClientSettings,\n\tcontent: Content,\n\tclock: Clock,\n): Promise<SendMailResult> {\n\tconst tls: TlsTarget = {\n\t\tservername: endpoint.host,\n\t\tverify: settings.tls === 'required',\n\t\t...(settings.ca ? { ca: settings.ca } : {}),\n\t};\n\tlet socket: ClientSocket;\n\ttry {\n\t\tsocket = await ClientSocket.open(\n\t\t\tendpoint,\n\t\t\tsettings.secure ? tls : undefined,\n\t\t\tsettings.timeouts.connect,\n\t\t\tclock,\n\t\t);\n\t} catch (error) {\n\t\tearly.add(error as object);\n\t\tthrow error;\n\t}\n\tlet quit = false;\n\ttry {\n\t\tconst ready = await open(socket, settings, tls).catch((error) => {\n\t\t\tearly.add(error as object);\n\t\t\tthrow error;\n\t\t});\n\t\tconst delivered = await transact(socket, settings, content, ready);\n\t\tsocket.write('QUIT\\r\\n');\n\t\tquit = true;\n\t\tawait socket\n\t\t\t.reply(\n\t\t\t\t'the reply to QUIT',\n\t\t\t\tMath.min(QUIT_WAIT, settings.timeouts.command),\n\t\t\t)\n\t\t\t.catch(() => {});\n\t\treturn {\n\t\t\t...delivered,\n\t\t\thost: endpoint.host,\n\t\t\tport: endpoint.port,\n\t\t\ttls: socket.secure ? { verified: socket.verified } : false,\n\t\t\tauthenticated: ready.authenticated,\n\t\t};\n\t} finally {\n\t\t// After a refusal the session is still in step: say goodbye.\n\t\tif (!quit) socket.write('QUIT\\r\\n');\n\t\tsocket.close();\n\t}\n}\n\n/** A DNS lookup, bounded by the delivery's deadline (the resolver has its own timeout too). */\nconst withinDeadline = <T>(\n\tlookup: Promise<T>,\n\tclock: Clock,\n\tname: string,\n\twhat: string,\n): Promise<T> =>\n\tclock.race(lookup, Number.POSITIVE_INFINITY, () =>\n\t\ttimedOut(name, what, clock.seconds, clock.seconds),\n\t);\n\n/** Direct delivery: each MX host's addresses in turn, while the failures are temporary and before MAIL FROM. */\nasync function viaMx(\n\toptions: MxDestination,\n\tsettings: ClientSettings,\n\tcontent: Content,\n\tclock: Clock,\n): Promise<SendMailResult> {\n\tconst { domain, resolver } = options;\n\tif (typeof domain !== 'string' || domain === '')\n\t\tthrow invalid('domain must be a domain name');\n\tif (typeof resolver?.mx !== 'function')\n\t\tthrow invalid('resolver must be a Resolver, such as @bumail/dns gives');\n\tconst port = portOf(options.port, 25);\n\tlet last: unknown;\n\tlet dnsError: unknown;\n\tlet tried = 0;\n\tlet looked = 0;\n\tconst mailHosts = await withinDeadline(\n\t\tresolveMx(domain, resolver),\n\t\tclock,\n\t\tdomain,\n\t\t'the MX lookup',\n\t);\n\thosts: for (const mx of mailHosts) {\n\t\t// A host looked up counts, with an address or not: no endless lookups.\n\t\tif (tried >= MAX_ADDRESSES || looked++ >= MAX_ADDRESSES) break;\n\t\tconst addresses = await withinDeadline(\n\t\t\taddressesOf(mx.host, resolver),\n\t\t\tclock,\n\t\t\tmx.host,\n\t\t\t'the address lookup',\n\t\t);\n\t\tif (!Array.isArray(addresses)) {\n\t\t\tdnsError = addresses.error;\n\t\t\tcontinue;\n\t\t}\n\t\tfor (const address of addresses) {\n\t\t\tif (tried++ >= MAX_ADDRESSES) break hosts;\n\t\t\ttry {\n\t\t\t\treturn await attempt(\n\t\t\t\t\t{ host: mx.host, address, port },\n\t\t\t\t\tsettings,\n\t\t\t\t\tcontent,\n\t\t\t\t\tclock,\n\t\t\t\t);\n\t\t\t} catch (error) {\n\t\t\t\tconst next =\n\t\t\t\t\terror instanceof SmtpError && error.temporary && early.has(error);\n\t\t\t\tif (!next) throw error;\n\t\t\t\tlast = error;\n\t\t\t}\n\t\t}\n\t}\n\tthrow last ?? noAddress(domain, dnsError);\n}\n\n/**\n * Delivers one message to one destination: a host (`{ host, port }`, a\n * smarthost or a submission server) or a domain's mail hosts (`{ domain,\n * resolver }`, by MX). Resolves once the server took the message for one\n * recipient at least; rejects with an `SmtpError` otherwise, `temporary`\n * telling whether to try again later. It is not a queue: retries are the\n * caller's.\n */\nexport async function sendMail(\n\tmessage: MessageSource,\n\toptions: SendMailOptions,\n): Promise<SendMailResult> {\n\tconst settings = settingsOf(options);\n\tconst content = contentOf(message, settings.normalizeLineEnds, settings.size);\n\tconst clock = new Clock(settings.deadline);\n\tif (!byMx(options)) {\n\t\tconst { host } = options;\n\t\tif (typeof host !== 'string' || !/^[^\\s/]+$/.test(host))\n\t\t\tthrow invalid(`host must be a host name or an address, not ${host}`);\n\t\tconst port = portOf(options.port, settings.secure ? 465 : 25);\n\t\treturn attempt({ host, address: host, port }, settings, content, clock);\n\t}\n\treturn viaMx(options, settings, content, clock);\n}\n"
19
19
  ],
20
- "mappings": ";;;;;;;;;;;AAcO,SAAS,SAAS,CAAC,SAAqC;AAAA,EAC9D,OACC,OAAO,YAA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AAM,IAAI,KAAK;AAAA,UACjE,IAAI,CAAC;AAAA,YAAM,MAAM;AAAA,UACjB,OAAO;AAAA;AAAA,MAET;AAAA,IACD;AAAA,EACA,MAAM,QAAQ,UAAU,QAAQ,QAAQ;AAAA;AAWzC,eAAsB,QAAQ,CAC7B,SACA,SAC0B;AAAA,EAC1B,MAAM,WAAW,WAAW,OAAO;AAAA,EACnC,MAAM,UAAU,UAAU,SAAS,SAAS,mBAAmB,SAAS,IAAI;AAAA,EAC5E,MAAM,QAAQ,IAAI,MAAM,SAAS,QAAQ;AAAA,EACzC,IAAI,CAAC,KAAK,OAAO,GAAG;AAAA,IACnB,QAAQ,SAAS;AAAA,IACjB,IAAI,OAAO,SAAS,YAAY,CAAC,YAAY,KAAK,IAAI;AAAA,MACrD,MAAM,QAAQ,+CAA+C,MAAM;AAAA,IACpE,MAAM,OAAO,OAAO,QAAQ,MAAM,SAAS,SAAS,MAAM,EAAE;AAAA,IAC5D,OAAO,QAAQ,EAAE,MAAM,SAAS,MAAM,KAAK,GAAG,UAAU,SAAS,KAAK;AAAA,EACvE;AAAA,EACA,OAAO,MAAM,SAAS,UAAU,SAAS,KAAK;AAAA;",
21
+ "debugId": "F9FE8E458D7309C564756E2164756E21",
22
22
  "names": []
23
23
  }
@@ -12,4 +12,10 @@ export declare const lost: (host: string, what?: string) => SmtpError;
12
12
  export declare const timedOut: (host: string, what: string, seconds: number, deadline?: number) => SmtpError;
13
13
  /** `TLS_FAILED`: the handshake, or the certificate's check. */
14
14
  export declare const tlsFailed: (host: string, why: string) => SmtpError;
15
+ /**
16
+ * `error` as it is, marked `afterData` when it is an `SmtpError` of a
17
+ * missing reply to the final dot: the same code, message, `temporary`,
18
+ * `rejected` and `cause`.
19
+ */
20
+ export declare function afterDot(error: unknown): unknown;
15
21
  //# sourceMappingURL=refusal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"refusal.d.ts","sourceRoot":"","sources":["../../src/client/refusal.ts"],"names":[],"mappings":"AAAA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,MAAM,cAM9C,CAAC;AAEH,0FAA0F;AAC1F,eAAO,MAAM,QAAQ,GACpB,MAAM,MAAM,EACZ,MAAM,MAAM,EACZ,SAAS,MAAM,EACf,WAAW,MAAM,cAOhB,CAAC;AAEH,+DAA+D;AAC/D,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,EAAE,KAAK,MAAM,cACY,CAAC;AAEhE;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAShD"}
@@ -17,10 +17,10 @@ export declare class ClientSocket {
17
17
  static open(endpoint: Endpoint, tls: TlsTarget | undefined, seconds: number, clock: Clock): Promise<ClientSocket>;
18
18
  /** The next reply, within `seconds` all told; `what` names it in errors: `the greeting`, `the reply to MAIL FROM`. */
19
19
  reply(what: string, seconds: number): Promise<Reply>;
20
- /** One of the caller's promises — the message stream's next part — bounded as a reply is, and cut short if the connection goes. */
20
+ /** One of the caller's promises — the message stream's next part — bounded as a reply is, and cut short if the connection goes (a hang-up after it settled is none of its business). */
21
21
  within<T>(promise: Promise<T>, seconds: number, what: string): Promise<T>;
22
- /** Queues bytes for the server; nothing once the connection failed. */
23
- write(data: Uint8Array | string): void;
22
+ /** Queues bytes for the server; nothing once the connection failed. Whether it did queue them. */
23
+ write(data: Uint8Array | string): boolean;
24
24
  /** Waits until the server took everything written. */
25
25
  drained(seconds: number): Promise<void>;
26
26
  /** After the 220 to STARTTLS: TLS on this connection. Anything the server sent past the 220 is an attack. */
@@ -1 +1 @@
1
- {"version":3,"file":"socket.d.ts","sourceRoot":"","sources":["../../src/client/socket.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAG/C,OAAO,EACN,KAAK,KAAK,EACV,KAAK,QAAQ,EAEb,KAAK,SAAS,EAEd,MAAM,UAAU,CAAC;AAElB;;;;;GAKG;AACH,qBAAa,YAAY;;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;I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c,EAAE,CAAC;IAC7C,QAAQ,CAAC,QAAQ,EAAE,SAAS,cAAc,EAAE,CAAC;IAC7C,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;CACtB;AA0ID,mDAAmD;AACnD,wBAAsB,QAAQ,CAC7B,MAAM,EAAE,YAAY,EACpB,QAAQ,EAAE,cAAc,EACxB,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,GACV,OAAO,CAAC,SAAS,CAAC,CASpB"}
1
+ {"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../src/client/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAa,MAAM,WAAW,CAAC;AAE3D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAiB,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAExD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C,4DAA4D;AAC5D,MAAM,WAAW,SAAS;IACzB,QAAQ,CAAC,QAAQ,EAAE,SAAS,cAAc,EAAE,CAAC;IAC7C,QAAQ,CAAC,QAAQ,EAAE,SAAS,cAAc,EAAE,CAAC;IAC7C,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;CACtB;AA6ID,mDAAmD;AACnD,wBAAsB,QAAQ,CAC7B,MAAM,EAAE,YAAY,EACpB,QAAQ,EAAE,cAAc,EACxB,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,GACV,OAAO,CAAC,SAAS,CAAC,CASpB"}
package/dist/errors.d.ts CHANGED
@@ -16,6 +16,12 @@ export interface SmtpErrorDetails {
16
16
  readonly rejected?: readonly RecipientReply[];
17
17
  /** The error behind this one, as `Error`'s `cause`. */
18
18
  readonly cause?: unknown;
19
+ /**
20
+ * The final dot of the message was written and no reply to it came (a
21
+ * timeout, a lost connection, a reply that is not one): the server may
22
+ * have taken the message. See `SmtpError.afterData`.
23
+ */
24
+ readonly afterData?: boolean;
19
25
  }
20
26
  /**
21
27
  * Thrown by `createSmtpServer` and `listen` for a wrong option or call; the
@@ -34,6 +40,15 @@ export declare class SmtpError extends Error {
34
40
  readonly reply?: Reply;
35
41
  /** With `RECIPIENTS_REFUSED`: each recipient, and the reply that refused it. */
36
42
  readonly rejected?: readonly RecipientReply[];
43
+ /**
44
+ * `true` when `sendMail` wrote the message's final dot and then got no
45
+ * reply to it (a `TIMEOUT`, a `CONNECTION_LOST`, a `BAD_REPLY`): the
46
+ * server may already have taken the message (RFC 5321 §4.1.5), so a
47
+ * retry, or a delivery by another route, can duplicate it. Absent for a
48
+ * failure before the dot (the server drops a message with no dot) and for
49
+ * a reply that refused the message (a 4xx or 5xx says it was not taken).
50
+ */
51
+ readonly afterData?: boolean;
37
52
  constructor(code: SmtpErrorCode, message: string, details?: SmtpErrorDetails);
38
53
  }
39
54
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAE9C,uGAAuG;AACvG,MAAM,MAAM,aAAa,GACtB,gBAAgB,GAChB,mBAAmB,GACnB,SAAS,GACT,iBAAiB,GACjB,iBAAiB,GACjB,iBAAiB,GACjB,cAAc,GACd,oBAAoB,GACpB,kBAAkB,GAClB,mBAAmB,GACnB,SAAS,GACT,WAAW,GACX,SAAS,GACT,oBAAoB,GACpB,iBAAiB,GACjB,YAAY,GACZ,kBAAkB,GAClB,mBAAmB,GACnB,SAAS,GACT,YAAY,CAAC;AAEhB,6DAA6D;AAC7D,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAA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AQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;CACtB;AAED,uFAAuF;AACvF,MAAM,WAAW,gBAAgB;IAChC,qEAAqE;IACrE,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC7B,kFAAkF;IAClF,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;IACvB,yEAAyE;IACzE,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,cAAc,EAAE,CAAC;IAC9C,uDAAuD;IACvD,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IACzB;;;;OAIG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;CAC7B;AAYD;;;;;;;GAOG;AACH,qBAAa,SAAU,SAAQ,KAAK;IACnC,SAAkB,IAAI,eAAe;IACrC,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,0EAA0E;IAC1E,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,mFAAmF;IACnF,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;IACvB,gFAAgF;IAChF,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,cAAc,EAAE,CAAC;IAC9C;;;;;;;OAOG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;gBAG5B,IAAI,EAAE,aAAa,EACnB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,gBAAqB;CAc/B"}
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  decodeLoginStep2,
8
8
  LineSplitter,
9
9
  Outgoing
10
- } from "./chunks/index-n4xwep5m.js";
10
+ } from "./chunks/index-5228egp5.js";
11
11
  // src/protocol/command.ts
12
12
  function parseCommand(line) {
13
13
  const space = line.indexOf(" ");
package/docs/guide.md CHANGED
@@ -1650,6 +1650,19 @@ is not. Every other outcome rejects with an `SmtpError`: its `code`, its
1650
1650
  `temporary`, and, when a reply caused it, `reply` with its enhanced status
1651
1651
  code (RFC 3463).
1652
1652
 
1653
+ `afterData` is `true` when the final dot was written and no reply to it came
1654
+ (a `TIMEOUT`, a `CONNECTION_LOST` or a `BAD_REPLY`): the server may already
1655
+ have taken the message (RFC 5321 §4.1.5), so sending it again, or by another
1656
+ route, can duplicate it. It is absent for a failure before the dot, which
1657
+ the server drops, and for a `REFUSED` to the dot, a 4xx or 5xx that says the
1658
+ message was not taken.
1659
+
1660
+ ```ts
1661
+ if (error.temporary && error.afterData) {
1662
+ // the message may be there already: retry the same host, not another route
1663
+ }
1664
+ ```
1665
+
1653
1666
  | `code` | when | `temporary` |
1654
1667
  | --- | --- | --- |
1655
1668
  | `INVALID_OPTION` | an option, an address or the message cannot be used | no |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bumail/smtp",
3
- "version": "0.6.0",
3
+ "version": "0.7.1",
4
4
  "description": "An SMTP server on Bun.listen — RFC 5321 with PIPELINING, SIZE, 8BITMIME, SMTPUTF8, STARTTLS and AUTH after TLS, policy hooks, and no open relay — and a client that delivers a message to a smarthost or by MX",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -47,9 +47,9 @@
47
47
  ]
48
48
  },
49
49
  "devDependencies": {
50
- "@bumail/auth": "^0.3.0",
51
- "@bumail/dns": "^0.1.1",
52
- "@bumail/store": "^0.4.0",
50
+ "@bumail/auth": "^0.4.1",
51
+ "@bumail/dns": "^0.2.1",
52
+ "@bumail/store": "^0.4.1",
53
53
  "@types/bun": "^1.4.2"
54
54
  },
55
55
  "peerDependencies": {