imapflow 2.5.6 → 2.5.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.5.8](https://github.com/postalsys/imapflow/compare/v2.5.7...v2.5.8) (2026-10-19)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * use the bundled libmime, libqp, libbase64 and encoding-japanese types ([c1e2e32](https://github.com/postalsys/imapflow/commit/c1e2e328cf0f7926895a83f08640f1b0a4619997))
9
+
10
+ ## [2.5.7](https://github.com/postalsys/imapflow/compare/v2.5.6...v2.5.7) (2026-10-19)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * bump libmime to 5.5.2 ([8f0f6f7](https://github.com/postalsys/imapflow/commit/8f0f6f7818c0afd601f5e86e8d8b510733162a42))
16
+
3
17
  ## [2.5.6](https://github.com/postalsys/imapflow/compare/v2.5.5...v2.5.6) (2026-10-19)
4
18
 
5
19
 
@@ -4,9 +4,49 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.JPDecoder = void 0;
7
+ exports.toJapaneseEncoding = toJapaneseEncoding;
7
8
  const node_stream_1 = require("node:stream");
8
9
  const encoding_japanese_1 = __importDefault(require("encoding-japanese"));
9
10
  const limited_passthrough_js_1 = require("./limited-passthrough.js");
11
+ const ENCODING_NAMES = new Set([
12
+ 'UTF32',
13
+ 'UTF16',
14
+ 'UTF16BE',
15
+ 'UTF16LE',
16
+ 'BINARY',
17
+ 'ASCII',
18
+ 'JIS',
19
+ 'UTF8',
20
+ 'EUCJP',
21
+ 'SJIS',
22
+ 'UNICODE'
23
+ ]);
24
+ /**
25
+ * Maps a MIME charset label onto the encoding name encoding-japanese expects.
26
+ *
27
+ * getDecoder() routes the ISO-2022-JP, JIS and EUC-JP families here, including variant labels such
28
+ * as "iso-2022-jp-2" or "euc-jp-ms", and each family maps to the one decoder the library has for it.
29
+ * Shift_JIS labels are mapped too, so the class stays usable on its own. Anything else is left for
30
+ * the library to detect from the bytes.
31
+ *
32
+ * @internal
33
+ */
34
+ function toJapaneseEncoding(charset) {
35
+ const name = charset.toUpperCase().replace(/[^A-Z0-9]+/g, '');
36
+ if (ENCODING_NAMES.has(name)) {
37
+ return name;
38
+ }
39
+ if (/^EUC/.test(name)) {
40
+ return 'EUCJP';
41
+ }
42
+ if (/^(JIS|ISO2022JP)/.test(name)) {
43
+ return 'JIS';
44
+ }
45
+ if (/^(SHIFTJIS|XSJIS|CP932|MSKANJI|WINDOWS31J)/.test(name)) {
46
+ return 'SJIS';
47
+ }
48
+ return 'AUTO';
49
+ }
10
50
  // A Transform stream for decoding Japanese character sets (Shift_JIS, EUC-JP, ISO-2022-JP).
11
51
  // Unlike iconv-lite which can decode incrementally, encoding-japanese requires the complete
12
52
  // input buffer for accurate charset detection and stateful decoding (especially ISO-2022-JP
@@ -56,13 +96,10 @@ class JPDecoder extends node_stream_1.Transform {
56
96
  try {
57
97
  let output = encoding_japanese_1.default.convert(input, {
58
98
  to: 'UNICODE', // to_encoding
59
- from: this.charset, // from_encoding
99
+ from: toJapaneseEncoding(this.charset), // from_encoding
60
100
  type: 'string'
61
101
  });
62
- if (typeof output === 'string') {
63
- output = Buffer.from(output);
64
- }
65
- this.push(output);
102
+ this.push(Buffer.from(output));
66
103
  }
67
104
  catch {
68
105
  // keep as is on errors
@@ -1,3 +1,3 @@
1
1
  export declare const name = "imapflow";
2
- export declare const version = "2.5.6";
2
+ export declare const version = "2.5.8";
3
3
  export declare const homepage = "https://imapflow.com/";
@@ -3,5 +3,5 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.homepage = exports.version = exports.name = void 0;
5
5
  exports.name = "imapflow";
6
- exports.version = "2.5.6";
6
+ exports.version = "2.5.8";
7
7
  exports.homepage = "https://imapflow.com/";
@@ -1,6 +1,45 @@
1
1
  import { Transform } from 'node:stream';
2
2
  import encodingJapanese from 'encoding-japanese';
3
3
  import { normalizeByteLimit } from './limited-passthrough.js';
4
+ const ENCODING_NAMES = new Set([
5
+ 'UTF32',
6
+ 'UTF16',
7
+ 'UTF16BE',
8
+ 'UTF16LE',
9
+ 'BINARY',
10
+ 'ASCII',
11
+ 'JIS',
12
+ 'UTF8',
13
+ 'EUCJP',
14
+ 'SJIS',
15
+ 'UNICODE'
16
+ ]);
17
+ /**
18
+ * Maps a MIME charset label onto the encoding name encoding-japanese expects.
19
+ *
20
+ * getDecoder() routes the ISO-2022-JP, JIS and EUC-JP families here, including variant labels such
21
+ * as "iso-2022-jp-2" or "euc-jp-ms", and each family maps to the one decoder the library has for it.
22
+ * Shift_JIS labels are mapped too, so the class stays usable on its own. Anything else is left for
23
+ * the library to detect from the bytes.
24
+ *
25
+ * @internal
26
+ */
27
+ export function toJapaneseEncoding(charset) {
28
+ const name = charset.toUpperCase().replace(/[^A-Z0-9]+/g, '');
29
+ if (ENCODING_NAMES.has(name)) {
30
+ return name;
31
+ }
32
+ if (/^EUC/.test(name)) {
33
+ return 'EUCJP';
34
+ }
35
+ if (/^(JIS|ISO2022JP)/.test(name)) {
36
+ return 'JIS';
37
+ }
38
+ if (/^(SHIFTJIS|XSJIS|CP932|MSKANJI|WINDOWS31J)/.test(name)) {
39
+ return 'SJIS';
40
+ }
41
+ return 'AUTO';
42
+ }
4
43
  // A Transform stream for decoding Japanese character sets (Shift_JIS, EUC-JP, ISO-2022-JP).
5
44
  // Unlike iconv-lite which can decode incrementally, encoding-japanese requires the complete
6
45
  // input buffer for accurate charset detection and stateful decoding (especially ISO-2022-JP
@@ -50,13 +89,10 @@ export class JPDecoder extends Transform {
50
89
  try {
51
90
  let output = encodingJapanese.convert(input, {
52
91
  to: 'UNICODE', // to_encoding
53
- from: this.charset, // from_encoding
92
+ from: toJapaneseEncoding(this.charset), // from_encoding
54
93
  type: 'string'
55
94
  });
56
- if (typeof output === 'string') {
57
- output = Buffer.from(output);
58
- }
59
- this.push(output);
95
+ this.push(Buffer.from(output));
60
96
  }
61
97
  catch {
62
98
  // keep as is on errors
@@ -1,3 +1,3 @@
1
1
  export declare const name = "imapflow";
2
- export declare const version = "2.5.6";
2
+ export declare const version = "2.5.8";
3
3
  export declare const homepage = "https://imapflow.com/";
@@ -1,4 +1,4 @@
1
1
  // Generated by scripts/build.js from package.json. Do not edit by hand.
2
2
  export const name = "imapflow";
3
- export const version = "2.5.6";
3
+ export const version = "2.5.8";
4
4
  export const homepage = "https://imapflow.com/";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "imapflow",
3
- "version": "2.5.6",
3
+ "version": "2.5.8",
4
4
  "description": "IMAP Client for Node",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/imap-flow.js",
@@ -40,6 +40,8 @@
40
40
  "test": "node --import tsx --test --test-force-exit --test-concurrency=1 $(find test -name '*-test.ts' -not -path '*/integration/*' -not -path '*/cloudflare/*' -not -path '*/celld/*' -not -path '*/browser/*')",
41
41
  "pretest:coverage": "npm run build",
42
42
  "test:coverage": "c8 node --import tsx --test --test-force-exit --test-concurrency=1 $(find test -name '*-test.ts' -not -path '*/integration/*' -not -path '*/cloudflare/*' -not -path '*/celld/*' -not -path '*/browser/*')",
43
+ "pretest:cjs": "npm run build",
44
+ "test:cjs": "NODE_OPTIONS=--no-experimental-require-module node test/package/cjs-smoke.cjs",
43
45
  "pretest:bun": "npm run build",
44
46
  "test:bun": "bun test --timeout 60000 $(find ./test -name '*-test.ts' -not -path '*/integration/*' -not -path '*/cloudflare/*' -not -path '*/celld/*' -not -path '*/browser/*')",
45
47
  "pretest:workers": "npm run build",
@@ -92,14 +94,14 @@
92
94
  "types-node-legacy": "npm:@types/node@20.0.0",
93
95
  "typescript": "6.0.3",
94
96
  "typescript-eslint": "8.71.2",
95
- "wrangler": "4.151.1"
97
+ "wrangler": "4.151.2"
96
98
  },
97
99
  "dependencies": {
98
- "@zone-eu/mailsplit": "5.4.26",
100
+ "@zone-eu/mailsplit": "5.4.27",
99
101
  "encoding-japanese": "2.4.0",
100
102
  "iconv-lite": "0.7.3",
101
103
  "libbase64": "1.4.1",
102
- "libmime": "5.5.1",
104
+ "libmime": "5.5.2",
103
105
  "libqp": "3.0.1",
104
106
  "pino": "10.3.1",
105
107
  "socks": "2.8.10"