@open-norantec/utilities 1.0.0-alpha.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.
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT LICENSE
2
+
3
+ Copyright (c) 2014-present Norantec Inc. <no-reply@norantec.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,5 @@
1
+ export declare class ArrayUtil {
2
+ static checkUnique<T>(data: Array<T>, validator: (item: T) => Array<string | number | boolean | null | undefined>): boolean;
3
+ static getPositiveIndexValue(length: number, index: number): number;
4
+ static traverse<R, T>(array: Array<T | Array<T>>, transformer?: (item: T) => R): Array<R | Array<R>>;
5
+ }
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ArrayUtil = void 0;
4
+ class ArrayUtil {
5
+ static checkUnique(data, validator) {
6
+ if (!data || !Array.isArray(data)) {
7
+ return;
8
+ }
9
+ const values = [];
10
+ for (const item of data) {
11
+ const currentValue = validator(item);
12
+ if (!Array.isArray(currentValue)) {
13
+ continue;
14
+ }
15
+ const exist = values.some((checkValue) => {
16
+ for (const [index, value] of checkValue.entries()) {
17
+ if (currentValue[index] !== value) {
18
+ return false;
19
+ }
20
+ }
21
+ return true;
22
+ });
23
+ if (exist) {
24
+ return false;
25
+ }
26
+ values.push(currentValue);
27
+ }
28
+ return true;
29
+ }
30
+ static getPositiveIndexValue(length, index) {
31
+ if (!length || !index) {
32
+ return index;
33
+ }
34
+ let result = index;
35
+ while (result < 0) {
36
+ result = length + result;
37
+ }
38
+ return result;
39
+ }
40
+ static traverse(array, transformer) {
41
+ if (!Array.isArray(array)) {
42
+ return [];
43
+ }
44
+ const result = [];
45
+ for (const item of array) {
46
+ if (Array.isArray(item)) {
47
+ result.push(ArrayUtil.traverse(item, transformer));
48
+ }
49
+ else {
50
+ result.push(typeof transformer === 'function' ? transformer(item) : item);
51
+ }
52
+ }
53
+ return result;
54
+ }
55
+ }
56
+ exports.ArrayUtil = ArrayUtil;
@@ -0,0 +1,5 @@
1
+ export declare class HeaderUtil {
2
+ static parse(headers: Record<string, any>): {
3
+ getValue: (name: string) => any;
4
+ };
5
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HeaderUtil = void 0;
4
+ const string_util_class_1 = require("./string-util.class");
5
+ class HeaderUtil {
6
+ static parse(headers) {
7
+ const getValue = (name) => {
8
+ var _a;
9
+ if (!headers || string_util_class_1.StringUtil.isFalsyString(name)) {
10
+ return null;
11
+ }
12
+ return (_a = Object.entries(headers).find(([key]) => {
13
+ if (string_util_class_1.StringUtil.isFalsyString(key) || key.toUpperCase() !== name.toUpperCase()) {
14
+ return false;
15
+ }
16
+ return true;
17
+ })) === null || _a === void 0 ? void 0 : _a[1];
18
+ };
19
+ return {
20
+ getValue,
21
+ };
22
+ }
23
+ }
24
+ exports.HeaderUtil = HeaderUtil;
@@ -0,0 +1,6 @@
1
+ export * from './array-util.class';
2
+ export * from './header-util.class';
3
+ export * from './json-util.class';
4
+ export * from './string-util.class';
5
+ export * from './user-agent-util.class';
6
+ export * from './vm-util.class';
package/dist/index.js ADDED
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./array-util.class"), exports);
18
+ __exportStar(require("./header-util.class"), exports);
19
+ __exportStar(require("./json-util.class"), exports);
20
+ __exportStar(require("./string-util.class"), exports);
21
+ __exportStar(require("./user-agent-util.class"), exports);
22
+ __exportStar(require("./vm-util.class"), exports);
@@ -0,0 +1,3 @@
1
+ export declare class JSONUtil {
2
+ static parse(literal: string, onError?: (error: Error) => any): any;
3
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JSONUtil = void 0;
4
+ class JSONUtil {
5
+ static parse(literal, onError) {
6
+ var _a;
7
+ try {
8
+ return JSON.parse(literal);
9
+ }
10
+ catch (e) {
11
+ return (_a = onError === null || onError === void 0 ? void 0 : onError(e)) !== null && _a !== void 0 ? _a : null;
12
+ }
13
+ }
14
+ }
15
+ exports.JSONUtil = JSONUtil;
@@ -0,0 +1,6 @@
1
+ export declare class StringUtil {
2
+ static isFalsyString(value: any, connector?: 'AND' | 'OR'): boolean;
3
+ static generateRandomText(length?: number, extraCharacters?: string): string;
4
+ static generateTempId(): string;
5
+ static extractTempId(idOrTempId: string): string;
6
+ }
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StringUtil = void 0;
4
+ const uuid_1 = require("uuid");
5
+ class StringUtil {
6
+ static isFalsyString(value, connector = 'AND') {
7
+ const stringList = Array.isArray(value) ? value : [value];
8
+ const checkResultList = stringList.map((stringValue) => typeof stringValue === 'string' && stringValue.length > 0);
9
+ if (connector === 'AND') {
10
+ return checkResultList.some((result) => !result);
11
+ }
12
+ if (connector === 'OR') {
13
+ return checkResultList.every((result) => !result);
14
+ }
15
+ return true;
16
+ }
17
+ static generateRandomText(length = 32, extraCharacters = '') {
18
+ const seed = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'.concat(extraCharacters);
19
+ let result = '';
20
+ while (result.length < length) {
21
+ result += seed.charAt(Math.floor(Math.random() * seed.length));
22
+ }
23
+ return result;
24
+ }
25
+ static generateTempId() {
26
+ const tempIds = [];
27
+ while (true) {
28
+ const currentTempId = (0, uuid_1.v4)();
29
+ if (tempIds.indexOf(currentTempId) === -1) {
30
+ tempIds.push(currentTempId);
31
+ return `temp$:${currentTempId}`;
32
+ }
33
+ }
34
+ }
35
+ static extractTempId(idOrTempId) {
36
+ var _a;
37
+ if (!idOrTempId) {
38
+ return null;
39
+ }
40
+ const regex = /^temp\$:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
41
+ if (!regex.test(idOrTempId)) {
42
+ return;
43
+ }
44
+ return ((_a = /^temp\$:(.*)$/g.exec(idOrTempId)) === null || _a === void 0 ? void 0 : _a[1]) || null;
45
+ }
46
+ }
47
+ exports.StringUtil = StringUtil;
@@ -0,0 +1 @@
1
+ {"program":{"fileNames":["../node_modules/typescript/lib/lib.es5.d.ts","../node_modules/typescript/lib/lib.es2015.d.ts","../node_modules/typescript/lib/lib.es2016.d.ts","../node_modules/typescript/lib/lib.es2017.d.ts","../node_modules/typescript/lib/lib.es2018.d.ts","../node_modules/typescript/lib/lib.es2019.d.ts","../node_modules/typescript/lib/lib.es2020.d.ts","../node_modules/typescript/lib/lib.dom.d.ts","../node_modules/typescript/lib/lib.dom.iterable.d.ts","../node_modules/typescript/lib/lib.webworker.importscripts.d.ts","../node_modules/typescript/lib/lib.scripthost.d.ts","../node_modules/typescript/lib/lib.es2015.core.d.ts","../node_modules/typescript/lib/lib.es2015.collection.d.ts","../node_modules/typescript/lib/lib.es2015.generator.d.ts","../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../node_modules/typescript/lib/lib.es2015.promise.d.ts","../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../node_modules/typescript/lib/lib.es2017.object.d.ts","../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../node_modules/typescript/lib/lib.es2017.string.d.ts","../node_modules/typescript/lib/lib.es2017.intl.d.ts","../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../node_modules/typescript/lib/lib.es2018.intl.d.ts","../node_modules/typescript/lib/lib.es2018.promise.d.ts","../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../node_modules/typescript/lib/lib.es2019.array.d.ts","../node_modules/typescript/lib/lib.es2019.object.d.ts","../node_modules/typescript/lib/lib.es2019.string.d.ts","../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../node_modules/typescript/lib/lib.es2019.intl.d.ts","../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../node_modules/typescript/lib/lib.es2020.date.d.ts","../node_modules/typescript/lib/lib.es2020.promise.d.ts","../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../node_modules/typescript/lib/lib.es2020.string.d.ts","../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../node_modules/typescript/lib/lib.es2020.intl.d.ts","../node_modules/typescript/lib/lib.es2020.number.d.ts","../node_modules/typescript/lib/lib.esnext.intl.d.ts","../node_modules/typescript/lib/lib.decorators.d.ts","../node_modules/typescript/lib/lib.decorators.legacy.d.ts","../node_modules/typescript/lib/lib.es2017.full.d.ts","../src/array-util.class.ts","../node_modules/uuid/dist/cjs/types.d.ts","../node_modules/uuid/dist/cjs/max.d.ts","../node_modules/uuid/dist/cjs/nil.d.ts","../node_modules/uuid/dist/cjs/parse.d.ts","../node_modules/uuid/dist/cjs/stringify.d.ts","../node_modules/uuid/dist/cjs/v1.d.ts","../node_modules/uuid/dist/cjs/v1ToV6.d.ts","../node_modules/uuid/dist/cjs/v35.d.ts","../node_modules/uuid/dist/cjs/v3.d.ts","../node_modules/uuid/dist/cjs/v4.d.ts","../node_modules/uuid/dist/cjs/v5.d.ts","../node_modules/uuid/dist/cjs/v6.d.ts","../node_modules/uuid/dist/cjs/v6ToV1.d.ts","../node_modules/uuid/dist/cjs/v7.d.ts","../node_modules/uuid/dist/cjs/validate.d.ts","../node_modules/uuid/dist/cjs/version.d.ts","../node_modules/uuid/dist/cjs/index.d.ts","../src/string-util.class.ts","../src/header-util.class.ts","../src/json-util.class.ts","../src/user-agent-util.class.ts","../src/vm-util.class.ts","../src/index.ts","../node_modules/@types/node/assert.d.ts","../node_modules/@types/node/assert/strict.d.ts","../node_modules/@types/node/globals.d.ts","../node_modules/@types/node/async_hooks.d.ts","../node_modules/@types/node/buffer.d.ts","../node_modules/@types/node/child_process.d.ts","../node_modules/@types/node/cluster.d.ts","../node_modules/@types/node/console.d.ts","../node_modules/@types/node/constants.d.ts","../node_modules/@types/node/crypto.d.ts","../node_modules/@types/node/dgram.d.ts","../node_modules/@types/node/diagnostics_channel.d.ts","../node_modules/@types/node/dns.d.ts","../node_modules/@types/node/dns/promises.d.ts","../node_modules/@types/node/domain.d.ts","../node_modules/@types/node/dom-events.d.ts","../node_modules/@types/node/events.d.ts","../node_modules/@types/node/fs.d.ts","../node_modules/@types/node/fs/promises.d.ts","../node_modules/@types/node/http.d.ts","../node_modules/@types/node/http2.d.ts","../node_modules/@types/node/https.d.ts","../node_modules/@types/node/inspector.d.ts","../node_modules/@types/node/module.d.ts","../node_modules/@types/node/net.d.ts","../node_modules/@types/node/os.d.ts","../node_modules/@types/node/path.d.ts","../node_modules/@types/node/perf_hooks.d.ts","../node_modules/@types/node/process.d.ts","../node_modules/@types/node/punycode.d.ts","../node_modules/@types/node/querystring.d.ts","../node_modules/@types/node/readline.d.ts","../node_modules/@types/node/readline/promises.d.ts","../node_modules/@types/node/repl.d.ts","../node_modules/@types/node/stream.d.ts","../node_modules/@types/node/stream/promises.d.ts","../node_modules/@types/node/stream/consumers.d.ts","../node_modules/@types/node/stream/web.d.ts","../node_modules/@types/node/string_decoder.d.ts","../node_modules/@types/node/test.d.ts","../node_modules/@types/node/timers.d.ts","../node_modules/@types/node/timers/promises.d.ts","../node_modules/@types/node/tls.d.ts","../node_modules/@types/node/trace_events.d.ts","../node_modules/@types/node/tty.d.ts","../node_modules/@types/node/url.d.ts","../node_modules/@types/node/util.d.ts","../node_modules/@types/node/v8.d.ts","../node_modules/@types/node/vm.d.ts","../node_modules/@types/node/wasi.d.ts","../node_modules/@types/node/worker_threads.d.ts","../node_modules/@types/node/zlib.d.ts","../node_modules/@types/node/globals.global.d.ts","../node_modules/@types/node/index.d.ts"],"fileInfos":[{"version":"f59215c5f1d886b05395ee7aca73e0ac69ddfad2843aa88530e797879d511bad","affectsGlobalScope":true},"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","dc48272d7c333ccf58034c0026162576b7d50ea0e69c3b9292f803fc20720fd5","27147504487dc1159369da4f4da8a26406364624fa9bc3db632f7d94a5bae2c3","5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4",{"version":"3dda5344576193a4ae48b8d03f105c86f20b2f2aff0a1d1fd7935f5d68649654","affectsGlobalScope":true},{"version":"35299ae4a62086698444a5aaee27fc7aa377c68cbb90b441c9ace246ffd05c97","affectsGlobalScope":true},{"version":"c5c5565225fce2ede835725a92a28ece149f83542aa4866cfb10290bff7b8996","affectsGlobalScope":true},{"version":"7d2dbc2a0250400af0809b0ad5f84686e84c73526de931f84560e483eb16b03c","affectsGlobalScope":true},{"version":"9d9885c728913c1d16e0d2831b40341d6ad9a0ceecaabc55209b306ad9c736a5","affectsGlobalScope":true},{"version":"17bea081b9c0541f39dd1ae9bc8c78bdd561879a682e60e2f25f688c0ecab248","affectsGlobalScope":true},{"version":"4443e68b35f3332f753eacc66a04ac1d2053b8b035a0e0ac1d455392b5e243b3","affectsGlobalScope":true},{"version":"ab22100fdd0d24cfc2cc59d0a00fc8cf449830d9c4030dc54390a46bd562e929","affectsGlobalScope":true},{"version":"f7bd636ae3a4623c503359ada74510c4005df5b36de7f23e1db8a5c543fd176b","affectsGlobalScope":true},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true},{"version":"0c20f4d2358eb679e4ae8a4432bdd96c857a2960fd6800b21ec4008ec59d60ea","affectsGlobalScope":true},{"version":"36ae84ccc0633f7c0787bc6108386c8b773e95d3b052d9464a99cd9b8795fbec","affectsGlobalScope":true},{"version":"82d0d8e269b9eeac02c3bd1c9e884e85d483fcb2cd168bccd6bc54df663da031","affectsGlobalScope":true},{"version":"b8deab98702588840be73d67f02412a2d45a417a3c097b2e96f7f3a42ac483d1","affectsGlobalScope":true},{"version":"4738f2420687fd85629c9efb470793bb753709c2379e5f85bc1815d875ceadcd","affectsGlobalScope":true},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true},{"version":"376d554d042fb409cb55b5cbaf0b2b4b7e669619493c5d18d5fa8bd67273f82a","affectsGlobalScope":true},{"version":"9fc46429fbe091ac5ad2608c657201eb68b6f1b8341bd6d670047d32ed0a88fa","affectsGlobalScope":true},{"version":"61c37c1de663cf4171e1192466e52c7a382afa58da01b1dc75058f032ddf0839","affectsGlobalScope":true},{"version":"c4138a3dd7cd6cf1f363ca0f905554e8d81b45844feea17786cdf1626cb8ea06","affectsGlobalScope":true},{"version":"6ff3e2452b055d8f0ec026511c6582b55d935675af67cdb67dd1dc671e8065df","affectsGlobalScope":true},{"version":"03de17b810f426a2f47396b0b99b53a82c1b60e9cba7a7edda47f9bb077882f4","affectsGlobalScope":true},{"version":"8184c6ddf48f0c98429326b428478ecc6143c27f79b79e85740f17e6feb090f1","affectsGlobalScope":true},{"version":"261c4d2cf86ac5a89ad3fb3fafed74cbb6f2f7c1d139b0540933df567d64a6ca","affectsGlobalScope":true},{"version":"6af1425e9973f4924fca986636ac19a0cf9909a7e0d9d3009c349e6244e957b6","affectsGlobalScope":true},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true},{"version":"15a630d6817718a2ddd7088c4f83e4673fde19fa992d2eae2cf51132a302a5d3","affectsGlobalScope":true},{"version":"f06948deb2a51aae25184561c9640fb66afeddb34531a9212d011792b1d19e0a","affectsGlobalScope":true},{"version":"01e0ee7e1f661acedb08b51f8a9b7d7f959e9cdb6441360f06522cc3aea1bf2e","affectsGlobalScope":true},{"version":"ac17a97f816d53d9dd79b0d235e1c0ed54a8cc6a0677e9a3d61efb480b2a3e4e","affectsGlobalScope":true},{"version":"bf14a426dbbf1022d11bd08d6b8e709a2e9d246f0c6c1032f3b2edb9a902adbe","affectsGlobalScope":true},{"version":"ec0104fee478075cb5171e5f4e3f23add8e02d845ae0165bfa3f1099241fa2aa","affectsGlobalScope":true},{"version":"2b72d528b2e2fe3c57889ca7baef5e13a56c957b946906d03767c642f386bbc3","affectsGlobalScope":true},{"version":"9cc66b0513ad41cb5f5372cca86ef83a0d37d1c1017580b7dace3ea5661836df","affectsGlobalScope":true},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true},{"version":"307c8b7ebbd7f23a92b73a4c6c0a697beca05b06b036c23a34553e5fe65e4fdc","affectsGlobalScope":true},{"version":"189c0703923150aa30673fa3de411346d727cc44a11c75d05d7cf9ef095daa22","affectsGlobalScope":true},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true},"994c234848afc14a2586b6565777f4c0b05dc479ede0a041bfd5becf6dceb586",{"version":"2e05c9d89fb72dbac3ddc8906135b27b00f27ab19a6398023416131032e1ffa7","signature":"d35f55376249d4c6135fd299b13e8fa27a21c19b80cee2c150d690f0e4b90457"},"cff399d99c68e4fafdd5835d443a980622267a39ac6f3f59b9e3d60d60c4f133","6ada175c0c585e89569e8feb8ff6fc9fc443d7f9ca6340b456e0f94cbef559bf","e56e4d95fad615c97eb0ae39c329a4cda9c0af178273a9173676cc9b14b58520","73e8dfd5e7d2abc18bdb5c5873e64dbdd1082408dd1921cad6ff7130d8339334","fc820b2f0c21501f51f79b58a21d3fa7ae5659fc1812784dbfbb72af147659ee","4f041ef66167b5f9c73101e5fd8468774b09429932067926f9b2960cc3e4f99d","31501b8fc4279e78f6a05ca35e365e73c0b0c57d06dbe8faecb10c7254ce7714","7bc76e7d4bbe3764abaf054aed3a622c5cdbac694e474050d71ce9d4ab93ea4b","ff4e9db3eb1e95d7ba4b5765e4dc7f512b90fb3b588adfd5ca9b0d9d7a56a1ae","f205fd03cd15ea054f7006b7ef8378ef29c315149da0726f4928d291e7dce7b9","d683908557d53abeb1b94747e764b3bd6b6226273514b96a942340e9ce4b7be7","7c6d5704e2f236fddaf8dbe9131d998a4f5132609ef795b78c3b63f46317f88a","d05bd4d28c12545827349b0ac3a79c50658d68147dad38d13e97e22353544496","b6436d90a5487d9b3c3916b939f68e43f7eaca4b0bb305d897d5124180a122b9","04ace6bedd6f59c30ea6df1f0f8d432c728c8bc5c5fd0c5c1c80242d3ab51977","57a8a7772769c35ba7b4b1ba125f0812deec5c7102a0d04d9e15b1d22880c9e8","badcc9d59770b91987e962f8e3ddfa1e06671b0e4c5e2738bbd002255cad3f38",{"version":"965e1010090ad4d45d96bc8f082a49a0cd53f5b8c2007a350a6be2eac731c17a","signature":"d813e8c87be51caa7afddd94642ae4edbced2b2e0b351c5e5116e270e33e869b"},{"version":"96b80d810190927f5232bd9c1021c7f9f07ca34e9bd173c292794049d67da621","signature":"d10b0cee405f198c5125d813dbfe49a5a265c6ede03f38ee3d1781a99dfdf2cb"},{"version":"2aa8f2e2306dcc4db2a8baa54be5960b22412113145413376660f287d6caaa8e","signature":"aad90a5a003c8756d6f2e56e15e5a6ead5f601ba1f0d50958f0960a91ab21613"},{"version":"51de8250c727f1446d2c49ecbae28a5c4b0bc09cbc26cbb488825ff854c52447","signature":"d6afe47645522dd88c7ae70694bc0317add95de9053baf10df9f5091f303d652"},{"version":"67281148e1c0a0c4c33b4507f5e9f6069305d5956637121f51ae7720d33115d1","signature":"0e5f78fea076d8eadb39e0bc00614888b0212c4292a816cfd949d87d9c303da8"},"145eff6cbe850af826c54de461c84d1467b7fa32d8d2316c5c94240345e73acc","7e771891adaa85b690266bc37bd6eb43bc57eecc4b54693ead36467e7369952a","a69c09dbea52352f479d3e7ac949fde3d17b195abe90b045d619f747b38d6d1a",{"version":"ca72190df0eb9b09d4b600821c8c7b6c9747b75a1c700c4d57dc0bb72abc074c","affectsGlobalScope":true},"21a167fec8f933752fb8157f06d28fab6817af3ad9b0bdb1908a10762391eab9",{"version":"bb65c6267c5d6676be61acbf6604cf0a4555ac4b505df58ac15c831fcbff4e3e","affectsGlobalScope":true},"374ca798f244e464346f14301dc2a8b4b111af1a83b49fffef5906c338a1f922","5a94487653355b56018122d92392beb2e5f4a6c63ba5cef83bbe1c99775ef713",{"version":"d5135ad93b33adcce80b18f8065087934cdc1730d63db58562edcf017e1aad9b","affectsGlobalScope":true},"82408ed3e959ddc60d3e9904481b5a8dc16469928257af22a3f7d1a3bc7fd8c4","dab86d9604fe40854ef3c0a6f9e8948873dc3509213418e5e457f410fd11200f","bb9c4ffa5e6290c6980b63c815cdd1625876dadb2efaf77edbe82984be93e55e","489532ff54b714f0e0939947a1c560e516d3ae93d51d639ab02e907a0e950114","f30bb836526d930a74593f7b0f5c1c46d10856415a8f69e5e2fc3db80371e362","14b5aa23c5d0ae1907bc696ac7b6915d88f7d85799cc0dc2dcf98fbce2c5a67c","5c439dafdc09abe4d6c260a96b822fa0ba5be7203c71a63ab1f1423cd9e838ea",{"version":"6b526a5ec4a401ca7c26cfe6a48e641d8f30af76673bad3b06a1b4504594a960","affectsGlobalScope":true},{"version":"816ad2e607a96de5bcac7d437f843f5afd8957f1fa5eefa6bba8e4ed7ca8fd84","affectsGlobalScope":true},"cec36af22f514322f870e81d30675c78df82ae8bf4863f5fd4e4424c040c678d","d903fafe96674bc0b2ac38a5be4a8fc07b14c2548d1cdb165a80ea24c44c0c54","5eec82ac21f84d83586c59a16b9b8502d34505d1393393556682fe7e7fde9ef2","04eb6578a588d6a46f50299b55f30e3a04ef27d0c5a46c57d8fcc211cd530faa","8d3c583a07e0c37e876908c2d5da575019f689df8d9fa4c081d99119d53dba22","2c828a5405191d006115ab34e191b8474bc6c86ffdc401d1a9864b1b6e088a58",{"version":"e8b18c6385ff784228a6f369694fcf1a6b475355ba89090a88de13587a9391d5","affectsGlobalScope":true},"d076fede3cb042e7b13fc29442aaa03a57806bc51e2b26a67a01fbc66a7c0c12","7c013aa892414a7fdcfd861ae524a668eaa3ede8c7c0acafaf611948122c8d93","b0973c3cbcdc59b37bf477731d468696ecaf442593ec51bab497a613a580fe30",{"version":"4989e92ba5b69b182d2caaea6295af52b7dc73a4f7a2e336a676722884e7139d","affectsGlobalScope":true},{"version":"b3624aed92dab6da8484280d3cb3e2f4130ec3f4ef3f8201c95144ae9e898bb6","affectsGlobalScope":true},"5153a2fd150e46ce57bb3f8db1318d33f6ad3261ed70ceeff92281c0608c74a3","210d54cd652ec0fec8c8916e4af59bb341065576ecda039842f9ffb2e908507c","36b03690b628eab08703d63f04eaa89c5df202e5f1edf3989f13ad389cd2c091","0effadd232a20498b11308058e334d3339cc5bf8c4c858393e38d9d4c0013dcf","25846d43937c672bab7e8195f3d881f93495df712ee901860effc109918938cc","fd93cee2621ff42dabe57b7be402783fd1aa69ece755bcba1e0290547ae60513","1b952304137851e45bc009785de89ada562d9376177c97e37702e39e60c2f1ff","69ee23dd0d215b09907ad30d23f88b7790c93329d1faf31d7835552a10cf7cbf","44b8b584a338b190a59f4f6929d072431950c7bd92ec2694821c11bce180c8a5","23b89798789dffbd437c0c423f5d02d11f9736aea73d6abf16db4f812ff36eda","223c37f62ce09a3d99e77498acdee7b2705a4ae14552fbdb4093600cd9164f3f",{"version":"970a90f76d4d219ad60819d61f5994514087ba94c985647a3474a5a3d12714ed","affectsGlobalScope":true},"e10177274a35a9d07c825615340b2fcde2f610f53f3fb40269fd196b4288dda6","4c8525f256873c7ba3135338c647eaf0ca7115a1a2805ae2d0056629461186ce","3c13ef48634e7b5012fcf7e8fce7496352c2d779a7201389ca96a2a81ee4314d","5d0a25ec910fa36595f85a67ac992d7a53dd4064a1ba6aea1c9f14ab73a023f2",{"version":"f0900cd5d00fe1263ff41201fb8073dbeb984397e4af3b8002a5c207a30bdc33","affectsGlobalScope":true},{"version":"4c50342e1b65d3bee2ed4ab18f84842d5724ad11083bd666d8705dc7a6079d80","affectsGlobalScope":true},"06d7c42d256f0ce6afe1b2b6cfbc97ab391f29dadb00dd0ae8e8f23f5bc916c3","ec4bd1b200670fb567920db572d6701ed42a9641d09c4ff6869768c8f81b404c","e59a892d87e72733e2a9ca21611b9beb52977be2696c7ba4b216cbbb9a48f5aa",{"version":"da26af7362f53d122283bc69fed862b9a9fe27e01bc6a69d1d682e0e5a4df3e6","affectsGlobalScope":true},"8a300fa9b698845a1f9c41ecbe2c5966634582a8e2020d51abcace9b55aa959e",{"version":"ab9b9a36e5284fd8d3bf2f7d5fcbc60052f25f27e4d20954782099282c60d23e","affectsGlobalScope":true},"8dbe725f8d237e70310977afcfa011629804d101ebaa0266cafda6b61ad72236"],"root":[49,[67,72]],"options":{"allowSyntheticDefaultImports":true,"declaration":true,"emitDecoratorMetadata":true,"experimentalDecorators":true,"module":1,"noFallthroughCasesInSwitch":false,"noImplicitAny":false,"outDir":"./","removeComments":true,"skipLibCheck":true,"sourceMap":false,"strictBindCallApply":false,"strictNullChecks":false,"target":4},"fileIdsList":[[73,119],[76,119],[77,82,110,119],[78,89,90,97,107,118,119],[78,79,89,97,119],[80,119],[81,82,90,98,119],[82,107,115,119],[83,85,89,97,119],[84,119],[85,86,119],[89,119],[87,89,119],[89,90,91,107,118,119],[89,90,91,104,107,110,119],[119,123],[119],[85,92,97,107,118,119],[89,90,92,93,97,107,115,118,119],[92,94,107,115,118,119],[73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125],[89,95,119],[96,118,119],[85,89,97,107,119],[98,119],[99,119],[76,100,119],[101,117,119,123],[102,119],[103,119],[89,104,105,119],[104,106,119,121],[77,89,107,108,109,110,119],[77,107,109,119],[107,108,119],[110,119],[111,119],[89,113,114,119],[113,114,119],[82,97,107,115,119],[116,119],[97,117,119],[77,92,103,118,119],[82,119],[107,119,120],[119,121],[119,122],[77,82,89,91,100,107,118,119,121,123],[107,119,124],[50,51,52,53,54,55,56,58,59,60,61,62,63,64,65,119],[50,119],[50,57,119],[67,119],[49,67,68,69,70,71,119],[66,119]],"referencedMap":[[73,1],[74,1],[76,2],[77,3],[78,4],[79,5],[80,6],[81,7],[82,8],[83,9],[84,10],[85,11],[86,11],[88,12],[87,13],[89,12],[90,14],[91,15],[75,16],[125,17],[92,18],[93,19],[94,20],[126,21],[95,22],[96,23],[97,24],[98,25],[99,26],[100,27],[101,28],[102,29],[103,30],[104,31],[105,31],[106,32],[107,33],[109,34],[108,35],[110,36],[111,37],[112,17],[113,38],[114,39],[115,40],[116,41],[117,42],[118,43],[119,44],[120,45],[121,46],[122,47],[123,48],[124,49],[46,17],[47,17],[8,17],[9,17],[13,17],[12,17],[2,17],[14,17],[15,17],[16,17],[17,17],[18,17],[19,17],[20,17],[21,17],[3,17],[4,17],[48,17],[25,17],[22,17],[23,17],[24,17],[26,17],[27,17],[28,17],[5,17],[29,17],[30,17],[31,17],[32,17],[6,17],[36,17],[33,17],[34,17],[35,17],[37,17],[7,17],[38,17],[43,17],[44,17],[39,17],[40,17],[41,17],[42,17],[1,17],[45,17],[11,17],[10,17],[66,50],[51,17],[52,17],[53,17],[54,17],[50,17],[55,51],[56,17],[58,52],[57,51],[59,51],[60,52],[61,51],[62,17],[63,51],[64,17],[65,17],[49,17],[68,53],[72,54],[69,17],[67,55],[70,17],[71,46]],"exportedModulesMap":[[73,1],[74,1],[76,2],[77,3],[78,4],[79,5],[80,6],[81,7],[82,8],[83,9],[84,10],[85,11],[86,11],[88,12],[87,13],[89,12],[90,14],[91,15],[75,16],[125,17],[92,18],[93,19],[94,20],[126,21],[95,22],[96,23],[97,24],[98,25],[99,26],[100,27],[101,28],[102,29],[103,30],[104,31],[105,31],[106,32],[107,33],[109,34],[108,35],[110,36],[111,37],[112,17],[113,38],[114,39],[115,40],[116,41],[117,42],[118,43],[119,44],[120,45],[121,46],[122,47],[123,48],[124,49],[46,17],[47,17],[8,17],[9,17],[13,17],[12,17],[2,17],[14,17],[15,17],[16,17],[17,17],[18,17],[19,17],[20,17],[21,17],[3,17],[4,17],[48,17],[25,17],[22,17],[23,17],[24,17],[26,17],[27,17],[28,17],[5,17],[29,17],[30,17],[31,17],[32,17],[6,17],[36,17],[33,17],[34,17],[35,17],[37,17],[7,17],[38,17],[43,17],[44,17],[39,17],[40,17],[41,17],[42,17],[1,17],[45,17],[11,17],[10,17],[66,50],[51,17],[52,17],[53,17],[54,17],[50,17],[55,51],[56,17],[58,52],[57,51],[59,51],[60,52],[61,51],[62,17],[63,51],[64,17],[65,17],[72,54]],"semanticDiagnosticsPerFile":[73,74,76,77,78,79,80,81,82,83,84,85,86,88,87,89,90,91,75,125,92,93,94,126,95,96,97,98,99,100,101,102,103,104,105,106,107,109,108,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,46,47,8,9,13,12,2,14,15,16,17,18,19,20,21,3,4,48,25,22,23,24,26,27,28,5,29,30,31,32,6,36,33,34,35,37,7,38,43,44,39,40,41,42,1,45,11,10,66,51,52,53,54,50,55,56,58,57,59,60,61,62,63,64,65,49,68,72,69,67,70,71]},"version":"5.1.6"}
@@ -0,0 +1,3 @@
1
+ export declare class UserAgentUtil {
2
+ static generateRandomUa(): string;
3
+ }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UserAgentUtil = void 0;
4
+ class UserAgentUtil {
5
+ static generateRandomUa() {
6
+ const userAgents = [
7
+ 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.12) Gecko/20070731 Ubuntu/dapper-security Firefox/1.5.0.12',
8
+ 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Acoo Browser; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.0.04506)',
9
+ 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11',
10
+ 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.20 (KHTML, like Gecko) Chrome/19.0.1036.7 Safari/535.20',
11
+ 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.8) Gecko Fedora/1.9.0.8-1.fc10 Kazehakase/0.5.6',
12
+ 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.71 Safari/537.1 LBBROWSER',
13
+ 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET CLR 2.0.50727; Media Center PC 6.0) ,Lynx/2.8.5rel.1 libwww-FM/2.14 SSL-MM/1.4.1 GNUTLS/1.2.9',
14
+ 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)',
15
+ 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; QQBrowser/7.0.3698.400)',
16
+ 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; QQDownload 732; .NET4.0C; .NET4.0E)',
17
+ 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:2.0b13pre) Gecko/20110307 Firefox/4.0b13pre',
18
+ 'Opera/9.80 (Macintosh; Intel Mac OS X 10.6.8; U; fr) Presto/2.9.168 Version/11.52',
19
+ 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.12) Gecko/20070731 Ubuntu/dapper-security Firefox/1.5.0.12',
20
+ 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; LBBROWSER)',
21
+ 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.8) Gecko Fedora/1.9.0.8-1.fc10 Kazehakase/0.5.6',
22
+ 'Mozilla/5.0 (X11; U; Linux; en-US) AppleWebKit/527+ (KHTML, like Gecko, Safari/419.3) Arora/0.6',
23
+ 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; QQBrowser/7.0.3698.400)',
24
+ 'Opera/9.25 (Windows NT 5.1; U; en), Lynx/2.8.5rel.1 libwww-FM/2.14 SSL-MM/1.4.1 GNUTLS/1.2.9',
25
+ 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36',
26
+ ];
27
+ const userAgent = userAgents[Math.random() * userAgents.length];
28
+ return userAgent;
29
+ }
30
+ }
31
+ exports.UserAgentUtil = UserAgentUtil;
@@ -0,0 +1,3 @@
1
+ export declare class VMUtil {
2
+ static runScriptCode(code: string, overrideContext?: Record<string, any>): void;
3
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VMUtil = void 0;
4
+ const vm = require("node:vm");
5
+ class VMUtil {
6
+ static runScriptCode(code, overrideContext) {
7
+ new vm.Script(code).runInContext(vm.createContext(Object.assign(Object.assign(Object.assign({}, global), { __dirname,
8
+ __filename,
9
+ process,
10
+ module,
11
+ exports,
12
+ require }), overrideContext)));
13
+ }
14
+ }
15
+ exports.VMUtil = VMUtil;
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@open-norantec/utilities",
3
+ "version": "1.0.0-alpha.0",
4
+ "description": "NoranTec Utilities",
5
+ "main": "dist/index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1",
8
+ "build:cjs": "rimraf dist && tsc -b",
9
+ "build": "npm run build:cjs",
10
+ "setup:exec": "node bin/nttc.js setup",
11
+ "setup": "npm run build && node bin/nttc.js setup"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+ssh://git@github.com/norantec/utilities.git"
16
+ },
17
+ "author": "lenconda <i@lenconda.top>",
18
+ "bugs": {
19
+ "url": "https://github.com/norantec/utilities/issues"
20
+ },
21
+ "files": [
22
+ "bin",
23
+ "dist",
24
+ "LICENSE",
25
+ "README.md"
26
+ ],
27
+ "publishConfig": {
28
+ "access": "public",
29
+ "registry": "https://registry.npmjs.org"
30
+ },
31
+ "homepage": "https://github.com/norantec/utilities#readme",
32
+ "devDependencies": {
33
+ "@stylistic/eslint-plugin": "^2.12.1",
34
+ "@types/node": "18.11.18",
35
+ "@typescript-eslint/eslint-plugin": "^8.0.0",
36
+ "@typescript-eslint/parser": "^8.0.0",
37
+ "cross-env": "^7.0.3",
38
+ "eslint": "^8.0.0",
39
+ "eslint-config-prettier": "^9.0.0",
40
+ "eslint-plugin-prettier": "^5.0.0",
41
+ "prettier": "^3.0.0",
42
+ "rimraf": "^6.0.1",
43
+ "ts-node": "^10.0.0",
44
+ "type-fest": "^4.37.0",
45
+ "typescript": "~5.1.3"
46
+ },
47
+ "dependencies": {
48
+ "uuid": "^11.1.0"
49
+ }
50
+ }