melperjs 4.0.0 → 5.0.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/.babelrc CHANGED
@@ -3,10 +3,10 @@
3
3
  "development": {
4
4
  "presets": [
5
5
  [
6
- "babel-preset-env",
6
+ "@babel/preset-env",
7
7
  {
8
8
  "targets": {
9
- "node": "current"
9
+ "node": "18"
10
10
  }
11
11
  }
12
12
  ]
@@ -15,6 +15,21 @@
15
15
  ]
16
16
  },
17
17
  "module": {
18
+ "presets": [
19
+ [
20
+ "@babel/preset-env",
21
+ {
22
+ "targets": {
23
+ "node": "18"
24
+ },
25
+ "modules": false
26
+ }
27
+ ]
28
+ ],
29
+ "plugins": [
30
+ ]
31
+ },
32
+ "browser": {
18
33
  "presets": [
19
34
  [
20
35
  "@babel/preset-env",
@@ -27,6 +42,9 @@
27
42
  ]
28
43
  ],
29
44
  "plugins": [
45
+ ],
46
+ "ignore": [
47
+ "./src/node.js"
30
48
  ]
31
49
  }
32
50
  },
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # MELPERJS
2
2
 
3
- Node.js module to use predefined common functions and utilities
3
+ Javascript module to use predefined common functions and utilities
4
4
 
5
5
  ## Installation
6
6
 
@@ -21,7 +21,8 @@ const nodeHelper = require("melperjs/node");
21
21
  const axios = require("axios");
22
22
 
23
23
  (async () => {
24
- console.log(helper.Exception("something went wrong", {status: 500}, "axios error"));
24
+ console.log(helper.CONSTANTS);
25
+ console.log(helper.Exception("something went wrong", {status: 400}, "bad request error"));
25
26
  console.log(helper.time());
26
27
  await helper.sleepMs(1000);
27
28
  console.log(helper.time());
@@ -31,7 +32,13 @@ const axios = require("axios");
31
32
  await helper.promiseTimeout(1000, helper.sleepMs(2000));
32
33
  } catch (e) {
33
34
  console.error(e.message);
35
+ console.log("Timeout, Internal Error ?", helper.isIntlError(e));
34
36
  }
37
+ console.log(helper.splitLines(`
38
+ 2.satır
39
+
40
+ 4.satır
41
+ `))
35
42
  console.log(helper.findKeyNode("c", {
36
43
  a: {
37
44
  b: {
@@ -43,9 +50,11 @@ const axios = require("axios");
43
50
  }
44
51
  }
45
52
  }));
46
- console.log("str empty", helper.checkEmpty(""));
47
- console.log("1 empty", helper.checkEmpty(1));
48
- console.log("[] empty", helper.checkEmpty([]));
53
+ console.log("'' empty ?", helper.checkEmpty(''));
54
+ console.log("1 empty ?", helper.checkEmpty(1));
55
+ console.log("0 empty ?", helper.checkEmpty(1));
56
+ console.log("[] empty ?", helper.checkEmpty([]));
57
+ console.log(helper.pascalCase("pascal case"));
49
58
  console.log(helper.upperCaseFirst("first letter upper"));
50
59
  console.log(helper.lowerCaseFirst("First Letter Lower"));
51
60
  console.log(helper.titleString("THIS mUsT be Title"));
@@ -60,9 +69,9 @@ const axios = require("axios");
60
69
  console.log(nodeHelper.tokenUuid(true));
61
70
  console.log(nodeHelper.tokenWeighted({strongProbability: 1000, lowProbability: 1}));
62
71
  console.log(nodeHelper.md5("data"));
63
- const password = helper.hashBcrypt("plain");
72
+ const password = nodeHelper.hashBcrypt("plain");
64
73
  console.log(password)
65
- console.log("passwordHash", helper.verifyBcrypt("plain", password));
74
+ console.log("passwordHash verified ?", nodeHelper.verifyBcrypt("plain", password));
66
75
  const cookies = helper.cookieDict(await axios.get("https://google.com"));
67
76
  console.log(cookies);
68
77
  console.log(helper.cookieHeader(cookies));
@@ -71,49 +80,58 @@ const axios = require("axios");
71
80
  console.log(nodeHelper.proxyObject(proxy));
72
81
  console.log(await nodeHelper.proxify({mode: 4, proxy}));
73
82
  console.log(nodeHelper.serverIp());
74
- console.log("HTTP CODE: 401 FOREIGN", helper.foreignHttpError(401));
75
- console.log("HTTP CODE: 407 FOREIGN (Failed Proxy Auth)", helper.foreignHttpError(407));
83
+ console.log("HTTP CODE: 400 (Bad Request) ?", helper.isIntlHttpCode(401));
84
+ console.log("HTTP CODE: 407 (Failed Proxy Auth) ?", helper.isIntlHttpCode(407));
76
85
  nodeHelper.createNumDir("test");
77
- nodeHelper.createDir("test");
78
86
  console.log("VERSIONED BY .GIT", "v" + nodeHelper.getVersion());
79
87
  })();
80
88
 
81
89
  /*
82
90
  {
83
- name: 'AxiosError',
91
+ LOWER_CASE: 'abcdefghijklmnopqrstuvwxyz',
92
+ UPPER_CASE: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
93
+ HEXADECIMAL: '0123456789abcdef',
94
+ NUMBERS: '0123456789'
95
+ }
96
+ {
97
+ name: 'BadRequestError',
84
98
  message: 'something went wrong',
85
- response: { status: 500 }
99
+ response: { status: 400 }
86
100
  }
87
- 1700529489
88
- 1700529490
89
- 1700529491
101
+ 1701697141
102
+ 1701697142
103
+ 1701697143
90
104
  Promise timed out after 1000ms
105
+ Timeout, Internal Error ? true
106
+ [ '2.satır', '4.satır' ]
91
107
  { x: 1, y: 2, c: { d: true } }
92
- str empty true
93
- 1 empty false
94
- [] empty true
108
+ '' empty ? true
109
+ 1 empty ? false
110
+ 0 empty ? false
111
+ [] empty ? true
112
+ PascalCase
95
113
  First letter upper
96
114
  first Letter Lower
97
115
  This Must Be Title
98
116
  LONG...
99
117
  SAFE TEXT
100
- 15WY89Q4yAMCzPmNsU0ANGX2eiOz7Gfy
101
- 9eb93429
102
- 7e1fb299-251c-4a75-bb37-f7cc3a730121
118
+ sP3jTNwe1rRrW1TVAPb4HAXNFjJB2mWb
119
+ f70f7212
120
+ f07fe6b1-46d5-4f30-8138-f263f4916e65
103
121
  strongProbability
104
- STIhrofUYVAQ4anplyJW2T7GEwSJkuk7
105
- 6db791a1
106
- 0cbef42d-a277-4f66-8bcc-e4de337c2b56
122
+ JT4tXSI7YdIYDGbzLmHkItZ32vgi5aos
123
+ 52c0da20
124
+ 3e4374f4-11d9-4174-b337-dbf8d7fa2d41
107
125
  strongProbability
108
126
  8d777f385d3dfec8815d20f7496026dc
109
- $2b$10$IsuTscKKHbcf6sBp7BrCOOcg6A8v32G9UxzdYN3Y6xyMaUynweYX2
110
- passwordHash true
127
+ $2b$10$DTITmEyk1IcWfG1qaVEvyOgLReqOI97X/LufbbV/nvOU8DspBNMOS
128
+ passwordHash verified ? true
111
129
  {
112
- '1P_JAR': '2023-11-21-01',
113
- AEC: 'Ackid1TlDwA2YJw3rzP5t3x5vBdxZt-4AzkhdwLahUVpj3vhdVHvPlw0VWM',
114
- NID: '511=tD21gyuziCvCgZSQZd5h_xDFOF6df8AhkFy0iXq9MwHG9K8J3FEkT7L0CACgjJhGDVQFoZG_Pwi2Wo8Kf7NnmvcNGVmk-lDhY768PI9sVSUmSHIYwpfsuVvG4NwNwk3iPNKmbqaC_H-YVGZhEJVn2c6YYUVxE0oEDtfuyPhGOXw'
130
+ '1P_JAR': '2023-12-04-13',
131
+ AEC: 'Ackid1Q9P_jk5EM2S_PU_QT-RUEu0syeyPMuCOLYbtlkX5gvB1zRTPytuw',
132
+ NID: '511=jBXxJSukq7Ku4449skx8tmFlqkM-nKwhaQ4hukE0F-jntKrI8daHyoAS6npvlujAMKU966ZMNGE6wu8xYc2PciilTQrKxgRyJv1QsdNIc6y_mlrLfuOfLXkwDuf0YWdS0Or3Aq6wHR87o0paAAcYAntlopexVF7NpQ6yifGe57c'
115
133
  }
116
- 1P_JAR=2023-11-21-01;AEC=Ackid1TlDwA2YJw3rzP5t3x5vBdxZt-4AzkhdwLahUVpj3vhdVHvPlw0VWM;NID=511=tD21gyuziCvCgZSQZd5h_xDFOF6df8AhkFy0iXq9MwHG9K8J3FEkT7L0CACgjJhGDVQFoZG_Pwi2Wo8Kf7NnmvcNGVmk-lDhY768PI9sVSUmSHIYwpfsuVvG4NwNwk3iPNKmbqaC_H-YVGZhEJVn2c6YYUVxE0oEDtfuyPhGOXw
134
+ 1P_JAR=2023-12-04-13;AEC=Ackid1Q9P_jk5EM2S_PU_QT-RUEu0syeyPMuCOLYbtlkX5gvB1zRTPytuw;NID=511=jBXxJSukq7Ku4449skx8tmFlqkM-nKwhaQ4hukE0F-jntKrI8daHyoAS6npvlujAMKU966ZMNGE6wu8xYc2PciilTQrKxgRyJv1QsdNIc6y_mlrLfuOfLXkwDuf0YWdS0Or3Aq6wHR87o0paAAcYAntlopexVF7NpQ6yifGe57c
117
135
  http://id:pw-{SESSION}@127.0.0.1:8080
118
136
  {
119
137
  protocol: 'http',
@@ -121,10 +139,10 @@ http://id:pw-{SESSION}@127.0.0.1:8080
121
139
  port: 8080,
122
140
  auth: { username: 'id', password: 'pw-{SESSION}' }
123
141
  }
124
- http://id:pw-527ef984@127.0.0.1:8080
142
+ http://id:pw-749756be@127.0.0.1:8080
125
143
  127.0.0.1
126
- HTTP CODE: 401 FOREIGN false
127
- HTTP CODE: 407 FOREIGN (Failed Proxy Auth) true
144
+ HTTP CODE: 400 (Bad Request) ? false
145
+ HTTP CODE: 407 (Failed Proxy Auth) ? true
128
146
  VERSIONED BY .GIT v2310.15182
129
147
  */
130
148
  ```
package/cjs/index.js CHANGED
@@ -3,39 +3,34 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.CONSTANTS = undefined;
6
+ exports.CONSTANTS = void 0;
7
7
  exports.Exception = Exception;
8
- exports.time = time;
9
- exports.sleepMs = sleepMs;
10
- exports.sleep = sleep;
11
- exports.promiseTimeout = promiseTimeout;
12
- exports.splitLines = splitLines;
13
- exports.findKeyNode = findKeyNode;
14
8
  exports.checkEmpty = checkEmpty;
15
- exports.pascalCase = pascalCase;
16
- exports.upperCaseFirst = upperCaseFirst;
17
- exports.lowerCaseFirst = lowerCaseFirst;
18
- exports.titleString = titleString;
9
+ exports.cookieDict = cookieDict;
10
+ exports.cookieHeader = cookieHeader;
11
+ exports.findKeyNode = findKeyNode;
12
+ exports.isIntlError = isIntlError;
13
+ exports.isIntlHttpCode = isIntlHttpCode;
19
14
  exports.limitString = limitString;
20
- exports.safeString = safeString;
21
- exports.randomString = randomString;
15
+ exports.lowerCaseFirst = lowerCaseFirst;
16
+ exports.pascalCase = pascalCase;
17
+ exports.promiseTimeout = promiseTimeout;
22
18
  exports.randomHex = randomHex;
19
+ exports.randomString = randomString;
23
20
  exports.randomUuid = randomUuid;
24
21
  exports.randomWeighted = randomWeighted;
25
- exports.cookieDict = cookieDict;
26
- exports.cookieHeader = cookieHeader;
27
- exports.isIntlHttpCode = isIntlHttpCode;
28
- exports.isIntlError = isIntlError;
29
- var _xss = require("xss");
30
- var _xss2 = _interopRequireDefault(_xss);
31
- var _camelCase = require("lodash/camelCase.js");
32
- var _camelCase2 = _interopRequireDefault(_camelCase);
33
- var _capitalize = require("lodash/capitalize.js");
34
- var _capitalize2 = _interopRequireDefault(_capitalize);
35
- var _isEmpty = require("lodash/isEmpty.js");
36
- var _isEmpty2 = _interopRequireDefault(_isEmpty);
37
- var _setCookieParser = require("set-cookie-parser");
38
- var _setCookieParser2 = _interopRequireDefault(_setCookieParser);
22
+ exports.safeString = safeString;
23
+ exports.sleep = sleep;
24
+ exports.sleepMs = sleepMs;
25
+ exports.splitLines = splitLines;
26
+ exports.time = time;
27
+ exports.titleString = titleString;
28
+ exports.upperCaseFirst = upperCaseFirst;
29
+ var _xss = _interopRequireDefault(require("xss"));
30
+ var _camelCase = _interopRequireDefault(require("lodash/camelCase.js"));
31
+ var _capitalize = _interopRequireDefault(require("lodash/capitalize.js"));
32
+ var _isEmpty = _interopRequireDefault(require("lodash/isEmpty.js"));
33
+ var _setCookieParser = _interopRequireDefault(require("set-cookie-parser"));
39
34
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
40
35
  const CONSTANTS = exports.CONSTANTS = {
41
36
  LOWER_CASE: "abcdefghijklmnopqrstuvwxyz",
@@ -94,11 +89,11 @@ function checkEmpty(value) {
94
89
  if (typeof value === "number") {
95
90
  return value === 0;
96
91
  } else {
97
- return (0, _isEmpty2.default)(value);
92
+ return (0, _isEmpty.default)(value);
98
93
  }
99
94
  }
100
95
  function pascalCase(str) {
101
- return upperCaseFirst((0, _camelCase2.default)(str));
96
+ return upperCaseFirst((0, _camelCase.default)(str));
102
97
  }
103
98
  function upperCaseFirst(str) {
104
99
  str = str || "";
@@ -110,7 +105,7 @@ function lowerCaseFirst(str) {
110
105
  }
111
106
  function titleString(str) {
112
107
  str = str || "";
113
- return str.split(' ').map(word => (0, _capitalize2.default)(word)).join(' ');
108
+ return str.split(' ').map(word => (0, _capitalize.default)(word)).join(' ');
114
109
  }
115
110
  function limitString(str, limit = 35) {
116
111
  str = str || "";
@@ -122,7 +117,7 @@ function limitString(str, limit = 35) {
122
117
  }
123
118
  function safeString(str) {
124
119
  str = str || "";
125
- return (0, _xss2.default)(str, {
120
+ return (0, _xss.default)(str, {
126
121
  whiteList: {},
127
122
  stripIgnoreTag: true,
128
123
  stripIgnoreTagBody: ["script"]
@@ -171,7 +166,7 @@ function randomWeighted(dict, randomFunc = totalWeight => Math.random() * totalW
171
166
  }
172
167
  function cookieDict(res, decodeValues = false) {
173
168
  let dict = {};
174
- const cookies = _setCookieParser2.default.parse(res, {
169
+ const cookies = _setCookieParser.default.parse(res, {
175
170
  decodeValues: decodeValues
176
171
  });
177
172
  for (let cookie of cookies) {
package/cjs/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["Exception","exports","time","sleepMs","sleep","promiseTimeout","splitLines","findKeyNode","checkEmpty","pascalCase","upperCaseFirst","lowerCaseFirst","titleString","limitString","safeString","randomString","randomHex","randomUuid","randomWeighted","cookieDict","cookieHeader","isIntlHttpCode","isIntlError","_xss","require","_xss2","_interopRequireDefault","_camelCase","_camelCase2","_capitalize","_capitalize2","_isEmpty","_isEmpty2","_setCookieParser","_setCookieParser2","obj","__esModule","default","CONSTANTS","LOWER_CASE","UPPER_CASE","HEXADECIMAL","NUMBERS","message","response","name","status","Math","floor","Date","now","milliseconds","Promise","resolve","setTimeout","seconds","promise","reject","timer","Error","then","value","clearTimeout","catch","reason","text","split","filter","item","map","trim","key","node","pair","hasOwnProperty","index","result","isEmpty","str","camelCase","toUpperCase","slice","toLowerCase","word","capitalize","join","limit","length","substring","xss","whiteList","stripIgnoreTag","stripIgnoreTagBody","useNumbers","useUppercase","characters","i","randomIndex","random","useDashes","d","uuid","replace","c","r","toString","replaceAll","dict","randomFunc","totalWeight","elements","Object","keys","weights","values","reduce","sum","weight","randomNum","weightSum","res","decodeValues","cookies","setCookieParser","parse","cookie","entries","httpCode","undefined","e","includes"],"sources":["../src/index.js"],"sourcesContent":["import xss from \"xss\";\r\nimport camelCase from \"lodash/camelCase.js\";\r\nimport capitalize from \"lodash/capitalize.js\";\r\nimport isEmpty from \"lodash/isEmpty.js\";\r\nimport setCookieParser from \"set-cookie-parser\";\r\n\r\n\r\nexport const CONSTANTS = {\r\n LOWER_CASE: \"abcdefghijklmnopqrstuvwxyz\",\r\n UPPER_CASE: \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\",\r\n HEXADECIMAL: \"0123456789abcdef\",\r\n NUMBERS: \"0123456789\",\r\n};\r\n\r\nexport function Exception(message, response = {}, name = null) {\r\n response.status = response.status || 400;\r\n return {\r\n name: pascalCase(name),\r\n message,\r\n response,\r\n }\r\n}\r\n\r\nexport function time() {\r\n return Math.floor(Date.now() / 1000);\r\n}\r\n\r\nexport async function sleepMs(milliseconds) {\r\n return new Promise(resolve => setTimeout(resolve, milliseconds));\r\n}\r\n\r\nexport async function sleep(seconds) {\r\n return await sleepMs(seconds * 1000);\r\n}\r\n\r\nexport function promiseTimeout(milliseconds, promise) {\r\n return new Promise((resolve, reject) => {\r\n const timer = setTimeout(() => {\r\n reject(new Error('Promise timed out after ' + milliseconds + 'ms'));\r\n }, milliseconds);\r\n\r\n promise\r\n .then(value => {\r\n clearTimeout(timer);\r\n resolve(value);\r\n })\r\n .catch(reason => {\r\n clearTimeout(timer);\r\n reject(reason);\r\n });\r\n });\r\n}\r\n\r\nexport function splitLines(text) {\r\n return text.split(/\\r?\\n/).filter(item => !checkEmpty(item)).map(item => item.trim());\r\n}\r\n\r\nexport function findKeyNode(key, node, pair = null) {\r\n if (node && node.hasOwnProperty(key) && (pair ? node[key] === pair : true)) {\r\n return node;\r\n } else if (typeof node === 'object') {\r\n for (let index in node) {\r\n const result = findKeyNode(key, node[index], pair);\r\n if (result) {\r\n return result;\r\n }\r\n }\r\n }\r\n return null;\r\n}\r\n\r\nexport function checkEmpty(value) {\r\n if (typeof value === \"number\") {\r\n return value === 0;\r\n } else {\r\n return isEmpty(value);\r\n }\r\n}\r\n\r\nexport function pascalCase(str) {\r\n return upperCaseFirst(camelCase(str));\r\n}\r\n\r\nexport function upperCaseFirst(str) {\r\n str = str || \"\";\r\n return str[0].toUpperCase() + str.slice(1);\r\n}\r\n\r\nexport function lowerCaseFirst(str) {\r\n str = str || \"\";\r\n return str[0].toLowerCase() + str.slice(1);\r\n}\r\n\r\nexport function titleString(str) {\r\n str = str || \"\";\r\n return str\r\n .split(' ')\r\n .map(word => capitalize(word))\r\n .join(' ');\r\n}\r\n\r\nexport function limitString(str, limit = 35) {\r\n str = str || \"\";\r\n if (str.length <= limit) {\r\n return str;\r\n } else {\r\n return str.substring(0, limit - 3) + \"...\";\r\n }\r\n}\r\n\r\nexport function safeString(str) {\r\n str = str || \"\";\r\n return xss(str, {\r\n whiteList: {},\r\n stripIgnoreTag: true,\r\n stripIgnoreTagBody: [\"script\"]\r\n });\r\n}\r\n\r\nexport function randomString(length, useNumbers = true, useUppercase = false) {\r\n \r\n let characters = CONSTANTS.LOWER_CASE;\r\n if (useUppercase) characters += CONSTANTS.UPPER_CASE;\r\n if (useNumbers) characters += CONSTANTS.NUMBERS;\r\n\r\n let randomString = '';\r\n for (let i = 0; i < length; i++) {\r\n const randomIndex = Math.floor(Math.random() * characters.length);\r\n randomString += characters[randomIndex];\r\n }\r\n\r\n return randomString;\r\n}\r\n\r\nexport function randomHex(length) {\r\n let result = '';\r\n for (let i = 0; i < length; i++) {\r\n const randomIndex = Math.floor(Math.random() * CONSTANTS.HEXADECIMAL.length);\r\n result += CONSTANTS.HEXADECIMAL[randomIndex];\r\n }\r\n\r\n return result;\r\n}\r\n\r\nexport function randomUuid(useDashes = true) {\r\n let d = Date.now();\r\n const uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {\r\n const r = (d + Math.random() * 16) % 16 | 0;\r\n d = Math.floor(d / 16);\r\n return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);\r\n });\r\n return useDashes ? uuid : uuid.replaceAll(\"-\", \"\");\r\n}\r\n\r\nexport function randomWeighted(dict, randomFunc = (totalWeight) => Math.random() * totalWeight) {\r\n let elements = Object.keys(dict);\r\n let weights = Object.values(dict);\r\n\r\n let totalWeight = weights.reduce((sum, weight) => sum + weight, 0);\r\n\r\n let randomNum = randomFunc(totalWeight);\r\n let weightSum = 0;\r\n\r\n for (let i = 0; i < elements.length; i++) {\r\n weightSum += weights[i];\r\n if (randomNum <= weightSum) {\r\n return elements[i];\r\n }\r\n }\r\n}\r\n\r\nexport function cookieDict(res, decodeValues = false) {\r\n let dict = {};\r\n const cookies = setCookieParser.parse(res, {decodeValues: decodeValues});\r\n for (let cookie of cookies) {\r\n dict[cookie.name] = cookie.value;\r\n }\r\n return dict;\r\n}\r\n\r\nexport function cookieHeader(cookieDict) {\r\n return Object.entries(cookieDict)\r\n .map(([key, value]) => `${key}=${value}`)\r\n .join(';')\r\n}\r\n\r\nexport function isIntlHttpCode(httpCode) {\r\n return (\r\n httpCode === undefined ||\r\n httpCode === null ||\r\n httpCode === 0 ||\r\n httpCode === 402 ||\r\n httpCode === 407 ||\r\n httpCode === 466 ||\r\n 500 <= httpCode\r\n );\r\n}\r\n\r\nexport function isIntlError(e) {\r\n return (\r\n e?.message?.toLowerCase?.()?.includes?.(\"timeout\") ||\r\n e?.message?.toLowerCase?.()?.includes?.(\"aborted\") ||\r\n e?.message?.toLowerCase?.()?.includes?.(\"tls connection\") ||\r\n e?.message?.toLowerCase?.()?.includes?.(\"socket hang\") ||\r\n isIntlHttpCode(e?.response?.status)\r\n )\r\n}"],"mappings":";;;;;;QAcgBA,SAAS,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AII,MAAM,IAAIH,OAAO,EAAE;IACxBf,IAAI,CAACkB,MAAM,CAAChF,IAAI,CAAC,GAAGgF,MAAM,CAAChE,KAAK;EACpC;EACA,OAAO8C,IAAI;AACf;AAEO,SAASvF,YAAYA,CAACD,UAAU,EAAE;EACrC,OAAO4F,MAAM,CAACe,OAAO,CAAC3G,UAAU,CAAC,CAC5BkD,GAAG,CAAC,CAAC,CAACE,GAAG,EAAEV,KAAK,CAAC,KAAM,GAAEU,GAAI,IAAGV,KAAM,EAAC,CAAC,CACxCwB,IAAI,CAAC,GAAG,CAAC;AAClB;AAEO,SAAShE,cAAcA,CAAC0G,QAAQ,EAAE;EACrC,OACIA,QAAQ,KAAKC,SAAS,IACtBD,QAAQ,KAAK,IAAI,IACjBA,QAAQ,KAAK,CAAC,IACdA,QAAQ,KAAK,GAAG,IAChBA,QAAQ,KAAK,GAAG,IAChBA,QAAQ,KAAK,GAAG,IAChB,GAAG,IAAIA,QAAQ;AAEvB;AAEO,SAASzG,WAAWA,CAAC2G,CAAC,EAAE;EAC3B,OACIA,CAAC,EAAEtF,OAAO,EAAEuC,WAAW,GAAG,CAAC,EAAEgD,QAAQ,GAAG,SAAS,CAAC,IAClDD,CAAC,EAAEtF,OAAO,EAAEuC,WAAW,GAAG,CAAC,EAAEgD,QAAQ,GAAG,SAAS,CAAC,IAClDD,CAAC,EAAEtF,OAAO,EAAEuC,WAAW,GAAG,CAAC,EAAEgD,QAAQ,GAAG,gBAAgB,CAAC,IACzDD,CAAC,EAAEtF,OAAO,EAAEuC,WAAW,GAAG,CAAC,EAAEgD,QAAQ,GAAG,aAAa,CAAC,IACtD7G,cAAc,CAAC4G,CAAC,EAAErF,QAAQ,EAAEE,MAAM,CAAC;AAE3C"}
1
+ {"version":3,"file":"index.js","names":["_xss","_interopRequireDefault","require","_camelCase","_capitalize","_isEmpty","_setCookieParser","obj","__esModule","default","CONSTANTS","exports","LOWER_CASE","UPPER_CASE","HEXADECIMAL","NUMBERS","Exception","message","response","name","status","pascalCase","time","Math","floor","Date","now","sleepMs","milliseconds","Promise","resolve","setTimeout","sleep","seconds","promiseTimeout","promise","reject","timer","Error","then","value","clearTimeout","catch","reason","splitLines","text","split","filter","item","checkEmpty","map","trim","findKeyNode","key","node","pair","hasOwnProperty","index","result","isEmpty","str","upperCaseFirst","camelCase","toUpperCase","slice","lowerCaseFirst","toLowerCase","titleString","word","capitalize","join","limitString","limit","length","substring","safeString","xss","whiteList","stripIgnoreTag","stripIgnoreTagBody","randomString","useNumbers","useUppercase","characters","i","randomIndex","random","randomHex","randomUuid","useDashes","d","uuid","replace","c","r","toString","replaceAll","randomWeighted","dict","randomFunc","totalWeight","elements","Object","keys","weights","values","reduce","sum","weight","randomNum","weightSum","cookieDict","res","decodeValues","cookies","setCookieParser","parse","cookie","cookieHeader","entries","isIntlHttpCode","httpCode","undefined","isIntlError","e","includes"],"sources":["../src/index.js"],"sourcesContent":["import xss from \"xss\";\r\nimport camelCase from \"lodash/camelCase.js\";\r\nimport capitalize from \"lodash/capitalize.js\";\r\nimport isEmpty from \"lodash/isEmpty.js\";\r\nimport setCookieParser from \"set-cookie-parser\";\r\n\r\n\r\nexport const CONSTANTS = {\r\n LOWER_CASE: \"abcdefghijklmnopqrstuvwxyz\",\r\n UPPER_CASE: \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\",\r\n HEXADECIMAL: \"0123456789abcdef\",\r\n NUMBERS: \"0123456789\",\r\n};\r\n\r\nexport function Exception(message, response = {}, name = null) {\r\n response.status = response.status || 400;\r\n return {\r\n name: pascalCase(name),\r\n message,\r\n response,\r\n }\r\n}\r\n\r\nexport function time() {\r\n return Math.floor(Date.now() / 1000);\r\n}\r\n\r\nexport async function sleepMs(milliseconds) {\r\n return new Promise(resolve => setTimeout(resolve, milliseconds));\r\n}\r\n\r\nexport async function sleep(seconds) {\r\n return await sleepMs(seconds * 1000);\r\n}\r\n\r\nexport function promiseTimeout(milliseconds, promise) {\r\n return new Promise((resolve, reject) => {\r\n const timer = setTimeout(() => {\r\n reject(new Error('Promise timed out after ' + milliseconds + 'ms'));\r\n }, milliseconds);\r\n\r\n promise\r\n .then(value => {\r\n clearTimeout(timer);\r\n resolve(value);\r\n })\r\n .catch(reason => {\r\n clearTimeout(timer);\r\n reject(reason);\r\n });\r\n });\r\n}\r\n\r\nexport function splitLines(text) {\r\n return text.split(/\\r?\\n/).filter(item => !checkEmpty(item)).map(item => item.trim());\r\n}\r\n\r\nexport function findKeyNode(key, node, pair = null) {\r\n if (node && node.hasOwnProperty(key) && (pair ? node[key] === pair : true)) {\r\n return node;\r\n } else if (typeof node === 'object') {\r\n for (let index in node) {\r\n const result = findKeyNode(key, node[index], pair);\r\n if (result) {\r\n return result;\r\n }\r\n }\r\n }\r\n return null;\r\n}\r\n\r\nexport function checkEmpty(value) {\r\n if (typeof value === \"number\") {\r\n return value === 0;\r\n } else {\r\n return isEmpty(value);\r\n }\r\n}\r\n\r\nexport function pascalCase(str) {\r\n return upperCaseFirst(camelCase(str));\r\n}\r\n\r\nexport function upperCaseFirst(str) {\r\n str = str || \"\";\r\n return str[0].toUpperCase() + str.slice(1);\r\n}\r\n\r\nexport function lowerCaseFirst(str) {\r\n str = str || \"\";\r\n return str[0].toLowerCase() + str.slice(1);\r\n}\r\n\r\nexport function titleString(str) {\r\n str = str || \"\";\r\n return str\r\n .split(' ')\r\n .map(word => capitalize(word))\r\n .join(' ');\r\n}\r\n\r\nexport function limitString(str, limit = 35) {\r\n str = str || \"\";\r\n if (str.length <= limit) {\r\n return str;\r\n } else {\r\n return str.substring(0, limit - 3) + \"...\";\r\n }\r\n}\r\n\r\nexport function safeString(str) {\r\n str = str || \"\";\r\n return xss(str, {\r\n whiteList: {},\r\n stripIgnoreTag: true,\r\n stripIgnoreTagBody: [\"script\"]\r\n });\r\n}\r\n\r\nexport function randomString(length, useNumbers = true, useUppercase = false) {\r\n\r\n let characters = CONSTANTS.LOWER_CASE;\r\n if (useUppercase) characters += CONSTANTS.UPPER_CASE;\r\n if (useNumbers) characters += CONSTANTS.NUMBERS;\r\n\r\n let randomString = '';\r\n for (let i = 0; i < length; i++) {\r\n const randomIndex = Math.floor(Math.random() * characters.length);\r\n randomString += characters[randomIndex];\r\n }\r\n\r\n return randomString;\r\n}\r\n\r\nexport function randomHex(length) {\r\n let result = '';\r\n for (let i = 0; i < length; i++) {\r\n const randomIndex = Math.floor(Math.random() * CONSTANTS.HEXADECIMAL.length);\r\n result += CONSTANTS.HEXADECIMAL[randomIndex];\r\n }\r\n\r\n return result;\r\n}\r\n\r\nexport function randomUuid(useDashes = true) {\r\n let d = Date.now();\r\n const uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {\r\n const r = (d + Math.random() * 16) % 16 | 0;\r\n d = Math.floor(d / 16);\r\n return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);\r\n });\r\n return useDashes ? uuid : uuid.replaceAll(\"-\", \"\");\r\n}\r\n\r\nexport function randomWeighted(dict, randomFunc = (totalWeight) => Math.random() * totalWeight) {\r\n let elements = Object.keys(dict);\r\n let weights = Object.values(dict);\r\n\r\n let totalWeight = weights.reduce((sum, weight) => sum + weight, 0);\r\n\r\n let randomNum = randomFunc(totalWeight);\r\n let weightSum = 0;\r\n\r\n for (let i = 0; i < elements.length; i++) {\r\n weightSum += weights[i];\r\n if (randomNum <= weightSum) {\r\n return elements[i];\r\n }\r\n }\r\n}\r\n\r\nexport function cookieDict(res, decodeValues = false) {\r\n let dict = {};\r\n const cookies = setCookieParser.parse(res, {decodeValues: decodeValues});\r\n for (let cookie of cookies) {\r\n dict[cookie.name] = cookie.value;\r\n }\r\n return dict;\r\n}\r\n\r\nexport function cookieHeader(cookieDict) {\r\n return Object.entries(cookieDict)\r\n .map(([key, value]) => `${key}=${value}`)\r\n .join(';')\r\n}\r\n\r\nexport function isIntlHttpCode(httpCode) {\r\n return (\r\n httpCode === undefined ||\r\n httpCode === null ||\r\n httpCode === 0 ||\r\n httpCode === 402 ||\r\n httpCode === 407 ||\r\n httpCode === 466 ||\r\n 500 <= httpCode\r\n );\r\n}\r\n\r\nexport function isIntlError(e) {\r\n return (\r\n e?.message?.toLowerCase?.()?.includes?.(\"timeout\") ||\r\n e?.message?.toLowerCase?.()?.includes?.(\"aborted\") ||\r\n e?.message?.toLowerCase?.()?.includes?.(\"tls connection\") ||\r\n e?.message?.toLowerCase?.()?.includes?.(\"socket hang\") ||\r\n isIntlHttpCode(e?.response?.status)\r\n )\r\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,WAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,QAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,gBAAA,GAAAL,sBAAA,CAAAC,OAAA;AAAgD,SAAAD,uBAAAM,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAGzC,MAAMG,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAG;EACrBE,UAAU,EAAE,4BAA4B;EACxCC,UAAU,EAAE,4BAA4B;EACxCC,WAAW,EAAE,kBAAkB;EAC/BC,OAAO,EAAE;AACb,CAAC;AAEM,SAASC,SAASA,CAACC,OAAO,EAAEC,QAAQ,GAAG,CAAC,CAAC,EAAEC,IAAI,GAAG,IAAI,EAAE;EAC3DD,QAAQ,CAACE,MAAM,GAAGF,QAAQ,CAACE,MAAM,IAAI,GAAG;EACxC,OAAO;IACHD,IAAI,EAAEE,UAAU,CAACF,IAAI,CAAC;IACtBF,OAAO;IACPC;EACJ,CAAC;AACL;AAEO,SAASI,IAAIA,CAAA,EAAG;EACnB,OAAOC,IAAI,CAACC,KAAK,CAACC,IAAI,CAACC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC;AACxC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AClDD,CAAC,EAAE3G,OAAO,EAAEiD,WAAW,GAAG,CAAC,EAAE2D,QAAQ,GAAG,SAAS,CAAC,IAClDD,CAAC,EAAE3G,OAAO,EAAEiD,WAAW,GAAG,CAAC,EAAE2D,QAAQ,GAAG,gBAAgB,CAAC,IACzDD,CAAC,EAAE3G,OAAO,EAAEiD,WAAW,GAAG,CAAC,EAAE2D,QAAQ,GAAG,aAAa,CAAC,IACtDL,cAAc,CAACI,CAAC,EAAE1G,QAAQ,EAAEE,MAAM,CAAC;AAE3C"}
package/cjs/node.js ADDED
@@ -0,0 +1,195 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createNumDir = createNumDir;
7
+ exports.formatProxy = formatProxy;
8
+ exports.getVersion = getVersion;
9
+ exports.hashBcrypt = hashBcrypt;
10
+ exports.md5 = md5;
11
+ exports.proxify = proxify;
12
+ exports.proxyObject = proxyObject;
13
+ exports.serverIp = serverIp;
14
+ exports.tokenHex = tokenHex;
15
+ exports.tokenString = tokenString;
16
+ exports.tokenUuid = tokenUuid;
17
+ exports.tokenWeighted = tokenWeighted;
18
+ exports.verifyBcrypt = verifyBcrypt;
19
+ var _fs = _interopRequireDefault(require("fs"));
20
+ var _path = _interopRequireDefault(require("path"));
21
+ var _crypto = _interopRequireDefault(require("crypto"));
22
+ var _os = require("os");
23
+ var _child_process = require("child_process");
24
+ var _bcrypt = _interopRequireDefault(require("bcrypt"));
25
+ var _axios = _interopRequireDefault(require("axios"));
26
+ var _hpagent = require("hpagent");
27
+ var _index = require("./index.js");
28
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
+ function tokenString(length, useNumbers = true, useUppercase = false) {
30
+ const lowercaseChars = _index.CONSTANTS.LOWER_CASE;
31
+ const uppercaseChars = _index.CONSTANTS.UPPER_CASE;
32
+ const numbers = _index.CONSTANTS.NUMBERS;
33
+ let characters = lowercaseChars;
34
+ if (useUppercase) characters += uppercaseChars;
35
+ if (useNumbers) characters += numbers;
36
+ let randomString = '';
37
+ while (randomString.length < length) {
38
+ const byte = _crypto.default.randomBytes(1)[0];
39
+ const index = byte % characters.length;
40
+ if (byte < 256 - 256 % characters.length) {
41
+ randomString += characters[index];
42
+ }
43
+ }
44
+ return randomString;
45
+ }
46
+ function tokenHex(length) {
47
+ return _crypto.default.randomBytes(Math.ceil(length / 2)).toString('hex').slice(0, length);
48
+ }
49
+ function tokenUuid(useDashes = true) {
50
+ const uuid = _crypto.default.randomUUID().toString();
51
+ return useDashes ? uuid : uuid.replaceAll("-", "");
52
+ }
53
+ function tokenWeighted(dict) {
54
+ return (0, _index.randomWeighted)(dict, _crypto.default.randomInt);
55
+ }
56
+ function serverIp() {
57
+ const interfaces = (0, _os.networkInterfaces)();
58
+ for (const devName in interfaces) {
59
+ const interfaceValue = interfaces[devName];
60
+ for (let i = 0; i < interfaceValue.length; i++) {
61
+ const alias = interfaceValue[i];
62
+ if (alias.family === 'IPv4' && alias.address !== '127.0.0.1' && !alias.address.startsWith("192.168.") && !alias.internal) return alias.address;
63
+ }
64
+ }
65
+ return '127.0.0.1';
66
+ }
67
+ function getVersion() {
68
+ try {
69
+ const date = new Date((0, _child_process.execSync)('git show -s --format=%ci HEAD').toString().trim());
70
+ const formatDatePart = value => value.toString().padStart(2, '0');
71
+ const year = date.getFullYear().toString().slice(-2);
72
+ const month = formatDatePart(date.getMonth() + 1);
73
+ const day = formatDatePart(date.getDate());
74
+ const hour = formatDatePart(date.getHours());
75
+ const minute = formatDatePart(date.getMinutes());
76
+ return parseFloat(`${year}${month}.${day}${hour}${minute}`);
77
+ } catch {
78
+ return 1.0;
79
+ }
80
+ }
81
+ function createNumDir(mainDirectory) {
82
+ _fs.default.mkdirSync(mainDirectory, {
83
+ recursive: true
84
+ });
85
+ for (let i = 0; i <= 9; i++) {
86
+ try {
87
+ _fs.default.mkdirSync(_path.default.join(mainDirectory, i.toString()));
88
+ } catch (e) {
89
+ console.error(`createNumDir:${i}`, e.message);
90
+ }
91
+ }
92
+ }
93
+ function md5(data) {
94
+ return _crypto.default.createHash('md5').update(data).digest("hex");
95
+ }
96
+ function hashBcrypt(plainText) {
97
+ return _bcrypt.default.hashSync(plainText, _bcrypt.default.genSaltSync(10));
98
+ }
99
+ function verifyBcrypt(plainText, hash) {
100
+ return _bcrypt.default.compareSync(plainText, hash);
101
+ }
102
+ function formatProxy(proxy, protocol = "http") {
103
+ proxy = proxy.trim();
104
+ const splitByProtocol = proxy.split("://");
105
+ if (1 < splitByProtocol.length) protocol = splitByProtocol[0];
106
+ proxy = splitByProtocol[splitByProtocol.length - 1];
107
+ if (!proxy.includes("@")) {
108
+ const proxyParts = proxy.split(":");
109
+ if (4 <= proxyParts.length) {
110
+ proxy = `${proxyParts[proxyParts.length - 2]}:${proxyParts[proxyParts.length - 1]}@`;
111
+ proxyParts.pop();
112
+ proxyParts.pop();
113
+ proxy += proxyParts.join(":");
114
+ }
115
+ }
116
+ const proxyParts = proxy.split(':');
117
+ const proxyEnd = parseInt(proxyParts[proxyParts.length - 1]);
118
+ const proxyStart = proxyParts[proxyParts.length - 2];
119
+ if (!proxyStart.includes(".")) {
120
+ proxyParts.pop();
121
+ proxyParts[proxyParts.length - 1] = _crypto.default.randomInt(parseInt(proxyStart), proxyEnd + 1).toString();
122
+ }
123
+ return protocol + "://" + proxyParts.join(':');
124
+ }
125
+ function proxyObject(...args) {
126
+ let proxy = formatProxy(...args);
127
+ const splitByProtocol = proxy.split('://');
128
+ const splitById = splitByProtocol[splitByProtocol.length - 1].split('@');
129
+ const splitByConn = splitById[splitById.length - 1].split(':');
130
+ proxy = {
131
+ protocol: splitByProtocol[0],
132
+ host: splitByConn[0],
133
+ port: parseInt(splitByConn[1])
134
+ };
135
+ if (1 < splitById.length) {
136
+ const splitByAuth = splitById[0].split(':');
137
+ proxy.auth = {
138
+ username: splitByAuth[0],
139
+ password: splitByAuth[1]
140
+ };
141
+ }
142
+ return proxy;
143
+ }
144
+ async function proxify(proxyConfig, callback = formatProxy) {
145
+ proxyConfig = proxyConfig || {};
146
+ const timeout = 7000;
147
+ if (proxyConfig.mode === 1) {
148
+ return callback(proxyConfig.proxy);
149
+ } else if (proxyConfig.mode === 2) {
150
+ const proxy = callback(proxyConfig.proxy);
151
+ try {
152
+ await _axios.default.get(proxyConfig.resetApi, {
153
+ timeout
154
+ });
155
+ } catch {
156
+ return false;
157
+ }
158
+ await (0, _index.sleep)(5);
159
+ for (let i = 0; i < 5; i++) {
160
+ try {
161
+ const res = await _axios.default.get("https://api64.ipify.org", {
162
+ timeout,
163
+ httpsAgent: new _hpagent.HttpsProxyAgent({
164
+ proxy,
165
+ timeout: 7000
166
+ })
167
+ });
168
+ if (res.status === 200) return proxy;
169
+ } catch {
170
+ await (0, _index.sleep)(3);
171
+ }
172
+ }
173
+ } else if (proxyConfig.mode === 3) {
174
+ try {
175
+ const res = await _axios.default.get(proxyConfig.resetApi, {
176
+ timeout
177
+ });
178
+ if (res.status === 200) return callback(proxyConfig.proxy);
179
+ } catch {
180
+ return false;
181
+ }
182
+ } else if (proxyConfig.mode === 4) {
183
+ return callback(proxyConfig.proxy).replace("{SESSION}", tokenHex(8));
184
+ } else if (proxyConfig.mode === 5) {
185
+ try {
186
+ const lines = proxyConfig.proxy.split("\n");
187
+ const line = lines[_crypto.default.randomInt(0, lines.length)];
188
+ return callback(line);
189
+ } catch {
190
+ return false;
191
+ }
192
+ }
193
+ return null;
194
+ }
195
+ //# sourceMappingURL=node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.js","names":["_fs","_interopRequireDefault","require","_path","_crypto","_os","_child_process","_bcrypt","_axios","_hpagent","_index","obj","__esModule","default","tokenString","length","useNumbers","useUppercase","lowercaseChars","CONSTANTS","LOWER_CASE","uppercaseChars","UPPER_CASE","numbers","NUMBERS","characters","randomString","byte","crypto","randomBytes","index","tokenHex","Math","ceil","toString","slice","tokenUuid","useDashes","uuid","randomUUID","replaceAll","tokenWeighted","dict","randomWeighted","randomInt","serverIp","interfaces","networkInterfaces","devName","interfaceValue","i","alias","family","address","startsWith","internal","getVersion","date","Date","execSync","trim","formatDatePart","value","padStart","year","getFullYear","month","getMonth","day","getDate","hour","getHours","minute","getMinutes","parseFloat","createNumDir","mainDirectory","fs","mkdirSync","recursive","path","join","e","console","error","message","md5","data","createHash","update","digest","hashBcrypt","plainText","bcrypt","hashSync","genSaltSync","verifyBcrypt","hash","compareSync","formatProxy","proxy","protocol","splitByProtocol","split","includes","proxyParts","pop","proxyEnd","parseInt","proxyStart","proxyObject","args","splitById","splitByConn","host","port","splitByAuth","auth","username","password","proxify","proxyConfig","callback","timeout","mode","axios","get","resetApi","sleep","res","httpsAgent","HttpsProxyAgent","status","replace","lines","line"],"sources":["../src/node.js"],"sourcesContent":["import fs from \"fs\";\r\nimport path from \"path\";\r\nimport crypto from \"crypto\";\r\nimport {networkInterfaces} from \"os\";\r\nimport {execSync} from \"child_process\";\r\n\r\nimport bcrypt from \"bcrypt\";\r\nimport axios from \"axios\";\r\nimport {HttpsProxyAgent} from \"hpagent\";\r\n\r\nimport {CONSTANTS, randomWeighted, sleep} from \"./index.js\";\r\n\r\n\r\nexport function tokenString(length, useNumbers = true, useUppercase = false) {\r\n const lowercaseChars = CONSTANTS.LOWER_CASE;\r\n const uppercaseChars = CONSTANTS.UPPER_CASE;\r\n const numbers = CONSTANTS.NUMBERS;\r\n\r\n let characters = lowercaseChars;\r\n if (useUppercase) characters += uppercaseChars;\r\n if (useNumbers) characters += numbers;\r\n\r\n let randomString = '';\r\n while (randomString.length < length) {\r\n const byte = crypto.randomBytes(1)[0];\r\n const index = byte % characters.length;\r\n if (byte < (256 - (256 % characters.length))) {\r\n randomString += characters[index];\r\n }\r\n }\r\n\r\n return randomString;\r\n}\r\n\r\nexport function tokenHex(length) {\r\n return crypto\r\n .randomBytes(Math.ceil(length / 2))\r\n .toString('hex')\r\n .slice(0, length);\r\n}\r\n\r\nexport function tokenUuid(useDashes = true) {\r\n const uuid = crypto.randomUUID().toString();\r\n return useDashes ? uuid : uuid.replaceAll(\"-\", \"\")\r\n}\r\n\r\nexport function tokenWeighted(dict) {\r\n return randomWeighted(dict, crypto.randomInt);\r\n}\r\n\r\nexport function serverIp() {\r\n const interfaces = networkInterfaces();\r\n for (const devName in interfaces) {\r\n const interfaceValue = interfaces[devName];\r\n for (let i = 0; i < interfaceValue.length; i++) {\r\n const alias = interfaceValue[i];\r\n if (alias.family === 'IPv4' && alias.address !== '127.0.0.1' && !alias.address.startsWith(\"192.168.\") && !alias.internal)\r\n return alias.address;\r\n }\r\n }\r\n return '127.0.0.1';\r\n}\r\n\r\nexport function getVersion() {\r\n try {\r\n const date = new Date(execSync('git show -s --format=%ci HEAD').toString().trim());\r\n const formatDatePart = (value) => value.toString().padStart(2, '0');\r\n const year = date.getFullYear().toString().slice(-2);\r\n const month = formatDatePart(date.getMonth() + 1);\r\n const day = formatDatePart(date.getDate());\r\n const hour = formatDatePart(date.getHours());\r\n const minute = formatDatePart(date.getMinutes());\r\n return parseFloat(`${year}${month}.${day}${hour}${minute}`);\r\n } catch {\r\n return 1.0;\r\n }\r\n}\r\n\r\nexport function createNumDir(mainDirectory) {\r\n fs.mkdirSync(mainDirectory, {recursive: true});\r\n for (let i = 0; i <= 9; i++) {\r\n try {\r\n fs.mkdirSync(path.join(mainDirectory, i.toString()));\r\n } catch (e) {\r\n console.error(`createNumDir:${i}`, e.message);\r\n }\r\n }\r\n}\r\n\r\nexport function md5(data) {\r\n return crypto.createHash('md5').update(data).digest(\"hex\");\r\n}\r\n\r\nexport function hashBcrypt(plainText) {\r\n return bcrypt.hashSync(plainText, bcrypt.genSaltSync(10));\r\n}\r\n\r\nexport function verifyBcrypt(plainText, hash) {\r\n return bcrypt.compareSync(plainText, hash);\r\n}\r\n\r\nexport function formatProxy(proxy, protocol = \"http\") {\r\n proxy = proxy.trim();\r\n const splitByProtocol = proxy.split(\"://\");\r\n if (1 < splitByProtocol.length)\r\n protocol = splitByProtocol[0];\r\n proxy = splitByProtocol[splitByProtocol.length - 1];\r\n if (!proxy.includes(\"@\")) {\r\n const proxyParts = proxy.split(\":\");\r\n if (4 <= proxyParts.length) {\r\n proxy = `${proxyParts[proxyParts.length - 2]}:${proxyParts[proxyParts.length - 1]}@`;\r\n proxyParts.pop();\r\n proxyParts.pop();\r\n proxy += proxyParts.join(\":\");\r\n }\r\n }\r\n const proxyParts = proxy.split(':');\r\n const proxyEnd = parseInt(proxyParts[proxyParts.length - 1]);\r\n const proxyStart = proxyParts[proxyParts.length - 2];\r\n if (!proxyStart.includes(\".\")) {\r\n proxyParts.pop();\r\n proxyParts[proxyParts.length - 1] = crypto.randomInt(parseInt(proxyStart), proxyEnd + 1).toString();\r\n }\r\n return protocol + \"://\" + proxyParts.join(':');\r\n}\r\n\r\nexport function proxyObject(...args) {\r\n let proxy = formatProxy(...args);\r\n const splitByProtocol = proxy.split('://');\r\n const splitById = splitByProtocol[splitByProtocol.length - 1].split('@');\r\n const splitByConn = splitById[splitById.length - 1].split(':');\r\n proxy = {\r\n protocol: splitByProtocol[0],\r\n host: splitByConn[0],\r\n port: parseInt(splitByConn[1]),\r\n };\r\n if (1 < splitById.length) {\r\n const splitByAuth = splitById[0].split(':');\r\n proxy.auth = {\r\n username: splitByAuth[0],\r\n password: splitByAuth[1]\r\n };\r\n }\r\n return proxy;\r\n}\r\n\r\nexport async function proxify(proxyConfig, callback = formatProxy) {\r\n proxyConfig = proxyConfig || {};\r\n const timeout = 7000;\r\n if (proxyConfig.mode === 1) {\r\n return callback(proxyConfig.proxy);\r\n } else if (proxyConfig.mode === 2) {\r\n const proxy = callback(proxyConfig.proxy);\r\n try {\r\n await axios.get(proxyConfig.resetApi, {timeout});\r\n } catch {\r\n return false;\r\n }\r\n await sleep(5);\r\n for (let i = 0; i < 5; i++) {\r\n try {\r\n const res = await axios.get(\"https://api64.ipify.org\", {\r\n timeout,\r\n httpsAgent: new HttpsProxyAgent({proxy, timeout: 7000})\r\n });\r\n if (res.status === 200)\r\n return proxy;\r\n } catch {\r\n await sleep(3);\r\n }\r\n }\r\n } else if (proxyConfig.mode === 3) {\r\n try {\r\n const res = await axios.get(proxyConfig.resetApi, {timeout});\r\n if (res.status === 200)\r\n return callback(proxyConfig.proxy);\r\n } catch {\r\n return false;\r\n }\r\n } else if (proxyConfig.mode === 4) {\r\n return callback(proxyConfig.proxy).replace(\"{SESSION}\", tokenHex(8));\r\n } else if (proxyConfig.mode === 5) {\r\n try {\r\n const lines = proxyConfig.proxy.split(\"\\n\");\r\n const line = lines[crypto.randomInt(0, lines.length)];\r\n return callback(line);\r\n } catch {\r\n return false;\r\n }\r\n }\r\n\r\n return null;\r\n}"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,IAAAA,GAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,GAAA,GAAAH,OAAA;AACA,IAAAI,cAAA,GAAAJ,OAAA;AAEA,IAAAK,OAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,MAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AAEA,IAAAQ,MAAA,GAAAR,OAAA;AAA4D,SAAAD,uBAAAU,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAGrD,SAASG,WAAWA,CAACC,MAAM,EAAEC,UAAU,GAAG,IAAI,EAAEC,YAAY,GAAG,KAAK,EAAE;EACzE,MAAMC,cAAc,GAAGC,gBAAS,CAACC,UAAU;EAC3C,MAAMC,cAAc,GAAGF,gBAAS,CAACG,UAAU;EAC3C,MAAMC,OAAO,GAAGJ,gBAAS,CAACK,OAAO;EAEjC,IAAIC,UAAU,GAAGP,cAAc;EAC/B,IAAID,YAAY,EAAEQ,UAAU,IAAIJ,cAAc;EAC9C,IA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