@n8n/imap 0.8.19 → 0.9.0

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 (44) hide show
  1. package/LICENSE.md +88 -0
  2. package/LICENSE_EE.md +27 -0
  3. package/dist/ImapSimple.d.ts +16 -0
  4. package/dist/ImapSimple.js +120 -0
  5. package/dist/ImapSimple.js.map +1 -0
  6. package/dist/PartData.d.ts +24 -0
  7. package/dist/PartData.js +109 -0
  8. package/dist/PartData.js.map +1 -0
  9. package/dist/build.tsbuildinfo +1 -0
  10. package/dist/errors.d.ts +12 -0
  11. package/dist/errors.js +30 -0
  12. package/dist/errors.js.map +1 -0
  13. package/dist/helpers/getMessage.d.ts +3 -0
  14. package/dist/helpers/getMessage.js +37 -0
  15. package/dist/helpers/getMessage.js.map +1 -0
  16. package/dist/index.d.ts +7 -0
  17. package/dist/index.js +85 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/types.d.ts +30 -0
  20. package/dist/types.js +3 -0
  21. package/dist/types.js.map +1 -0
  22. package/package.json +42 -18
  23. package/LICENSE +0 -19
  24. package/README.md +0 -754
  25. package/deps/encoding/encoding-indexes.js +0 -73
  26. package/deps/encoding/encoding.js +0 -2340
  27. package/deps/test/utf7-imap.js +0 -48
  28. package/deps/test/utf7-rfc2152.js +0 -78
  29. package/deps/utf7.js +0 -104
  30. package/index.d.ts +0 -396
  31. package/lib/Connection.js +0 -2131
  32. package/lib/Parser.js +0 -1026
  33. package/test/test-connection-fetch-dup.js +0 -92
  34. package/test/test-connection-fetch-frag.js +0 -92
  35. package/test/test-connection-fetch-spillover.js +0 -176
  36. package/test/test-connection-fetch-stringbody.js +0 -104
  37. package/test/test-connection-idle-normal.js +0 -144
  38. package/test/test-connection-idle-order.js +0 -138
  39. package/test/test-parse-bodystructure.js +0 -83
  40. package/test/test-parse-envelope-addrs.js +0 -117
  41. package/test/test-parse-expr.js +0 -92
  42. package/test/test-parse-header.js +0 -109
  43. package/test/test-parser.js +0 -543
  44. package/test/test.js +0 -4
package/dist/index.js ADDED
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.connect = connect;
21
+ exports.getParts = getParts;
22
+ const imap_1 = __importDefault(require("imap"));
23
+ const errors_1 = require("./errors");
24
+ const ImapSimple_1 = require("./ImapSimple");
25
+ async function connect(options) {
26
+ const authTimeout = options.imap.authTimeout ?? 2000;
27
+ options.imap.authTimeout = authTimeout;
28
+ const imap = new imap_1.default(options.imap);
29
+ return await new Promise((resolve, reject) => {
30
+ const cleanUp = () => {
31
+ imap.removeListener('ready', imapOnReady);
32
+ imap.removeListener('error', imapOnError);
33
+ imap.removeListener('close', imapOnClose);
34
+ imap.removeListener('end', imapOnEnd);
35
+ };
36
+ const imapOnReady = () => {
37
+ cleanUp();
38
+ resolve(new ImapSimple_1.ImapSimple(imap));
39
+ };
40
+ const imapOnError = (e) => {
41
+ if (e.source === 'timeout-auth') {
42
+ e = new errors_1.ConnectionTimeoutError(authTimeout);
43
+ }
44
+ cleanUp();
45
+ reject(e);
46
+ };
47
+ const imapOnEnd = () => {
48
+ cleanUp();
49
+ reject(new errors_1.ConnectionEndedError());
50
+ };
51
+ const imapOnClose = () => {
52
+ cleanUp();
53
+ reject(new errors_1.ConnectionClosedError());
54
+ };
55
+ imap.once('ready', imapOnReady);
56
+ imap.once('error', imapOnError);
57
+ imap.once('close', imapOnClose);
58
+ imap.once('end', imapOnEnd);
59
+ if (options.onMail) {
60
+ imap.on('mail', options.onMail);
61
+ }
62
+ if (options.onExpunge) {
63
+ imap.on('expunge', options.onExpunge);
64
+ }
65
+ if (options.onUpdate) {
66
+ imap.on('update', options.onUpdate);
67
+ }
68
+ imap.connect();
69
+ });
70
+ }
71
+ function getParts(struct, parts = []) {
72
+ for (let i = 0; i < struct.length; i++) {
73
+ if (Array.isArray(struct[i])) {
74
+ getParts(struct[i], parts);
75
+ }
76
+ else if (struct[i].partID) {
77
+ parts.push(struct[i]);
78
+ }
79
+ }
80
+ return parts;
81
+ }
82
+ __exportStar(require("./ImapSimple"), exports);
83
+ __exportStar(require("./errors"), exports);
84
+ __exportStar(require("./types"), exports);
85
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAWA,0BAyDC;AAYD,4BAeC;AA7FD,gDAAwB;AAExB,qCAA+F;AAC/F,6CAA0C;AAMnC,KAAK,UAAU,OAAO,CAAC,OAA0B;IACvD,MAAM,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC;IACrD,OAAO,CAAC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IAEvC,MAAM,IAAI,GAAG,IAAI,cAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpC,OAAO,MAAM,IAAI,OAAO,CAAa,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACxD,MAAM,OAAO,GAAG,GAAG,EAAE;YACpB,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,WAAW,CAA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,OAAO,CAAC,SAAS,EAAE,CAAC;YACvB,IAAI,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;QACvC,CAAC;QAED,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;YACtB,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;QACrC,CAAC;QAED,IAAI,CAAC,OAAO,EAAE,CAAC;IAChB,CAAC,CAAC,CAAC;AACJ,CAAC;AAYD,SAAgB,QAAQ,CAGvB,MAAW,EAEX,QAAuB,EAAE;IAEzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACxC,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC9B,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;QAC5B,CAAC;aAAM,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;YAC7B,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAgB,CAAC,CAAC;QACtC,CAAC;IACF,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AAED,+CAA6B;AAC7B,2CAAyB;AACzB,0CAAwB"}
@@ -0,0 +1,30 @@
1
+ import type { Config, ImapMessageBodyInfo, ImapMessageAttributes } from 'imap';
2
+ export interface ImapSimpleOptions {
3
+ imap: Config;
4
+ onMail?: ((numNewMail: number) => void) | undefined;
5
+ onExpunge?: ((seqNo: number) => void) | undefined;
6
+ onUpdate?: ((seqNo: number, info: {
7
+ num: number | undefined;
8
+ text: unknown;
9
+ }) => void) | undefined;
10
+ }
11
+ export interface MessagePart {
12
+ partID: string;
13
+ encoding: 'BASE64' | 'QUOTED-PRINTABLE' | '7BIT' | '8BIT' | 'BINARY' | 'UUENCODE';
14
+ type: 'TEXT';
15
+ subtype: string;
16
+ params?: {
17
+ charset?: string;
18
+ };
19
+ disposition?: {
20
+ type: string;
21
+ };
22
+ }
23
+ export interface MessageBodyPart extends ImapMessageBodyInfo {
24
+ body: string | object;
25
+ }
26
+ export interface Message {
27
+ attributes: ImapMessageAttributes;
28
+ parts: MessageBodyPart[];
29
+ seqNo?: number;
30
+ }
package/dist/types.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,24 +1,48 @@
1
1
  {
2
2
  "name": "@n8n/imap",
3
- "version": "0.8.19",
4
- "description": "An IMAP module for node.js that makes communicating with IMAP servers easy",
5
- "main": "./lib/Connection",
6
- "types": "index.d.ts",
7
- "packageManager": "pnpm@9.6.0",
3
+ "version": "0.9.0",
4
+ "main": "dist/index.js",
5
+ "module": "src/index.ts",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist/**/*",
9
+ "LICENSE.md",
10
+ "LICENSE_EE.md"
11
+ ],
12
+ "dependencies": {
13
+ "iconv-lite": "0.6.3",
14
+ "imap": "0.8.19",
15
+ "quoted-printable": "1.0.1",
16
+ "utf8": "3.0.0",
17
+ "uuencode": "0.0.4"
18
+ },
8
19
  "devDependencies": {
9
- "tape": "~5.9.0"
20
+ "@types/imap": "^0.8.40",
21
+ "@types/quoted-printable": "^1.0.2",
22
+ "@types/utf8": "^3.0.3",
23
+ "@types/uuencode": "^0.0.3",
24
+ "@n8n/typescript-config": "1.2.0"
10
25
  },
11
- "scripts": {
12
- "test": "node test/test.js && tape deps/test/*.js"
26
+ "license": "SEE LICENSE IN LICENSE.md",
27
+ "homepage": "https://n8n.io",
28
+ "author": {
29
+ "name": "Jan Oberhauser",
30
+ "email": "jan@n8n.io"
13
31
  },
14
- "engines": {
15
- "node": ">=18.0.0"
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "git+https://github.com/n8n-io/n8n.git"
16
35
  },
17
- "keywords": [
18
- "imap",
19
- "mail",
20
- "email",
21
- "reader",
22
- "client"
23
- ]
24
- }
36
+ "scripts": {
37
+ "clean": "rimraf dist .turbo",
38
+ "dev": "pnpm watch",
39
+ "typecheck": "tsc --noEmit",
40
+ "build": "tsc -p tsconfig.build.json",
41
+ "format": "biome format --write src test",
42
+ "format:check": "biome ci src test",
43
+ "lint": "eslint . --quiet",
44
+ "lintfix": "eslint . --fix",
45
+ "watch": "tsc -p tsconfig.build.json --watch",
46
+ "test": "jest"
47
+ }
48
+ }
package/LICENSE DELETED
@@ -1,19 +0,0 @@
1
- Copyright Brian White. All rights reserved.
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy
4
- of this software and associated documentation files (the "Software"), to
5
- deal in the Software without restriction, including without limitation the
6
- rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7
- sell copies of the Software, and to permit persons to whom the Software is
8
- furnished to do so, subject to the following conditions:
9
-
10
- The above copyright notice and this permission notice shall be included in
11
- all copies or substantial portions of the Software.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19
- IN THE SOFTWARE.