ddan-js 2.7.9 → 2.8.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.
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const is_1 = require("../../util/is");
4
+ const bytes2str = (bytes) => {
5
+ if (!bytes || !is_1.default.isArrayLike(bytes))
6
+ return '';
7
+ const str = bytes.reduce((str, byte) => str + String.fromCharCode(byte), '');
8
+ return str;
9
+ };
10
+ const str2bytes = (str = '') => {
11
+ const content = str;
12
+ const bufView = new Uint8Array(content.length);
13
+ for (let i = 0, strLen = content.length; i < strLen; i++) {
14
+ bufView[i] = content.charCodeAt(i);
15
+ }
16
+ return bufView;
17
+ };
18
+ const str2hex = (str) => {
19
+ let hexString = '';
20
+ for (let i = 0; i < str.length; i++) {
21
+ hexString += str.charCodeAt(i).toString(16).padStart(2, '0');
22
+ }
23
+ return hexString;
24
+ };
25
+ const hex2str = (hexstr) => {
26
+ let str = '';
27
+ for (let i = 0; i < hexstr.length; i += 2) {
28
+ str += String.fromCharCode(parseInt(hexstr.substr(i, 2), 16));
29
+ }
30
+ return str;
31
+ };
32
+ const concatBytes = (...args) => {
33
+ // 计算所有 Uint8Array 的总长度
34
+ const totalLength = args.reduce((sum, arr) => sum + arr.length, 0);
35
+ // 创建一个新的 Uint8Array
36
+ const combined = new Uint8Array(totalLength);
37
+ // 当前写入的位置
38
+ let offset = 0;
39
+ // 将每个 Uint8Array 复制到新的数组中
40
+ for (const arr of args) {
41
+ combined.set(arr, offset);
42
+ offset += arr.length;
43
+ }
44
+ return combined;
45
+ };
46
+ const uint32ToBytes = (uint32) => {
47
+ const bytes = new Uint8Array(8);
48
+ bytes[0] = (uint32[0] >>> 24) & 0xff;
49
+ bytes[1] = (uint32[0] >>> 16) & 0xff;
50
+ bytes[2] = (uint32[0] >>> 8) & 0xff;
51
+ bytes[3] = uint32[0] & 0xff;
52
+ bytes[4] = (uint32[1] >>> 24) & 0xff;
53
+ bytes[5] = (uint32[1] >>> 16) & 0xff;
54
+ bytes[6] = (uint32[1] >>> 8) & 0xff;
55
+ bytes[7] = uint32[1] & 0xff;
56
+ return bytes;
57
+ };
58
+ const bytesToUint32 = (bytes) => {
59
+ const unit32 = new Uint32Array(2);
60
+ unit32[0] = (bytes[0] << 24) | (bytes[1] << 16) | (bytes[2] << 8) | bytes[3];
61
+ unit32[1] = (bytes[4] << 24) | (bytes[5] << 16) | (bytes[6] << 8) | bytes[7];
62
+ return unit32;
63
+ };
64
+ const toUint32 = (str) => {
65
+ const length = Math.ceil(str.length / 4);
66
+ const uint32Array = new Uint32Array(length);
67
+ for (let i = 0; i < length; i++) {
68
+ uint32Array[i] =
69
+ (str.charCodeAt(i * 4) << 24) |
70
+ (str.charCodeAt(i * 4 + 1) << 16) |
71
+ (str.charCodeAt(i * 4 + 2) << 8) |
72
+ str.charCodeAt(i * 4 + 3);
73
+ }
74
+ return uint32Array;
75
+ };
76
+ const fromUint32 = (uint32) => {
77
+ let result = '';
78
+ for (let i = 0; i < uint32.length; i++) {
79
+ result += String.fromCharCode((uint32[i] >>> 24) & 0xff, // 提取最高 8 位
80
+ (uint32[i] >>> 16) & 0xff, // 提取次高 8 位
81
+ (uint32[i] >>> 8) & 0xff, // 提取次低 8 位
82
+ uint32[i] & 0xff // 提取最低 8 位
83
+ );
84
+ }
85
+ // 去掉可能因字符串长度不是4的倍数导致的填充字符
86
+ return result.replace(/\0+$/, '');
87
+ };
88
+ const hex2bytes = (hex) => {
89
+ let bytes = new Uint8Array(hex.length / 2);
90
+ for (let i = 0; i < bytes.length; i++) {
91
+ bytes[i] = parseInt(hex.substr(i * 2, 2), 16);
92
+ }
93
+ return bytes;
94
+ };
95
+ const bytes2hex = (bytes) => {
96
+ return Array.from(bytes)
97
+ .map((b) => b.toString(16).padStart(2, '0'))
98
+ .join('');
99
+ };
100
+ exports.default = {
101
+ bytes2str,
102
+ str2bytes,
103
+ str2hex,
104
+ hex2str,
105
+ concatBytes,
106
+ uint32ToBytes,
107
+ bytesToUint32,
108
+ hex2bytes,
109
+ bytes2hex,
110
+ toUint32,
111
+ fromUint32,
112
+ };
@@ -4,6 +4,8 @@ const base64_1 = require("./base64");
4
4
  const is_1 = require("../../util/is");
5
5
  const utf8_1 = require("./utf8");
6
6
  const math_1 = require("../math");
7
+ const base_1 = require("./base");
8
+ const pkcs_1 = require("./pkcs");
7
9
  const str2ab = (content = '', base64 = false) => {
8
10
  if (base64) {
9
11
  return base64_1.default.base64ToBytes(content).buffer;
@@ -26,34 +28,6 @@ const ab2str = (data, base64 = false) => {
26
28
  return uint8Array.reduce((str, byte) => str + String.fromCharCode(byte), '');
27
29
  }
28
30
  };
29
- const bytesToStr = (bytes) => {
30
- if (!bytes || !is_1.default.isArrayLike(bytes))
31
- return '';
32
- const str = bytes.reduce((str, byte) => str + String.fromCharCode(byte), '');
33
- return str;
34
- };
35
- const strToBytes = (str = '') => {
36
- const content = str;
37
- const bufView = new Uint8Array(content.length);
38
- for (let i = 0, strLen = content.length; i < strLen; i++) {
39
- bufView[i] = content.charCodeAt(i);
40
- }
41
- return bufView;
42
- };
43
- const str2Hex = (str) => {
44
- let hexString = '';
45
- for (let i = 0; i < str.length; i++) {
46
- hexString += str.charCodeAt(i).toString(16).padStart(2, '0');
47
- }
48
- return hexString;
49
- };
50
- const hex2Str = (hexstr) => {
51
- let str = '';
52
- for (let i = 0; i < hexstr.length; i += 2) {
53
- str += String.fromCharCode(parseInt(hexstr.substr(i, 2), 16));
54
- }
55
- return str;
56
- };
57
31
  const utf8ToBase64 = (str) => {
58
32
  if (is_1.default.isBrowser) {
59
33
  return btoa(str);
@@ -107,34 +81,17 @@ const toDataUrl = (textOrBuf, contentType = 'text/plain') => {
107
81
  }
108
82
  return '';
109
83
  };
110
- const concatBytes = (...args) => {
111
- // 计算所有 Uint8Array 的总长度
112
- const totalLength = args.reduce((sum, arr) => sum + arr.length, 0);
113
- // 创建一个新的 Uint8Array
114
- const combined = new Uint8Array(totalLength);
115
- // 当前写入的位置
116
- let offset = 0;
117
- // 将每个 Uint8Array 复制到新的数组中
118
- for (const arr of args) {
119
- combined.set(arr, offset);
120
- offset += arr.length;
121
- }
122
- return combined;
123
- };
124
84
  exports.default = {
85
+ ...base_1.default,
86
+ ...pkcs_1.default,
125
87
  ...utf8_1.default,
126
88
  ...base64_1.default,
127
- str2Hex,
128
- hex2Str,
129
89
  str2ab,
130
90
  ab2str,
131
- bytesToStr,
132
- strToBytes,
133
91
  utf8ToBase64,
134
92
  base64ToUtf8,
135
93
  getRandomBytes,
136
94
  textEncode,
137
95
  textDecode,
138
96
  toDataUrl,
139
- concatBytes,
140
97
  };
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const base_1 = require("./base");
4
+ // PKCS#7 填充函数,将明文填充到指定的块大小(8 字节)
5
+ const pkcs7Padding = (plaintext, blockSize) => {
6
+ const padding = blockSize - (plaintext.length % blockSize);
7
+ const padtext = new Uint8Array(padding).fill(padding);
8
+ const result = base_1.default.concatBytes(plaintext, padtext);
9
+ return result;
10
+ };
11
+ // PKCS#7 去除填充函数,解密后去掉填充字符
12
+ const pkcs7Unpadding = (ciphertext) => {
13
+ const padding = ciphertext[ciphertext.length - 1];
14
+ return ciphertext.slice(0, -padding);
15
+ };
16
+ exports.default = { pkcs7Padding, pkcs7Unpadding };
@@ -4,6 +4,7 @@ const time_1 = require("../time");
4
4
  const base64_1 = require("./base64");
5
5
  const const_1 = require("./const");
6
6
  const uuid_1 = require("./uuid");
7
+ const tea_1 = require("./tea");
7
8
  const guid = (len, prefix = false, sep = "") => {
8
9
  const pwd = (0, uuid_1.default)(len || 32);
9
10
  if (!prefix)
@@ -22,6 +23,7 @@ const getHexString = (len) => {
22
23
  exports.default = {
23
24
  ...const_1.default,
24
25
  base64: base64_1.default,
26
+ tea: tea_1.default,
25
27
  uuid: uuid_1.default,
26
28
  guid,
27
29
  getHexString
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const convert_1 = require("../convert");
4
+ const delta = 0x9e3779b9; // 常量 Delta
5
+ const encrypt = (v, teaKey) => {
6
+ let sum = 0;
7
+ const n = 32; // 32轮加密
8
+ for (let i = 0; i < n; i++) {
9
+ sum = (sum + delta) >>> 0;
10
+ v[0] = (v[0] + (((v[1] << 4) + teaKey[0]) ^ (v[1] + sum) ^ ((v[1] >>> 5) + teaKey[1]))) >>> 0;
11
+ v[1] = (v[1] + (((v[0] << 4) + teaKey[2]) ^ (v[0] + sum) ^ ((v[0] >>> 5) + teaKey[3]))) >>> 0;
12
+ }
13
+ return v;
14
+ };
15
+ const decrypt = (v, teaKey) => {
16
+ const n = 32; // 32轮解密
17
+ let sum = (delta * n) >>> 0;
18
+ for (let i = 0; i < n; i++) {
19
+ v[1] = (v[1] - (((v[0] << 4) + teaKey[2]) ^ (v[0] + sum) ^ ((v[0] >>> 5) + teaKey[3]))) >>> 0;
20
+ v[0] = (v[0] - (((v[1] << 4) + teaKey[0]) ^ (v[1] + sum) ^ ((v[1] >>> 5) + teaKey[1]))) >>> 0;
21
+ sum = (sum - delta) >>> 0;
22
+ }
23
+ return v;
24
+ };
25
+ /**
26
+ * TEA KEY
27
+ * @param str 位
28
+ * @returns 4组32位
29
+ */
30
+ const toTeaKey = (str) => {
31
+ const keyBytes = convert_1.default.str2bytes(str);
32
+ const key = new Uint32Array(4);
33
+ key[0] = (keyBytes[0] << 24) | (keyBytes[1] << 16) | (keyBytes[2] << 8) | keyBytes[3];
34
+ key[1] = (keyBytes[4] << 24) | (keyBytes[5] << 16) | (keyBytes[6] << 8) | keyBytes[7];
35
+ key[2] = (keyBytes[8] << 24) | (keyBytes[9] << 16) | (keyBytes[10] << 8) | keyBytes[11];
36
+ key[3] = (keyBytes[12] << 24) | (keyBytes[13] << 16) | (keyBytes[14] << 8) | keyBytes[15];
37
+ return key;
38
+ };
39
+ const encodeBytes = (plainbytes, key) => {
40
+ // 转换明文为字节数组并进行PKCS#7填充
41
+ const padded = convert_1.default.pkcs7Padding(plainbytes, 8);
42
+ // 将明文分块并加密
43
+ const key4LongBytes = toTeaKey(key);
44
+ const encryptedBlocks = [];
45
+ for (let i = 0; i < padded.length; i += 8) {
46
+ const block = convert_1.default.bytesToUint32(padded.slice(i, i + 8));
47
+ const encryptedBlock = encrypt(block, key4LongBytes);
48
+ encryptedBlocks.push(convert_1.default.uint32ToBytes(encryptedBlock));
49
+ }
50
+ const encoded = convert_1.default.concatBytes(...encryptedBlocks);
51
+ return encoded;
52
+ };
53
+ const decodeBytes = (cipherbytes, key) => {
54
+ // 将密文分块并解密
55
+ const key4LongBytes = toTeaKey(key);
56
+ const decryptedBlocks = [];
57
+ for (let i = 0; i < cipherbytes.length; i += 8) {
58
+ const block = convert_1.default.bytesToUint32(cipherbytes.slice(i, i + 8));
59
+ const decryptedBlock = decrypt(block, key4LongBytes);
60
+ decryptedBlocks.push(convert_1.default.uint32ToBytes(decryptedBlock));
61
+ }
62
+ const decryptedBytes = convert_1.default.concatBytes(...decryptedBlocks);
63
+ // 去除填充并返回明文
64
+ const decryptedUnpaddBytes = convert_1.default.pkcs7Unpadding(decryptedBytes);
65
+ return decryptedUnpaddBytes;
66
+ };
67
+ const encode = (plaintext, key) => {
68
+ // 转换明文为字节数组并进行PKCS#7填充
69
+ const plainBytes = convert_1.default.textEncode(plaintext);
70
+ const encoded = encodeBytes(plainBytes, key);
71
+ return convert_1.default.bytesToBase64(encoded);
72
+ };
73
+ const decode = (ciphertext, key) => {
74
+ const cipherBytes = convert_1.default.base64ToBytes(ciphertext);
75
+ const decryptedBytes = decodeBytes(cipherBytes, key);
76
+ return convert_1.default.textDecode(decryptedBytes.buffer);
77
+ };
78
+ exports.default = { encrypt, decrypt, toTeaKey, encode, decode, encodeBytes, decodeBytes };
@@ -9,6 +9,7 @@ const polling_1 = require("./modules/polling");
9
9
  const hooker_1 = require("./hooker");
10
10
  const pipeline_1 = require("./modules/pipeline");
11
11
  const safeTask_1 = require("./modules/safeTask");
12
+ const log_1 = require("./log");
12
13
  /**
13
14
  *
14
15
  * @param task 任务
@@ -31,6 +32,7 @@ const task = (param) => new pipeTask_1.default(param);
31
32
  const safeTask = (func, callback) => new safeTask_1.default(func, callback);
32
33
  exports.default = {
33
34
  ...base_1.default,
35
+ ...log_1.default,
34
36
  sleep: base_1.default.delay,
35
37
  run,
36
38
  exec,
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const is_1 = require("../../util/is");
4
+ const rsa_web_1 = require("../node/rsa-web");
5
+ const rsa_1 = require("../rsa");
6
+ const string_1 = require("../string");
7
+ const logString = async (data) => {
8
+ try {
9
+ const jsonString = JSON.stringify(data);
10
+ if (jsonString === undefined)
11
+ return '';
12
+ const ret = is_1.default.isBrowser ? await rsa_1.default.encode(jsonString) : await rsa_web_1.default.encode(jsonString);
13
+ return ret;
14
+ }
15
+ catch (error) {
16
+ return '';
17
+ }
18
+ };
19
+ const logParse = async (logStr) => {
20
+ try {
21
+ if (!logStr)
22
+ return '';
23
+ const ret = is_1.default.isBrowser ? await rsa_1.default.decode(logStr) : await rsa_web_1.default.decode(logStr);
24
+ return string_1.default.jsonFormat(ret);
25
+ }
26
+ catch (error) {
27
+ return '';
28
+ }
29
+ };
30
+ exports.default = { logString, logParse };
@@ -14,24 +14,24 @@ function toString(value) {
14
14
  }
15
15
  if (Array.isArray(value)) {
16
16
  // Recursively convert values (susceptible to call stack limits).
17
- return `${value.map((other) => other == null ? other : toString(other))}`;
17
+ return `${value.map((other) => (other == null ? other : toString(other)))}`;
18
18
  }
19
19
  if (is_1.default.isSymbol(value)) {
20
20
  return value.toString();
21
21
  }
22
22
  const result = `${value}`;
23
- return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
23
+ return result == '0' && 1 / value == -INFINITY ? '-0' : result;
24
24
  }
25
25
  const upperFirst = (0, createCaseFirst_1.default)('toUpperCase');
26
26
  const lowerFirst = (0, createCaseFirst_1.default)('toLowerCase');
27
- const snakeCase = (string) => ((0, words_1.default)(toString(string).replace(/['\u2019]/g, '')).reduce((result, word, index) => (result + (index ? '_' : '') + word.toLowerCase()), ''));
28
- const kebabCase = (string) => ((0, words_1.default)(toString(string).replace(/['\u2019]/g, '')).reduce((result, word, index) => (result + (index ? '-' : '') + word.toLowerCase()), ''));
29
- const upperCase = (string) => ((0, words_1.default)(toString(string).replace(/['\u2019]/g, '')).reduce((result, word, index) => (result + (index ? ' ' : '') + word.toUpperCase()), ''));
30
- const camelCase = (string) => ((0, words_1.default)(toString(string).replace(/['\u2019]/g, '')).reduce((result, word, index) => {
27
+ const snakeCase = (string) => (0, words_1.default)(toString(string).replace(/['\u2019]/g, '')).reduce((result, word, index) => result + (index ? '_' : '') + word.toLowerCase(), '');
28
+ const kebabCase = (string) => (0, words_1.default)(toString(string).replace(/['\u2019]/g, '')).reduce((result, word, index) => result + (index ? '-' : '') + word.toLowerCase(), '');
29
+ const upperCase = (string) => (0, words_1.default)(toString(string).replace(/['\u2019]/g, '')).reduce((result, word, index) => result + (index ? ' ' : '') + word.toUpperCase(), '');
30
+ const camelCase = (string) => (0, words_1.default)(toString(string).replace(/['\u2019]/g, '')).reduce((result, word, index) => {
31
31
  word = word.toLowerCase();
32
32
  return result + (index ? upperFirst(word) : word);
33
- }, ''));
34
- const lowerCase = (string) => ((0, words_1.default)(toString(string).replace(/['\u2019]/g, '')).reduce((result, word, index) => (result + (index ? ' ' : '') + word.toLowerCase()), ''));
33
+ }, '');
34
+ const lowerCase = (string) => (0, words_1.default)(toString(string).replace(/['\u2019]/g, '')).reduce((result, word, index) => result + (index ? ' ' : '') + word.toLowerCase(), '');
35
35
  /**
36
36
  * startCase('--foo-bar--')
37
37
  * // => 'Foo Bar'
@@ -42,7 +42,7 @@ const lowerCase = (string) => ((0, words_1.default)(toString(string).replace(/['
42
42
  * startCase('__FOO_BAR__')
43
43
  * // => 'FOO BAR'
44
44
  */
45
- const startCase = (string) => ((0, words_1.default)(`${string}`.replace(/['\u2019]/g, '')).reduce((result, word, index) => (result + (index ? ' ' : '') + upperFirst(word)), ''));
45
+ const startCase = (string) => (0, words_1.default)(`${string}`.replace(/['\u2019]/g, '')).reduce((result, word, index) => result + (index ? ' ' : '') + upperFirst(word), '');
46
46
  const splitOnFirst = (string, separator) => {
47
47
  if (!(typeof string === 'string' && typeof separator === 'string')) {
48
48
  throw new TypeError('Expected the arguments to be of type `string`');
@@ -54,19 +54,18 @@ const splitOnFirst = (string, separator) => {
54
54
  if (separatorIndex === -1) {
55
55
  return [];
56
56
  }
57
- return [
58
- string.slice(0, separatorIndex),
59
- string.slice(separatorIndex + separator.length)
60
- ];
57
+ return [string.slice(0, separatorIndex), string.slice(separatorIndex + separator.length)];
61
58
  };
62
59
  const parseValue = (value, { number = false, boolean = false } = {}) => {
63
60
  let val = value;
64
61
  if (!value || typeof value !== 'string')
65
62
  return val;
66
- if (number && !Number.isNaN(Number(value)) && (typeof value === 'string' && value.trim() !== '')) {
63
+ if (number && !Number.isNaN(Number(value)) && typeof value === 'string' && value.trim() !== '') {
67
64
  val = Number(value);
68
65
  }
69
- else if (boolean && value !== null && (value.toLowerCase() === 'true' || value.toLowerCase() === 'false')) {
66
+ else if (boolean &&
67
+ value !== null &&
68
+ (value.toLowerCase() === 'true' || value.toLowerCase() === 'false')) {
70
69
  val = value.toLowerCase() === 'true';
71
70
  }
72
71
  return val;
@@ -80,11 +79,22 @@ const replace = (source, rules) => {
80
79
  const _arr = Array.isArray(rules) ? rules : [rules];
81
80
  (_arr || []).forEach((e) => {
82
81
  if (e.key && e.value) {
83
- result = result.replace(new RegExp(e.key, e.flag || ""), e.value);
82
+ result = result.replace(new RegExp(e.key, e.flag || ''), e.value);
84
83
  }
85
84
  });
86
85
  return result;
87
86
  };
87
+ const jsonFormat = (jsonString) => {
88
+ try {
89
+ if (!jsonString)
90
+ return '';
91
+ const json = JSON.parse(jsonString);
92
+ return JSON.stringify(json, null, 2);
93
+ }
94
+ catch (error) {
95
+ return jsonString;
96
+ }
97
+ };
88
98
  exports.default = {
89
99
  toString,
90
100
  startCase,
@@ -97,5 +107,6 @@ exports.default = {
97
107
  lowerFirst,
98
108
  splitOnFirst,
99
109
  parseValue,
100
- replace
110
+ replace,
111
+ jsonFormat
101
112
  };
@@ -63,6 +63,15 @@ declare const dUtil: {
63
63
  decode: (base64Str: string) => string;
64
64
  encodeByOss: (input: string) => string;
65
65
  };
66
+ tea: {
67
+ encrypt: (v: Uint32Array, teaKey: Uint32Array) => Uint32Array;
68
+ decrypt: (v: Uint32Array, teaKey: Uint32Array) => Uint32Array;
69
+ toTeaKey: (str: string) => Uint32Array;
70
+ encode: (plaintext: string, key: string) => string;
71
+ decode: (ciphertext: string, key: string) => string;
72
+ encodeBytes: (plainbytes: Uint8Array, key: string) => Uint8Array;
73
+ decodeBytes: (cipherbytes: Uint8Array, key: string) => Uint8Array;
74
+ };
66
75
  uuid: (len?: number, radix?: number) => string;
67
76
  guid: (len: number, prefix?: boolean, sep?: string) => string;
68
77
  getHexString: (len: number) => string;
@@ -70,19 +79,14 @@ declare const dUtil: {
70
79
  keyLower: string;
71
80
  keyUpper: string;
72
81
  keyChars: string;
73
- str2Hex: (str: string) => string;
74
- hex2Str: (hexstr: string) => string;
75
82
  str2ab: (content?: string, base64?: boolean) => ArrayBuffer;
76
83
  ab2str: (data: ArrayBuffer, base64?: boolean) => string;
77
- bytesToStr: (bytes: Uint8Array) => string;
78
- strToBytes: (str?: string) => Uint8Array;
79
84
  utf8ToBase64: (str: string) => string;
80
85
  base64ToUtf8: (base64Str: string) => string;
81
86
  getRandomBytes: (length: number) => Uint8Array;
82
87
  textEncode: (text: string) => Uint8Array;
83
88
  textDecode: (buf: ArrayBufferLike) => string;
84
89
  toDataUrl: (textOrBuf: string | ArrayBuffer, contentType?: string) => string;
85
- concatBytes: (...args: Uint8Array[]) => Uint8Array;
86
90
  toBase64: (input?: string) => string;
87
91
  fromBase64: (input?: string) => string;
88
92
  bytesToBase64: (bytes: Uint8Array) => string;
@@ -91,6 +95,19 @@ declare const dUtil: {
91
95
  fromUtf8: (utftext: string) => string;
92
96
  toUtf8Bytes: (content: string) => Uint8Array;
93
97
  fromUtf8Bytes: (utf8Bytes: Uint8Array) => string;
98
+ pkcs7Padding: (plaintext: Uint8Array, blockSize: number) => Uint8Array;
99
+ pkcs7Unpadding: (ciphertext: Uint8Array) => Uint8Array;
100
+ bytes2str: (bytes: Uint8Array) => string;
101
+ str2bytes: (str?: string) => Uint8Array;
102
+ str2hex: (str: string) => string;
103
+ hex2str: (hexstr: string) => string;
104
+ concatBytes: (...args: Uint8Array[]) => Uint8Array;
105
+ uint32ToBytes: (uint32: Uint32Array) => Uint8Array;
106
+ bytesToUint32: (bytes: Uint8Array) => Uint32Array;
107
+ hex2bytes: (hex: string) => Uint8Array;
108
+ bytes2hex: (bytes: Uint8Array) => string;
109
+ toUint32: (str: string) => Uint32Array;
110
+ fromUint32: (uint32: Uint32Array) => string;
94
111
  gbk: {
95
112
  gbkLength: (str: string) => number;
96
113
  gbkCut: (source: string, len: number) => string;
@@ -143,6 +160,7 @@ declare const dUtil: {
143
160
  boolean?: boolean | undefined;
144
161
  }) => any;
145
162
  replace: (source: string, rules: import("./typings").Ddan.IRegexRule | import("./typings").Ddan.IRegexRule[]) => string;
163
+ jsonFormat: (jsonString: string) => string;
146
164
  };
147
165
  time: {
148
166
  now: () => import("./modules/time/dtime").default;
@@ -267,6 +285,22 @@ declare const dHook: {
267
285
  readonly Instance: T;
268
286
  readonly I: T;
269
287
  };
288
+ toString: (value: any) => any;
289
+ startCase: (string: any) => any;
290
+ snakeCase: (string: any) => any;
291
+ kebabCase: (string: any) => any;
292
+ camelCase: (string: any) => any;
293
+ upperCase: (string: any) => any;
294
+ upperFirst: (string: any) => any;
295
+ lowerCase: (string: any) => any;
296
+ lowerFirst: (string: any) => any;
297
+ splitOnFirst: (string: any, separator: any) => string[];
298
+ parseValue: (value?: any, { number, boolean }?: {
299
+ number?: boolean | undefined;
300
+ boolean?: boolean | undefined;
301
+ }) => any;
302
+ replace: (source: string, rules: import("./typings").Ddan.IRegexRule | import("./typings").Ddan.IRegexRule[]) => string;
303
+ jsonFormat: (jsonString: string) => string;
270
304
  sleep: (ms?: number) => Promise<unknown>;
271
305
  run: <T_1 = any>(task?: import("./typings").Ddan.PFunction<T_1> | undefined, wait?: number) => Promise<[any, undefined] | [null, T_1]>;
272
306
  exec: (func: import("./typings").Ddan.Function, taskId?: string) => import("./typings").Ddan.PSafeResult<any>;
@@ -278,6 +312,8 @@ declare const dHook: {
278
312
  pipe: (func: import("./typings").Ddan.Function, callback?: ((result: import("./typings").Ddan.SafeResult<any>) => void) | undefined) => import("./modules/hook/modules/pipeline").default;
279
313
  pipeline: (max?: number) => import("./modules/hook/modules/pipeline").default;
280
314
  safeTask: (func: import("./typings").Ddan.Function, callback?: ((result: import("./typings").Ddan.SafeResult<any>) => void) | undefined) => import("./modules/hook/modules/safeTask").default;
315
+ logString: (data: any) => Promise<string>;
316
+ logParse: (logStr: string) => Promise<string>;
281
317
  to: <T_2 = any, U extends object = any>(promise: Promise<T_2>, errorExt?: object | undefined) => Promise<[null, T_2] | [U, undefined]>;
282
318
  go: <T_3 = any>(task?: import("./typings").Ddan.PFunction<T_3> | undefined) => Promise<[any, undefined] | [null, T_3]>;
283
319
  delay: (ms?: number) => Promise<unknown>;
@@ -287,6 +323,15 @@ declare const dHook: {
287
323
  decode: (base64Str: string) => string;
288
324
  encodeByOss: (input: string) => string;
289
325
  };
326
+ tea: {
327
+ encrypt: (v: Uint32Array, teaKey: Uint32Array) => Uint32Array;
328
+ decrypt: (v: Uint32Array, teaKey: Uint32Array) => Uint32Array;
329
+ toTeaKey: (str: string) => Uint32Array;
330
+ encode: (plaintext: string, key: string) => string;
331
+ decode: (ciphertext: string, key: string) => string;
332
+ encodeBytes: (plainbytes: Uint8Array, key: string) => Uint8Array;
333
+ decodeBytes: (cipherbytes: Uint8Array, key: string) => Uint8Array;
334
+ };
290
335
  uuid: (len?: number, radix?: number) => string;
291
336
  guid: (len: number, prefix?: boolean, sep?: string) => string;
292
337
  getHexString: (len: number) => string;
@@ -294,19 +339,14 @@ declare const dHook: {
294
339
  keyLower: string;
295
340
  keyUpper: string;
296
341
  keyChars: string;
297
- str2Hex: (str: string) => string;
298
- hex2Str: (hexstr: string) => string;
299
342
  str2ab: (content?: string, base64?: boolean) => ArrayBuffer;
300
343
  ab2str: (data: ArrayBuffer, base64?: boolean) => string;
301
- bytesToStr: (bytes: Uint8Array) => string;
302
- strToBytes: (str?: string) => Uint8Array;
303
344
  utf8ToBase64: (str: string) => string;
304
345
  base64ToUtf8: (base64Str: string) => string;
305
346
  getRandomBytes: (length: number) => Uint8Array;
306
347
  textEncode: (text: string) => Uint8Array;
307
348
  textDecode: (buf: ArrayBufferLike) => string;
308
349
  toDataUrl: (textOrBuf: string | ArrayBuffer, contentType?: string) => string;
309
- concatBytes: (...args: Uint8Array[]) => Uint8Array;
310
350
  toBase64: (input?: string) => string;
311
351
  fromBase64: (input?: string) => string;
312
352
  bytesToBase64: (bytes: Uint8Array) => string;
@@ -315,6 +355,19 @@ declare const dHook: {
315
355
  fromUtf8: (utftext: string) => string;
316
356
  toUtf8Bytes: (content: string) => Uint8Array;
317
357
  fromUtf8Bytes: (utf8Bytes: Uint8Array) => string;
358
+ pkcs7Padding: (plaintext: Uint8Array, blockSize: number) => Uint8Array;
359
+ pkcs7Unpadding: (ciphertext: Uint8Array) => Uint8Array;
360
+ bytes2str: (bytes: Uint8Array) => string;
361
+ str2bytes: (str?: string) => Uint8Array;
362
+ str2hex: (str: string) => string;
363
+ hex2str: (hexstr: string) => string;
364
+ concatBytes: (...args: Uint8Array[]) => Uint8Array;
365
+ uint32ToBytes: (uint32: Uint32Array) => Uint8Array;
366
+ bytesToUint32: (bytes: Uint8Array) => Uint32Array;
367
+ hex2bytes: (hex: string) => Uint8Array;
368
+ bytes2hex: (bytes: Uint8Array) => string;
369
+ toUint32: (str: string) => Uint32Array;
370
+ fromUint32: (uint32: Uint32Array) => string;
318
371
  };
319
372
  declare const dMini: {
320
373
  mini: {
@@ -638,6 +691,8 @@ declare const _default: {
638
691
  pipe: (func: import("./typings").Ddan.Function, callback?: ((result: import("./typings").Ddan.SafeResult<any>) => void) | undefined) => import("./modules/hook/modules/pipeline").default;
639
692
  pipeline: (max?: number) => import("./modules/hook/modules/pipeline").default;
640
693
  safeTask: (func: import("./typings").Ddan.Function, callback?: ((result: import("./typings").Ddan.SafeResult<any>) => void) | undefined) => import("./modules/hook/modules/safeTask").default;
694
+ logString: (data: any) => Promise<string>;
695
+ logParse: (logStr: string) => Promise<string>;
641
696
  to: <T_1 = any, U extends object = any>(promise: Promise<T_1>, errorExt?: object | undefined) => Promise<[null, T_1] | [U, undefined]>;
642
697
  go: <T_2 = any>(task?: import("./typings").Ddan.PFunction<T_2> | undefined) => Promise<[any, undefined] | [null, T_2]>;
643
698
  delay: (ms?: number) => Promise<unknown>;
@@ -744,6 +799,7 @@ declare const _default: {
744
799
  boolean?: boolean | undefined;
745
800
  }) => any;
746
801
  replace: (source: string, rules: import("./typings").Ddan.IRegexRule | import("./typings").Ddan.IRegexRule[]) => string;
802
+ jsonFormat: (jsonString: string) => string;
747
803
  };
748
804
  obj: {
749
805
  copy: (source: any, options?: {
@@ -770,6 +826,15 @@ declare const _default: {
770
826
  decode: (base64Str: string) => string;
771
827
  encodeByOss: (input: string) => string;
772
828
  };
829
+ tea: {
830
+ encrypt: (v: Uint32Array, teaKey: Uint32Array) => Uint32Array;
831
+ decrypt: (v: Uint32Array, teaKey: Uint32Array) => Uint32Array;
832
+ toTeaKey: (str: string) => Uint32Array;
833
+ encode: (plaintext: string, key: string) => string;
834
+ decode: (ciphertext: string, key: string) => string;
835
+ encodeBytes: (plainbytes: Uint8Array, key: string) => Uint8Array;
836
+ decodeBytes: (cipherbytes: Uint8Array, key: string) => Uint8Array;
837
+ };
773
838
  uuid: (len?: number, radix?: number) => string;
774
839
  guid: (len: number, prefix?: boolean, sep?: string) => string;
775
840
  getHexString: (len: number) => string;
@@ -912,19 +977,14 @@ declare const _default: {
912
977
  };
913
978
  };
914
979
  convert: {
915
- str2Hex: (str: string) => string;
916
- hex2Str: (hexstr: string) => string;
917
980
  str2ab: (content?: string, base64?: boolean) => ArrayBuffer;
918
981
  ab2str: (data: ArrayBuffer, base64?: boolean) => string;
919
- bytesToStr: (bytes: Uint8Array) => string;
920
- strToBytes: (str?: string) => Uint8Array;
921
982
  utf8ToBase64: (str: string) => string;
922
983
  base64ToUtf8: (base64Str: string) => string;
923
984
  getRandomBytes: (length: number) => Uint8Array;
924
985
  textEncode: (text: string) => Uint8Array;
925
986
  textDecode: (buf: ArrayBufferLike) => string;
926
987
  toDataUrl: (textOrBuf: string | ArrayBuffer, contentType?: string) => string;
927
- concatBytes: (...args: Uint8Array[]) => Uint8Array;
928
988
  toBase64: (input?: string) => string;
929
989
  fromBase64: (input?: string) => string;
930
990
  bytesToBase64: (bytes: Uint8Array) => string;
@@ -933,6 +993,19 @@ declare const _default: {
933
993
  fromUtf8: (utftext: string) => string;
934
994
  toUtf8Bytes: (content: string) => Uint8Array;
935
995
  fromUtf8Bytes: (utf8Bytes: Uint8Array) => string;
996
+ pkcs7Padding: (plaintext: Uint8Array, blockSize: number) => Uint8Array;
997
+ pkcs7Unpadding: (ciphertext: Uint8Array) => Uint8Array;
998
+ bytes2str: (bytes: Uint8Array) => string;
999
+ str2bytes: (str?: string) => Uint8Array;
1000
+ str2hex: (str: string) => string;
1001
+ hex2str: (hexstr: string) => string;
1002
+ concatBytes: (...args: Uint8Array[]) => Uint8Array;
1003
+ uint32ToBytes: (uint32: Uint32Array) => Uint8Array;
1004
+ bytesToUint32: (bytes: Uint8Array) => Uint32Array;
1005
+ hex2bytes: (hex: string) => Uint8Array;
1006
+ bytes2hex: (bytes: Uint8Array) => string;
1007
+ toUint32: (str: string) => Uint32Array;
1008
+ fromUint32: (uint32: Uint32Array) => string;
936
1009
  };
937
1010
  KValue: typeof KValue;
938
1011
  Mapping: typeof Mapping;