@mavogel/awscdk-rootmail 0.1.41 → 0.1.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/.jsii +9 -9
  2. package/lib/rootmail.js +1 -1
  3. package/lib/ses-receive.js +1 -1
  4. package/node_modules/@aws-sdk/checksums/package.json +5 -5
  5. package/node_modules/@aws-sdk/client-cloudwatch-logs/dist-cjs/index.js +1 -1
  6. package/node_modules/@aws-sdk/client-cloudwatch-logs/package.json +8 -8
  7. package/node_modules/@aws-sdk/client-route-53/dist-cjs/index.js +1 -1
  8. package/node_modules/@aws-sdk/client-route-53/package.json +9 -9
  9. package/node_modules/@aws-sdk/client-s3/dist-cjs/index.js +1 -1
  10. package/node_modules/@aws-sdk/client-s3/package.json +12 -12
  11. package/node_modules/@aws-sdk/client-ses/dist-cjs/index.js +1 -1
  12. package/node_modules/@aws-sdk/client-ses/package.json +8 -8
  13. package/node_modules/@aws-sdk/client-ssm/dist-cjs/index.js +1 -1
  14. package/node_modules/@aws-sdk/client-ssm/package.json +8 -8
  15. package/node_modules/@aws-sdk/core/dist-cjs/submodules/client/index.js +7 -2
  16. package/node_modules/@aws-sdk/core/dist-cjs/submodules/httpAuthSchemes/index.js +3 -0
  17. package/node_modules/@aws-sdk/core/dist-es/submodules/client/setFeature.js +0 -2
  18. package/node_modules/@aws-sdk/core/dist-es/submodules/client/util-endpoints/lib/aws/partitions.js +6 -0
  19. package/node_modules/@aws-sdk/core/dist-es/submodules/httpAuthSchemes/utils/getUpdatedSystemClockOffset.js +3 -0
  20. package/node_modules/@aws-sdk/core/dist-types/submodules/client/util-endpoints/lib/aws/partitions.d.ts +20 -0
  21. package/node_modules/@aws-sdk/core/dist-types/submodules/httpAuthSchemes/utils/getUpdatedSystemClockOffset.d.ts +1 -0
  22. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-endpoints/lib/aws/partitions.d.ts +20 -0
  23. package/node_modules/@aws-sdk/core/package.json +7 -8
  24. package/node_modules/@aws-sdk/credential-provider-env/package.json +5 -5
  25. package/node_modules/@aws-sdk/credential-provider-http/package.json +7 -7
  26. package/node_modules/@aws-sdk/credential-provider-ini/package.json +12 -12
  27. package/node_modules/@aws-sdk/credential-provider-login/package.json +6 -6
  28. package/node_modules/@aws-sdk/credential-provider-node/package.json +10 -10
  29. package/node_modules/@aws-sdk/credential-provider-process/package.json +5 -5
  30. package/node_modules/@aws-sdk/credential-provider-sso/package.json +7 -7
  31. package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +6 -6
  32. package/node_modules/@aws-sdk/middleware-sdk-route53/package.json +3 -3
  33. package/node_modules/@aws-sdk/middleware-sdk-s3/package.json +6 -6
  34. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/cognito-identity/index.js +1 -1
  35. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/signin/index.js +1 -1
  36. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso/index.js +1 -1
  37. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/index.js +1 -1
  38. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/index.js +1 -1
  39. package/node_modules/@aws-sdk/nested-clients/package.json +8 -8
  40. package/node_modules/@aws-sdk/signature-v4-multi-region/package.json +3 -3
  41. package/node_modules/@aws-sdk/token-providers/package.json +6 -6
  42. package/node_modules/@aws-sdk/types/package.json +2 -2
  43. package/node_modules/@aws-sdk/xml-builder/package.json +2 -2
  44. package/node_modules/@smithy/core/dist-cjs/submodules/client/index.js +1 -0
  45. package/node_modules/@smithy/core/dist-cjs/submodules/retry/index.browser.js +41 -13
  46. package/node_modules/@smithy/core/dist-cjs/submodules/retry/index.js +41 -13
  47. package/node_modules/@smithy/core/dist-es/submodules/client/smithy-client/command.js +1 -0
  48. package/node_modules/@smithy/core/dist-es/submodules/retry/middleware-retry/retryMiddleware.js +11 -5
  49. package/node_modules/@smithy/core/dist-es/submodules/retry/util-retry/StandardRetryStrategy.js +2 -2
  50. package/node_modules/@smithy/core/dist-es/submodules/retry/util-retry/race.js +22 -0
  51. package/node_modules/@smithy/core/dist-es/submodules/retry/util-retry/retries-2026-config.js +6 -6
  52. package/node_modules/@smithy/core/dist-types/submodules/retry/util-retry/race.d.ts +3 -0
  53. package/node_modules/@smithy/core/dist-types/submodules/retry/util-retry/retries-2026-config.d.ts +16 -6
  54. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/retry/util-retry/race.d.ts +3 -0
  55. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/retry/util-retry/retries-2026-config.d.ts +16 -6
  56. package/node_modules/@smithy/core/package.json +2 -2
  57. package/node_modules/@smithy/fetch-http-handler/dist-cjs/index.js +10 -4
  58. package/node_modules/@smithy/fetch-http-handler/dist-es/fetch-http-handler.js +6 -2
  59. package/node_modules/@smithy/fetch-http-handler/dist-es/request-timeout.js +4 -2
  60. package/node_modules/@smithy/fetch-http-handler/dist-types/request-timeout.d.ts +12 -1
  61. package/node_modules/@smithy/fetch-http-handler/dist-types/ts3.4/request-timeout.d.ts +12 -1
  62. package/node_modules/@smithy/fetch-http-handler/package.json +3 -3
  63. package/node_modules/@smithy/node-http-handler/dist-cjs/index.js +31 -31
  64. package/node_modules/@smithy/node-http-handler/dist-es/node-http-handler.js +2 -4
  65. package/node_modules/@smithy/node-http-handler/dist-es/set-socket-timeout.js +29 -27
  66. package/node_modules/@smithy/node-http-handler/dist-types/set-socket-timeout.d.ts +7 -3
  67. package/node_modules/@smithy/node-http-handler/dist-types/ts3.4/set-socket-timeout.d.ts +7 -3
  68. package/node_modules/@smithy/node-http-handler/package.json +3 -3
  69. package/node_modules/@smithy/types/dist-types/middleware.d.ts +6 -0
  70. package/node_modules/@smithy/types/dist-types/ts3.4/middleware.d.ts +6 -0
  71. package/node_modules/@smithy/types/package.json +1 -1
  72. package/node_modules/mailparser/CHANGELOG.md +7 -0
  73. package/node_modules/mailparser/package.json +3 -3
  74. package/node_modules/nodemailer/CHANGELOG.md +28 -0
  75. package/node_modules/nodemailer/README.md +21 -0
  76. package/node_modules/nodemailer/dist/cjs/addressparser/index.js +185 -2
  77. package/node_modules/nodemailer/dist/cjs/dkim/sign.js +2 -2
  78. package/node_modules/nodemailer/dist/cjs/errors.d.ts +2 -0
  79. package/node_modules/nodemailer/dist/cjs/errors.js +11 -1
  80. package/node_modules/nodemailer/dist/cjs/json-transport/index.js +2 -0
  81. package/node_modules/nodemailer/dist/cjs/mailer/index.d.ts +12 -2
  82. package/node_modules/nodemailer/dist/cjs/mailer/index.js +56 -4
  83. package/node_modules/nodemailer/dist/cjs/mailer/mail-message.d.ts +10 -0
  84. package/node_modules/nodemailer/dist/cjs/mime-funcs/index.d.ts +2 -1
  85. package/node_modules/nodemailer/dist/cjs/mime-funcs/index.js +72 -2
  86. package/node_modules/nodemailer/dist/cjs/mime-node/index.js +1 -73
  87. package/node_modules/nodemailer/dist/cjs/package-info.d.ts +1 -1
  88. package/node_modules/nodemailer/dist/cjs/package-info.js +1 -1
  89. package/node_modules/nodemailer/dist/cjs/shared/index.d.ts +23 -0
  90. package/node_modules/nodemailer/dist/cjs/shared/index.js +79 -0
  91. package/node_modules/nodemailer/dist/cjs/smtp-connection/index.js +6 -0
  92. package/node_modules/nodemailer/dist/cjs/smtp-pool/index.d.ts +10 -3
  93. package/node_modules/nodemailer/dist/cjs/smtp-pool/index.js +70 -12
  94. package/node_modules/nodemailer/dist/cjs/smtp-pool/pool-resource.js +26 -4
  95. package/node_modules/nodemailer/dist/cjs/smtp-transport/index.d.ts +1 -0
  96. package/node_modules/nodemailer/dist/cjs/smtp-transport/index.js +47 -35
  97. package/node_modules/nodemailer/dist/cjs/well-known/services.js +7 -0
  98. package/node_modules/nodemailer/dist/esm/addressparser/index.js +185 -2
  99. package/node_modules/nodemailer/dist/esm/dkim/sign.js +2 -2
  100. package/node_modules/nodemailer/dist/esm/errors.d.ts +2 -0
  101. package/node_modules/nodemailer/dist/esm/errors.js +9 -0
  102. package/node_modules/nodemailer/dist/esm/json-transport/index.js +2 -0
  103. package/node_modules/nodemailer/dist/esm/mailer/index.d.ts +12 -2
  104. package/node_modules/nodemailer/dist/esm/mailer/index.js +56 -4
  105. package/node_modules/nodemailer/dist/esm/mailer/mail-message.d.ts +10 -0
  106. package/node_modules/nodemailer/dist/esm/mime-funcs/index.d.ts +2 -1
  107. package/node_modules/nodemailer/dist/esm/mime-funcs/index.js +72 -2
  108. package/node_modules/nodemailer/dist/esm/mime-node/index.js +1 -73
  109. package/node_modules/nodemailer/dist/esm/package-info.d.ts +1 -1
  110. package/node_modules/nodemailer/dist/esm/package-info.js +1 -1
  111. package/node_modules/nodemailer/dist/esm/shared/index.d.ts +23 -0
  112. package/node_modules/nodemailer/dist/esm/shared/index.js +78 -0
  113. package/node_modules/nodemailer/dist/esm/smtp-connection/index.js +6 -0
  114. package/node_modules/nodemailer/dist/esm/smtp-pool/index.d.ts +10 -3
  115. package/node_modules/nodemailer/dist/esm/smtp-pool/index.js +70 -12
  116. package/node_modules/nodemailer/dist/esm/smtp-pool/pool-resource.js +26 -4
  117. package/node_modules/nodemailer/dist/esm/smtp-transport/index.d.ts +1 -0
  118. package/node_modules/nodemailer/dist/esm/smtp-transport/index.js +47 -35
  119. package/node_modules/nodemailer/dist/esm/well-known/services.js +7 -0
  120. package/node_modules/nodemailer/dist/well-known/services.json +8 -0
  121. package/node_modules/nodemailer/package.json +7 -7
  122. package/package.json +10 -10
@@ -1,36 +1,38 @@
1
1
  import { timing } from "./timing";
2
2
  const DEFER_EVENT_LISTENER_TIME = 3000;
3
- export const setSocketTimeout = (request, reject, timeoutInMs = 0, destroyResponseBodyOnTimeout = false) => {
4
- let response;
5
- if (destroyResponseBodyOnTimeout) {
6
- request.once("response", (res) => (response = res));
3
+ export const setSocketTimeout = (request, reject, timeoutInMs = 0, isServiceDefault = false) => {
4
+ if (!Number.isFinite(timeoutInMs) || timeoutInMs <= 0) {
5
+ return;
7
6
  }
8
- const registerTimeout = (offset) => {
9
- const timeout = timeoutInMs - offset;
10
- const onTimeout = () => {
11
- const error = Object.assign(new Error(`@smithy/node-http-handler - the request socket timed out after ${timeoutInMs} ms of inactivity (${destroyResponseBodyOnTimeout ? "service default socket timeout" : "configured by client requestHandler"}).`), { name: "TimeoutError" });
12
- if (destroyResponseBodyOnTimeout) {
13
- response?.destroy(error);
14
- }
15
- request.destroy();
16
- reject(error);
17
- };
18
- if (request.socket) {
19
- request.socket.setTimeout(timeout, onTimeout);
20
- request.on("close", () => request.socket?.removeListener("timeout", onTimeout));
7
+ let response;
8
+ request.once("response", (res) => (response = res));
9
+ const onTimeout = () => {
10
+ if (response?.complete) {
11
+ request.socket?.destroy();
12
+ return;
13
+ }
14
+ const error = Object.assign(new Error(`@smithy/node-http-handler - the request socket timed out after ${timeoutInMs} ms of inactivity (${isServiceDefault ? "service default socket timeout" : "configured by client requestHandler"}).`), { name: "TimeoutError" });
15
+ response?.destroy(error);
16
+ request.destroy();
17
+ reject(error);
18
+ };
19
+ const registerTimeout = () => {
20
+ const { socket } = request;
21
+ if (!socket) {
22
+ request.once("socket", registerTimeout);
23
+ }
24
+ else if (socket.connecting) {
25
+ socket.once("connect", registerTimeout);
21
26
  }
22
27
  else {
23
- request.setTimeout(timeout, onTimeout);
28
+ socket.setTimeout(timeoutInMs, onTimeout);
29
+ request.on("close", () => socket.removeListener("timeout", onTimeout));
24
30
  }
25
31
  };
26
- if (0 < timeoutInMs && timeoutInMs < 6000) {
27
- registerTimeout(0);
28
- return 0;
29
- }
30
- const deferralId = timing.setTimeout(registerTimeout.bind(null, timeoutInMs === 0 ? 0 : DEFER_EVENT_LISTENER_TIME), DEFER_EVENT_LISTENER_TIME);
31
- if (destroyResponseBodyOnTimeout) {
32
- request.once("close", () => timing.clearTimeout(deferralId));
33
- return 0;
32
+ if (timeoutInMs < 6000) {
33
+ registerTimeout();
34
+ return;
34
35
  }
35
- return deferralId;
36
+ const deferralId = timing.setTimeout(registerTimeout, DEFER_EVENT_LISTENER_TIME);
37
+ request.once("close", () => timing.clearTimeout(deferralId));
36
38
  };
@@ -1,7 +1,11 @@
1
1
  import type { ClientRequest } from "node:http";
2
2
  /**
3
+ * Sets a rolling socket idle timeout that stays armed through the response body. Timeouts of
4
+ * 6000 ms or more register after 3000 ms, so requests that finish sooner skip the socket
5
+ * listener, and may fire up to 3000 ms late. The timeout is not cancelled on headers. It is
6
+ * removed, or its deferral cleared, when the request closes.
7
+ *
3
8
  * @internal
4
- * @param destroyResponseBodyOnTimeout - set by the service default. On timeout the response
5
- * body is destroyed with the TimeoutError, and the timeout stays armed through the body.
9
+ * @param isServiceDefault - whether timeoutInMs is the service default, which labels the error.
6
10
  */
7
- export declare const setSocketTimeout: (request: ClientRequest, reject: (err: Error) => void, timeoutInMs?: number, destroyResponseBodyOnTimeout?: boolean) => NodeJS.Timeout | number;
11
+ export declare const setSocketTimeout: (request: ClientRequest, reject: (err: Error) => void, timeoutInMs?: number, isServiceDefault?: boolean) => void;
@@ -1,7 +1,11 @@
1
1
  import { ClientRequest } from "node:http";
2
2
  /**
3
+ * Sets a rolling socket idle timeout that stays armed through the response body. Timeouts of
4
+ * 6000 ms or more register after 3000 ms, so requests that finish sooner skip the socket
5
+ * listener, and may fire up to 3000 ms late. The timeout is not cancelled on headers. It is
6
+ * removed, or its deferral cleared, when the request closes.
7
+ *
3
8
  * @internal
4
- * @param destroyResponseBodyOnTimeout - set by the service default. On timeout the response
5
- * body is destroyed with the TimeoutError, and the timeout stays armed through the body.
9
+ * @param isServiceDefault - whether timeoutInMs is the service default, which labels the error.
6
10
  */
7
- export declare const setSocketTimeout: (request: ClientRequest, reject: (err: Error) => void, timeoutInMs?: number, destroyResponseBodyOnTimeout?: boolean) => NodeJS.Timeout | number;
11
+ export declare const setSocketTimeout: (request: ClientRequest, reject: (err: Error) => void, timeoutInMs?: number, isServiceDefault?: boolean) => void;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smithy/node-http-handler",
3
- "version": "4.14.1",
3
+ "version": "4.14.2",
4
4
  "description": "Provides a way to make requests",
5
5
  "homepage": "https://github.com/smithy-lang/smithy-typescript/tree/main/packages/node-http-handler",
6
6
  "license": "Apache-2.0",
@@ -39,8 +39,8 @@
39
39
  "test:watch": "yarn g:vitest watch"
40
40
  },
41
41
  "dependencies": {
42
- "@smithy/core": "^3.38.1",
43
- "@smithy/types": "^4.19.0",
42
+ "@smithy/core": "^3.39.0",
43
+ "@smithy/types": "^4.20.0",
44
44
  "tslib": "^2.6.2"
45
45
  },
46
46
  "devDependencies": {
@@ -1,3 +1,4 @@
1
+ import type { AbortSignal as DeprecatedAbortSignal } from "./abort";
1
2
  import type { SelectedHttpAuthScheme } from "./auth/HttpAuthScheme";
2
3
  import type { AuthScheme, HttpAuthDefinition } from "./auth/auth";
3
4
  import type { Command } from "./command";
@@ -510,6 +511,11 @@ export interface HandlerExecutionContext {
510
511
  * Transferred from request options to the Smithy context.
511
512
  */
512
513
  metricsRecorder?: MetricsRecorder<unknown>;
514
+ /**
515
+ * Transferred from request options to allow middleware to cancel
516
+ * asynchronous work outside of the request handler.
517
+ */
518
+ abortSignal?: AbortSignal | DeprecatedAbortSignal;
513
519
  /**
514
520
  * @deprecated
515
521
  * Do not assign arbitrary members to the Smithy Context,
@@ -1,3 +1,4 @@
1
+ import { AbortSignal as DeprecatedAbortSignal } from "./abort";
1
2
  import { SelectedHttpAuthScheme } from "./auth/HttpAuthScheme";
2
3
  import { AuthScheme, HttpAuthDefinition } from "./auth/auth";
3
4
  import { Command } from "./command";
@@ -510,6 +511,11 @@ export interface HandlerExecutionContext {
510
511
  * Transferred from request options to the Smithy context.
511
512
  */
512
513
  metricsRecorder?: MetricsRecorder<unknown>;
514
+ /**
515
+ * Transferred from request options to allow middleware to cancel
516
+ * asynchronous work outside of the request handler.
517
+ */
518
+ abortSignal?: AbortSignal | DeprecatedAbortSignal;
513
519
  /**
514
520
  * @deprecated
515
521
  * Do not assign arbitrary members to the Smithy Context,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smithy/types",
3
- "version": "4.19.0",
3
+ "version": "4.20.0",
4
4
  "homepage": "https://github.com/smithy-lang/smithy-typescript/tree/main/packages/types",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [3.14.3](https://github.com/nodemailer/mailparser/compare/v3.14.2...v3.14.3) (2026-11-10)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * update dependencies ([76cdfce](https://github.com/nodemailer/mailparser/commit/76cdfce245775bdbc71293734e05b6113fa4133d))
9
+
3
10
  ## [3.14.2](https://github.com/nodemailer/mailparser/compare/v3.14.1...v3.14.2) (2026-11-04)
4
11
 
5
12
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mailparser",
3
- "version": "3.14.2",
3
+ "version": "3.14.3",
4
4
  "description": "Parse e-mails",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/index.js",
@@ -97,7 +97,7 @@
97
97
  "html-to-text": "10.0.1",
98
98
  "libmime": "5.6.4",
99
99
  "linkify-it": "5.0.2",
100
- "nodemailer": "10.3.1",
100
+ "nodemailer": "10.5.0",
101
101
  "punycode.js": "2.3.1",
102
102
  "tlds": "1.261.0"
103
103
  },
@@ -112,7 +112,7 @@
112
112
  "prettier": "3.9.10",
113
113
  "tsx": "4.23.15",
114
114
  "typescript": "6.0.3",
115
- "typescript-eslint": "8.72.1"
115
+ "typescript-eslint": "8.72.2"
116
116
  },
117
117
  "repository": {
118
118
  "type": "git",
@@ -1,5 +1,33 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## [10.5.0](https://github.com/nodemailer/nodemailer/compare/v10.4.1...v10.5.0) (2026-11-10)
4
+
5
+
6
+ ### Features
7
+
8
+ * **smtp:** support AbortSignal for individual sends ([#1911](https://github.com/nodemailer/nodemailer/issues/1911)) ([66387ed](https://github.com/nodemailer/nodemailer/commit/66387ed6f4bd26208b944b74b7329201ad77377b)), closes [#1910](https://github.com/nodemailer/nodemailer/issues/1910)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **dkim:** encode the d= domain the same way as the address headers ([#1908](https://github.com/nodemailer/nodemailer/issues/1908)) ([4ebf03f](https://github.com/nodemailer/nodemailer/commit/4ebf03fba33a96118c10afa340ce895a00549148))
14
+ * **mime-funcs:** encode header text that would be decoded as an invalid encoded word ([#1912](https://github.com/nodemailer/nodemailer/issues/1912)) ([7a7b942](https://github.com/nodemailer/nodemailer/commit/7a7b9427b632d8785190747ae2c62e88e77bc837))
15
+
16
+ ## [10.4.1](https://github.com/nodemailer/nodemailer/compare/v10.4.0...v10.4.1) (2026-11-10)
17
+
18
+
19
+ ### Bug Fixes
20
+
21
+ * **addressparser:** read whitespace and comments around a dot of the domain as CFWS ([c2b9c41](https://github.com/nodemailer/nodemailer/commit/c2b9c41bb81b2294ebadd294ad15ff035a17d0a5))
22
+ * **mime-node:** hand a domain to the UTS-46 mapper without lowercasing it first ([093e4dd](https://github.com/nodemailer/nodemailer/commit/093e4dd60af8a21e7f06a49c7f889291728e966a))
23
+
24
+ ## [10.4.0](https://github.com/nodemailer/nodemailer/compare/v10.3.1...v10.4.0) (2026-11-07)
25
+
26
+
27
+ ### Features
28
+
29
+ * let close({ force: true }) end pooled connections that are delivering a message ([aba943c](https://github.com/nodemailer/nodemailer/commit/aba943cf9d24493aca2a3e043df06beadc728feb))
30
+
3
31
  ## [10.3.1](https://github.com/nodemailer/nodemailer/compare/v10.3.0...v10.3.1) (2026-10-29)
4
32
 
5
33
 
@@ -14,6 +14,27 @@ See [nodemailer.com](https://nodemailer.com/) for documentation and terms.
14
14
 
15
15
  Nodemailer targets Node.js 20 and later. The ES module build also runs on [Bun](https://bun.sh/) (tested against the latest release) and on [Cloudflare Workers](https://developers.cloudflare.com/workers/) with the `nodejs_compat` compatibility flag. On Workers only the SMTP based transports apply, `sendmail` needs a child process, and the runtime does not allow turning certificate validation off, so `tls.rejectUnauthorized: false` fails there with an error.
16
16
 
17
+ ## Cancelling an individual SMTP send
18
+
19
+ Pass an `AbortSignal` in the message options to cancel one `sendMail()` call:
20
+
21
+ ```js
22
+ await transporter.sendMail({
23
+ from: 'sender@example.com',
24
+ to: 'recipient@example.com',
25
+ text: 'Hello',
26
+ signal: AbortSignal.timeout(30_000)
27
+ });
28
+ ```
29
+
30
+ This is supported by SMTP and pooled SMTP transports. A pre-aborted signal prevents processing; aborting later stops subsequent plugin processing, removes a queued message, or closes the SMTP connection assigned to that message. Other deliveries in the pool can continue. Both promise and callback forms report an error named `AbortError`, with `code: 'EABORT'` and the signal's reason as `cause`. The signal listener is removed when the send finishes.
31
+
32
+ Cancellation stops local processing; it does not prove that the SMTP server has not already accepted the message. Do not retry a cancelled send automatically on that assumption.
33
+
34
+ Work already started by a plugin or a custom `getSocket` hook requires that code's cooperation to stop. Nodemailer ignores late plugin completion and destroys a socket handed back after cancellation. Plugins can read `mail.data.signal` to cancel their own work.
35
+
36
+ Other bundled transports (stream, JSON, sendmail and SES) ignore the signal once the message is handed to them, so the message is sent normally. A signal that is already aborted, or aborts while plugins run, still cancels the send with `EABORT` on every transport, as that happens before the transport is called. A `signal` value that is not an `AbortSignal` fails the send with `ECONFIG`. Custom transports can opt in with `supportsAbortSignal: true`; their `send()` must register its abort listener synchronously, check for a pre-aborted signal, stop the work it owns, invoke its callback once, and remove the listener on completion.
37
+
17
38
  ## Having an issue?
18
39
 
19
40
  #### First review the docs
@@ -48,6 +48,30 @@ class TokenList {
48
48
  this.slots[at + 2] = end;
49
49
  return this.length++;
50
50
  }
51
+ /**
52
+ * Offset of the first character of a token that is part of its value. A text run that is
53
+ * no plain slice of the field still spans the whitespace and control characters its value
54
+ * is trimmed of.
55
+ */
56
+ contentStart(index) {
57
+ let start = this.slots[index * 3 + 1];
58
+ const end = this.slots[index * 3 + 2];
59
+ while (start < end && _isDroppedCode(this.str.charCodeAt(start))) {
60
+ start++;
61
+ }
62
+ return start;
63
+ }
64
+ /**
65
+ * Offset just past the last character of a token that is part of its value
66
+ */
67
+ contentEnd(index) {
68
+ const start = this.slots[index * 3 + 1];
69
+ let end = this.slots[index * 3 + 2];
70
+ while (end > start && _isDroppedCode(this.str.charCodeAt(end - 1))) {
71
+ end--;
72
+ }
73
+ return end;
74
+ }
51
75
  /**
52
76
  * The character of an operator token, an empty string for a text run
53
77
  */
@@ -183,6 +207,44 @@ function _isSpaceCode(code) {
183
207
  code === 0x3000 ||
184
208
  code === 0xfeff);
185
209
  }
210
+ /**
211
+ * Checks for the whitespace RFC 5322 folding whitespace is made of: SP and HTAB, plus the
212
+ * line break a fold carries. The other characters _isSpaceCode accepts are atext under
213
+ * RFC 6532, and parsers disagree on them: mailauth keeps U+00A0 in a domain, so joining a
214
+ * domain across one names a domain that reader never sees
215
+ *
216
+ * @param code Character code
217
+ * @return true if the character is folding whitespace
218
+ */
219
+ function _isFoldingSpaceCode(code) {
220
+ return code === 0x20 || code === 0x09 || code === 0x0d || code === 0x0a;
221
+ }
222
+ /**
223
+ * Checks if every character in a stretch of the field is folding whitespace
224
+ *
225
+ * @param str The field
226
+ * @param from Offset of the first character
227
+ * @param to Offset just past the last one
228
+ * @return true if the stretch holds nothing but folding whitespace
229
+ */
230
+ function _isFoldingGap(str, from, to) {
231
+ for (let i = from; i < to; i++) {
232
+ if (!_isFoldingSpaceCode(str.charCodeAt(i))) {
233
+ return false;
234
+ }
235
+ }
236
+ return true;
237
+ }
238
+ /**
239
+ * Checks for a character the value of a text run is trimmed of, or leaves out: whitespace,
240
+ * C0 controls and DEL
241
+ *
242
+ * @param code Character code
243
+ * @return true if the character is not part of the value at the edge of a run
244
+ */
245
+ function _isDroppedCode(code) {
246
+ return code < 0x20 || code === 0x7f || _isSpaceCode(code);
247
+ }
186
248
  /**
187
249
  * The characters JS `\w` matches without the unicode flag, the set the `\b` in
188
250
  * LOOSE_TEXT_ADDR is read against. charCodeAt off either end of the string gives NaN,
@@ -233,6 +295,9 @@ const LEADING_QUOTED_STRING = /^"(?:[^"\\]|\\[\s\S])*"/;
233
295
  * The scan is by index, a pattern such as /\s+@/ backtracks over a long whitespace run that
234
296
  * no '@' follows.
235
297
  *
298
+ * The whitespace around the dots of the domain that follows is dropped as well, see
299
+ * _joinDomainDotSpacing.
300
+ *
236
301
  * @param value Value holding the '@'
237
302
  * @param at Offset of the '@', or -1
238
303
  * @return The value with the whitespace beside that '@' removed
@@ -249,7 +314,86 @@ function _joinAtSpacing(value, at) {
249
314
  while (end < value.length && _isSpaceCode(value.charCodeAt(end))) {
250
315
  end++;
251
316
  }
252
- return start === at && end === at + 1 ? value : value.slice(0, start) + '@' + value.slice(end);
317
+ const joined = start === at && end === at + 1 ? value : value.slice(0, start) + '@' + value.slice(end);
318
+ return _joinDomainDotSpacing(joined, start);
319
+ }
320
+ // The ASCII atext characters: printable, and none of the RFC 5322 specials
321
+ const ASCII_ATEXT = new Uint8Array(0x80);
322
+ for (let code = 0x21; code < 0x7f; code++) {
323
+ ASCII_ATEXT[code] = '()<>[]:;@\\,."'.indexOf(String.fromCharCode(code)) < 0 ? 1 : 0;
324
+ }
325
+ /**
326
+ * Checks if a character can be part of an atom: anything but the specials, whitespace and
327
+ * the control characters (RFC 5322 3.2.3, with non-ASCII allowed as RFC 6532 does)
328
+ *
329
+ * @param code Character code
330
+ * @return true if the character is atext
331
+ */
332
+ function _isAtextCode(code) {
333
+ return code < 0x80 ? ASCII_ATEXT[code] === 1 : !_isSpaceCode(code);
334
+ }
335
+ /**
336
+ * Drops the whitespace around the dots of the domain behind the '@' at an offset.
337
+ *
338
+ * obs-domain is atoms with CFWS around the dots (RFC 5322 4.4), so 'user@victim.example
339
+ * .allowed.example' names user@victim.example.allowed.example. Read as two runs, the domain
340
+ * ended at the whitespace and the envelope went to victim.example, a different domain than
341
+ * the one an RFC 5322 parser, and an application validating the address with one, reads
342
+ * (GHSA-3q53-mvfw-q9v8). A comment around a dot reaches here as whitespace.
343
+ *
344
+ * Only SP, HTAB and a fold count as the whitespace, see _isFoldingSpaceCode.
345
+ *
346
+ * Only a dot with an atom on both sides joins, as for a conformant parser: whitespace that
347
+ * is not beside a dot ends the domain, and so does a dot that no atom follows, which keeps
348
+ * 'user@example.com .' from becoming a domain with a trailing dot. A domain literal is left
349
+ * alone. Everything from where the domain ends is kept as it is.
350
+ *
351
+ * @param value Value holding the '@'
352
+ * @param at Offset of the '@'
353
+ * @return The value with the whitespace around the dots of that domain removed
354
+ */
355
+ function _joinDomainDotSpacing(value, at) {
356
+ const len = value.length;
357
+ // '[' is no atext, so a domain literal ends the walk before it starts
358
+ let pos = at + 1;
359
+ let spaced = false;
360
+ for (;;) {
361
+ const labelStart = pos;
362
+ while (pos < len && _isAtextCode(value.charCodeAt(pos))) {
363
+ pos++;
364
+ }
365
+ if (pos === labelStart) {
366
+ break;
367
+ }
368
+ // the dot, with the whitespace on either side of it, and the label behind it
369
+ let next = pos;
370
+ while (next < len && _isFoldingSpaceCode(value.charCodeAt(next))) {
371
+ next++;
372
+ }
373
+ if (value.charCodeAt(next) !== 0x2e) {
374
+ break;
375
+ }
376
+ next++;
377
+ while (next < len && _isFoldingSpaceCode(value.charCodeAt(next))) {
378
+ next++;
379
+ }
380
+ if (next >= len || !_isAtextCode(value.charCodeAt(next))) {
381
+ break;
382
+ }
383
+ spaced = spaced || next !== pos + 1;
384
+ pos = next;
385
+ }
386
+ if (!spaced) {
387
+ return value;
388
+ }
389
+ // every whitespace character the walk covered sits beside a dot
390
+ let domain = '';
391
+ for (let k = at + 1; k < pos; k++) {
392
+ if (!_isFoldingSpaceCode(value.charCodeAt(k))) {
393
+ domain += value.charAt(k);
394
+ }
395
+ }
396
+ return value.slice(0, at + 1) + domain + value.slice(pos);
253
397
  }
254
398
  /**
255
399
  * Drops the whitespace beside the '@' that splits the domain off a value. That is the '@'
@@ -553,6 +697,15 @@ function _collectAddressParts(tokens, from, to) {
553
697
  // whether the last text run holds nothing but quoted text so far, which is what a quoted
554
698
  // local part is until the '@' after it joins the run
555
699
  let lastTextPureQuoted = false;
700
+ // whether the last text run holds an unquoted '@', so that it runs on into a domain, and
701
+ // whether nothing but comments has come since it, see the join below
702
+ let lastTextHasAt = false;
703
+ let lastTextOpen = false;
704
+ // Where the last text run, or the last comment since it, ended in the field, and whether
705
+ // everything between it and the comments since was folding whitespace. The tokens are
706
+ // trimmed of any whitespace, so this is read off the field itself.
707
+ let gapFrom = 0;
708
+ let gapsFolding = true;
556
709
  // Last character of the run each state is currently accumulating. Reading it back off
557
710
  // the accumulator with slice(-1) makes the engine flatten the whole growing string on
558
711
  // every token, which is quadratic over an address built from many comment-joined atoms
@@ -570,18 +723,27 @@ function _collectAddressParts(tokens, from, to) {
570
723
  case '<':
571
724
  state = 'address';
572
725
  insideQuotes = false;
726
+ lastTextOpen = false;
573
727
  break;
574
728
  case '(':
575
729
  state = 'comment';
576
730
  insideQuotes = false;
731
+ gapsFolding = gapsFolding && _isFoldingGap(tokens.str, gapFrom, tokens.contentStart(i));
577
732
  break;
578
733
  case '"':
579
734
  insideQuotes = !insideQuotes;
580
735
  state = 'text';
736
+ lastTextOpen = false;
581
737
  break;
582
738
  default:
583
739
  state = 'text';
584
740
  insideQuotes = false;
741
+ if (value !== ')') {
742
+ lastTextOpen = false;
743
+ }
744
+ else {
745
+ gapFrom = tokens.contentEnd(i);
746
+ }
585
747
  break;
586
748
  }
587
749
  }
@@ -598,8 +760,23 @@ function _collectAddressParts(tokens, from, to) {
598
760
  // of the '@', but it cannot join two atoms into one: gluing across it would read
599
761
  // 'user@example.com(x)evil.com' as the single domain 'example.comevil.com' and
600
762
  // deliver to a domain the sender never named.
763
+ // A comment beside a dot of a domain is CFWS inside obs-domain, with or without
764
+ // folding whitespace around it, so 'user@victim.example(x).allowed.example' names
765
+ // one domain (GHSA-3q53-mvfw-q9v8). Any other whitespace in between keeps them apart.
766
+ // A ')' always leaves the walk in unquoted text, so neither needs checking here.
767
+ // Neither join across a comment takes in a second '@' once the run holds one: the
768
+ // address would then split at the last '@', and 'user@company(x).com@attacker.net',
769
+ // which an RFC 5322 parser reads as user@company.com, would go to attacker.net.
601
770
  const parts = data[state];
602
- const joins = prevNoBreak && parts.length && (prevOperator !== ')' || lastChars[state] === '@' || value.charAt(0) === '@');
771
+ const secondAt = lastTextHasAt && prevOperator === ')' && value.indexOf('@') >= 0;
772
+ const joinsDomain = !secondAt &&
773
+ lastTextOpen &&
774
+ lastTextHasAt &&
775
+ prevOperator === ')' &&
776
+ (lastChars.text === '.' || value.charAt(0) === '.') &&
777
+ gapsFolding &&
778
+ _isFoldingGap(tokens.str, gapFrom, tokens.contentStart(i));
779
+ const joins = joinsDomain || (!secondAt && prevNoBreak && parts.length > 0 && (prevOperator !== ')' || lastChars[state] === '@' || value.charAt(0) === '@'));
603
780
  if (joins) {
604
781
  const last = data[state].length - 1;
605
782
  if (state === 'text' && !insideQuotes) {
@@ -624,6 +801,12 @@ function _collectAddressParts(tokens, from, to) {
624
801
  lastTextPureQuoted = insideQuotes;
625
802
  }
626
803
  }
804
+ if (state === 'text') {
805
+ lastTextHasAt = (joins && lastTextHasAt) || (!insideQuotes && value.indexOf('@') >= 0);
806
+ lastTextOpen = true;
807
+ gapFrom = tokens.contentEnd(i);
808
+ gapsFolding = true;
809
+ }
627
810
  }
628
811
  }
629
812
  // If there is no text but a comment, replace the two. A comment is never part of a
@@ -36,7 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
36
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- const punycode = __importStar(require("../punycode/index.js"));
39
+ const shared = __importStar(require("../shared/index.js"));
40
40
  const mimeFuncs = __importStar(require("../mime-funcs/index.js"));
41
41
  const node_crypto_1 = __importDefault(require("node:crypto"));
42
42
  const errors = __importStar(require("../errors.js"));
@@ -103,7 +103,7 @@ function generateDKIMHeader(domainName, keySelector, fieldNames, hashAlgo, bodyH
103
103
  'v=1',
104
104
  'a=rsa-' + hashAlgo,
105
105
  'c=relaxed/relaxed',
106
- 'd=' + punycode.toASCII(cleanTagValue(domainName)),
106
+ 'd=' + shared.normalizeDomain(cleanTagValue(domainName), false),
107
107
  'q=dns/txt',
108
108
  's=' + cleanTagValue(keySelector),
109
109
  'bh=' + bodyHash,
@@ -23,6 +23,7 @@ export declare const ERROR_CODES: {
23
23
  readonly EMESSAGE: "Message delivery error";
24
24
  readonly EOTP: "Invalid one-time passcode data (otp option)";
25
25
  readonly ESTREAM: "Stream processing error";
26
+ readonly EABORT: "Message sending aborted";
26
27
  readonly EAUTH: "Authentication failed";
27
28
  readonly ENOAUTH: "Authentication credentials not provided";
28
29
  readonly EOAUTH2: "OAuth2 token generation or refresh error";
@@ -51,6 +52,7 @@ export declare const EENVELOPE = "EENVELOPE";
51
52
  export declare const EMESSAGE = "EMESSAGE";
52
53
  export declare const EOTP = "EOTP";
53
54
  export declare const ESTREAM = "ESTREAM";
55
+ export declare const EABORT = "EABORT";
54
56
  export declare const EAUTH = "EAUTH";
55
57
  export declare const ENOAUTH = "ENOAUTH";
56
58
  export declare const EOAUTH2 = "EOAUTH2";
@@ -10,7 +10,7 @@
10
10
  * err.code = errors.ECONNECTION;
11
11
  */
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.ERR_ACCESS_DENIED = exports.isPermanentResponseCode = exports.isTransientError = exports.EFETCH = exports.EURLACCESS = exports.EFILEACCESS = exports.EPROXY = exports.ECONFIG = exports.ESES = exports.ESENDMAIL = exports.EMAXRECIPIENTS = exports.EMAXLIMIT = exports.EOAUTH2 = exports.ENOAUTH = exports.EAUTH = exports.ESTREAM = exports.EOTP = exports.EMESSAGE = exports.EENVELOPE = exports.EPROTOCOL = exports.EREQUIRETLS = exports.ETLS = exports.EDNS = exports.ESOCKET = exports.ETIMEDOUT = exports.ECONNECTION = exports.ERROR_CODES = void 0;
13
+ exports.ERR_ACCESS_DENIED = exports.isPermanentResponseCode = exports.isTransientError = exports.createAbortError = exports.EFETCH = exports.EURLACCESS = exports.EFILEACCESS = exports.EPROXY = exports.ECONFIG = exports.ESES = exports.ESENDMAIL = exports.EMAXRECIPIENTS = exports.EMAXLIMIT = exports.EOAUTH2 = exports.ENOAUTH = exports.EAUTH = exports.EABORT = exports.ESTREAM = exports.EOTP = exports.EMESSAGE = exports.EENVELOPE = exports.EPROTOCOL = exports.EREQUIRETLS = exports.ETLS = exports.EDNS = exports.ESOCKET = exports.ETIMEDOUT = exports.ECONNECTION = exports.ERROR_CODES = void 0;
14
14
  /**
15
15
  * Error code descriptions for documentation and debugging
16
16
  */
@@ -29,6 +29,7 @@ exports.ERROR_CODES = {
29
29
  EMESSAGE: 'Message delivery error',
30
30
  EOTP: 'Invalid one-time passcode data (otp option)',
31
31
  ESTREAM: 'Stream processing error',
32
+ EABORT: 'Message sending aborted',
32
33
  // Authentication errors
33
34
  EAUTH: 'Authentication failed',
34
35
  ENOAUTH: 'Authentication credentials not provided',
@@ -58,6 +59,7 @@ exports.EENVELOPE = 'EENVELOPE';
58
59
  exports.EMESSAGE = 'EMESSAGE';
59
60
  exports.EOTP = 'EOTP';
60
61
  exports.ESTREAM = 'ESTREAM';
62
+ exports.EABORT = 'EABORT';
61
63
  exports.EAUTH = 'EAUTH';
62
64
  exports.ENOAUTH = 'ENOAUTH';
63
65
  exports.EOAUTH2 = 'EOAUTH2';
@@ -70,6 +72,14 @@ exports.EPROXY = 'EPROXY';
70
72
  exports.EFILEACCESS = 'EFILEACCESS';
71
73
  exports.EURLACCESS = 'EURLACCESS';
72
74
  exports.EFETCH = 'EFETCH';
75
+ /** Creates the error reported when a caller cancels an individual send. @internal */
76
+ const createAbortError = (signal) => {
77
+ const err = new Error('Message sending aborted', { cause: signal.reason });
78
+ err.name = 'AbortError';
79
+ err.code = exports.EABORT;
80
+ return err;
81
+ };
82
+ exports.createAbortError = createAbortError;
73
83
  /**
74
84
  * Tells whether the error ended the connection rather than rejected what was sent over it
75
85
  */
@@ -83,6 +83,8 @@ class JSONTransport {
83
83
  }
84
84
  delete data.envelope;
85
85
  delete data.normalizedHeaders;
86
+ // the per-message AbortSignal is not message data
87
+ delete data.signal;
86
88
  // the message field is the object itself with skipEncoding, the
87
89
  // createTransport overload for that option types the result accordingly
88
90
  return done(null, {
@@ -112,6 +112,11 @@ export interface MailMeta {
112
112
  * declared on Transport, Transporter and Mail
113
113
  */
114
114
  export interface Transport<T = SentMessageInfo, D extends TransportOptions = TransportOptions> {
115
+ /**
116
+ * Set only if send() cancels its own work on mail.data.signal and removes its signal listener
117
+ * when finished. Without it the signal is still honored up to dispatch, then ignored.
118
+ */
119
+ supportsAbortSignal?: boolean | undefined;
115
120
  /** Transport name, used for logging */
116
121
  name: string;
117
122
  /** Transport version, used for logging */
@@ -176,8 +181,13 @@ declare class Mail<out T = SentMessageInfo, out D extends TransportOptions = Tra
176
181
  dkim: DKIM | false;
177
182
  transporter: Transport<T, D>;
178
183
  logger: shared.Logger;
179
- /** Closes the transport, the pooled SMTP transport closes its connections */
180
- close: () => void;
184
+ /**
185
+ * Closes the transport, the pooled SMTP transport closes its connections. With `force` the
186
+ * pooled transport also closes connections that are delivering a message
187
+ */
188
+ close: (options?: {
189
+ force?: boolean;
190
+ }) => void;
181
191
  /** Tells whether the transport can take a message right away */
182
192
  isIdle: () => boolean;
183
193
  /** Checks the configuration, the SMTP transports connect and authenticate for it */