@nestjs/common 11.1.12 → 11.1.13
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.
- package/Readme.md +1 -0
- package/package.json +2 -2
- package/pipes/validation.pipe.js +18 -4
- package/services/console-logger.service.js +2 -2
package/Readme.md
CHANGED
|
@@ -63,6 +63,7 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
|
|
63
63
|
<td><a href="https://microsoft.com/" target="_blank"><img src="https://nestjs.com/img/logos/microsoft-logo.png" width="180" valign="middle" /></a></td>
|
|
64
64
|
<td><a href="https://mojam.co" target="_blank"><img src="https://nestjs.com/img/logos/mojam-logo.png" width="80" valign="middle" /></a></td>
|
|
65
65
|
<td><a href="https://valor-software.com/" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/valor-software.png" width="170" valign="middle" /></a></td>
|
|
66
|
+
<td><a href="https://serpapi.com/" target="_blank"><img src="https://nestjs.com/img/logos/serpapi-logo.png" width="150" valign="middle" /></a></td>
|
|
66
67
|
</tr>
|
|
67
68
|
</table>
|
|
68
69
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestjs/common",
|
|
3
|
-
"version": "11.1.
|
|
3
|
+
"version": "11.1.13",
|
|
4
4
|
"description": "Nest - modern, fast, powerful node.js web framework (@common)",
|
|
5
5
|
"author": "Kamil Mysliwiec",
|
|
6
6
|
"homepage": "https://nestjs.com",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"optional": true
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "e3a958ac3efebe7995e6d487e00bbc6fd6267fd5"
|
|
42
42
|
}
|
package/pipes/validation.pipe.js
CHANGED
|
@@ -12,6 +12,11 @@ const load_package_util_1 = require("../utils/load-package.util");
|
|
|
12
12
|
const shared_utils_1 = require("../utils/shared.utils");
|
|
13
13
|
let classValidator = {};
|
|
14
14
|
let classTransformer = {};
|
|
15
|
+
/**
|
|
16
|
+
* Built-in JavaScript types that should be excluded from prototype stripping
|
|
17
|
+
* to avoid conflicts with test frameworks like Jest's useFakeTimers
|
|
18
|
+
*/
|
|
19
|
+
const BUILT_IN_TYPES = [Date, RegExp, Error, Map, Set, WeakMap, WeakSet];
|
|
15
20
|
/**
|
|
16
21
|
* @see [Validation](https://docs.nestjs.com/techniques/validation)
|
|
17
22
|
*
|
|
@@ -21,7 +26,7 @@ let ValidationPipe = class ValidationPipe {
|
|
|
21
26
|
constructor(options) {
|
|
22
27
|
options = options || {};
|
|
23
28
|
const { transform, disableErrorMessages, errorHttpStatusCode, expectedType, transformOptions, validateCustomDecorators, ...validatorOptions } = options;
|
|
24
|
-
// @see https://github.com/nestjs/nest/issues/10683#issuecomment-1413690508
|
|
29
|
+
// @see [https://github.com/nestjs/nest/issues/10683#issuecomment-1413690508](https://github.com/nestjs/nest/issues/10683#issuecomment-1413690508)
|
|
25
30
|
this.validatorOptions = { forbidUnknownValues: false, ...validatorOptions };
|
|
26
31
|
this.isTransformEnabled = !!transform;
|
|
27
32
|
this.transformOptions = transformOptions;
|
|
@@ -76,7 +81,7 @@ let ValidationPipe = class ValidationPipe {
|
|
|
76
81
|
if (originalValue === undefined && originalEntity === '') {
|
|
77
82
|
// Since SWC requires empty string for validation (to avoid an error),
|
|
78
83
|
// a fallback is needed to revert to the original value (when undefined).
|
|
79
|
-
// @see https://github.com/nestjs/nest/issues/14430
|
|
84
|
+
// @see [https://github.com/nestjs/nest/issues/14430](https://github.com/nestjs/nest/issues/14430)
|
|
80
85
|
return originalValue;
|
|
81
86
|
}
|
|
82
87
|
if (isPrimitive) {
|
|
@@ -159,7 +164,7 @@ let ValidationPipe = class ValidationPipe {
|
|
|
159
164
|
// SWC requires empty string to be returned instead of an empty object
|
|
160
165
|
// when the value is nil and the metatype is not a class instance, but a plain object (enum, for example).
|
|
161
166
|
// Otherwise, the error will be thrown.
|
|
162
|
-
// @see https://github.com/nestjs/nest/issues/12680
|
|
167
|
+
// @see [https://github.com/nestjs/nest/issues/12680](https://github.com/nestjs/nest/issues/12680)
|
|
163
168
|
return '';
|
|
164
169
|
}
|
|
165
170
|
stripProtoKeys(value) {
|
|
@@ -168,15 +173,24 @@ let ValidationPipe = class ValidationPipe {
|
|
|
168
173
|
util_1.types.isTypedArray(value)) {
|
|
169
174
|
return;
|
|
170
175
|
}
|
|
176
|
+
// Skip built-in JavaScript primitives to avoid Jest useFakeTimers conflicts
|
|
177
|
+
if (BUILT_IN_TYPES.some(type => value instanceof type)) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
171
180
|
if (Array.isArray(value)) {
|
|
172
181
|
for (const v of value) {
|
|
173
182
|
this.stripProtoKeys(v);
|
|
174
183
|
}
|
|
175
184
|
return;
|
|
176
185
|
}
|
|
186
|
+
// Delete dangerous prototype pollution keys
|
|
177
187
|
delete value.__proto__;
|
|
178
|
-
delete value.constructor;
|
|
179
188
|
delete value.prototype;
|
|
189
|
+
// Only delete constructor if it's NOT a built-in type
|
|
190
|
+
const constructorType = value?.constructor;
|
|
191
|
+
if (constructorType && !BUILT_IN_TYPES.includes(constructorType)) {
|
|
192
|
+
delete value.constructor;
|
|
193
|
+
}
|
|
180
194
|
for (const key in value) {
|
|
181
195
|
this.stripProtoKeys(value[key]);
|
|
182
196
|
}
|
|
@@ -284,10 +284,10 @@ let ConsoleLogger = ConsoleLogger_1 = class ConsoleLogger {
|
|
|
284
284
|
colors: this.options.colors,
|
|
285
285
|
breakLength,
|
|
286
286
|
};
|
|
287
|
-
if (this.options.maxArrayLength) {
|
|
287
|
+
if (typeof this.options.maxArrayLength !== 'undefined') {
|
|
288
288
|
inspectOptions.maxArrayLength = this.options.maxArrayLength;
|
|
289
289
|
}
|
|
290
|
-
if (this.options.maxStringLength) {
|
|
290
|
+
if (typeof this.options.maxStringLength !== 'undefined') {
|
|
291
291
|
inspectOptions.maxStringLength = this.options.maxStringLength;
|
|
292
292
|
}
|
|
293
293
|
return inspectOptions;
|