@mavogel/awscdk-rootmail 0.1.25 → 0.1.27

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 (170) hide show
  1. package/.jsii +9 -9
  2. package/lib/rootmail.js +1 -1
  3. package/lib/ses-receive.js +1 -1
  4. package/lib/ses-receive.ops-santa-handler.js +2 -2
  5. package/node_modules/@aws-sdk/checksums/package.json +3 -3
  6. package/node_modules/@aws-sdk/client-cloudwatch-logs/dist-cjs/index.js +9 -7
  7. package/node_modules/@aws-sdk/client-cloudwatch-logs/dist-es/schemas/schemas_0.js +11 -6
  8. package/node_modules/@aws-sdk/client-cloudwatch-logs/dist-types/commands/DescribeDeliveriesCommand.d.ts +3 -0
  9. package/node_modules/@aws-sdk/client-cloudwatch-logs/dist-types/commands/DescribeDeliveryDestinationsCommand.d.ts +3 -0
  10. package/node_modules/@aws-sdk/client-cloudwatch-logs/dist-types/commands/DescribeDeliverySourcesCommand.d.ts +3 -0
  11. package/node_modules/@aws-sdk/client-cloudwatch-logs/dist-types/commands/PutResourcePolicyCommand.d.ts +1 -1
  12. package/node_modules/@aws-sdk/client-cloudwatch-logs/dist-types/models/models_0.d.ts +27 -1
  13. package/node_modules/@aws-sdk/client-cloudwatch-logs/dist-types/ts3.4/models/models_0.d.ts +3 -0
  14. package/node_modules/@aws-sdk/client-cloudwatch-logs/package.json +4 -4
  15. package/node_modules/@aws-sdk/client-route-53/dist-cjs/index.js +1 -1
  16. package/node_modules/@aws-sdk/client-route-53/package.json +4 -4
  17. package/node_modules/@aws-sdk/client-s3/dist-cjs/index.js +1 -1
  18. package/node_modules/@aws-sdk/client-s3/package.json +7 -7
  19. package/node_modules/@aws-sdk/client-ses/dist-cjs/index.js +1 -1
  20. package/node_modules/@aws-sdk/client-ses/package.json +4 -4
  21. package/node_modules/@aws-sdk/client-ssm/dist-cjs/index.js +1 -1
  22. package/node_modules/@aws-sdk/client-ssm/package.json +4 -4
  23. package/node_modules/@aws-sdk/core/dist-cjs/submodules/protocols/index.js +94 -1589
  24. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/index.js +1 -7
  25. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/AwsJsonRpcProtocol.js +1 -3
  26. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/AwsRestJsonProtocol.js +1 -3
  27. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/index.d.ts +2 -8
  28. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/AwsJson1_0Protocol.d.ts +1 -2
  29. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/AwsJson1_1Protocol.d.ts +1 -2
  30. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/AwsJsonRpcProtocol.d.ts +2 -3
  31. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/AwsRestJsonProtocol.d.ts +2 -3
  32. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/index.d.ts +10 -10
  33. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/AwsJson1_0Protocol.d.ts +1 -2
  34. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/AwsJson1_1Protocol.d.ts +1 -2
  35. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/AwsJsonRpcProtocol.d.ts +2 -3
  36. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/AwsRestJsonProtocol.d.ts +2 -3
  37. package/node_modules/@aws-sdk/core/package.json +2 -2
  38. package/node_modules/@aws-sdk/credential-provider-env/package.json +3 -3
  39. package/node_modules/@aws-sdk/credential-provider-http/package.json +3 -3
  40. package/node_modules/@aws-sdk/credential-provider-ini/package.json +10 -10
  41. package/node_modules/@aws-sdk/credential-provider-login/package.json +4 -4
  42. package/node_modules/@aws-sdk/credential-provider-node/package.json +8 -8
  43. package/node_modules/@aws-sdk/credential-provider-process/package.json +3 -3
  44. package/node_modules/@aws-sdk/credential-provider-sso/package.json +5 -5
  45. package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +4 -4
  46. package/node_modules/@aws-sdk/middleware-sdk-s3/package.json +3 -3
  47. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/cognito-identity/index.js +1 -1
  48. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/signin/index.js +1 -1
  49. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso/index.js +1 -1
  50. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/index.js +1 -1
  51. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/index.js +1 -1
  52. package/node_modules/@aws-sdk/nested-clients/package.json +3 -3
  53. package/node_modules/@aws-sdk/token-providers/dist-cjs/index.js +37 -19
  54. package/node_modules/@aws-sdk/token-providers/dist-es/fromSso.js +37 -19
  55. package/node_modules/@aws-sdk/token-providers/package.json +4 -4
  56. package/node_modules/@smithy/core/dist-cjs/submodules/protocols/index.js +1695 -3
  57. package/node_modules/@smithy/core/dist-es/submodules/protocols/ConfigurableSerdeContext.js +6 -0
  58. package/node_modules/@smithy/core/dist-es/submodules/protocols/UnionSerde.js +26 -0
  59. package/node_modules/@smithy/core/dist-es/submodules/protocols/common.js +3 -0
  60. package/node_modules/@smithy/core/dist-es/submodules/protocols/index.js +8 -0
  61. package/node_modules/@smithy/core/dist-es/submodules/protocols/json/SmithyRpcV2JsonProtocol.js +102 -0
  62. package/node_modules/{@aws-sdk → @smithy}/core/dist-es/submodules/protocols/json/codec-v1/JsonShapeDeserializer.js +8 -1
  63. package/node_modules/{@aws-sdk → @smithy}/core/dist-es/submodules/protocols/json/codec-v1/JsonShapeSerializer.js +8 -1
  64. package/node_modules/{@aws-sdk → @smithy}/core/dist-es/submodules/protocols/json/codec-v2/JsonShapeDeserializer2.js +13 -2
  65. package/node_modules/{@aws-sdk → @smithy}/core/dist-es/submodules/protocols/json/codec-v2/JsonShapeSerializer2.js +11 -1
  66. package/node_modules/{@aws-sdk → @smithy}/core/dist-es/submodules/protocols/json/parseJsonBody.js +16 -1
  67. package/node_modules/@smithy/core/dist-es/submodules/protocols/writeKey.js +3 -0
  68. package/node_modules/@smithy/core/dist-types/submodules/protocols/ConfigurableSerdeContext.d.ts +8 -0
  69. package/node_modules/@smithy/core/dist-types/submodules/protocols/UnionSerde.d.ts +24 -0
  70. package/node_modules/@smithy/core/dist-types/submodules/protocols/common.d.ts +2 -0
  71. package/node_modules/@smithy/core/dist-types/submodules/protocols/index.d.ts +9 -0
  72. package/node_modules/@smithy/core/dist-types/submodules/protocols/json/JsonSettings.d.ts +13 -0
  73. package/node_modules/@smithy/core/dist-types/submodules/protocols/json/SmithyRpcV2JsonProtocol.d.ts +28 -0
  74. package/node_modules/{@aws-sdk → @smithy}/core/dist-types/submodules/protocols/json/parseJsonBody.d.ts +16 -0
  75. package/node_modules/@smithy/core/dist-types/submodules/protocols/writeKey.d.ts +4 -0
  76. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/ConfigurableSerdeContext.d.ts +8 -0
  77. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/UnionSerde.d.ts +24 -0
  78. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/common.d.ts +2 -0
  79. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/index.d.ts +9 -0
  80. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/JsonSettings.d.ts +13 -0
  81. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/SmithyRpcV2JsonProtocol.d.ts +28 -0
  82. package/node_modules/{@aws-sdk → @smithy}/core/dist-types/ts3.4/submodules/protocols/json/codec-v1/JsonCodec.d.ts +15 -11
  83. package/node_modules/{@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json → @smithy/core/dist-types/ts3.4/submodules/protocols/json/codec-v1}/JsonSettings.d.ts +7 -4
  84. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/codec-v1/JsonShapeDeserializer.d.ts +14 -0
  85. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/codec-v1/JsonShapeSerializer.d.ts +29 -0
  86. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/codec-v2/JsonBytesStringAdapter.d.ts +51 -0
  87. package/node_modules/{@aws-sdk → @smithy}/core/dist-types/ts3.4/submodules/protocols/json/codec-v2/JsonCodec2.d.ts +13 -9
  88. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/codec-v2/JsonShapeDeserializer2.d.ts +30 -0
  89. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/codec-v2/JsonShapeSerializer2.d.ts +60 -0
  90. package/node_modules/{@aws-sdk → @smithy}/core/dist-types/ts3.4/submodules/protocols/json/detectBufferParsing.d.ts +1 -1
  91. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/jsonReplacer.d.ts +21 -0
  92. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/jsonReviver.d.ts +15 -0
  93. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/needsReviver.d.ts +11 -0
  94. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/parseJsonBody.d.ts +38 -0
  95. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/writeKey.d.ts +4 -0
  96. package/node_modules/@smithy/core/package.json +2 -1
  97. package/node_modules/@zone-eu/mailsplit/README.md +43 -54
  98. package/node_modules/@zone-eu/mailsplit/lib/mime-node.js +7 -3
  99. package/node_modules/@zone-eu/mailsplit/package.json +20 -15
  100. package/node_modules/libmime/CHANGELOG.md +7 -0
  101. package/node_modules/libmime/dist/cjs/libmime.js +24 -10
  102. package/node_modules/libmime/dist/esm/libmime.js +24 -10
  103. package/node_modules/libmime/package.json +3 -1
  104. package/node_modules/mailparser/CHANGELOG.md +14 -0
  105. package/node_modules/mailparser/README.md +6 -0
  106. package/node_modules/mailparser/dist/cjs/index.d.ts +10 -0
  107. package/node_modules/mailparser/dist/cjs/index.js +12 -0
  108. package/node_modules/mailparser/dist/cjs/mail-parser.d.ts +98 -0
  109. package/node_modules/mailparser/dist/cjs/mail-parser.js +1419 -0
  110. package/node_modules/mailparser/dist/cjs/package.json +3 -0
  111. package/node_modules/mailparser/dist/cjs/simple-parser.d.ts +17 -0
  112. package/node_modules/mailparser/dist/cjs/simple-parser.js +133 -0
  113. package/node_modules/mailparser/dist/cjs/stream-hash.d.ts +24 -0
  114. package/node_modules/mailparser/dist/cjs/stream-hash.js +33 -0
  115. package/node_modules/mailparser/dist/cjs/tlds.cjs +8 -0
  116. package/node_modules/mailparser/dist/cjs/types.d.ts +309 -0
  117. package/node_modules/mailparser/dist/cjs/types.js +2 -0
  118. package/node_modules/mailparser/dist/esm/index.d.ts +10 -0
  119. package/node_modules/mailparser/dist/esm/index.js +4 -0
  120. package/node_modules/mailparser/dist/esm/mail-parser.d.ts +98 -0
  121. package/node_modules/mailparser/{lib → dist/esm}/mail-parser.js +302 -368
  122. package/node_modules/mailparser/dist/esm/package.json +3 -0
  123. package/node_modules/mailparser/dist/esm/simple-parser.d.ts +17 -0
  124. package/node_modules/mailparser/{lib → dist/esm}/simple-parser.js +45 -68
  125. package/node_modules/mailparser/dist/esm/stream-hash.d.ts +24 -0
  126. package/node_modules/mailparser/{lib → dist/esm}/stream-hash.js +7 -9
  127. package/node_modules/mailparser/dist/esm/tlds.cjs +8 -0
  128. package/node_modules/mailparser/dist/esm/types.d.ts +309 -0
  129. package/node_modules/mailparser/dist/esm/types.js +1 -0
  130. package/node_modules/mailparser/package.json +86 -15
  131. package/package.json +11 -11
  132. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/codec-v1/JsonSettings.d.ts +0 -7
  133. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/codec-v1/JsonSettings.d.ts +0 -4
  134. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/codec-v1/JsonShapeDeserializer.d.ts +0 -13
  135. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/codec-v1/JsonShapeSerializer.d.ts +0 -18
  136. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/codec-v2/JsonBytesStringAdapter.d.ts +0 -27
  137. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/codec-v2/JsonShapeDeserializer2.d.ts +0 -15
  138. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/codec-v2/JsonShapeSerializer2.d.ts +0 -39
  139. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/jsonReplacer.d.ts +0 -7
  140. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/jsonReviver.d.ts +0 -7
  141. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/needsReviver.d.ts +0 -2
  142. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/parseJsonBody.d.ts +0 -14
  143. package/node_modules/mailparser/.gitattributes +0 -1
  144. package/node_modules/mailparser/.prettierignore +0 -3
  145. package/node_modules/mailparser/.prettierrc.js +0 -10
  146. package/node_modules/mailparser/.release-please-manifest.json +0 -3
  147. package/node_modules/mailparser/eslint.config.js +0 -33
  148. package/node_modules/mailparser/index.js +0 -9
  149. package/node_modules/mailparser/release-please-config.json +0 -10
  150. /package/node_modules/{@aws-sdk → @smithy}/core/dist-es/submodules/protocols/json/JsonSettings.js +0 -0
  151. /package/node_modules/{@aws-sdk → @smithy}/core/dist-es/submodules/protocols/json/codec-v1/JsonCodec.js +0 -0
  152. /package/node_modules/{@aws-sdk → @smithy}/core/dist-es/submodules/protocols/json/codec-v1/JsonSettings.js +0 -0
  153. /package/node_modules/{@aws-sdk → @smithy}/core/dist-es/submodules/protocols/json/codec-v2/JsonBytesStringAdapter.js +0 -0
  154. /package/node_modules/{@aws-sdk → @smithy}/core/dist-es/submodules/protocols/json/codec-v2/JsonCodec2.js +0 -0
  155. /package/node_modules/{@aws-sdk → @smithy}/core/dist-es/submodules/protocols/json/detectBufferParsing.js +0 -0
  156. /package/node_modules/{@aws-sdk → @smithy}/core/dist-es/submodules/protocols/json/jsonReplacer.js +0 -0
  157. /package/node_modules/{@aws-sdk → @smithy}/core/dist-es/submodules/protocols/json/jsonReviver.js +0 -0
  158. /package/node_modules/{@aws-sdk → @smithy}/core/dist-es/submodules/protocols/json/needsReviver.js +0 -0
  159. /package/node_modules/{@aws-sdk → @smithy}/core/dist-types/submodules/protocols/json/codec-v1/JsonCodec.d.ts +0 -0
  160. /package/node_modules/{@aws-sdk/core/dist-types/submodules/protocols/json → @smithy/core/dist-types/submodules/protocols/json/codec-v1}/JsonSettings.d.ts +0 -0
  161. /package/node_modules/{@aws-sdk → @smithy}/core/dist-types/submodules/protocols/json/codec-v1/JsonShapeDeserializer.d.ts +0 -0
  162. /package/node_modules/{@aws-sdk → @smithy}/core/dist-types/submodules/protocols/json/codec-v1/JsonShapeSerializer.d.ts +0 -0
  163. /package/node_modules/{@aws-sdk → @smithy}/core/dist-types/submodules/protocols/json/codec-v2/JsonBytesStringAdapter.d.ts +0 -0
  164. /package/node_modules/{@aws-sdk → @smithy}/core/dist-types/submodules/protocols/json/codec-v2/JsonCodec2.d.ts +0 -0
  165. /package/node_modules/{@aws-sdk → @smithy}/core/dist-types/submodules/protocols/json/codec-v2/JsonShapeDeserializer2.d.ts +0 -0
  166. /package/node_modules/{@aws-sdk → @smithy}/core/dist-types/submodules/protocols/json/codec-v2/JsonShapeSerializer2.d.ts +0 -0
  167. /package/node_modules/{@aws-sdk → @smithy}/core/dist-types/submodules/protocols/json/detectBufferParsing.d.ts +0 -0
  168. /package/node_modules/{@aws-sdk → @smithy}/core/dist-types/submodules/protocols/json/jsonReplacer.d.ts +0 -0
  169. /package/node_modules/{@aws-sdk → @smithy}/core/dist-types/submodules/protocols/json/jsonReviver.d.ts +0 -0
  170. /package/node_modules/{@aws-sdk → @smithy}/core/dist-types/submodules/protocols/json/needsReviver.d.ts +0 -0
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,17 @@
1
+ import type { ParsedMail, SimpleParserOptions, Source } from './types.js';
2
+ /**
3
+ * Called with the parsed message, or with the error that stopped parsing.
4
+ */
5
+ export type SimpleParserCallback = (err: Error | null, mail: ParsedMail) => void;
6
+ /**
7
+ * Parses a whole message into one object, attachments buffered in memory. Resolves with the
8
+ * parsed message, or calls `callback` with it when one is given.
9
+ *
10
+ * @param input The raw message as a Buffer or a string, or a readable stream of it
11
+ * @param options Parser options, see {@link SimpleParserOptions}
12
+ * @throws {TypeError} When `input` is `null` or `undefined`
13
+ */
14
+ declare function simpleParser(input: Source, callback: SimpleParserCallback): void;
15
+ declare function simpleParser(input: Source, options: SimpleParserOptions | null | undefined, callback: SimpleParserCallback): void;
16
+ declare function simpleParser(input: Source, options?: SimpleParserOptions | null): Promise<ParsedMail>;
17
+ export default simpleParser;
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const mail_parser_js_1 = __importDefault(require("./mail-parser.js"));
7
+ function simpleParser(input, options, callback) {
8
+ if (input === null || input === undefined) {
9
+ throw new TypeError('Input cannot be null or undefined.');
10
+ }
11
+ if (!callback && typeof options === 'function') {
12
+ callback = options;
13
+ options = false;
14
+ }
15
+ let promise;
16
+ let done;
17
+ if (!callback) {
18
+ promise = new Promise((resolve, reject) => {
19
+ done = (err, mail) => {
20
+ if (err) {
21
+ reject(err);
22
+ }
23
+ else {
24
+ resolve(mail);
25
+ }
26
+ };
27
+ });
28
+ }
29
+ else {
30
+ done = callback;
31
+ }
32
+ // MailParser may emit a non-fatal 'error' and still reach 'end', so settle only once:
33
+ // the first error or the result wins
34
+ let settled = false;
35
+ let settle = (...args) => {
36
+ if (settled) {
37
+ return;
38
+ }
39
+ settled = true;
40
+ done(...args);
41
+ };
42
+ let parserOptions = options || {};
43
+ let keepCidLinks = !!parserOptions.keepCidLinks;
44
+ let mail = {
45
+ attachments: []
46
+ };
47
+ let parser = new mail_parser_js_1.default(parserOptions);
48
+ parser.on('error', err => {
49
+ settle(err);
50
+ });
51
+ parser.on('headers', headers => {
52
+ mail.headers = headers;
53
+ mail.headerLines = parser.headerLines;
54
+ });
55
+ let reading = false;
56
+ let reader = () => {
57
+ reading = true;
58
+ let data = parser.read();
59
+ if (data === null) {
60
+ reading = false;
61
+ return;
62
+ }
63
+ if (data.type === 'text') {
64
+ Object.keys(data).forEach(key => {
65
+ if (['text', 'html', 'textAsHtml', 'textConversionError'].includes(key)) {
66
+ mail[key] = data[key];
67
+ }
68
+ });
69
+ }
70
+ if (data.type === 'attachment') {
71
+ let attachment = data;
72
+ mail.attachments.push(attachment);
73
+ let chunks = [];
74
+ let chunklen = 0;
75
+ attachment.content.on('readable', () => {
76
+ let chunk;
77
+ while ((chunk = attachment.content.read()) !== null) {
78
+ chunks.push(chunk);
79
+ chunklen += chunk.length;
80
+ }
81
+ });
82
+ attachment.content.on('end', () => {
83
+ attachment.content = Buffer.concat(chunks, chunklen);
84
+ attachment.release();
85
+ reader();
86
+ });
87
+ }
88
+ else {
89
+ reader();
90
+ }
91
+ };
92
+ parser.on('readable', () => {
93
+ if (!reading) {
94
+ reader();
95
+ }
96
+ });
97
+ parser.on('end', () => {
98
+ ['subject', 'references', 'date', 'to', 'from', 'to', 'cc', 'bcc', 'message-id', 'in-reply-to', 'reply-to'].forEach(key => {
99
+ if (mail.headers && mail.headers.has(key)) {
100
+ mail[key.replace(/-([a-z])/g, (m, c) => c.toUpperCase())] = mail.headers.get(key);
101
+ }
102
+ });
103
+ if (keepCidLinks) {
104
+ return settle(null, mail);
105
+ }
106
+ parser.updateImageLinks((attachment, done) => done(false, 'data:' + attachment.contentType + ';base64,' + attachment.content.toString('base64')), (err, html) => {
107
+ if (err) {
108
+ return settle(err);
109
+ }
110
+ mail.html = html;
111
+ settle(null, mail);
112
+ });
113
+ });
114
+ if (typeof input === 'string') {
115
+ parser.end(Buffer.from(input));
116
+ }
117
+ else if (Buffer.isBuffer(input)) {
118
+ parser.end(input);
119
+ }
120
+ else {
121
+ input
122
+ .once('error', err => {
123
+ input.destroy();
124
+ parser.destroy();
125
+ settle(err);
126
+ })
127
+ .pipe(parser);
128
+ }
129
+ return promise;
130
+ }
131
+ exports.default = simpleParser;
132
+ module.exports = exports.default;
133
+ Object.defineProperty(module.exports, 'default', { value: exports.default, enumerable: false, writable: true, configurable: true });
@@ -0,0 +1,24 @@
1
+ import crypto from 'node:crypto';
2
+ import { Transform } from 'node:stream';
3
+ import type { TransformCallback } from 'node:stream';
4
+ /**
5
+ * The object StreamHash records its results on.
6
+ */
7
+ export interface HashTarget {
8
+ checksum?: string;
9
+ size?: number;
10
+ }
11
+ /**
12
+ * A pass-through stream that records the checksum and byte size of what flows through it on the
13
+ * given object once the stream ends. Throws when the hash algorithm is not available.
14
+ */
15
+ declare class StreamHash extends Transform {
16
+ attachment: HashTarget;
17
+ algo: string;
18
+ hash: crypto.Hash;
19
+ byteCount: number;
20
+ constructor(attachment: HashTarget, algo?: string);
21
+ _transform(chunk: Buffer, encoding: BufferEncoding, done: TransformCallback): void;
22
+ _flush(done: TransformCallback): void;
23
+ }
24
+ export default StreamHash;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const node_crypto_1 = __importDefault(require("node:crypto"));
7
+ const node_stream_1 = require("node:stream");
8
+ /**
9
+ * A pass-through stream that records the checksum and byte size of what flows through it on the
10
+ * given object once the stream ends. Throws when the hash algorithm is not available.
11
+ */
12
+ class StreamHash extends node_stream_1.Transform {
13
+ constructor(attachment, algo) {
14
+ super();
15
+ this.attachment = attachment;
16
+ this.algo = (algo || 'md5').toLowerCase();
17
+ this.hash = node_crypto_1.default.createHash(this.algo);
18
+ this.byteCount = 0;
19
+ }
20
+ _transform(chunk, encoding, done) {
21
+ this.hash.update(chunk);
22
+ this.byteCount += chunk.length;
23
+ done(null, chunk);
24
+ }
25
+ _flush(done) {
26
+ this.attachment.checksum = this.hash.digest('hex');
27
+ this.attachment.size = this.byteCount;
28
+ done();
29
+ }
30
+ }
31
+ exports.default = StreamHash;
32
+ module.exports = exports.default;
33
+ Object.defineProperty(module.exports, 'default', { value: exports.default, enumerable: false, writable: true, configurable: true });
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ // The tlds package ships its list as index.json. An ES module can only import JSON with an import
4
+ // attribute, which Node.js 20 before 20.10 does not parse, so both builds load the list through
5
+ // this CommonJS file instead: require() reads JSON on every Node.js version, and `import` of a
6
+ // CommonJS module gives its module.exports as the default export. scripts/build.js copies it next
7
+ // to the compiled modules.
8
+ module.exports = require('tlds');
@@ -0,0 +1,309 @@
1
+ import type { Readable } from 'node:stream';
2
+ /**
3
+ * A structured header value with parameters, as produced for `Content-Type`,
4
+ * `Content-Disposition` and `DKIM-Signature`.
5
+ *
6
+ * `Content-Type: text/plain; charset="UTF-8"` becomes
7
+ * `{ value: 'text/plain', params: { charset: 'UTF-8' } }`.
8
+ */
9
+ export interface StructuredHeader {
10
+ /** The main value, without parameters. Encoded words are decoded. */
11
+ value: string;
12
+ /** Parameters keyed by lowercase name. RFC 2231 and RFC 2047 encoded values are decoded. */
13
+ params: {
14
+ [key: string]: string;
15
+ };
16
+ }
17
+ /**
18
+ * One mailbox or group of an address header.
19
+ */
20
+ export interface EmailAddress {
21
+ /** The display name, or the group name for a group. Empty string when the header gave none. */
22
+ name: string;
23
+ /** The address, with an internationalized (punycode) domain decoded to Unicode. Not set for a group. */
24
+ address?: string;
25
+ /** The members of a group, when this entry is a group (`Group: a@example.com, b@example.com;`). */
26
+ group?: EmailAddress[];
27
+ }
28
+ /**
29
+ * A parsed address header (`From`, `To`, `Cc`, `Bcc`, `Sender`, `Reply-To`, `Delivered-To`,
30
+ * `Return-Path`, `Disposition-Notification-To`).
31
+ */
32
+ export interface AddressObject {
33
+ /** The parsed addresses. */
34
+ value: EmailAddress[];
35
+ /** The addresses formatted for an HTML context, with every value HTML-escaped. */
36
+ html: string;
37
+ /** The addresses formatted as plain text, display names quoted. */
38
+ text: string;
39
+ }
40
+ /**
41
+ * One entry of the combined `list` header, built from a `List-*` header such as `List-Unsubscribe`.
42
+ */
43
+ export interface ListHeaderEntry {
44
+ /** An `http:` or `https:` URL from the header. */
45
+ url?: string;
46
+ /** A display name from the header. */
47
+ name?: string;
48
+ /** An e-mail address from the header, without the `mailto:` prefix. */
49
+ mail?: string;
50
+ /** A value without an `@`, such as the `List-Id` identifier. */
51
+ id?: string;
52
+ }
53
+ /**
54
+ * The combined `List-*` headers, keyed by the part of the header name after `list-`. For example
55
+ * `List-Unsubscribe` is found under `unsubscribe` and `List-Id` under `id`.
56
+ */
57
+ export interface ListHeaders {
58
+ [key: string]: ListHeaderEntry;
59
+ }
60
+ /**
61
+ * A parsed header value. What a header parses into depends on its name:
62
+ *
63
+ * - address headers are {@link AddressObject} values,
64
+ * - `Date` is a `Date` (the current time when the header can not be parsed),
65
+ * - `Content-Type`, `Content-Disposition` and `DKIM-Signature` are {@link StructuredHeader} values,
66
+ * - `References` is a string, or an array of strings when it lists more than one Message-ID,
67
+ * - `Priority`, `X-Priority`, `X-MSMail-Priority` and `Importance` are combined into `priority`,
68
+ * one of `'high'`, `'normal'` or `'low'`,
69
+ * - `List-*` headers are combined into `list`, see {@link ListHeaders},
70
+ * - every other header is its decoded string value.
71
+ *
72
+ * A header that is repeated becomes an array of values, except for the headers that can only appear
73
+ * once (`From`, `Subject`, `Date`, `Message-ID`, `Content-Type` and the like), which keep their first
74
+ * occurrence.
75
+ */
76
+ export type HeaderValue = string | string[] | Date | AddressObject | AddressObject[] | StructuredHeader | StructuredHeader[] | ListHeaders;
77
+ /**
78
+ * Parsed headers keyed by lowercase header name.
79
+ */
80
+ export type Headers = Map<string, HeaderValue>;
81
+ /**
82
+ * The raw header lines in the order they appear, with the lowercase header name as `key` and the
83
+ * unparsed line, folding included, as `line`.
84
+ */
85
+ export type HeaderLines = ReadonlyArray<{
86
+ key: string;
87
+ line: string;
88
+ }>;
89
+ /**
90
+ * The properties every attachment has, whether streamed by {@link MailParser} or buffered by
91
+ * `simpleParser`.
92
+ */
93
+ export interface AttachmentCommon {
94
+ /** Identifies an attachment among the objects {@link MailParser} emits. */
95
+ type: 'attachment';
96
+ /** The MIME type. For `application/octet-stream` it is detected from the file name when there is one. */
97
+ contentType: string;
98
+ /** The IMAP style part number (`'1.2'`), or `null` when the message is not multipart. */
99
+ partId: string | null;
100
+ /** The `Content-Disposition` value (`'attachment'`, `'inline'` or whatever the message said), if the part had one. */
101
+ contentDisposition?: string;
102
+ /** The file name, if the part named one. */
103
+ filename?: string;
104
+ /** The parsed MIME headers of the attachment part. */
105
+ headers: Headers;
106
+ /** The `Content-ID` value, angle brackets included, if the part had one. */
107
+ contentId?: string;
108
+ /** The `Content-ID` value without angle brackets, to match against `cid:` URLs. */
109
+ cid?: string;
110
+ /** `true` when the part has a `Content-ID` and sits inside `multipart/related`, such as an embedded image. */
111
+ related?: boolean;
112
+ }
113
+ /**
114
+ * An attachment as {@link MailParser} emits it: the content is a stream that has to be read, and
115
+ * `release()` called, before the parser continues.
116
+ */
117
+ export interface AttachmentStream extends AttachmentCommon {
118
+ /** The decoded attachment content. */
119
+ content: Readable;
120
+ /**
121
+ * Tells the parser the attachment has been handled, so it can continue with the rest of the
122
+ * message. Must be called for every attachment. Set to `null` once called.
123
+ */
124
+ release: (() => void) | null;
125
+ /** The hex encoded checksum of the content (md5 unless `checksumAlgo` says otherwise). Set once `content` has ended. */
126
+ checksum?: string;
127
+ /** The size of the decoded content in bytes. Set once `content` has ended. */
128
+ size?: number;
129
+ }
130
+ /**
131
+ * An attachment as `simpleParser` returns it, with the content buffered in memory.
132
+ */
133
+ export interface Attachment extends AttachmentCommon {
134
+ /** The decoded attachment content. */
135
+ content: Buffer;
136
+ /** Always `null`, `simpleParser` has released the attachment already. */
137
+ release: null;
138
+ /** The hex encoded checksum of the content (md5 unless `checksumAlgo` says otherwise). */
139
+ checksum: string;
140
+ /** The size of the decoded content in bytes. */
141
+ size: number;
142
+ }
143
+ /**
144
+ * The text content {@link MailParser} emits once, after the whole message has been parsed.
145
+ */
146
+ export interface MessageText {
147
+ /** Identifies the text content among the objects {@link MailParser} emits. */
148
+ type: 'text';
149
+ /**
150
+ * The HTML content: every `text/html` part, with plain text parts outside `multipart/alternative`
151
+ * converted to HTML. Not set when the message has no HTML part.
152
+ */
153
+ html?: string;
154
+ /**
155
+ * The plain text content: every `text/plain` part, with HTML converted to text where there is no
156
+ * plain text alternative. Not set when the message has no text at all.
157
+ */
158
+ text?: string;
159
+ /** The plain text content converted to HTML, links included. Set whenever `text` is. */
160
+ textAsHtml?: string;
161
+ /**
162
+ * Why an HTML part could not be converted to text: it was longer than `maxHtmlLengthToParse`,
163
+ * nested deeper than the converter can handle, or the converter failed. The text of that part is
164
+ * empty, everything else is parsed as usual.
165
+ */
166
+ textConversionError?: Error;
167
+ }
168
+ /**
169
+ * The `Iconv` class of the `iconv` package, or anything with the same interface.
170
+ */
171
+ export interface IconvConstructor {
172
+ new (fromCharset: string, toCharset: string): NodeJS.ReadWriteStream;
173
+ }
174
+ /**
175
+ * Options for {@link MailParser}. `simpleParser` takes the same options plus `keepCidLinks`.
176
+ */
177
+ export interface MailParserOptions {
178
+ /**
179
+ * Do not convert HTML to plain text when the message has no plain text part.
180
+ * @default false
181
+ */
182
+ skipHtmlToText?: boolean;
183
+ /**
184
+ * HTML parts longer than this many characters are not converted to plain text, see
185
+ * {@link MessageText.textConversionError}. No limit by default.
186
+ */
187
+ maxHtmlLengthToParse?: number;
188
+ /**
189
+ * Formats the `Date` header of embedded `message/rfc822` parts in the generated text and HTML.
190
+ * By default `date.toUTCString()` is used.
191
+ */
192
+ formatDateString?: (date: Date) => string;
193
+ /**
194
+ * Do not replace `cid:` links in the HTML when `updateImageLinks()` (and so `simpleParser`) runs.
195
+ * @default false
196
+ */
197
+ skipImageLinks?: boolean;
198
+ /**
199
+ * Do not generate `textAsHtml`, and leave plain text parts out of `html`.
200
+ * @default false
201
+ */
202
+ skipTextToHtml?: boolean;
203
+ /**
204
+ * Do not turn URLs, e-mail addresses and `@mentions` into links in `textAsHtml`.
205
+ * @default false
206
+ */
207
+ skipTextLinks?: boolean;
208
+ /**
209
+ * Treat `message/delivery-status` parts as attachments instead of adding them to the text content.
210
+ * @default false
211
+ */
212
+ keepDeliveryStatus?: boolean;
213
+ /**
214
+ * Decode character sets with the native `iconv` module instead of `iconv-lite`. Pass the
215
+ * `Iconv` class: `{ Iconv: require('iconv').Iconv }`.
216
+ */
217
+ Iconv?: IconvConstructor;
218
+ /**
219
+ * The hash algorithm for attachment checksums, any name `crypto.createHash()` accepts. An algorithm
220
+ * that is not available makes the parser emit an error.
221
+ * @default 'md5'
222
+ */
223
+ checksumAlgo?: string;
224
+ /**
225
+ * The longest the URLs `updateImageLinks()` writes into the HTML may be in total, in characters.
226
+ * References past the limit are left as `cid:` links.
227
+ * @default 20971520 (20 MB)
228
+ */
229
+ maxInlinedImagesSize?: number;
230
+ /**
231
+ * Never parse embedded `message/rfc822` parts, keep every one of them as an attachment.
232
+ * @default false
233
+ */
234
+ ignoreEmbedded?: boolean;
235
+ /**
236
+ * Parse an embedded message unless its disposition says `attachment`. By default only an embedded
237
+ * message with an `inline` disposition is parsed, any other is kept as an attachment.
238
+ * @default false
239
+ */
240
+ defaultInlineEmbedded?: boolean;
241
+ /**
242
+ * The largest header block of one MIME part, in bytes. A larger one makes the parser emit an error.
243
+ * @default 1048576 (1 MB)
244
+ */
245
+ maxHeadSize?: number;
246
+ /**
247
+ * The most MIME parts a message may have. More make the parser emit an error.
248
+ * @default 1000
249
+ */
250
+ maxChildNodes?: number;
251
+ }
252
+ /**
253
+ * Options for `simpleParser`.
254
+ */
255
+ export interface SimpleParserOptions extends MailParserOptions {
256
+ /**
257
+ * Leave `cid:` links in the HTML as they are. By default every `cid:` link to an image attachment
258
+ * is replaced with a `data:` URL of the image.
259
+ * @default false
260
+ */
261
+ keepCidLinks?: boolean;
262
+ }
263
+ /**
264
+ * The parsed message `simpleParser` resolves with.
265
+ */
266
+ export interface ParsedMail {
267
+ /** Every attachment, content buffered. */
268
+ attachments: Attachment[];
269
+ /** Parsed headers of the message, see {@link HeaderValue}. */
270
+ headers: Headers;
271
+ /** The raw header lines of the message. */
272
+ headerLines: HeaderLines;
273
+ /**
274
+ * The HTML content, see {@link MessageText.html}. Unless `keepCidLinks` is set, `cid:` links to
275
+ * image attachments are replaced with `data:` URLs, and the value is `false` when the message has no
276
+ * HTML; with `keepCidLinks` set it is not set instead.
277
+ */
278
+ html?: string | false;
279
+ /** The plain text content, see {@link MessageText.text}. */
280
+ text?: string;
281
+ /** The plain text content converted to HTML, see {@link MessageText.textAsHtml}. */
282
+ textAsHtml?: string;
283
+ /** Why an HTML part could not be converted to text, see {@link MessageText.textConversionError}. */
284
+ textConversionError?: Error;
285
+ /** The `Subject` header. */
286
+ subject?: string;
287
+ /** The `References` header: one Message-ID as a string, more than one as an array. */
288
+ references?: string | string[];
289
+ /** The `Date` header. */
290
+ date?: Date;
291
+ /** The `To` header, an array when the message has more than one `To` header. */
292
+ to?: AddressObject | AddressObject[];
293
+ /** The `From` header. */
294
+ from?: AddressObject;
295
+ /** The `Cc` header, an array when the message has more than one `Cc` header. */
296
+ cc?: AddressObject | AddressObject[];
297
+ /** The `Bcc` header, an array when the message has more than one `Bcc` header. */
298
+ bcc?: AddressObject | AddressObject[];
299
+ /** The `Message-ID` header, angle brackets included. */
300
+ messageId?: string;
301
+ /** The `In-Reply-To` header, angle brackets included. */
302
+ inReplyTo?: string;
303
+ /** The `Reply-To` header. */
304
+ replyTo?: AddressObject;
305
+ }
306
+ /**
307
+ * A message to parse: the raw message as a Buffer or a string, or a readable stream of it.
308
+ */
309
+ export type Source = Buffer | string | Readable;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,10 @@
1
+ import MailParser from './mail-parser.js';
2
+ import simpleParser from './simple-parser.js';
3
+ export { MailParser, simpleParser };
4
+ export type { SimpleParserCallback } from './simple-parser.js';
5
+ export type * from './types.js';
6
+ declare const _default: {
7
+ MailParser: typeof MailParser;
8
+ simpleParser: typeof simpleParser;
9
+ };
10
+ export default _default;
@@ -0,0 +1,4 @@
1
+ import MailParser from './mail-parser.js';
2
+ import simpleParser from './simple-parser.js';
3
+ export { MailParser, simpleParser };
4
+ export default { MailParser, simpleParser };
@@ -0,0 +1,98 @@
1
+ import { Transform } from 'node:stream';
2
+ import type { TransformCallback } from 'node:stream';
3
+ import type { AddressObject, AttachmentStream, EmailAddress, HeaderLines, Headers, MailParserOptions, MessageText } from './types.js';
4
+ /**
5
+ * A lower level, streaming e-mail parser. It is a Transform stream: write the raw message in and
6
+ * read the parsed content out. It emits:
7
+ *
8
+ * - a `headers` event with the parsed headers of the message (see {@link Headers}),
9
+ * - a `headerLines` event with the raw header lines,
10
+ * - an {@link AttachmentStream} object for every attachment, whose content stream has to be read
11
+ * and `release()` called before the parser continues,
12
+ * - one {@link MessageText} object with the text content at the end.
13
+ *
14
+ * For one-shot parsing into a single object, use `simpleParser` instead.
15
+ */
16
+ declare class MailParser extends Transform {
17
+ /** The options the parser was created with. */
18
+ options: MailParserOptions;
19
+ /** The parsed headers of the message, `false` until they have been parsed. */
20
+ headers: Headers | false;
21
+ /** The raw header lines of the message, `false` until they have been parsed. */
22
+ headerLines: HeaderLines | false;
23
+ /** The plain text content, `false` until the message has been parsed or when there is none. */
24
+ text: string | false;
25
+ /** The HTML content, `false` until the message has been parsed or when there is none. */
26
+ html: string | false;
27
+ /** The plain text content as HTML, `false` until the message has been parsed or when there is none. */
28
+ textAsHtml: string | false;
29
+ /** The `Subject` header, set once the headers have been parsed. */
30
+ subject?: string;
31
+ /** The `References` header, set once the headers have been parsed. */
32
+ references?: string | string[];
33
+ /** The `Date` header, set once the headers have been parsed. */
34
+ date?: Date;
35
+ /** The `To` header, set once the headers have been parsed. */
36
+ to?: AddressObject | AddressObject[];
37
+ /** The `From` header, set once the headers have been parsed. */
38
+ from?: AddressObject;
39
+ /** The `Cc` header, set once the headers have been parsed. */
40
+ cc?: AddressObject | AddressObject[];
41
+ /** The `Bcc` header, set once the headers have been parsed. */
42
+ bcc?: AddressObject | AddressObject[];
43
+ /** The `Message-ID` header, set once the headers have been parsed. */
44
+ messageId?: string;
45
+ /** The `In-Reply-To` header, set once the headers have been parsed. */
46
+ inReplyTo?: string;
47
+ /** The `Reply-To` header, set once the headers have been parsed. */
48
+ replyTo?: AddressObject;
49
+ constructor(config?: MailParserOptions);
50
+ _transform(chunk: Buffer, encoding: BufferEncoding, done: TransformCallback): void;
51
+ _flush(done: TransformCallback): void;
52
+ /**
53
+ * Turns a `Priority`, `X-Priority`, `X-MSMail-Priority` or `Importance` header value into
54
+ * `'high'`, `'normal'` or `'low'`.
55
+ */
56
+ parsePriority(value: string): 'high' | 'normal' | 'low';
57
+ /**
58
+ * Wraps a Message-ID in angle brackets where they are missing. Returns `false` for an empty value.
59
+ */
60
+ ensureMessageIDFormat(value: string): string | false;
61
+ /**
62
+ * Formats parsed addresses for an HTML context, every value HTML-escaped.
63
+ */
64
+ getAddressesHTML(value: EmailAddress | EmailAddress[]): string;
65
+ /**
66
+ * Formats parsed addresses as plain text, display names quoted.
67
+ */
68
+ getAddressesText(value: EmailAddress | EmailAddress[]): string;
69
+ /**
70
+ * Replaces `cid:` links to image attachments in the HTML content. Call it once the parser has
71
+ * ended. `replaceCallback` is called once for every referenced image attachment and answers with
72
+ * the URL to use instead; `done` gets the updated HTML, or `false` when the message has no HTML.
73
+ * The total length of the URLs written is bounded by `maxInlinedImagesSize`.
74
+ */
75
+ updateImageLinks(replaceCallback: (attachment: AttachmentStream, callback: (err: Error | null | false | undefined, url?: string) => void) => void, done: (err: Error | null, html?: string | false) => void): void;
76
+ /**
77
+ * Converts plain text to HTML the way `textAsHtml` is built: HTML-escaped, paragraphs and line
78
+ * breaks kept, and links turned into anchors unless `skipTextLinks` is set. Returns an empty
79
+ * string when `skipTextToHtml` is set.
80
+ */
81
+ textToHtml(str: string): string;
82
+ }
83
+ interface MailParser {
84
+ /** Emitted once with the parsed headers of the message. */
85
+ on(event: 'headers', listener: (headers: Headers) => void): this;
86
+ /** Emitted once with the raw header lines of the message. */
87
+ on(event: 'headerLines', listener: (headerLines: HeaderLines) => void): this;
88
+ /** Emitted for every attachment and, at the end, once for the text content. */
89
+ on(event: 'data', listener: (data: AttachmentStream | MessageText) => void): this;
90
+ on(event: string | symbol, listener: (...args: any[]) => void): this;
91
+ once(event: 'headers', listener: (headers: Headers) => void): this;
92
+ once(event: 'headerLines', listener: (headerLines: HeaderLines) => void): this;
93
+ once(event: 'data', listener: (data: AttachmentStream | MessageText) => void): this;
94
+ once(event: string | symbol, listener: (...args: any[]) => void): this;
95
+ /** Returns the next attachment or text content object, or `null` when none is buffered. */
96
+ read(size?: number): AttachmentStream | MessageText | null;
97
+ }
98
+ export default MailParser;