imapflow 1.0.122 → 1.0.124

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,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ - 1.0.123 - 2023-03-22
4
+
5
+ - Do not throw if server responds with `tag BYE`
6
+
3
7
  - 1.0.118 - 2022-12-22
4
8
 
5
9
  - Refactored detecting special use folders
@@ -50,6 +50,8 @@ module.exports = async (connection, username, accessToken) => {
50
50
  );
51
51
  response.next();
52
52
 
53
+ connection.authCapabilities.set(`AUTH=${command}`, true);
54
+
53
55
  return username;
54
56
  } catch (err) {
55
57
  let errorCode = getStatusCode(err.response);
@@ -16,6 +16,8 @@ module.exports = async (connection, username, password) => {
16
16
  ]);
17
17
  response.next();
18
18
 
19
+ connection.authCapabilities.set('LOGIN', true);
20
+
19
21
  return username;
20
22
  } catch (err) {
21
23
  let errorCode = getStatusCode(err.response);
package/lib/imap-flow.js CHANGED
@@ -217,6 +217,8 @@ class ImapFlow extends EventEmitter {
217
217
  * @type {Map<string, boolean|number>}
218
218
  */
219
219
  this.capabilities = new Map();
220
+ this.authCapabilities = new Map();
221
+
220
222
  this.rawCapabilities = null;
221
223
 
222
224
  this.expectCapabilityUpdate = false; // force CAPABILITY after LOGIN
@@ -538,6 +540,7 @@ class ImapFlow extends EventEmitter {
538
540
 
539
541
  switch (parsed.command.toUpperCase()) {
540
542
  case 'OK':
543
+ case 'BYE':
541
544
  await new Promise(resolve => request.resolve({ response: parsed, next: resolve }));
542
545
  break;
543
546
 
@@ -972,6 +975,15 @@ class ImapFlow extends EventEmitter {
972
975
  async sectionCapability(section) {
973
976
  this.rawCapabilities = section;
974
977
  this.capabilities = updateCapabilities(section);
978
+
979
+ if (this.capabilities) {
980
+ for (let [capa] of this.capabilities) {
981
+ if (/^AUTH=/i.test(capa)) {
982
+ this.authCapabilities.set(capa.toUpperCase(), false);
983
+ }
984
+ }
985
+ }
986
+
975
987
  if (this.expectCapabilityUpdate) {
976
988
  this.expectCapabilityUpdate = false;
977
989
  }
@@ -980,6 +992,15 @@ class ImapFlow extends EventEmitter {
980
992
  async untaggedCapability(untagged) {
981
993
  this.rawCapabilities = untagged.attributes;
982
994
  this.capabilities = updateCapabilities(untagged.attributes);
995
+
996
+ if (this.capabilities) {
997
+ for (let [capa] of this.capabilities) {
998
+ if (/^AUTH=/i.test(capa)) {
999
+ this.authCapabilities.set(capa.toUpperCase(), false);
1000
+ }
1001
+ }
1002
+ }
1003
+
983
1004
  if (this.expectCapabilityUpdate) {
984
1005
  this.expectCapabilityUpdate = false;
985
1006
  }
@@ -2178,6 +2199,13 @@ class ImapFlow extends EventEmitter {
2178
2199
  res.next();
2179
2200
  }
2180
2201
  }
2202
+
2203
+ if (!finished) {
2204
+ // FETCH never finished!
2205
+ let error = new Error('FETCH did not finish');
2206
+ error.code = 'ENotFinished';
2207
+ throw error;
2208
+ }
2181
2209
  } catch (err) {
2182
2210
  setImmediate(() => this.close());
2183
2211
  throw err;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "imapflow",
3
- "version": "1.0.122",
3
+ "version": "1.0.124",
4
4
  "description": "IMAP Client for Node",
5
5
  "main": "./lib/imap-flow.js",
6
6
  "scripts": {
@@ -31,11 +31,11 @@
31
31
  "@babel/eslint-plugin": "7.19.1",
32
32
  "@babel/plugin-syntax-class-properties": "7.12.13",
33
33
  "@babel/preset-env": "7.20.2",
34
- "@types/node": "18.15.3",
34
+ "@types/node": "18.15.10",
35
35
  "braintree-jsdoc-template": "3.3.0",
36
36
  "eslint": "8.36.0",
37
37
  "eslint-config-nodemailer": "1.2.0",
38
- "eslint-config-prettier": "8.7.0",
38
+ "eslint-config-prettier": "8.8.0",
39
39
  "grunt": "1.6.1",
40
40
  "grunt-cli": "1.4.3",
41
41
  "grunt-contrib-nodeunit": "5.0.0",