@nocobase/plugin-workflow-mailer 2.3.0-beta.13 → 2.3.0-beta.15

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 (173) hide show
  1. package/dist/externalVersion.js +6 -6
  2. package/dist/node_modules/joi/package.json +1 -1
  3. package/dist/node_modules/nodemailer/dist/cjs/addressparser/index.d.ts +59 -0
  4. package/dist/node_modules/nodemailer/dist/cjs/addressparser/index.js +790 -0
  5. package/dist/node_modules/nodemailer/dist/cjs/base64/index.d.ts +36 -0
  6. package/dist/node_modules/nodemailer/dist/cjs/base64/index.js +119 -0
  7. package/dist/node_modules/nodemailer/dist/cjs/dkim/index.d.ts +52 -0
  8. package/dist/node_modules/nodemailer/dist/cjs/dkim/index.js +228 -0
  9. package/dist/node_modules/nodemailer/dist/cjs/dkim/message-parser.d.ts +48 -0
  10. package/dist/node_modules/nodemailer/dist/cjs/dkim/message-parser.js +180 -0
  11. package/dist/node_modules/nodemailer/dist/cjs/dkim/relaxed-body.d.ts +36 -0
  12. package/dist/node_modules/nodemailer/dist/cjs/dkim/relaxed-body.js +148 -0
  13. package/dist/node_modules/nodemailer/dist/cjs/dkim/sign.d.ts +52 -0
  14. package/dist/node_modules/nodemailer/dist/cjs/dkim/sign.js +165 -0
  15. package/dist/node_modules/nodemailer/dist/cjs/errors.d.ts +96 -0
  16. package/dist/node_modules/nodemailer/dist/cjs/errors.js +70 -0
  17. package/dist/node_modules/nodemailer/dist/cjs/fetch/cookies.d.ts +107 -0
  18. package/dist/node_modules/nodemailer/dist/cjs/fetch/cookies.js +282 -0
  19. package/dist/node_modules/nodemailer/dist/cjs/fetch/index.d.ts +65 -0
  20. package/dist/node_modules/nodemailer/dist/cjs/fetch/index.js +384 -0
  21. package/dist/node_modules/nodemailer/dist/cjs/json-transport/index.d.ts +64 -0
  22. package/dist/node_modules/nodemailer/dist/cjs/json-transport/index.js +99 -0
  23. package/dist/node_modules/nodemailer/dist/cjs/mail-composer/index.d.ts +174 -0
  24. package/dist/node_modules/nodemailer/dist/cjs/mail-composer/index.js +613 -0
  25. package/dist/node_modules/nodemailer/dist/cjs/mailer/index.d.ts +237 -0
  26. package/dist/node_modules/nodemailer/dist/cjs/mailer/index.js +415 -0
  27. package/dist/node_modules/nodemailer/dist/cjs/mailer/mail-message.d.ts +97 -0
  28. package/dist/node_modules/nodemailer/dist/cjs/mailer/mail-message.js +342 -0
  29. package/dist/node_modules/nodemailer/dist/cjs/mime-funcs/index.d.ts +161 -0
  30. package/dist/node_modules/nodemailer/dist/cjs/mime-funcs/index.js +787 -0
  31. package/dist/node_modules/nodemailer/dist/cjs/mime-funcs/mime-types.d.ts +2 -0
  32. package/dist/node_modules/nodemailer/dist/cjs/mime-funcs/mime-types.js +2103 -0
  33. package/dist/node_modules/nodemailer/dist/cjs/mime-node/index.d.ts +333 -0
  34. package/dist/node_modules/nodemailer/dist/cjs/mime-node/index.js +1493 -0
  35. package/dist/node_modules/nodemailer/dist/cjs/mime-node/last-newline.d.ts +5 -0
  36. package/dist/node_modules/nodemailer/dist/cjs/mime-node/last-newline.js +32 -0
  37. package/dist/node_modules/nodemailer/dist/cjs/mime-node/le-unix.d.ts +9 -0
  38. package/dist/node_modules/nodemailer/dist/cjs/mime-node/le-unix.js +40 -0
  39. package/dist/node_modules/nodemailer/dist/cjs/mime-node/le-windows.d.ts +10 -0
  40. package/dist/node_modules/nodemailer/dist/cjs/mime-node/le-windows.js +47 -0
  41. package/dist/node_modules/nodemailer/dist/cjs/nodemailer.d.ts +124 -0
  42. package/dist/node_modules/nodemailer/dist/cjs/nodemailer.js +1 -0
  43. package/dist/node_modules/nodemailer/dist/cjs/package-info.d.ts +3 -0
  44. package/dist/node_modules/nodemailer/dist/cjs/package-info.js +7 -0
  45. package/dist/node_modules/nodemailer/dist/cjs/package.json +3 -0
  46. package/dist/node_modules/nodemailer/dist/cjs/punycode/index.d.ts +73 -0
  47. package/dist/node_modules/nodemailer/{lib → dist/cjs}/punycode/index.js +62 -111
  48. package/dist/node_modules/nodemailer/dist/cjs/qp/index.d.ts +32 -0
  49. package/dist/node_modules/nodemailer/dist/cjs/qp/index.js +207 -0
  50. package/dist/node_modules/nodemailer/dist/cjs/sendmail-transport/index.d.ts +69 -0
  51. package/dist/node_modules/nodemailer/dist/cjs/sendmail-transport/index.js +210 -0
  52. package/dist/node_modules/nodemailer/dist/cjs/ses-transport/index.d.ts +112 -0
  53. package/dist/node_modules/nodemailer/dist/cjs/ses-transport/index.js +252 -0
  54. package/dist/node_modules/nodemailer/dist/cjs/shared/index.d.ts +260 -0
  55. package/dist/node_modules/nodemailer/dist/cjs/shared/index.js +680 -0
  56. package/dist/node_modules/nodemailer/dist/cjs/shared/objects.d.ts +23 -0
  57. package/dist/node_modules/nodemailer/dist/cjs/shared/objects.js +43 -0
  58. package/dist/node_modules/nodemailer/dist/cjs/shared/url.d.ts +21 -0
  59. package/dist/node_modules/nodemailer/dist/cjs/shared/url.js +255 -0
  60. package/dist/node_modules/nodemailer/dist/cjs/smtp-connection/data-stream.d.ts +15 -0
  61. package/dist/node_modules/nodemailer/dist/cjs/smtp-connection/data-stream.js +108 -0
  62. package/dist/node_modules/nodemailer/dist/cjs/smtp-connection/http-proxy-client.d.ts +47 -0
  63. package/dist/node_modules/nodemailer/dist/cjs/smtp-connection/http-proxy-client.js +189 -0
  64. package/dist/node_modules/nodemailer/dist/cjs/smtp-connection/index.d.ts +416 -0
  65. package/dist/node_modules/nodemailer/dist/cjs/smtp-connection/index.js +1837 -0
  66. package/dist/node_modules/nodemailer/dist/cjs/smtp-pool/index.d.ts +133 -0
  67. package/dist/node_modules/nodemailer/dist/cjs/smtp-pool/index.js +569 -0
  68. package/dist/node_modules/nodemailer/dist/cjs/smtp-pool/pool-resource.d.ts +62 -0
  69. package/dist/node_modules/nodemailer/dist/cjs/smtp-pool/pool-resource.js +257 -0
  70. package/dist/node_modules/nodemailer/dist/cjs/smtp-transport/index.d.ts +156 -0
  71. package/dist/node_modules/nodemailer/dist/cjs/smtp-transport/index.js +371 -0
  72. package/dist/node_modules/nodemailer/dist/cjs/stream-transport/index.d.ts +65 -0
  73. package/dist/node_modules/nodemailer/dist/cjs/stream-transport/index.js +146 -0
  74. package/dist/node_modules/nodemailer/dist/cjs/well-known/index.d.ts +35 -0
  75. package/dist/node_modules/nodemailer/dist/cjs/well-known/index.js +41 -0
  76. package/dist/node_modules/nodemailer/dist/cjs/well-known/services.d.ts +2 -0
  77. package/dist/node_modules/nodemailer/dist/cjs/well-known/services.js +674 -0
  78. package/dist/node_modules/nodemailer/dist/cjs/xoauth2/index.d.ts +201 -0
  79. package/dist/node_modules/nodemailer/dist/cjs/xoauth2/index.js +426 -0
  80. package/dist/node_modules/nodemailer/dist/esm/addressparser/index.d.ts +59 -0
  81. package/dist/node_modules/nodemailer/{lib → dist/esm}/addressparser/index.js +361 -131
  82. package/dist/node_modules/nodemailer/dist/esm/base64/index.d.ts +36 -0
  83. package/dist/node_modules/nodemailer/{lib → dist/esm}/base64/index.js +31 -56
  84. package/dist/node_modules/nodemailer/dist/esm/dkim/index.d.ts +52 -0
  85. package/dist/node_modules/nodemailer/{lib → dist/esm}/dkim/index.js +49 -78
  86. package/dist/node_modules/nodemailer/dist/esm/dkim/message-parser.d.ts +48 -0
  87. package/dist/node_modules/nodemailer/{lib → dist/esm}/dkim/message-parser.js +64 -42
  88. package/dist/node_modules/nodemailer/dist/esm/dkim/relaxed-body.d.ts +36 -0
  89. package/dist/node_modules/nodemailer/dist/esm/dkim/relaxed-body.js +141 -0
  90. package/dist/node_modules/nodemailer/dist/esm/dkim/sign.d.ts +52 -0
  91. package/dist/node_modules/nodemailer/{lib → dist/esm}/dkim/sign.js +50 -46
  92. package/dist/node_modules/nodemailer/dist/esm/errors.d.ts +96 -0
  93. package/dist/node_modules/nodemailer/{lib → dist/esm}/errors.js +26 -18
  94. package/dist/node_modules/nodemailer/dist/esm/fetch/cookies.d.ts +107 -0
  95. package/dist/node_modules/nodemailer/dist/esm/fetch/cookies.js +242 -0
  96. package/dist/node_modules/nodemailer/dist/esm/fetch/index.d.ts +65 -0
  97. package/dist/node_modules/nodemailer/{lib → dist/esm}/fetch/index.js +80 -147
  98. package/dist/node_modules/nodemailer/dist/esm/json-transport/index.d.ts +64 -0
  99. package/dist/node_modules/nodemailer/{lib → dist/esm}/json-transport/index.js +19 -39
  100. package/dist/node_modules/nodemailer/dist/esm/mail-composer/index.d.ts +174 -0
  101. package/dist/node_modules/nodemailer/{lib → dist/esm}/mail-composer/index.js +199 -265
  102. package/dist/node_modules/nodemailer/dist/esm/mailer/index.d.ts +237 -0
  103. package/dist/node_modules/nodemailer/{lib → dist/esm}/mailer/index.js +128 -234
  104. package/dist/node_modules/nodemailer/dist/esm/mailer/mail-message.d.ts +97 -0
  105. package/dist/node_modules/nodemailer/{lib → dist/esm}/mailer/mail-message.js +62 -114
  106. package/dist/node_modules/nodemailer/dist/esm/mime-funcs/index.d.ts +161 -0
  107. package/dist/node_modules/nodemailer/dist/esm/mime-funcs/index.js +738 -0
  108. package/dist/node_modules/nodemailer/dist/esm/mime-funcs/mime-types.d.ts +2 -0
  109. package/dist/node_modules/nodemailer/{lib → dist/esm}/mime-funcs/mime-types.js +29 -42
  110. package/dist/node_modules/nodemailer/dist/esm/mime-node/index.d.ts +333 -0
  111. package/dist/node_modules/nodemailer/{lib → dist/esm}/mime-node/index.js +259 -372
  112. package/dist/node_modules/nodemailer/dist/esm/mime-node/last-newline.d.ts +5 -0
  113. package/dist/node_modules/nodemailer/{lib → dist/esm}/mime-node/last-newline.js +4 -10
  114. package/dist/node_modules/nodemailer/dist/esm/mime-node/le-unix.d.ts +9 -0
  115. package/dist/node_modules/nodemailer/{lib → dist/esm}/mime-node/le-unix.js +6 -11
  116. package/dist/node_modules/nodemailer/dist/esm/mime-node/le-windows.d.ts +10 -0
  117. package/dist/node_modules/nodemailer/{lib → dist/esm}/mime-node/le-windows.js +6 -13
  118. package/dist/node_modules/nodemailer/dist/esm/nodemailer.d.ts +124 -0
  119. package/dist/node_modules/nodemailer/dist/esm/nodemailer.js +166 -0
  120. package/dist/node_modules/nodemailer/dist/esm/package-info.d.ts +3 -0
  121. package/dist/node_modules/nodemailer/dist/esm/package-info.js +4 -0
  122. package/dist/node_modules/nodemailer/dist/esm/package.json +3 -0
  123. package/dist/node_modules/nodemailer/dist/esm/punycode/index.d.ts +73 -0
  124. package/dist/node_modules/nodemailer/dist/esm/punycode/index.js +405 -0
  125. package/dist/node_modules/nodemailer/dist/esm/qp/index.d.ts +32 -0
  126. package/dist/node_modules/nodemailer/{lib → dist/esm}/qp/index.js +38 -67
  127. package/dist/node_modules/nodemailer/dist/esm/sendmail-transport/index.d.ts +69 -0
  128. package/dist/node_modules/nodemailer/{lib → dist/esm}/sendmail-transport/index.js +51 -101
  129. package/dist/node_modules/nodemailer/dist/esm/ses-transport/index.d.ts +112 -0
  130. package/dist/node_modules/nodemailer/dist/esm/ses-transport/index.js +212 -0
  131. package/dist/node_modules/nodemailer/dist/esm/shared/index.d.ts +260 -0
  132. package/dist/node_modules/nodemailer/{lib → dist/esm}/shared/index.js +156 -272
  133. package/dist/node_modules/nodemailer/dist/esm/shared/objects.d.ts +23 -0
  134. package/dist/node_modules/nodemailer/{lib → dist/esm}/shared/objects.js +13 -17
  135. package/dist/node_modules/nodemailer/dist/esm/shared/url.d.ts +21 -0
  136. package/dist/node_modules/nodemailer/dist/esm/shared/url.js +214 -0
  137. package/dist/node_modules/nodemailer/dist/esm/smtp-connection/data-stream.d.ts +15 -0
  138. package/dist/node_modules/nodemailer/dist/esm/smtp-connection/data-stream.js +103 -0
  139. package/dist/node_modules/nodemailer/dist/esm/smtp-connection/http-proxy-client.d.ts +47 -0
  140. package/dist/node_modules/nodemailer/{lib → dist/esm}/smtp-connection/http-proxy-client.js +49 -74
  141. package/dist/node_modules/nodemailer/dist/esm/smtp-connection/index.d.ts +416 -0
  142. package/dist/node_modules/nodemailer/{lib → dist/esm}/smtp-connection/index.js +574 -794
  143. package/dist/node_modules/nodemailer/dist/esm/smtp-pool/index.d.ts +133 -0
  144. package/dist/node_modules/nodemailer/{lib → dist/esm}/smtp-pool/index.js +172 -284
  145. package/dist/node_modules/nodemailer/dist/esm/smtp-pool/pool-resource.d.ts +62 -0
  146. package/dist/node_modules/nodemailer/{lib → dist/esm}/smtp-pool/pool-resource.js +57 -97
  147. package/dist/node_modules/nodemailer/dist/esm/smtp-transport/index.d.ts +156 -0
  148. package/dist/node_modules/nodemailer/{lib → dist/esm}/smtp-transport/index.js +81 -179
  149. package/dist/node_modules/nodemailer/dist/esm/stream-transport/index.d.ts +65 -0
  150. package/dist/node_modules/nodemailer/{lib → dist/esm}/stream-transport/index.js +36 -74
  151. package/dist/node_modules/nodemailer/dist/esm/well-known/index.d.ts +35 -0
  152. package/dist/node_modules/nodemailer/{lib → dist/esm}/well-known/index.js +5 -16
  153. package/dist/node_modules/nodemailer/dist/esm/well-known/services.d.ts +2 -0
  154. package/dist/node_modules/nodemailer/dist/esm/well-known/services.js +671 -0
  155. package/dist/node_modules/nodemailer/dist/esm/xoauth2/index.d.ts +201 -0
  156. package/dist/node_modules/nodemailer/{lib → dist/esm}/xoauth2/index.js +125 -187
  157. package/dist/node_modules/nodemailer/{lib → dist}/well-known/services.json +9 -2
  158. package/dist/node_modules/nodemailer/package.json +1 -1
  159. package/package.json +3 -3
  160. package/dist/node_modules/nodemailer/.gitattributes +0 -6
  161. package/dist/node_modules/nodemailer/.ncurc.js +0 -9
  162. package/dist/node_modules/nodemailer/.prettierignore +0 -8
  163. package/dist/node_modules/nodemailer/.prettierrc +0 -12
  164. package/dist/node_modules/nodemailer/.prettierrc.js +0 -10
  165. package/dist/node_modules/nodemailer/.release-please-config.json +0 -9
  166. package/dist/node_modules/nodemailer/eslint.config.js +0 -88
  167. package/dist/node_modules/nodemailer/lib/dkim/relaxed-body.js +0 -154
  168. package/dist/node_modules/nodemailer/lib/fetch/cookies.js +0 -276
  169. package/dist/node_modules/nodemailer/lib/mime-funcs/index.js +0 -671
  170. package/dist/node_modules/nodemailer/lib/nodemailer.js +0 -1
  171. package/dist/node_modules/nodemailer/lib/ses-transport/index.js +0 -266
  172. package/dist/node_modules/nodemailer/lib/shared/url.js +0 -151
  173. package/dist/node_modules/nodemailer/lib/smtp-connection/data-stream.js +0 -105
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ // Safe copying of objects whose keys come from the caller.
3
+ //
4
+ // This lives in its own leaf module, like ./url.ts, so that every layer can reach it.
5
+ // src/shared/index.ts imports src/fetch, so src/fetch can not import src/shared back,
6
+ // and src/mime-funcs is a leaf that would otherwise pull in dns/net/os/fs for a string
7
+ // comparison. src/shared/index.ts re-exports both functions for the callers that already
8
+ // depend on it.
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.copyOwnKeys = exports.isProtoKey = void 0;
11
+ /**
12
+ * Detects a key that can not be copied onto a plain object with `target[key] = value`.
13
+ *
14
+ * "__proto__" is the only one: assigning it runs the inherited setter and replaces the
15
+ * prototype of the target instead of adding a property to it, so a caller can smuggle
16
+ * values past validation that only inspects own keys. JSON.parse produces such a key
17
+ * where an object literal can not. "constructor" and "prototype" have no such setter and
18
+ * become ordinary own properties, so dropping them would only discard legitimate values.
19
+ *
20
+ * @param key Key to check
21
+ * @returns true if the key must not be copied
22
+ */
23
+ const isProtoKey = (key) => key === '__proto__';
24
+ exports.isProtoKey = isProtoKey;
25
+ /**
26
+ * Copies own enumerable keys from a source object to a target object. Every copy that
27
+ * walks the keys of user supplied data goes through here, see isProtoKey.
28
+ *
29
+ * @param target Object to copy the keys to
30
+ * @param source Object to copy the keys from
31
+ * @param [skip] Optional predicate, return true to leave a key out
32
+ * @returns The target object
33
+ */
34
+ const copyOwnKeys = (target, source, skip) => {
35
+ Object.keys(source || {}).forEach(key => {
36
+ if ((0, exports.isProtoKey)(key) || (skip && skip(key))) {
37
+ return;
38
+ }
39
+ target[key] = source[key];
40
+ });
41
+ return target;
42
+ };
43
+ exports.copyOwnKeys = copyOwnKeys;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Parsed URL in the shape of the legacy `url.parse()` result
3
+ */
4
+ export interface ParsedUrl {
5
+ protocol: string | null;
6
+ host: string | null;
7
+ hostname: string | null;
8
+ port: string | null;
9
+ pathname: string | null;
10
+ search: string | null;
11
+ path: string | null;
12
+ href: string;
13
+ auth: string | null;
14
+ /** Decoded user name, null when the URL carries no credentials */
15
+ username: string | null;
16
+ /** Decoded password, null when the URL carries none */
17
+ password: string | null;
18
+ query: string | null | Record<string, string | string[]>;
19
+ }
20
+ export declare const parse: (input?: string | null, parseQueryString?: boolean) => ParsedUrl;
21
+ export declare const resolve: (from: string, to: string) => string;
@@ -0,0 +1,255 @@
1
+ "use strict";
2
+ // URL parsing wrapper around the WHATWG `URL` class. It only falls back to the
3
+ // legacy, deprecation-warning-emitting `url.parse()` / `url.resolve()` for input
4
+ // the WHATWG parser rejects.
5
+ //
6
+ // The WHATWG `URL` exposes a different shape than the legacy parser, so results
7
+ // are normalized back into the legacy field names the rest of the codebase reads
8
+ // (`protocol`, `hostname`, `port`, `pathname`, `path`, `search`, `auth`, `query`,
9
+ // `href`). This keeps every existing call site unchanged.
10
+ //
11
+ // Known, accepted divergences from the legacy parser:
12
+ // - non-special schemes (smtp:/smtps:/direct:) are not host-lowercased by
13
+ // WHATWG; cosmetic only, SMTP/DNS hosts are case-insensitive. (IDNA mapping
14
+ // and IPv6 brackets are normalized back by normalizeHostname below.)
15
+ // - a literal unescaped ':' inside a password is percent-encoded by WHATWG;
16
+ // such passwords should be percent-encoded by the caller anyway.
17
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
+ if (k2 === undefined) k2 = k;
19
+ var desc = Object.getOwnPropertyDescriptor(m, k);
20
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
+ desc = { enumerable: true, get: function() { return m[k]; } };
22
+ }
23
+ Object.defineProperty(o, k2, desc);
24
+ }) : (function(o, m, k, k2) {
25
+ if (k2 === undefined) k2 = k;
26
+ o[k2] = m[k];
27
+ }));
28
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
29
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
30
+ }) : function(o, v) {
31
+ o["default"] = v;
32
+ });
33
+ var __importStar = (this && this.__importStar) || (function () {
34
+ var ownKeys = function(o) {
35
+ ownKeys = Object.getOwnPropertyNames || function (o) {
36
+ var ar = [];
37
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
38
+ return ar;
39
+ };
40
+ return ownKeys(o);
41
+ };
42
+ return function (mod) {
43
+ if (mod && mod.__esModule) return mod;
44
+ var result = {};
45
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
46
+ __setModuleDefault(result, mod);
47
+ return result;
48
+ };
49
+ })();
50
+ var __importDefault = (this && this.__importDefault) || function (mod) {
51
+ return (mod && mod.__esModule) ? mod : { "default": mod };
52
+ };
53
+ Object.defineProperty(exports, "__esModule", { value: true });
54
+ exports.resolve = exports.parse = void 0;
55
+ const node_net_1 = __importDefault(require("node:net"));
56
+ const node_url_1 = __importDefault(require("node:url"));
57
+ const punycode = __importStar(require("../punycode/index.js"));
58
+ // Matches a "scheme:" not followed by "//" (and with something after it), used
59
+ // to re-insert the authority separator the legacy parser did not require.
60
+ const SLASHLESS_AUTHORITY = /^([a-zA-Z][a-zA-Z0-9+.-]*:)(?!\/\/)([\s\S]+)$/;
61
+ // Leading and trailing C0 controls and spaces, which the WHATWG parser strips before it
62
+ // looks at the input. Stripped up front so that the slash-less form is recognized in a
63
+ // value read from a file with a trailing newline as well.
64
+ const SURROUNDING_WHITESPACE = /^[\x00-\x20]+|[\x00-\x20]+$/g;
65
+ // Leading characters legacy url.parse() skips before it reads the scheme
66
+ const LEGACY_TRIM = /^[\x00-\x20\u00a0\ufeff]+/;
67
+ // The authority of a "scheme://authority/..." or a scheme-relative "//authority/..."
68
+ // string: the scheme, if any (anything the legacy parser takes for one, it is less strict
69
+ // than WHATWG about the first character), and what the legacy parser has to report as the
70
+ // host once the userinfo is removed, see legacyParse. The legacy parser treats a backslash
71
+ // as a slash.
72
+ const AUTHORITY = /^([a-zA-Z0-9+.-]+:)?[\\/]{2}([^\\/?#]*)/;
73
+ // The WHATWG forbidden domain code points, except '%' which an opaque host may carry: the
74
+ // C0 control characters, space, DEL and the URL delimiters. CONTROL_CHARS is the C0 and DEL
75
+ // subset, checked on its own in legacyParse where the host string still carries the port
76
+ // and IPv6 brackets.
77
+ const FORBIDDEN_HOST_CHARS = /[\x00-\x20#/:<>?@[\\\]^|\x7f]/;
78
+ const CONTROL_CHARS = /[\x00-\x1f\x7f]/;
79
+ // The error the WHATWG parser throws, for a host that only fails the checks in this module
80
+ function invalidUrl(input) {
81
+ const err = new TypeError('Invalid URL');
82
+ err.code = 'ERR_INVALID_URL';
83
+ err.input = input;
84
+ return err;
85
+ }
86
+ // Legacy url.parse() for input the WHATWG parser refused. The legacy parser does not
87
+ // reject a host it can not represent: a NUL byte, a percent-encoded byte, a space or a
88
+ // '<' inside the host ends the host early and the rest becomes the path, so
89
+ // 'localhost%00.example.com' silently turns into a request to 'localhost'. When the
90
+ // input has an authority that the legacy parser reads as the host (always for
91
+ // "scheme://", for "//host" only when slashesDenoteHost is set, as url.resolve() does
92
+ // for its target), the legacy result is accepted only if that host is the whole written
93
+ // authority, lowercased and IDNA mapped the way the legacy parser does it, and carries
94
+ // no control character. A legacy result with a host (an empty one included, 'http:///x'
95
+ // is a request to localhost) that no such authority accounts for is refused as well.
96
+ // Otherwise the WHATWG error is reported. Relative input has no authority to check and
97
+ // keeps the legacy behavior.
98
+ function legacyParse(input, parseQueryString, whatwgError, slashesDenoteHost) {
99
+ const parsed = node_url_1.default.parse(input, parseQueryString, slashesDenoteHost);
100
+ const authority = AUTHORITY.exec(input.replace(LEGACY_TRIM, ''));
101
+ if (authority && (authority[1] || parsed.hostname !== null)) {
102
+ const written = authority[2].slice(authority[2].lastIndexOf('@') + 1);
103
+ if (!written || CONTROL_CHARS.test(written) || (parsed.host || '').toLowerCase() !== punycode.toASCII(written.toLowerCase())) {
104
+ throw whatwgError;
105
+ }
106
+ // the legacy parser takes any bracketed value for an IPv6 literal
107
+ if (written.charAt(0) === '[' && !node_net_1.default.isIPv6(written.slice(1, written.indexOf(']')))) {
108
+ throw whatwgError;
109
+ }
110
+ }
111
+ else if (parsed.hostname !== null) {
112
+ throw whatwgError;
113
+ }
114
+ // the legacy parser only offers the joined form, split it on the first colon
115
+ const legacyAuth = parsed.auth === null || parsed.auth === undefined ? null : parsed.auth.split(':');
116
+ const result = parsed;
117
+ result.username = legacyAuth ? legacyAuth.shift() : null;
118
+ result.password = legacyAuth && legacyAuth.length ? legacyAuth.join(':') : null;
119
+ return result;
120
+ }
121
+ // decodeURIComponent that never throws. Legacy url.parse() decodes the auth
122
+ // component but tolerates malformed percent sequences, so mirror that.
123
+ function safeDecode(str) {
124
+ try {
125
+ return decodeURIComponent(str);
126
+ }
127
+ catch (_err) {
128
+ return str;
129
+ }
130
+ }
131
+ // Derives the legacy-shaped bare hostname from a WHATWG URL. WHATWG keeps IPv6
132
+ // literals bracketed ('[::1]') and, for non-special schemes (smtp:/smtps:/socks:),
133
+ // percent-encodes a non-ASCII host instead of IDNA-mapping it. Both forms are
134
+ // un-resolvable when handed to net/dns/http.request, which is what every call
135
+ // site does, so map them back to what legacy url.parse() returned: the bare
136
+ // address and the IDNA mapped (lowercased, punycode) form. Idempotent on plain
137
+ // ASCII and already-punycode hosts, so special-scheme hosts (already IDNA-mapped
138
+ // by WHATWG) pass through.
139
+ function normalizeHostname(raw, href) {
140
+ const hostname = raw || '';
141
+ if (!hostname) {
142
+ // Host-less URL (e.g. 'direct:'): legacy returned '' here, not null;
143
+ // consumers do `hostname.length` / `'.' + hostname`, so keep it a string.
144
+ return '';
145
+ }
146
+ if (hostname.charAt(0) === '[' && hostname.charAt(hostname.length - 1) === ']') {
147
+ return hostname.slice(1, -1);
148
+ }
149
+ const decoded = safeDecode(hostname);
150
+ // domainToASCII applies the WHATWG host rules (IDNA mapping included) and returns an
151
+ // empty string for a host it refuses, the forbidden characters among them
152
+ const mapped = FORBIDDEN_HOST_CHARS.test(decoded) ? '' : node_url_1.default.domainToASCII(decoded);
153
+ if (!mapped) {
154
+ throw invalidUrl(href);
155
+ }
156
+ return mapped;
157
+ }
158
+ const parse = (input, parseQueryString) => {
159
+ input = (input || '').replace(SURROUNDING_WHITESPACE, '');
160
+ // Legacy url.parse() parses a "user:pass@host:port" authority that follows
161
+ // the scheme even without the "//" separator, for schemes outside its
162
+ // built-in slashed-protocol list (smtp:/smtps:/socks:/...). The WHATWG
163
+ // parser instead treats a scheme not followed by "//" as an opaque path.
164
+ // Re-insert the "//" so slash-less connection/proxy URLs keep resolving to
165
+ // an authority, as they did before. This assumes a slash-authority scheme,
166
+ // which every consumer here uses (http/https/smtp/smtps/socks/direct); an
167
+ // opaque scheme like mailto:/data:/tel: would be mis-split, but none reach
168
+ // this module.
169
+ const slashless = SLASHLESS_AUTHORITY.exec(input);
170
+ const normalized = slashless ? slashless[1] + '//' + slashless[2] : input;
171
+ let u;
172
+ try {
173
+ u = new URL(normalized);
174
+ }
175
+ catch (err) {
176
+ // WHATWG rejects some input the legacy parser tolerated (empty/relative
177
+ // strings, scheme-relative '//host/path', out-of-range ports, ...). Fall
178
+ // back to the legacy parser so behavior, including the downstream errors
179
+ // callers rely on, is preserved. This is the only path that can still
180
+ // emit a deprecation warning; it fires for anything WHATWG cannot
181
+ // represent, including legitimate relative URLs, not just malformed input.
182
+ return legacyParse(normalized, parseQueryString, err);
183
+ }
184
+ const hostname = normalizeHostname(u.hostname, u.href);
185
+ const port = u.port || null;
186
+ const pathname = u.pathname || null;
187
+ const search = u.search || null;
188
+ // Legacy `.auth` is the decoded "user[:pass]" string; WHATWG keeps the
189
+ // username/password percent-encoded, so decode to stay byte-compatible with
190
+ // existing consumers (parseConnectionUrl, Basic/Proxy-Authorization headers).
191
+ let auth = null;
192
+ let username = null;
193
+ let password = null;
194
+ if (u.username || u.password) {
195
+ // Gate on password too: legacy url.parse('smtps://:pass@host').auth was
196
+ // ':pass'. Dropping it would silently connect unauthenticated.
197
+ username = safeDecode(u.username);
198
+ password = u.password ? safeDecode(u.password) : null;
199
+ // the joined form is ambiguous once the user name contains a colon, so
200
+ // consumers that need the parts read username and password instead
201
+ auth = username + (password !== null ? ':' + password : '');
202
+ }
203
+ let query;
204
+ if (parseQueryString) {
205
+ // Mirror querystring.parse(): null-prototype object, repeated keys become an array.
206
+ const parsed = Object.create(null);
207
+ u.searchParams.forEach((value, key) => {
208
+ if (Object.prototype.hasOwnProperty.call(parsed, key)) {
209
+ const existing = parsed[key];
210
+ if (Array.isArray(existing)) {
211
+ existing.push(value);
212
+ }
213
+ else {
214
+ parsed[key] = [existing, value];
215
+ }
216
+ }
217
+ else {
218
+ parsed[key] = value;
219
+ }
220
+ });
221
+ query = parsed;
222
+ }
223
+ else {
224
+ query = search ? search.slice(1) : null;
225
+ }
226
+ return {
227
+ protocol: u.protocol || null,
228
+ host: u.host || null,
229
+ hostname,
230
+ port,
231
+ pathname,
232
+ search,
233
+ path: (pathname || '') + (search || '') || null,
234
+ href: u.href,
235
+ auth,
236
+ username,
237
+ password,
238
+ query
239
+ };
240
+ };
241
+ exports.parse = parse;
242
+ const resolve = (from, to) => {
243
+ try {
244
+ return new URL(to, from).href;
245
+ }
246
+ catch (err) {
247
+ // Malformed target, fall back to the legacy resolver, but only when the legacy
248
+ // parser reads the same host out of both inputs that was written. The target
249
+ // decides the host when it is absolute or scheme-relative, the base otherwise
250
+ legacyParse(from, false, err, true);
251
+ legacyParse(to, false, err, true);
252
+ return node_url_1.default.resolve(from, to);
253
+ }
254
+ };
255
+ exports.resolve = resolve;
@@ -0,0 +1,15 @@
1
+ import { Transform, type TransformOptions } from 'node:stream';
2
+ /**
3
+ * Escapes dots in the beginning of lines. Ends the stream with <CR><LF>.<CR><LF>
4
+ * Also makes sure that only <CR><LF> sequences are used for linebreaks, bare CR and bare LF
5
+ * are both turned into <CR><LF>
6
+ *
7
+ * @param options Stream options
8
+ */
9
+ export default class DataStream extends Transform {
10
+ options: TransformOptions;
11
+ inByteCount: number;
12
+ outByteCount: number;
13
+ lastByte: number | false;
14
+ constructor(options?: TransformOptions);
15
+ }
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const node_stream_1 = require("node:stream");
4
+ // bytes inserted into the output, shared as they are only ever copied by Buffer.concat
5
+ const INSERT_LF = Buffer.from('\n');
6
+ const INSERT_LF_DOT = Buffer.from('\n.');
7
+ const INSERT_CR = Buffer.from('\r');
8
+ const INSERT_DOT = Buffer.from('.');
9
+ /**
10
+ * Escapes dots in the beginning of lines. Ends the stream with <CR><LF>.<CR><LF>
11
+ * Also makes sure that only <CR><LF> sequences are used for linebreaks, bare CR and bare LF
12
+ * are both turned into <CR><LF>
13
+ *
14
+ * @param options Stream options
15
+ */
16
+ class DataStream extends node_stream_1.Transform {
17
+ constructor(options) {
18
+ super(options);
19
+ this.options = options || {};
20
+ this.inByteCount = 0;
21
+ this.outByteCount = 0;
22
+ this.lastByte = false;
23
+ }
24
+ /**
25
+ * Escapes dots
26
+ * @internal
27
+ */
28
+ _transform(chunk, encoding, done) {
29
+ const chunks = [];
30
+ let chunklen = 0;
31
+ let i, len, lastPos = 0;
32
+ let buf;
33
+ if (!chunk || !chunk.length) {
34
+ return done();
35
+ }
36
+ if (typeof chunk === 'string') {
37
+ chunk = Buffer.from(chunk);
38
+ }
39
+ this.inByteCount += chunk.length;
40
+ for (i = 0, len = chunk.length; i < len; i++) {
41
+ const byte = chunk[i];
42
+ const prev = i ? chunk[i - 1] : this.lastByte;
43
+ let insert = false;
44
+ if (prev === 0x0d && byte !== 0x0a) {
45
+ // a bare CR becomes CRLF. A receiver that treats a lone CR as a line end would
46
+ // otherwise see "\r.\r" as the end of the data (SMTP smuggling), so a dot
47
+ // following it is stuffed like at the start of any other line
48
+ insert = byte === 0x2e ? INSERT_LF_DOT : INSERT_LF;
49
+ }
50
+ else if (byte === 0x0a && prev !== 0x0d) {
51
+ // a bare LF becomes CRLF
52
+ insert = INSERT_CR;
53
+ }
54
+ else if (byte === 0x2e && (prev === 0x0a || prev === false)) {
55
+ // a dot at the start of a line
56
+ insert = INSERT_DOT;
57
+ }
58
+ if (insert) {
59
+ if (i > lastPos) {
60
+ buf = chunk.slice(lastPos, i);
61
+ chunks.push(buf);
62
+ chunklen += buf.length;
63
+ }
64
+ chunks.push(insert);
65
+ chunklen += insert.length;
66
+ lastPos = i;
67
+ }
68
+ }
69
+ if (chunks.length) {
70
+ // add last piece
71
+ if (lastPos < chunk.length) {
72
+ buf = chunk.slice(lastPos);
73
+ chunks.push(buf);
74
+ chunklen += buf.length;
75
+ }
76
+ this.outByteCount += chunklen;
77
+ this.push(Buffer.concat(chunks, chunklen));
78
+ }
79
+ else {
80
+ this.outByteCount += chunk.length;
81
+ this.push(chunk);
82
+ }
83
+ this.lastByte = chunk[chunk.length - 1];
84
+ done();
85
+ }
86
+ /**
87
+ * Finalizes the stream with a dot on a single line
88
+ * @internal
89
+ */
90
+ _flush(done) {
91
+ let buf;
92
+ if (this.lastByte === 0x0a) {
93
+ buf = Buffer.from('.\r\n');
94
+ }
95
+ else if (this.lastByte === 0x0d) {
96
+ buf = Buffer.from('\n.\r\n');
97
+ }
98
+ else {
99
+ buf = Buffer.from('\r\n.\r\n');
100
+ }
101
+ this.outByteCount += buf.length;
102
+ this.push(buf);
103
+ done();
104
+ }
105
+ }
106
+ exports.default = DataStream;
107
+ module.exports = exports.default;
108
+ Object.defineProperty(module.exports, 'default', { value: exports.default, enumerable: false, writable: true, configurable: true });
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Minimal HTTP/S proxy client
3
+ */
4
+ import net from 'node:net';
5
+ import type { Callback } from '../errors.js';
6
+ /**
7
+ * TLS options for connecting to an HTTPS proxy
8
+ */
9
+ export interface HttpProxyClientOptions {
10
+ /** Set to false to accept a proxy certificate that fails validation (e.g. self-signed) */
11
+ rejectUnauthorized?: boolean | undefined;
12
+ }
13
+ /**
14
+ * Receives the proxied socket once the CONNECT handshake has succeeded, or the error that prevented it
15
+ */
16
+ export type HttpProxyClientCallback = Callback<net.Socket>;
17
+ /**
18
+ * Establishes proxied connection to destinationPort
19
+ *
20
+ * httpProxyClient("http://localhost:3128/", 80, "google.com", function(err, socket){
21
+ * socket.write("GET / HTTP/1.0\r\n\r\n");
22
+ * });
23
+ *
24
+ * @param proxyUrl proxy configuration, e.g. "http://proxy.host:3128/"
25
+ * @param destinationPort Port to open in destination host
26
+ * @param destinationHost Destination hostname
27
+ * @param callback Callback to run with the socket object once connection is established
28
+ */
29
+ declare function httpProxyClient(proxyUrl: string, destinationPort: number | string, destinationHost: string, callback: HttpProxyClientCallback): void;
30
+ /**
31
+ * Establishes proxied connection to destinationPort through an HTTPS proxy
32
+ *
33
+ * @param proxyUrl proxy configuration, e.g. "https://proxy.host:3128/"
34
+ * @param destinationPort Port to open in destination host
35
+ * @param destinationHost Destination hostname
36
+ * @param tlsOptions TLS options for the proxy connection (e.g. { rejectUnauthorized: false })
37
+ * @param callback Callback to run with the socket object once connection is established
38
+ */
39
+ declare function httpProxyClient(proxyUrl: string, destinationPort: number | string, destinationHost: string, tlsOptions: HttpProxyClientOptions | undefined, callback: HttpProxyClientCallback): void;
40
+ /**
41
+ * Socket timeout in milliseconds while the CONNECT handshake is in progress, defaults to 30 seconds.
42
+ * Settable on the function itself, the same way the CommonJS module exposed it.
43
+ */
44
+ declare namespace httpProxyClient {
45
+ let timeout: number | undefined;
46
+ }
47
+ export default httpProxyClient;