imapflow 1.3.5 → 1.3.7

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/.github/codeql/codeql-config.yml +12 -0
  2. package/.github/workflows/codeql.yml +102 -0
  3. package/.github/workflows/stale.yml +5 -0
  4. package/.github/workflows/test.yml +3 -0
  5. package/.release-please-manifest.json +1 -1
  6. package/CHANGELOG.md +14 -0
  7. package/lib/commands/authenticate.js +5 -5
  8. package/lib/commands/fetch.js +1 -0
  9. package/lib/commands/logout.js +1 -0
  10. package/lib/commands/select.js +2 -1
  11. package/lib/commands/starttls.js +3 -0
  12. package/lib/commands/store.js +1 -0
  13. package/lib/handler/imap-stream.js +23 -6
  14. package/lib/handler/token-parser.js +0 -5
  15. package/lib/imap-flow.d.ts +5 -0
  16. package/lib/imap-flow.js +205 -29
  17. package/lib/proxy-connection.js +26 -1
  18. package/lib/tools.js +12 -0
  19. package/package.json +1 -1
  20. package/test/commands-branches-test.js +1068 -0
  21. package/test/connection-edge-cases-test.js +138 -1
  22. package/test/fixtures/test-tls.js +8 -0
  23. package/test/handler-branches-test.js +334 -0
  24. package/test/imap-compiler-test.js +47 -0
  25. package/test/imap-flow-compress-test.js +154 -0
  26. package/test/imap-flow-coverage-test.js +609 -0
  27. package/test/imap-flow-fetch-download-test.js +801 -0
  28. package/test/imap-flow-internals-test.js +450 -0
  29. package/test/imap-flow-methods-test.js +738 -0
  30. package/test/imap-flow-proxy-paths-test.js +215 -0
  31. package/test/imap-flow-secure-test.js +327 -0
  32. package/test/imap-flow-server-test.js +1046 -0
  33. package/test/imap-formal-syntax-test.js +18 -0
  34. package/test/imap-parser-test.js +52 -0
  35. package/test/imap-stream-edge-cases-test.js +122 -0
  36. package/test/jp-decoder-test.js +48 -0
  37. package/test/limited-passthrough-test.js +17 -0
  38. package/test/proxy-connection-test.js +86 -0
  39. package/test/reliability-improvements-test.js +88 -0
  40. package/test/search-compiler-test.js +31 -0
  41. package/test/search-test.js +61 -0
  42. package/test/starttls-injection-test.js +181 -0
  43. package/test/token-parser-test.js +64 -0
  44. package/test/tools-test.js +360 -0
package/lib/tools.js CHANGED
@@ -353,10 +353,12 @@ const tools = {
353
353
  .replace(/<\d+(\.\d+)?>$/, '');
354
354
  continue;
355
355
  }
356
+ /* c8 ignore start */ // defensive: key is always a string produced by the compiler above
356
357
  if (typeof key !== 'string') {
357
358
  // should not happen
358
359
  continue;
359
360
  }
361
+ /* c8 ignore stop */
360
362
 
361
363
  let getString = attribute => {
362
364
  if (!attribute) {
@@ -502,6 +504,10 @@ const tools = {
502
504
  }
503
505
  }
504
506
 
507
+ // Non-cryptographic identifier: MD5 is used only to derive a stable, compact
508
+ // account-unique id from non-secret data (path:uidValidity:uid). No security
509
+ // property (collision/preimage resistance, secrecy) is relied upon, so a fast
510
+ // hash is the appropriate choice here — not a security-sensitive use.
505
511
  map.id =
506
512
  map.emailId ||
507
513
  createHash('md5')
@@ -550,10 +556,12 @@ const tools = {
550
556
  if (Buffer.isBuffer(obj.value)) {
551
557
  return obj.value.toString();
552
558
  }
559
+ /* c8 ignore next */ // defensive: envelope tokens are always string/Buffer/NIL, never another type
553
560
  return obj.value;
554
561
  };
555
562
 
556
563
  let processAddresses = function (list) {
564
+ /* c8 ignore next 2 */ // defensive: processAddresses is only called with non-empty arrays, so the [] fallback is unreachable
557
565
  return []
558
566
  .concat(list || [])
559
567
  .map(addr => {
@@ -608,10 +616,12 @@ const tools = {
608
616
  }
609
617
 
610
618
  if (entry[8] && entry[8].value) {
619
+ /* c8 ignore next */ // the guard ensures getStrValue is truthy here, so the '' fallback is unreachable
611
620
  envelope.inReplyTo = (getStrValue(entry[8]) || '').toString().trim();
612
621
  }
613
622
 
614
623
  if (entry[9] && entry[9].value) {
624
+ /* c8 ignore next */ // the guard ensures getStrValue is truthy here, so the '' fallback is unreachable
615
625
  envelope.messageId = (getStrValue(entry[9]) || '').toString().trim();
616
626
  }
617
627
 
@@ -815,6 +825,7 @@ const tools = {
815
825
 
816
826
  // envelope of the encapsulated message
817
827
  if (node[i]) {
828
+ /* c8 ignore next */ // node[i] is truthy inside this guard, so the [] fallback is unreachable
818
829
  curNode.envelope = tools.parseEnvelope([].concat(node[i] || []));
819
830
  }
820
831
  i++;
@@ -882,6 +893,7 @@ const tools = {
882
893
  // body language
883
894
  if (i < node.length - 1) {
884
895
  if (node[i]) {
896
+ /* c8 ignore next */ // node[i] is truthy inside this guard, so the [] fallback is unreachable
885
897
  curNode.language = [].concat(node[i] || []).map(val => ((val && val.value) || '').toString().toLowerCase());
886
898
  }
887
899
  i++;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "imapflow",
3
- "version": "1.3.5",
3
+ "version": "1.3.7",
4
4
  "description": "IMAP Client for Node",
5
5
  "main": "lib/imap-flow.js",
6
6
  "types": "lib/imap-flow.d.ts",