umt 2.14.0 → 2.16.0

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 (196) hide show
  1. package/module/Array/arraysJoin.js +9 -1
  2. package/module/Array/arraysJoin.js.map +1 -1
  3. package/module/Array/sum.js +35 -2
  4. package/module/Array/sum.js.map +1 -1
  5. package/module/Array/zip.js +21 -5
  6. package/module/Array/zip.js.map +1 -1
  7. package/module/Array/zipLongest.js +23 -4
  8. package/module/Array/zipLongest.js.map +1 -1
  9. package/module/Crypto/decodeBase32.js.map +1 -1
  10. package/module/Crypto/decodeBase58.js +1 -2
  11. package/module/Crypto/decodeBase58.js.map +1 -1
  12. package/module/Crypto/encodeBase32.js +11 -6
  13. package/module/Crypto/encodeBase32.js.map +1 -1
  14. package/module/DataStructure/priorityQueue.js +8 -1
  15. package/module/DataStructure/priorityQueue.js.map +1 -1
  16. package/module/IP/ipToBinaryString.js +3 -1
  17. package/module/IP/ipToBinaryString.js.map +1 -1
  18. package/module/IP/longToIp.d.ts +1 -1
  19. package/module/IP/longToIp.js +2 -7
  20. package/module/IP/longToIp.js.map +1 -1
  21. package/module/Math/addition.js +4 -11
  22. package/module/Math/addition.js.map +1 -1
  23. package/module/Math/multiplication.js +14 -6
  24. package/module/Math/multiplication.js.map +1 -1
  25. package/module/Math/nCr.js +6 -2
  26. package/module/Math/nCr.js.map +1 -1
  27. package/module/Math/standardDeviation.js +12 -7
  28. package/module/Math/standardDeviation.js.map +1 -1
  29. package/module/Math/subtract.js +5 -9
  30. package/module/Math/subtract.js.map +1 -1
  31. package/module/Object/deepClone.d.ts +10 -0
  32. package/module/Object/deepClone.js +16 -9
  33. package/module/Object/deepClone.js.map +1 -1
  34. package/module/Object/getObjectsCommon.d.ts +10 -0
  35. package/module/Object/getObjectsCommon.js +10 -0
  36. package/module/Object/getObjectsCommon.js.map +1 -1
  37. package/module/Object/getObjectsDiff.d.ts +10 -0
  38. package/module/Object/getObjectsDiff.js +17 -6
  39. package/module/Object/getObjectsDiff.js.map +1 -1
  40. package/module/Object/has.d.ts +10 -0
  41. package/module/Object/has.js +13 -2
  42. package/module/Object/has.js.map +1 -1
  43. package/module/Object/index.d.ts +4 -0
  44. package/module/Object/index.js +4 -0
  45. package/module/Object/index.js.map +1 -1
  46. package/module/Object/keyBy.d.ts +10 -0
  47. package/module/Object/keyBy.js +10 -0
  48. package/module/Object/keyBy.js.map +1 -1
  49. package/module/Object/mapKeys.d.ts +10 -0
  50. package/module/Object/mapKeys.js +12 -1
  51. package/module/Object/mapKeys.js.map +1 -1
  52. package/module/Object/mapValues.d.ts +10 -0
  53. package/module/Object/mapValues.js +10 -0
  54. package/module/Object/mapValues.js.map +1 -1
  55. package/module/Object/merge.d.ts +10 -0
  56. package/module/Object/merge.js +17 -1
  57. package/module/Object/merge.js.map +1 -1
  58. package/module/Object/mergeDeep.d.ts +10 -0
  59. package/module/Object/mergeDeep.js +29 -15
  60. package/module/Object/mergeDeep.js.map +1 -1
  61. package/module/Object/pick.d.ts +10 -0
  62. package/module/Object/pick.js +10 -0
  63. package/module/Object/pick.js.map +1 -1
  64. package/module/Object/pickDeep.d.ts +10 -0
  65. package/module/Object/pickDeep.js +10 -5
  66. package/module/Object/pickDeep.js.map +1 -1
  67. package/module/Object/removePrototype.d.ts +15 -0
  68. package/module/Object/removePrototype.js +25 -0
  69. package/module/Object/removePrototype.js.map +1 -0
  70. package/module/Object/removePrototypeDeep.d.ts +11 -0
  71. package/module/Object/removePrototypeDeep.js +60 -0
  72. package/module/Object/removePrototypeDeep.js.map +1 -0
  73. package/module/Object/removePrototypeMap.d.ts +9 -0
  74. package/module/Object/removePrototypeMap.js +13 -0
  75. package/module/Object/removePrototypeMap.js.map +1 -0
  76. package/module/Object/removePrototypeMapDeep.d.ts +9 -0
  77. package/module/Object/removePrototypeMapDeep.js +13 -0
  78. package/module/Object/removePrototypeMapDeep.js.map +1 -0
  79. package/module/String/escapeHtml.js +11 -2
  80. package/module/String/escapeHtml.js.map +1 -1
  81. package/module/String/formatString/applyFormatter.js +5 -5
  82. package/module/String/formatString/applyFormatter.js.map +1 -1
  83. package/module/String/formatString/getValue.js +3 -1
  84. package/module/String/formatString/getValue.js.map +1 -1
  85. package/module/String/levenshteinDistance.js +41 -24
  86. package/module/String/levenshteinDistance.js.map +1 -1
  87. package/module/String/slugify.js +7 -5
  88. package/module/String/slugify.js.map +1 -1
  89. package/module/String/trimEndCharacters.js +3 -1
  90. package/module/String/trimEndCharacters.js.map +1 -1
  91. package/module/String/trimStartCharacters.js +3 -1
  92. package/module/String/trimStartCharacters.js.map +1 -1
  93. package/module/String/unescapeHtml.d.ts +1 -1
  94. package/module/String/unescapeHtml.js +48 -4
  95. package/module/String/unescapeHtml.js.map +1 -1
  96. package/module/Tool/parseJson.js +13 -1
  97. package/module/Tool/parseJson.js.map +1 -1
  98. package/module/URL/buildUrl.js +4 -0
  99. package/module/URL/buildUrl.js.map +1 -1
  100. package/module/URL/parseQueryString.js +4 -0
  101. package/module/URL/parseQueryString.js.map +1 -1
  102. package/module/Validate/isDeepEqual.js +7 -5
  103. package/module/Validate/isDeepEqual.js.map +1 -1
  104. package/module/Validate/isPrimeNumber.js +12 -2
  105. package/module/Validate/isPrimeNumber.js.map +1 -1
  106. package/module/Validate/object/index.d.ts +2 -0
  107. package/module/Validate/object/index.js +2 -0
  108. package/module/Validate/object/index.js.map +1 -1
  109. package/module/Validate/object/intersection.d.ts +10 -0
  110. package/module/Validate/object/intersection.js +25 -0
  111. package/module/Validate/object/intersection.js.map +1 -0
  112. package/module/Validate/object/optional.d.ts +6 -0
  113. package/module/Validate/object/optional.js +6 -0
  114. package/module/Validate/object/optional.js.map +1 -1
  115. package/module/Validate/object/union.d.ts +9 -0
  116. package/module/Validate/object/union.js +27 -0
  117. package/module/Validate/object/union.js.map +1 -0
  118. package/module/Validate/parseEmail.js +6 -0
  119. package/module/Validate/parseEmail.js.map +1 -1
  120. package/module/Validate/string/uuid.d.ts +1 -5
  121. package/module/Validate/string/uuid.js +19 -2
  122. package/module/Validate/string/uuid.js.map +1 -1
  123. package/module/es5/Array/arraysJoin.js +20 -2
  124. package/module/es5/Array/sum.js +38 -4
  125. package/module/es5/Array/zip.js +23 -17
  126. package/module/es5/Array/zipLongest.js +27 -14
  127. package/module/es5/Crypto/decodeBase58.js +1 -2
  128. package/module/es5/Crypto/encodeBase32.js +12 -6
  129. package/module/es5/DataStructure/priorityQueue.js +8 -3
  130. package/module/es5/IP/ipToBinaryString.js +2 -2
  131. package/module/es5/IP/longToIp.d.ts +1 -1
  132. package/module/es5/IP/longToIp.js +2 -13
  133. package/module/es5/Math/addition.js +4 -13
  134. package/module/es5/Math/multiplication.js +37 -6
  135. package/module/es5/Math/nCr.js +7 -2
  136. package/module/es5/Math/standardDeviation.js +25 -10
  137. package/module/es5/Math/subtract.js +12 -9
  138. package/module/es5/Object/deepClone.d.ts +10 -0
  139. package/module/es5/Object/deepClone.js +16 -9
  140. package/module/es5/Object/getObjectsCommon.d.ts +10 -0
  141. package/module/es5/Object/getObjectsCommon.js +10 -0
  142. package/module/es5/Object/getObjectsDiff.d.ts +10 -0
  143. package/module/es5/Object/getObjectsDiff.js +32 -17
  144. package/module/es5/Object/has.d.ts +10 -0
  145. package/module/es5/Object/has.js +11 -7
  146. package/module/es5/Object/index.d.ts +4 -0
  147. package/module/es5/Object/index.js +44 -0
  148. package/module/es5/Object/keyBy.d.ts +10 -0
  149. package/module/es5/Object/keyBy.js +10 -0
  150. package/module/es5/Object/mapKeys.d.ts +10 -0
  151. package/module/es5/Object/mapKeys.js +12 -1
  152. package/module/es5/Object/mapValues.d.ts +10 -0
  153. package/module/es5/Object/mapValues.js +10 -0
  154. package/module/es5/Object/merge.d.ts +10 -0
  155. package/module/es5/Object/merge.js +19 -1
  156. package/module/es5/Object/mergeDeep.d.ts +10 -0
  157. package/module/es5/Object/mergeDeep.js +34 -18
  158. package/module/es5/Object/pick.d.ts +10 -0
  159. package/module/es5/Object/pick.js +10 -0
  160. package/module/es5/Object/pickDeep.d.ts +10 -0
  161. package/module/es5/Object/pickDeep.js +10 -3
  162. package/module/es5/Object/removePrototype.d.ts +15 -0
  163. package/module/es5/Object/removePrototype.js +31 -0
  164. package/module/es5/Object/removePrototypeDeep.d.ts +11 -0
  165. package/module/es5/Object/removePrototypeDeep.js +81 -0
  166. package/module/es5/Object/removePrototypeMap.d.ts +9 -0
  167. package/module/es5/Object/removePrototypeMap.js +20 -0
  168. package/module/es5/Object/removePrototypeMapDeep.d.ts +9 -0
  169. package/module/es5/Object/removePrototypeMapDeep.js +20 -0
  170. package/module/es5/String/escapeHtml.js +12 -3
  171. package/module/es5/String/formatString/applyFormatter.js +5 -5
  172. package/module/es5/String/formatString/getValue.js +4 -1
  173. package/module/es5/String/levenshteinDistance.js +43 -28
  174. package/module/es5/String/slugify.js +8 -1
  175. package/module/es5/String/trimEndCharacters.js +3 -1
  176. package/module/es5/String/trimStartCharacters.js +3 -1
  177. package/module/es5/String/unescapeHtml.d.ts +1 -1
  178. package/module/es5/String/unescapeHtml.js +46 -4
  179. package/module/es5/Tool/parseJson.js +14 -1
  180. package/module/es5/URL/buildUrl.js +4 -0
  181. package/module/es5/URL/parseQueryString.js +4 -0
  182. package/module/es5/Validate/isDeepEqual.js +48 -39
  183. package/module/es5/Validate/isPrimeNumber.js +14 -2
  184. package/module/es5/Validate/object/index.d.ts +2 -0
  185. package/module/es5/Validate/object/index.js +22 -0
  186. package/module/es5/Validate/object/intersection.d.ts +10 -0
  187. package/module/es5/Validate/object/intersection.js +34 -0
  188. package/module/es5/Validate/object/optional.d.ts +6 -0
  189. package/module/es5/Validate/object/optional.js +6 -0
  190. package/module/es5/Validate/object/union.d.ts +9 -0
  191. package/module/es5/Validate/object/union.js +36 -0
  192. package/module/es5/Validate/parseEmail.js +8 -0
  193. package/module/es5/Validate/string/uuid.d.ts +1 -5
  194. package/module/es5/Validate/string/uuid.js +24 -2
  195. package/package.json +19 -19
  196. package/module/es5/tsconfig.tsbuildinfo +0 -1
@@ -19,6 +19,34 @@ var htmlUnescapeMap = {
19
19
  "=": "="
20
20
  };
21
21
 
22
+ /**
23
+ * Security: Checks whether a numeric code point is safe to decode.
24
+ * Rejects NULL (0), C0 control chars (1-31 except TAB 9, LF 10, CR 13),
25
+ * DEL (127), C1 control chars (128-159), lone surrogates (0xD800-0xDFFF),
26
+ * and values beyond the Unicode maximum (>0x10FFFF).
27
+ */
28
+ var isSafeCodePoint = function isSafeCodePoint(codePoint) {
29
+ if (codePoint > 0x10ffff) {
30
+ return false;
31
+ }
32
+ if (codePoint === 0) {
33
+ return false;
34
+ }
35
+ if (codePoint >= 0xd800 && codePoint <= 0xdfff) {
36
+ return false;
37
+ }
38
+ if (codePoint <= 0x1f && codePoint !== 0x09 && codePoint !== 0x0a && codePoint !== 0x0d) {
39
+ return false;
40
+ }
41
+ if (codePoint === 0x7f) {
42
+ return false;
43
+ }
44
+ if (codePoint >= 0x80 && codePoint <= 0x9f) {
45
+ return false;
46
+ }
47
+ return true;
48
+ };
49
+
22
50
  /**
23
51
  * Unescapes HTML entities in a string
24
52
  * @param string_ - The string to unescape
@@ -26,7 +54,7 @@ var htmlUnescapeMap = {
26
54
  * @example
27
55
  * ```typescript
28
56
  * unescapeHtml("&lt;script&gt;alert(&quot;Hello&quot;);&lt;/script&gt;");
29
- * // Returns: "<script>alert("Hello");</script>"
57
+ * // Returns: "<script>alert(\"Hello\");</script>"
30
58
  *
31
59
  * unescapeHtml("Tom &amp; Jerry");
32
60
  * // Returns: "Tom & Jerry"
@@ -36,15 +64,29 @@ var htmlUnescapeMap = {
36
64
  * ```
37
65
  */
38
66
  var unescapeHtml = exports.unescapeHtml = function unescapeHtml(string_) {
39
- var entityRegex = /&(?:amp|lt|gt|quot|#39|#x27|#x2F|#x60|#x3D);|&#(\d*);|&#x([\dA-Fa-f]*);/g;
67
+ var entityRegex = /&(?:amp|lt|gt|quot|#39|#x27|#x2F|#x60|#x3D);|&#(\d{1,7});|&#x([\dA-Fa-f]{1,6});/g;
40
68
  return string_.replaceAll(entityRegex, function (match, dec, hex) {
41
69
  if (dec !== undefined) {
42
70
  var codePoint = Number.parseInt(dec, 10);
43
- return Number.isNaN(codePoint) ? match : String.fromCodePoint(codePoint);
71
+ // Security: reject dangerous code points to prevent injection attacks.
72
+ // NULL bytes (0) enable null-byte injection that can truncate strings in
73
+ // downstream systems. C0 control chars (1-31 except TAB/LF/CR) and the
74
+ // DEL char (127) can break parsers. C1 control chars (128-159) are
75
+ // invalid in HTML. Surrogate code points (0xD800-0xDFFF) produce
76
+ // malformed strings. Out-of-range values (>0x10FFFF) are not valid
77
+ // Unicode. Leave these entity references unmodified rather than decoding
78
+ // them into potentially dangerous characters.
79
+ if (!isSafeCodePoint(codePoint)) {
80
+ return match;
81
+ }
82
+ return String.fromCodePoint(codePoint);
44
83
  }
45
84
  if (hex !== undefined) {
46
85
  var _codePoint = Number.parseInt(hex, 16);
47
- return Number.isNaN(_codePoint) ? match : String.fromCodePoint(_codePoint);
86
+ if (!isSafeCodePoint(_codePoint)) {
87
+ return match;
88
+ }
89
+ return String.fromCodePoint(_codePoint);
48
90
  }
49
91
  return htmlUnescapeMap[match];
50
92
  });
@@ -4,6 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.parseJson = void 0;
7
+ // Security: Keys that must be stripped during JSON parsing to prevent
8
+ // prototype pollution. If an attacker controls the JSON input, they can
9
+ // embed keys like "__proto__" which, when the parsed object is later
10
+ // spread or merged (e.g. via Object.assign, spread operator, or any
11
+ // deep-merge utility), can overwrite properties on Object.prototype
12
+ // and affect all objects in the runtime.
13
+ var DANGEROUS_KEYS = new Set(["__proto__", "constructor", "prototype"]);
14
+
7
15
  /**
8
16
  * Parses a JSON string into a typed JavaScript value
9
17
  * @template T The expected type of the parsed value (defaults to unknown)
@@ -12,5 +20,10 @@ exports.parseJson = void 0;
12
20
  * @throws {SyntaxError} If the JSON string is invalid
13
21
  */
14
22
  var parseJson = exports.parseJson = function parseJson(json) {
15
- return JSON.parse(json);
23
+ return JSON.parse(json, function (key, value) {
24
+ if (DANGEROUS_KEYS.has(key)) {
25
+ return;
26
+ }
27
+ return value;
28
+ });
16
29
  };
@@ -25,6 +25,10 @@ var buildUrl = exports.buildUrl = function buildUrl(base) {
25
25
  var url = new URL(base);
26
26
  for (var _i = 0, _Object$keys = Object.keys(parameters); _i < _Object$keys.length; _i++) {
27
27
  var key = _Object$keys[_i];
28
+ // Prevent prototype pollution by rejecting dangerous keys
29
+ if (key === "__proto__" || key === "constructor" || key === "prototype") {
30
+ continue;
31
+ }
28
32
  url.searchParams.append(key, parameters[key]);
29
33
  }
30
34
  return url.toString();
@@ -46,6 +46,10 @@ var parseQueryString = exports.parseQueryString = function parseQueryString(quer
46
46
  var _step$value = _slicedToArray(_step.value, 2),
47
47
  key = _step$value[0],
48
48
  value = _step$value[1];
49
+ // Prevent prototype pollution by rejecting dangerous keys
50
+ if (key === "__proto__" || key === "constructor" || key === "prototype") {
51
+ continue;
52
+ }
49
53
  result[key] = value;
50
54
  }
51
55
  } catch (err) {
@@ -4,10 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.isDeepEqual = isDeepEqual;
7
- function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
8
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
9
- function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
10
- function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
11
7
  function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
12
8
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
13
9
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
@@ -93,19 +89,32 @@ function isDeepEqual(a, b) {
93
89
  _iterator.f();
94
90
  }
95
91
  } else {
96
- var yCopy = _toConsumableArray(y);
92
+ // Performance: Use Set<number> to track matched indices instead of
93
+ // splice(), avoiding O(n) array shifts per removal (O(n²) → O(n)).
94
+ var usedIndices = new Set();
97
95
  var _iterator2 = _createForOfIteratorHelper(x),
98
96
  _step2;
99
97
  try {
100
98
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
101
99
  var itemX = _step2.value;
102
100
  var found = false;
103
- for (var _index = 0; _index < yCopy.length; _index++) {
104
- if (compare(itemX, yCopy[_index])) {
105
- yCopy.splice(_index, 1);
106
- found = true;
107
- break;
101
+ var _iterator3 = _createForOfIteratorHelper(y.entries()),
102
+ _step3;
103
+ try {
104
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
105
+ var _step3$value = _slicedToArray(_step3.value, 2),
106
+ _index = _step3$value[0],
107
+ itemY = _step3$value[1];
108
+ if (!usedIndices.has(_index) && compare(itemX, itemY)) {
109
+ usedIndices.add(_index);
110
+ found = true;
111
+ break;
112
+ }
108
113
  }
114
+ } catch (err) {
115
+ _iterator3.e(err);
116
+ } finally {
117
+ _iterator3.f();
109
118
  }
110
119
  if (!found) {
111
120
  return false;
@@ -116,7 +125,7 @@ function isDeepEqual(a, b) {
116
125
  } finally {
117
126
  _iterator2.f();
118
127
  }
119
- return yCopy.length === 0;
128
+ return usedIndices.size === y.length;
120
129
  }
121
130
  return true;
122
131
  }
@@ -124,35 +133,35 @@ function isDeepEqual(a, b) {
124
133
  if (x.size !== y.size) {
125
134
  return false;
126
135
  }
127
- var _iterator3 = _createForOfIteratorHelper(x),
128
- _step3;
136
+ var _iterator4 = _createForOfIteratorHelper(x),
137
+ _step4;
129
138
  try {
130
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
131
- var item = _step3.value;
139
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
140
+ var item = _step4.value;
132
141
  var _found = false;
133
- var _iterator4 = _createForOfIteratorHelper(y),
134
- _step4;
142
+ var _iterator5 = _createForOfIteratorHelper(y),
143
+ _step5;
135
144
  try {
136
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
137
- var otherItem = _step4.value;
145
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
146
+ var otherItem = _step5.value;
138
147
  if (compare(item, otherItem)) {
139
148
  _found = true;
140
149
  break;
141
150
  }
142
151
  }
143
152
  } catch (err) {
144
- _iterator4.e(err);
153
+ _iterator5.e(err);
145
154
  } finally {
146
- _iterator4.f();
155
+ _iterator5.f();
147
156
  }
148
157
  if (!_found) {
149
158
  return false;
150
159
  }
151
160
  }
152
161
  } catch (err) {
153
- _iterator3.e(err);
162
+ _iterator4.e(err);
154
163
  } finally {
155
- _iterator3.f();
164
+ _iterator4.f();
156
165
  }
157
166
  return true;
158
167
  }
@@ -160,39 +169,39 @@ function isDeepEqual(a, b) {
160
169
  if (x.size !== y.size) {
161
170
  return false;
162
171
  }
163
- var _iterator5 = _createForOfIteratorHelper(x),
164
- _step5;
172
+ var _iterator6 = _createForOfIteratorHelper(x),
173
+ _step6;
165
174
  try {
166
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
167
- var _step5$value = _slicedToArray(_step5.value, 2),
168
- key = _step5$value[0],
169
- value = _step5$value[1];
175
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
176
+ var _step6$value = _slicedToArray(_step6.value, 2),
177
+ key = _step6$value[0],
178
+ value = _step6$value[1];
170
179
  var _found2 = false;
171
- var _iterator6 = _createForOfIteratorHelper(y),
172
- _step6;
180
+ var _iterator7 = _createForOfIteratorHelper(y),
181
+ _step7;
173
182
  try {
174
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
175
- var _step6$value = _slicedToArray(_step6.value, 2),
176
- otherKey = _step6$value[0],
177
- otherValue = _step6$value[1];
183
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
184
+ var _step7$value = _slicedToArray(_step7.value, 2),
185
+ otherKey = _step7$value[0],
186
+ otherValue = _step7$value[1];
178
187
  if (compare(key, otherKey) && compare(value, otherValue)) {
179
188
  _found2 = true;
180
189
  break;
181
190
  }
182
191
  }
183
192
  } catch (err) {
184
- _iterator6.e(err);
193
+ _iterator7.e(err);
185
194
  } finally {
186
- _iterator6.f();
195
+ _iterator7.f();
187
196
  }
188
197
  if (!_found2) {
189
198
  return false;
190
199
  }
191
200
  }
192
201
  } catch (err) {
193
- _iterator5.e(err);
202
+ _iterator6.e(err);
194
203
  } finally {
195
- _iterator5.f();
204
+ _iterator6.f();
196
205
  }
197
206
  return true;
198
207
  }
@@ -18,8 +18,20 @@ var isPrimeNumber = exports.isPrimeNumber = function isPrimeNumber(n) {
18
18
  if (n <= 1 || !Number.isInteger(n)) {
19
19
  return false;
20
20
  }
21
- for (var index = 2; index <= Math.sqrt(n); index++) {
22
- if (n % index === 0) {
21
+
22
+ // Handle small primes and eliminate even numbers / multiples of 3 early
23
+ if (n <= 3) {
24
+ return true;
25
+ }
26
+ if (n % 2 === 0 || n % 3 === 0) {
27
+ return false;
28
+ }
29
+
30
+ // Performance: only test divisors of the form 6k +/- 1.
31
+ // All primes > 3 are of this form, so we skip ~2/3 of candidates
32
+ // compared to the naive loop that checks every integer from 2 to sqrt(n).
33
+ for (var index = 5; index * index <= n; index += 6) {
34
+ if (n % index === 0 || n % (index + 2) === 0) {
23
35
  return false;
24
36
  }
25
37
  }
@@ -1,2 +1,4 @@
1
1
  export * from "./core";
2
+ export * from "./intersection";
2
3
  export * from "./optional";
4
+ export * from "./union";
@@ -14,6 +14,17 @@ Object.keys(_core).forEach(function (key) {
14
14
  }
15
15
  });
16
16
  });
17
+ var _intersection = require("./intersection");
18
+ Object.keys(_intersection).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _intersection[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function get() {
24
+ return _intersection[key];
25
+ }
26
+ });
27
+ });
17
28
  var _optional = require("./optional");
18
29
  Object.keys(_optional).forEach(function (key) {
19
30
  if (key === "default" || key === "__esModule") return;
@@ -24,4 +35,15 @@ Object.keys(_optional).forEach(function (key) {
24
35
  return _optional[key];
25
36
  }
26
37
  });
38
+ });
39
+ var _union = require("./union");
40
+ Object.keys(_union).forEach(function (key) {
41
+ if (key === "default" || key === "__esModule") return;
42
+ if (key in exports && exports[key] === _union[key]) return;
43
+ Object.defineProperty(exports, key, {
44
+ enumerable: true,
45
+ get: function get() {
46
+ return _union[key];
47
+ }
48
+ });
27
49
  });
@@ -0,0 +1,10 @@
1
+ import type { UnionToIntersection } from "../../types/logic";
2
+ import type { ValidateCoreReturnType } from "../../Validate/type";
3
+ type ExtractValidatedType<V> = V extends (value: never) => ValidateCoreReturnType<infer T> ? T : never;
4
+ /**
5
+ * Creates an intersection validator that passes only if all given validators pass
6
+ * @param validators - Validator functions to compose as an intersection (logical AND)
7
+ * @returns {Function} - Validator that checks if the value matches all validators
8
+ */
9
+ export declare const intersection: <Vs extends ((value: never) => ValidateCoreReturnType<unknown>)[]>(...validators: [...Vs]) => (value: UnionToIntersection<ExtractValidatedType<Vs[number]>>) => ValidateCoreReturnType<UnionToIntersection<ExtractValidatedType<Vs[number]>>>;
10
+ export {};
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.intersection = void 0;
7
+ /**
8
+ * Creates an intersection validator that passes only if all given validators pass
9
+ * @param validators - Validator functions to compose as an intersection (logical AND)
10
+ * @returns {Function} - Validator that checks if the value matches all validators
11
+ */
12
+ var intersection = exports.intersection = function intersection() {
13
+ for (var _len = arguments.length, validators = new Array(_len), _key = 0; _key < _len; _key++) {
14
+ validators[_key] = arguments[_key];
15
+ }
16
+ return function (value) {
17
+ for (var _i = 0, _validators = validators; _i < _validators.length; _i++) {
18
+ var validator = _validators[_i];
19
+ var result = validator(value);
20
+ if (!result.validate) {
21
+ return {
22
+ validate: false,
23
+ message: result.message,
24
+ type: value
25
+ };
26
+ }
27
+ }
28
+ return {
29
+ validate: true,
30
+ message: "",
31
+ type: value
32
+ };
33
+ };
34
+ };
@@ -1,2 +1,8 @@
1
1
  import type { ValidateCoreReturnType } from "../../Validate/type";
2
+ /**
3
+ * Wraps a validator to accept undefined values
4
+ * @template T - The type of value the wrapped validator expects
5
+ * @param {Function} validator - Validator function to make optional
6
+ * @returns {Function} - Validator that passes for undefined or delegates to the wrapped validator
7
+ */
2
8
  export declare const optional: <T>(validator: (value: T) => ValidateCoreReturnType<T>) => ((value?: T) => ValidateCoreReturnType<T | undefined>);
@@ -4,6 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.optional = void 0;
7
+ /**
8
+ * Wraps a validator to accept undefined values
9
+ * @template T - The type of value the wrapped validator expects
10
+ * @param {Function} validator - Validator function to make optional
11
+ * @returns {Function} - Validator that passes for undefined or delegates to the wrapped validator
12
+ */
7
13
  var optional = exports.optional = function optional(validator) {
8
14
  var optionalValidator = function optionalValidator(value) {
9
15
  if (value === undefined) {
@@ -0,0 +1,9 @@
1
+ import type { ValidateCoreReturnType } from "../../Validate/type";
2
+ type ExtractValidatedType<V> = V extends (value: never) => ValidateCoreReturnType<infer T> ? T : never;
3
+ /**
4
+ * Creates a union validator that passes if any of the given validators pass
5
+ * @param validators - Validator functions to compose as a union (logical OR)
6
+ * @returns {Function} - Validator that checks if the value matches any of the validators
7
+ */
8
+ export declare const union: <Vs extends ((value: never) => ValidateCoreReturnType<unknown>)[]>(...validators: [...Vs]) => (value: ExtractValidatedType<Vs[number]>) => ValidateCoreReturnType<ExtractValidatedType<Vs[number]>>;
9
+ export {};
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.union = void 0;
7
+ /**
8
+ * Creates a union validator that passes if any of the given validators pass
9
+ * @param validators - Validator functions to compose as a union (logical OR)
10
+ * @returns {Function} - Validator that checks if the value matches any of the validators
11
+ */
12
+ var union = exports.union = function union() {
13
+ for (var _len = arguments.length, validators = new Array(_len), _key = 0; _key < _len; _key++) {
14
+ validators[_key] = arguments[_key];
15
+ }
16
+ return function (value) {
17
+ var lastMessage = "";
18
+ for (var _i = 0, _validators = validators; _i < _validators.length; _i++) {
19
+ var validator = _validators[_i];
20
+ var result = validator(value);
21
+ if (result.validate) {
22
+ return {
23
+ validate: true,
24
+ message: "",
25
+ type: value
26
+ };
27
+ }
28
+ lastMessage = result.message;
29
+ }
30
+ return {
31
+ validate: false,
32
+ message: lastMessage,
33
+ type: value
34
+ };
35
+ };
36
+ };
@@ -33,6 +33,14 @@ var EMAIL_PATTERNS = {
33
33
  var parseEmail = exports.parseEmail = function parseEmail(_ref) {
34
34
  var email = _ref.email,
35
35
  options = _ref.options;
36
+ // ReDoS mitigation: reject excessively long inputs before regex evaluation
37
+ // RFC 5321 specifies max 256 characters for a full email address
38
+ var MAX_EMAIL_LENGTH = 320;
39
+ if (email.length > MAX_EMAIL_LENGTH) {
40
+ return {
41
+ valid: false
42
+ };
43
+ }
36
44
  var level = options.level;
37
45
  var pattern = EMAIL_PATTERNS[level];
38
46
  var match = pattern.exec(email);
@@ -1,11 +1,7 @@
1
1
  import type { ValidateReturnType } from "../../Validate/type";
2
- /**
3
- * String validation module for UUID strings
4
- * Provides validation functionality for checking if a string is a valid UUID
5
- */
6
2
  /**
7
3
  * Creates a validator for checking if a string is a valid UUID
8
- * @param {number[]} [versions=[4]] - Array of supported UUID versions
4
+ * @param {number[]} [versions=[4]] - Array of supported UUID versions (1-7)
9
5
  * @param {string} [message] - Custom error message for validation failure
10
6
  * @returns {ValidateReturnType<string>} - Validator for UUID strings
11
7
  */
@@ -11,16 +11,38 @@ function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.fre
11
11
  * Provides validation functionality for checking if a string is a valid UUID
12
12
  */
13
13
 
14
+ // Security: Valid UUID versions are single-digit integers (1-7).
15
+ // The version value is interpolated into a RegExp constructor, so untrusted
16
+ // input could inject arbitrary regex patterns (regex injection / ReDoS).
17
+ // We validate each version is a safe integer in the expected range before use.
18
+ var VALID_UUID_VERSIONS = new Set([1, 2, 3, 4, 5, 6, 7]);
19
+
14
20
  /**
15
21
  * Creates a validator for checking if a string is a valid UUID
16
- * @param {number[]} [versions=[4]] - Array of supported UUID versions
22
+ * @param {number[]} [versions=[4]] - Array of supported UUID versions (1-7)
17
23
  * @param {string} [message] - Custom error message for validation failure
18
24
  * @returns {ValidateReturnType<string>} - Validator for UUID strings
19
25
  */
20
26
  var uuid = exports.uuid = function uuid() {
21
27
  var versions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [4];
22
28
  var message = arguments.length > 1 ? arguments[1] : undefined;
23
- var versionRegexes = versions.map(function (version) {
29
+ // Security: Sanitize version input to prevent regex injection.
30
+ // Only allow known UUID version numbers (integers 1-7) to be interpolated
31
+ // into the RegExp pattern. Reject anything else to block arbitrary regex
32
+ // metacharacter injection via untrusted input.
33
+ var safeVersions = versions.filter(function (v) {
34
+ return VALID_UUID_VERSIONS.has(v);
35
+ });
36
+ if (safeVersions.length === 0) {
37
+ return {
38
+ type: "string",
39
+ message: message,
40
+ validate: function validate() {
41
+ return false;
42
+ }
43
+ };
44
+ }
45
+ var versionRegexes = safeVersions.map(function (version) {
24
46
  return new RegExp(String.raw(_templateObject || (_templateObject = _taggedTemplateLiteral(["^[da-f]{8}-?[da-f]{4}-?", "[da-f]{3}-?[89ab][da-f]{3}-?[da-f]{12}$"], ["^[\\da-f]{8}-?[\\da-f]{4}-?", "[\\da-f]{3}-?[89ab][\\da-f]{3}-?[\\da-f]{12}$"])), version), "i");
25
47
  });
26
48
  return {
package/package.json CHANGED
@@ -7,38 +7,38 @@
7
7
  "devDependencies": {
8
8
  "@babel/cli": "7.28.6",
9
9
  "@babel/core": "7.29.0",
10
- "@babel/preset-env": "7.29.0",
10
+ "@babel/preset-env": "7.29.2",
11
11
  "@babel/preset-typescript": "7.28.5",
12
- "@biomejs/biome": "2.4.7",
13
- "@codecov/bundle-analyzer": "1.9.1",
12
+ "@biomejs/biome": "2.4.12",
13
+ "@codecov/bundle-analyzer": "2.0.1",
14
14
  "@eslint/js": "10.0.1",
15
- "@swc/core": "1.15.18",
15
+ "@swc/core": "1.15.30",
16
16
  "@swc/jest": "0.2.39",
17
- "@types/bun": "1.3.10",
17
+ "@types/bun": "1.3.12",
18
18
  "@types/jest": "30.0.0",
19
19
  "@types/lodash": "4.17.24",
20
- "@types/node": "25.5.0",
21
- "@typescript-eslint/eslint-plugin": "8.57.0",
22
- "@typescript-eslint/parser": "8.57.0",
23
- "bun-types": "1.3.10",
24
- "dependency-cruiser": "17.3.9",
20
+ "@types/node": "25.6.0",
21
+ "@typescript-eslint/eslint-plugin": "8.58.2",
22
+ "@typescript-eslint/parser": "8.58.2",
23
+ "bun-types": "1.3.12",
24
+ "dependency-cruiser": "17.3.10",
25
25
  "es-toolkit": "1.45.1",
26
- "eslint": "10.0.3",
27
- "eslint-plugin-baseline-js": "0.6.1",
26
+ "eslint": "10.2.1",
27
+ "eslint-plugin-baseline-js": "0.6.2",
28
28
  "eslint-plugin-import": "2.32.0",
29
- "eslint-plugin-unicorn": "63.0.0",
29
+ "eslint-plugin-unicorn": "64.0.0",
30
30
  "fast-sort": "3.4.1",
31
31
  "gh-pages": "6.3.0",
32
32
  "jest": "30.3.0",
33
33
  "jest-junit": "16.0.0",
34
- "lodash": "4.17.23",
34
+ "lodash": "4.18.1",
35
35
  "mitata": "1.0.34",
36
- "ts-jest": "29.4.6",
36
+ "ts-jest": "29.4.9",
37
37
  "ts-node": "10.9.2",
38
38
  "tsc-alias": "1.8.16",
39
- "typedoc": "0.28.17",
40
- "typescript": "5.9.3",
41
- "typescript-eslint": "8.57.0"
39
+ "typedoc": "0.28.19",
40
+ "typescript": "6.0.3",
41
+ "typescript-eslint": "8.58.2"
42
42
  },
43
43
  "exports": {
44
44
  ".": {
@@ -218,5 +218,5 @@
218
218
  },
219
219
  "type": "module",
220
220
  "types": "module/index.d.ts",
221
- "version": "2.14.0"
221
+ "version": "2.16.0"
222
222
  }