imapflow 1.0.159 → 1.0.161
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 +14 -0
- package/LICENSE.txt +1 -1
- package/README.md +1 -1
- package/lib/imap-flow.js +39 -20
- package/lib/types.d.ts +36 -31
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.0.161](https://github.com/postalsys/imapflow/compare/v1.0.160...v1.0.161) (2024-05-06)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **listTree:** pass listing options as an optional argument ([917ba80](https://github.com/postalsys/imapflow/commit/917ba80f21b2fe485154acd252d6565b838e73e6))
|
|
9
|
+
|
|
10
|
+
## [1.0.160](https://github.com/postalsys/imapflow/compare/v1.0.159...v1.0.160) (2024-04-22)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* **copy:** Updated cipyright year to 2024 ([e3f5040](https://github.com/postalsys/imapflow/commit/e3f5040e8f90523e12108e978ac5002f8caa9e1e))
|
|
16
|
+
|
|
3
17
|
## [1.0.159](https://github.com/postalsys/imapflow/compare/v1.0.158...v1.0.159) (2024-04-12)
|
|
4
18
|
|
|
5
19
|
|
package/LICENSE.txt
CHANGED
package/README.md
CHANGED
package/lib/imap-flow.js
CHANGED
|
@@ -768,7 +768,11 @@ class ImapFlow extends EventEmitter {
|
|
|
768
768
|
this.writeSocket.destroySoon = () => {
|
|
769
769
|
try {
|
|
770
770
|
if (this.socket) {
|
|
771
|
-
this.socket.destroySoon
|
|
771
|
+
if (typeof this.socket.destroySoon === 'function') {
|
|
772
|
+
this.socket.destroySoon();
|
|
773
|
+
} else {
|
|
774
|
+
this.socket.destroy();
|
|
775
|
+
}
|
|
772
776
|
}
|
|
773
777
|
this.writeSocket.end();
|
|
774
778
|
} catch (err) {
|
|
@@ -1480,7 +1484,11 @@ class ImapFlow extends EventEmitter {
|
|
|
1480
1484
|
|
|
1481
1485
|
if (this.writeSocket && !this.writeSocket.destroyed) {
|
|
1482
1486
|
try {
|
|
1483
|
-
this.writeSocket.destroySoon
|
|
1487
|
+
if (typeof this.writeSocket.destroySoon === 'function') {
|
|
1488
|
+
this.writeSocket.destroySoon();
|
|
1489
|
+
} else {
|
|
1490
|
+
this.writeSocket.destroy();
|
|
1491
|
+
}
|
|
1484
1492
|
} catch (err) {
|
|
1485
1493
|
this.log.error({ err, cid: this.id });
|
|
1486
1494
|
}
|
|
@@ -1488,7 +1496,11 @@ class ImapFlow extends EventEmitter {
|
|
|
1488
1496
|
|
|
1489
1497
|
if (this.socket && !this.socket.destroyed && this.writeSocket !== this.socket) {
|
|
1490
1498
|
try {
|
|
1491
|
-
this.socket.destroySoon
|
|
1499
|
+
if (typeof this.socket.destroySoon === 'function') {
|
|
1500
|
+
this.socket.destroySoon();
|
|
1501
|
+
} else {
|
|
1502
|
+
this.socket.destroy();
|
|
1503
|
+
}
|
|
1492
1504
|
} catch (err) {
|
|
1493
1505
|
this.log.error({ err, cid: this.id });
|
|
1494
1506
|
}
|
|
@@ -1532,7 +1544,7 @@ class ImapFlow extends EventEmitter {
|
|
|
1532
1544
|
* @property {String} pathAsListed mailbox path as listed in the LIST/LSUB response
|
|
1533
1545
|
* @property {String} name mailbox name (last part of path after delimiter)
|
|
1534
1546
|
* @property {String} delimiter mailbox path delimiter, usually "." or "/"
|
|
1535
|
-
* @property {
|
|
1547
|
+
* @property {String[]} parent An array of parent folder names. All names are in unicode
|
|
1536
1548
|
* @property {String} parentPath Same as `parent`, but as a complete string path (unicode string)
|
|
1537
1549
|
* @property {Set<string>} flags a set of flags for this mailbox
|
|
1538
1550
|
* @property {String} specialUse one of special-use flags (if applicable): "\All", "\Archive", "\Drafts", "\Flagged", "\Junk", "\Sent", "\Trash". Additionally INBOX has non-standard "\Inbox" flag set
|
|
@@ -1541,22 +1553,27 @@ class ImapFlow extends EventEmitter {
|
|
|
1541
1553
|
* @property {StatusObject} [status] If `statusQuery` was used, then this value includes the status response
|
|
1542
1554
|
*/
|
|
1543
1555
|
|
|
1556
|
+
/**
|
|
1557
|
+
* @typedef {Object} ListOptions
|
|
1558
|
+
* @global
|
|
1559
|
+
* @property {Object} [statusQuery] request status items for every listed entry
|
|
1560
|
+
* @property {Boolean} [statusQuery.messages] if `true` request count of messages
|
|
1561
|
+
* @property {Boolean} [statusQuery.recent] if `true` request count of messages with \\Recent tag
|
|
1562
|
+
* @property {Boolean} [statusQuery.uidNext] if `true` request predicted next UID
|
|
1563
|
+
* @property {Boolean} [statusQuery.uidValidity] if `true` request mailbox `UIDVALIDITY` value
|
|
1564
|
+
* @property {Boolean} [statusQuery.unseen] if `true` request count of unseen messages
|
|
1565
|
+
* @property {Boolean} [statusQuery.highestModseq] if `true` request last known modseq value
|
|
1566
|
+
* @property {Object} [specialUseHints] set specific paths as special use folders, this would override special use flags provided from the server
|
|
1567
|
+
* @property {String} [specialUseHints.sent] Path to "Sent Mail" folder
|
|
1568
|
+
* @property {String} [specialUseHints.trash] Path to "Trash" folder
|
|
1569
|
+
* @property {String} [specialUseHints.junk] Path to "Junk Mail" folder
|
|
1570
|
+
* @property {String} [specialUseHints.drafts] Path to "Drafts" folder
|
|
1571
|
+
*/
|
|
1572
|
+
|
|
1544
1573
|
/**
|
|
1545
1574
|
* Lists available mailboxes as an Array
|
|
1546
1575
|
*
|
|
1547
|
-
* @param {
|
|
1548
|
-
* @param {Object} [options.statusQuery] request status items for every listed entry
|
|
1549
|
-
* @param {Boolean} [options.statusQuery.messages] if `true` request count of messages
|
|
1550
|
-
* @param {Boolean} [options.statusQuery.recent] if `true` request count of messages with \\Recent tag
|
|
1551
|
-
* @param {Boolean} [options.statusQuery.uidNext] if `true` request predicted next UID
|
|
1552
|
-
* @param {Boolean} [options.statusQuery.uidValidity] if `true` request mailbox `UIDVALIDITY` value
|
|
1553
|
-
* @param {Boolean} [options.statusQuery.unseen] if `true` request count of unseen messages
|
|
1554
|
-
* @param {Boolean} [options.statusQuery.highestModseq] if `true` request last known modseq value
|
|
1555
|
-
* @param {Object} [options.specialUseHints] set specific paths as special use folders, this would override special use flags provided from the server
|
|
1556
|
-
* @param {String} [options.specialUseHints.sent] Path to "Sent Mail" folder
|
|
1557
|
-
* @param {String} [options.specialUseHints.trash] Path to "Trash" folder
|
|
1558
|
-
* @param {String} [options.specialUseHints.junk] Path to "Junk Mail" folder
|
|
1559
|
-
* @param {String} [options.specialUseHints.drafts] Path to "Drafts" folder
|
|
1576
|
+
* @param {ListOptions} [options] defines additional listing options
|
|
1560
1577
|
* @returns {Promise<ListResponse[]>} An array of ListResponse objects
|
|
1561
1578
|
*
|
|
1562
1579
|
* @example
|
|
@@ -1577,7 +1594,7 @@ class ImapFlow extends EventEmitter {
|
|
|
1577
1594
|
* @property {String} path mailbox path
|
|
1578
1595
|
* @property {String} name mailbox name (last part of path after delimiter)
|
|
1579
1596
|
* @property {String} delimiter mailbox path delimiter, usually "." or "/"
|
|
1580
|
-
* @property {
|
|
1597
|
+
* @property {String[]} flags list of flags for this mailbox
|
|
1581
1598
|
* @property {String} specialUse one of special-use flags (if applicable): "\All", "\Archive", "\Drafts", "\Flagged", "\Junk", "\Sent", "\Trash". Additionally INBOX has non-standard "\Inbox" flag set
|
|
1582
1599
|
* @property {Boolean} listed `true` if mailbox was found from the output of LIST command
|
|
1583
1600
|
* @property {Boolean} subscribed `true` if mailbox was found from the output of LSUB command
|
|
@@ -1588,14 +1605,16 @@ class ImapFlow extends EventEmitter {
|
|
|
1588
1605
|
/**
|
|
1589
1606
|
* Lists available mailboxes as a tree structured object
|
|
1590
1607
|
*
|
|
1608
|
+
* @param {ListOptions} [options] defines additional listing options
|
|
1591
1609
|
* @returns {Promise<ListTreeResponse>} Tree structured object
|
|
1592
1610
|
*
|
|
1593
1611
|
* @example
|
|
1594
1612
|
* let tree = await client.listTree();
|
|
1595
1613
|
* tree.folders.forEach(mailbox=>console.log(mailbox.path));
|
|
1596
1614
|
*/
|
|
1597
|
-
async listTree() {
|
|
1598
|
-
|
|
1615
|
+
async listTree(options) {
|
|
1616
|
+
options = options || {};
|
|
1617
|
+
let folders = await this.run('LIST', '', '*', options);
|
|
1599
1618
|
this.folders = new Map(folders.map(folder => [folder.path, folder]));
|
|
1600
1619
|
return getFolderTree(folders);
|
|
1601
1620
|
}
|
package/lib/types.d.ts
CHANGED
|
@@ -162,44 +162,18 @@ declare module "imapflow" {
|
|
|
162
162
|
* let list = await client.list();
|
|
163
163
|
* list.forEach(mailbox=>console.log(mailbox.path));
|
|
164
164
|
* @param [options] - defines additional listing options
|
|
165
|
-
* @param [options.statusQuery] - request status items for every listed entry
|
|
166
|
-
* @param [options.statusQuery.messages] - if `true` request count of messages
|
|
167
|
-
* @param [options.statusQuery.recent] - if `true` request count of messages with \\Recent tag
|
|
168
|
-
* @param [options.statusQuery.uidNext] - if `true` request predicted next UID
|
|
169
|
-
* @param [options.statusQuery.uidValidity] - if `true` request mailbox `UIDVALIDITY` value
|
|
170
|
-
* @param [options.statusQuery.unseen] - if `true` request count of unseen messages
|
|
171
|
-
* @param [options.statusQuery.highestModseq] - if `true` request last known modseq value
|
|
172
|
-
* @param [options.specialUseHints] - set specific paths as special use folders, this would override special use flags provided from the server
|
|
173
|
-
* @param [options.specialUseHints.sent] - Path to "Sent Mail" folder
|
|
174
|
-
* @param [options.specialUseHints.trash] - Path to "Trash" folder
|
|
175
|
-
* @param [options.specialUseHints.junk] - Path to "Junk Mail" folder
|
|
176
|
-
* @param [options.specialUseHints.drafts] - Path to "Drafts" folder
|
|
177
165
|
* @returns An array of ListResponse objects
|
|
178
166
|
*/
|
|
179
|
-
list(options?:
|
|
180
|
-
statusQuery?: {
|
|
181
|
-
messages?: boolean;
|
|
182
|
-
recent?: boolean;
|
|
183
|
-
uidNext?: boolean;
|
|
184
|
-
uidValidity?: boolean;
|
|
185
|
-
unseen?: boolean;
|
|
186
|
-
highestModseq?: boolean;
|
|
187
|
-
};
|
|
188
|
-
specialUseHints?: {
|
|
189
|
-
sent?: string;
|
|
190
|
-
trash?: string;
|
|
191
|
-
junk?: string;
|
|
192
|
-
drafts?: string;
|
|
193
|
-
};
|
|
194
|
-
}): Promise<ListResponse[]>;
|
|
167
|
+
list(options?: ListOptions): Promise<ListResponse[]>;
|
|
195
168
|
/**
|
|
196
169
|
* Lists available mailboxes as a tree structured object
|
|
197
170
|
* @example
|
|
198
171
|
* let tree = await client.listTree();
|
|
199
172
|
* tree.folders.forEach(mailbox=>console.log(mailbox.path));
|
|
173
|
+
* @param [options] - defines additional listing options
|
|
200
174
|
* @returns Tree structured object
|
|
201
175
|
*/
|
|
202
|
-
listTree(): Promise<ListTreeResponse>;
|
|
176
|
+
listTree(options?: ListOptions): Promise<ListTreeResponse>;
|
|
203
177
|
/**
|
|
204
178
|
* Performs a no-op call against server
|
|
205
179
|
*/
|
|
@@ -660,7 +634,7 @@ declare type ListResponse = {
|
|
|
660
634
|
pathAsListed: string;
|
|
661
635
|
name: string;
|
|
662
636
|
delimiter: string;
|
|
663
|
-
parent:
|
|
637
|
+
parent: String[];
|
|
664
638
|
parentPath: string;
|
|
665
639
|
flags: Set<string>;
|
|
666
640
|
specialUse: string;
|
|
@@ -669,6 +643,37 @@ declare type ListResponse = {
|
|
|
669
643
|
status?: StatusObject;
|
|
670
644
|
};
|
|
671
645
|
|
|
646
|
+
/**
|
|
647
|
+
* @property [statusQuery] - request status items for every listed entry
|
|
648
|
+
* @property [statusQuery.messages] - if `true` request count of messages
|
|
649
|
+
* @property [statusQuery.recent] - if `true` request count of messages with \\Recent tag
|
|
650
|
+
* @property [statusQuery.uidNext] - if `true` request predicted next UID
|
|
651
|
+
* @property [statusQuery.uidValidity] - if `true` request mailbox `UIDVALIDITY` value
|
|
652
|
+
* @property [statusQuery.unseen] - if `true` request count of unseen messages
|
|
653
|
+
* @property [statusQuery.highestModseq] - if `true` request last known modseq value
|
|
654
|
+
* @property [specialUseHints] - set specific paths as special use folders, this would override special use flags provided from the server
|
|
655
|
+
* @property [specialUseHints.sent] - Path to "Sent Mail" folder
|
|
656
|
+
* @property [specialUseHints.trash] - Path to "Trash" folder
|
|
657
|
+
* @property [specialUseHints.junk] - Path to "Junk Mail" folder
|
|
658
|
+
* @property [specialUseHints.drafts] - Path to "Drafts" folder
|
|
659
|
+
*/
|
|
660
|
+
declare type ListOptions = {
|
|
661
|
+
statusQuery?: {
|
|
662
|
+
messages?: boolean;
|
|
663
|
+
recent?: boolean;
|
|
664
|
+
uidNext?: boolean;
|
|
665
|
+
uidValidity?: boolean;
|
|
666
|
+
unseen?: boolean;
|
|
667
|
+
highestModseq?: boolean;
|
|
668
|
+
};
|
|
669
|
+
specialUseHints?: {
|
|
670
|
+
sent?: string;
|
|
671
|
+
trash?: string;
|
|
672
|
+
junk?: string;
|
|
673
|
+
drafts?: string;
|
|
674
|
+
};
|
|
675
|
+
};
|
|
676
|
+
|
|
672
677
|
/**
|
|
673
678
|
* @property root - If `true` then this is root node without any additional properties besides *folders*
|
|
674
679
|
* @property path - mailbox path
|
|
@@ -686,7 +691,7 @@ declare type ListTreeResponse = {
|
|
|
686
691
|
path: string;
|
|
687
692
|
name: string;
|
|
688
693
|
delimiter: string;
|
|
689
|
-
flags:
|
|
694
|
+
flags: String[];
|
|
690
695
|
specialUse: string;
|
|
691
696
|
listed: boolean;
|
|
692
697
|
subscribed: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "imapflow",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.161",
|
|
4
4
|
"description": "IMAP Client for Node",
|
|
5
5
|
"main": "./lib/imap-flow.js",
|
|
6
6
|
"scripts": {
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://imapflow.com/",
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@babel/eslint-parser": "7.24.
|
|
32
|
-
"@babel/eslint-plugin": "7.
|
|
31
|
+
"@babel/eslint-parser": "7.24.5",
|
|
32
|
+
"@babel/eslint-plugin": "7.24.5",
|
|
33
33
|
"@babel/plugin-syntax-class-properties": "7.12.13",
|
|
34
|
-
"@babel/preset-env": "7.24.
|
|
35
|
-
"@types/node": "20.12.
|
|
34
|
+
"@babel/preset-env": "7.24.5",
|
|
35
|
+
"@types/node": "20.12.8",
|
|
36
36
|
"eslint": "8.57.0",
|
|
37
37
|
"eslint-config-nodemailer": "1.2.0",
|
|
38
38
|
"eslint-config-prettier": "9.1.0",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"libqp": "2.1.0",
|
|
54
54
|
"mailsplit": "5.4.0",
|
|
55
55
|
"nodemailer": "6.9.13",
|
|
56
|
-
"pino": "
|
|
56
|
+
"pino": "9.0.0",
|
|
57
57
|
"socks": "2.8.3"
|
|
58
58
|
}
|
|
59
59
|
}
|