imapflow 1.0.97 → 1.0.98

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.98 - 2022-05-30
4
+
5
+ - Fixed an issue with envelope parsing where literal values were returned as Buffers
6
+
3
7
  - 1.0.97 - 2022-05-29
4
8
 
5
9
  - Allow single quotes in atoms
package/lib/tools.js CHANGED
@@ -350,25 +350,38 @@ module.exports = {
350
350
  },
351
351
 
352
352
  parseEnvelope(entry) {
353
+ let getStrValue = obj => {
354
+ if (!obj) {
355
+ return false;
356
+ }
357
+ if (typeof obj.value === 'string') {
358
+ return obj.value;
359
+ }
360
+ if (Buffer.isBuffer(obj.value)) {
361
+ return obj.value.toString();
362
+ }
363
+ return obj.value;
364
+ };
365
+
353
366
  let processAddresses = function (list) {
354
367
  return [].concat(list || []).map(addr => ({
355
- name: libmime.decodeWords((addr[0] && addr[0].value) || ''),
356
- address: ((addr[2] && addr[2].value) || '') + '@' + ((addr[3] && addr[3].value) || '')
368
+ name: libmime.decodeWords(getStrValue(addr[0]) || ''),
369
+ address: (getStrValue(addr[2]) || '') + '@' + (getStrValue(addr[3]) || '')
357
370
  }));
358
371
  },
359
372
  envelope = {};
360
373
 
361
374
  if (entry[0] && entry[0].value) {
362
- let date = new Date(entry[0].value);
375
+ let date = new Date(getStrValue(entry[0]));
363
376
  if (date.toString() === 'Invalid Date') {
364
- envelope.date = entry[0].value;
377
+ envelope.date = getStrValue(entry[0]);
365
378
  } else {
366
379
  envelope.date = date;
367
380
  }
368
381
  }
369
382
 
370
383
  if (entry[1] && entry[1].value) {
371
- envelope.subject = libmime.decodeWords(entry[1] && entry[1].value);
384
+ envelope.subject = libmime.decodeWords(getStrValue(entry[1]));
372
385
  }
373
386
 
374
387
  if (entry[2] && entry[2].length) {
@@ -396,11 +409,11 @@ module.exports = {
396
409
  }
397
410
 
398
411
  if (entry[8] && entry[8].value) {
399
- envelope.inReplyTo = entry[8].value;
412
+ envelope.inReplyTo = (getStrValue(entry[8]) || '').toString().trim();
400
413
  }
401
414
 
402
415
  if (entry[9] && entry[9].value) {
403
- envelope.messageId = entry[9].value;
416
+ envelope.messageId = (getStrValue(entry[9]) || '').toString().trim();
404
417
  }
405
418
 
406
419
  return envelope;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "imapflow",
3
- "version": "1.0.97",
3
+ "version": "1.0.98",
4
4
  "description": "IMAP Client for Node",
5
5
  "main": "./lib/imap-flow.js",
6
6
  "scripts": {
@@ -27,13 +27,13 @@
27
27
  },
28
28
  "homepage": "https://imapflow.com/",
29
29
  "devDependencies": {
30
- "@babel/eslint-parser": "7.17.0",
30
+ "@babel/eslint-parser": "7.18.2",
31
31
  "@babel/eslint-plugin": "7.17.7",
32
32
  "@babel/plugin-syntax-class-properties": "7.12.13",
33
- "@babel/preset-env": "7.17.12",
34
- "@types/node": "17.0.34",
33
+ "@babel/preset-env": "7.18.2",
34
+ "@types/node": "17.0.36",
35
35
  "braintree-jsdoc-template": "3.3.0",
36
- "eslint": "8.15.0",
36
+ "eslint": "8.16.0",
37
37
  "eslint-config-nodemailer": "1.2.0",
38
38
  "eslint-config-prettier": "8.5.0",
39
39
  "grunt": "1.5.3",