@naturalcycles/nodejs-lib 12.46.0 → 12.47.3
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/dist/stream/pipeline/pipeline.d.ts +1 -1
- package/dist/stream/pipeline/pipeline.js +6 -0
- package/dist/validation/joi/joi.shared.schemas.d.ts +1 -1
- package/dist/validation/joi/joi.shared.schemas.js +3 -6
- package/dist/validation/joi/joi.validation.util.js +1 -0
- package/dist/validation/joi/string.extensions.js +6 -4
- package/package.json +1 -1
- package/src/stream/pipeline/pipeline.ts +10 -1
- package/src/validation/joi/joi.shared.schemas.ts +3 -6
- package/src/validation/joi/joi.validation.util.ts +1 -0
- package/src/validation/joi/string.extensions.ts +5 -3
- package/CHANGELOG.md +0 -1810
|
@@ -7,3 +7,9 @@ const util_1 = require("util");
|
|
|
7
7
|
* Promisified stream.pipeline()
|
|
8
8
|
*/
|
|
9
9
|
exports._pipeline = (0, util_1.promisify)(stream_1.pipeline);
|
|
10
|
+
// Workaround https://github.com/nodejs/node/issues/40191
|
|
11
|
+
// todo: remove it when fix is released in 16.x and in AppEngine 16.x
|
|
12
|
+
if (process.version > 'v16.13') {
|
|
13
|
+
const { pipeline } = require('stream/promises');
|
|
14
|
+
exports._pipeline = ((streams) => pipeline(...streams));
|
|
15
|
+
}
|
|
@@ -17,7 +17,7 @@ export declare function oneOfSchema<T = any>(...schemas: AnySchemaTyped<any>[]):
|
|
|
17
17
|
export declare const anySchema: import("joi").AnySchema;
|
|
18
18
|
export declare const anyObjectSchema: import("joi").ObjectSchema<any>;
|
|
19
19
|
/**
|
|
20
|
-
* [a-
|
|
20
|
+
* [a-zA-Z0-9_]*
|
|
21
21
|
* 6-64 length
|
|
22
22
|
*/
|
|
23
23
|
export declare const idSchema: import("./string.extensions").ExtendedStringSchema;
|
|
@@ -28,13 +28,10 @@ exports.anySchema = joi_extensions_1.Joi.any();
|
|
|
28
28
|
exports.anyObjectSchema = joi_extensions_1.Joi.object().options({ stripUnknown: false });
|
|
29
29
|
// 1g498efj5sder3324zer
|
|
30
30
|
/**
|
|
31
|
-
* [a-
|
|
31
|
+
* [a-zA-Z0-9_]*
|
|
32
32
|
* 6-64 length
|
|
33
33
|
*/
|
|
34
|
-
exports.idSchema = exports.stringSchema
|
|
35
|
-
.regex(/^[a-z0-9_]*$/)
|
|
36
|
-
.min(6)
|
|
37
|
-
.max(64);
|
|
34
|
+
exports.idSchema = exports.stringSchema.regex(/^[a-zA-Z0-9_]{6,64}$/);
|
|
38
35
|
/**
|
|
39
36
|
* `_` should NOT be allowed to be able to use slug-ids as part of natural ids with `_` separator.
|
|
40
37
|
*/
|
|
@@ -42,7 +39,7 @@ exports.SLUG_PATTERN = /^[a-z0-9-]*$/;
|
|
|
42
39
|
/**
|
|
43
40
|
* "Slug" - a valid URL, filename, etc.
|
|
44
41
|
*/
|
|
45
|
-
exports.slugSchema = exports.stringSchema.regex(
|
|
42
|
+
exports.slugSchema = exports.stringSchema.regex(/^[a-z0-9-]{1,255}$/);
|
|
46
43
|
// 16725225600 is 2500-01-01
|
|
47
44
|
exports.unixTimestampSchema = exports.numberSchema.integer().min(0).max(16725225600);
|
|
48
45
|
// 2
|
|
@@ -130,6 +130,7 @@ function createError(value, err, objectName) {
|
|
|
130
130
|
// Make annotation non-enumerable, to not get it automatically printed,
|
|
131
131
|
// but still accessible
|
|
132
132
|
Object.defineProperty(data, 'annotation', {
|
|
133
|
+
configurable: true,
|
|
133
134
|
enumerable: false,
|
|
134
135
|
value: annotation,
|
|
135
136
|
});
|
|
@@ -87,13 +87,15 @@ function stringExtensions(joi) {
|
|
|
87
87
|
},
|
|
88
88
|
],
|
|
89
89
|
validate(v, helpers, args) {
|
|
90
|
-
console.log('!!! stripHTML', args, v)
|
|
91
|
-
const { strict = false } = args;
|
|
90
|
+
// console.log('!!! stripHTML', args, v)
|
|
92
91
|
const r = sanitize(v, {
|
|
93
|
-
allowedTags: [],
|
|
92
|
+
allowedTags: [],
|
|
94
93
|
// disallowedTagsMode: 'discard' // discard is default
|
|
94
|
+
parser: {
|
|
95
|
+
decodeEntities: false, // prevent decoding/changing of &<>"'
|
|
96
|
+
},
|
|
95
97
|
});
|
|
96
|
-
if (strict && r !== v) {
|
|
98
|
+
if (args.strict && r !== v) {
|
|
97
99
|
return helpers.error('string.stripHTML', args);
|
|
98
100
|
}
|
|
99
101
|
return r; // return converted value (or the same, if there was nothing to sanitize)
|
package/package.json
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import { pipeline } from 'stream'
|
|
2
2
|
import { promisify } from 'util'
|
|
3
3
|
|
|
4
|
+
type AnyStream = NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream
|
|
5
|
+
|
|
4
6
|
/**
|
|
5
7
|
* Promisified stream.pipeline()
|
|
6
8
|
*/
|
|
7
|
-
export
|
|
9
|
+
export let _pipeline = promisify(pipeline)
|
|
10
|
+
|
|
11
|
+
// Workaround https://github.com/nodejs/node/issues/40191
|
|
12
|
+
// todo: remove it when fix is released in 16.x and in AppEngine 16.x
|
|
13
|
+
if (process.version > 'v16.13') {
|
|
14
|
+
const { pipeline } = require('stream/promises')
|
|
15
|
+
_pipeline = ((streams: AnyStream[]) => pipeline(...streams)) as any
|
|
16
|
+
}
|
|
@@ -42,13 +42,10 @@ export const anyObjectSchema = Joi.object().options({ stripUnknown: false })
|
|
|
42
42
|
|
|
43
43
|
// 1g498efj5sder3324zer
|
|
44
44
|
/**
|
|
45
|
-
* [a-
|
|
45
|
+
* [a-zA-Z0-9_]*
|
|
46
46
|
* 6-64 length
|
|
47
47
|
*/
|
|
48
|
-
export const idSchema = stringSchema
|
|
49
|
-
.regex(/^[a-z0-9_]*$/)
|
|
50
|
-
.min(6)
|
|
51
|
-
.max(64)
|
|
48
|
+
export const idSchema = stringSchema.regex(/^[a-zA-Z0-9_]{6,64}$/)
|
|
52
49
|
|
|
53
50
|
/**
|
|
54
51
|
* `_` should NOT be allowed to be able to use slug-ids as part of natural ids with `_` separator.
|
|
@@ -58,7 +55,7 @@ export const SLUG_PATTERN = /^[a-z0-9-]*$/
|
|
|
58
55
|
/**
|
|
59
56
|
* "Slug" - a valid URL, filename, etc.
|
|
60
57
|
*/
|
|
61
|
-
export const slugSchema = stringSchema.regex(
|
|
58
|
+
export const slugSchema = stringSchema.regex(/^[a-z0-9-]{1,255}$/)
|
|
62
59
|
|
|
63
60
|
// 16725225600 is 2500-01-01
|
|
64
61
|
export const unixTimestampSchema = numberSchema.integer().min(0).max(16725225600)
|
|
@@ -172,6 +172,7 @@ function createError(value: any, err: ValidationError, objectName?: string): Joi
|
|
|
172
172
|
// Make annotation non-enumerable, to not get it automatically printed,
|
|
173
173
|
// but still accessible
|
|
174
174
|
Object.defineProperty(data, 'annotation', {
|
|
175
|
+
configurable: true,
|
|
175
176
|
enumerable: false,
|
|
176
177
|
value: annotation,
|
|
177
178
|
})
|
|
@@ -109,15 +109,17 @@ export function stringExtensions(joi: typeof Joi): Extension {
|
|
|
109
109
|
},
|
|
110
110
|
],
|
|
111
111
|
validate(v: string, helpers, args: JoiStripHTMLOptions) {
|
|
112
|
-
console.log('!!! stripHTML', args, v)
|
|
113
|
-
const { strict = false } = args
|
|
112
|
+
// console.log('!!! stripHTML', args, v)
|
|
114
113
|
|
|
115
114
|
const r = sanitize(v, {
|
|
116
115
|
allowedTags: [], // no html tags allowed at all
|
|
117
116
|
// disallowedTagsMode: 'discard' // discard is default
|
|
117
|
+
parser: {
|
|
118
|
+
decodeEntities: false, // prevent decoding/changing of &<>"'
|
|
119
|
+
},
|
|
118
120
|
})
|
|
119
121
|
|
|
120
|
-
if (strict && r !== v) {
|
|
122
|
+
if (args.strict && r !== v) {
|
|
121
123
|
return helpers.error('string.stripHTML', args)
|
|
122
124
|
}
|
|
123
125
|
|