apple-mail-mcp 2.20.0 → 2.20.2

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 (4) hide show
  1. package/README.md +16 -2
  2. package/build/cli.js +616 -361
  3. package/build/index.js +642 -385
  4. package/package.json +1 -1
package/build/cli.js CHANGED
@@ -48,7 +48,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
48
48
  mod
49
49
  ));
50
50
 
51
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/punycode/index.js
51
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/punycode/index.js
52
52
  function error(type) {
53
53
  throw new RangeError(errors[type]);
54
54
  }
@@ -94,7 +94,7 @@ function ucs2decode(string) {
94
94
  }
95
95
  var maxInt, base, tMin, tMax, skew, damp, initialBias, initialN, delimiter, regexPunycode, regexNonASCII, regexSeparators, errors, baseMinusTMin, floor, stringFromCharCode, basicToDigit, digitToBasic, adapt, decode, encode, toUnicode, toASCII;
96
96
  var init_punycode = __esm({
97
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/punycode/index.js"() {
97
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/punycode/index.js"() {
98
98
  maxInt = 2147483647;
99
99
  base = 36;
100
100
  tMin = 1;
@@ -265,7 +265,7 @@ var init_punycode = __esm({
265
265
  }
266
266
  });
267
267
 
268
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/shared/url.js
268
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/shared/url.js
269
269
  import net from "node:net";
270
270
  import urllib from "node:url";
271
271
  function invalidUrl(input) {
@@ -318,7 +318,7 @@ function normalizeHostname(raw, href) {
318
318
  }
319
319
  var SLASHLESS_AUTHORITY, SURROUNDING_WHITESPACE, LEGACY_TRIM, AUTHORITY, FORBIDDEN_HOST_CHARS, CONTROL_CHARS, parse, resolve;
320
320
  var init_url = __esm({
321
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/shared/url.js"() {
321
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/shared/url.js"() {
322
322
  init_punycode();
323
323
  SLASHLESS_AUTHORITY = /^([a-zA-Z][a-zA-Z0-9+.-]*:)(?!\/\/)([\s\S]+)$/;
324
324
  SURROUNDING_WHITESPACE = /^[\x00-\x20]+|[\x00-\x20]+$/g;
@@ -394,11 +394,11 @@ var init_url = __esm({
394
394
  }
395
395
  });
396
396
 
397
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/fetch/cookies.js
397
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/fetch/cookies.js
398
398
  import net2 from "node:net";
399
- var SESSION_TIMEOUT, Cookies;
399
+ var SESSION_TIMEOUT, Cookies, cookies_default;
400
400
  var init_cookies = __esm({
401
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/fetch/cookies.js"() {
401
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/fetch/cookies.js"() {
402
402
  init_url();
403
403
  SESSION_TIMEOUT = 1800;
404
404
  Cookies = class {
@@ -604,24 +604,25 @@ var init_cookies = __esm({
604
604
  return path3;
605
605
  }
606
606
  };
607
+ cookies_default = Cookies;
607
608
  }
608
609
  });
609
610
 
610
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/package-info.js
611
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/package-info.js
611
612
  var name, version, homepage;
612
613
  var init_package_info = __esm({
613
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/package-info.js"() {
614
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/package-info.js"() {
614
615
  name = "nodemailer";
615
- version = "10.0.10";
616
+ version = "10.0.13";
616
617
  homepage = "https://nodemailer.com/";
617
618
  }
618
619
  });
619
620
 
620
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/errors.js
621
- var ETLS, ENOAUTH, EOAUTH2, EMAXLIMIT, EMAXRECIPIENTS, ESENDMAIL, ESES, ECONFIG, EPROXY, EFILEACCESS, EURLACCESS, EFETCH;
621
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/errors.js
622
+ var ECONNECTION, ENOAUTH, EOAUTH2, EMAXLIMIT, EMAXRECIPIENTS, ESENDMAIL, ESES, ECONFIG, EPROXY, EFILEACCESS, EURLACCESS, EFETCH;
622
623
  var init_errors = __esm({
623
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/errors.js"() {
624
- ETLS = "ETLS";
624
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/errors.js"() {
625
+ ECONNECTION = "ECONNECTION";
625
626
  ENOAUTH = "ENOAUTH";
626
627
  EOAUTH2 = "EOAUTH2";
627
628
  EMAXLIMIT = "EMAXLIMIT";
@@ -636,10 +637,10 @@ var init_errors = __esm({
636
637
  }
637
638
  });
638
639
 
639
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/shared/objects.js
640
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/shared/objects.js
640
641
  var isProtoKey, copyOwnKeys;
641
642
  var init_objects = __esm({
642
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/shared/objects.js"() {
643
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/shared/objects.js"() {
643
644
  isProtoKey = (key) => key === "__proto__";
644
645
  copyOwnKeys = (target, source, skip) => {
645
646
  Object.keys(source || {}).forEach((key) => {
@@ -653,7 +654,7 @@ var init_objects = __esm({
653
654
  }
654
655
  });
655
656
 
656
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/fetch/index.js
657
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/fetch/index.js
657
658
  import http from "node:http";
658
659
  import https from "node:https";
659
660
  import zlib from "node:zlib";
@@ -674,7 +675,7 @@ function parseFetchUrl(url) {
674
675
  function nmfetch(url, options) {
675
676
  options = options || {};
676
677
  options.fetchRes = options.fetchRes || new PassThrough();
677
- options.cookies = options.cookies || new Cookies();
678
+ options.cookies = options.cookies || new cookies_default();
678
679
  options.redirects = options.redirects || 0;
679
680
  options.maxRedirects = isNaN(options.maxRedirects) ? MAX_REDIRECTS : options.maxRedirects;
680
681
  const fetchRes = options.fetchRes;
@@ -748,14 +749,11 @@ function nmfetch(url, options) {
748
749
  return encodeURIComponent(key) + "=" + encodeURIComponent(value);
749
750
  }).join("&"));
750
751
  } catch (E) {
751
- if (finished) {
752
- return void 0;
753
- }
754
752
  finished = true;
755
753
  E.code = EFETCH;
756
754
  E.sourceUrl = url;
757
- fetchRes.emit("error", E);
758
- return void 0;
755
+ setImmediate(() => fetchRes.emit("error", E));
756
+ return fetchRes;
759
757
  }
760
758
  } else {
761
759
  body = Buffer.from(options.body.toString().trim());
@@ -799,28 +797,21 @@ function nmfetch(url, options) {
799
797
  });
800
798
  return fetchRes;
801
799
  }
802
- if (options.timeout) {
803
- req.setTimeout(options.timeout, () => {
804
- if (finished) {
805
- return;
806
- }
807
- finished = true;
808
- req.abort();
809
- const err = new Error("Request Timeout");
810
- err.code = EFETCH;
811
- err.sourceUrl = url;
812
- fetchRes.emit("error", err);
813
- });
814
- }
815
- req.on("error", (err) => {
800
+ const fail = (err, sourceUrl = url) => {
816
801
  if (finished) {
817
802
  return;
818
803
  }
819
804
  finished = true;
820
805
  err.code = EFETCH;
821
- err.sourceUrl = url;
806
+ err.sourceUrl = sourceUrl;
822
807
  fetchRes.emit("error", err);
823
- });
808
+ req.abort();
809
+ };
810
+ const timeout = typeof options.timeout === "number" && options.timeout >= 0 ? options.timeout : DEFAULT_TIMEOUT;
811
+ if (timeout) {
812
+ req.setTimeout(timeout, () => fail(new Error("Request Timeout")));
813
+ }
814
+ req.on("error", (err) => fail(err));
824
815
  req.on("response", (res) => {
825
816
  let inflate;
826
817
  if (finished) {
@@ -840,13 +831,7 @@ function nmfetch(url, options) {
840
831
  if ([301, 302, 303, 307, 308].includes(res.statusCode) && res.headers.location) {
841
832
  options.redirects++;
842
833
  if (options.redirects > options.maxRedirects) {
843
- finished = true;
844
- const err = new Error("Maximum redirect count exceeded");
845
- err.code = EFETCH;
846
- err.sourceUrl = url;
847
- fetchRes.emit("error", err);
848
- req.abort();
849
- return;
834
+ return fail(new Error("Maximum redirect count exceeded"));
850
835
  }
851
836
  options.method = "GET";
852
837
  options.body = false;
@@ -858,13 +843,7 @@ function nmfetch(url, options) {
858
843
  }
859
844
  const redirectParsed = parseFetchUrl(redirectUrl);
860
845
  if (!redirectParsed) {
861
- finished = true;
862
- const err = new Error("Unsupported protocol for URL " + redirectUrl);
863
- err.code = EFETCH;
864
- err.sourceUrl = redirectUrl;
865
- fetchRes.emit("error", err);
866
- req.abort();
867
- return;
846
+ return fail(new Error("Unsupported protocol for URL " + redirectUrl), redirectUrl);
868
847
  }
869
848
  const crossHost = redirectParsed.hostname !== parsed.hostname;
870
849
  const downgrade = parsed.protocol === "https:" && redirectParsed.protocol === "http:";
@@ -876,41 +855,31 @@ function nmfetch(url, options) {
876
855
  }
877
856
  });
878
857
  }
858
+ finished = true;
859
+ res.resume();
860
+ req.abort();
879
861
  return nmfetch(redirectUrl, options);
880
862
  }
881
863
  fetchRes.statusCode = res.statusCode;
882
864
  fetchRes.headers = res.headers;
883
865
  if (res.statusCode >= 300 && !options.allowErrorResponse) {
884
- finished = true;
885
- const err = new Error("Invalid status code " + res.statusCode);
886
- err.code = EFETCH;
887
- err.sourceUrl = url;
888
- fetchRes.emit("error", err);
889
- req.abort();
890
- return;
891
- }
892
- res.on("error", (err) => {
893
- if (finished) {
866
+ return fail(new Error("Invalid status code " + res.statusCode));
867
+ }
868
+ res.on("error", (err) => fail(err));
869
+ const maxBytes = typeof options.maxBytes === "number" && options.maxBytes > 0 ? options.maxBytes : DEFAULT_MAX_BYTES;
870
+ const source = inflate || res;
871
+ let received = 0;
872
+ source.on("data", (chunk) => {
873
+ received += chunk.length;
874
+ if (received <= maxBytes || finished) {
894
875
  return;
895
876
  }
896
- finished = true;
897
- err.code = EFETCH;
898
- err.sourceUrl = url;
899
- fetchRes.emit("error", err);
900
- req.abort();
877
+ source.unpipe(fetchRes);
878
+ fail(new Error("Response size exceeds the allowed " + maxBytes + " bytes"));
901
879
  });
902
880
  if (inflate) {
903
881
  res.pipe(inflate).pipe(fetchRes);
904
- inflate.on("error", (err) => {
905
- if (finished) {
906
- return;
907
- }
908
- finished = true;
909
- err.code = EFETCH;
910
- err.sourceUrl = url;
911
- fetchRes.emit("error", err);
912
- req.abort();
913
- });
882
+ inflate.on("error", (err) => fail(err));
914
883
  } else {
915
884
  res.pipe(fetchRes);
916
885
  }
@@ -923,26 +892,24 @@ function nmfetch(url, options) {
923
892
  }
924
893
  req.write(body);
925
894
  } catch (err) {
926
- finished = true;
927
- err.code = EFETCH;
928
- err.sourceUrl = url;
929
- fetchRes.emit("error", err);
930
- return;
895
+ return fail(err);
931
896
  }
932
897
  }
933
898
  req.end();
934
899
  });
935
900
  return fetchRes;
936
901
  }
937
- var MAX_REDIRECTS, TLS_OPTION_KEYS, fetch_default;
902
+ var MAX_REDIRECTS, DEFAULT_TIMEOUT, DEFAULT_MAX_BYTES, TLS_OPTION_KEYS, fetch_default;
938
903
  var init_fetch = __esm({
939
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/fetch/index.js"() {
904
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/fetch/index.js"() {
940
905
  init_url();
941
906
  init_cookies();
942
907
  init_package_info();
943
908
  init_errors();
944
909
  init_objects();
945
910
  MAX_REDIRECTS = 5;
911
+ DEFAULT_TIMEOUT = 60 * 1e3;
912
+ DEFAULT_MAX_BYTES = 64 * 1024 * 1024;
946
913
  TLS_OPTION_KEYS = [
947
914
  "ALPNProtocols",
948
915
  "ca",
@@ -966,12 +933,13 @@ var init_fetch = __esm({
966
933
  "sessionIdContext",
967
934
  "sigalgs"
968
935
  ];
969
- nmfetch.Cookies = Cookies;
936
+ nmfetch.Cookies = cookies_default;
937
+ nmfetch.DEFAULT_TIMEOUT = DEFAULT_TIMEOUT;
970
938
  fetch_default = nmfetch;
971
939
  }
972
940
  });
973
941
 
974
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/shared/index.js
942
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/shared/index.js
975
943
  import util from "node:util";
976
944
  import fs from "node:fs";
977
945
  import dns from "node:dns";
@@ -1112,7 +1080,7 @@ function createDefaultLogger(levels) {
1112
1080
  }
1113
1081
  var DNS_TTL, CACHE_CLEANUP_INTERVAL, MAX_CACHE_SIZE, lastCacheCleanup, networkInterfaces, isFamilySupported, resolve2, dnsCache, formatDNSValue, resolveHostname, parseConnectionUrl, _logFunc, getLogger, callbackPromise, parseDataURI, assign, encodeXText;
1114
1082
  var init_shared = __esm({
1115
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/shared/index.js"() {
1083
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/shared/index.js"() {
1116
1084
  init_url();
1117
1085
  init_fetch();
1118
1086
  init_errors();
@@ -1386,8 +1354,9 @@ var init_shared = __esm({
1386
1354
  }
1387
1355
  const logger = options.logger === true ? createDefaultLogger(levels) : options.logger;
1388
1356
  levels.forEach((level) => {
1389
- response[level] = (data, message, ...args) => {
1390
- _logFunc(logger, level, defaults, data, message, ...args);
1357
+ response[level] = (...args) => {
1358
+ const data = typeof args[0] === "string" ? void 0 : args.shift();
1359
+ _logFunc(logger, level, defaults, data, ...args);
1391
1360
  };
1392
1361
  });
1393
1362
  return response;
@@ -1491,7 +1460,7 @@ var init_shared = __esm({
1491
1460
  }
1492
1461
  });
1493
1462
 
1494
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/mime-funcs/mime-types.js
1463
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/mime-funcs/mime-types.js
1495
1464
  import path from "node:path";
1496
1465
  function detectMimeType(filename) {
1497
1466
  if (!filename) {
@@ -1528,7 +1497,7 @@ function detectExtension(mimeType) {
1528
1497
  }
1529
1498
  var defaultMimeType, defaultExtension, mimeTypes, extensions;
1530
1499
  var init_mime_types = __esm({
1531
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/mime-funcs/mime-types.js"() {
1500
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/mime-funcs/mime-types.js"() {
1532
1501
  defaultMimeType = "application/octet-stream";
1533
1502
  defaultExtension = "bin";
1534
1503
  mimeTypes = /* @__PURE__ */ new Map([
@@ -3593,7 +3562,7 @@ var init_mime_types = __esm({
3593
3562
  }
3594
3563
  });
3595
3564
 
3596
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/base64/index.js
3565
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/base64/index.js
3597
3566
  var base64_exports = {};
3598
3567
  __export(base64_exports, {
3599
3568
  Encoder: () => Encoder,
@@ -3609,7 +3578,7 @@ function encode2(buffer) {
3609
3578
  }
3610
3579
  function wrap(str2, lineLength) {
3611
3580
  str2 = (str2 || "").toString();
3612
- lineLength = lineLength || 76;
3581
+ lineLength = Math.max(Number(lineLength) || 76, 1);
3613
3582
  if (str2.length <= lineLength) {
3614
3583
  return str2;
3615
3584
  }
@@ -3626,7 +3595,7 @@ function wrap(str2, lineLength) {
3626
3595
  }
3627
3596
  var Encoder;
3628
3597
  var init_base64 = __esm({
3629
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/base64/index.js"() {
3598
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/base64/index.js"() {
3630
3599
  Encoder = class extends Transform {
3631
3600
  constructor(options) {
3632
3601
  super();
@@ -3694,7 +3663,7 @@ var init_base64 = __esm({
3694
3663
  }
3695
3664
  });
3696
3665
 
3697
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/qp/index.js
3666
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/qp/index.js
3698
3667
  var qp_exports = {};
3699
3668
  __export(qp_exports, {
3700
3669
  Encoder: () => Encoder2,
@@ -3720,7 +3689,7 @@ function encode3(buffer) {
3720
3689
  }
3721
3690
  function wrap2(str2, lineLength) {
3722
3691
  str2 = (str2 || "").toString();
3723
- lineLength = lineLength || 76;
3692
+ lineLength = Math.max(Number(lineLength) || 76, MIN_LINE_LENGTH);
3724
3693
  if (str2.length <= lineLength) {
3725
3694
  return str2;
3726
3695
  }
@@ -3765,6 +3734,9 @@ function wrap2(str2, lineLength) {
3765
3734
  }
3766
3735
  }
3767
3736
  }
3737
+ if (!line.length) {
3738
+ line = str2.substr(pos, lineLength);
3739
+ }
3768
3740
  if (pos + line.length < len && line.substr(-1) !== "\n") {
3769
3741
  if (line.length === lineLength && line.match(/[=][\da-f]{2}$/i)) {
3770
3742
  line = line.substr(0, line.length - 3);
@@ -3795,9 +3767,10 @@ function checkRanges(nr, ranges) {
3795
3767
  }
3796
3768
  return false;
3797
3769
  }
3798
- var QP_RANGES, Encoder2;
3770
+ var MIN_LINE_LENGTH, QP_RANGES, Encoder2;
3799
3771
  var init_qp = __esm({
3800
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/qp/index.js"() {
3772
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/qp/index.js"() {
3773
+ MIN_LINE_LENGTH = 4;
3801
3774
  QP_RANGES = [
3802
3775
  [9],
3803
3776
  // <TAB>
@@ -3861,7 +3834,7 @@ var init_qp = __esm({
3861
3834
  }
3862
3835
  });
3863
3836
 
3864
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/mime-funcs/index.js
3837
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/mime-funcs/index.js
3865
3838
  function isPlainText(value, isParam) {
3866
3839
  const re = isParam ? /[\x00-\x1f\x7f"\u0080-\uFFFF]/ : /[\x00-\x08\x0b\x0c\x0e-\x1f\u0080-\uFFFF]/;
3867
3840
  return typeof value === "string" && !re.test(value);
@@ -4069,7 +4042,7 @@ function buildHeaderParam(key, data, maxLength) {
4069
4042
  }
4070
4043
  function parseHeaderValue(str2) {
4071
4044
  const response = {
4072
- value: false,
4045
+ value: "",
4073
4046
  params: {}
4074
4047
  };
4075
4048
  const setParam = (name2, value2) => {
@@ -4260,7 +4233,7 @@ function safeEncodeURIComponent(str2) {
4260
4233
  return str2.replace(/[\x00-\x1F *'()<>@,;:\\"[\]?=\u007F-\uFFFF]/g, (chr) => encodeURICharComponent(chr));
4261
4234
  }
4262
4235
  var init_mime_funcs = __esm({
4263
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/mime-funcs/index.js"() {
4236
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/mime-funcs/index.js"() {
4264
4237
  init_base64();
4265
4238
  init_qp();
4266
4239
  init_mime_types();
@@ -4268,7 +4241,7 @@ var init_mime_funcs = __esm({
4268
4241
  }
4269
4242
  });
4270
4243
 
4271
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/addressparser/index.js
4244
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/addressparser/index.js
4272
4245
  function _quoteLocalPart(address) {
4273
4246
  const lastAt = address.lastIndexOf("@");
4274
4247
  if (lastAt < 0) {
@@ -4376,6 +4349,58 @@ function _recoverAddrSpec(data) {
4376
4349
  data.address = address;
4377
4350
  data.text = [data.text].concat(rest).filter((part) => part).join(" ");
4378
4351
  }
4352
+ function _stripAddressComments(address) {
4353
+ const comments = [];
4354
+ let result = "";
4355
+ let comment = "";
4356
+ let depth = 0;
4357
+ let closer = "";
4358
+ let lastChar = "";
4359
+ for (let i = 0, len = address.length; i < len; i++) {
4360
+ const chr = address.charAt(i);
4361
+ if (depth) {
4362
+ if (chr === "\\" && i < len - 1) {
4363
+ comment += address.charAt(++i);
4364
+ } else if (chr === "(") {
4365
+ depth++;
4366
+ comment += chr;
4367
+ } else if (chr === ")" && !--depth) {
4368
+ comments.push(comment.trim());
4369
+ comment = "";
4370
+ if (lastChar !== "@" && address.charAt(i + 1) !== "@") {
4371
+ result += " ";
4372
+ lastChar = " ";
4373
+ }
4374
+ } else {
4375
+ comment += chr;
4376
+ }
4377
+ continue;
4378
+ }
4379
+ if (closer) {
4380
+ if (chr === "\\" && closer === '"' && i < len - 1) {
4381
+ result += chr + address.charAt(++i);
4382
+ lastChar = address.charAt(i);
4383
+ continue;
4384
+ }
4385
+ if (chr === closer) {
4386
+ closer = "";
4387
+ }
4388
+ } else if (chr === '"') {
4389
+ closer = '"';
4390
+ } else if (chr === "[") {
4391
+ closer = "]";
4392
+ } else if (chr === "(") {
4393
+ depth = 1;
4394
+ continue;
4395
+ }
4396
+ result += chr;
4397
+ lastChar = chr;
4398
+ }
4399
+ if (depth) {
4400
+ comments.push(comment.trim());
4401
+ }
4402
+ return { address: result.trim(), comments: comments.filter((text) => text) };
4403
+ }
4379
4404
  function _handleAddress(tokens, depth) {
4380
4405
  let isGroup = false;
4381
4406
  let state = "text";
@@ -4463,6 +4488,22 @@ function _handleAddress(tokens, depth) {
4463
4488
  group: groupMembers
4464
4489
  });
4465
4490
  } else {
4491
+ const addressComments = [];
4492
+ const addressParts = [];
4493
+ for (const part of data.address) {
4494
+ if (part.indexOf("(") < 0) {
4495
+ addressParts.push(part);
4496
+ continue;
4497
+ }
4498
+ const stripped = _stripAddressComments(part);
4499
+ for (const comment of stripped.comments) {
4500
+ addressComments.push(comment);
4501
+ }
4502
+ if (stripped.address) {
4503
+ addressParts.push(stripped.address);
4504
+ }
4505
+ }
4506
+ data.address = addressParts;
4466
4507
  if (!data.address.length && data.text.length) {
4467
4508
  for (let i = data.text.length - 1; i >= 0; i--) {
4468
4509
  if (!data.textWasQuoted[i] && ADDR_SPEC.test(data.text[i])) {
@@ -4510,6 +4551,9 @@ function _handleAddress(tokens, depth) {
4510
4551
  data.text = "";
4511
4552
  }
4512
4553
  _recoverAddrSpec(data);
4554
+ if (!data.text && addressComments.length) {
4555
+ data.text = addressComments.join(" ");
4556
+ }
4513
4557
  const address = {
4514
4558
  address: data.address || data.text || "",
4515
4559
  name: data.text || data.address || ""
@@ -4582,9 +4626,9 @@ function addressparser(str2, options) {
4582
4626
  }
4583
4627
  return parsedAddresses;
4584
4628
  }
4585
- var HAS_WHITESPACE, QUOTED_LOCAL_ADDR, ADDR_SPEC, LOOSE_ADDR_SPEC, LOOSE_TEXT_ADDR, Tokenizer, MAX_NESTED_GROUP_DEPTH;
4629
+ var HAS_WHITESPACE, QUOTED_LOCAL_ADDR, ADDR_SPEC, LOOSE_ADDR_SPEC, LOOSE_TEXT_ADDR, Tokenizer, MAX_NESTED_GROUP_DEPTH, addressparser_default;
4586
4630
  var init_addressparser = __esm({
4587
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/addressparser/index.js"() {
4631
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/addressparser/index.js"() {
4588
4632
  HAS_WHITESPACE = /\s/;
4589
4633
  QUOTED_LOCAL_ADDR = /^("(?:[^"\\]|\\[\s\S])*"@\S+)(?:\s+([\s\S]+))?$/;
4590
4634
  ADDR_SPEC = /^[^@\s]+@[^@\s]+$/;
@@ -4692,14 +4736,15 @@ var init_addressparser = __esm({
4692
4736
  }
4693
4737
  };
4694
4738
  MAX_NESTED_GROUP_DEPTH = 50;
4739
+ addressparser_default = addressparser;
4695
4740
  }
4696
4741
  });
4697
4742
 
4698
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/mime-node/last-newline.js
4743
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/mime-node/last-newline.js
4699
4744
  import { Transform as Transform3 } from "node:stream";
4700
4745
  var LastNewline;
4701
4746
  var init_last_newline = __esm({
4702
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/mime-node/last-newline.js"() {
4747
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/mime-node/last-newline.js"() {
4703
4748
  LastNewline = class extends Transform3 {
4704
4749
  constructor() {
4705
4750
  super();
@@ -4729,11 +4774,11 @@ var init_last_newline = __esm({
4729
4774
  }
4730
4775
  });
4731
4776
 
4732
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/mime-node/le-windows.js
4777
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/mime-node/le-windows.js
4733
4778
  import { Transform as Transform4 } from "node:stream";
4734
4779
  var LeWindows;
4735
4780
  var init_le_windows = __esm({
4736
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/mime-node/le-windows.js"() {
4781
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/mime-node/le-windows.js"() {
4737
4782
  LeWindows = class extends Transform4 {
4738
4783
  constructor(options) {
4739
4784
  super(options);
@@ -4771,11 +4816,11 @@ var init_le_windows = __esm({
4771
4816
  }
4772
4817
  });
4773
4818
 
4774
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/mime-node/le-unix.js
4819
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/mime-node/le-unix.js
4775
4820
  import { Transform as Transform5 } from "node:stream";
4776
4821
  var LeUnix;
4777
4822
  var init_le_unix = __esm({
4778
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/mime-node/le-unix.js"() {
4823
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/mime-node/le-unix.js"() {
4779
4824
  LeUnix = class extends Transform5 {
4780
4825
  constructor(options) {
4781
4826
  super(options);
@@ -4806,7 +4851,7 @@ var init_le_unix = __esm({
4806
4851
  }
4807
4852
  });
4808
4853
 
4809
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/mime-node/index.js
4854
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/mime-node/index.js
4810
4855
  import crypto from "node:crypto";
4811
4856
  import fs2 from "node:fs";
4812
4857
  import { PassThrough as PassThrough2 } from "node:stream";
@@ -4826,7 +4871,7 @@ function _stripBoundaryControls(value) {
4826
4871
  }
4827
4872
  var FORMATTED_HEADERS, ATEXT, DOT_ATOM, QUOTED_STRING, PLAIN_ADDRESS, URL_PARSER_UNSAFE, MimeNode, mime_node_default;
4828
4873
  var init_mime_node = __esm({
4829
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/mime-node/index.js"() {
4874
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/mime-node/index.js"() {
4830
4875
  init_punycode();
4831
4876
  init_shared();
4832
4877
  init_mime_funcs();
@@ -5643,7 +5688,7 @@ var init_mime_node = __esm({
5643
5688
  flattened.push(copy);
5644
5689
  continue;
5645
5690
  }
5646
- const parsed = this._normalizeParsedAddresses(addressparser(address));
5691
+ const parsed = this._normalizeParsedAddresses(addressparser_default(address));
5647
5692
  for (let i = 0; i < parsed.length; i++) {
5648
5693
  flattened.push(parsed[i]);
5649
5694
  }
@@ -5953,14 +5998,14 @@ var init_mime_node = __esm({
5953
5998
  }
5954
5999
  });
5955
6000
 
5956
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/mail-composer/index.js
6001
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/mail-composer/index.js
5957
6002
  function isContentObject(value) {
5958
6003
  const content = value;
5959
6004
  return typeof value === "object" && !!(content.content || content.path || content.href || content.raw);
5960
6005
  }
5961
6006
  var MailComposer, mail_composer_default;
5962
6007
  var init_mail_composer = __esm({
5963
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/mail-composer/index.js"() {
6008
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/mail-composer/index.js"() {
5964
6009
  init_mime_node();
5965
6010
  init_mime_funcs();
5966
6011
  init_shared();
@@ -6447,11 +6492,11 @@ var init_mail_composer = __esm({
6447
6492
  }
6448
6493
  });
6449
6494
 
6450
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/dkim/message-parser.js
6495
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/dkim/message-parser.js
6451
6496
  import { Transform as Transform6 } from "node:stream";
6452
- var MessageParser;
6497
+ var MessageParser, message_parser_default;
6453
6498
  var init_message_parser = __esm({
6454
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/dkim/message-parser.js"() {
6499
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/dkim/message-parser.js"() {
6455
6500
  MessageParser = class extends Transform6 {
6456
6501
  constructor(options) {
6457
6502
  super(options);
@@ -6575,15 +6620,16 @@ var init_message_parser = __esm({
6575
6620
  }));
6576
6621
  }
6577
6622
  };
6623
+ message_parser_default = MessageParser;
6578
6624
  }
6579
6625
  });
6580
6626
 
6581
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/dkim/relaxed-body.js
6627
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/dkim/relaxed-body.js
6582
6628
  import { Transform as Transform7 } from "node:stream";
6583
6629
  import crypto2 from "node:crypto";
6584
- var CHAR_CR, CHAR_LF, CHAR_SPACE, CHAR_TAB, CRLF, EMPTY_LINES, RelaxedBody;
6630
+ var CHAR_CR, CHAR_LF, CHAR_SPACE, CHAR_TAB, CRLF, EMPTY_LINES, RelaxedBody, relaxed_body_default;
6585
6631
  var init_relaxed_body = __esm({
6586
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/dkim/relaxed-body.js"() {
6632
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/dkim/relaxed-body.js"() {
6587
6633
  CHAR_CR = 13;
6588
6634
  CHAR_LF = 10;
6589
6635
  CHAR_SPACE = 32;
@@ -6701,11 +6747,17 @@ var init_relaxed_body = __esm({
6701
6747
  callback();
6702
6748
  }
6703
6749
  };
6750
+ relaxed_body_default = RelaxedBody;
6704
6751
  }
6705
6752
  });
6706
6753
 
6707
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/dkim/sign.js
6754
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/dkim/sign.js
6708
6755
  import crypto3 from "node:crypto";
6756
+ function unsupportedHashAlgoError(hashAlgo) {
6757
+ const err = new Error('Unsupported DKIM hash algorithm "' + hashAlgo + '"');
6758
+ err.code = ECONFIG;
6759
+ return err;
6760
+ }
6709
6761
  function sign(headers, hashAlgo, bodyHash, options) {
6710
6762
  options = options || {};
6711
6763
  const defaultFieldNames = "From:Sender:Reply-To:Subject:Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive";
@@ -6713,7 +6765,12 @@ function sign(headers, hashAlgo, bodyHash, options) {
6713
6765
  const canonicalizedHeaderData = relaxedHeaders(headers, fieldNames, options.skipFields);
6714
6766
  const dkimHeader = generateDKIMHeader(options.domainName, options.keySelector, canonicalizedHeaderData.fieldNames, hashAlgo, bodyHash);
6715
6767
  canonicalizedHeaderData.headers += "dkim-signature:" + relaxedHeaderLine(dkimHeader);
6716
- const signer = crypto3.createSign(("rsa-" + hashAlgo).toUpperCase());
6768
+ let signer;
6769
+ try {
6770
+ signer = crypto3.createSign(("rsa-" + hashAlgo).toUpperCase());
6771
+ } catch (_E) {
6772
+ throw unsupportedHashAlgoError(hashAlgo);
6773
+ }
6717
6774
  signer.update(canonicalizedHeaderData.headers, "latin1");
6718
6775
  let signature;
6719
6776
  try {
@@ -6771,22 +6828,24 @@ function relaxedHeaderLine(line) {
6771
6828
  }
6772
6829
  var sign_default;
6773
6830
  var init_sign = __esm({
6774
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/dkim/sign.js"() {
6831
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/dkim/sign.js"() {
6775
6832
  init_punycode();
6776
6833
  init_mime_funcs();
6834
+ init_errors();
6777
6835
  sign.relaxedHeaders = relaxedHeaders;
6836
+ sign.unsupportedHashAlgoError = unsupportedHashAlgoError;
6778
6837
  sign_default = sign;
6779
6838
  }
6780
6839
  });
6781
6840
 
6782
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/dkim/index.js
6841
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/dkim/index.js
6783
6842
  import { PassThrough as PassThrough3 } from "node:stream";
6784
6843
  import fs3 from "node:fs";
6785
6844
  import path2 from "node:path";
6786
6845
  import crypto4 from "node:crypto";
6787
6846
  var DKIM_ALGO, MAX_MESSAGE_SIZE, DKIMSigner, DKIM, dkim_default;
6788
6847
  var init_dkim = __esm({
6789
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/dkim/index.js"() {
6848
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/dkim/index.js"() {
6790
6849
  init_message_parser();
6791
6850
  init_relaxed_body();
6792
6851
  init_sign();
@@ -6865,13 +6924,21 @@ var init_dkim = __esm({
6865
6924
  return;
6866
6925
  }
6867
6926
  const key = this.keys[keyPos++];
6868
- const dkimField = sign_default(this.headers, this.hashAlgo, this.bodyHash, {
6869
- domainName: key.domainName,
6870
- keySelector: key.keySelector,
6871
- privateKey: key.privateKey,
6872
- headerFieldNames: this.options.headerFieldNames,
6873
- skipFields: this.options.skipFields
6874
- });
6927
+ let dkimField;
6928
+ try {
6929
+ dkimField = sign_default(this.headers, this.hashAlgo, this.bodyHash, {
6930
+ domainName: key.domainName,
6931
+ keySelector: key.keySelector,
6932
+ privateKey: key.privateKey,
6933
+ headerFieldNames: this.options.headerFieldNames,
6934
+ skipFields: this.options.skipFields
6935
+ });
6936
+ } catch (err) {
6937
+ this.hasErrored = true;
6938
+ this.cleanup();
6939
+ this.output.emit("error", err);
6940
+ return;
6941
+ }
6875
6942
  if (dkimField) {
6876
6943
  this.output.write(Buffer.from(dkimField + "\r\n"));
6877
6944
  }
@@ -6903,8 +6970,8 @@ var init_dkim = __esm({
6903
6970
  this.relaxedBody.pipe(this.cache);
6904
6971
  }
6905
6972
  signStream() {
6906
- this.parser = new MessageParser();
6907
- this.relaxedBody = new RelaxedBody({
6973
+ this.parser = new message_parser_default();
6974
+ this.relaxedBody = new relaxed_body_default({
6908
6975
  hashAlgo: this.hashAlgo
6909
6976
  });
6910
6977
  this.parser.on("headers", (value) => {
@@ -6963,7 +7030,12 @@ var init_dkim = __esm({
6963
7030
  }
6964
7031
  const signer = new DKIMSigner(options, this.keys, inputStream, output);
6965
7032
  setImmediate(() => {
6966
- signer.signStream();
7033
+ try {
7034
+ signer.signStream();
7035
+ } catch (_E) {
7036
+ output.emit("error", sign_default.unsupportedHashAlgoError(signer.hashAlgo));
7037
+ return;
7038
+ }
6967
7039
  if (writeValue) {
6968
7040
  setImmediate(() => {
6969
7041
  inputStream.end(writeValue);
@@ -6977,7 +7049,7 @@ var init_dkim = __esm({
6977
7049
  }
6978
7050
  });
6979
7051
 
6980
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/smtp-connection/http-proxy-client.js
7052
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/smtp-connection/http-proxy-client.js
6981
7053
  import net5 from "node:net";
6982
7054
  import tls from "node:tls";
6983
7055
  function httpProxyClient(proxyUrl, destinationPort, destinationHost, tlsOptions, callback) {
@@ -6986,11 +7058,12 @@ function httpProxyClient(proxyUrl, destinationPort, destinationHost, tlsOptions,
6986
7058
  tlsOptions = {};
6987
7059
  }
6988
7060
  tlsOptions = tlsOptions || {};
7061
+ const done = callback;
6989
7062
  destinationPort = Number(destinationPort) || 0;
6990
7063
  if (!destinationPort || /[\r\n]/.test(destinationHost)) {
6991
7064
  const err = new Error("Invalid proxy destination");
6992
7065
  err.code = EPROXY;
6993
- setImmediate(() => callback(err));
7066
+ setImmediate(() => done(err));
6994
7067
  return;
6995
7068
  }
6996
7069
  const proxy = parse(proxyUrl);
@@ -7016,7 +7089,7 @@ function httpProxyClient(proxyUrl, destinationPort, destinationHost, tlsOptions,
7016
7089
  socket.destroy();
7017
7090
  } catch (_E) {
7018
7091
  }
7019
- callback(err);
7092
+ done(err);
7020
7093
  };
7021
7094
  const timeoutErr = () => {
7022
7095
  const err = new Error("Proxy socket timed out");
@@ -7064,12 +7137,12 @@ function httpProxyClient(proxyUrl, destinationPort, destinationHost, tlsOptions,
7064
7137
  }
7065
7138
  const err = new Error("Invalid response from proxy" + (match && ": " + match[1] || ""));
7066
7139
  err.code = EPROXY;
7067
- return callback(err);
7140
+ return done(err);
7068
7141
  }
7069
7142
  socket.removeListener("error", tempSocketErr);
7070
7143
  socket.removeListener("timeout", timeoutErr);
7071
7144
  socket.setTimeout(0);
7072
- return callback(null, socket);
7145
+ return done(null, socket);
7073
7146
  }
7074
7147
  if (headers.length > MAX_RESPONSE_HEADER_BYTES) {
7075
7148
  socket.removeListener("data", onSocketData);
@@ -7086,7 +7159,7 @@ function httpProxyClient(proxyUrl, destinationPort, destinationHost, tlsOptions,
7086
7159
  }
7087
7160
  var MAX_RESPONSE_HEADER_BYTES, http_proxy_client_default;
7088
7161
  var init_http_proxy_client = __esm({
7089
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/smtp-connection/http-proxy-client.js"() {
7162
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/smtp-connection/http-proxy-client.js"() {
7090
7163
  init_url();
7091
7164
  init_errors();
7092
7165
  MAX_RESPONSE_HEADER_BYTES = 64 * 1024;
@@ -7094,10 +7167,10 @@ var init_http_proxy_client = __esm({
7094
7167
  }
7095
7168
  });
7096
7169
 
7097
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/mailer/mail-message.js
7170
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/mailer/mail-message.js
7098
7171
  var hasOwn, MailMessage;
7099
7172
  var init_mail_message = __esm({
7100
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/mailer/mail-message.js"() {
7173
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/mailer/mail-message.js"() {
7101
7174
  init_shared();
7102
7175
  init_mime_node();
7103
7176
  init_mime_funcs();
@@ -7354,7 +7427,7 @@ var init_mail_message = __esm({
7354
7427
  }
7355
7428
  });
7356
7429
 
7357
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/mailer/index.js
7430
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/mailer/index.js
7358
7431
  import { EventEmitter } from "node:events";
7359
7432
  import util2 from "node:util";
7360
7433
  import net6 from "node:net";
@@ -7362,7 +7435,7 @@ import dns2 from "node:dns";
7362
7435
  import crypto5 from "node:crypto";
7363
7436
  var DEFAULT_MAX_RECIPIENTS, Mail, mailer_default;
7364
7437
  var init_mailer = __esm({
7365
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/mailer/index.js"() {
7438
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/mailer/index.js"() {
7366
7439
  init_shared();
7367
7440
  init_mime_types();
7368
7441
  init_mail_composer();
@@ -7707,11 +7780,15 @@ var init_mailer = __esm({
7707
7780
  }
7708
7781
  });
7709
7782
 
7710
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/smtp-connection/data-stream.js
7783
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/smtp-connection/data-stream.js
7711
7784
  import { Transform as Transform8 } from "node:stream";
7712
- var DataStream;
7785
+ var INSERT_LF, INSERT_LF_DOT, INSERT_CR, INSERT_DOT, DataStream;
7713
7786
  var init_data_stream = __esm({
7714
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/smtp-connection/data-stream.js"() {
7787
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/smtp-connection/data-stream.js"() {
7788
+ INSERT_LF = Buffer.from("\n");
7789
+ INSERT_LF_DOT = Buffer.from("\n.");
7790
+ INSERT_CR = Buffer.from("\r");
7791
+ INSERT_DOT = Buffer.from(".");
7715
7792
  DataStream = class extends Transform8 {
7716
7793
  constructor(options) {
7717
7794
  super(options);
@@ -7737,29 +7814,28 @@ var init_data_stream = __esm({
7737
7814
  }
7738
7815
  this.inByteCount += chunk.length;
7739
7816
  for (i = 0, len = chunk.length; i < len; i++) {
7740
- if (chunk[i] === 46) {
7741
- if (i && chunk[i - 1] === 10 || !i && (!this.lastByte || this.lastByte === 10)) {
7742
- buf = chunk.slice(lastPos, i + 1);
7817
+ const byte = chunk[i];
7818
+ const prev = i ? chunk[i - 1] : this.lastByte;
7819
+ let insert = false;
7820
+ if (prev === 13 && byte !== 10) {
7821
+ insert = byte === 46 ? INSERT_LF_DOT : INSERT_LF;
7822
+ } else if (byte === 10 && prev !== 13) {
7823
+ insert = INSERT_CR;
7824
+ } else if (byte === 46 && (prev === 10 || prev === false)) {
7825
+ insert = INSERT_DOT;
7826
+ }
7827
+ if (insert) {
7828
+ if (i > lastPos) {
7829
+ buf = chunk.slice(lastPos, i);
7743
7830
  chunks.push(buf);
7744
- chunks.push(Buffer.from("."));
7745
- chunklen += buf.length + 1;
7746
- lastPos = i + 1;
7747
- }
7748
- } else if (chunk[i] === 10) {
7749
- if (i && chunk[i - 1] !== 13 || !i && this.lastByte !== 13) {
7750
- if (i > lastPos) {
7751
- buf = chunk.slice(lastPos, i);
7752
- chunks.push(buf);
7753
- chunklen += buf.length + 2;
7754
- } else {
7755
- chunklen += 2;
7756
- }
7757
- chunks.push(Buffer.from("\r\n"));
7758
- lastPos = i + 1;
7831
+ chunklen += buf.length;
7759
7832
  }
7833
+ chunks.push(insert);
7834
+ chunklen += insert.length;
7835
+ lastPos = i;
7760
7836
  }
7761
7837
  }
7762
- if (chunklen) {
7838
+ if (chunks.length) {
7763
7839
  if (lastPos < chunk.length) {
7764
7840
  buf = chunk.slice(lastPos);
7765
7841
  chunks.push(buf);
@@ -7795,7 +7871,7 @@ var init_data_stream = __esm({
7795
7871
  }
7796
7872
  });
7797
7873
 
7798
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/smtp-connection/index.js
7874
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/smtp-connection/index.js
7799
7875
  import { EventEmitter as EventEmitter2 } from "node:events";
7800
7876
  import net7 from "node:net";
7801
7877
  import tls2 from "node:tls";
@@ -7817,7 +7893,7 @@ function isPartialLine(line) {
7817
7893
  }
7818
7894
  var CONNECTION_TIMEOUT, SOCKET_TIMEOUT, GREETING_TIMEOUT, DNS_TIMEOUT, TEARDOWN_NOOP, MAX_RESPONSE_SIZE, SMTPConnection, smtp_connection_default;
7819
7895
  var init_smtp_connection = __esm({
7820
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/smtp-connection/index.js"() {
7896
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/smtp-connection/index.js"() {
7821
7897
  init_package_info();
7822
7898
  init_data_stream();
7823
7899
  init_shared();
@@ -7834,6 +7910,9 @@ var init_smtp_connection = __esm({
7834
7910
  this.id = crypto6.randomBytes(8).toString("base64").replace(/\W/g, "");
7835
7911
  this.stage = "init";
7836
7912
  this.options = options || {};
7913
+ if (this.options.requireTLS && (this.options.ignoreTLS || this.options.opportunisticTLS)) {
7914
+ this.options = Object.assign({}, this.options, { ignoreTLS: false, opportunisticTLS: false });
7915
+ }
7837
7916
  this.secureConnection = !!this.options.secure;
7838
7917
  this.alreadySecured = !!this.options.secured;
7839
7918
  this.port = Number(this.options.port) || (this.secureConnection ? 465 : 587);
@@ -7876,6 +7955,8 @@ var init_smtp_connection = __esm({
7876
7955
  this._destroyed = false;
7877
7956
  this._closing = false;
7878
7957
  this._currentDataStream = false;
7958
+ this._pendingSend = false;
7959
+ this._connectCallback = false;
7879
7960
  this._onSocketData = (chunk) => this._onData(chunk);
7880
7961
  this._onSocketError = (error2) => this._onError(error2, "ESOCKET", false, "CONN");
7881
7962
  this._onSocketClose = () => this._onClose();
@@ -7890,7 +7971,9 @@ var init_smtp_connection = __esm({
7890
7971
  */
7891
7972
  connect(connectCallback) {
7892
7973
  if (typeof connectCallback === "function") {
7974
+ this._connectCallback = connectCallback;
7893
7975
  this.once("connect", () => {
7976
+ this._connectCallback = false;
7894
7977
  this.logger.debug({
7895
7978
  tnx: "smtp"
7896
7979
  }, "SMTP handshake finished");
@@ -8090,6 +8173,14 @@ var init_smtp_connection = __esm({
8090
8173
  }
8091
8174
  this._currentDataStream = false;
8092
8175
  }
8176
+ if (this._pendingSend) {
8177
+ const { stream, onStreamError } = this._pendingSend;
8178
+ if (stream) {
8179
+ stream.removeListener("error", onStreamError);
8180
+ stream.on("error", TEARDOWN_NOOP);
8181
+ }
8182
+ this._pendingSend = false;
8183
+ }
8093
8184
  if (socket && !socket.destroyed) {
8094
8185
  try {
8095
8186
  socket.setTimeout(0);
@@ -8116,12 +8207,14 @@ var init_smtp_connection = __esm({
8116
8207
  }
8117
8208
  this._auth = authData || {};
8118
8209
  this._authMethod = (this._auth.method || "").toString().trim().toUpperCase() || false;
8210
+ const canUseXOAuth2 = !!this._auth.oauth2 || this.customAuth.has("XOAUTH2");
8119
8211
  if (!this._authMethod && this._auth.oauth2 && !this._auth.credentials) {
8120
8212
  this._authMethod = "XOAUTH2";
8121
8213
  } else if (!this._authMethod || this._authMethod === "XOAUTH2" && !this._auth.oauth2) {
8122
- this._authMethod = (this._supportedAuth[0] || "PLAIN").toUpperCase().trim();
8214
+ const supported = this._supportedAuth.find((method) => method !== "XOAUTH2" || canUseXOAuth2);
8215
+ this._authMethod = (supported || "PLAIN").toUpperCase().trim();
8123
8216
  }
8124
- if (this._authMethod !== "XOAUTH2" && (!this._auth.credentials || !this._auth.credentials.user || !this._auth.credentials.pass)) {
8217
+ if ((this._authMethod !== "XOAUTH2" || this.customAuth.has("XOAUTH2")) && (!this._auth.credentials || !this._auth.credentials.user || !this._auth.credentials.pass)) {
8125
8218
  if (this._auth.user && this._auth.pass || this.customAuth.has(this._authMethod)) {
8126
8219
  this._auth.credentials = {
8127
8220
  user: this._auth.user,
@@ -8157,41 +8250,42 @@ var init_smtp_connection = __esm({
8157
8250
  returned = true;
8158
8251
  callback(this._formatError(err, "EAUTH", lastResponse, "AUTH " + this._authMethod));
8159
8252
  };
8253
+ const sendCommand = (cmd, done) => {
8254
+ let promise;
8255
+ if (!done) {
8256
+ promise = new Promise((resolve5, reject2) => {
8257
+ done = callbackPromise(resolve5, reject2);
8258
+ });
8259
+ }
8260
+ this._responseActions.push((str2) => {
8261
+ lastResponse = str2;
8262
+ let codes = str2.match(/^(\d+)(?:\s(\d+\.\d+\.\d+))?\s/);
8263
+ let data = {
8264
+ command: cmd,
8265
+ response: str2
8266
+ };
8267
+ if (codes) {
8268
+ data.status = Number(codes[1]) || 0;
8269
+ if (codes[2]) {
8270
+ data.code = codes[2];
8271
+ }
8272
+ data.text = str2.substr(codes[0].length);
8273
+ } else {
8274
+ data.text = str2;
8275
+ data.status = 0;
8276
+ }
8277
+ done(null, data);
8278
+ });
8279
+ setImmediate(() => this._sendCommand(cmd));
8280
+ return promise;
8281
+ };
8160
8282
  const handlerResponse = handler({
8161
8283
  auth: this._auth,
8162
8284
  method: this._authMethod,
8163
8285
  extensions: [].concat(this._supportedExtensions),
8164
8286
  authMethods: [].concat(this._supportedAuth),
8165
8287
  maxAllowedSize: this._maxAllowedSize || false,
8166
- sendCommand: (cmd, done) => {
8167
- let promise;
8168
- if (!done) {
8169
- promise = new Promise((resolve5, reject2) => {
8170
- done = callbackPromise(resolve5, reject2);
8171
- });
8172
- }
8173
- this._responseActions.push((str2) => {
8174
- lastResponse = str2;
8175
- let codes = str2.match(/^(\d+)(?:\s(\d+\.\d+\.\d+))?\s/);
8176
- let data = {
8177
- command: cmd,
8178
- response: str2
8179
- };
8180
- if (codes) {
8181
- data.status = Number(codes[1]) || 0;
8182
- if (codes[2]) {
8183
- data.code = codes[2];
8184
- }
8185
- data.text = str2.substr(codes[0].length);
8186
- } else {
8187
- data.text = str2;
8188
- data.status = 0;
8189
- }
8190
- done(null, data);
8191
- });
8192
- setImmediate(() => this._sendCommand(cmd));
8193
- return promise;
8194
- },
8288
+ sendCommand,
8195
8289
  resolve: resolve4,
8196
8290
  reject
8197
8291
  });
@@ -8247,30 +8341,40 @@ var init_smtp_connection = __esm({
8247
8341
  * @param callback Callback to return once sending is completed
8248
8342
  */
8249
8343
  send(envelope, message, done) {
8344
+ let returned = false;
8345
+ const callback = (err, info) => {
8346
+ if (returned) {
8347
+ return;
8348
+ }
8349
+ returned = true;
8350
+ if (this._pendingSend && this._pendingSend.callback === callback) {
8351
+ this._pendingSend = false;
8352
+ }
8353
+ done(err, info);
8354
+ };
8250
8355
  if (!message) {
8251
- return done(this._formatError("Empty message", "EMESSAGE", false, "API"));
8356
+ return callback(this._formatError("Empty message", "EMESSAGE", false, "API"));
8252
8357
  }
8253
8358
  const isDestroyedMessage = this._isDestroyedMessage("send message");
8254
8359
  if (isDestroyedMessage) {
8255
- return done(this._formatError(isDestroyedMessage, "ECONNECTION", false, "API"));
8360
+ return callback(this._formatError(isDestroyedMessage, "ECONNECTION", false, "API"));
8256
8361
  }
8257
8362
  if (this._maxAllowedSize && envelope.size > this._maxAllowedSize) {
8258
8363
  setImmediate(() => {
8259
- done(this._formatError("Message size larger than allowed " + this._maxAllowedSize, "EMESSAGE", false, "MAIL FROM"));
8364
+ callback(this._formatError("Message size larger than allowed " + this._maxAllowedSize, "EMESSAGE", false, "MAIL FROM"));
8260
8365
  });
8261
8366
  return;
8262
8367
  }
8263
- let returned = false;
8264
- const callback = function(...args) {
8265
- if (returned) {
8266
- return;
8267
- }
8268
- returned = true;
8269
- done(...args);
8368
+ const pendingSend = {
8369
+ callback,
8370
+ stream: false,
8371
+ onStreamError: (err) => callback(this._formatError(err, "ESTREAM", false, "API"))
8270
8372
  };
8271
8373
  if (typeof message.on === "function") {
8272
- message.on("error", (err) => callback(this._formatError(err, "ESTREAM", false, "API")));
8374
+ pendingSend.stream = message;
8375
+ pendingSend.stream.on("error", pendingSend.onStreamError);
8273
8376
  }
8377
+ this._pendingSend = pendingSend;
8274
8378
  const startTime = Date.now();
8275
8379
  this._setEnvelope(envelope, (err, info) => {
8276
8380
  if (err) {
@@ -8288,11 +8392,12 @@ var init_smtp_connection = __esm({
8288
8392
  if (err2) {
8289
8393
  return callback(err2);
8290
8394
  }
8291
- info.envelopeTime = envelopeTime - startTime;
8292
- info.messageTime = Date.now() - envelopeTime;
8293
- info.messageSize = stream.outByteCount;
8294
- info.response = str2;
8295
- return callback(null, info);
8395
+ const result = info;
8396
+ result.envelopeTime = envelopeTime - startTime;
8397
+ result.messageTime = Date.now() - envelopeTime;
8398
+ result.messageSize = stream.outByteCount;
8399
+ result.response = str2;
8400
+ return callback(null, result);
8296
8401
  });
8297
8402
  if (typeof message.pipe === "function") {
8298
8403
  message.pipe(stream);
@@ -8436,8 +8541,12 @@ var init_smtp_connection = __esm({
8436
8541
  } else {
8437
8542
  this.logger.error(data, err.message);
8438
8543
  }
8544
+ const pendingSend = this._pendingSend;
8439
8545
  this.emit("error", err);
8440
8546
  this.close();
8547
+ if (pendingSend) {
8548
+ pendingSend.callback(err);
8549
+ }
8441
8550
  }
8442
8551
  /** @internal */
8443
8552
  _formatError(message, type, response, command) {
@@ -8482,12 +8591,21 @@ var init_smtp_connection = __esm({
8482
8591
  this.logger.info({
8483
8592
  tnx: "network"
8484
8593
  }, "Connection closed");
8594
+ const failureResponse = typeof serverResponse === "string" && /^[45]\d{2}[ -]/.test(serverResponse) ? serverResponse : false;
8485
8595
  if (this.upgrading && !this._destroyed) {
8486
- return this._onError(new Error("Connection closed unexpectedly"), "ETLS", serverResponse, "CONN");
8487
- } else if (![this._actionGreeting, this.close].includes(this._responseActions[0]) && !this._destroyed) {
8488
- return this._onError(new Error("Connection closed unexpectedly"), "ECONNECTION", serverResponse, "CONN");
8489
- } else if (/^[45]\d{2}\b/.test(serverResponse)) {
8490
- return this._onError(new Error("Connection closed unexpectedly"), "ECONNECTION", serverResponse, "CONN");
8596
+ return this._onError(new Error("Connection closed unexpectedly"), "ETLS", failureResponse, "CONN");
8597
+ }
8598
+ if (!failureResponse && this._responseActions[0] === this._actionGreeting && this._connectCallback && !this._destroyed) {
8599
+ const connectCallback = this._connectCallback;
8600
+ this._connectCallback = false;
8601
+ const err = this._formatError(new Error("Connection closed unexpectedly"), "ECONNECTION", false, "CONN");
8602
+ this.logger.warn({ tnx: "network" }, err.message);
8603
+ connectCallback(err);
8604
+ this.close();
8605
+ return;
8606
+ }
8607
+ if (failureResponse || this._responseActions[0] !== this.close && !this._destroyed) {
8608
+ return this._onError(new Error("Connection closed unexpectedly"), "ECONNECTION", failureResponse, "CONN");
8491
8609
  }
8492
8610
  this._destroy();
8493
8611
  }
@@ -8895,17 +9013,19 @@ var init_smtp_connection = __esm({
8895
9013
  if (/[ -]AUTH\b/i.test(str2)) {
8896
9014
  this.allowsAuth = true;
8897
9015
  }
8898
- if (/[ -]AUTH(?:(\s+|=)[^\n]*\s+|\s+|=)PLAIN/i.test(str2)) {
8899
- this._supportedAuth.push("PLAIN");
8900
- }
8901
- if (/[ -]AUTH(?:(\s+|=)[^\n]*\s+|\s+|=)LOGIN/i.test(str2)) {
8902
- this._supportedAuth.push("LOGIN");
8903
- }
8904
- if (/[ -]AUTH(?:(\s+|=)[^\n]*\s+|\s+|=)CRAM-MD5/i.test(str2)) {
8905
- this._supportedAuth.push("CRAM-MD5");
9016
+ const authMechanisms = /* @__PURE__ */ new Set();
9017
+ for (const line of this._ehloLines) {
9018
+ const authMatch = /^AUTH[\s=](.*)/i.exec(line);
9019
+ if (authMatch) {
9020
+ for (const mechanism of authMatch[1].split(/[\s=]+/)) {
9021
+ authMechanisms.add(mechanism.toUpperCase());
9022
+ }
9023
+ }
8906
9024
  }
8907
- if (/[ -]AUTH(?:(\s+|=)[^\n]*\s+|\s+|=)XOAUTH2/i.test(str2)) {
8908
- this._supportedAuth.push("XOAUTH2");
9025
+ for (const mechanism of ["PLAIN", "LOGIN", "CRAM-MD5", "XOAUTH2"]) {
9026
+ if (authMechanisms.has(mechanism)) {
9027
+ this._supportedAuth.push(mechanism);
9028
+ }
8909
9029
  }
8910
9030
  if (match = str2.match(/[ -]SIZE(?:[ \t]+(\d+))?/im)) {
8911
9031
  this._supportedExtensions.push("SIZE");
@@ -9151,7 +9271,9 @@ var init_smtp_connection = __esm({
9151
9271
  });
9152
9272
  this._sendCommand("DATA");
9153
9273
  } else {
9154
- err = this._formatError("Can't send mail - all recipients were rejected", "EENVELOPE", str2, "RCPT TO");
9274
+ const deferred = envelope.rejectedErrors.find((rejectedErr) => rejectedErr.responseCode && rejectedErr.responseCode < 500);
9275
+ const reply = deferred?.response ?? str2;
9276
+ err = this._formatError("Can't send mail - all recipients were rejected", "EENVELOPE", reply, "RCPT TO");
9155
9277
  err.rejected = envelope.rejected;
9156
9278
  err.rejectedErrors = envelope.rejectedErrors;
9157
9279
  return callback(err);
@@ -9290,12 +9412,12 @@ var init_smtp_connection = __esm({
9290
9412
  }
9291
9413
  });
9292
9414
 
9293
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/xoauth2/index.js
9415
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/xoauth2/index.js
9294
9416
  import { Stream } from "node:stream";
9295
9417
  import crypto7 from "node:crypto";
9296
9418
  var XOAuth2, xoauth2_default;
9297
9419
  var init_xoauth2 = __esm({
9298
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/xoauth2/index.js"() {
9420
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/xoauth2/index.js"() {
9299
9421
  init_fetch();
9300
9422
  init_shared();
9301
9423
  init_errors();
@@ -9303,12 +9425,12 @@ var init_xoauth2 = __esm({
9303
9425
  constructor(options, logger) {
9304
9426
  super();
9305
9427
  this.options = options || {};
9428
+ this.configError = false;
9306
9429
  if (options && options.serviceClient) {
9307
9430
  if (!options.privateKey || !options.user) {
9308
9431
  const err = new Error('Options "privateKey" and "user" are required for service account!');
9309
9432
  err.code = EOAUTH2;
9310
- setImmediate(() => this.emit("error", err));
9311
- return;
9433
+ this.configError = err;
9312
9434
  }
9313
9435
  const serviceRequestTimeout = Math.min(Math.max(Number(this.options.serviceRequestTimeout) || 0, 0), 3600);
9314
9436
  this.options.serviceRequestTimeout = serviceRequestTimeout || 5 * 60;
@@ -9339,6 +9461,10 @@ var init_xoauth2 = __esm({
9339
9461
  * @param callback Callback function with error object and token string
9340
9462
  */
9341
9463
  getToken(renew, callback) {
9464
+ const done = callback;
9465
+ if (this.configError) {
9466
+ return done(this.configError);
9467
+ }
9342
9468
  if (!renew && this.accessToken && (!this.expires || this.expires > Date.now())) {
9343
9469
  this.logger.debug({
9344
9470
  tnx: "OAUTH2",
@@ -9363,10 +9489,10 @@ var init_xoauth2 = __esm({
9363
9489
  }, "Cannot renew access token for %s: No refresh mechanism available", this.options.user);
9364
9490
  const err = new Error("Can't create new access token for user");
9365
9491
  err.code = EOAUTH2;
9366
- return callback(err);
9492
+ return done(err);
9367
9493
  }
9368
9494
  if (this.renewing) {
9369
- this.renewalQueue.push({ renew, callback });
9495
+ this.renewalQueue.push({ renew, callback: done });
9370
9496
  return;
9371
9497
  }
9372
9498
  this.renewing = true;
@@ -9388,7 +9514,7 @@ var init_xoauth2 = __esm({
9388
9514
  action: "renew"
9389
9515
  }, "Generated new Access Token for %s", this.options.user);
9390
9516
  }
9391
- callback(err, accessToken);
9517
+ done(err, accessToken);
9392
9518
  };
9393
9519
  if (this.provisionCallback) {
9394
9520
  this.provisionCallback(this.options.user, !!renew, (err, accessToken, expires) => {
@@ -9426,6 +9552,7 @@ var init_xoauth2 = __esm({
9426
9552
  * @param callback Callback function with error object and token string
9427
9553
  */
9428
9554
  generateToken(callback) {
9555
+ const done = callback;
9429
9556
  let urlOptions;
9430
9557
  let loggedUrlOptions;
9431
9558
  if (this.options.serviceClient) {
@@ -9444,7 +9571,7 @@ var init_xoauth2 = __esm({
9444
9571
  } catch (_err) {
9445
9572
  const err = new Error("Can't generate token. Check your auth options");
9446
9573
  err.code = EOAUTH2;
9447
- return callback(err);
9574
+ return done(err);
9448
9575
  }
9449
9576
  urlOptions = {
9450
9577
  grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer",
@@ -9458,7 +9585,7 @@ var init_xoauth2 = __esm({
9458
9585
  if (!this.options.refreshToken) {
9459
9586
  const err = new Error("Can't create new access token for user");
9460
9587
  err.code = EOAUTH2;
9461
- return callback(err);
9588
+ return done(err);
9462
9589
  }
9463
9590
  urlOptions = {
9464
9591
  client_id: this.options.clientId || "",
@@ -9483,12 +9610,12 @@ var init_xoauth2 = __esm({
9483
9610
  this.postRequest(this.options.accessUrl, urlOptions, this.options, (error2, body) => {
9484
9611
  let data;
9485
9612
  if (error2) {
9486
- return callback(error2);
9613
+ return done(error2);
9487
9614
  }
9488
9615
  try {
9489
9616
  data = JSON.parse(body.toString());
9490
9617
  } catch (E) {
9491
- return callback(E);
9618
+ return done(E);
9492
9619
  }
9493
9620
  if (!data || typeof data !== "object") {
9494
9621
  this.logger.debug({
@@ -9498,7 +9625,7 @@ var init_xoauth2 = __esm({
9498
9625
  }, "Response: %s", (body || "").toString());
9499
9626
  const err2 = new Error("Invalid authentication response");
9500
9627
  err2.code = EOAUTH2;
9501
- return callback(err2);
9628
+ return done(err2);
9502
9629
  }
9503
9630
  const logData = Object.assign({}, data);
9504
9631
  if (logData.access_token) {
@@ -9519,7 +9646,7 @@ var init_xoauth2 = __esm({
9519
9646
  }
9520
9647
  const err2 = new Error(errorMessage);
9521
9648
  err2.code = EOAUTH2;
9522
- return callback(err2);
9649
+ return done(err2);
9523
9650
  }
9524
9651
  if (data.access_token) {
9525
9652
  this.updateToken(data.access_token, data.expires_in);
@@ -9527,7 +9654,7 @@ var init_xoauth2 = __esm({
9527
9654
  }
9528
9655
  const err = new Error("No access token");
9529
9656
  err.code = EOAUTH2;
9530
- return callback(err);
9657
+ return done(err);
9531
9658
  });
9532
9659
  }
9533
9660
  /**
@@ -9561,7 +9688,10 @@ var init_xoauth2 = __esm({
9561
9688
  method: "post",
9562
9689
  headers: params.customHeaders,
9563
9690
  body: payload,
9564
- allowErrorResponse: true
9691
+ allowErrorResponse: true,
9692
+ // unset falls back to the fetch default, a stalled token endpoint would otherwise keep
9693
+ // `renewing` set and queue every later request
9694
+ timeout: params.requestTimeout
9565
9695
  };
9566
9696
  if (/^https:/i.test(url)) {
9567
9697
  fetchOptions.tls = Object.assign({ rejectUnauthorized: true }, params.tls || {});
@@ -9617,11 +9747,11 @@ var init_xoauth2 = __esm({
9617
9747
  }
9618
9748
  });
9619
9749
 
9620
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/smtp-pool/pool-resource.js
9750
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/smtp-pool/pool-resource.js
9621
9751
  import { EventEmitter as EventEmitter3 } from "node:events";
9622
9752
  var PoolResource;
9623
9753
  var init_pool_resource = __esm({
9624
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/smtp-pool/pool-resource.js"() {
9754
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/smtp-pool/pool-resource.js"() {
9625
9755
  init_smtp_connection();
9626
9756
  init_shared();
9627
9757
  init_xoauth2();
@@ -9644,7 +9774,7 @@ var init_pool_resource = __esm({
9644
9774
  method: "XOAUTH2"
9645
9775
  };
9646
9776
  oauth2.on("token", (token) => this.pool.mailer.emit("token", token));
9647
- oauth2.on("error", (err) => this.emit("error", err));
9777
+ oauth2.on("error", (err) => this._fail(err));
9648
9778
  break;
9649
9779
  }
9650
9780
  default:
@@ -9667,6 +9797,19 @@ var init_pool_resource = __esm({
9667
9797
  this._connected = false;
9668
9798
  this.messages = 0;
9669
9799
  this.available = true;
9800
+ this._failed = false;
9801
+ }
9802
+ /**
9803
+ * Emits 'error' for the first failure only. A dead resource can report the same failure more
9804
+ * than once (the connection error, then the send callback), the pool handles it once
9805
+ * @internal
9806
+ */
9807
+ _fail(err) {
9808
+ if (this._failed) {
9809
+ return;
9810
+ }
9811
+ this._failed = true;
9812
+ this.emit("error", err);
9670
9813
  }
9671
9814
  /**
9672
9815
  * Initiates a connection to the SMTP server
@@ -9676,7 +9819,7 @@ var init_pool_resource = __esm({
9676
9819
  connect(callback) {
9677
9820
  this.pool.getSocket(this.options, (err, socketOptions) => {
9678
9821
  if (err) {
9679
- this.emit("error", err);
9822
+ this._fail(err);
9680
9823
  return callback(err);
9681
9824
  }
9682
9825
  let returned = false;
@@ -9693,8 +9836,8 @@ var init_pool_resource = __esm({
9693
9836
  options = Object.assign(assign(false, options), socketOptions);
9694
9837
  }
9695
9838
  this.connection = new smtp_connection_default(options);
9696
- this.connection.once("error", (err2) => {
9697
- this.emit("error", err2);
9839
+ this.connection.on("error", (err2) => {
9840
+ this._fail(err2);
9698
9841
  if (returned) {
9699
9842
  return;
9700
9843
  }
@@ -9703,39 +9846,26 @@ var init_pool_resource = __esm({
9703
9846
  });
9704
9847
  this.connection.once("end", () => {
9705
9848
  this.close();
9706
- if (returned) {
9707
- return;
9708
- }
9709
9849
  returned = true;
9710
- const timer = setTimeout(() => {
9711
- if (returned) {
9712
- return;
9713
- }
9714
- const err2 = new Error("Unexpected socket close");
9715
- if (this.connection && this.connection._socket && this.connection._socket.upgrading) {
9716
- err2.code = ETLS;
9717
- }
9718
- callback(err2);
9719
- }, 1e3);
9720
- try {
9721
- timer.unref();
9722
- } catch (_E) {
9723
- }
9724
9850
  });
9725
- this.connection.connect(() => {
9851
+ this.connection.connect((err2) => {
9726
9852
  if (returned) {
9727
9853
  return;
9728
9854
  }
9855
+ if (err2) {
9856
+ returned = true;
9857
+ return;
9858
+ }
9729
9859
  if (this.auth && (this.connection.allowsAuth || options.forceAuth)) {
9730
- this.connection.login(this.auth, (err2) => {
9860
+ this.connection.login(this.auth, (err3) => {
9731
9861
  if (returned) {
9732
9862
  return;
9733
9863
  }
9734
9864
  returned = true;
9735
- if (err2) {
9865
+ if (err3) {
9736
9866
  this.connection.close();
9737
- this.emit("error", err2);
9738
- return callback(err2);
9867
+ this._fail(err3);
9868
+ return callback(err3);
9739
9869
  }
9740
9870
  this._connected = true;
9741
9871
  callback(null, true);
@@ -9784,7 +9914,7 @@ var init_pool_resource = __esm({
9784
9914
  this.messages++;
9785
9915
  if (err) {
9786
9916
  this.connection.close();
9787
- this.emit("error", err);
9917
+ this._fail(err);
9788
9918
  return callback(err);
9789
9919
  }
9790
9920
  info.envelope = {
@@ -9797,7 +9927,7 @@ var init_pool_resource = __esm({
9797
9927
  const err2 = new Error("Resource exhausted");
9798
9928
  err2.code = EMAXLIMIT;
9799
9929
  this.connection.close();
9800
- this.emit("error", err2);
9930
+ this._fail(err2);
9801
9931
  } else {
9802
9932
  this.pool._checkRateLimit(() => {
9803
9933
  this.available = true;
@@ -9825,10 +9955,10 @@ var init_pool_resource = __esm({
9825
9955
  }
9826
9956
  });
9827
9957
 
9828
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/well-known/services.js
9958
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/well-known/services.js
9829
9959
  var services;
9830
9960
  var init_services = __esm({
9831
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/well-known/services.js"() {
9961
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/well-known/services.js"() {
9832
9962
  services = {
9833
9963
  "126": {
9834
9964
  "description": "126 Mail (NetEase)",
@@ -10496,7 +10626,7 @@ var init_services = __esm({
10496
10626
  }
10497
10627
  });
10498
10628
 
10499
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/well-known/index.js
10629
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/well-known/index.js
10500
10630
  function normalizeKey(key) {
10501
10631
  return key.replace(/[^a-zA-Z0-9.-]/g, "").toLowerCase();
10502
10632
  }
@@ -10515,7 +10645,7 @@ function wellKnown(key) {
10515
10645
  }
10516
10646
  var normalized;
10517
10647
  var init_well_known = __esm({
10518
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/well-known/index.js"() {
10648
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/well-known/index.js"() {
10519
10649
  init_services();
10520
10650
  normalized = {};
10521
10651
  Object.keys(services).forEach((key) => {
@@ -10532,17 +10662,19 @@ var init_well_known = __esm({
10532
10662
  }
10533
10663
  });
10534
10664
 
10535
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/smtp-pool/index.js
10665
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/smtp-pool/index.js
10536
10666
  import { EventEmitter as EventEmitter4 } from "node:events";
10537
- var SMTPPool, smtp_pool_default;
10667
+ var REQUEUE_BASE_DELAY, REQUEUE_MAX_DELAY, SMTPPool, smtp_pool_default;
10538
10668
  var init_smtp_pool = __esm({
10539
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/smtp-pool/index.js"() {
10669
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/smtp-pool/index.js"() {
10540
10670
  init_pool_resource();
10541
10671
  init_smtp_connection();
10542
10672
  init_well_known();
10543
10673
  init_shared();
10544
10674
  init_errors();
10545
10675
  init_package_info();
10676
+ REQUEUE_BASE_DELAY = 50;
10677
+ REQUEUE_MAX_DELAY = 2e3;
10546
10678
  SMTPPool = class extends EventEmitter4 {
10547
10679
  constructor(options) {
10548
10680
  super();
@@ -10573,6 +10705,7 @@ var init_smtp_pool = __esm({
10573
10705
  );
10574
10706
  this.options.maxConnections = this.options.maxConnections || 5;
10575
10707
  this.options.maxMessages = this.options.maxMessages || 100;
10708
+ this.options.maxRequeues = typeof this.options.maxRequeues === "number" ? this.options.maxRequeues : 5;
10576
10709
  this.logger = getLogger(this.options, {
10577
10710
  component: this.options.component || "smtp-pool"
10578
10711
  });
@@ -10615,6 +10748,9 @@ var init_smtp_pool = __esm({
10615
10748
  */
10616
10749
  send(mail, callback) {
10617
10750
  if (this._closed) {
10751
+ const err = new Error("Connection pool was closed");
10752
+ err.code = ECONNECTION;
10753
+ setImmediate(() => callback(err));
10618
10754
  return false;
10619
10755
  }
10620
10756
  this._queue.push({
@@ -10801,14 +10937,19 @@ var init_smtp_pool = __esm({
10801
10937
  this._removeConnection(connection);
10802
10938
  if (connection.queueEntry) {
10803
10939
  setTimeout(() => {
10940
+ let delay = 0;
10804
10941
  if (connection.queueEntry) {
10805
10942
  if (this._shouldRequeuOnConnectionClose(connection.queueEntry)) {
10806
- this._requeueEntryOnConnectionClose(connection);
10943
+ delay = this._requeueEntryOnConnectionClose(connection);
10807
10944
  } else {
10808
10945
  this._failDeliveryOnConnectionClose(connection);
10809
10946
  }
10810
10947
  }
10811
- this._continueProcessing();
10948
+ if (delay) {
10949
+ setTimeout(() => this._continueProcessing(), delay);
10950
+ } else {
10951
+ this._continueProcessing();
10952
+ }
10812
10953
  }, 50);
10813
10954
  } else {
10814
10955
  if (!this._closed && this.idling && !this._connections.length) {
@@ -10822,7 +10963,7 @@ var init_smtp_pool = __esm({
10822
10963
  }
10823
10964
  /** @internal */
10824
10965
  _shouldRequeuOnConnectionClose(queueEntry) {
10825
- if (this.options.maxRequeues === void 0 || this.options.maxRequeues < 0) {
10966
+ if (this.options.maxRequeues < 0) {
10826
10967
  return true;
10827
10968
  }
10828
10969
  return queueEntry.requeueAttempts < this.options.maxRequeues;
@@ -10831,7 +10972,9 @@ var init_smtp_pool = __esm({
10831
10972
  _failDeliveryOnConnectionClose(connection) {
10832
10973
  if (connection.queueEntry && connection.queueEntry.callback) {
10833
10974
  try {
10834
- connection.queueEntry.callback(new Error("Reached maximum number of retries after connection was closed"));
10975
+ const err = new Error("Reached maximum number of retries after connection was closed");
10976
+ err.code = ECONNECTION;
10977
+ connection.queueEntry.callback(err);
10835
10978
  } catch (E) {
10836
10979
  this.logger.error({
10837
10980
  err: E,
@@ -10845,6 +10988,7 @@ var init_smtp_pool = __esm({
10845
10988
  }
10846
10989
  /** @internal */
10847
10990
  _requeueEntryOnConnectionClose(connection) {
10991
+ const delay = Math.min(REQUEUE_BASE_DELAY * 2 ** connection.queueEntry.requeueAttempts, REQUEUE_MAX_DELAY);
10848
10992
  connection.queueEntry.requeueAttempts += 1;
10849
10993
  this.logger.debug({
10850
10994
  tnx: "pool",
@@ -10854,6 +10998,7 @@ var init_smtp_pool = __esm({
10854
10998
  }, "Re-queued message <%s> for #%s. Attempt: #%s", connection.queueEntry.messageId, connection.id, connection.queueEntry.requeueAttempts);
10855
10999
  this._queue.unshift(connection.queueEntry);
10856
11000
  connection.queueEntry = false;
11001
+ return delay;
10857
11002
  }
10858
11003
  /**
10859
11004
  * Continue to process message if the pool hasn't closed
@@ -10928,10 +11073,11 @@ var init_smtp_pool = __esm({
10928
11073
  callback = callbackPromise(resolve4, reject);
10929
11074
  });
10930
11075
  }
11076
+ const done = callback;
10931
11077
  const auth = new PoolResource(this).auth;
10932
11078
  this.getSocket(this.options, (err, socketOptions) => {
10933
11079
  if (err) {
10934
- return callback(err);
11080
+ return done(err);
10935
11081
  }
10936
11082
  let options = this.options;
10937
11083
  if (socketOptions && socketOptions.connection) {
@@ -10953,14 +11099,14 @@ var init_smtp_pool = __esm({
10953
11099
  }
10954
11100
  returned = true;
10955
11101
  connection.close();
10956
- return callback(err2);
11102
+ return done(err2);
10957
11103
  });
10958
11104
  connection.once("end", () => {
10959
11105
  if (returned) {
10960
11106
  return;
10961
11107
  }
10962
11108
  returned = true;
10963
- return callback(new Error("Connection closed"));
11109
+ return done(new Error("Connection closed"));
10964
11110
  });
10965
11111
  const finalize = () => {
10966
11112
  if (returned) {
@@ -10968,30 +11114,35 @@ var init_smtp_pool = __esm({
10968
11114
  }
10969
11115
  returned = true;
10970
11116
  connection.quit();
10971
- return callback(null, true);
11117
+ return done(null, true);
10972
11118
  };
10973
- connection.connect(() => {
11119
+ connection.connect((err2) => {
10974
11120
  if (returned) {
10975
11121
  return;
10976
11122
  }
11123
+ if (err2) {
11124
+ returned = true;
11125
+ connection.close();
11126
+ return done(err2);
11127
+ }
10977
11128
  if (auth && (connection.allowsAuth || options.forceAuth)) {
10978
- connection.login(auth, (err2) => {
11129
+ connection.login(auth, (err3) => {
10979
11130
  if (returned) {
10980
11131
  return;
10981
11132
  }
10982
- if (err2) {
11133
+ if (err3) {
10983
11134
  returned = true;
10984
11135
  connection.close();
10985
- return callback(err2);
11136
+ return done(err3);
10986
11137
  }
10987
11138
  finalize();
10988
11139
  });
10989
11140
  } else if (!auth && connection.allowsAuth && options.forceAuth) {
10990
- const err2 = new Error("Authentication info was not provided");
10991
- err2.code = ENOAUTH;
11141
+ const err3 = new Error("Authentication info was not provided");
11142
+ err3.code = ENOAUTH;
10992
11143
  returned = true;
10993
11144
  connection.close();
10994
- return callback(err2);
11145
+ return done(err3);
10995
11146
  } else {
10996
11147
  finalize();
10997
11148
  }
@@ -11004,11 +11155,11 @@ var init_smtp_pool = __esm({
11004
11155
  }
11005
11156
  });
11006
11157
 
11007
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/smtp-transport/index.js
11158
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/smtp-transport/index.js
11008
11159
  import { EventEmitter as EventEmitter5 } from "node:events";
11009
11160
  var SMTPTransport, smtp_transport_default;
11010
11161
  var init_smtp_transport = __esm({
11011
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/smtp-transport/index.js"() {
11162
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/smtp-transport/index.js"() {
11012
11163
  init_smtp_connection();
11013
11164
  init_well_known();
11014
11165
  init_shared();
@@ -11143,27 +11294,6 @@ var init_smtp_transport = __esm({
11143
11294
  connection.close();
11144
11295
  return callback(err2);
11145
11296
  });
11146
- connection.once("end", () => {
11147
- if (returned) {
11148
- return;
11149
- }
11150
- const timer = setTimeout(() => {
11151
- if (returned) {
11152
- return;
11153
- }
11154
- returned = true;
11155
- cleanupPerCallAuth();
11156
- const err2 = new Error("Unexpected socket close");
11157
- if (connection && connection._socket && connection._socket.upgrading) {
11158
- err2.code = ETLS;
11159
- }
11160
- callback(err2);
11161
- }, 1e3);
11162
- try {
11163
- timer.unref();
11164
- } catch (_E) {
11165
- }
11166
- });
11167
11297
  const sendMessage = () => {
11168
11298
  const envelope = mail.message.getEnvelope();
11169
11299
  const messageId = mail.message.messageId();
@@ -11182,6 +11312,9 @@ var init_smtp_transport = __esm({
11182
11312
  messageId
11183
11313
  }, "Sending message %s to <%s>", messageId, recipients.join(", "));
11184
11314
  connection.send(envelope, mail.message.createReadStream(), (err2, info) => {
11315
+ if (returned) {
11316
+ return;
11317
+ }
11185
11318
  returned = true;
11186
11319
  cleanupPerCallAuth();
11187
11320
  connection.close();
@@ -11207,21 +11340,26 @@ var init_smtp_transport = __esm({
11207
11340
  }
11208
11341
  });
11209
11342
  };
11210
- connection.connect(() => {
11343
+ connection.connect((err2) => {
11211
11344
  if (returned) {
11212
11345
  return;
11213
11346
  }
11347
+ if (err2) {
11348
+ returned = true;
11349
+ connection.close();
11350
+ return callback(err2);
11351
+ }
11214
11352
  perCallAuth = this.getAuth(mail.data.auth);
11215
11353
  if (perCallAuth && (connection.allowsAuth || options.forceAuth)) {
11216
- connection.login(perCallAuth, (err2) => {
11354
+ connection.login(perCallAuth, (err3) => {
11217
11355
  cleanupPerCallAuth();
11218
11356
  if (returned) {
11219
11357
  return;
11220
11358
  }
11221
- if (err2) {
11359
+ if (err3) {
11222
11360
  returned = true;
11223
11361
  connection.close();
11224
- return callback(err2);
11362
+ return callback(err3);
11225
11363
  }
11226
11364
  sendMessage();
11227
11365
  });
@@ -11238,9 +11376,10 @@ var init_smtp_transport = __esm({
11238
11376
  callback = callbackPromise(resolve4, reject);
11239
11377
  });
11240
11378
  }
11379
+ const done = callback;
11241
11380
  this.getSocket(this.options, (err, socketOptions) => {
11242
11381
  if (err) {
11243
- return callback(err);
11382
+ return done(err);
11244
11383
  }
11245
11384
  let options = this.options;
11246
11385
  if (socketOptions && socketOptions.connection) {
@@ -11270,7 +11409,7 @@ var init_smtp_transport = __esm({
11270
11409
  returned = true;
11271
11410
  cleanupPerCallAuth();
11272
11411
  connection.close();
11273
- return callback(err2);
11412
+ return done(err2);
11274
11413
  });
11275
11414
  connection.once("end", () => {
11276
11415
  if (returned) {
@@ -11278,7 +11417,7 @@ var init_smtp_transport = __esm({
11278
11417
  }
11279
11418
  returned = true;
11280
11419
  cleanupPerCallAuth();
11281
- return callback(new Error("Connection closed"));
11420
+ return done(new Error("Connection closed"));
11282
11421
  });
11283
11422
  const finalize = () => {
11284
11423
  if (returned) {
@@ -11287,33 +11426,38 @@ var init_smtp_transport = __esm({
11287
11426
  returned = true;
11288
11427
  cleanupPerCallAuth();
11289
11428
  connection.quit();
11290
- return callback(null, true);
11429
+ return done(null, true);
11291
11430
  };
11292
- connection.connect(() => {
11431
+ connection.connect((err2) => {
11293
11432
  if (returned) {
11294
11433
  return;
11295
11434
  }
11435
+ if (err2) {
11436
+ returned = true;
11437
+ connection.close();
11438
+ return done(err2);
11439
+ }
11296
11440
  perCallAuth = this.getAuth({});
11297
11441
  if (perCallAuth && (connection.allowsAuth || options.forceAuth)) {
11298
- connection.login(perCallAuth, (err2) => {
11442
+ connection.login(perCallAuth, (err3) => {
11299
11443
  cleanupPerCallAuth();
11300
11444
  if (returned) {
11301
11445
  return;
11302
11446
  }
11303
- if (err2) {
11447
+ if (err3) {
11304
11448
  returned = true;
11305
11449
  connection.close();
11306
- return callback(err2);
11450
+ return done(err3);
11307
11451
  }
11308
11452
  finalize();
11309
11453
  });
11310
11454
  } else if (!perCallAuth && connection.allowsAuth && options.forceAuth) {
11311
- const err2 = new Error("Authentication info was not provided");
11312
- err2.code = ENOAUTH;
11455
+ const err3 = new Error("Authentication info was not provided");
11456
+ err3.code = ENOAUTH;
11313
11457
  returned = true;
11314
11458
  cleanupPerCallAuth();
11315
11459
  connection.close();
11316
- return callback(err2);
11460
+ return done(err3);
11317
11461
  } else {
11318
11462
  finalize();
11319
11463
  }
@@ -11335,11 +11479,11 @@ var init_smtp_transport = __esm({
11335
11479
  }
11336
11480
  });
11337
11481
 
11338
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/sendmail-transport/index.js
11482
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/sendmail-transport/index.js
11339
11483
  import { spawn } from "node:child_process";
11340
11484
  var SendmailTransport, sendmail_transport_default;
11341
11485
  var init_sendmail_transport = __esm({
11342
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/sendmail-transport/index.js"() {
11486
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/sendmail-transport/index.js"() {
11343
11487
  init_package_info();
11344
11488
  init_shared();
11345
11489
  init_errors();
@@ -11480,10 +11624,10 @@ var init_sendmail_transport = __esm({
11480
11624
  }
11481
11625
  });
11482
11626
 
11483
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/stream-transport/index.js
11627
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/stream-transport/index.js
11484
11628
  var StreamTransport, stream_transport_default;
11485
11629
  var init_stream_transport = __esm({
11486
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/stream-transport/index.js"() {
11630
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/stream-transport/index.js"() {
11487
11631
  init_package_info();
11488
11632
  init_shared();
11489
11633
  init_le_windows();
@@ -11577,10 +11721,10 @@ var init_stream_transport = __esm({
11577
11721
  }
11578
11722
  });
11579
11723
 
11580
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/json-transport/index.js
11724
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/json-transport/index.js
11581
11725
  var JSONTransport, json_transport_default;
11582
11726
  var init_json_transport = __esm({
11583
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/json-transport/index.js"() {
11727
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/json-transport/index.js"() {
11584
11728
  init_package_info();
11585
11729
  init_shared();
11586
11730
  JSONTransport = class {
@@ -11636,7 +11780,7 @@ var init_json_transport = __esm({
11636
11780
  }
11637
11781
  });
11638
11782
 
11639
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/ses-transport/index.js
11783
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/ses-transport/index.js
11640
11784
  import EventEmitter6 from "node:events";
11641
11785
  function tagSesError(err) {
11642
11786
  if (err && typeof err === "object" && !err.code) {
@@ -11646,7 +11790,7 @@ function tagSesError(err) {
11646
11790
  }
11647
11791
  var SESTransport, ses_transport_default;
11648
11792
  var init_ses_transport = __esm({
11649
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/ses-transport/index.js"() {
11793
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/ses-transport/index.js"() {
11650
11794
  init_package_info();
11651
11795
  init_shared();
11652
11796
  init_errors();
@@ -11828,7 +11972,7 @@ var init_ses_transport = __esm({
11828
11972
  }
11829
11973
  });
11830
11974
 
11831
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/nodemailer.js
11975
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/nodemailer.js
11832
11976
  function createTransport(transporter, defaults) {
11833
11977
  let options;
11834
11978
  if (
@@ -11950,7 +12094,7 @@ function getTestMessageUrl(info) {
11950
12094
  }
11951
12095
  var ETHEREAL_API, ETHEREAL_WEB, ETHEREAL_API_KEY, ETHEREAL_CACHE, testAccount, nodemailer, nodemailer_default;
11952
12096
  var init_nodemailer = __esm({
11953
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/nodemailer.js"() {
12097
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/nodemailer.js"() {
11954
12098
  init_mailer();
11955
12099
  init_shared();
11956
12100
  init_smtp_pool();
@@ -45015,8 +45159,8 @@ var require_constants2 = __commonJS({
45015
45159
  "use strict";
45016
45160
  Object.defineProperty(exports, "__esModule", { value: true });
45017
45161
  exports.SOCKS5_NO_ACCEPTABLE_AUTH = exports.SOCKS5_CUSTOM_AUTH_END = exports.SOCKS5_CUSTOM_AUTH_START = exports.SOCKS_INCOMING_PACKET_SIZES = exports.SocksClientState = exports.Socks5Response = exports.Socks5HostType = exports.Socks5Auth = exports.Socks4Response = exports.SocksCommand = exports.ERRORS = exports.DEFAULT_TIMEOUT = void 0;
45018
- var DEFAULT_TIMEOUT = 3e4;
45019
- exports.DEFAULT_TIMEOUT = DEFAULT_TIMEOUT;
45162
+ var DEFAULT_TIMEOUT2 = 3e4;
45163
+ exports.DEFAULT_TIMEOUT = DEFAULT_TIMEOUT2;
45020
45164
  var ERRORS = {
45021
45165
  InvalidSocksCommand: "An invalid SOCKS command was provided. Valid options are connect, bind, and associate.",
45022
45166
  InvalidSocksCommandForOperation: "An invalid SOCKS command was provided. Only a subset of commands are supported for this operation.",
@@ -57841,9 +57985,12 @@ __export(imapClient_exports, {
57841
57985
  MAX_UNSCOPED_SEARCH_DEPTH: () => MAX_UNSCOPED_SEARCH_DEPTH,
57842
57986
  __resetPool: () => __resetPool,
57843
57987
  __setPoolConnect: () => __setPoolConnect,
57988
+ base64DecodedLength: () => base64DecodedLength,
57989
+ base64DecodedSizeFromTail: () => base64DecodedSizeFromTail,
57844
57990
  bodyStructureHasAttachments: () => bodyStructureHasAttachments,
57845
57991
  buildImapConnectionOptions: () => buildImapConnectionOptions,
57846
57992
  decodeImapId: () => decodeImapId,
57993
+ decodedSizeWithoutBody: () => decodedSizeWithoutBody,
57847
57994
  dropAllPools: () => dropAllPools,
57848
57995
  encodeImapId: () => encodeImapId,
57849
57996
  imapAppendDraft: () => imapAppendDraft,
@@ -57884,6 +58031,7 @@ __export(imapClient_exports, {
57884
58031
  matchMailbox: () => matchMailbox,
57885
58032
  normalizeMessageId: () => normalizeMessageId,
57886
58033
  omittedNote: () => omittedNote,
58034
+ quotedPrintableDecodedLength: () => quotedPrintableDecodedLength,
57887
58035
  resolveDraftImapAccount: () => resolveDraftImapAccount,
57888
58036
  resolveImapConfig: () => resolveImapConfig,
57889
58037
  resolveImapConfigs: () => resolveImapConfigs,
@@ -59344,6 +59492,56 @@ async function imapDeleteMessageById(id, deps = {}) {
59344
59492
  }
59345
59493
  });
59346
59494
  }
59495
+ function dispositionSize(params) {
59496
+ const raw = params?.size?.trim();
59497
+ return raw && /^\d+$/.test(raw) ? Number(raw) : void 0;
59498
+ }
59499
+ function base64DecodedLength(body) {
59500
+ const s = typeof body === "string" ? body : body.toString("latin1");
59501
+ const n = s.replace(/[^A-Za-z0-9+/]/g, "").length;
59502
+ return Math.floor(n * 3 / 4);
59503
+ }
59504
+ function base64DecodedSizeFromTail(total, tail) {
59505
+ if (tail.length >= total) return base64DecodedLength(tail);
59506
+ const s = tail.toString("latin1");
59507
+ const term = s.includes("\r\n") ? "\r\n" : "\n";
59508
+ const segs = s.split(term);
59509
+ if (segs.length < 3) return void 0;
59510
+ let trailing = 0;
59511
+ while (segs.length > 1 && segs[segs.length - 1] === "") {
59512
+ segs.pop();
59513
+ trailing++;
59514
+ }
59515
+ const last = segs[segs.length - 1];
59516
+ const full = segs.slice(1, -1);
59517
+ if (full.length === 0 || !last) return void 0;
59518
+ const L = full[0].length;
59519
+ const alphabet = /^[A-Za-z0-9+/]+$/;
59520
+ if (L === 0 || L % 4 !== 0 || !full.every((l) => l.length === L && alphabet.test(l))) {
59521
+ return void 0;
59522
+ }
59523
+ const m = /^([A-Za-z0-9+/]*)(=*)$/.exec(last);
59524
+ if (!m || m[2].length > 2 || last.length > L) return void 0;
59525
+ const before = total - trailing * term.length - last.length;
59526
+ if (before < 0 || before % (L + term.length) !== 0) return void 0;
59527
+ const chars = before / (L + term.length) * L + last.length;
59528
+ if (chars % 4 !== 0) return void 0;
59529
+ return chars / 4 * 3 - m[2].length;
59530
+ }
59531
+ function quotedPrintableDecodedLength(body) {
59532
+ const s = (typeof body === "string" ? body : body.toString("latin1")).replace(/=\r?\n/g, "");
59533
+ const escapes = s.match(/=[0-9A-Fa-f]{2}/g)?.length ?? 0;
59534
+ return s.length - escapes * 2;
59535
+ }
59536
+ function decodedSizeWithoutBody(a) {
59537
+ if (a.declaredSize !== void 0) return { size: a.declaredSize, exact: true };
59538
+ if (a.encoding === "base64") {
59539
+ const chars = a.encodedSize - 2 * Math.floor(a.encodedSize / 78);
59540
+ return { size: Math.floor(chars * 3 / 4), exact: false };
59541
+ }
59542
+ if (a.encoding === "quoted-printable") return { size: a.encodedSize, exact: false };
59543
+ return { size: a.encodedSize, exact: true };
59544
+ }
59347
59545
  function collectAttachments(node, out = []) {
59348
59546
  if (!node) return out;
59349
59547
  const filename = node.dispositionParameters?.filename || node.parameters?.name;
@@ -59355,7 +59553,9 @@ function collectAttachments(node, out = []) {
59355
59553
  part: node.part,
59356
59554
  filename: filename || `part-${node.part}`,
59357
59555
  mimeType: node.type || "application/octet-stream",
59358
- size: node.size ?? 0
59556
+ encodedSize: node.size ?? 0,
59557
+ encoding: (node.encoding || "").toLowerCase().trim(),
59558
+ declaredSize: dispositionSize(node.dispositionParameters)
59359
59559
  });
59360
59560
  }
59361
59561
  for (const child of node.childNodes ?? []) collectAttachments(child, out);
@@ -59376,6 +59576,52 @@ async function streamToBuffer(content, maxBytes) {
59376
59576
  }
59377
59577
  return Buffer.concat(chunks);
59378
59578
  }
59579
+ async function resolveDecodedSizes(client, uid, atts) {
59580
+ const out = atts.map(decodedSizeWithoutBody);
59581
+ const probes = [];
59582
+ atts.forEach((a, i) => {
59583
+ if (a.declaredSize !== void 0 || a.encodedSize <= 0) return;
59584
+ if (a.encoding === "base64") {
59585
+ probes.push({ i, start: Math.max(0, a.encodedSize - BASE64_TAIL_WINDOW), kind: "b64" });
59586
+ } else if (a.encoding === "quoted-printable" && a.encodedSize <= QP_EXACT_MAX_BYTES) {
59587
+ probes.push({ i, start: 0, kind: "qp" });
59588
+ }
59589
+ });
59590
+ if (probes.length === 0) return out;
59591
+ let parts;
59592
+ try {
59593
+ const msg = await client.fetchOne(
59594
+ String(uid),
59595
+ {
59596
+ uid: true,
59597
+ bodyParts: probes.map((p) => ({
59598
+ key: atts[p.i].part,
59599
+ start: p.start,
59600
+ maxLength: atts[p.i].encodedSize - p.start
59601
+ }))
59602
+ },
59603
+ { uid: true }
59604
+ );
59605
+ parts = msg ? msg.bodyParts : void 0;
59606
+ } catch {
59607
+ return out;
59608
+ }
59609
+ for (const p of probes) {
59610
+ const a = atts[p.i];
59611
+ const buf = parts?.get(a.part.toLowerCase());
59612
+ if (!buf) continue;
59613
+ let exact;
59614
+ if (p.kind === "qp") {
59615
+ exact = quotedPrintableDecodedLength(buf);
59616
+ } else {
59617
+ const requested = a.encodedSize - p.start;
59618
+ const total = buf.length < requested ? p.start + buf.length : a.encodedSize;
59619
+ exact = base64DecodedSizeFromTail(total, buf);
59620
+ }
59621
+ if (exact !== void 0) out[p.i] = { size: exact, exact: true };
59622
+ }
59623
+ return out;
59624
+ }
59379
59625
  async function imapListAttachments(id, deps = {}) {
59380
59626
  const ref = decodeImapId(id);
59381
59627
  if (!ref) return { success: false, error: `Not an IMAP message id: "${id}".` };
@@ -59384,12 +59630,18 @@ async function imapListAttachments(id, deps = {}) {
59384
59630
  if (!msg || !msg.bodyStructure) {
59385
59631
  return { success: false, error: `IMAP message UID ${ref.uid} not found in "${ref.path}".` };
59386
59632
  }
59387
- const attachments = collectAttachments(msg.bodyStructure).map((a) => ({
59388
- id: `${id}#${a.part}`,
59389
- name: a.filename,
59390
- mimeType: a.mimeType,
59391
- size: a.size
59392
- }));
59633
+ const atts = collectAttachments(msg.bodyStructure);
59634
+ const sizes = await resolveDecodedSizes(client, ref.uid, atts);
59635
+ const attachments = atts.map((a, i) => {
59636
+ const info = {
59637
+ id: `${id}#${a.part}`,
59638
+ name: a.filename,
59639
+ mimeType: a.mimeType,
59640
+ size: sizes[i].size
59641
+ };
59642
+ if (!sizes[i].exact) info.sizeApproximate = true;
59643
+ return info;
59644
+ });
59393
59645
  return { success: true, attachments };
59394
59646
  });
59395
59647
  }
@@ -59410,10 +59662,11 @@ async function imapFetchAttachment(id, attachmentName, deps = {}) {
59410
59662
  error: `Attachment "${attachmentName}" not found on UID ${ref.uid}. Available: ${names}.`
59411
59663
  };
59412
59664
  }
59413
- if (match.size > MAX_IMAP_ATTACHMENT_BYTES) {
59665
+ const expected = decodedSizeWithoutBody(match).size;
59666
+ if (expected > MAX_IMAP_ATTACHMENT_BYTES) {
59414
59667
  return {
59415
59668
  success: false,
59416
- error: `IMAP attachment "${attachmentName}" is ${match.size} bytes; the maximum is ${MAX_IMAP_ATTACHMENT_BYTES} bytes (25 MiB).`
59669
+ error: `IMAP attachment "${attachmentName}" is ${expected} bytes; the maximum is ${MAX_IMAP_ATTACHMENT_BYTES} bytes (25 MiB).`
59417
59670
  };
59418
59671
  }
59419
59672
  try {
@@ -59601,7 +59854,7 @@ async function imapThread(id, deps = {}, limit = 50) {
59601
59854
  true
59602
59855
  );
59603
59856
  }
59604
- var import_imapflow, IMAP_ENV, defaultConnect, SPECIAL_USE_ALIASES, NOT_DELETED, LARGE_MAILBOX_MESSAGES, FIRST_SEARCH_WINDOW, MAX_WINDOW, MAX_UNSCOPED_SEARCH_DEPTH, ROW_QUERY, ROW_QUERY_NO_STRUCTURE, ROW_QUERY_HEADERS_ONLY, DELETED_MARGIN, poolConnect, pools, connecting, MAX_COMPOSE_SOURCE_BYTES, MAX_RFC822_INLINE_BYTES, MAX_RFC822_FILE_BYTES, HEADER_WINDOW_BYTES, MAIL_FLAG_BITS, imapMarkRead, imapMarkUnread, FALLBACK_TRASH_PATH, imapBatchMarkRead, imapBatchMarkUnread, imapBatchFlag, imapBatchUnflag, imapBatchDelete;
59857
+ var import_imapflow, IMAP_ENV, defaultConnect, SPECIAL_USE_ALIASES, NOT_DELETED, LARGE_MAILBOX_MESSAGES, FIRST_SEARCH_WINDOW, MAX_WINDOW, MAX_UNSCOPED_SEARCH_DEPTH, ROW_QUERY, ROW_QUERY_NO_STRUCTURE, ROW_QUERY_HEADERS_ONLY, DELETED_MARGIN, poolConnect, pools, connecting, MAX_COMPOSE_SOURCE_BYTES, MAX_RFC822_INLINE_BYTES, MAX_RFC822_FILE_BYTES, HEADER_WINDOW_BYTES, MAIL_FLAG_BITS, imapMarkRead, imapMarkUnread, FALLBACK_TRASH_PATH, BASE64_TAIL_WINDOW, QP_EXACT_MAX_BYTES, imapBatchMarkRead, imapBatchMarkUnread, imapBatchFlag, imapBatchUnflag, imapBatchDelete;
59605
59858
  var init_imapClient = __esm({
59606
59859
  "src/services/imapClient.ts"() {
59607
59860
  "use strict";
@@ -59706,6 +59959,8 @@ var init_imapClient = __esm({
59706
59959
  imapMarkRead = (id, deps = {}) => flagOp(id, "\\Seen", true, deps);
59707
59960
  imapMarkUnread = (id, deps = {}) => flagOp(id, "\\Seen", false, deps);
59708
59961
  FALLBACK_TRASH_PATH = "Trash";
59962
+ BASE64_TAIL_WINDOW = 1024;
59963
+ QP_EXACT_MAX_BYTES = 64 * 1024;
59709
59964
  imapBatchMarkRead = (ids, deps = {}) => imapBatch(ids, deps, async (c, uids) => {
59710
59965
  assertMutated(
59711
59966
  await c.messageFlagsAdd(uids, ["\\Seen"], { uid: true }),