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/index.js CHANGED
@@ -7256,7 +7256,7 @@ function isInlineDisposition(headers) {
7256
7256
  function extractSize(headers) {
7257
7257
  const dispHeader = getHeader(headers, "Content-Disposition");
7258
7258
  if (dispHeader) {
7259
- const sizeMatch = dispHeader.match(/size=(\d+)/i);
7259
+ const sizeMatch = dispHeader.match(/(?:^|;)\s*size\s*=\s*"?(\d+)/i);
7260
7260
  if (sizeMatch) return parseInt(sizeMatch[1], 10);
7261
7261
  }
7262
7262
  return 0;
@@ -7285,8 +7285,8 @@ function decodePartText(bytes, charset) {
7285
7285
  return new TextDecoder("windows-1252").decode(bytes);
7286
7286
  }
7287
7287
  }
7288
- function estimateBase64Size(base64Body) {
7289
- const cleaned = base64Body.replace(/[\s\r\n]/g, "");
7288
+ function base64DecodedSize(base64Body) {
7289
+ const cleaned = base64Body.replace(/[^A-Za-z0-9+/]/g, "");
7290
7290
  return Math.floor(cleaned.length * 3 / 4);
7291
7291
  }
7292
7292
  function splitMimeParts(source, boundary) {
@@ -7349,7 +7349,8 @@ function decodeQuotedPrintable(body) {
7349
7349
  }
7350
7350
  function estimateSize(body, encoding) {
7351
7351
  const enc = (encoding || "").toLowerCase().trim();
7352
- if (enc === "base64") return estimateBase64Size(body);
7352
+ if (enc === "base64") return base64DecodedSize(body);
7353
+ if (enc === "quoted-printable") return decodeQuotedPrintable(body).length;
7353
7354
  return body.length;
7354
7355
  }
7355
7356
  function parseMimeAttachments(source) {
@@ -7921,7 +7922,7 @@ var init_auditLog = __esm({
7921
7922
  }
7922
7923
  });
7923
7924
 
7924
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/punycode/index.js
7925
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/punycode/index.js
7925
7926
  function error2(type) {
7926
7927
  throw new RangeError(errors[type]);
7927
7928
  }
@@ -7967,7 +7968,7 @@ function ucs2decode(string3) {
7967
7968
  }
7968
7969
  var maxInt, base, tMin, tMax, skew, damp, initialBias, initialN, delimiter2, regexPunycode, regexNonASCII, regexSeparators, errors, baseMinusTMin, floor, stringFromCharCode, basicToDigit, digitToBasic, adapt, decode, encode, toUnicode, toASCII;
7969
7970
  var init_punycode = __esm({
7970
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/punycode/index.js"() {
7971
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/punycode/index.js"() {
7971
7972
  maxInt = 2147483647;
7972
7973
  base = 36;
7973
7974
  tMin = 1;
@@ -8138,7 +8139,7 @@ var init_punycode = __esm({
8138
8139
  }
8139
8140
  });
8140
8141
 
8141
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/shared/url.js
8142
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/shared/url.js
8142
8143
  import net from "node:net";
8143
8144
  import urllib from "node:url";
8144
8145
  function invalidUrl(input) {
@@ -8191,7 +8192,7 @@ function normalizeHostname(raw, href) {
8191
8192
  }
8192
8193
  var SLASHLESS_AUTHORITY, SURROUNDING_WHITESPACE, LEGACY_TRIM, AUTHORITY, FORBIDDEN_HOST_CHARS, CONTROL_CHARS, parse3, resolve3;
8193
8194
  var init_url = __esm({
8194
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/shared/url.js"() {
8195
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/shared/url.js"() {
8195
8196
  init_punycode();
8196
8197
  SLASHLESS_AUTHORITY = /^([a-zA-Z][a-zA-Z0-9+.-]*:)(?!\/\/)([\s\S]+)$/;
8197
8198
  SURROUNDING_WHITESPACE = /^[\x00-\x20]+|[\x00-\x20]+$/g;
@@ -8267,11 +8268,11 @@ var init_url = __esm({
8267
8268
  }
8268
8269
  });
8269
8270
 
8270
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/fetch/cookies.js
8271
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/fetch/cookies.js
8271
8272
  import net2 from "node:net";
8272
- var SESSION_TIMEOUT, Cookies;
8273
+ var SESSION_TIMEOUT, Cookies, cookies_default;
8273
8274
  var init_cookies = __esm({
8274
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/fetch/cookies.js"() {
8275
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/fetch/cookies.js"() {
8275
8276
  init_url();
8276
8277
  SESSION_TIMEOUT = 1800;
8277
8278
  Cookies = class {
@@ -8477,24 +8478,25 @@ var init_cookies = __esm({
8477
8478
  return path3;
8478
8479
  }
8479
8480
  };
8481
+ cookies_default = Cookies;
8480
8482
  }
8481
8483
  });
8482
8484
 
8483
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/package-info.js
8485
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/package-info.js
8484
8486
  var name, version2, homepage;
8485
8487
  var init_package_info = __esm({
8486
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/package-info.js"() {
8488
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/package-info.js"() {
8487
8489
  name = "nodemailer";
8488
- version2 = "10.0.10";
8490
+ version2 = "10.0.13";
8489
8491
  homepage = "https://nodemailer.com/";
8490
8492
  }
8491
8493
  });
8492
8494
 
8493
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/errors.js
8494
- var ETLS, ENOAUTH, EOAUTH2, EMAXLIMIT, EMAXRECIPIENTS, ESENDMAIL, ESES, ECONFIG, EPROXY, EFILEACCESS, EURLACCESS, EFETCH;
8495
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/errors.js
8496
+ var ECONNECTION, ENOAUTH, EOAUTH2, EMAXLIMIT, EMAXRECIPIENTS, ESENDMAIL, ESES, ECONFIG, EPROXY, EFILEACCESS, EURLACCESS, EFETCH;
8495
8497
  var init_errors = __esm({
8496
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/errors.js"() {
8497
- ETLS = "ETLS";
8498
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/errors.js"() {
8499
+ ECONNECTION = "ECONNECTION";
8498
8500
  ENOAUTH = "ENOAUTH";
8499
8501
  EOAUTH2 = "EOAUTH2";
8500
8502
  EMAXLIMIT = "EMAXLIMIT";
@@ -8509,10 +8511,10 @@ var init_errors = __esm({
8509
8511
  }
8510
8512
  });
8511
8513
 
8512
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/shared/objects.js
8514
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/shared/objects.js
8513
8515
  var isProtoKey, copyOwnKeys;
8514
8516
  var init_objects = __esm({
8515
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/shared/objects.js"() {
8517
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/shared/objects.js"() {
8516
8518
  isProtoKey = (key) => key === "__proto__";
8517
8519
  copyOwnKeys = (target, source, skip) => {
8518
8520
  Object.keys(source || {}).forEach((key) => {
@@ -8526,7 +8528,7 @@ var init_objects = __esm({
8526
8528
  }
8527
8529
  });
8528
8530
 
8529
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/fetch/index.js
8531
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/fetch/index.js
8530
8532
  import http from "node:http";
8531
8533
  import https from "node:https";
8532
8534
  import zlib from "node:zlib";
@@ -8547,7 +8549,7 @@ function parseFetchUrl(url) {
8547
8549
  function nmfetch(url, options) {
8548
8550
  options = options || {};
8549
8551
  options.fetchRes = options.fetchRes || new PassThrough();
8550
- options.cookies = options.cookies || new Cookies();
8552
+ options.cookies = options.cookies || new cookies_default();
8551
8553
  options.redirects = options.redirects || 0;
8552
8554
  options.maxRedirects = isNaN(options.maxRedirects) ? MAX_REDIRECTS : options.maxRedirects;
8553
8555
  const fetchRes = options.fetchRes;
@@ -8621,14 +8623,11 @@ function nmfetch(url, options) {
8621
8623
  return encodeURIComponent(key) + "=" + encodeURIComponent(value);
8622
8624
  }).join("&"));
8623
8625
  } catch (E) {
8624
- if (finished) {
8625
- return void 0;
8626
- }
8627
8626
  finished = true;
8628
8627
  E.code = EFETCH;
8629
8628
  E.sourceUrl = url;
8630
- fetchRes.emit("error", E);
8631
- return void 0;
8629
+ setImmediate(() => fetchRes.emit("error", E));
8630
+ return fetchRes;
8632
8631
  }
8633
8632
  } else {
8634
8633
  body = Buffer.from(options.body.toString().trim());
@@ -8672,28 +8671,21 @@ function nmfetch(url, options) {
8672
8671
  });
8673
8672
  return fetchRes;
8674
8673
  }
8675
- if (options.timeout) {
8676
- req.setTimeout(options.timeout, () => {
8677
- if (finished) {
8678
- return;
8679
- }
8680
- finished = true;
8681
- req.abort();
8682
- const err = new Error("Request Timeout");
8683
- err.code = EFETCH;
8684
- err.sourceUrl = url;
8685
- fetchRes.emit("error", err);
8686
- });
8687
- }
8688
- req.on("error", (err) => {
8674
+ const fail = (err, sourceUrl = url) => {
8689
8675
  if (finished) {
8690
8676
  return;
8691
8677
  }
8692
8678
  finished = true;
8693
8679
  err.code = EFETCH;
8694
- err.sourceUrl = url;
8680
+ err.sourceUrl = sourceUrl;
8695
8681
  fetchRes.emit("error", err);
8696
- });
8682
+ req.abort();
8683
+ };
8684
+ const timeout = typeof options.timeout === "number" && options.timeout >= 0 ? options.timeout : DEFAULT_TIMEOUT;
8685
+ if (timeout) {
8686
+ req.setTimeout(timeout, () => fail(new Error("Request Timeout")));
8687
+ }
8688
+ req.on("error", (err) => fail(err));
8697
8689
  req.on("response", (res) => {
8698
8690
  let inflate;
8699
8691
  if (finished) {
@@ -8713,13 +8705,7 @@ function nmfetch(url, options) {
8713
8705
  if ([301, 302, 303, 307, 308].includes(res.statusCode) && res.headers.location) {
8714
8706
  options.redirects++;
8715
8707
  if (options.redirects > options.maxRedirects) {
8716
- finished = true;
8717
- const err = new Error("Maximum redirect count exceeded");
8718
- err.code = EFETCH;
8719
- err.sourceUrl = url;
8720
- fetchRes.emit("error", err);
8721
- req.abort();
8722
- return;
8708
+ return fail(new Error("Maximum redirect count exceeded"));
8723
8709
  }
8724
8710
  options.method = "GET";
8725
8711
  options.body = false;
@@ -8731,13 +8717,7 @@ function nmfetch(url, options) {
8731
8717
  }
8732
8718
  const redirectParsed = parseFetchUrl(redirectUrl);
8733
8719
  if (!redirectParsed) {
8734
- finished = true;
8735
- const err = new Error("Unsupported protocol for URL " + redirectUrl);
8736
- err.code = EFETCH;
8737
- err.sourceUrl = redirectUrl;
8738
- fetchRes.emit("error", err);
8739
- req.abort();
8740
- return;
8720
+ return fail(new Error("Unsupported protocol for URL " + redirectUrl), redirectUrl);
8741
8721
  }
8742
8722
  const crossHost = redirectParsed.hostname !== parsed.hostname;
8743
8723
  const downgrade = parsed.protocol === "https:" && redirectParsed.protocol === "http:";
@@ -8749,41 +8729,31 @@ function nmfetch(url, options) {
8749
8729
  }
8750
8730
  });
8751
8731
  }
8732
+ finished = true;
8733
+ res.resume();
8734
+ req.abort();
8752
8735
  return nmfetch(redirectUrl, options);
8753
8736
  }
8754
8737
  fetchRes.statusCode = res.statusCode;
8755
8738
  fetchRes.headers = res.headers;
8756
8739
  if (res.statusCode >= 300 && !options.allowErrorResponse) {
8757
- finished = true;
8758
- const err = new Error("Invalid status code " + res.statusCode);
8759
- err.code = EFETCH;
8760
- err.sourceUrl = url;
8761
- fetchRes.emit("error", err);
8762
- req.abort();
8763
- return;
8764
- }
8765
- res.on("error", (err) => {
8766
- if (finished) {
8740
+ return fail(new Error("Invalid status code " + res.statusCode));
8741
+ }
8742
+ res.on("error", (err) => fail(err));
8743
+ const maxBytes = typeof options.maxBytes === "number" && options.maxBytes > 0 ? options.maxBytes : DEFAULT_MAX_BYTES;
8744
+ const source = inflate || res;
8745
+ let received = 0;
8746
+ source.on("data", (chunk) => {
8747
+ received += chunk.length;
8748
+ if (received <= maxBytes || finished) {
8767
8749
  return;
8768
8750
  }
8769
- finished = true;
8770
- err.code = EFETCH;
8771
- err.sourceUrl = url;
8772
- fetchRes.emit("error", err);
8773
- req.abort();
8751
+ source.unpipe(fetchRes);
8752
+ fail(new Error("Response size exceeds the allowed " + maxBytes + " bytes"));
8774
8753
  });
8775
8754
  if (inflate) {
8776
8755
  res.pipe(inflate).pipe(fetchRes);
8777
- inflate.on("error", (err) => {
8778
- if (finished) {
8779
- return;
8780
- }
8781
- finished = true;
8782
- err.code = EFETCH;
8783
- err.sourceUrl = url;
8784
- fetchRes.emit("error", err);
8785
- req.abort();
8786
- });
8756
+ inflate.on("error", (err) => fail(err));
8787
8757
  } else {
8788
8758
  res.pipe(fetchRes);
8789
8759
  }
@@ -8796,26 +8766,24 @@ function nmfetch(url, options) {
8796
8766
  }
8797
8767
  req.write(body);
8798
8768
  } catch (err) {
8799
- finished = true;
8800
- err.code = EFETCH;
8801
- err.sourceUrl = url;
8802
- fetchRes.emit("error", err);
8803
- return;
8769
+ return fail(err);
8804
8770
  }
8805
8771
  }
8806
8772
  req.end();
8807
8773
  });
8808
8774
  return fetchRes;
8809
8775
  }
8810
- var MAX_REDIRECTS, TLS_OPTION_KEYS, fetch_default;
8776
+ var MAX_REDIRECTS, DEFAULT_TIMEOUT, DEFAULT_MAX_BYTES, TLS_OPTION_KEYS, fetch_default;
8811
8777
  var init_fetch = __esm({
8812
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/fetch/index.js"() {
8778
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/fetch/index.js"() {
8813
8779
  init_url();
8814
8780
  init_cookies();
8815
8781
  init_package_info();
8816
8782
  init_errors();
8817
8783
  init_objects();
8818
8784
  MAX_REDIRECTS = 5;
8785
+ DEFAULT_TIMEOUT = 60 * 1e3;
8786
+ DEFAULT_MAX_BYTES = 64 * 1024 * 1024;
8819
8787
  TLS_OPTION_KEYS = [
8820
8788
  "ALPNProtocols",
8821
8789
  "ca",
@@ -8839,12 +8807,13 @@ var init_fetch = __esm({
8839
8807
  "sessionIdContext",
8840
8808
  "sigalgs"
8841
8809
  ];
8842
- nmfetch.Cookies = Cookies;
8810
+ nmfetch.Cookies = cookies_default;
8811
+ nmfetch.DEFAULT_TIMEOUT = DEFAULT_TIMEOUT;
8843
8812
  fetch_default = nmfetch;
8844
8813
  }
8845
8814
  });
8846
8815
 
8847
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/shared/index.js
8816
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/shared/index.js
8848
8817
  import util2 from "node:util";
8849
8818
  import fs from "node:fs";
8850
8819
  import dns from "node:dns";
@@ -8985,7 +8954,7 @@ function createDefaultLogger(levels) {
8985
8954
  }
8986
8955
  var DNS_TTL, CACHE_CLEANUP_INTERVAL, MAX_CACHE_SIZE, lastCacheCleanup, networkInterfaces, isFamilySupported, resolve4, dnsCache, formatDNSValue, resolveHostname, parseConnectionUrl, _logFunc, getLogger, callbackPromise, parseDataURI, assign, encodeXText;
8987
8956
  var init_shared = __esm({
8988
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/shared/index.js"() {
8957
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/shared/index.js"() {
8989
8958
  init_url();
8990
8959
  init_fetch();
8991
8960
  init_errors();
@@ -9259,8 +9228,9 @@ var init_shared = __esm({
9259
9228
  }
9260
9229
  const logger = options.logger === true ? createDefaultLogger(levels) : options.logger;
9261
9230
  levels.forEach((level) => {
9262
- response[level] = (data, message, ...args) => {
9263
- _logFunc(logger, level, defaults, data, message, ...args);
9231
+ response[level] = (...args) => {
9232
+ const data = typeof args[0] === "string" ? void 0 : args.shift();
9233
+ _logFunc(logger, level, defaults, data, ...args);
9264
9234
  };
9265
9235
  });
9266
9236
  return response;
@@ -9364,7 +9334,7 @@ var init_shared = __esm({
9364
9334
  }
9365
9335
  });
9366
9336
 
9367
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/mime-funcs/mime-types.js
9337
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/mime-funcs/mime-types.js
9368
9338
  import path from "node:path";
9369
9339
  function detectMimeType(filename) {
9370
9340
  if (!filename) {
@@ -9401,7 +9371,7 @@ function detectExtension(mimeType) {
9401
9371
  }
9402
9372
  var defaultMimeType, defaultExtension, mimeTypes, extensions;
9403
9373
  var init_mime_types = __esm({
9404
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/mime-funcs/mime-types.js"() {
9374
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/mime-funcs/mime-types.js"() {
9405
9375
  defaultMimeType = "application/octet-stream";
9406
9376
  defaultExtension = "bin";
9407
9377
  mimeTypes = /* @__PURE__ */ new Map([
@@ -11466,7 +11436,7 @@ var init_mime_types = __esm({
11466
11436
  }
11467
11437
  });
11468
11438
 
11469
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/base64/index.js
11439
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/base64/index.js
11470
11440
  var base64_exports = {};
11471
11441
  __export(base64_exports, {
11472
11442
  Encoder: () => Encoder,
@@ -11482,7 +11452,7 @@ function encode2(buffer) {
11482
11452
  }
11483
11453
  function wrap(str2, lineLength) {
11484
11454
  str2 = (str2 || "").toString();
11485
- lineLength = lineLength || 76;
11455
+ lineLength = Math.max(Number(lineLength) || 76, 1);
11486
11456
  if (str2.length <= lineLength) {
11487
11457
  return str2;
11488
11458
  }
@@ -11499,7 +11469,7 @@ function wrap(str2, lineLength) {
11499
11469
  }
11500
11470
  var Encoder;
11501
11471
  var init_base64 = __esm({
11502
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/base64/index.js"() {
11472
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/base64/index.js"() {
11503
11473
  Encoder = class extends Transform {
11504
11474
  constructor(options) {
11505
11475
  super();
@@ -11567,7 +11537,7 @@ var init_base64 = __esm({
11567
11537
  }
11568
11538
  });
11569
11539
 
11570
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/qp/index.js
11540
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/qp/index.js
11571
11541
  var qp_exports = {};
11572
11542
  __export(qp_exports, {
11573
11543
  Encoder: () => Encoder2,
@@ -11593,7 +11563,7 @@ function encode3(buffer) {
11593
11563
  }
11594
11564
  function wrap2(str2, lineLength) {
11595
11565
  str2 = (str2 || "").toString();
11596
- lineLength = lineLength || 76;
11566
+ lineLength = Math.max(Number(lineLength) || 76, MIN_LINE_LENGTH);
11597
11567
  if (str2.length <= lineLength) {
11598
11568
  return str2;
11599
11569
  }
@@ -11638,6 +11608,9 @@ function wrap2(str2, lineLength) {
11638
11608
  }
11639
11609
  }
11640
11610
  }
11611
+ if (!line.length) {
11612
+ line = str2.substr(pos, lineLength);
11613
+ }
11641
11614
  if (pos + line.length < len && line.substr(-1) !== "\n") {
11642
11615
  if (line.length === lineLength && line.match(/[=][\da-f]{2}$/i)) {
11643
11616
  line = line.substr(0, line.length - 3);
@@ -11668,9 +11641,10 @@ function checkRanges(nr, ranges) {
11668
11641
  }
11669
11642
  return false;
11670
11643
  }
11671
- var QP_RANGES, Encoder2;
11644
+ var MIN_LINE_LENGTH, QP_RANGES, Encoder2;
11672
11645
  var init_qp = __esm({
11673
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/qp/index.js"() {
11646
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/qp/index.js"() {
11647
+ MIN_LINE_LENGTH = 4;
11674
11648
  QP_RANGES = [
11675
11649
  [9],
11676
11650
  // <TAB>
@@ -11734,7 +11708,7 @@ var init_qp = __esm({
11734
11708
  }
11735
11709
  });
11736
11710
 
11737
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/mime-funcs/index.js
11711
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/mime-funcs/index.js
11738
11712
  function isPlainText(value, isParam) {
11739
11713
  const re = isParam ? /[\x00-\x1f\x7f"\u0080-\uFFFF]/ : /[\x00-\x08\x0b\x0c\x0e-\x1f\u0080-\uFFFF]/;
11740
11714
  return typeof value === "string" && !re.test(value);
@@ -11942,7 +11916,7 @@ function buildHeaderParam(key, data, maxLength) {
11942
11916
  }
11943
11917
  function parseHeaderValue(str2) {
11944
11918
  const response = {
11945
- value: false,
11919
+ value: "",
11946
11920
  params: {}
11947
11921
  };
11948
11922
  const setParam = (name2, value2) => {
@@ -12133,7 +12107,7 @@ function safeEncodeURIComponent(str2) {
12133
12107
  return str2.replace(/[\x00-\x1F *'()<>@,;:\\"[\]?=\u007F-\uFFFF]/g, (chr) => encodeURICharComponent(chr));
12134
12108
  }
12135
12109
  var init_mime_funcs = __esm({
12136
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/mime-funcs/index.js"() {
12110
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/mime-funcs/index.js"() {
12137
12111
  init_base64();
12138
12112
  init_qp();
12139
12113
  init_mime_types();
@@ -12141,7 +12115,7 @@ var init_mime_funcs = __esm({
12141
12115
  }
12142
12116
  });
12143
12117
 
12144
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/addressparser/index.js
12118
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/addressparser/index.js
12145
12119
  function _quoteLocalPart(address) {
12146
12120
  const lastAt = address.lastIndexOf("@");
12147
12121
  if (lastAt < 0) {
@@ -12249,6 +12223,58 @@ function _recoverAddrSpec(data) {
12249
12223
  data.address = address;
12250
12224
  data.text = [data.text].concat(rest).filter((part) => part).join(" ");
12251
12225
  }
12226
+ function _stripAddressComments(address) {
12227
+ const comments = [];
12228
+ let result = "";
12229
+ let comment = "";
12230
+ let depth = 0;
12231
+ let closer = "";
12232
+ let lastChar = "";
12233
+ for (let i = 0, len = address.length; i < len; i++) {
12234
+ const chr = address.charAt(i);
12235
+ if (depth) {
12236
+ if (chr === "\\" && i < len - 1) {
12237
+ comment += address.charAt(++i);
12238
+ } else if (chr === "(") {
12239
+ depth++;
12240
+ comment += chr;
12241
+ } else if (chr === ")" && !--depth) {
12242
+ comments.push(comment.trim());
12243
+ comment = "";
12244
+ if (lastChar !== "@" && address.charAt(i + 1) !== "@") {
12245
+ result += " ";
12246
+ lastChar = " ";
12247
+ }
12248
+ } else {
12249
+ comment += chr;
12250
+ }
12251
+ continue;
12252
+ }
12253
+ if (closer) {
12254
+ if (chr === "\\" && closer === '"' && i < len - 1) {
12255
+ result += chr + address.charAt(++i);
12256
+ lastChar = address.charAt(i);
12257
+ continue;
12258
+ }
12259
+ if (chr === closer) {
12260
+ closer = "";
12261
+ }
12262
+ } else if (chr === '"') {
12263
+ closer = '"';
12264
+ } else if (chr === "[") {
12265
+ closer = "]";
12266
+ } else if (chr === "(") {
12267
+ depth = 1;
12268
+ continue;
12269
+ }
12270
+ result += chr;
12271
+ lastChar = chr;
12272
+ }
12273
+ if (depth) {
12274
+ comments.push(comment.trim());
12275
+ }
12276
+ return { address: result.trim(), comments: comments.filter((text) => text) };
12277
+ }
12252
12278
  function _handleAddress(tokens, depth) {
12253
12279
  let isGroup = false;
12254
12280
  let state = "text";
@@ -12336,6 +12362,22 @@ function _handleAddress(tokens, depth) {
12336
12362
  group: groupMembers
12337
12363
  });
12338
12364
  } else {
12365
+ const addressComments = [];
12366
+ const addressParts = [];
12367
+ for (const part of data.address) {
12368
+ if (part.indexOf("(") < 0) {
12369
+ addressParts.push(part);
12370
+ continue;
12371
+ }
12372
+ const stripped = _stripAddressComments(part);
12373
+ for (const comment of stripped.comments) {
12374
+ addressComments.push(comment);
12375
+ }
12376
+ if (stripped.address) {
12377
+ addressParts.push(stripped.address);
12378
+ }
12379
+ }
12380
+ data.address = addressParts;
12339
12381
  if (!data.address.length && data.text.length) {
12340
12382
  for (let i = data.text.length - 1; i >= 0; i--) {
12341
12383
  if (!data.textWasQuoted[i] && ADDR_SPEC.test(data.text[i])) {
@@ -12383,6 +12425,9 @@ function _handleAddress(tokens, depth) {
12383
12425
  data.text = "";
12384
12426
  }
12385
12427
  _recoverAddrSpec(data);
12428
+ if (!data.text && addressComments.length) {
12429
+ data.text = addressComments.join(" ");
12430
+ }
12386
12431
  const address = {
12387
12432
  address: data.address || data.text || "",
12388
12433
  name: data.text || data.address || ""
@@ -12455,9 +12500,9 @@ function addressparser(str2, options) {
12455
12500
  }
12456
12501
  return parsedAddresses;
12457
12502
  }
12458
- var HAS_WHITESPACE, QUOTED_LOCAL_ADDR, ADDR_SPEC, LOOSE_ADDR_SPEC, LOOSE_TEXT_ADDR, Tokenizer, MAX_NESTED_GROUP_DEPTH;
12503
+ var HAS_WHITESPACE, QUOTED_LOCAL_ADDR, ADDR_SPEC, LOOSE_ADDR_SPEC, LOOSE_TEXT_ADDR, Tokenizer, MAX_NESTED_GROUP_DEPTH, addressparser_default;
12459
12504
  var init_addressparser = __esm({
12460
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/addressparser/index.js"() {
12505
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/addressparser/index.js"() {
12461
12506
  HAS_WHITESPACE = /\s/;
12462
12507
  QUOTED_LOCAL_ADDR = /^("(?:[^"\\]|\\[\s\S])*"@\S+)(?:\s+([\s\S]+))?$/;
12463
12508
  ADDR_SPEC = /^[^@\s]+@[^@\s]+$/;
@@ -12565,14 +12610,15 @@ var init_addressparser = __esm({
12565
12610
  }
12566
12611
  };
12567
12612
  MAX_NESTED_GROUP_DEPTH = 50;
12613
+ addressparser_default = addressparser;
12568
12614
  }
12569
12615
  });
12570
12616
 
12571
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/mime-node/last-newline.js
12617
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/mime-node/last-newline.js
12572
12618
  import { Transform as Transform3 } from "node:stream";
12573
12619
  var LastNewline;
12574
12620
  var init_last_newline = __esm({
12575
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/mime-node/last-newline.js"() {
12621
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/mime-node/last-newline.js"() {
12576
12622
  LastNewline = class extends Transform3 {
12577
12623
  constructor() {
12578
12624
  super();
@@ -12602,11 +12648,11 @@ var init_last_newline = __esm({
12602
12648
  }
12603
12649
  });
12604
12650
 
12605
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/mime-node/le-windows.js
12651
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/mime-node/le-windows.js
12606
12652
  import { Transform as Transform4 } from "node:stream";
12607
12653
  var LeWindows;
12608
12654
  var init_le_windows = __esm({
12609
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/mime-node/le-windows.js"() {
12655
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/mime-node/le-windows.js"() {
12610
12656
  LeWindows = class extends Transform4 {
12611
12657
  constructor(options) {
12612
12658
  super(options);
@@ -12644,11 +12690,11 @@ var init_le_windows = __esm({
12644
12690
  }
12645
12691
  });
12646
12692
 
12647
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/mime-node/le-unix.js
12693
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/mime-node/le-unix.js
12648
12694
  import { Transform as Transform5 } from "node:stream";
12649
12695
  var LeUnix;
12650
12696
  var init_le_unix = __esm({
12651
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/mime-node/le-unix.js"() {
12697
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/mime-node/le-unix.js"() {
12652
12698
  LeUnix = class extends Transform5 {
12653
12699
  constructor(options) {
12654
12700
  super(options);
@@ -12679,7 +12725,7 @@ var init_le_unix = __esm({
12679
12725
  }
12680
12726
  });
12681
12727
 
12682
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/mime-node/index.js
12728
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/mime-node/index.js
12683
12729
  import crypto from "node:crypto";
12684
12730
  import fs2 from "node:fs";
12685
12731
  import { PassThrough as PassThrough2 } from "node:stream";
@@ -12699,7 +12745,7 @@ function _stripBoundaryControls(value) {
12699
12745
  }
12700
12746
  var FORMATTED_HEADERS, ATEXT, DOT_ATOM, QUOTED_STRING, PLAIN_ADDRESS, URL_PARSER_UNSAFE, MimeNode, mime_node_default;
12701
12747
  var init_mime_node = __esm({
12702
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/mime-node/index.js"() {
12748
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/mime-node/index.js"() {
12703
12749
  init_punycode();
12704
12750
  init_shared();
12705
12751
  init_mime_funcs();
@@ -13516,7 +13562,7 @@ var init_mime_node = __esm({
13516
13562
  flattened.push(copy);
13517
13563
  continue;
13518
13564
  }
13519
- const parsed = this._normalizeParsedAddresses(addressparser(address));
13565
+ const parsed = this._normalizeParsedAddresses(addressparser_default(address));
13520
13566
  for (let i = 0; i < parsed.length; i++) {
13521
13567
  flattened.push(parsed[i]);
13522
13568
  }
@@ -13826,14 +13872,14 @@ var init_mime_node = __esm({
13826
13872
  }
13827
13873
  });
13828
13874
 
13829
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/mail-composer/index.js
13875
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/mail-composer/index.js
13830
13876
  function isContentObject(value) {
13831
13877
  const content = value;
13832
13878
  return typeof value === "object" && !!(content.content || content.path || content.href || content.raw);
13833
13879
  }
13834
13880
  var MailComposer, mail_composer_default;
13835
13881
  var init_mail_composer = __esm({
13836
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/mail-composer/index.js"() {
13882
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/mail-composer/index.js"() {
13837
13883
  init_mime_node();
13838
13884
  init_mime_funcs();
13839
13885
  init_shared();
@@ -14320,11 +14366,11 @@ var init_mail_composer = __esm({
14320
14366
  }
14321
14367
  });
14322
14368
 
14323
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/dkim/message-parser.js
14369
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/dkim/message-parser.js
14324
14370
  import { Transform as Transform6 } from "node:stream";
14325
- var MessageParser;
14371
+ var MessageParser, message_parser_default;
14326
14372
  var init_message_parser = __esm({
14327
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/dkim/message-parser.js"() {
14373
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/dkim/message-parser.js"() {
14328
14374
  MessageParser = class extends Transform6 {
14329
14375
  constructor(options) {
14330
14376
  super(options);
@@ -14448,15 +14494,16 @@ var init_message_parser = __esm({
14448
14494
  }));
14449
14495
  }
14450
14496
  };
14497
+ message_parser_default = MessageParser;
14451
14498
  }
14452
14499
  });
14453
14500
 
14454
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/dkim/relaxed-body.js
14501
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/dkim/relaxed-body.js
14455
14502
  import { Transform as Transform7 } from "node:stream";
14456
14503
  import crypto2 from "node:crypto";
14457
- var CHAR_CR, CHAR_LF, CHAR_SPACE, CHAR_TAB, CRLF, EMPTY_LINES, RelaxedBody;
14504
+ var CHAR_CR, CHAR_LF, CHAR_SPACE, CHAR_TAB, CRLF, EMPTY_LINES, RelaxedBody, relaxed_body_default;
14458
14505
  var init_relaxed_body = __esm({
14459
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/dkim/relaxed-body.js"() {
14506
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/dkim/relaxed-body.js"() {
14460
14507
  CHAR_CR = 13;
14461
14508
  CHAR_LF = 10;
14462
14509
  CHAR_SPACE = 32;
@@ -14574,11 +14621,17 @@ var init_relaxed_body = __esm({
14574
14621
  callback();
14575
14622
  }
14576
14623
  };
14624
+ relaxed_body_default = RelaxedBody;
14577
14625
  }
14578
14626
  });
14579
14627
 
14580
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/dkim/sign.js
14628
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/dkim/sign.js
14581
14629
  import crypto3 from "node:crypto";
14630
+ function unsupportedHashAlgoError(hashAlgo) {
14631
+ const err = new Error('Unsupported DKIM hash algorithm "' + hashAlgo + '"');
14632
+ err.code = ECONFIG;
14633
+ return err;
14634
+ }
14582
14635
  function sign(headers, hashAlgo, bodyHash, options) {
14583
14636
  options = options || {};
14584
14637
  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";
@@ -14586,7 +14639,12 @@ function sign(headers, hashAlgo, bodyHash, options) {
14586
14639
  const canonicalizedHeaderData = relaxedHeaders(headers, fieldNames, options.skipFields);
14587
14640
  const dkimHeader = generateDKIMHeader(options.domainName, options.keySelector, canonicalizedHeaderData.fieldNames, hashAlgo, bodyHash);
14588
14641
  canonicalizedHeaderData.headers += "dkim-signature:" + relaxedHeaderLine(dkimHeader);
14589
- const signer = crypto3.createSign(("rsa-" + hashAlgo).toUpperCase());
14642
+ let signer;
14643
+ try {
14644
+ signer = crypto3.createSign(("rsa-" + hashAlgo).toUpperCase());
14645
+ } catch (_E) {
14646
+ throw unsupportedHashAlgoError(hashAlgo);
14647
+ }
14590
14648
  signer.update(canonicalizedHeaderData.headers, "latin1");
14591
14649
  let signature;
14592
14650
  try {
@@ -14644,22 +14702,24 @@ function relaxedHeaderLine(line) {
14644
14702
  }
14645
14703
  var sign_default;
14646
14704
  var init_sign = __esm({
14647
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/dkim/sign.js"() {
14705
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/dkim/sign.js"() {
14648
14706
  init_punycode();
14649
14707
  init_mime_funcs();
14708
+ init_errors();
14650
14709
  sign.relaxedHeaders = relaxedHeaders;
14710
+ sign.unsupportedHashAlgoError = unsupportedHashAlgoError;
14651
14711
  sign_default = sign;
14652
14712
  }
14653
14713
  });
14654
14714
 
14655
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/dkim/index.js
14715
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/dkim/index.js
14656
14716
  import { PassThrough as PassThrough3 } from "node:stream";
14657
14717
  import fs3 from "node:fs";
14658
14718
  import path2 from "node:path";
14659
14719
  import crypto4 from "node:crypto";
14660
14720
  var DKIM_ALGO, MAX_MESSAGE_SIZE, DKIMSigner, DKIM, dkim_default;
14661
14721
  var init_dkim = __esm({
14662
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/dkim/index.js"() {
14722
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/dkim/index.js"() {
14663
14723
  init_message_parser();
14664
14724
  init_relaxed_body();
14665
14725
  init_sign();
@@ -14738,13 +14798,21 @@ var init_dkim = __esm({
14738
14798
  return;
14739
14799
  }
14740
14800
  const key = this.keys[keyPos++];
14741
- const dkimField = sign_default(this.headers, this.hashAlgo, this.bodyHash, {
14742
- domainName: key.domainName,
14743
- keySelector: key.keySelector,
14744
- privateKey: key.privateKey,
14745
- headerFieldNames: this.options.headerFieldNames,
14746
- skipFields: this.options.skipFields
14747
- });
14801
+ let dkimField;
14802
+ try {
14803
+ dkimField = sign_default(this.headers, this.hashAlgo, this.bodyHash, {
14804
+ domainName: key.domainName,
14805
+ keySelector: key.keySelector,
14806
+ privateKey: key.privateKey,
14807
+ headerFieldNames: this.options.headerFieldNames,
14808
+ skipFields: this.options.skipFields
14809
+ });
14810
+ } catch (err) {
14811
+ this.hasErrored = true;
14812
+ this.cleanup();
14813
+ this.output.emit("error", err);
14814
+ return;
14815
+ }
14748
14816
  if (dkimField) {
14749
14817
  this.output.write(Buffer.from(dkimField + "\r\n"));
14750
14818
  }
@@ -14776,8 +14844,8 @@ var init_dkim = __esm({
14776
14844
  this.relaxedBody.pipe(this.cache);
14777
14845
  }
14778
14846
  signStream() {
14779
- this.parser = new MessageParser();
14780
- this.relaxedBody = new RelaxedBody({
14847
+ this.parser = new message_parser_default();
14848
+ this.relaxedBody = new relaxed_body_default({
14781
14849
  hashAlgo: this.hashAlgo
14782
14850
  });
14783
14851
  this.parser.on("headers", (value) => {
@@ -14836,7 +14904,12 @@ var init_dkim = __esm({
14836
14904
  }
14837
14905
  const signer = new DKIMSigner(options, this.keys, inputStream, output);
14838
14906
  setImmediate(() => {
14839
- signer.signStream();
14907
+ try {
14908
+ signer.signStream();
14909
+ } catch (_E) {
14910
+ output.emit("error", sign_default.unsupportedHashAlgoError(signer.hashAlgo));
14911
+ return;
14912
+ }
14840
14913
  if (writeValue) {
14841
14914
  setImmediate(() => {
14842
14915
  inputStream.end(writeValue);
@@ -14850,7 +14923,7 @@ var init_dkim = __esm({
14850
14923
  }
14851
14924
  });
14852
14925
 
14853
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/smtp-connection/http-proxy-client.js
14926
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/smtp-connection/http-proxy-client.js
14854
14927
  import net5 from "node:net";
14855
14928
  import tls from "node:tls";
14856
14929
  function httpProxyClient(proxyUrl, destinationPort, destinationHost, tlsOptions, callback) {
@@ -14859,11 +14932,12 @@ function httpProxyClient(proxyUrl, destinationPort, destinationHost, tlsOptions,
14859
14932
  tlsOptions = {};
14860
14933
  }
14861
14934
  tlsOptions = tlsOptions || {};
14935
+ const done = callback;
14862
14936
  destinationPort = Number(destinationPort) || 0;
14863
14937
  if (!destinationPort || /[\r\n]/.test(destinationHost)) {
14864
14938
  const err = new Error("Invalid proxy destination");
14865
14939
  err.code = EPROXY;
14866
- setImmediate(() => callback(err));
14940
+ setImmediate(() => done(err));
14867
14941
  return;
14868
14942
  }
14869
14943
  const proxy = parse3(proxyUrl);
@@ -14889,7 +14963,7 @@ function httpProxyClient(proxyUrl, destinationPort, destinationHost, tlsOptions,
14889
14963
  socket.destroy();
14890
14964
  } catch (_E) {
14891
14965
  }
14892
- callback(err);
14966
+ done(err);
14893
14967
  };
14894
14968
  const timeoutErr = () => {
14895
14969
  const err = new Error("Proxy socket timed out");
@@ -14937,12 +15011,12 @@ function httpProxyClient(proxyUrl, destinationPort, destinationHost, tlsOptions,
14937
15011
  }
14938
15012
  const err = new Error("Invalid response from proxy" + (match && ": " + match[1] || ""));
14939
15013
  err.code = EPROXY;
14940
- return callback(err);
15014
+ return done(err);
14941
15015
  }
14942
15016
  socket.removeListener("error", tempSocketErr);
14943
15017
  socket.removeListener("timeout", timeoutErr);
14944
15018
  socket.setTimeout(0);
14945
- return callback(null, socket);
15019
+ return done(null, socket);
14946
15020
  }
14947
15021
  if (headers.length > MAX_RESPONSE_HEADER_BYTES) {
14948
15022
  socket.removeListener("data", onSocketData);
@@ -14959,7 +15033,7 @@ function httpProxyClient(proxyUrl, destinationPort, destinationHost, tlsOptions,
14959
15033
  }
14960
15034
  var MAX_RESPONSE_HEADER_BYTES, http_proxy_client_default;
14961
15035
  var init_http_proxy_client = __esm({
14962
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/smtp-connection/http-proxy-client.js"() {
15036
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/smtp-connection/http-proxy-client.js"() {
14963
15037
  init_url();
14964
15038
  init_errors();
14965
15039
  MAX_RESPONSE_HEADER_BYTES = 64 * 1024;
@@ -14967,10 +15041,10 @@ var init_http_proxy_client = __esm({
14967
15041
  }
14968
15042
  });
14969
15043
 
14970
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/mailer/mail-message.js
15044
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/mailer/mail-message.js
14971
15045
  var hasOwn, MailMessage;
14972
15046
  var init_mail_message = __esm({
14973
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/mailer/mail-message.js"() {
15047
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/mailer/mail-message.js"() {
14974
15048
  init_shared();
14975
15049
  init_mime_node();
14976
15050
  init_mime_funcs();
@@ -15227,7 +15301,7 @@ var init_mail_message = __esm({
15227
15301
  }
15228
15302
  });
15229
15303
 
15230
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/mailer/index.js
15304
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/mailer/index.js
15231
15305
  import { EventEmitter } from "node:events";
15232
15306
  import util3 from "node:util";
15233
15307
  import net6 from "node:net";
@@ -15235,7 +15309,7 @@ import dns2 from "node:dns";
15235
15309
  import crypto5 from "node:crypto";
15236
15310
  var DEFAULT_MAX_RECIPIENTS, Mail, mailer_default;
15237
15311
  var init_mailer = __esm({
15238
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/mailer/index.js"() {
15312
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/mailer/index.js"() {
15239
15313
  init_shared();
15240
15314
  init_mime_types();
15241
15315
  init_mail_composer();
@@ -15580,11 +15654,15 @@ var init_mailer = __esm({
15580
15654
  }
15581
15655
  });
15582
15656
 
15583
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/smtp-connection/data-stream.js
15657
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/smtp-connection/data-stream.js
15584
15658
  import { Transform as Transform8 } from "node:stream";
15585
- var DataStream;
15659
+ var INSERT_LF, INSERT_LF_DOT, INSERT_CR, INSERT_DOT, DataStream;
15586
15660
  var init_data_stream = __esm({
15587
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/smtp-connection/data-stream.js"() {
15661
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/smtp-connection/data-stream.js"() {
15662
+ INSERT_LF = Buffer.from("\n");
15663
+ INSERT_LF_DOT = Buffer.from("\n.");
15664
+ INSERT_CR = Buffer.from("\r");
15665
+ INSERT_DOT = Buffer.from(".");
15588
15666
  DataStream = class extends Transform8 {
15589
15667
  constructor(options) {
15590
15668
  super(options);
@@ -15610,29 +15688,28 @@ var init_data_stream = __esm({
15610
15688
  }
15611
15689
  this.inByteCount += chunk.length;
15612
15690
  for (i = 0, len = chunk.length; i < len; i++) {
15613
- if (chunk[i] === 46) {
15614
- if (i && chunk[i - 1] === 10 || !i && (!this.lastByte || this.lastByte === 10)) {
15615
- buf = chunk.slice(lastPos, i + 1);
15691
+ const byte = chunk[i];
15692
+ const prev = i ? chunk[i - 1] : this.lastByte;
15693
+ let insert = false;
15694
+ if (prev === 13 && byte !== 10) {
15695
+ insert = byte === 46 ? INSERT_LF_DOT : INSERT_LF;
15696
+ } else if (byte === 10 && prev !== 13) {
15697
+ insert = INSERT_CR;
15698
+ } else if (byte === 46 && (prev === 10 || prev === false)) {
15699
+ insert = INSERT_DOT;
15700
+ }
15701
+ if (insert) {
15702
+ if (i > lastPos) {
15703
+ buf = chunk.slice(lastPos, i);
15616
15704
  chunks.push(buf);
15617
- chunks.push(Buffer.from("."));
15618
- chunklen += buf.length + 1;
15619
- lastPos = i + 1;
15620
- }
15621
- } else if (chunk[i] === 10) {
15622
- if (i && chunk[i - 1] !== 13 || !i && this.lastByte !== 13) {
15623
- if (i > lastPos) {
15624
- buf = chunk.slice(lastPos, i);
15625
- chunks.push(buf);
15626
- chunklen += buf.length + 2;
15627
- } else {
15628
- chunklen += 2;
15629
- }
15630
- chunks.push(Buffer.from("\r\n"));
15631
- lastPos = i + 1;
15705
+ chunklen += buf.length;
15632
15706
  }
15707
+ chunks.push(insert);
15708
+ chunklen += insert.length;
15709
+ lastPos = i;
15633
15710
  }
15634
15711
  }
15635
- if (chunklen) {
15712
+ if (chunks.length) {
15636
15713
  if (lastPos < chunk.length) {
15637
15714
  buf = chunk.slice(lastPos);
15638
15715
  chunks.push(buf);
@@ -15668,7 +15745,7 @@ var init_data_stream = __esm({
15668
15745
  }
15669
15746
  });
15670
15747
 
15671
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/smtp-connection/index.js
15748
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/smtp-connection/index.js
15672
15749
  import { EventEmitter as EventEmitter2 } from "node:events";
15673
15750
  import net7 from "node:net";
15674
15751
  import tls2 from "node:tls";
@@ -15690,7 +15767,7 @@ function isPartialLine(line) {
15690
15767
  }
15691
15768
  var CONNECTION_TIMEOUT, SOCKET_TIMEOUT, GREETING_TIMEOUT, DNS_TIMEOUT, TEARDOWN_NOOP, MAX_RESPONSE_SIZE, SMTPConnection, smtp_connection_default;
15692
15769
  var init_smtp_connection = __esm({
15693
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/smtp-connection/index.js"() {
15770
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/smtp-connection/index.js"() {
15694
15771
  init_package_info();
15695
15772
  init_data_stream();
15696
15773
  init_shared();
@@ -15707,6 +15784,9 @@ var init_smtp_connection = __esm({
15707
15784
  this.id = crypto6.randomBytes(8).toString("base64").replace(/\W/g, "");
15708
15785
  this.stage = "init";
15709
15786
  this.options = options || {};
15787
+ if (this.options.requireTLS && (this.options.ignoreTLS || this.options.opportunisticTLS)) {
15788
+ this.options = Object.assign({}, this.options, { ignoreTLS: false, opportunisticTLS: false });
15789
+ }
15710
15790
  this.secureConnection = !!this.options.secure;
15711
15791
  this.alreadySecured = !!this.options.secured;
15712
15792
  this.port = Number(this.options.port) || (this.secureConnection ? 465 : 587);
@@ -15749,6 +15829,8 @@ var init_smtp_connection = __esm({
15749
15829
  this._destroyed = false;
15750
15830
  this._closing = false;
15751
15831
  this._currentDataStream = false;
15832
+ this._pendingSend = false;
15833
+ this._connectCallback = false;
15752
15834
  this._onSocketData = (chunk) => this._onData(chunk);
15753
15835
  this._onSocketError = (error3) => this._onError(error3, "ESOCKET", false, "CONN");
15754
15836
  this._onSocketClose = () => this._onClose();
@@ -15763,7 +15845,9 @@ var init_smtp_connection = __esm({
15763
15845
  */
15764
15846
  connect(connectCallback) {
15765
15847
  if (typeof connectCallback === "function") {
15848
+ this._connectCallback = connectCallback;
15766
15849
  this.once("connect", () => {
15850
+ this._connectCallback = false;
15767
15851
  this.logger.debug({
15768
15852
  tnx: "smtp"
15769
15853
  }, "SMTP handshake finished");
@@ -15963,6 +16047,14 @@ var init_smtp_connection = __esm({
15963
16047
  }
15964
16048
  this._currentDataStream = false;
15965
16049
  }
16050
+ if (this._pendingSend) {
16051
+ const { stream, onStreamError } = this._pendingSend;
16052
+ if (stream) {
16053
+ stream.removeListener("error", onStreamError);
16054
+ stream.on("error", TEARDOWN_NOOP);
16055
+ }
16056
+ this._pendingSend = false;
16057
+ }
15966
16058
  if (socket && !socket.destroyed) {
15967
16059
  try {
15968
16060
  socket.setTimeout(0);
@@ -15989,12 +16081,14 @@ var init_smtp_connection = __esm({
15989
16081
  }
15990
16082
  this._auth = authData || {};
15991
16083
  this._authMethod = (this._auth.method || "").toString().trim().toUpperCase() || false;
16084
+ const canUseXOAuth2 = !!this._auth.oauth2 || this.customAuth.has("XOAUTH2");
15992
16085
  if (!this._authMethod && this._auth.oauth2 && !this._auth.credentials) {
15993
16086
  this._authMethod = "XOAUTH2";
15994
16087
  } else if (!this._authMethod || this._authMethod === "XOAUTH2" && !this._auth.oauth2) {
15995
- this._authMethod = (this._supportedAuth[0] || "PLAIN").toUpperCase().trim();
16088
+ const supported = this._supportedAuth.find((method) => method !== "XOAUTH2" || canUseXOAuth2);
16089
+ this._authMethod = (supported || "PLAIN").toUpperCase().trim();
15996
16090
  }
15997
- if (this._authMethod !== "XOAUTH2" && (!this._auth.credentials || !this._auth.credentials.user || !this._auth.credentials.pass)) {
16091
+ if ((this._authMethod !== "XOAUTH2" || this.customAuth.has("XOAUTH2")) && (!this._auth.credentials || !this._auth.credentials.user || !this._auth.credentials.pass)) {
15998
16092
  if (this._auth.user && this._auth.pass || this.customAuth.has(this._authMethod)) {
15999
16093
  this._auth.credentials = {
16000
16094
  user: this._auth.user,
@@ -16030,41 +16124,42 @@ var init_smtp_connection = __esm({
16030
16124
  returned = true;
16031
16125
  callback(this._formatError(err, "EAUTH", lastResponse, "AUTH " + this._authMethod));
16032
16126
  };
16127
+ const sendCommand = (cmd, done) => {
16128
+ let promise;
16129
+ if (!done) {
16130
+ promise = new Promise((resolve6, reject2) => {
16131
+ done = callbackPromise(resolve6, reject2);
16132
+ });
16133
+ }
16134
+ this._responseActions.push((str2) => {
16135
+ lastResponse = str2;
16136
+ let codes = str2.match(/^(\d+)(?:\s(\d+\.\d+\.\d+))?\s/);
16137
+ let data = {
16138
+ command: cmd,
16139
+ response: str2
16140
+ };
16141
+ if (codes) {
16142
+ data.status = Number(codes[1]) || 0;
16143
+ if (codes[2]) {
16144
+ data.code = codes[2];
16145
+ }
16146
+ data.text = str2.substr(codes[0].length);
16147
+ } else {
16148
+ data.text = str2;
16149
+ data.status = 0;
16150
+ }
16151
+ done(null, data);
16152
+ });
16153
+ setImmediate(() => this._sendCommand(cmd));
16154
+ return promise;
16155
+ };
16033
16156
  const handlerResponse = handler({
16034
16157
  auth: this._auth,
16035
16158
  method: this._authMethod,
16036
16159
  extensions: [].concat(this._supportedExtensions),
16037
16160
  authMethods: [].concat(this._supportedAuth),
16038
16161
  maxAllowedSize: this._maxAllowedSize || false,
16039
- sendCommand: (cmd, done) => {
16040
- let promise;
16041
- if (!done) {
16042
- promise = new Promise((resolve6, reject2) => {
16043
- done = callbackPromise(resolve6, reject2);
16044
- });
16045
- }
16046
- this._responseActions.push((str2) => {
16047
- lastResponse = str2;
16048
- let codes = str2.match(/^(\d+)(?:\s(\d+\.\d+\.\d+))?\s/);
16049
- let data = {
16050
- command: cmd,
16051
- response: str2
16052
- };
16053
- if (codes) {
16054
- data.status = Number(codes[1]) || 0;
16055
- if (codes[2]) {
16056
- data.code = codes[2];
16057
- }
16058
- data.text = str2.substr(codes[0].length);
16059
- } else {
16060
- data.text = str2;
16061
- data.status = 0;
16062
- }
16063
- done(null, data);
16064
- });
16065
- setImmediate(() => this._sendCommand(cmd));
16066
- return promise;
16067
- },
16162
+ sendCommand,
16068
16163
  resolve: resolve5,
16069
16164
  reject
16070
16165
  });
@@ -16120,30 +16215,40 @@ var init_smtp_connection = __esm({
16120
16215
  * @param callback Callback to return once sending is completed
16121
16216
  */
16122
16217
  send(envelope, message, done) {
16218
+ let returned = false;
16219
+ const callback = (err, info) => {
16220
+ if (returned) {
16221
+ return;
16222
+ }
16223
+ returned = true;
16224
+ if (this._pendingSend && this._pendingSend.callback === callback) {
16225
+ this._pendingSend = false;
16226
+ }
16227
+ done(err, info);
16228
+ };
16123
16229
  if (!message) {
16124
- return done(this._formatError("Empty message", "EMESSAGE", false, "API"));
16230
+ return callback(this._formatError("Empty message", "EMESSAGE", false, "API"));
16125
16231
  }
16126
16232
  const isDestroyedMessage = this._isDestroyedMessage("send message");
16127
16233
  if (isDestroyedMessage) {
16128
- return done(this._formatError(isDestroyedMessage, "ECONNECTION", false, "API"));
16234
+ return callback(this._formatError(isDestroyedMessage, "ECONNECTION", false, "API"));
16129
16235
  }
16130
16236
  if (this._maxAllowedSize && envelope.size > this._maxAllowedSize) {
16131
16237
  setImmediate(() => {
16132
- done(this._formatError("Message size larger than allowed " + this._maxAllowedSize, "EMESSAGE", false, "MAIL FROM"));
16238
+ callback(this._formatError("Message size larger than allowed " + this._maxAllowedSize, "EMESSAGE", false, "MAIL FROM"));
16133
16239
  });
16134
16240
  return;
16135
16241
  }
16136
- let returned = false;
16137
- const callback = function(...args) {
16138
- if (returned) {
16139
- return;
16140
- }
16141
- returned = true;
16142
- done(...args);
16242
+ const pendingSend = {
16243
+ callback,
16244
+ stream: false,
16245
+ onStreamError: (err) => callback(this._formatError(err, "ESTREAM", false, "API"))
16143
16246
  };
16144
16247
  if (typeof message.on === "function") {
16145
- message.on("error", (err) => callback(this._formatError(err, "ESTREAM", false, "API")));
16248
+ pendingSend.stream = message;
16249
+ pendingSend.stream.on("error", pendingSend.onStreamError);
16146
16250
  }
16251
+ this._pendingSend = pendingSend;
16147
16252
  const startTime = Date.now();
16148
16253
  this._setEnvelope(envelope, (err, info) => {
16149
16254
  if (err) {
@@ -16161,11 +16266,12 @@ var init_smtp_connection = __esm({
16161
16266
  if (err2) {
16162
16267
  return callback(err2);
16163
16268
  }
16164
- info.envelopeTime = envelopeTime - startTime;
16165
- info.messageTime = Date.now() - envelopeTime;
16166
- info.messageSize = stream.outByteCount;
16167
- info.response = str2;
16168
- return callback(null, info);
16269
+ const result = info;
16270
+ result.envelopeTime = envelopeTime - startTime;
16271
+ result.messageTime = Date.now() - envelopeTime;
16272
+ result.messageSize = stream.outByteCount;
16273
+ result.response = str2;
16274
+ return callback(null, result);
16169
16275
  });
16170
16276
  if (typeof message.pipe === "function") {
16171
16277
  message.pipe(stream);
@@ -16309,8 +16415,12 @@ var init_smtp_connection = __esm({
16309
16415
  } else {
16310
16416
  this.logger.error(data, err.message);
16311
16417
  }
16418
+ const pendingSend = this._pendingSend;
16312
16419
  this.emit("error", err);
16313
16420
  this.close();
16421
+ if (pendingSend) {
16422
+ pendingSend.callback(err);
16423
+ }
16314
16424
  }
16315
16425
  /** @internal */
16316
16426
  _formatError(message, type, response, command) {
@@ -16355,12 +16465,21 @@ var init_smtp_connection = __esm({
16355
16465
  this.logger.info({
16356
16466
  tnx: "network"
16357
16467
  }, "Connection closed");
16468
+ const failureResponse = typeof serverResponse === "string" && /^[45]\d{2}[ -]/.test(serverResponse) ? serverResponse : false;
16358
16469
  if (this.upgrading && !this._destroyed) {
16359
- return this._onError(new Error("Connection closed unexpectedly"), "ETLS", serverResponse, "CONN");
16360
- } else if (![this._actionGreeting, this.close].includes(this._responseActions[0]) && !this._destroyed) {
16361
- return this._onError(new Error("Connection closed unexpectedly"), "ECONNECTION", serverResponse, "CONN");
16362
- } else if (/^[45]\d{2}\b/.test(serverResponse)) {
16363
- return this._onError(new Error("Connection closed unexpectedly"), "ECONNECTION", serverResponse, "CONN");
16470
+ return this._onError(new Error("Connection closed unexpectedly"), "ETLS", failureResponse, "CONN");
16471
+ }
16472
+ if (!failureResponse && this._responseActions[0] === this._actionGreeting && this._connectCallback && !this._destroyed) {
16473
+ const connectCallback = this._connectCallback;
16474
+ this._connectCallback = false;
16475
+ const err = this._formatError(new Error("Connection closed unexpectedly"), "ECONNECTION", false, "CONN");
16476
+ this.logger.warn({ tnx: "network" }, err.message);
16477
+ connectCallback(err);
16478
+ this.close();
16479
+ return;
16480
+ }
16481
+ if (failureResponse || this._responseActions[0] !== this.close && !this._destroyed) {
16482
+ return this._onError(new Error("Connection closed unexpectedly"), "ECONNECTION", failureResponse, "CONN");
16364
16483
  }
16365
16484
  this._destroy();
16366
16485
  }
@@ -16768,17 +16887,19 @@ var init_smtp_connection = __esm({
16768
16887
  if (/[ -]AUTH\b/i.test(str2)) {
16769
16888
  this.allowsAuth = true;
16770
16889
  }
16771
- if (/[ -]AUTH(?:(\s+|=)[^\n]*\s+|\s+|=)PLAIN/i.test(str2)) {
16772
- this._supportedAuth.push("PLAIN");
16773
- }
16774
- if (/[ -]AUTH(?:(\s+|=)[^\n]*\s+|\s+|=)LOGIN/i.test(str2)) {
16775
- this._supportedAuth.push("LOGIN");
16776
- }
16777
- if (/[ -]AUTH(?:(\s+|=)[^\n]*\s+|\s+|=)CRAM-MD5/i.test(str2)) {
16778
- this._supportedAuth.push("CRAM-MD5");
16890
+ const authMechanisms = /* @__PURE__ */ new Set();
16891
+ for (const line of this._ehloLines) {
16892
+ const authMatch = /^AUTH[\s=](.*)/i.exec(line);
16893
+ if (authMatch) {
16894
+ for (const mechanism of authMatch[1].split(/[\s=]+/)) {
16895
+ authMechanisms.add(mechanism.toUpperCase());
16896
+ }
16897
+ }
16779
16898
  }
16780
- if (/[ -]AUTH(?:(\s+|=)[^\n]*\s+|\s+|=)XOAUTH2/i.test(str2)) {
16781
- this._supportedAuth.push("XOAUTH2");
16899
+ for (const mechanism of ["PLAIN", "LOGIN", "CRAM-MD5", "XOAUTH2"]) {
16900
+ if (authMechanisms.has(mechanism)) {
16901
+ this._supportedAuth.push(mechanism);
16902
+ }
16782
16903
  }
16783
16904
  if (match = str2.match(/[ -]SIZE(?:[ \t]+(\d+))?/im)) {
16784
16905
  this._supportedExtensions.push("SIZE");
@@ -17024,7 +17145,9 @@ var init_smtp_connection = __esm({
17024
17145
  });
17025
17146
  this._sendCommand("DATA");
17026
17147
  } else {
17027
- err = this._formatError("Can't send mail - all recipients were rejected", "EENVELOPE", str2, "RCPT TO");
17148
+ const deferred = envelope.rejectedErrors.find((rejectedErr) => rejectedErr.responseCode && rejectedErr.responseCode < 500);
17149
+ const reply = deferred?.response ?? str2;
17150
+ err = this._formatError("Can't send mail - all recipients were rejected", "EENVELOPE", reply, "RCPT TO");
17028
17151
  err.rejected = envelope.rejected;
17029
17152
  err.rejectedErrors = envelope.rejectedErrors;
17030
17153
  return callback(err);
@@ -17163,12 +17286,12 @@ var init_smtp_connection = __esm({
17163
17286
  }
17164
17287
  });
17165
17288
 
17166
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/xoauth2/index.js
17289
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/xoauth2/index.js
17167
17290
  import { Stream } from "node:stream";
17168
17291
  import crypto7 from "node:crypto";
17169
17292
  var XOAuth2, xoauth2_default;
17170
17293
  var init_xoauth2 = __esm({
17171
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/xoauth2/index.js"() {
17294
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/xoauth2/index.js"() {
17172
17295
  init_fetch();
17173
17296
  init_shared();
17174
17297
  init_errors();
@@ -17176,12 +17299,12 @@ var init_xoauth2 = __esm({
17176
17299
  constructor(options, logger) {
17177
17300
  super();
17178
17301
  this.options = options || {};
17302
+ this.configError = false;
17179
17303
  if (options && options.serviceClient) {
17180
17304
  if (!options.privateKey || !options.user) {
17181
17305
  const err = new Error('Options "privateKey" and "user" are required for service account!');
17182
17306
  err.code = EOAUTH2;
17183
- setImmediate(() => this.emit("error", err));
17184
- return;
17307
+ this.configError = err;
17185
17308
  }
17186
17309
  const serviceRequestTimeout = Math.min(Math.max(Number(this.options.serviceRequestTimeout) || 0, 0), 3600);
17187
17310
  this.options.serviceRequestTimeout = serviceRequestTimeout || 5 * 60;
@@ -17212,6 +17335,10 @@ var init_xoauth2 = __esm({
17212
17335
  * @param callback Callback function with error object and token string
17213
17336
  */
17214
17337
  getToken(renew, callback) {
17338
+ const done = callback;
17339
+ if (this.configError) {
17340
+ return done(this.configError);
17341
+ }
17215
17342
  if (!renew && this.accessToken && (!this.expires || this.expires > Date.now())) {
17216
17343
  this.logger.debug({
17217
17344
  tnx: "OAUTH2",
@@ -17236,10 +17363,10 @@ var init_xoauth2 = __esm({
17236
17363
  }, "Cannot renew access token for %s: No refresh mechanism available", this.options.user);
17237
17364
  const err = new Error("Can't create new access token for user");
17238
17365
  err.code = EOAUTH2;
17239
- return callback(err);
17366
+ return done(err);
17240
17367
  }
17241
17368
  if (this.renewing) {
17242
- this.renewalQueue.push({ renew, callback });
17369
+ this.renewalQueue.push({ renew, callback: done });
17243
17370
  return;
17244
17371
  }
17245
17372
  this.renewing = true;
@@ -17261,7 +17388,7 @@ var init_xoauth2 = __esm({
17261
17388
  action: "renew"
17262
17389
  }, "Generated new Access Token for %s", this.options.user);
17263
17390
  }
17264
- callback(err, accessToken);
17391
+ done(err, accessToken);
17265
17392
  };
17266
17393
  if (this.provisionCallback) {
17267
17394
  this.provisionCallback(this.options.user, !!renew, (err, accessToken, expires) => {
@@ -17299,6 +17426,7 @@ var init_xoauth2 = __esm({
17299
17426
  * @param callback Callback function with error object and token string
17300
17427
  */
17301
17428
  generateToken(callback) {
17429
+ const done = callback;
17302
17430
  let urlOptions;
17303
17431
  let loggedUrlOptions;
17304
17432
  if (this.options.serviceClient) {
@@ -17317,7 +17445,7 @@ var init_xoauth2 = __esm({
17317
17445
  } catch (_err) {
17318
17446
  const err = new Error("Can't generate token. Check your auth options");
17319
17447
  err.code = EOAUTH2;
17320
- return callback(err);
17448
+ return done(err);
17321
17449
  }
17322
17450
  urlOptions = {
17323
17451
  grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer",
@@ -17331,7 +17459,7 @@ var init_xoauth2 = __esm({
17331
17459
  if (!this.options.refreshToken) {
17332
17460
  const err = new Error("Can't create new access token for user");
17333
17461
  err.code = EOAUTH2;
17334
- return callback(err);
17462
+ return done(err);
17335
17463
  }
17336
17464
  urlOptions = {
17337
17465
  client_id: this.options.clientId || "",
@@ -17356,12 +17484,12 @@ var init_xoauth2 = __esm({
17356
17484
  this.postRequest(this.options.accessUrl, urlOptions, this.options, (error3, body) => {
17357
17485
  let data;
17358
17486
  if (error3) {
17359
- return callback(error3);
17487
+ return done(error3);
17360
17488
  }
17361
17489
  try {
17362
17490
  data = JSON.parse(body.toString());
17363
17491
  } catch (E) {
17364
- return callback(E);
17492
+ return done(E);
17365
17493
  }
17366
17494
  if (!data || typeof data !== "object") {
17367
17495
  this.logger.debug({
@@ -17371,7 +17499,7 @@ var init_xoauth2 = __esm({
17371
17499
  }, "Response: %s", (body || "").toString());
17372
17500
  const err2 = new Error("Invalid authentication response");
17373
17501
  err2.code = EOAUTH2;
17374
- return callback(err2);
17502
+ return done(err2);
17375
17503
  }
17376
17504
  const logData = Object.assign({}, data);
17377
17505
  if (logData.access_token) {
@@ -17392,7 +17520,7 @@ var init_xoauth2 = __esm({
17392
17520
  }
17393
17521
  const err2 = new Error(errorMessage);
17394
17522
  err2.code = EOAUTH2;
17395
- return callback(err2);
17523
+ return done(err2);
17396
17524
  }
17397
17525
  if (data.access_token) {
17398
17526
  this.updateToken(data.access_token, data.expires_in);
@@ -17400,7 +17528,7 @@ var init_xoauth2 = __esm({
17400
17528
  }
17401
17529
  const err = new Error("No access token");
17402
17530
  err.code = EOAUTH2;
17403
- return callback(err);
17531
+ return done(err);
17404
17532
  });
17405
17533
  }
17406
17534
  /**
@@ -17434,7 +17562,10 @@ var init_xoauth2 = __esm({
17434
17562
  method: "post",
17435
17563
  headers: params.customHeaders,
17436
17564
  body: payload,
17437
- allowErrorResponse: true
17565
+ allowErrorResponse: true,
17566
+ // unset falls back to the fetch default, a stalled token endpoint would otherwise keep
17567
+ // `renewing` set and queue every later request
17568
+ timeout: params.requestTimeout
17438
17569
  };
17439
17570
  if (/^https:/i.test(url)) {
17440
17571
  fetchOptions.tls = Object.assign({ rejectUnauthorized: true }, params.tls || {});
@@ -17490,11 +17621,11 @@ var init_xoauth2 = __esm({
17490
17621
  }
17491
17622
  });
17492
17623
 
17493
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/smtp-pool/pool-resource.js
17624
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/smtp-pool/pool-resource.js
17494
17625
  import { EventEmitter as EventEmitter3 } from "node:events";
17495
17626
  var PoolResource;
17496
17627
  var init_pool_resource = __esm({
17497
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/smtp-pool/pool-resource.js"() {
17628
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/smtp-pool/pool-resource.js"() {
17498
17629
  init_smtp_connection();
17499
17630
  init_shared();
17500
17631
  init_xoauth2();
@@ -17517,7 +17648,7 @@ var init_pool_resource = __esm({
17517
17648
  method: "XOAUTH2"
17518
17649
  };
17519
17650
  oauth2.on("token", (token) => this.pool.mailer.emit("token", token));
17520
- oauth2.on("error", (err) => this.emit("error", err));
17651
+ oauth2.on("error", (err) => this._fail(err));
17521
17652
  break;
17522
17653
  }
17523
17654
  default:
@@ -17540,6 +17671,19 @@ var init_pool_resource = __esm({
17540
17671
  this._connected = false;
17541
17672
  this.messages = 0;
17542
17673
  this.available = true;
17674
+ this._failed = false;
17675
+ }
17676
+ /**
17677
+ * Emits 'error' for the first failure only. A dead resource can report the same failure more
17678
+ * than once (the connection error, then the send callback), the pool handles it once
17679
+ * @internal
17680
+ */
17681
+ _fail(err) {
17682
+ if (this._failed) {
17683
+ return;
17684
+ }
17685
+ this._failed = true;
17686
+ this.emit("error", err);
17543
17687
  }
17544
17688
  /**
17545
17689
  * Initiates a connection to the SMTP server
@@ -17549,7 +17693,7 @@ var init_pool_resource = __esm({
17549
17693
  connect(callback) {
17550
17694
  this.pool.getSocket(this.options, (err, socketOptions) => {
17551
17695
  if (err) {
17552
- this.emit("error", err);
17696
+ this._fail(err);
17553
17697
  return callback(err);
17554
17698
  }
17555
17699
  let returned = false;
@@ -17566,8 +17710,8 @@ var init_pool_resource = __esm({
17566
17710
  options = Object.assign(assign(false, options), socketOptions);
17567
17711
  }
17568
17712
  this.connection = new smtp_connection_default(options);
17569
- this.connection.once("error", (err2) => {
17570
- this.emit("error", err2);
17713
+ this.connection.on("error", (err2) => {
17714
+ this._fail(err2);
17571
17715
  if (returned) {
17572
17716
  return;
17573
17717
  }
@@ -17576,39 +17720,26 @@ var init_pool_resource = __esm({
17576
17720
  });
17577
17721
  this.connection.once("end", () => {
17578
17722
  this.close();
17579
- if (returned) {
17580
- return;
17581
- }
17582
17723
  returned = true;
17583
- const timer = setTimeout(() => {
17584
- if (returned) {
17585
- return;
17586
- }
17587
- const err2 = new Error("Unexpected socket close");
17588
- if (this.connection && this.connection._socket && this.connection._socket.upgrading) {
17589
- err2.code = ETLS;
17590
- }
17591
- callback(err2);
17592
- }, 1e3);
17593
- try {
17594
- timer.unref();
17595
- } catch (_E) {
17596
- }
17597
17724
  });
17598
- this.connection.connect(() => {
17725
+ this.connection.connect((err2) => {
17599
17726
  if (returned) {
17600
17727
  return;
17601
17728
  }
17729
+ if (err2) {
17730
+ returned = true;
17731
+ return;
17732
+ }
17602
17733
  if (this.auth && (this.connection.allowsAuth || options.forceAuth)) {
17603
- this.connection.login(this.auth, (err2) => {
17734
+ this.connection.login(this.auth, (err3) => {
17604
17735
  if (returned) {
17605
17736
  return;
17606
17737
  }
17607
17738
  returned = true;
17608
- if (err2) {
17739
+ if (err3) {
17609
17740
  this.connection.close();
17610
- this.emit("error", err2);
17611
- return callback(err2);
17741
+ this._fail(err3);
17742
+ return callback(err3);
17612
17743
  }
17613
17744
  this._connected = true;
17614
17745
  callback(null, true);
@@ -17657,7 +17788,7 @@ var init_pool_resource = __esm({
17657
17788
  this.messages++;
17658
17789
  if (err) {
17659
17790
  this.connection.close();
17660
- this.emit("error", err);
17791
+ this._fail(err);
17661
17792
  return callback(err);
17662
17793
  }
17663
17794
  info.envelope = {
@@ -17670,7 +17801,7 @@ var init_pool_resource = __esm({
17670
17801
  const err2 = new Error("Resource exhausted");
17671
17802
  err2.code = EMAXLIMIT;
17672
17803
  this.connection.close();
17673
- this.emit("error", err2);
17804
+ this._fail(err2);
17674
17805
  } else {
17675
17806
  this.pool._checkRateLimit(() => {
17676
17807
  this.available = true;
@@ -17698,10 +17829,10 @@ var init_pool_resource = __esm({
17698
17829
  }
17699
17830
  });
17700
17831
 
17701
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/well-known/services.js
17832
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/well-known/services.js
17702
17833
  var services;
17703
17834
  var init_services = __esm({
17704
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/well-known/services.js"() {
17835
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/well-known/services.js"() {
17705
17836
  services = {
17706
17837
  "126": {
17707
17838
  "description": "126 Mail (NetEase)",
@@ -18369,7 +18500,7 @@ var init_services = __esm({
18369
18500
  }
18370
18501
  });
18371
18502
 
18372
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/well-known/index.js
18503
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/well-known/index.js
18373
18504
  function normalizeKey(key) {
18374
18505
  return key.replace(/[^a-zA-Z0-9.-]/g, "").toLowerCase();
18375
18506
  }
@@ -18388,7 +18519,7 @@ function wellKnown(key) {
18388
18519
  }
18389
18520
  var normalized;
18390
18521
  var init_well_known = __esm({
18391
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/well-known/index.js"() {
18522
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/well-known/index.js"() {
18392
18523
  init_services();
18393
18524
  normalized = {};
18394
18525
  Object.keys(services).forEach((key) => {
@@ -18405,17 +18536,19 @@ var init_well_known = __esm({
18405
18536
  }
18406
18537
  });
18407
18538
 
18408
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/smtp-pool/index.js
18539
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/smtp-pool/index.js
18409
18540
  import { EventEmitter as EventEmitter4 } from "node:events";
18410
- var SMTPPool, smtp_pool_default;
18541
+ var REQUEUE_BASE_DELAY, REQUEUE_MAX_DELAY, SMTPPool, smtp_pool_default;
18411
18542
  var init_smtp_pool = __esm({
18412
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/smtp-pool/index.js"() {
18543
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/smtp-pool/index.js"() {
18413
18544
  init_pool_resource();
18414
18545
  init_smtp_connection();
18415
18546
  init_well_known();
18416
18547
  init_shared();
18417
18548
  init_errors();
18418
18549
  init_package_info();
18550
+ REQUEUE_BASE_DELAY = 50;
18551
+ REQUEUE_MAX_DELAY = 2e3;
18419
18552
  SMTPPool = class extends EventEmitter4 {
18420
18553
  constructor(options) {
18421
18554
  super();
@@ -18446,6 +18579,7 @@ var init_smtp_pool = __esm({
18446
18579
  );
18447
18580
  this.options.maxConnections = this.options.maxConnections || 5;
18448
18581
  this.options.maxMessages = this.options.maxMessages || 100;
18582
+ this.options.maxRequeues = typeof this.options.maxRequeues === "number" ? this.options.maxRequeues : 5;
18449
18583
  this.logger = getLogger(this.options, {
18450
18584
  component: this.options.component || "smtp-pool"
18451
18585
  });
@@ -18488,6 +18622,9 @@ var init_smtp_pool = __esm({
18488
18622
  */
18489
18623
  send(mail, callback) {
18490
18624
  if (this._closed) {
18625
+ const err = new Error("Connection pool was closed");
18626
+ err.code = ECONNECTION;
18627
+ setImmediate(() => callback(err));
18491
18628
  return false;
18492
18629
  }
18493
18630
  this._queue.push({
@@ -18674,14 +18811,19 @@ var init_smtp_pool = __esm({
18674
18811
  this._removeConnection(connection);
18675
18812
  if (connection.queueEntry) {
18676
18813
  setTimeout(() => {
18814
+ let delay = 0;
18677
18815
  if (connection.queueEntry) {
18678
18816
  if (this._shouldRequeuOnConnectionClose(connection.queueEntry)) {
18679
- this._requeueEntryOnConnectionClose(connection);
18817
+ delay = this._requeueEntryOnConnectionClose(connection);
18680
18818
  } else {
18681
18819
  this._failDeliveryOnConnectionClose(connection);
18682
18820
  }
18683
18821
  }
18684
- this._continueProcessing();
18822
+ if (delay) {
18823
+ setTimeout(() => this._continueProcessing(), delay);
18824
+ } else {
18825
+ this._continueProcessing();
18826
+ }
18685
18827
  }, 50);
18686
18828
  } else {
18687
18829
  if (!this._closed && this.idling && !this._connections.length) {
@@ -18695,7 +18837,7 @@ var init_smtp_pool = __esm({
18695
18837
  }
18696
18838
  /** @internal */
18697
18839
  _shouldRequeuOnConnectionClose(queueEntry) {
18698
- if (this.options.maxRequeues === void 0 || this.options.maxRequeues < 0) {
18840
+ if (this.options.maxRequeues < 0) {
18699
18841
  return true;
18700
18842
  }
18701
18843
  return queueEntry.requeueAttempts < this.options.maxRequeues;
@@ -18704,7 +18846,9 @@ var init_smtp_pool = __esm({
18704
18846
  _failDeliveryOnConnectionClose(connection) {
18705
18847
  if (connection.queueEntry && connection.queueEntry.callback) {
18706
18848
  try {
18707
- connection.queueEntry.callback(new Error("Reached maximum number of retries after connection was closed"));
18849
+ const err = new Error("Reached maximum number of retries after connection was closed");
18850
+ err.code = ECONNECTION;
18851
+ connection.queueEntry.callback(err);
18708
18852
  } catch (E) {
18709
18853
  this.logger.error({
18710
18854
  err: E,
@@ -18718,6 +18862,7 @@ var init_smtp_pool = __esm({
18718
18862
  }
18719
18863
  /** @internal */
18720
18864
  _requeueEntryOnConnectionClose(connection) {
18865
+ const delay = Math.min(REQUEUE_BASE_DELAY * 2 ** connection.queueEntry.requeueAttempts, REQUEUE_MAX_DELAY);
18721
18866
  connection.queueEntry.requeueAttempts += 1;
18722
18867
  this.logger.debug({
18723
18868
  tnx: "pool",
@@ -18727,6 +18872,7 @@ var init_smtp_pool = __esm({
18727
18872
  }, "Re-queued message <%s> for #%s. Attempt: #%s", connection.queueEntry.messageId, connection.id, connection.queueEntry.requeueAttempts);
18728
18873
  this._queue.unshift(connection.queueEntry);
18729
18874
  connection.queueEntry = false;
18875
+ return delay;
18730
18876
  }
18731
18877
  /**
18732
18878
  * Continue to process message if the pool hasn't closed
@@ -18801,10 +18947,11 @@ var init_smtp_pool = __esm({
18801
18947
  callback = callbackPromise(resolve5, reject);
18802
18948
  });
18803
18949
  }
18950
+ const done = callback;
18804
18951
  const auth = new PoolResource(this).auth;
18805
18952
  this.getSocket(this.options, (err, socketOptions) => {
18806
18953
  if (err) {
18807
- return callback(err);
18954
+ return done(err);
18808
18955
  }
18809
18956
  let options = this.options;
18810
18957
  if (socketOptions && socketOptions.connection) {
@@ -18826,14 +18973,14 @@ var init_smtp_pool = __esm({
18826
18973
  }
18827
18974
  returned = true;
18828
18975
  connection.close();
18829
- return callback(err2);
18976
+ return done(err2);
18830
18977
  });
18831
18978
  connection.once("end", () => {
18832
18979
  if (returned) {
18833
18980
  return;
18834
18981
  }
18835
18982
  returned = true;
18836
- return callback(new Error("Connection closed"));
18983
+ return done(new Error("Connection closed"));
18837
18984
  });
18838
18985
  const finalize = () => {
18839
18986
  if (returned) {
@@ -18841,30 +18988,35 @@ var init_smtp_pool = __esm({
18841
18988
  }
18842
18989
  returned = true;
18843
18990
  connection.quit();
18844
- return callback(null, true);
18991
+ return done(null, true);
18845
18992
  };
18846
- connection.connect(() => {
18993
+ connection.connect((err2) => {
18847
18994
  if (returned) {
18848
18995
  return;
18849
18996
  }
18997
+ if (err2) {
18998
+ returned = true;
18999
+ connection.close();
19000
+ return done(err2);
19001
+ }
18850
19002
  if (auth && (connection.allowsAuth || options.forceAuth)) {
18851
- connection.login(auth, (err2) => {
19003
+ connection.login(auth, (err3) => {
18852
19004
  if (returned) {
18853
19005
  return;
18854
19006
  }
18855
- if (err2) {
19007
+ if (err3) {
18856
19008
  returned = true;
18857
19009
  connection.close();
18858
- return callback(err2);
19010
+ return done(err3);
18859
19011
  }
18860
19012
  finalize();
18861
19013
  });
18862
19014
  } else if (!auth && connection.allowsAuth && options.forceAuth) {
18863
- const err2 = new Error("Authentication info was not provided");
18864
- err2.code = ENOAUTH;
19015
+ const err3 = new Error("Authentication info was not provided");
19016
+ err3.code = ENOAUTH;
18865
19017
  returned = true;
18866
19018
  connection.close();
18867
- return callback(err2);
19019
+ return done(err3);
18868
19020
  } else {
18869
19021
  finalize();
18870
19022
  }
@@ -18877,11 +19029,11 @@ var init_smtp_pool = __esm({
18877
19029
  }
18878
19030
  });
18879
19031
 
18880
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/smtp-transport/index.js
19032
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/smtp-transport/index.js
18881
19033
  import { EventEmitter as EventEmitter5 } from "node:events";
18882
19034
  var SMTPTransport, smtp_transport_default;
18883
19035
  var init_smtp_transport = __esm({
18884
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/smtp-transport/index.js"() {
19036
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/smtp-transport/index.js"() {
18885
19037
  init_smtp_connection();
18886
19038
  init_well_known();
18887
19039
  init_shared();
@@ -19016,27 +19168,6 @@ var init_smtp_transport = __esm({
19016
19168
  connection.close();
19017
19169
  return callback(err2);
19018
19170
  });
19019
- connection.once("end", () => {
19020
- if (returned) {
19021
- return;
19022
- }
19023
- const timer = setTimeout(() => {
19024
- if (returned) {
19025
- return;
19026
- }
19027
- returned = true;
19028
- cleanupPerCallAuth();
19029
- const err2 = new Error("Unexpected socket close");
19030
- if (connection && connection._socket && connection._socket.upgrading) {
19031
- err2.code = ETLS;
19032
- }
19033
- callback(err2);
19034
- }, 1e3);
19035
- try {
19036
- timer.unref();
19037
- } catch (_E) {
19038
- }
19039
- });
19040
19171
  const sendMessage = () => {
19041
19172
  const envelope = mail.message.getEnvelope();
19042
19173
  const messageId = mail.message.messageId();
@@ -19055,6 +19186,9 @@ var init_smtp_transport = __esm({
19055
19186
  messageId
19056
19187
  }, "Sending message %s to <%s>", messageId, recipients.join(", "));
19057
19188
  connection.send(envelope, mail.message.createReadStream(), (err2, info) => {
19189
+ if (returned) {
19190
+ return;
19191
+ }
19058
19192
  returned = true;
19059
19193
  cleanupPerCallAuth();
19060
19194
  connection.close();
@@ -19080,21 +19214,26 @@ var init_smtp_transport = __esm({
19080
19214
  }
19081
19215
  });
19082
19216
  };
19083
- connection.connect(() => {
19217
+ connection.connect((err2) => {
19084
19218
  if (returned) {
19085
19219
  return;
19086
19220
  }
19221
+ if (err2) {
19222
+ returned = true;
19223
+ connection.close();
19224
+ return callback(err2);
19225
+ }
19087
19226
  perCallAuth = this.getAuth(mail.data.auth);
19088
19227
  if (perCallAuth && (connection.allowsAuth || options.forceAuth)) {
19089
- connection.login(perCallAuth, (err2) => {
19228
+ connection.login(perCallAuth, (err3) => {
19090
19229
  cleanupPerCallAuth();
19091
19230
  if (returned) {
19092
19231
  return;
19093
19232
  }
19094
- if (err2) {
19233
+ if (err3) {
19095
19234
  returned = true;
19096
19235
  connection.close();
19097
- return callback(err2);
19236
+ return callback(err3);
19098
19237
  }
19099
19238
  sendMessage();
19100
19239
  });
@@ -19111,9 +19250,10 @@ var init_smtp_transport = __esm({
19111
19250
  callback = callbackPromise(resolve5, reject);
19112
19251
  });
19113
19252
  }
19253
+ const done = callback;
19114
19254
  this.getSocket(this.options, (err, socketOptions) => {
19115
19255
  if (err) {
19116
- return callback(err);
19256
+ return done(err);
19117
19257
  }
19118
19258
  let options = this.options;
19119
19259
  if (socketOptions && socketOptions.connection) {
@@ -19143,7 +19283,7 @@ var init_smtp_transport = __esm({
19143
19283
  returned = true;
19144
19284
  cleanupPerCallAuth();
19145
19285
  connection.close();
19146
- return callback(err2);
19286
+ return done(err2);
19147
19287
  });
19148
19288
  connection.once("end", () => {
19149
19289
  if (returned) {
@@ -19151,7 +19291,7 @@ var init_smtp_transport = __esm({
19151
19291
  }
19152
19292
  returned = true;
19153
19293
  cleanupPerCallAuth();
19154
- return callback(new Error("Connection closed"));
19294
+ return done(new Error("Connection closed"));
19155
19295
  });
19156
19296
  const finalize = () => {
19157
19297
  if (returned) {
@@ -19160,33 +19300,38 @@ var init_smtp_transport = __esm({
19160
19300
  returned = true;
19161
19301
  cleanupPerCallAuth();
19162
19302
  connection.quit();
19163
- return callback(null, true);
19303
+ return done(null, true);
19164
19304
  };
19165
- connection.connect(() => {
19305
+ connection.connect((err2) => {
19166
19306
  if (returned) {
19167
19307
  return;
19168
19308
  }
19309
+ if (err2) {
19310
+ returned = true;
19311
+ connection.close();
19312
+ return done(err2);
19313
+ }
19169
19314
  perCallAuth = this.getAuth({});
19170
19315
  if (perCallAuth && (connection.allowsAuth || options.forceAuth)) {
19171
- connection.login(perCallAuth, (err2) => {
19316
+ connection.login(perCallAuth, (err3) => {
19172
19317
  cleanupPerCallAuth();
19173
19318
  if (returned) {
19174
19319
  return;
19175
19320
  }
19176
- if (err2) {
19321
+ if (err3) {
19177
19322
  returned = true;
19178
19323
  connection.close();
19179
- return callback(err2);
19324
+ return done(err3);
19180
19325
  }
19181
19326
  finalize();
19182
19327
  });
19183
19328
  } else if (!perCallAuth && connection.allowsAuth && options.forceAuth) {
19184
- const err2 = new Error("Authentication info was not provided");
19185
- err2.code = ENOAUTH;
19329
+ const err3 = new Error("Authentication info was not provided");
19330
+ err3.code = ENOAUTH;
19186
19331
  returned = true;
19187
19332
  cleanupPerCallAuth();
19188
19333
  connection.close();
19189
- return callback(err2);
19334
+ return done(err3);
19190
19335
  } else {
19191
19336
  finalize();
19192
19337
  }
@@ -19208,11 +19353,11 @@ var init_smtp_transport = __esm({
19208
19353
  }
19209
19354
  });
19210
19355
 
19211
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/sendmail-transport/index.js
19356
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/sendmail-transport/index.js
19212
19357
  import { spawn } from "node:child_process";
19213
19358
  var SendmailTransport, sendmail_transport_default;
19214
19359
  var init_sendmail_transport = __esm({
19215
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/sendmail-transport/index.js"() {
19360
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/sendmail-transport/index.js"() {
19216
19361
  init_package_info();
19217
19362
  init_shared();
19218
19363
  init_errors();
@@ -19353,10 +19498,10 @@ var init_sendmail_transport = __esm({
19353
19498
  }
19354
19499
  });
19355
19500
 
19356
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/stream-transport/index.js
19501
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/stream-transport/index.js
19357
19502
  var StreamTransport, stream_transport_default;
19358
19503
  var init_stream_transport = __esm({
19359
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/stream-transport/index.js"() {
19504
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/stream-transport/index.js"() {
19360
19505
  init_package_info();
19361
19506
  init_shared();
19362
19507
  init_le_windows();
@@ -19450,10 +19595,10 @@ var init_stream_transport = __esm({
19450
19595
  }
19451
19596
  });
19452
19597
 
19453
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/json-transport/index.js
19598
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/json-transport/index.js
19454
19599
  var JSONTransport, json_transport_default;
19455
19600
  var init_json_transport = __esm({
19456
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/json-transport/index.js"() {
19601
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/json-transport/index.js"() {
19457
19602
  init_package_info();
19458
19603
  init_shared();
19459
19604
  JSONTransport = class {
@@ -19509,7 +19654,7 @@ var init_json_transport = __esm({
19509
19654
  }
19510
19655
  });
19511
19656
 
19512
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/ses-transport/index.js
19657
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/ses-transport/index.js
19513
19658
  import EventEmitter6 from "node:events";
19514
19659
  function tagSesError(err) {
19515
19660
  if (err && typeof err === "object" && !err.code) {
@@ -19519,7 +19664,7 @@ function tagSesError(err) {
19519
19664
  }
19520
19665
  var SESTransport, ses_transport_default;
19521
19666
  var init_ses_transport = __esm({
19522
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/ses-transport/index.js"() {
19667
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/ses-transport/index.js"() {
19523
19668
  init_package_info();
19524
19669
  init_shared();
19525
19670
  init_errors();
@@ -19701,7 +19846,7 @@ var init_ses_transport = __esm({
19701
19846
  }
19702
19847
  });
19703
19848
 
19704
- // node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/nodemailer.js
19849
+ // node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/nodemailer.js
19705
19850
  function createTransport(transporter, defaults) {
19706
19851
  let options;
19707
19852
  if (
@@ -19823,7 +19968,7 @@ function getTestMessageUrl(info) {
19823
19968
  }
19824
19969
  var ETHEREAL_API, ETHEREAL_WEB, ETHEREAL_API_KEY, ETHEREAL_CACHE, testAccount, nodemailer, nodemailer_default;
19825
19970
  var init_nodemailer = __esm({
19826
- "node_modules/.pnpm/nodemailer@10.0.10/node_modules/nodemailer/dist/esm/nodemailer.js"() {
19971
+ "node_modules/.pnpm/nodemailer@10.0.13/node_modules/nodemailer/dist/esm/nodemailer.js"() {
19827
19972
  init_mailer();
19828
19973
  init_shared();
19829
19974
  init_smtp_pool();
@@ -52749,8 +52894,8 @@ var require_constants2 = __commonJS({
52749
52894
  "use strict";
52750
52895
  Object.defineProperty(exports, "__esModule", { value: true });
52751
52896
  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;
52752
- var DEFAULT_TIMEOUT = 3e4;
52753
- exports.DEFAULT_TIMEOUT = DEFAULT_TIMEOUT;
52897
+ var DEFAULT_TIMEOUT2 = 3e4;
52898
+ exports.DEFAULT_TIMEOUT = DEFAULT_TIMEOUT2;
52754
52899
  var ERRORS = {
52755
52900
  InvalidSocksCommand: "An invalid SOCKS command was provided. Valid options are connect, bind, and associate.",
52756
52901
  InvalidSocksCommandForOperation: "An invalid SOCKS command was provided. Only a subset of commands are supported for this operation.",
@@ -65182,9 +65327,12 @@ __export(imapClient_exports, {
65182
65327
  MAX_UNSCOPED_SEARCH_DEPTH: () => MAX_UNSCOPED_SEARCH_DEPTH,
65183
65328
  __resetPool: () => __resetPool,
65184
65329
  __setPoolConnect: () => __setPoolConnect,
65330
+ base64DecodedLength: () => base64DecodedLength,
65331
+ base64DecodedSizeFromTail: () => base64DecodedSizeFromTail,
65185
65332
  bodyStructureHasAttachments: () => bodyStructureHasAttachments,
65186
65333
  buildImapConnectionOptions: () => buildImapConnectionOptions,
65187
65334
  decodeImapId: () => decodeImapId,
65335
+ decodedSizeWithoutBody: () => decodedSizeWithoutBody,
65188
65336
  dropAllPools: () => dropAllPools,
65189
65337
  encodeImapId: () => encodeImapId,
65190
65338
  imapAppendDraft: () => imapAppendDraft,
@@ -65225,6 +65373,7 @@ __export(imapClient_exports, {
65225
65373
  matchMailbox: () => matchMailbox,
65226
65374
  normalizeMessageId: () => normalizeMessageId,
65227
65375
  omittedNote: () => omittedNote,
65376
+ quotedPrintableDecodedLength: () => quotedPrintableDecodedLength,
65228
65377
  resolveDraftImapAccount: () => resolveDraftImapAccount,
65229
65378
  resolveImapConfig: () => resolveImapConfig,
65230
65379
  resolveImapConfigs: () => resolveImapConfigs,
@@ -66685,6 +66834,56 @@ async function imapDeleteMessageById(id, deps = {}) {
66685
66834
  }
66686
66835
  });
66687
66836
  }
66837
+ function dispositionSize(params) {
66838
+ const raw = params?.size?.trim();
66839
+ return raw && /^\d+$/.test(raw) ? Number(raw) : void 0;
66840
+ }
66841
+ function base64DecodedLength(body) {
66842
+ const s = typeof body === "string" ? body : body.toString("latin1");
66843
+ const n = s.replace(/[^A-Za-z0-9+/]/g, "").length;
66844
+ return Math.floor(n * 3 / 4);
66845
+ }
66846
+ function base64DecodedSizeFromTail(total, tail) {
66847
+ if (tail.length >= total) return base64DecodedLength(tail);
66848
+ const s = tail.toString("latin1");
66849
+ const term = s.includes("\r\n") ? "\r\n" : "\n";
66850
+ const segs = s.split(term);
66851
+ if (segs.length < 3) return void 0;
66852
+ let trailing = 0;
66853
+ while (segs.length > 1 && segs[segs.length - 1] === "") {
66854
+ segs.pop();
66855
+ trailing++;
66856
+ }
66857
+ const last = segs[segs.length - 1];
66858
+ const full = segs.slice(1, -1);
66859
+ if (full.length === 0 || !last) return void 0;
66860
+ const L = full[0].length;
66861
+ const alphabet = /^[A-Za-z0-9+/]+$/;
66862
+ if (L === 0 || L % 4 !== 0 || !full.every((l) => l.length === L && alphabet.test(l))) {
66863
+ return void 0;
66864
+ }
66865
+ const m = /^([A-Za-z0-9+/]*)(=*)$/.exec(last);
66866
+ if (!m || m[2].length > 2 || last.length > L) return void 0;
66867
+ const before = total - trailing * term.length - last.length;
66868
+ if (before < 0 || before % (L + term.length) !== 0) return void 0;
66869
+ const chars = before / (L + term.length) * L + last.length;
66870
+ if (chars % 4 !== 0) return void 0;
66871
+ return chars / 4 * 3 - m[2].length;
66872
+ }
66873
+ function quotedPrintableDecodedLength(body) {
66874
+ const s = (typeof body === "string" ? body : body.toString("latin1")).replace(/=\r?\n/g, "");
66875
+ const escapes = s.match(/=[0-9A-Fa-f]{2}/g)?.length ?? 0;
66876
+ return s.length - escapes * 2;
66877
+ }
66878
+ function decodedSizeWithoutBody(a) {
66879
+ if (a.declaredSize !== void 0) return { size: a.declaredSize, exact: true };
66880
+ if (a.encoding === "base64") {
66881
+ const chars = a.encodedSize - 2 * Math.floor(a.encodedSize / 78);
66882
+ return { size: Math.floor(chars * 3 / 4), exact: false };
66883
+ }
66884
+ if (a.encoding === "quoted-printable") return { size: a.encodedSize, exact: false };
66885
+ return { size: a.encodedSize, exact: true };
66886
+ }
66688
66887
  function collectAttachments(node, out = []) {
66689
66888
  if (!node) return out;
66690
66889
  const filename = node.dispositionParameters?.filename || node.parameters?.name;
@@ -66696,7 +66895,9 @@ function collectAttachments(node, out = []) {
66696
66895
  part: node.part,
66697
66896
  filename: filename || `part-${node.part}`,
66698
66897
  mimeType: node.type || "application/octet-stream",
66699
- size: node.size ?? 0
66898
+ encodedSize: node.size ?? 0,
66899
+ encoding: (node.encoding || "").toLowerCase().trim(),
66900
+ declaredSize: dispositionSize(node.dispositionParameters)
66700
66901
  });
66701
66902
  }
66702
66903
  for (const child of node.childNodes ?? []) collectAttachments(child, out);
@@ -66717,6 +66918,52 @@ async function streamToBuffer(content, maxBytes) {
66717
66918
  }
66718
66919
  return Buffer.concat(chunks);
66719
66920
  }
66921
+ async function resolveDecodedSizes(client, uid, atts) {
66922
+ const out = atts.map(decodedSizeWithoutBody);
66923
+ const probes = [];
66924
+ atts.forEach((a, i) => {
66925
+ if (a.declaredSize !== void 0 || a.encodedSize <= 0) return;
66926
+ if (a.encoding === "base64") {
66927
+ probes.push({ i, start: Math.max(0, a.encodedSize - BASE64_TAIL_WINDOW), kind: "b64" });
66928
+ } else if (a.encoding === "quoted-printable" && a.encodedSize <= QP_EXACT_MAX_BYTES) {
66929
+ probes.push({ i, start: 0, kind: "qp" });
66930
+ }
66931
+ });
66932
+ if (probes.length === 0) return out;
66933
+ let parts;
66934
+ try {
66935
+ const msg = await client.fetchOne(
66936
+ String(uid),
66937
+ {
66938
+ uid: true,
66939
+ bodyParts: probes.map((p) => ({
66940
+ key: atts[p.i].part,
66941
+ start: p.start,
66942
+ maxLength: atts[p.i].encodedSize - p.start
66943
+ }))
66944
+ },
66945
+ { uid: true }
66946
+ );
66947
+ parts = msg ? msg.bodyParts : void 0;
66948
+ } catch {
66949
+ return out;
66950
+ }
66951
+ for (const p of probes) {
66952
+ const a = atts[p.i];
66953
+ const buf = parts?.get(a.part.toLowerCase());
66954
+ if (!buf) continue;
66955
+ let exact;
66956
+ if (p.kind === "qp") {
66957
+ exact = quotedPrintableDecodedLength(buf);
66958
+ } else {
66959
+ const requested = a.encodedSize - p.start;
66960
+ const total = buf.length < requested ? p.start + buf.length : a.encodedSize;
66961
+ exact = base64DecodedSizeFromTail(total, buf);
66962
+ }
66963
+ if (exact !== void 0) out[p.i] = { size: exact, exact: true };
66964
+ }
66965
+ return out;
66966
+ }
66720
66967
  async function imapListAttachments(id, deps = {}) {
66721
66968
  const ref = decodeImapId(id);
66722
66969
  if (!ref) return { success: false, error: `Not an IMAP message id: "${id}".` };
@@ -66725,12 +66972,18 @@ async function imapListAttachments(id, deps = {}) {
66725
66972
  if (!msg || !msg.bodyStructure) {
66726
66973
  return { success: false, error: `IMAP message UID ${ref.uid} not found in "${ref.path}".` };
66727
66974
  }
66728
- const attachments = collectAttachments(msg.bodyStructure).map((a) => ({
66729
- id: `${id}#${a.part}`,
66730
- name: a.filename,
66731
- mimeType: a.mimeType,
66732
- size: a.size
66733
- }));
66975
+ const atts = collectAttachments(msg.bodyStructure);
66976
+ const sizes = await resolveDecodedSizes(client, ref.uid, atts);
66977
+ const attachments = atts.map((a, i) => {
66978
+ const info = {
66979
+ id: `${id}#${a.part}`,
66980
+ name: a.filename,
66981
+ mimeType: a.mimeType,
66982
+ size: sizes[i].size
66983
+ };
66984
+ if (!sizes[i].exact) info.sizeApproximate = true;
66985
+ return info;
66986
+ });
66734
66987
  return { success: true, attachments };
66735
66988
  });
66736
66989
  }
@@ -66751,10 +67004,11 @@ async function imapFetchAttachment(id, attachmentName, deps = {}) {
66751
67004
  error: `Attachment "${attachmentName}" not found on UID ${ref.uid}. Available: ${names}.`
66752
67005
  };
66753
67006
  }
66754
- if (match.size > MAX_IMAP_ATTACHMENT_BYTES) {
67007
+ const expected = decodedSizeWithoutBody(match).size;
67008
+ if (expected > MAX_IMAP_ATTACHMENT_BYTES) {
66755
67009
  return {
66756
67010
  success: false,
66757
- error: `IMAP attachment "${attachmentName}" is ${match.size} bytes; the maximum is ${MAX_IMAP_ATTACHMENT_BYTES} bytes (25 MiB).`
67011
+ error: `IMAP attachment "${attachmentName}" is ${expected} bytes; the maximum is ${MAX_IMAP_ATTACHMENT_BYTES} bytes (25 MiB).`
66758
67012
  };
66759
67013
  }
66760
67014
  try {
@@ -66942,7 +67196,7 @@ async function imapThread(id, deps = {}, limit = 50) {
66942
67196
  true
66943
67197
  );
66944
67198
  }
66945
- 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;
67199
+ 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;
66946
67200
  var init_imapClient = __esm({
66947
67201
  "src/services/imapClient.ts"() {
66948
67202
  "use strict";
@@ -67047,6 +67301,8 @@ var init_imapClient = __esm({
67047
67301
  imapMarkRead = (id, deps = {}) => flagOp(id, "\\Seen", true, deps);
67048
67302
  imapMarkUnread = (id, deps = {}) => flagOp(id, "\\Seen", false, deps);
67049
67303
  FALLBACK_TRASH_PATH = "Trash";
67304
+ BASE64_TAIL_WINDOW = 1024;
67305
+ QP_EXACT_MAX_BYTES = 64 * 1024;
67050
67306
  imapBatchMarkRead = (ids, deps = {}) => imapBatch(ids, deps, async (c, uids) => {
67051
67307
  assertMutated(
67052
67308
  await c.messageFlagsAdd(uids, ["\\Seen"], { uid: true }),
@@ -75230,7 +75486,7 @@ function object(shape, params) {
75230
75486
  return new ZodMiniObject(def);
75231
75487
  }
75232
75488
 
75233
- // node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
75489
+ // node_modules/.pnpm/@modelcontextprotocol+sdk@1.31.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
75234
75490
  function isZ4Schema(s) {
75235
75491
  const schema = s;
75236
75492
  return !!schema._zod;
@@ -76085,7 +76341,7 @@ function preprocess(fn, schema) {
76085
76341
  // node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/classic/external.js
76086
76342
  config(en_default2());
76087
76343
 
76088
- // node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
76344
+ // node_modules/.pnpm/@modelcontextprotocol+sdk@1.31.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
76089
76345
  var LATEST_PROTOCOL_VERSION = "2025-11-25";
76090
76346
  var SUPPORTED_PROTOCOL_VERSIONS = [LATEST_PROTOCOL_VERSION, "2025-06-18", "2025-03-26", "2024-11-05", "2024-10-07"];
76091
76347
  var RELATED_TASK_META_KEY = "io.modelcontextprotocol/related-task";
@@ -77616,7 +77872,7 @@ var UrlElicitationRequiredError = class extends McpError {
77616
77872
  }
77617
77873
  };
77618
77874
 
77619
- // node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/interfaces.js
77875
+ // node_modules/.pnpm/@modelcontextprotocol+sdk@1.31.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/interfaces.js
77620
77876
  function isTerminal(status) {
77621
77877
  return status === "completed" || status === "failed" || status === "cancelled";
77622
77878
  }
@@ -78905,7 +79161,7 @@ var zodToJsonSchema = (schema, options) => {
78905
79161
  return combined;
78906
79162
  };
78907
79163
 
78908
- // node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js
79164
+ // node_modules/.pnpm/@modelcontextprotocol+sdk@1.31.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js
78909
79165
  function mapMiniTarget(t) {
78910
79166
  if (!t)
78911
79167
  return "draft-7";
@@ -78947,7 +79203,7 @@ function parseWithCompat(schema, data) {
78947
79203
  return result.data;
78948
79204
  }
78949
79205
 
78950
- // node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js
79206
+ // node_modules/.pnpm/@modelcontextprotocol+sdk@1.31.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js
78951
79207
  var DEFAULT_REQUEST_TIMEOUT_MSEC = 6e4;
78952
79208
  var Protocol = class {
78953
79209
  constructor(_options) {
@@ -79901,7 +80157,7 @@ function mergeCapabilities(base2, additional) {
79901
80157
  return result;
79902
80158
  }
79903
80159
 
79904
- // node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js
80160
+ // node_modules/.pnpm/@modelcontextprotocol+sdk@1.31.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js
79905
80161
  var import_ajv = __toESM(require_ajv(), 1);
79906
80162
  var import_ajv_formats = __toESM(require_dist(), 1);
79907
80163
  function createDefaultAjvInstance() {
@@ -79969,7 +80225,7 @@ var AjvJsonSchemaValidator = class {
79969
80225
  }
79970
80226
  };
79971
80227
 
79972
- // node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/server.js
80228
+ // node_modules/.pnpm/@modelcontextprotocol+sdk@1.31.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/server.js
79973
80229
  var ExperimentalServerTasks = class {
79974
80230
  constructor(_server) {
79975
80231
  this._server = _server;
@@ -80182,7 +80438,7 @@ var ExperimentalServerTasks = class {
80182
80438
  }
80183
80439
  };
80184
80440
 
80185
- // node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js
80441
+ // node_modules/.pnpm/@modelcontextprotocol+sdk@1.31.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js
80186
80442
  function assertToolsCallTaskCapability(requests, method, entityName) {
80187
80443
  if (!requests) {
80188
80444
  throw new Error(`${entityName} does not support task creation (required for ${method})`);
@@ -80217,7 +80473,7 @@ function assertClientRequestTaskCapability(requests, method, entityName) {
80217
80473
  }
80218
80474
  }
80219
80475
 
80220
- // node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js
80476
+ // node_modules/.pnpm/@modelcontextprotocol+sdk@1.31.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js
80221
80477
  var Server = class extends Protocol {
80222
80478
  /**
80223
80479
  * Initializes this server with the given name and version information.
@@ -80588,7 +80844,7 @@ var Server = class extends Protocol {
80588
80844
  }
80589
80845
  };
80590
80846
 
80591
- // node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js
80847
+ // node_modules/.pnpm/@modelcontextprotocol+sdk@1.31.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js
80592
80848
  var COMPLETABLE_SYMBOL = /* @__PURE__ */ Symbol.for("mcp.completable");
80593
80849
  function isCompletable(schema) {
80594
80850
  return !!schema && typeof schema === "object" && COMPLETABLE_SYMBOL in schema;
@@ -80602,7 +80858,7 @@ var McpZodTypeKind;
80602
80858
  McpZodTypeKind2["Completable"] = "McpCompletable";
80603
80859
  })(McpZodTypeKind || (McpZodTypeKind = {}));
80604
80860
 
80605
- // node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/uriTemplate.js
80861
+ // node_modules/.pnpm/@modelcontextprotocol+sdk@1.31.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/uriTemplate.js
80606
80862
  var MAX_TEMPLATE_LENGTH = 1e6;
80607
80863
  var MAX_VARIABLE_LENGTH = 1e6;
80608
80864
  var MAX_TEMPLATE_EXPRESSIONS = 1e4;
@@ -80824,7 +81080,7 @@ var UriTemplate = class _UriTemplate {
80824
81080
  }
80825
81081
  };
80826
81082
 
80827
- // node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/toolNameValidation.js
81083
+ // node_modules/.pnpm/@modelcontextprotocol+sdk@1.31.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/toolNameValidation.js
80828
81084
  var TOOL_NAME_REGEX = /^[A-Za-z0-9._-]{1,128}$/;
80829
81085
  function validateToolName(name2) {
80830
81086
  const warnings = [];
@@ -80882,7 +81138,7 @@ function validateAndWarnToolName(name2) {
80882
81138
  return result.isValid;
80883
81139
  }
80884
81140
 
80885
- // node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/mcp-server.js
81141
+ // node_modules/.pnpm/@modelcontextprotocol+sdk@1.31.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/mcp-server.js
80886
81142
  var ExperimentalMcpServerTasks = class {
80887
81143
  constructor(_mcpServer) {
80888
81144
  this._mcpServer = _mcpServer;
@@ -80897,7 +81153,7 @@ var ExperimentalMcpServerTasks = class {
80897
81153
  }
80898
81154
  };
80899
81155
 
80900
- // node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js
81156
+ // node_modules/.pnpm/@modelcontextprotocol+sdk@1.31.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js
80901
81157
  var McpServer = class {
80902
81158
  constructor(serverInfo, options) {
80903
81159
  this._registeredResources = {};
@@ -81713,10 +81969,10 @@ var EMPTY_COMPLETION_RESULT = {
81713
81969
  }
81714
81970
  };
81715
81971
 
81716
- // node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
81972
+ // node_modules/.pnpm/@modelcontextprotocol+sdk@1.31.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
81717
81973
  import process2 from "node:process";
81718
81974
 
81719
- // node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js
81975
+ // node_modules/.pnpm/@modelcontextprotocol+sdk@1.31.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js
81720
81976
  var STDIO_DEFAULT_MAX_BUFFER_SIZE = 10 * 1024 * 1024;
81721
81977
  var ReadBuffer = class {
81722
81978
  constructor(options) {
@@ -81753,7 +82009,7 @@ function serializeMessage(message) {
81753
82009
  return JSON.stringify(message) + "\n";
81754
82010
  }
81755
82011
 
81756
- // node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
82012
+ // node_modules/.pnpm/@modelcontextprotocol+sdk@1.31.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
81757
82013
  var StdioServerTransport = class {
81758
82014
  constructor(_stdin = process2.stdin, _stdout = process2.stdout, options) {
81759
82015
  this._stdin = _stdin;
@@ -89721,7 +89977,7 @@ registerTool(
89721
89977
  registerTool(
89722
89978
  "list-attachments",
89723
89979
  {
89724
- description: "Use when: enumerating a message's attachments (by id) to discover their names, MIME types, and sizes \u2014 typically before saving or fetching one.\nReturns: each attachment's name, MIME type, and size, plus a count.\nDo not use when: you want the bytes (use fetch-attachment for inline base64, or save-attachment to write to disk). Get the message id from search-messages or list-messages first.",
89980
+ description: "Use when: enumerating a message's attachments (by id) to discover their names, MIME types, and sizes \u2014 typically before saving or fetching one.\nReturns: each attachment's name, MIME type, and decoded size in bytes (what fetch-attachment returns), plus a count; sizeApproximate: true marks the rare IMAP size that is an estimate.\nDo not use when: you want the bytes (use fetch-attachment for inline base64, or save-attachment to write to disk). Get the message id from search-messages or list-messages first.",
89725
89981
  inputSchema: {
89726
89982
  id: MESSAGE_ID_SCHEMA
89727
89983
  },
@@ -89741,8 +89997,9 @@ registerTool(
89741
89997
  return successResponse("No attachments found", structured);
89742
89998
  }
89743
89999
  const attachmentList = attachments.map((a) => {
89744
- const sizeKb = Math.round(a.size / 1024);
89745
- return ` - ${a.name} (${a.mimeType}, ${sizeKb} KB)`;
90000
+ const approx = "sizeApproximate" in a && a.sizeApproximate ? "~" : "";
90001
+ const size = a.size < 1024 ? `${a.size} bytes` : `${Math.round(a.size / 1024)} KB`;
90002
+ return ` - ${a.name} (${a.mimeType}, ${approx}${size})`;
89746
90003
  }).join("\n");
89747
90004
  return successResponse(
89748
90005
  `Found ${attachments.length} attachment(s):