@mavogel/awscdk-rootmail 0.1.23 → 0.1.25

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 (96) hide show
  1. package/.jsii +4 -4
  2. package/lib/rootmail.js +1 -1
  3. package/lib/ses-receive.js +1 -1
  4. package/node_modules/@zone-eu/mailsplit/README.md +1 -1
  5. package/node_modules/@zone-eu/mailsplit/lib/headers.js +10 -4
  6. package/node_modules/@zone-eu/mailsplit/lib/message-splitter.js +5 -4
  7. package/node_modules/@zone-eu/mailsplit/lib/mime-node.d.ts +4 -1
  8. package/node_modules/@zone-eu/mailsplit/lib/mime-node.js +23 -2
  9. package/node_modules/@zone-eu/mailsplit/lib/types.d.ts +3 -1
  10. package/node_modules/@zone-eu/mailsplit/package.json +4 -4
  11. package/node_modules/libbase64/CHANGELOG.md +20 -0
  12. package/node_modules/libbase64/README.md +40 -13
  13. package/node_modules/libbase64/dist/cjs/libbase64.d.ts +80 -0
  14. package/node_modules/libbase64/dist/cjs/libbase64.js +310 -0
  15. package/node_modules/libbase64/dist/cjs/package.json +3 -0
  16. package/node_modules/libbase64/dist/esm/libbase64.d.ts +80 -0
  17. package/node_modules/libbase64/{lib → dist/esm}/libbase64.js +74 -117
  18. package/node_modules/libbase64/dist/esm/package.json +3 -0
  19. package/node_modules/libbase64/package.json +59 -13
  20. package/node_modules/libmime/CHANGELOG.md +31 -0
  21. package/node_modules/libmime/README.md +55 -26
  22. package/node_modules/libmime/SECURITY.md +152 -0
  23. package/node_modules/libmime/dist/cjs/charset.d.ts +43 -0
  24. package/node_modules/libmime/dist/cjs/charset.js +135 -0
  25. package/node_modules/libmime/dist/cjs/charsets.d.ts +2 -0
  26. package/node_modules/libmime/dist/cjs/charsets.js +213 -0
  27. package/node_modules/libmime/dist/cjs/get-charset-name.d.ts +1 -0
  28. package/node_modules/libmime/dist/cjs/get-charset-name.js +224 -0
  29. package/node_modules/libmime/dist/cjs/libmime.d.ts +218 -0
  30. package/node_modules/libmime/dist/cjs/libmime.js +1013 -0
  31. package/node_modules/libmime/dist/cjs/mimetypes.d.ts +7 -0
  32. package/node_modules/libmime/dist/cjs/mimetypes.js +2072 -0
  33. package/node_modules/libmime/dist/cjs/package.json +3 -0
  34. package/node_modules/libmime/dist/cjs/types.d.ts +59 -0
  35. package/node_modules/libmime/dist/cjs/types.js +4 -0
  36. package/node_modules/libmime/dist/esm/charset.d.ts +43 -0
  37. package/node_modules/libmime/dist/esm/charset.js +125 -0
  38. package/node_modules/libmime/dist/esm/charsets.d.ts +2 -0
  39. package/node_modules/libmime/{lib → dist/esm}/charsets.js +3 -5
  40. package/node_modules/libmime/dist/esm/get-charset-name.d.ts +1 -0
  41. package/node_modules/libmime/{lib → dist/esm}/get-charset-name.js +1 -8
  42. package/node_modules/libmime/dist/esm/libmime.d.ts +219 -0
  43. package/node_modules/libmime/{lib → dist/esm}/libmime.js +256 -329
  44. package/node_modules/libmime/dist/esm/mimetypes.d.ts +7 -0
  45. package/node_modules/libmime/dist/esm/mimetypes.js +2068 -0
  46. package/node_modules/libmime/dist/esm/package.json +3 -0
  47. package/node_modules/libmime/dist/esm/types.d.ts +59 -0
  48. package/node_modules/libmime/dist/esm/types.js +3 -0
  49. package/node_modules/libmime/package.json +58 -15
  50. package/node_modules/libqp/CHANGELOG.md +18 -0
  51. package/node_modules/libqp/README.md +50 -19
  52. package/node_modules/libqp/dist/cjs/libqp.d.ts +74 -0
  53. package/node_modules/libqp/dist/cjs/libqp.js +378 -0
  54. package/node_modules/libqp/dist/cjs/package.json +3 -0
  55. package/node_modules/libqp/dist/esm/libqp.d.ts +74 -0
  56. package/node_modules/libqp/dist/esm/libqp.js +369 -0
  57. package/node_modules/libqp/dist/esm/package.json +3 -0
  58. package/node_modules/libqp/lib/libqp.js +4 -383
  59. package/node_modules/libqp/lib/package.json +3 -0
  60. package/node_modules/libqp/package.json +62 -6
  61. package/node_modules/mailparser/.release-please-manifest.json +1 -1
  62. package/node_modules/mailparser/CHANGELOG.md +42 -0
  63. package/node_modules/mailparser/package.json +5 -5
  64. package/node_modules/nodemailer/CHANGELOG.md +44 -0
  65. package/node_modules/nodemailer/dist/cjs/addressparser/index.js +695 -267
  66. package/node_modules/nodemailer/dist/cjs/mailer/mail-message.js +4 -1
  67. package/node_modules/nodemailer/dist/cjs/mime-funcs/index.js +8 -2
  68. package/node_modules/nodemailer/dist/cjs/mime-node/index.js +48 -16
  69. package/node_modules/nodemailer/dist/cjs/package-info.d.ts +1 -1
  70. package/node_modules/nodemailer/dist/cjs/package-info.js +1 -1
  71. package/node_modules/nodemailer/dist/cjs/shared/url.js +22 -5
  72. package/node_modules/nodemailer/dist/esm/addressparser/index.js +695 -267
  73. package/node_modules/nodemailer/dist/esm/mailer/mail-message.js +4 -1
  74. package/node_modules/nodemailer/dist/esm/mime-funcs/index.js +8 -2
  75. package/node_modules/nodemailer/dist/esm/mime-node/index.js +48 -16
  76. package/node_modules/nodemailer/dist/esm/package-info.d.ts +1 -1
  77. package/node_modules/nodemailer/dist/esm/package-info.js +1 -1
  78. package/node_modules/nodemailer/dist/esm/shared/url.js +22 -5
  79. package/node_modules/nodemailer/package.json +1 -1
  80. package/package.json +3 -3
  81. package/node_modules/libbase64/.eslintrc +0 -11
  82. package/node_modules/libbase64/.github/FUNDING.yml +0 -4
  83. package/node_modules/libbase64/.github/VULNERABILITY_REPORT.yml +0 -75
  84. package/node_modules/libbase64/.github/workflows/release.yaml +0 -39
  85. package/node_modules/libbase64/.github/workflows/test.yml +0 -21
  86. package/node_modules/libbase64/.ncurc.js +0 -13
  87. package/node_modules/libbase64/.prettierrc.js +0 -8
  88. package/node_modules/libmime/lib/charset.js +0 -131
  89. package/node_modules/libmime/lib/mimetypes.js +0 -2049
  90. package/node_modules/libqp/.eslintrc +0 -15
  91. package/node_modules/libqp/.github/FUNDING.yml +0 -4
  92. package/node_modules/libqp/.github/VULNERABILITY_REPORT.yml +0 -75
  93. package/node_modules/libqp/.github/workflows/release.yaml +0 -39
  94. package/node_modules/libqp/.github/workflows/test.yml +0 -21
  95. package/node_modules/libqp/.prettierrc.js +0 -8
  96. package/node_modules/libqp/test/libqp-test.js +0 -366
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Configuration object of a Libmime instance, kept as `config`. The library itself does not read any keys
3
+ */
4
+ export type LibmimeConfig = Record<string, any>;
5
+ /**
6
+ * A single header line split into its key and value
7
+ */
8
+ export interface HeaderLine {
9
+ /** Lowercased header key */
10
+ key: string;
11
+ /** Header value, unfolded and trimmed, not mime word decoded */
12
+ value: string;
13
+ }
14
+ /**
15
+ * Parsed header block, every key holds the values of all the header lines with that key
16
+ */
17
+ export type HeaderObject = Record<string, string[]>;
18
+ /**
19
+ * Header value with key=value parameters as returned by parseHeaderValue()
20
+ */
21
+ export interface ParsedHeaderValue {
22
+ /** The value in front of the parameters, eg. "text/plain" */
23
+ value: string;
24
+ /** Parameters keyed by their lowercased names */
25
+ params: Record<string, string>;
26
+ /**
27
+ * Names of the params assembled from rfc2231 segments. Their values are already decoded,
28
+ * so a caller that runs decodeWords() over the params has to leave them out. Non-enumerable
29
+ */
30
+ decodedParams: string[];
31
+ }
32
+ /**
33
+ * Header value with parameters as accepted by buildHeaderValue()
34
+ */
35
+ export interface StructuredHeaderValue {
36
+ value: string;
37
+ params?: Record<string, unknown> | undefined;
38
+ }
39
+ /**
40
+ * A parameter key and value pair as returned by buildHeaderParam()
41
+ */
42
+ export interface HeaderParam {
43
+ key: string;
44
+ value: string;
45
+ }
46
+ /**
47
+ * Header value with key=value parameters, the name the @types/libmime declarations used
48
+ */
49
+ export interface StructuredHeader {
50
+ value: string;
51
+ params: {
52
+ [key: string]: string;
53
+ };
54
+ }
55
+ /**
56
+ * Encoding of a mime encoded word, Q for quoted printable and B for base64. Lowercase letters
57
+ * and longer names that start with Q or B are accepted as well
58
+ */
59
+ export type MimeWordEncoding = 'Q' | 'B';
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ // Public types of the library. Re-exported from the package entry point, and reachable as
3
+ // members of the default export (`libmime.ParsedHeaderValue`) as well
4
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,43 @@
1
+ import { Buffer } from 'node:buffer';
2
+ /**
3
+ * Encodes an unicode string into an Buffer object as UTF-8
4
+ *
5
+ * We force UTF-8 here, no strange encodings allowed.
6
+ *
7
+ * @param str String to be encoded
8
+ * @return UTF-8 encoded typed array
9
+ */
10
+ export declare function encode(str: string): Buffer;
11
+ /**
12
+ * Decodes a string from Buffer to an unicode string using specified encoding.
13
+ * An unknown charset falls back to UTF-8
14
+ *
15
+ * @param buf Binary data to be decoded
16
+ * @param [fromCharset='UTF-8'] Binary data is decoded into string using this charset
17
+ * @return Decoded string
18
+ */
19
+ export declare function decode(buf: Buffer | string, fromCharset?: string): string;
20
+ /**
21
+ * Convert a string from specific encoding to UTF-8 Buffer
22
+ *
23
+ * @param data String or Buffer to be encoded
24
+ * @param [fromCharset='UTF-8'] Source encoding for the string
25
+ * @return UTF-8 encoded typed array
26
+ */
27
+ export declare function convert(data: string | Buffer, fromCharset?: string): Buffer;
28
+ /**
29
+ * Converts well known invalid character set names to proper names.
30
+ * eg. win-1257 will be converted to windows-1257. Missing or non-string
31
+ * input defaults to UTF-8.
32
+ *
33
+ * @param charset Charset name to convert
34
+ * @return Canonicalized charset name
35
+ */
36
+ export declare function normalizeCharset(charset?: unknown): string;
37
+ declare const _default: {
38
+ encode: typeof encode;
39
+ decode: typeof decode;
40
+ convert: typeof convert;
41
+ normalizeCharset: typeof normalizeCharset;
42
+ };
43
+ export default _default;
@@ -0,0 +1,125 @@
1
+ import { Buffer } from 'node:buffer';
2
+ import iconv from 'iconv-lite';
3
+ import encodingJapanese from 'encoding-japanese';
4
+ import charsets from './charsets.js';
5
+ /**
6
+ * Character set encoding and decoding functions
7
+ */
8
+ // Names that are decoded as UTF-8 without going through iconv-lite
9
+ const UTF8_COMPATIBLE = /^(?:(?:us-)?ascii|utf-8|7bit)$/i;
10
+ // iconv-lite codecs that are not character sets a message could be written in. UTF-7 is a known
11
+ // way to smuggle markup past filters (=?utf-7?Q?+ADw-script+AD4-?= decodes to "<script>"), base64
12
+ // and hex are transfer encodings. A name resolving to one of them is treated like a charset
13
+ // iconv-lite does not know. iconv-lite resolves the name itself and returns one cached codec per
14
+ // encoding, so every alias it knows (unicode-1-1-utf-7 is utf7 too) is caught by identity
15
+ const UNSUPPORTED_CODECS = new Set(['utf7', 'utf7imap', 'base64', 'hex'].map(name => iconv.getCodec(name)));
16
+ const isUnsupportedCodec = (name) => {
17
+ try {
18
+ return UNSUPPORTED_CODECS.has(iconv.getCodec(name));
19
+ }
20
+ catch (_err) {
21
+ // a charset iconv-lite does not know at all
22
+ return false;
23
+ }
24
+ };
25
+ // Own entries only, so that a name such as '__proto__' or 'constructor' does not resolve to an
26
+ // inherited Object.prototype member
27
+ const CHARSET_ALIASES = new Map(Object.entries(charsets));
28
+ /**
29
+ * Encodes an unicode string into an Buffer object as UTF-8
30
+ *
31
+ * We force UTF-8 here, no strange encodings allowed.
32
+ *
33
+ * @param str String to be encoded
34
+ * @return UTF-8 encoded typed array
35
+ */
36
+ export function encode(str) {
37
+ return Buffer.from(str, 'utf-8');
38
+ }
39
+ /**
40
+ * Decodes a string from Buffer to an unicode string using specified encoding.
41
+ * An unknown charset falls back to UTF-8
42
+ *
43
+ * @param buf Binary data to be decoded
44
+ * @param [fromCharset='UTF-8'] Binary data is decoded into string using this charset
45
+ * @return Decoded string
46
+ */
47
+ export function decode(buf, fromCharset) {
48
+ fromCharset = normalizeCharset(fromCharset || 'UTF-8');
49
+ if (UTF8_COMPATIBLE.test(fromCharset)) {
50
+ return buf.toString('utf-8');
51
+ }
52
+ if (isUnsupportedCodec(fromCharset)) {
53
+ // enforce utf-8, the same as for a charset iconv-lite does not know
54
+ return buf.toString();
55
+ }
56
+ try {
57
+ if (/^jis|^iso-?2022-?jp|^EUCJP/i.test(fromCharset)) {
58
+ if (typeof buf === 'string') {
59
+ buf = Buffer.from(buf);
60
+ }
61
+ try {
62
+ let output = encodingJapanese.convert(buf, {
63
+ to: 'UNICODE',
64
+ from: fromCharset,
65
+ type: 'string'
66
+ });
67
+ if (typeof output === 'string') {
68
+ return output;
69
+ }
70
+ // fall through to iconv-lite if convert returned something unexpected
71
+ }
72
+ catch (_err) {
73
+ // ignore, defaults to iconv-lite on error
74
+ }
75
+ }
76
+ // iconv-lite reads a string as binary, kept as it always was
77
+ return iconv.decode(buf, fromCharset);
78
+ }
79
+ catch (_err) {
80
+ // enforce utf-8, data loss might occur
81
+ return buf.toString();
82
+ }
83
+ }
84
+ /**
85
+ * Convert a string from specific encoding to UTF-8 Buffer
86
+ *
87
+ * @param data String or Buffer to be encoded
88
+ * @param [fromCharset='UTF-8'] Source encoding for the string
89
+ * @return UTF-8 encoded typed array
90
+ */
91
+ export function convert(data, fromCharset) {
92
+ fromCharset = normalizeCharset(fromCharset || 'UTF-8');
93
+ if (typeof data !== 'string') {
94
+ if (UTF8_COMPATIBLE.test(fromCharset)) {
95
+ return data;
96
+ }
97
+ return encode(decode(data, fromCharset));
98
+ }
99
+ return encode(data);
100
+ }
101
+ /**
102
+ * Converts well known invalid character set names to proper names.
103
+ * eg. win-1257 will be converted to windows-1257. Missing or non-string
104
+ * input defaults to UTF-8.
105
+ *
106
+ * @param charset Charset name to convert
107
+ * @return Canonicalized charset name
108
+ */
109
+ export function normalizeCharset(charset) {
110
+ let name = (charset || 'UTF-8').toString().toLowerCase().trim();
111
+ // first pass
112
+ let canonical = CHARSET_ALIASES.get(name);
113
+ if (canonical) {
114
+ return canonical;
115
+ }
116
+ name = name
117
+ .replace(/^utf[-_]?(\d+)/, 'utf-$1')
118
+ .replace(/^(?:us[-_]?)ascii/, 'windows-1252')
119
+ .replace(/^win(?:dows)?[-_]?(\d+)/, 'windows-$1')
120
+ .replace(/^(?:latin|iso[-_]?8859)?[-_]?(\d+)/, 'iso-8859-$1')
121
+ .replace(/^l[-_]?(\d+)/, 'iso-8859-$1');
122
+ // updated pass
123
+ return CHARSET_ALIASES.get(name) || name.toUpperCase();
124
+ }
125
+ export default { encode, decode, convert, normalizeCharset };
@@ -0,0 +1,2 @@
1
+ declare const charsets: Record<string, string>;
2
+ export default charsets;
@@ -1,8 +1,5 @@
1
- /* eslint quote-props: 0*/
2
-
3
- 'use strict';
4
-
5
- module.exports = {
1
+ // Charset name aliases, keyed by the lowercased alias, mapped to the canonical name
2
+ const charsets = {
6
3
  '866': 'IBM866',
7
4
  'unicode-1-1-utf-8': 'UTF-8',
8
5
  'utf-8': 'UTF-8',
@@ -210,3 +207,4 @@ module.exports = {
210
207
  'utf-16': 'UTF-16LE',
211
208
  'utf-16le': 'UTF-16LE'
212
209
  };
210
+ export default charsets;
@@ -0,0 +1 @@
1
+ export declare const getCharsetName: (charset: unknown) => string | false;
@@ -1,5 +1,3 @@
1
- 'use strict';
2
-
3
1
  // https://nodejs.org/api/util.html#encodings-supported-by-default-with-full-icu-data
4
2
  // NB! iso-8859-16 not supported
5
3
  const CHARSETS = [
@@ -215,13 +213,8 @@ const CHARSETS = [
215
213
  'x-sjis',
216
214
  'x-x-big5'
217
215
  ];
218
-
219
216
  const CHARSET_MAP = new Map(CHARSETS.map(charset => [charset.replace(/[-_]+/g, ''), charset]));
220
-
221
- const getCharsetName = charset => {
217
+ export const getCharsetName = (charset) => {
222
218
  let charsetKey = (charset || '').toString().toLowerCase().trim().replace(/[-_]+/g, '');
223
-
224
219
  return CHARSET_MAP.get(charsetKey) || false;
225
220
  };
226
-
227
- module.exports.getCharsetName = getCharsetName;
@@ -0,0 +1,219 @@
1
+ import { Buffer } from 'node:buffer';
2
+ import type { HeaderLine, HeaderObject, HeaderParam, LibmimeConfig, ParsedHeaderValue, StructuredHeaderValue } from './types.js';
3
+ import type * as types from './types.js';
4
+ export type * from './types.js';
5
+ export declare class Libmime {
6
+ config: LibmimeConfig;
7
+ constructor(config?: LibmimeConfig);
8
+ /**
9
+ * Checks if a value is plaintext string (uses only printable 7bit chars)
10
+ *
11
+ * When isParam is set the value is destined for a header parameter, so HT, CR and LF
12
+ * are not plaintext either: a header parameter has no way to carry them. HT is a valid
13
+ * fold point, so folding and unfolding a header would rewrite it as a space, and CR/LF
14
+ * cannot appear in a header value at all. DEL is neither a token character nor qtext,
15
+ * so it can not be carried bare or quoted. Such values have to go through the rfc2231
16
+ * parameter continuation encoding instead, the same way non-ASCII text does.
17
+ *
18
+ * @param {String} value String to be tested
19
+ * @param {Boolean} [isParam] Set to true if the value is a header parameter value
20
+ * @returns {Boolean} true if it is a plaintext string
21
+ */
22
+ isPlainText(value: unknown, isParam?: boolean): boolean;
23
+ private isPlainParamValue;
24
+ /**
25
+ * Checks if a multi line string containes lines longer than the selected value.
26
+ *
27
+ * Useful when detecting if a mail message needs any processing at all:
28
+ * if only plaintext characters are used and lines are short, then there is
29
+ * no need to encode the values in any way. If the value is plaintext but has
30
+ * longer lines then allowed, then use format=flowed
31
+ *
32
+ * @param {String} str String to be tested
33
+ * @param {Number} lineLength Max line length to check for
34
+ * @returns {Boolean} Returns true if there is at least one line longer than lineLength chars
35
+ */
36
+ hasLongerLines(str: string, lineLength: number): boolean;
37
+ /**
38
+ * Decodes a string from a format=flowed soft wrapping.
39
+ *
40
+ * @param {String} str Plaintext string with format=flowed to decode
41
+ * @param {Boolean} [delSp] If true, delete leading spaces (delsp=yes)
42
+ * @return {String} Mime decoded string
43
+ */
44
+ decodeFlowed(input: unknown, delSp?: boolean): string;
45
+ /**
46
+ * Adds soft line breaks to content marked with format=flowed to
47
+ * ensure that no line in the message is never longer than lineLength
48
+ *
49
+ * @param {String} str Plaintext string that requires wrapping
50
+ * @param {Number} [lineLength=76] Maximum length of a line
51
+ * @return {String} String with forced line breaks
52
+ */
53
+ encodeFlowed(str: string, lineLength?: number): string;
54
+ /**
55
+ * Encodes a string or an Buffer to an UTF-8 MIME Word (rfc2047)
56
+ *
57
+ * @param {String|Buffer} data String to be encoded
58
+ * @param {String} mimeWordEncoding='Q' Encoding for the mime word, either Q or B
59
+ * @param {Number} [maxLength=0] If set, split mime words into several chunks if needed
60
+ * @return {String} Single or several mime words joined together
61
+ */
62
+ encodeWord(data: string | Buffer, mimeWordEncoding?: string, maxLength?: number): string;
63
+ /**
64
+ * Normalizes a charset name to its canonical form, resolving common aliases and
65
+ * invalid names. For example `iso-8859-8-i` and `iso-8859-8-e` become `ISO-8859-8`
66
+ * and `win-1257` becomes `windows-1257`. Unknown charsets are returned uppercased.
67
+ * Missing or non-string input defaults to `UTF-8`.
68
+ *
69
+ * @param {String} charset Charset name to normalize
70
+ * @return {String} Canonical charset name
71
+ */
72
+ normalizeCharset(charset?: unknown): string;
73
+ /**
74
+ * Decodes the inner payload of a single mime encoded-word into a unicode string.
75
+ * Expects the three components of `=?charset?encoding?text?=` already separated.
76
+ *
77
+ * @param {String} charset Charset name from the encoded-word (may include an RFC 2231 language tag, which is ignored)
78
+ * @param {String} encoding Encoding indicator, either 'Q' or 'B' (case insensitive)
79
+ * @param {String} str Encoded payload between the second `?` and the trailing `?=`
80
+ * @return {String} Decoded unicode string
81
+ */
82
+ decodeWord(charset: string, encoding: string, str: string): string;
83
+ /**
84
+ * Finds word sequences with non ascii text and converts these to mime words
85
+ *
86
+ * @param {String|Buffer} data String to be encoded
87
+ * @param {String} mimeWordEncoding='Q' Encoding for the mime word, either Q or B
88
+ * @param {Number} [maxLength=0] If set, split mime words into several chunks if needed
89
+ * @param {String} [fromCharset='UTF-8'] Source character set
90
+ * @return {String} String with possible mime words
91
+ */
92
+ encodeWords(data: string | Buffer, mimeWordEncoding?: string, maxLength?: number | string, fromCharset?: string): string;
93
+ /**
94
+ * Decode a string that might include one or several mime words
95
+ *
96
+ * @param {String} str String including some mime words that will be decoded
97
+ * @return {String} Decoded unicode string
98
+ */
99
+ decodeWords(str: unknown): string;
100
+ getHex(c: number | undefined): string | false;
101
+ /**
102
+ * Splits a string by :
103
+ * The result is not mime word decoded, you need to do your own decoding based
104
+ * on the rules for the specific header key
105
+ *
106
+ * @param {String} headerLine Single header line, might include linebreaks as well if folded
107
+ * @return {Object} An object of {key, value}
108
+ */
109
+ decodeHeader(headerLine: unknown): HeaderLine;
110
+ /**
111
+ * Parses a block of header lines. Does not decode mime words as every
112
+ * header might have its own rules (eg. formatted email addresses and such)
113
+ *
114
+ * @param {String} headers Headers string
115
+ * @return {Object} An object of headers, where header keys are object keys and every value is an Array of the values for that key
116
+ */
117
+ decodeHeaders(headers: string): HeaderObject;
118
+ /**
119
+ * Joins parsed header value together as 'value; param1=value1; param2=value2'
120
+ * PS: We are following RFC 822 for the list of special characters that we need to keep in quotes.
121
+ * Refer: https://www.w3.org/Protocols/rfc1341/4_Content-Type.html
122
+ * @param {Object} structured Parsed header value
123
+ * @return {String} joined header value
124
+ */
125
+ buildHeaderValue(structured: StructuredHeaderValue): string;
126
+ /**
127
+ * Parses a header value with key=value arguments into a structured
128
+ * object.
129
+ *
130
+ * parseHeaderValue('text/plain; CHARSET=UTF-8') ->
131
+ * {
132
+ * 'value': 'text/plain',
133
+ * 'params': {
134
+ * 'charset': 'UTF-8'
135
+ * }
136
+ * }
137
+ *
138
+ * The result also carries a non-enumerable `decodedParams` array that names the params
139
+ * assembled from rfc2231 segments (title*=, title*0*=, title*0=). Those values are already
140
+ * decoded, so a caller that runs decodeWords() over the params has to leave them out
141
+ *
142
+ * @param {String} str Header value
143
+ * @return {Object} Header value as a parsed structure
144
+ */
145
+ parseHeaderValue(str: string): ParsedHeaderValue;
146
+ /**
147
+ * Encodes a string or an Buffer to an UTF-8 Parameter Value Continuation encoding (rfc2231)
148
+ * Useful for splitting long parameter values.
149
+ *
150
+ * For example
151
+ * title="unicode string"
152
+ * becomes
153
+ * title*0*=utf-8''unicode
154
+ * title*1*=%20string
155
+ *
156
+ * @param {String} key Parameter name (eg. 'filename')
157
+ * @param {String|Buffer} data String to be encoded
158
+ * @param {Number} [maxLength=50] Max length for generated chunks
159
+ * @param {String} [fromCharset='UTF-8'] Source character set
160
+ * @return {Array} A list of encoded keys and headers
161
+ */
162
+ buildHeaderParam(key: string, data: unknown, maxLength?: number, fromCharset?: string): HeaderParam[];
163
+ /**
164
+ * Returns file extension for a content type string. If no suitable extensions
165
+ * are found, 'bin' is used as the default extension
166
+ *
167
+ * @param {String} mimeType Content type to be checked for
168
+ * @return {String} File extension
169
+ */
170
+ detectExtension(input: unknown): string;
171
+ /**
172
+ * Returns content type for a file extension. If no suitable content types
173
+ * are found, 'application/octet-stream' is used as the default content type
174
+ *
175
+ * @param {String} extension Extension (or filename) to be checked for
176
+ * @return {String} Content type
177
+ */
178
+ detectMimeType(input: unknown): string;
179
+ /**
180
+ * Folds long lines, useful for folding header lines (afterSpace=false) and
181
+ * flowed text (afterSpace=true)
182
+ *
183
+ * @param {String} str String to be folded
184
+ * @param {Number} [lineLength=76] Maximum length of a line
185
+ * @param {Boolean} afterSpace If true, leave a space in the end of a line
186
+ * @return {String} String with folded lines
187
+ */
188
+ foldLines(input: unknown, lineLength?: number, afterSpace?: boolean): string;
189
+ /**
190
+ * Splits a mime encoded string. Needed for dividing mime words into smaller chunks
191
+ *
192
+ * @param {String} str Mime encoded string to be split up
193
+ * @param {Number} maxlen Maximum length of characters for one part (minimum 12)
194
+ * @return {Array} Split string
195
+ */
196
+ splitMimeEncodedString(str: string, maxlen?: number): string[];
197
+ encodeURICharComponent(chr: string): string;
198
+ safeEncodeURIComponent(input: unknown): string;
199
+ }
200
+ /**
201
+ * The shared instance, the default export of the package. The class is attached to it as `Libmime`,
202
+ * so `require('libmime').Libmime` keeps working
203
+ */
204
+ declare const libmime: Libmime & {
205
+ Libmime: typeof Libmime;
206
+ };
207
+ type LibmimeInstance = Libmime;
208
+ declare namespace libmime {
209
+ type Libmime = LibmimeInstance;
210
+ type HeaderLine = types.HeaderLine;
211
+ type HeaderObject = types.HeaderObject;
212
+ type HeaderParam = types.HeaderParam;
213
+ type LibmimeConfig = types.LibmimeConfig;
214
+ type MimeWordEncoding = types.MimeWordEncoding;
215
+ type ParsedHeaderValue = types.ParsedHeaderValue;
216
+ type StructuredHeader = types.StructuredHeader;
217
+ type StructuredHeaderValue = types.StructuredHeaderValue;
218
+ }
219
+ export default libmime;