@hyperbytes/wappler-imap-manager 1.0.6 → 1.1.1

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/LICENSE.md CHANGED
@@ -5,10 +5,10 @@ Copyright (c) 2025 Brian English
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
7
7
  in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ to use, copy, modify, merge, publish, distribute, sublicense, BUT NOT TO sell
9
9
  copies of the Software, and to permit persons to whom the Software is
10
10
  furnished to do so, subject to the following conditions:
11
-
11
+ Sale of this code requires the permission of the copyright holder.
12
12
  The above copyright notice and this permission notice shall be included in all
13
13
  copies or substantial portions of the Software.
14
14
 
package/package.json CHANGED
@@ -1,18 +1,14 @@
1
1
  {
2
2
  "name": "@hyperbytes/wappler-imap-manager",
3
- "version": "1.0.6",
3
+ "version": "1.1.1",
4
4
  "description": "IMAP eMail Management for Wappler",
5
- "license": "MIT",
5
+ "license": "Restricted MIT",
6
6
  "author": {
7
7
  "name": "Brian English - @hyperbytes"
8
8
  },
9
9
  "keywords": [
10
- "wappler-extension",
11
- "server-connect",
12
10
  "IMAP",
13
- "email",
14
- "wappler",
15
- "node"
11
+ "email"
16
12
  ],
17
13
  "dependencies": {
18
14
  "imap": "^0.8.0",
@@ -46,7 +46,11 @@ exports.imapcount = async function (options, name) {
46
46
  password: IMAP_PASSWORD,
47
47
  host: IMAP_HOST,
48
48
  port: IMAP_PORT,
49
- tls: IMAP_TLS
49
+ tls: IMAP_TLS,
50
+ tlsOptions: {
51
+ rejectUnauthorized: process.env.IMAP_CERTIFICATE_OVERRIDE === '1' ? false : true
52
+ }
53
+
50
54
  };
51
55
 
52
56
  return getEmailCount(config, mailbox);
@@ -18,6 +18,10 @@ exports.imapcreatefolder = async function (options) {
18
18
  host: IMAP_HOST,
19
19
  port: IMAP_PORT,
20
20
  tls: IMAP_TLS,
21
+ tlsOptions: {
22
+ rejectUnauthorized: process.env.IMAP_CERTIFICATE_OVERRIDE === '1' ? false : true
23
+ }
24
+
21
25
  });
22
26
 
23
27
 
@@ -66,7 +66,11 @@ exports.imapdelete = async function (options, name) {
66
66
  password: IMAP_PASSWORD,
67
67
  host: IMAP_HOST,
68
68
  port: IMAP_PORT,
69
- tls: IMAP_TLS
69
+ tls: IMAP_TLS,
70
+ tlsOptions: {
71
+ rejectUnauthorized: process.env.IMAP_CERTIFICATE_OVERRIDE === '1' ? false : true
72
+ }
73
+
70
74
  };
71
75
 
72
76
  return deleteEmail(config, uid, uidvalidity);
@@ -21,6 +21,10 @@ exports.imapdeletefolder = async function (options) {
21
21
  host: IMAP_HOST,
22
22
  port: IMAP_PORT,
23
23
  tls: IMAP_TLS,
24
+ tlsOptions: {
25
+ rejectUnauthorized: process.env.IMAP_CERTIFICATE_OVERRIDE === '1' ? false : true
26
+ }
27
+
24
28
  });
25
29
 
26
30
  imap.connect();
@@ -15,7 +15,11 @@ exports.imapdirlist = async function (options) {
15
15
  password: IMAP_PASSWORD,
16
16
  host: IMAP_HOST,
17
17
  port: IMAP_PORT,
18
- tls: IMAP_TLS
18
+ tls: IMAP_TLS,
19
+ tlsOptions: {
20
+ rejectUnauthorized: process.env.IMAP_CERTIFICATE_OVERRIDE === '1' ? false : true
21
+ }
22
+
19
23
  });
20
24
 
21
25
  imap.once('ready', () => {
@@ -54,7 +54,11 @@ exports.imapexpunge = async function (options, name) {
54
54
  password: IMAP_PASSWORD,
55
55
  host: IMAP_HOST,
56
56
  port: IMAP_PORT,
57
- tls: IMAP_TLS
57
+ tls: IMAP_TLS,
58
+ tlsOptions: {
59
+ rejectUnauthorized: process.env.IMAP_CERTIFICATE_OVERRIDE === '1' ? false : true
60
+ }
61
+
58
62
  };
59
63
 
60
64
  return expungeEmail(config);
@@ -67,9 +67,14 @@ exports.imapflag = async function (options, name) {
67
67
  password: IMAP_PASSWORD,
68
68
  host: IMAP_HOST,
69
69
  port: IMAP_PORT,
70
- tls: IMAP_TLS
70
+ tls: IMAP_TLS,
71
+ tlsOptions: {
72
+ rejectUnauthorized: process.env.IMAP_CERTIFICATE_OVERRIDE === '1' ? false : true
73
+ }
74
+
71
75
  };
72
76
 
77
+
73
78
  return flagEmail(config, uid, mailbox, uidvalidity);
74
79
  };
75
80
 
@@ -31,7 +31,11 @@ exports.imapgetattachments = async function (options, name) {
31
31
  password: IMAP_PASSWORD,
32
32
  host: IMAP_HOST,
33
33
  port: IMAP_PORT,
34
- tls: true
34
+ tls: true,
35
+ tlsOptions: {
36
+ rejectUnauthorized: process.env.IMAP_CERTIFICATE_OVERRIDE === '1' ? false : true
37
+ }
38
+
35
39
  });
36
40
 
37
41
  imap.once('ready', () => {
@@ -44,7 +48,7 @@ exports.imapgetattachments = async function (options, name) {
44
48
  // Validate UIDVALIDITY before proceeding
45
49
  if (Number(box.uidvalidity) !== Number(uidvalidity)) {
46
50
  imap.end();
47
- return resolve({ savedFiles: [], message: "UID Validity mismatch", url: '', path: '', status: 401 });
51
+ return resolve({ savedFiles: [], message: "UID Validity mismatch", url: '', path: '', status: 400 });
48
52
  }
49
53
 
50
54
  const fetch = imap.fetch(uid, { bodies: '', struct: true });
@@ -60,7 +64,7 @@ exports.imapgetattachments = async function (options, name) {
60
64
 
61
65
  if (!parsed.attachments || parsed.attachments.length === 0) {
62
66
  imap.end();
63
- return resolve({ savedFiles: [], message: "No Attachments Found", url: returnPath, path: sentPath, status: 200 });
67
+ return resolve("{ savedFiles: [], message: 'No Attachments Found', url: returnPath, path: sentPath, status: 200 }".toJSON);
64
68
  }
65
69
 
66
70
  const savedFiles = [];
@@ -20,6 +20,10 @@ exports.imapgetrawheaders = async function (options) {
20
20
  host: IMAP_HOST,
21
21
  port: IMAP_PORT,
22
22
  tls: IMAP_TLS,
23
+ tlsOptions: {
24
+ rejectUnauthorized: process.env.IMAP_CERTIFICATE_OVERRIDE === '1' ? false : true
25
+ }
26
+
23
27
  });
24
28
 
25
29
  imap.once('error', (err) => {
@@ -14,7 +14,11 @@ exports.imapgetuidvalidity = async function (options, name) {
14
14
  password: IMAP_PASSWORD,
15
15
  host: IMAP_HOST,
16
16
  port: IMAP_PORT,
17
- tls: IMAP_TLS
17
+ tls: IMAP_TLS,
18
+ tlsOptions: {
19
+ rejectUnauthorized: process.env.IMAP_CERTIFICATE_OVERRIDE === '1' ? false : true
20
+ }
21
+
18
22
  });
19
23
 
20
24
  imap.once('ready', () => {
@@ -18,7 +18,11 @@ exports.imapmailcontent = async function (options, name) {
18
18
  password: IMAP_PASSWORD,
19
19
  host: IMAP_HOST,
20
20
  port: IMAP_PORT,
21
- tls: true
21
+ tls: true,
22
+ tlsOptions: {
23
+ rejectUnauthorized: process.env.IMAP_CERTIFICATE_OVERRIDE === '1' ? false : true
24
+ }
25
+
22
26
  };
23
27
 
24
28
  const imap = new Imap(imapConfig);
@@ -19,6 +19,10 @@ exports.imapmailheaders = async function (options, name) {
19
19
  host: IMAP_HOST,
20
20
  port: IMAP_PORT,
21
21
  tls: IMAP_TLS,
22
+ tlsOptions: {
23
+ rejectUnauthorized: process.env.IMAP_CERTIFICATE_OVERRIDE === '1' ? false : true
24
+ }
25
+
22
26
  });
23
27
 
24
28
  const messages = [];
@@ -19,7 +19,11 @@ exports.imapmovefolder = async function (options) {
19
19
  password: IMAP_PASSWORD,
20
20
  host: IMAP_HOST,
21
21
  port: IMAP_PORT,
22
- tls: IMAP_TLS
22
+ tls: IMAP_TLS,
23
+ tlsOptions: {
24
+ rejectUnauthorized: process.env.IMAP_CERTIFICATE_OVERRIDE === '1' ? false : true
25
+ }
26
+
23
27
  });
24
28
 
25
29
  imap.once('ready', () => {
@@ -19,7 +19,11 @@ exports.imapremoveflag = async function (options, name) {
19
19
  password: IMAP_PASSWORD,
20
20
  host: IMAP_HOST,
21
21
  port: IMAP_PORT,
22
- tls: IMAP_TLS
22
+ tls: IMAP_TLS,
23
+ tlsOptions: {
24
+ rejectUnauthorized: process.env.IMAP_CERTIFICATE_OVERRIDE === '1' ? false : true
25
+ }
26
+
23
27
  };
24
28
 
25
29
  const removeFlagFromEmail = (uid, flagName, mailboxName, expectedUidValidity) => {
@@ -71,7 +71,9 @@ exports.imapsaveasdraft = async function (options) {
71
71
  host: IMAP_HOST,
72
72
  port: IMAP_PORT,
73
73
  tls: IMAP_TLS,
74
- tlsOptions: { rejectUnauthorized: false },
74
+ tlsOptions: {
75
+ rejectUnauthorized: process.env.IMAP_CERTIFICATE_OVERRIDE === '1' ? false : true
76
+ },
75
77
  authTimeout: 5000
76
78
  }
77
79
  };
@@ -114,6 +114,10 @@ async function saveToSentFolder(options, mailOptions) {
114
114
  host: process.env.IMAP_HOST,
115
115
  port: process.env.IMAP_PORT,
116
116
  tls: true,
117
+ tlsOptions: {
118
+ rejectUnauthorized: process.env.IMAP_CERTIFICATE_OVERRIDE === '1' ? false : true
119
+ }
120
+
117
121
  };
118
122
 
119
123
  let emailContent = `From: ${mailOptions.from}
@@ -8,7 +8,11 @@ exports.imapgetrawheaders = async function (options) {
8
8
  password: options.imap_password,
9
9
  host: options.imap_host,
10
10
  port: options.imap_port,
11
- tls: true
11
+ tls: true,
12
+ tlsOptions: {
13
+ rejectUnauthorized: process.env.IMAP_CERTIFICATE_OVERRIDE === '1' ? false : true
14
+ }
15
+
12
16
  });
13
17
 
14
18
  imap.once('ready', () => {
@@ -15,7 +15,11 @@ exports.imapsubscribe = async function (options) {
15
15
  password: IMAP_PASSWORD,
16
16
  host: IMAP_HOST,
17
17
  port: IMAP_PORT,
18
- tls: IMAP_TLS
18
+ tls: IMAP_TLS,
19
+ tlsOptions: {
20
+ rejectUnauthorized: process.env.IMAP_CERTIFICATE_OVERRIDE === '1' ? false : true
21
+ }
22
+
19
23
  });
20
24
 
21
25
  imap.once('ready', () => {
@@ -14,7 +14,11 @@ exports.imapsubscribedlist = async function (options) {
14
14
  password: IMAP_PASSWORD,
15
15
  host: IMAP_HOST,
16
16
  port: IMAP_PORT,
17
- tls: IMAP_TLS
17
+ tls: IMAP_TLS,
18
+ tlsOptions: {
19
+ rejectUnauthorized: process.env.IMAP_CERTIFICATE_OVERRIDE === '1' ? false : true
20
+ }
21
+
18
22
  });
19
23
 
20
24
  imap.once('ready', () => {
@@ -14,7 +14,11 @@ exports.imaptrashperms = async function () {
14
14
  password: IMAP_PASSWORD,
15
15
  host: IMAP_HOST,
16
16
  port: IMAP_PORT,
17
- tls: IMAP_TLS
17
+ tls: IMAP_TLS,
18
+ tlsOptions: {
19
+ rejectUnauthorized: process.env.IMAP_CERTIFICATE_OVERRIDE === '1' ? false : true
20
+ }
21
+
18
22
  });
19
23
 
20
24
  imap.once('ready', () => {
@@ -13,7 +13,11 @@ exports.imapunsubscribedlist = async function (options) {
13
13
  password: IMAP_PASSWORD,
14
14
  host: IMAP_HOST,
15
15
  port: IMAP_PORT,
16
- tls: IMAP_TLS
16
+ tls: IMAP_TLS,
17
+ tlsOptions: {
18
+ rejectUnauthorized: process.env.IMAP_CERTIFICATE_OVERRIDE === '1' ? false : true
19
+ }
20
+
17
21
  });
18
22
 
19
23
  imap.once('ready', () => {