@mavogel/awscdk-rootmail 0.1.4 → 0.1.5

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 (179) hide show
  1. package/.jsii +2 -2
  2. package/lib/rootmail.js +1 -1
  3. package/lib/ses-receive.js +1 -1
  4. package/node_modules/@aws-sdk/checksums/package.json +2 -2
  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 +3 -3
  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 +3 -3
  9. package/node_modules/@aws-sdk/client-s3/dist-cjs/index.js +38 -15
  10. package/node_modules/@aws-sdk/client-s3/dist-es/models/enums.js +7 -0
  11. package/node_modules/@aws-sdk/client-s3/dist-es/schemas/schemas_0.js +28 -14
  12. package/node_modules/@aws-sdk/client-s3/dist-types/commands/CopyObjectCommand.d.ts +3 -0
  13. package/node_modules/@aws-sdk/client-s3/dist-types/commands/CreateMultipartUploadCommand.d.ts +3 -0
  14. package/node_modules/@aws-sdk/client-s3/dist-types/commands/GetBucketInventoryConfigurationCommand.d.ts +1 -1
  15. package/node_modules/@aws-sdk/client-s3/dist-types/commands/GetBucketNotificationConfigurationCommand.d.ts +3 -3
  16. package/node_modules/@aws-sdk/client-s3/dist-types/commands/GetObjectCommand.d.ts +3 -0
  17. package/node_modules/@aws-sdk/client-s3/dist-types/commands/GetObjectLockConfigurationCommand.d.ts +4 -0
  18. package/node_modules/@aws-sdk/client-s3/dist-types/commands/GetObjectRetentionCommand.d.ts +5 -0
  19. package/node_modules/@aws-sdk/client-s3/dist-types/commands/HeadObjectCommand.d.ts +3 -0
  20. package/node_modules/@aws-sdk/client-s3/dist-types/commands/ListBucketInventoryConfigurationsCommand.d.ts +1 -1
  21. package/node_modules/@aws-sdk/client-s3/dist-types/commands/PutBucketInventoryConfigurationCommand.d.ts +1 -1
  22. package/node_modules/@aws-sdk/client-s3/dist-types/commands/PutBucketNotificationConfigurationCommand.d.ts +3 -3
  23. package/node_modules/@aws-sdk/client-s3/dist-types/commands/PutObjectCommand.d.ts +3 -0
  24. package/node_modules/@aws-sdk/client-s3/dist-types/commands/PutObjectLockConfigurationCommand.d.ts +4 -0
  25. package/node_modules/@aws-sdk/client-s3/dist-types/commands/PutObjectRetentionCommand.d.ts +5 -0
  26. package/node_modules/@aws-sdk/client-s3/dist-types/commands/PutPublicAccessBlockCommand.d.ts +1 -1
  27. package/node_modules/@aws-sdk/client-s3/dist-types/models/enums.d.ts +15 -0
  28. package/node_modules/@aws-sdk/client-s3/dist-types/models/models_0.d.ts +186 -49
  29. package/node_modules/@aws-sdk/client-s3/dist-types/models/models_1.d.ts +43 -1
  30. package/node_modules/@aws-sdk/client-s3/dist-types/schemas/schemas_0.d.ts +1 -0
  31. package/node_modules/@aws-sdk/client-s3/dist-types/ts3.4/commands/PutPublicAccessBlockCommand.d.ts +1 -1
  32. package/node_modules/@aws-sdk/client-s3/dist-types/ts3.4/models/enums.d.ts +8 -0
  33. package/node_modules/@aws-sdk/client-s3/dist-types/ts3.4/models/models_0.d.ts +23 -7
  34. package/node_modules/@aws-sdk/client-s3/dist-types/ts3.4/models/models_1.d.ts +14 -1
  35. package/node_modules/@aws-sdk/client-s3/dist-types/ts3.4/schemas/schemas_0.d.ts +1 -0
  36. package/node_modules/@aws-sdk/client-s3/package.json +6 -6
  37. package/node_modules/@aws-sdk/client-ses/dist-cjs/index.js +1 -1
  38. package/node_modules/@aws-sdk/client-ses/package.json +3 -3
  39. package/node_modules/@aws-sdk/client-ssm/dist-cjs/index.js +1 -1
  40. package/node_modules/@aws-sdk/client-ssm/package.json +3 -3
  41. package/node_modules/@aws-sdk/core/dist-cjs/submodules/util/index.js +5 -0
  42. package/node_modules/@aws-sdk/core/dist-es/submodules/util/hasOwn.js +3 -0
  43. package/node_modules/@aws-sdk/core/dist-es/submodules/util/index.js +1 -0
  44. package/node_modules/@aws-sdk/core/dist-types/submodules/util/hasOwn.d.ts +4 -0
  45. package/node_modules/@aws-sdk/core/dist-types/submodules/util/index.d.ts +1 -0
  46. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/util/hasOwn.d.ts +1 -0
  47. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/util/index.d.ts +1 -0
  48. package/node_modules/@aws-sdk/core/package.json +1 -1
  49. package/node_modules/@aws-sdk/credential-provider-env/package.json +2 -2
  50. package/node_modules/@aws-sdk/credential-provider-http/package.json +2 -2
  51. package/node_modules/@aws-sdk/credential-provider-ini/package.json +9 -9
  52. package/node_modules/@aws-sdk/credential-provider-login/package.json +3 -3
  53. package/node_modules/@aws-sdk/credential-provider-node/package.json +7 -7
  54. package/node_modules/@aws-sdk/credential-provider-process/package.json +2 -2
  55. package/node_modules/@aws-sdk/credential-provider-sso/package.json +4 -4
  56. package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +3 -3
  57. package/node_modules/@aws-sdk/middleware-sdk-s3/package.json +2 -2
  58. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/cognito-identity/index.js +1 -1
  59. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/signin/index.js +1 -1
  60. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso/index.js +1 -1
  61. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/index.js +1 -1
  62. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/index.js +1 -1
  63. package/node_modules/@aws-sdk/nested-clients/package.json +2 -2
  64. package/node_modules/@aws-sdk/token-providers/package.json +3 -3
  65. package/node_modules/mailparser/.release-please-manifest.json +1 -1
  66. package/node_modules/mailparser/CHANGELOG.md +28 -0
  67. package/node_modules/mailparser/package.json +2 -2
  68. package/node_modules/nodemailer/CHANGELOG.md +74 -0
  69. package/node_modules/nodemailer/dist/cjs/addressparser/index.d.ts +1 -3
  70. package/node_modules/nodemailer/dist/cjs/addressparser/index.js +176 -13
  71. package/node_modules/nodemailer/dist/cjs/base64/index.d.ts +2 -6
  72. package/node_modules/nodemailer/dist/cjs/base64/index.js +2 -0
  73. package/node_modules/nodemailer/dist/cjs/dkim/index.d.ts +4 -4
  74. package/node_modules/nodemailer/dist/cjs/dkim/message-parser.d.ts +1 -3
  75. package/node_modules/nodemailer/dist/cjs/dkim/message-parser.js +2 -0
  76. package/node_modules/nodemailer/dist/cjs/dkim/relaxed-body.d.ts +3 -22
  77. package/node_modules/nodemailer/dist/cjs/dkim/relaxed-body.js +5 -0
  78. package/node_modules/nodemailer/dist/cjs/dkim/sign.d.ts +5 -5
  79. package/node_modules/nodemailer/dist/cjs/errors.d.ts +8 -8
  80. package/node_modules/nodemailer/dist/cjs/fetch/cookies.d.ts +12 -10
  81. package/node_modules/nodemailer/dist/cjs/fetch/cookies.js +28 -14
  82. package/node_modules/nodemailer/dist/cjs/fetch/index.d.ts +15 -15
  83. package/node_modules/nodemailer/dist/cjs/json-transport/index.d.ts +2 -2
  84. package/node_modules/nodemailer/dist/cjs/mail-composer/index.d.ts +49 -104
  85. package/node_modules/nodemailer/dist/cjs/mail-composer/index.js +11 -2
  86. package/node_modules/nodemailer/dist/cjs/mailer/index.d.ts +21 -28
  87. package/node_modules/nodemailer/dist/cjs/mailer/index.js +19 -5
  88. package/node_modules/nodemailer/dist/cjs/mailer/mail-message.d.ts +8 -12
  89. package/node_modules/nodemailer/dist/cjs/mailer/mail-message.js +2 -0
  90. package/node_modules/nodemailer/dist/cjs/mime-funcs/index.d.ts +1 -1
  91. package/node_modules/nodemailer/dist/cjs/mime-funcs/index.js +4 -1
  92. package/node_modules/nodemailer/dist/cjs/mime-node/index.d.ts +37 -191
  93. package/node_modules/nodemailer/dist/cjs/mime-node/index.js +82 -12
  94. package/node_modules/nodemailer/dist/cjs/mime-node/last-newline.d.ts +1 -3
  95. package/node_modules/nodemailer/dist/cjs/mime-node/last-newline.js +2 -0
  96. package/node_modules/nodemailer/dist/cjs/mime-node/le-unix.d.ts +1 -5
  97. package/node_modules/nodemailer/dist/cjs/mime-node/le-unix.js +1 -0
  98. package/node_modules/nodemailer/dist/cjs/mime-node/le-windows.d.ts +1 -5
  99. package/node_modules/nodemailer/dist/cjs/mime-node/le-windows.js +1 -0
  100. package/node_modules/nodemailer/dist/cjs/nodemailer.d.ts +2 -2
  101. package/node_modules/nodemailer/dist/cjs/package-info.d.ts +1 -1
  102. package/node_modules/nodemailer/dist/cjs/package-info.js +1 -1
  103. package/node_modules/nodemailer/dist/cjs/qp/index.d.ts +2 -5
  104. package/node_modules/nodemailer/dist/cjs/qp/index.js +2 -0
  105. package/node_modules/nodemailer/dist/cjs/sendmail-transport/index.d.ts +4 -6
  106. package/node_modules/nodemailer/dist/cjs/ses-transport/index.d.ts +2 -2
  107. package/node_modules/nodemailer/dist/cjs/ses-transport/index.js +5 -1
  108. package/node_modules/nodemailer/dist/cjs/shared/index.d.ts +31 -37
  109. package/node_modules/nodemailer/dist/cjs/shared/index.js +19 -7
  110. package/node_modules/nodemailer/dist/cjs/smtp-connection/data-stream.d.ts +1 -9
  111. package/node_modules/nodemailer/dist/cjs/smtp-connection/data-stream.js +2 -0
  112. package/node_modules/nodemailer/dist/cjs/smtp-connection/http-proxy-client.d.ts +1 -1
  113. package/node_modules/nodemailer/dist/cjs/smtp-connection/index.d.ts +62 -403
  114. package/node_modules/nodemailer/dist/cjs/smtp-connection/index.js +37 -1
  115. package/node_modules/nodemailer/dist/cjs/smtp-pool/index.d.ts +8 -46
  116. package/node_modules/nodemailer/dist/cjs/smtp-pool/index.js +13 -2
  117. package/node_modules/nodemailer/dist/cjs/smtp-pool/pool-resource.d.ts +2 -4
  118. package/node_modules/nodemailer/dist/cjs/smtp-transport/index.d.ts +16 -16
  119. package/node_modules/nodemailer/dist/cjs/stream-transport/index.d.ts +3 -3
  120. package/node_modules/nodemailer/dist/cjs/well-known/index.d.ts +9 -9
  121. package/node_modules/nodemailer/dist/cjs/well-known/services.js +2 -0
  122. package/node_modules/nodemailer/dist/cjs/xoauth2/index.d.ts +18 -18
  123. package/node_modules/nodemailer/dist/esm/addressparser/index.d.ts +1 -3
  124. package/node_modules/nodemailer/dist/esm/addressparser/index.js +176 -13
  125. package/node_modules/nodemailer/dist/esm/base64/index.d.ts +2 -6
  126. package/node_modules/nodemailer/dist/esm/base64/index.js +2 -0
  127. package/node_modules/nodemailer/dist/esm/dkim/index.d.ts +4 -4
  128. package/node_modules/nodemailer/dist/esm/dkim/message-parser.d.ts +1 -3
  129. package/node_modules/nodemailer/dist/esm/dkim/message-parser.js +2 -0
  130. package/node_modules/nodemailer/dist/esm/dkim/relaxed-body.d.ts +3 -22
  131. package/node_modules/nodemailer/dist/esm/dkim/relaxed-body.js +5 -0
  132. package/node_modules/nodemailer/dist/esm/dkim/sign.d.ts +5 -5
  133. package/node_modules/nodemailer/dist/esm/errors.d.ts +8 -8
  134. package/node_modules/nodemailer/dist/esm/fetch/cookies.d.ts +12 -10
  135. package/node_modules/nodemailer/dist/esm/fetch/cookies.js +25 -14
  136. package/node_modules/nodemailer/dist/esm/fetch/index.d.ts +15 -15
  137. package/node_modules/nodemailer/dist/esm/json-transport/index.d.ts +2 -2
  138. package/node_modules/nodemailer/dist/esm/mail-composer/index.d.ts +49 -104
  139. package/node_modules/nodemailer/dist/esm/mail-composer/index.js +11 -2
  140. package/node_modules/nodemailer/dist/esm/mailer/index.d.ts +21 -28
  141. package/node_modules/nodemailer/dist/esm/mailer/index.js +19 -5
  142. package/node_modules/nodemailer/dist/esm/mailer/mail-message.d.ts +8 -12
  143. package/node_modules/nodemailer/dist/esm/mailer/mail-message.js +2 -0
  144. package/node_modules/nodemailer/dist/esm/mime-funcs/index.d.ts +1 -1
  145. package/node_modules/nodemailer/dist/esm/mime-funcs/index.js +4 -1
  146. package/node_modules/nodemailer/dist/esm/mime-node/index.d.ts +37 -191
  147. package/node_modules/nodemailer/dist/esm/mime-node/index.js +82 -12
  148. package/node_modules/nodemailer/dist/esm/mime-node/last-newline.d.ts +1 -3
  149. package/node_modules/nodemailer/dist/esm/mime-node/last-newline.js +2 -0
  150. package/node_modules/nodemailer/dist/esm/mime-node/le-unix.d.ts +1 -5
  151. package/node_modules/nodemailer/dist/esm/mime-node/le-unix.js +1 -0
  152. package/node_modules/nodemailer/dist/esm/mime-node/le-windows.d.ts +1 -5
  153. package/node_modules/nodemailer/dist/esm/mime-node/le-windows.js +1 -0
  154. package/node_modules/nodemailer/dist/esm/nodemailer.d.ts +2 -2
  155. package/node_modules/nodemailer/dist/esm/package-info.d.ts +1 -1
  156. package/node_modules/nodemailer/dist/esm/package-info.js +1 -1
  157. package/node_modules/nodemailer/dist/esm/qp/index.d.ts +2 -5
  158. package/node_modules/nodemailer/dist/esm/qp/index.js +2 -0
  159. package/node_modules/nodemailer/dist/esm/sendmail-transport/index.d.ts +4 -6
  160. package/node_modules/nodemailer/dist/esm/ses-transport/index.d.ts +2 -2
  161. package/node_modules/nodemailer/dist/esm/ses-transport/index.js +5 -1
  162. package/node_modules/nodemailer/dist/esm/shared/index.d.ts +31 -37
  163. package/node_modules/nodemailer/dist/esm/shared/index.js +19 -7
  164. package/node_modules/nodemailer/dist/esm/smtp-connection/data-stream.d.ts +1 -9
  165. package/node_modules/nodemailer/dist/esm/smtp-connection/data-stream.js +2 -0
  166. package/node_modules/nodemailer/dist/esm/smtp-connection/http-proxy-client.d.ts +1 -1
  167. package/node_modules/nodemailer/dist/esm/smtp-connection/index.d.ts +62 -403
  168. package/node_modules/nodemailer/dist/esm/smtp-connection/index.js +37 -1
  169. package/node_modules/nodemailer/dist/esm/smtp-pool/index.d.ts +8 -46
  170. package/node_modules/nodemailer/dist/esm/smtp-pool/index.js +13 -2
  171. package/node_modules/nodemailer/dist/esm/smtp-pool/pool-resource.d.ts +2 -4
  172. package/node_modules/nodemailer/dist/esm/smtp-transport/index.d.ts +16 -16
  173. package/node_modules/nodemailer/dist/esm/stream-transport/index.d.ts +3 -3
  174. package/node_modules/nodemailer/dist/esm/well-known/index.d.ts +9 -9
  175. package/node_modules/nodemailer/dist/esm/well-known/services.js +2 -0
  176. package/node_modules/nodemailer/dist/esm/xoauth2/index.d.ts +18 -18
  177. package/node_modules/nodemailer/dist/well-known/services.json +2 -2
  178. package/node_modules/nodemailer/package.json +6 -6
  179. package/package.json +1 -1
@@ -3,9 +3,7 @@
3
3
  */
4
4
  export interface AddressParserOptions {
5
5
  /** Flatten groups into a single list of mailboxes */
6
- flatten?: boolean;
7
- /** Internal recursion depth counter (do not set manually) */
8
- _depth?: number;
6
+ flatten?: boolean | undefined;
9
7
  }
10
8
  /**
11
9
  * A single mailbox. Either value may be an empty string when the input did not carry it
@@ -47,6 +47,134 @@ const ADDR_SPEC = /^[^@\s]+@[^@\s]+$/;
47
47
  * further '@' that a domain should not have but malformed headers carry anyway.
48
48
  */
49
49
  const LOOSE_ADDR_SPEC = /^[^@\s]+@\S+$/;
50
+ /**
51
+ * An addr-spec sitting inside free text, together with the whitespace around it. Sticky
52
+ * on purpose: it is run at the one offset _looseAddressStart picks rather than being let
53
+ * loose to search, see there.
54
+ */
55
+ const LOOSE_TEXT_ADDR = /\s*\b[^@\s]+@[^\s]+\b\s*/y;
56
+ /**
57
+ * The characters JS `\s` matches, which the scan below has to agree with to land on the
58
+ * same match the pattern would.
59
+ */
60
+ function _isSpaceCode(code) {
61
+ return (code === 0x20 ||
62
+ (code >= 0x09 && code <= 0x0d) ||
63
+ code === 0xa0 ||
64
+ code === 0x1680 ||
65
+ (code >= 0x2000 && code <= 0x200a) ||
66
+ code === 0x2028 ||
67
+ code === 0x2029 ||
68
+ code === 0x202f ||
69
+ code === 0x205f ||
70
+ code === 0x3000 ||
71
+ code === 0xfeff);
72
+ }
73
+ /**
74
+ * The characters JS `\w` matches without the unicode flag, the set the `\b` in
75
+ * LOOSE_TEXT_ADDR is read against. charCodeAt off either end of the string gives NaN,
76
+ * which compares false throughout, so out of range reads as the non-word the pattern
77
+ * treats them as.
78
+ */
79
+ function _isWordCode(code) {
80
+ return (code >= 0x30 && code <= 0x39) || (code >= 0x41 && code <= 0x5a) || (code >= 0x61 && code <= 0x7a) || code === 0x5f;
81
+ }
82
+ /**
83
+ * Whether `\b` holds at an offset
84
+ */
85
+ function _isBoundary(text, at) {
86
+ return _isWordCode(text.charCodeAt(at - 1)) !== _isWordCode(text.charCodeAt(at));
87
+ }
88
+ /**
89
+ * Offset of the first '@' in `text` between `from` and `to`, or -1 when the range holds none.
90
+ *
91
+ * indexOf would scan on to the end of the value, and the value here is a whole header. The
92
+ * walk below steps one whitespace delimited run at a time and only ever uses a '@' that sits
93
+ * inside the run it is on, so an unbounded probe rescans everything behind that run once per
94
+ * run and grows with the square of the header: 400KB of free text carrying no '@' took a
95
+ * quarter of a second. GHSA-v53p-9fqp-m79j took the pattern search out of this walk and left
96
+ * the probe unbounded behind it.
97
+ *
98
+ * @param text Text to look in
99
+ * @param from Offset to start at
100
+ * @param to Offset to stop before
101
+ * @return Offset of the '@', or -1
102
+ */
103
+ function _indexOfAt(text, from, to) {
104
+ for (let i = from; i < to; i++) {
105
+ if (text.charCodeAt(i) === 0x40) {
106
+ return i;
107
+ }
108
+ }
109
+ return -1;
110
+ }
111
+ /**
112
+ * Finds the offset LOOSE_TEXT_ADDR matches at, or -1 when it does not match at all.
113
+ *
114
+ * Letting the pattern search for itself is quadratic: '[^@\s]+' is retried from every
115
+ * offset and rescans the run to the next '@' each time, so 140KB of header holding no
116
+ * usable '@' blocks the event loop for about ten seconds (GHSA-v53p-9fqp-m79j). The search is also unnecessary.
117
+ * '[^@\s]+' crosses neither whitespace nor a '@', so a match can only begin at the head of
118
+ * a whitespace delimited run or just past a '@' inside one, and '[^\s]+\b' gives characters
119
+ * back until it lands on a boundary, so the only end it can take in that run is the last
120
+ * boundary in it. Both are found in one pass, and the pattern is then run at that single
121
+ * offset.
122
+ *
123
+ * @param text Free text to look in
124
+ * @return Offset to match at, or -1
125
+ */
126
+ function _looseAddressStart(text) {
127
+ const len = text.length;
128
+ let pos = 0;
129
+ while (pos < len) {
130
+ while (pos < len && _isSpaceCode(text.charCodeAt(pos))) {
131
+ pos++;
132
+ }
133
+ if (pos >= len) {
134
+ break;
135
+ }
136
+ const runStart = pos;
137
+ let runEnd = pos;
138
+ while (runEnd < len && !_isSpaceCode(text.charCodeAt(runEnd))) {
139
+ runEnd++;
140
+ }
141
+ let at = _indexOfAt(text, runStart, runEnd);
142
+ if (at >= 0) {
143
+ let lastBoundary = -1;
144
+ for (let k = runEnd; k > runStart; k--) {
145
+ if (_isBoundary(text, k)) {
146
+ lastBoundary = k;
147
+ break;
148
+ }
149
+ }
150
+ let atomStart = runStart;
151
+ while (lastBoundary >= 0 && at >= 0) {
152
+ // '[^@\s]+' has to cover a character before the '@' and '[^\s]+' one after it,
153
+ // and the boundary that ends the match has to sit past both
154
+ if (at > atomStart && runEnd > at + 1 && lastBoundary > at + 1) {
155
+ for (let start = atomStart; start < at; start++) {
156
+ if (_isBoundary(text, start)) {
157
+ if (start > runStart) {
158
+ return start;
159
+ }
160
+ // the leading '\s*' is greedy, so a match that begins at the run
161
+ // takes the whitespace in front of it along
162
+ let padded = runStart;
163
+ while (padded > 0 && _isSpaceCode(text.charCodeAt(padded - 1))) {
164
+ padded--;
165
+ }
166
+ return padded;
167
+ }
168
+ }
169
+ }
170
+ atomStart = at + 1;
171
+ at = _indexOfAt(text, atomStart, runEnd);
172
+ }
173
+ }
174
+ pos = runEnd;
175
+ }
176
+ return -1;
177
+ }
50
178
  /**
51
179
  * Recovers the addr-spec from an angle-addr that came back holding unquoted whitespace.
52
180
  *
@@ -131,6 +259,12 @@ function _handleAddress(tokens, depth) {
131
259
  textWasQuoted: []
132
260
  };
133
261
  let insideQuotes = false;
262
+ // Last character of the run each state is currently accumulating. Reading it back off
263
+ // the accumulator with slice(-1) makes the engine flatten the whole growing string on
264
+ // every token, which is quadratic over an address built from many comment-joined atoms
265
+ // (GHSA-prgh-xp8r-p3m5). A run only ever grows by the token appended below, so the
266
+ // character is carried along instead of re-read.
267
+ const lastChars = { address: '', comment: '', group: '', text: '' };
134
268
  // Filter out <addresses>, (comments) and regular text
135
269
  for (let i = 0, len = tokens.length; i < len; i++) {
136
270
  const token = tokens[i];
@@ -161,6 +295,19 @@ function _handleAddress(tokens, depth) {
161
295
  }
162
296
  }
163
297
  else if (token.value) {
298
+ // An empty quoted string is dropped by the tokenizer, leaving no text token of its
299
+ // own for textWasQuoted to be recorded on, so the pair of quote operators right in
300
+ // front of this token is all that is left of it and the run it opens carries the
301
+ // quoting instead. Without this '""@example.com' reads as the bare '@example.com',
302
+ // the quotes never go back on, and the value is no longer an addr-spec a trailing
303
+ // comment can be peeled off of. It only ever opens a run: a run that already holds
304
+ // material collected outside the quotes is not a quoted string, whatever follows it
305
+ const prevPrevToken = i > 1 ? tokens[i - 2] : null;
306
+ const opensAfterEmptyQuotedString = prevToken?.type === 'operator' &&
307
+ prevToken.value === '"' &&
308
+ !!prevToken.noBreak &&
309
+ prevPrevToken?.type === 'operator' &&
310
+ prevPrevToken.value === '"';
164
311
  if (state === 'address') {
165
312
  // Handle unquoted name that includes a "<".
166
313
  // Apple Mail truncates everything between an unexpected < and an address.
@@ -174,17 +321,21 @@ function _handleAddress(tokens, depth) {
174
321
  const joins = prevToken &&
175
322
  prevToken.noBreak &&
176
323
  parts.length &&
177
- (prevToken.value !== ')' || parts[parts.length - 1].slice(-1) === '@' || token.value.charAt(0) === '@');
324
+ (prevToken.value !== ')' || lastChars[state] === '@' || token.value.charAt(0) === '@');
178
325
  if (joins) {
179
326
  data[state][data[state].length - 1] += token.value;
327
+ if (token.value) {
328
+ lastChars[state] = token.value.charAt(token.value.length - 1);
329
+ }
180
330
  if (state === 'text' && insideQuotes) {
181
331
  data.textWasQuoted[data.textWasQuoted.length - 1] = true;
182
332
  }
183
333
  }
184
334
  else {
185
335
  data[state].push(token.value);
336
+ lastChars[state] = token.value.charAt(token.value.length - 1);
186
337
  if (state === 'text') {
187
- data.textWasQuoted.push(insideQuotes);
338
+ data.textWasQuoted.push(insideQuotes || opensAfterEmptyQuotedString);
188
339
  }
189
340
  }
190
341
  }
@@ -234,16 +385,19 @@ function _handleAddress(tokens, depth) {
234
385
  for (let i = data.text.length - 1; i >= 0; i--) {
235
386
  // Security: Do not extract email addresses from quoted strings
236
387
  if (!data.textWasQuoted[i]) {
237
- data.text[i] = data.text[i]
238
- .replace(/\s*\b[^@\s]+@[^\s]+\b\s*/, (match) => {
239
- if (!extracted) {
240
- data.address = [match.trim()];
388
+ const part = data.text[i];
389
+ let remainder = part;
390
+ const at = _looseAddressStart(part);
391
+ if (at >= 0) {
392
+ LOOSE_TEXT_ADDR.lastIndex = at;
393
+ const match = LOOSE_TEXT_ADDR.exec(part);
394
+ if (match) {
395
+ data.address = [match[0].trim()];
241
396
  extracted = true;
242
- return ' ';
397
+ remainder = part.slice(0, at) + ' ' + part.slice(at + match[0].length);
243
398
  }
244
- return match;
245
- })
246
- .trim();
399
+ }
400
+ data.text[i] = remainder.trim();
247
401
  if (extracted) {
248
402
  break;
249
403
  }
@@ -266,6 +420,18 @@ function _handleAddress(tokens, depth) {
266
420
  // Join values with spaces
267
421
  data.text = data.text.join(' ');
268
422
  data.address = data.address.join(' ');
423
+ if (addressFromQuotedText && data.text) {
424
+ // The mailbox is still sitting in the text, so it moves over here and is quoted
425
+ // before the recovery below rather than after it. Anything else the text holds
426
+ // came along with it: a comment ends the domain but leaves the atoms behind it in
427
+ // the same text, and '"user"@example.com(x)evil.com' was handed on as the address
428
+ // 'user@example.com evil.com', a second domain riding into the envelope recipient
429
+ // on a value that is no addr-spec at all (GHSA-g57g-f23g-4646). Putting the quotes
430
+ // back first is what lets the recovery tell the whitespace an addr-spec may carry
431
+ // from the wreckage trailing one, as only a quoted local part may hold whitespace
432
+ data.address = _quoteLocalPart(data.text);
433
+ data.text = '';
434
+ }
269
435
  _recoverAddrSpec(data);
270
436
  const address = {
271
437
  address: data.address || data.text || '',
@@ -279,9 +445,6 @@ function _handleAddress(tokens, depth) {
279
445
  address.address = '';
280
446
  }
281
447
  }
282
- if (addressFromQuotedText && address.address) {
283
- address.address = _quoteLocalPart(address.address);
284
- }
285
448
  addresses.push(address);
286
449
  }
287
450
  return addresses;
@@ -1,4 +1,4 @@
1
- import { Transform, type TransformCallback } from 'node:stream';
1
+ import { Transform } from 'node:stream';
2
2
  /**
3
3
  * Encodes a Buffer into a base64 encoded string
4
4
  *
@@ -19,7 +19,7 @@ export declare function wrap(str: string, lineLength?: number | false): string;
19
19
  */
20
20
  export interface EncoderOptions {
21
21
  /** Maximum length for lines, set to false to disable wrapping */
22
- lineLength?: number | false;
22
+ lineLength?: number | false | undefined;
23
23
  }
24
24
  /**
25
25
  * Creates a transform stream for encoding data to base64 encoding
@@ -32,9 +32,5 @@ export declare class Encoder extends Transform {
32
32
  options: EncoderOptions;
33
33
  inputBytes: number;
34
34
  outputBytes: number;
35
- _curLine: string;
36
- _remainingBytes: Buffer | false;
37
35
  constructor(options?: EncoderOptions);
38
- _transform(chunk: Buffer | string, encoding: BufferEncoding | 'buffer', done: TransformCallback): void;
39
- _flush(done: TransformCallback): void;
40
36
  }
@@ -54,6 +54,7 @@ export class Encoder extends Transform {
54
54
  this.inputBytes = 0;
55
55
  this.outputBytes = 0;
56
56
  }
57
+ /** @internal */
57
58
  _transform(chunk, encoding, done) {
58
59
  let buf = encoding !== 'buffer' ? Buffer.from(chunk, encoding) : chunk;
59
60
  if (!buf || !buf.length) {
@@ -95,6 +96,7 @@ export class Encoder extends Transform {
95
96
  }
96
97
  setImmediate(done);
97
98
  }
99
+ /** @internal */
98
100
  _flush(done) {
99
101
  if (this._remainingBytes && this._remainingBytes.length) {
100
102
  this._curLine += encode(this._remainingBytes);
@@ -9,13 +9,13 @@ export type { DKIMKey, DKIMPrivateKey, DKIMSignOptions };
9
9
  */
10
10
  export interface DKIMOptions extends DKIMSignOptions {
11
11
  /** One or more signing keys, used instead of the domainName, keySelector and privateKey options */
12
- keys?: DKIMKey | DKIMKey[];
12
+ keys?: DKIMKey | DKIMKey[] | undefined;
13
13
  /** Directory for buffering large message bodies to disk, no buffering when not set */
14
- cacheDir?: string | false;
14
+ cacheDir?: string | false | undefined;
15
15
  /** Body size in bytes from which the body is buffered to cacheDir, defaults to 10 MB */
16
- cacheTreshold?: number;
16
+ cacheTreshold?: number | undefined;
17
17
  /** Hash algorithm for the body hash and the signature, defaults to sha256 */
18
- hashAlgo?: string;
18
+ hashAlgo?: string | undefined;
19
19
  }
20
20
  /**
21
21
  * The signed message as returned by DKIM#sign
@@ -1,4 +1,4 @@
1
- import { Transform, type TransformCallback, type TransformOptions } from 'node:stream';
1
+ import { Transform, type TransformOptions } from 'node:stream';
2
2
  /**
3
3
  * A header line as emitted with the 'headers' event
4
4
  */
@@ -35,7 +35,5 @@ export default class MessageParser extends Transform {
35
35
  * @return Returns true if headers are already found or false otherwise
36
36
  */
37
37
  checkHeaders(data: Buffer): boolean;
38
- _transform(chunk: Buffer | string, encoding: BufferEncoding, callback: TransformCallback): void;
39
- _flush(callback: TransformCallback): void;
40
38
  parseHeaders(): MessageParserHeaderLine[];
41
39
  }
@@ -88,6 +88,7 @@ export default class MessageParser extends Transform {
88
88
  this.updateLastBytes(data);
89
89
  return false;
90
90
  }
91
+ /** @internal */
91
92
  _transform(chunk, encoding, callback) {
92
93
  if (!chunk || !chunk.length) {
93
94
  return callback();
@@ -108,6 +109,7 @@ export default class MessageParser extends Transform {
108
109
  }
109
110
  setImmediate(callback);
110
111
  }
112
+ /** @internal */
111
113
  _flush(callback) {
112
114
  if (this.headerChunks) {
113
115
  // no empty line was seen, so the message consists of headers only
@@ -1,13 +1,13 @@
1
- import { Transform, type TransformCallback } from 'node:stream';
1
+ import { Transform } from 'node:stream';
2
2
  import crypto from 'node:crypto';
3
3
  /**
4
4
  * Options for the relaxed body hash stream
5
5
  */
6
6
  export interface RelaxedBodyOptions {
7
7
  /** Hash algorithm for the body hash, defaults to sha256 */
8
- hashAlgo?: string;
8
+ hashAlgo?: string | undefined;
9
9
  /** Collect the canonicalized body and emit it with the 'hash' event */
10
- debug?: boolean;
10
+ debug?: boolean | undefined;
11
11
  }
12
12
  /**
13
13
  * Passes the message body through unchanged and hashes its relaxed
@@ -22,25 +22,6 @@ export default class RelaxedBody extends Transform {
22
22
  /** Bytes of the original body seen so far */
23
23
  byteLength: number;
24
24
  debug: boolean | undefined;
25
- _debugBody: Buffer[] | false;
26
- /** The current line has bytes that survive canonicalization */
27
- _lineHasContent: boolean;
28
- /** Whitespace that ends up as a single space if more content follows on the line */
29
- _pendingWsp: boolean;
30
- /** A CR that is part of the line ending if LF follows, otherwise content */
31
- _pendingCr: boolean;
32
- /** Empty lines that are hashed only once a non-empty line follows them */
33
- _pendingEmptyLines: number;
34
25
  constructor(options?: RelaxedBodyOptions);
35
- _hashCanonical(data: Buffer): void;
36
- _hashEmptyLines(): void;
37
- /**
38
- * Writes a content byte, with the space a pending run of whitespace collapses to,
39
- * into the output buffer and returns the new write position. Kept a method rather
40
- * than a closure so the write position stays a plain local in the byte loop
41
- */
42
- _emitContent(out: Buffer, outPos: number, c: number): number;
43
26
  updateHash(chunk: Buffer, final?: boolean): void;
44
- _transform(chunk: Buffer | string, encoding: BufferEncoding, callback: TransformCallback): void;
45
- _flush(callback: TransformCallback): void;
46
27
  }
@@ -29,6 +29,7 @@ export default class RelaxedBody extends Transform {
29
29
  this._pendingCr = false;
30
30
  this._pendingEmptyLines = 0;
31
31
  }
32
+ /** @internal */
32
33
  _hashCanonical(data) {
33
34
  if (!data.length) {
34
35
  return;
@@ -38,6 +39,7 @@ export default class RelaxedBody extends Transform {
38
39
  this._debugBody.push(Buffer.from(data));
39
40
  }
40
41
  }
42
+ /** @internal */
41
43
  _hashEmptyLines() {
42
44
  while (this._pendingEmptyLines > 0) {
43
45
  const count = Math.min(this._pendingEmptyLines, EMPTY_LINES.length / 2);
@@ -49,6 +51,7 @@ export default class RelaxedBody extends Transform {
49
51
  * Writes a content byte, with the space a pending run of whitespace collapses to,
50
52
  * into the output buffer and returns the new write position. Kept a method rather
51
53
  * than a closure so the write position stays a plain local in the byte loop
54
+ * @internal
52
55
  */
53
56
  _emitContent(out, outPos, c) {
54
57
  if (!this._lineHasContent) {
@@ -111,6 +114,7 @@ export default class RelaxedBody extends Transform {
111
114
  }
112
115
  this._hashCanonical(out.subarray(0, outPos));
113
116
  }
117
+ /** @internal */
114
118
  _transform(chunk, encoding, callback) {
115
119
  if (!chunk || !chunk.length) {
116
120
  return callback();
@@ -123,6 +127,7 @@ export default class RelaxedBody extends Transform {
123
127
  this.push(chunk);
124
128
  callback();
125
129
  }
130
+ /** @internal */
126
131
  _flush(callback) {
127
132
  this.updateHash(Buffer.alloc(0), true);
128
133
  if (this._lineHasContent) {
@@ -10,17 +10,17 @@ export type DKIMPrivateKey = crypto.KeyLike | crypto.SignKeyObjectInput | crypto
10
10
  */
11
11
  export interface DKIMKey {
12
12
  /** Domain name to be signed for */
13
- domainName?: string;
13
+ domainName?: string | undefined;
14
14
  /** DKIM key selector to use */
15
- keySelector?: string;
15
+ keySelector?: string | undefined;
16
16
  /** DKIM private key to use */
17
- privateKey?: DKIMPrivateKey;
17
+ privateKey?: DKIMPrivateKey | undefined;
18
18
  }
19
19
  export interface DKIMSignOptions extends DKIMKey {
20
20
  /** Colon separated list of header field names to sign, defaults to the RFC4871 list */
21
- headerFieldNames?: string;
21
+ headerFieldNames?: string | undefined;
22
22
  /** Colon separated list of header field names to leave out of the signature */
23
- skipFields?: string;
23
+ skipFields?: string | undefined;
24
24
  }
25
25
  /**
26
26
  * Canonicalized headers and the list of field names that went into them
@@ -68,21 +68,21 @@ export declare const EFETCH = "EFETCH";
68
68
  */
69
69
  export interface NodemailerError extends Error {
70
70
  /** Nodemailer error code, see ERROR_CODES */
71
- code?: string;
71
+ code?: string | undefined;
72
72
  /** SMTP command that was in flight when the server replied with an error */
73
- command?: string;
73
+ command?: string | undefined;
74
74
  /** Raw SMTP server response */
75
- response?: string;
75
+ response?: string | undefined;
76
76
  /** Numeric SMTP response code */
77
- responseCode?: number;
77
+ responseCode?: number | undefined;
78
78
  /** URL of the resource that could not be fetched */
79
- sourceUrl?: string;
79
+ sourceUrl?: string | undefined;
80
80
  /** Recipient address the error applies to */
81
- recipient?: string;
81
+ recipient?: string | undefined;
82
82
  /** Recipient addresses rejected by the server */
83
- rejected?: string[];
83
+ rejected?: string[] | undefined;
84
84
  /** Per-recipient errors for the rejected addresses */
85
- rejectedErrors?: NodemailerError[];
85
+ rejectedErrors?: NodemailerError[] | undefined;
86
86
  }
87
87
  /**
88
88
  * Node style callback: called with an error, or with null and the result
@@ -3,19 +3,19 @@
3
3
  */
4
4
  export interface CookiesOptions {
5
5
  /** Lifetime in seconds for cookies that do not set their own expiration (default 1800) */
6
- sessionTimeout?: number | string;
6
+ sessionTimeout?: number | string | undefined;
7
7
  }
8
8
  /**
9
9
  * A cookie as parsed from a 'Set-Cookie:' header and kept in the jar
10
10
  */
11
11
  export interface Cookie {
12
- name?: string;
13
- value?: string;
14
- domain?: string;
15
- path?: string;
16
- expires?: Date;
17
- secure?: boolean;
18
- httponly?: boolean;
12
+ name?: string | undefined;
13
+ value?: string | undefined;
14
+ domain?: string | undefined;
15
+ path?: string | undefined;
16
+ expires?: Date | undefined;
17
+ secure?: boolean | undefined;
18
+ httponly?: boolean | undefined;
19
19
  }
20
20
  /**
21
21
  * Creates a biskviit cookie jar for managing cookie values in memory
@@ -85,10 +85,12 @@ export default class Cookies {
85
85
  */
86
86
  isExpired(cookie: Cookie): boolean;
87
87
  /**
88
- * Returns normalized cookie path for an URL path argument
88
+ * Returns the default path for an URL path argument, the default-path of
89
+ * RFC 6265 section 5.1.4. A cookie that carries no Path attribute is scoped
90
+ * to the directory of the URL it was set from
89
91
  *
90
92
  * @param pathname
91
- * @returns Normalized path
93
+ * @returns Default path
92
94
  */
93
95
  getPath(pathname?: string | null): string;
94
96
  }
@@ -1,4 +1,5 @@
1
1
  // module to handle cookies
2
+ import net from 'node:net';
2
3
  import * as urllib from '../shared/url.js';
3
4
  const SESSION_TIMEOUT = 1800; // 30 min
4
5
  /**
@@ -24,12 +25,19 @@ export default class Cookies {
24
25
  let domain;
25
26
  if (cookie.domain) {
26
27
  domain = cookie.domain.replace(/^\./, '');
27
- // do not allow cross origin cookies
28
+ // do not allow cross origin cookies. There is no public suffix list here, so a
29
+ // multi-label suffix like 'co.uk' can not be told apart from a registrable domain
28
30
  if (
29
31
  // can't be valid if the requested domain is shorter than current hostname
30
32
  urlparts.hostname.length < domain.length ||
33
+ // a top level domain is not a valid scope, 'Domain=com' would otherwise be
34
+ // sent to every .com host. A trailing dot does not make 'com.' any better
35
+ domain.indexOf('.') < 0 ||
36
+ domain.endsWith('.') ||
37
+ // an IP address has no subdomains, so cookies set on it stay host-only
38
+ net.isIP(urlparts.hostname) ||
31
39
  // prefix domains with dot to be sure that partial matches are not used
32
- ('.' + urlparts.hostname).substr(-domain.length + 1) !== '.' + domain) {
40
+ !('.' + urlparts.hostname).endsWith('.' + domain)) {
33
41
  cookie.domain = urlparts.hostname;
34
42
  }
35
43
  }
@@ -149,9 +157,13 @@ export default class Cookies {
149
157
  ('.' + urlparts.hostname).substr(-cookie.domain.length) !== cookie.domain)) {
150
158
  return false;
151
159
  }
152
- // check if path matches
153
- const path = this.getPath(urlparts.pathname);
154
- if (path.substr(0, cookie.path.length) !== cookie.path) {
160
+ // check if the request path path-matches the cookie path (RFC 6265 section 5.1.4):
161
+ // identical paths match, otherwise the cookie path must be a directory prefix
162
+ const pathname = urlparts.pathname || '/';
163
+ const cookiePath = cookie.path;
164
+ const pathMatches = pathname === cookiePath ||
165
+ (pathname.startsWith(cookiePath) && (cookiePath.endsWith('/') || pathname.charAt(cookiePath.length) === '/'));
166
+ if (!pathMatches) {
155
167
  return false;
156
168
  }
157
169
  // check secure argument
@@ -208,22 +220,21 @@ export default class Cookies {
208
220
  return (cookie.expires && cookie.expires < new Date()) || !cookie.value;
209
221
  }
210
222
  /**
211
- * Returns normalized cookie path for an URL path argument
223
+ * Returns the default path for an URL path argument, the default-path of
224
+ * RFC 6265 section 5.1.4. A cookie that carries no Path attribute is scoped
225
+ * to the directory of the URL it was set from
212
226
  *
213
227
  * @param pathname
214
- * @returns Normalized path
228
+ * @returns Default path
215
229
  */
216
230
  getPath(pathname) {
217
231
  const pathParts = (pathname || '/').split('/');
218
232
  pathParts.pop(); // remove filename part
219
- let path = pathParts.join('/').trim();
220
- // ensure path prefix /
233
+ const path = pathParts.join('/').trim();
234
+ // a path that holds no more than one '/' is scoped to the root path, and so
235
+ // is one that does not start with '/' at all
221
236
  if (path.charAt(0) !== '/') {
222
- path = '/' + path;
223
- }
224
- // ensure path suffix /
225
- if (path.substr(-1) !== '/') {
226
- path += '/';
237
+ return '/';
227
238
  }
228
239
  return path;
229
240
  }
@@ -6,43 +6,43 @@ import Cookies from './cookies.js';
6
6
  */
7
7
  export interface FetchOptions {
8
8
  /** HTTP method, defaults to GET, or to POST when a body is given */
9
- method?: string;
9
+ method?: string | undefined;
10
10
  /** Request headers, keys are lowercased before use */
11
- headers?: http.OutgoingHttpHeaders;
11
+ headers?: http.OutgoingHttpHeaders | undefined;
12
12
  /** Overrides the default User-Agent header */
13
- userAgent?: string;
13
+ userAgent?: string | undefined;
14
14
  /** Cookie string(s) to seed the cookie jar with for this URL */
15
- cookie?: string | string[] | false;
15
+ cookie?: string | string[] | false | undefined;
16
16
  /** Cookie jar shared across redirects, created when missing */
17
- cookies?: Cookies;
17
+ cookies?: Cookies | undefined;
18
18
  /** Request body: a readable stream, a Buffer, a form object or a string */
19
19
  body?: Readable | Buffer | {
20
20
  [key: string]: any;
21
- } | string | false;
21
+ } | string | false | undefined;
22
22
  /** Content-Type header for the body, false leaves it out for a stream body */
23
- contentType?: string | false;
23
+ contentType?: string | false | undefined;
24
24
  /** TLS settings, only the keys listed in TLS_OPTION_KEYS are used */
25
25
  tls?: {
26
26
  [key: string]: any;
27
- };
27
+ } | undefined;
28
28
  /** Request timeout in milliseconds */
29
- timeout?: number;
29
+ timeout?: number | undefined;
30
30
  /** Maximum number of redirects to follow (default 5) */
31
- maxRedirects?: number;
31
+ maxRedirects?: number | undefined;
32
32
  /** Resolve responses with a status code of 300 or above instead of emitting an error */
33
- allowErrorResponse?: boolean;
33
+ allowErrorResponse?: boolean | undefined;
34
34
  /** Redirects followed so far, set by nmfetch itself */
35
- redirects?: number;
35
+ redirects?: number | undefined;
36
36
  /** Response stream shared across redirects, set by nmfetch itself */
37
- fetchRes?: FetchResponse;
37
+ fetchRes?: FetchResponse | undefined;
38
38
  }
39
39
  /**
40
40
  * The stream nmfetch returns. The response body is piped into it, the status code and
41
41
  * headers of the final response are attached once they arrive
42
42
  */
43
43
  export interface FetchResponse extends PassThrough {
44
- statusCode?: number;
45
- headers?: http.IncomingHttpHeaders;
44
+ statusCode?: number | undefined;
45
+ headers?: http.IncomingHttpHeaders | undefined;
46
46
  }
47
47
  declare function nmfetch(url: string, options?: FetchOptions): FetchResponse;
48
48
  declare namespace nmfetch {