ddan-js 2.7.10 → 2.8.1
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/bin/ddan-js.esm.js +1 -1
- package/bin/ddan-js.js +1 -1
- package/bin/lib/class/kvalue.js +4 -1
- package/bin/lib/index.js +2 -1
- package/bin/lib/modules/convert/base.js +112 -0
- package/bin/lib/modules/convert/index.js +4 -47
- package/bin/lib/modules/convert/pkcs.js +16 -0
- package/bin/lib/modules/crypto/index.js +2 -0
- package/bin/lib/modules/crypto/tea.js +79 -0
- package/bin/lib/modules/hook/log.js +27 -3
- package/bin/types/class/kvalue.d.ts +1 -0
- package/bin/types/index.d.ts +78 -20
- package/bin/types/modules/convert/base.d.ts +14 -0
- package/bin/types/modules/convert/index.d.ts +13 -5
- package/bin/types/modules/convert/pkcs.d.ts +5 -0
- package/bin/types/modules/crypto/index.d.ts +10 -0
- package/bin/types/modules/crypto/tea.d.ts +11 -0
- package/bin/types/modules/hook/index.d.ts +4 -2
- package/bin/types/modules/hook/log.d.ts +4 -2
- package/package.json +1 -1
|
@@ -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,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const convert_1 = require("../convert");
|
|
4
|
+
const delta = 0x9e3779b9; // 常量 Delta
|
|
5
|
+
const TEAKey = "33576f37387276645054657a6831686e454664424e5652456f47794835795942";
|
|
6
|
+
const encrypt = (v, teaKey) => {
|
|
7
|
+
let sum = 0;
|
|
8
|
+
const n = 32; // 32轮加密
|
|
9
|
+
for (let i = 0; i < n; i++) {
|
|
10
|
+
sum = (sum + delta) >>> 0;
|
|
11
|
+
v[0] = (v[0] + (((v[1] << 4) + teaKey[0]) ^ (v[1] + sum) ^ ((v[1] >>> 5) + teaKey[1]))) >>> 0;
|
|
12
|
+
v[1] = (v[1] + (((v[0] << 4) + teaKey[2]) ^ (v[0] + sum) ^ ((v[0] >>> 5) + teaKey[3]))) >>> 0;
|
|
13
|
+
}
|
|
14
|
+
return v;
|
|
15
|
+
};
|
|
16
|
+
const decrypt = (v, teaKey) => {
|
|
17
|
+
const n = 32; // 32轮解密
|
|
18
|
+
let sum = (delta * n) >>> 0;
|
|
19
|
+
for (let i = 0; i < n; i++) {
|
|
20
|
+
v[1] = (v[1] - (((v[0] << 4) + teaKey[2]) ^ (v[0] + sum) ^ ((v[0] >>> 5) + teaKey[3]))) >>> 0;
|
|
21
|
+
v[0] = (v[0] - (((v[1] << 4) + teaKey[0]) ^ (v[1] + sum) ^ ((v[1] >>> 5) + teaKey[1]))) >>> 0;
|
|
22
|
+
sum = (sum - delta) >>> 0;
|
|
23
|
+
}
|
|
24
|
+
return v;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* TEA KEY
|
|
28
|
+
* @param str 位
|
|
29
|
+
* @returns 4组32位
|
|
30
|
+
*/
|
|
31
|
+
const toTeaKey = (str) => {
|
|
32
|
+
const keyBytes = convert_1.default.str2bytes(str);
|
|
33
|
+
const key = new Uint32Array(4);
|
|
34
|
+
key[0] = (keyBytes[0] << 24) | (keyBytes[1] << 16) | (keyBytes[2] << 8) | keyBytes[3];
|
|
35
|
+
key[1] = (keyBytes[4] << 24) | (keyBytes[5] << 16) | (keyBytes[6] << 8) | keyBytes[7];
|
|
36
|
+
key[2] = (keyBytes[8] << 24) | (keyBytes[9] << 16) | (keyBytes[10] << 8) | keyBytes[11];
|
|
37
|
+
key[3] = (keyBytes[12] << 24) | (keyBytes[13] << 16) | (keyBytes[14] << 8) | keyBytes[15];
|
|
38
|
+
return key;
|
|
39
|
+
};
|
|
40
|
+
const encodeBytes = (plainbytes, key) => {
|
|
41
|
+
// 转换明文为字节数组并进行PKCS#7填充
|
|
42
|
+
const padded = convert_1.default.pkcs7Padding(plainbytes, 8);
|
|
43
|
+
// 将明文分块并加密
|
|
44
|
+
const key4LongBytes = toTeaKey(key);
|
|
45
|
+
const encryptedBlocks = [];
|
|
46
|
+
for (let i = 0; i < padded.length; i += 8) {
|
|
47
|
+
const block = convert_1.default.bytesToUint32(padded.slice(i, i + 8));
|
|
48
|
+
const encryptedBlock = encrypt(block, key4LongBytes);
|
|
49
|
+
encryptedBlocks.push(convert_1.default.uint32ToBytes(encryptedBlock));
|
|
50
|
+
}
|
|
51
|
+
const encoded = convert_1.default.concatBytes(...encryptedBlocks);
|
|
52
|
+
return encoded;
|
|
53
|
+
};
|
|
54
|
+
const decodeBytes = (cipherbytes, key) => {
|
|
55
|
+
// 将密文分块并解密
|
|
56
|
+
const key4LongBytes = toTeaKey(key);
|
|
57
|
+
const decryptedBlocks = [];
|
|
58
|
+
for (let i = 0; i < cipherbytes.length; i += 8) {
|
|
59
|
+
const block = convert_1.default.bytesToUint32(cipherbytes.slice(i, i + 8));
|
|
60
|
+
const decryptedBlock = decrypt(block, key4LongBytes);
|
|
61
|
+
decryptedBlocks.push(convert_1.default.uint32ToBytes(decryptedBlock));
|
|
62
|
+
}
|
|
63
|
+
const decryptedBytes = convert_1.default.concatBytes(...decryptedBlocks);
|
|
64
|
+
// 去除填充并返回明文
|
|
65
|
+
const decryptedUnpaddBytes = convert_1.default.pkcs7Unpadding(decryptedBytes);
|
|
66
|
+
return decryptedUnpaddBytes;
|
|
67
|
+
};
|
|
68
|
+
const encode = (plaintext, key) => {
|
|
69
|
+
// 转换明文为字节数组并进行PKCS#7填充
|
|
70
|
+
const plainBytes = convert_1.default.textEncode(plaintext);
|
|
71
|
+
const encoded = encodeBytes(plainBytes, key);
|
|
72
|
+
return convert_1.default.bytesToBase64(encoded);
|
|
73
|
+
};
|
|
74
|
+
const decode = (ciphertext, key) => {
|
|
75
|
+
const cipherBytes = convert_1.default.base64ToBytes(ciphertext);
|
|
76
|
+
const decryptedBytes = decodeBytes(cipherBytes, key);
|
|
77
|
+
return convert_1.default.textDecode(decryptedBytes.buffer);
|
|
78
|
+
};
|
|
79
|
+
exports.default = { TEAKey, encrypt, decrypt, toTeaKey, encode, decode, encodeBytes, decodeBytes };
|
|
@@ -3,8 +3,32 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const is_1 = require("../../util/is");
|
|
4
4
|
const rsa_web_1 = require("../node/rsa-web");
|
|
5
5
|
const rsa_1 = require("../rsa");
|
|
6
|
+
const tea_1 = require("../crypto/tea");
|
|
7
|
+
const convert_1 = require("../convert");
|
|
6
8
|
const string_1 = require("../string");
|
|
7
|
-
const logString =
|
|
9
|
+
const logString = (data) => {
|
|
10
|
+
try {
|
|
11
|
+
const jsonString = JSON.stringify(data);
|
|
12
|
+
if (jsonString === undefined)
|
|
13
|
+
return '';
|
|
14
|
+
return tea_1.default.encode(jsonString, convert_1.default.hex2str(tea_1.default.TEAKey));
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
return '';
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const logParse = (logStr) => {
|
|
21
|
+
try {
|
|
22
|
+
if (!logStr)
|
|
23
|
+
return '';
|
|
24
|
+
const ret = tea_1.default.decode(logStr, convert_1.default.hex2str(tea_1.default.TEAKey));
|
|
25
|
+
return string_1.default.jsonFormat(ret);
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
return '';
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const logRString = async (data) => {
|
|
8
32
|
try {
|
|
9
33
|
const jsonString = JSON.stringify(data);
|
|
10
34
|
if (jsonString === undefined)
|
|
@@ -16,7 +40,7 @@ const logString = async (data) => {
|
|
|
16
40
|
return '';
|
|
17
41
|
}
|
|
18
42
|
};
|
|
19
|
-
const
|
|
43
|
+
const logRParse = async (logStr) => {
|
|
20
44
|
try {
|
|
21
45
|
if (!logStr)
|
|
22
46
|
return '';
|
|
@@ -27,4 +51,4 @@ const logParse = async (logStr) => {
|
|
|
27
51
|
return '';
|
|
28
52
|
}
|
|
29
53
|
};
|
|
30
|
-
exports.default = { logString, logParse };
|
|
54
|
+
exports.default = { logString, logParse, logRString, logRParse };
|
package/bin/types/index.d.ts
CHANGED
|
@@ -63,6 +63,16 @@ declare const dUtil: {
|
|
|
63
63
|
decode: (base64Str: string) => string;
|
|
64
64
|
encodeByOss: (input: string) => string;
|
|
65
65
|
};
|
|
66
|
+
tea: {
|
|
67
|
+
TEAKey: string;
|
|
68
|
+
encrypt: (v: Uint32Array, teaKey: Uint32Array) => Uint32Array;
|
|
69
|
+
decrypt: (v: Uint32Array, teaKey: Uint32Array) => Uint32Array;
|
|
70
|
+
toTeaKey: (str: string) => Uint32Array;
|
|
71
|
+
encode: (plaintext: string, key: string) => string;
|
|
72
|
+
decode: (ciphertext: string, key: string) => string;
|
|
73
|
+
encodeBytes: (plainbytes: Uint8Array, key: string) => Uint8Array;
|
|
74
|
+
decodeBytes: (cipherbytes: Uint8Array, key: string) => Uint8Array;
|
|
75
|
+
};
|
|
66
76
|
uuid: (len?: number, radix?: number) => string;
|
|
67
77
|
guid: (len: number, prefix?: boolean, sep?: string) => string;
|
|
68
78
|
getHexString: (len: number) => string;
|
|
@@ -70,19 +80,14 @@ declare const dUtil: {
|
|
|
70
80
|
keyLower: string;
|
|
71
81
|
keyUpper: string;
|
|
72
82
|
keyChars: string;
|
|
73
|
-
str2Hex: (str: string) => string;
|
|
74
|
-
hex2Str: (hexstr: string) => string;
|
|
75
83
|
str2ab: (content?: string, base64?: boolean) => ArrayBuffer;
|
|
76
84
|
ab2str: (data: ArrayBuffer, base64?: boolean) => string;
|
|
77
|
-
bytesToStr: (bytes: Uint8Array) => string;
|
|
78
|
-
strToBytes: (str?: string) => Uint8Array;
|
|
79
85
|
utf8ToBase64: (str: string) => string;
|
|
80
86
|
base64ToUtf8: (base64Str: string) => string;
|
|
81
87
|
getRandomBytes: (length: number) => Uint8Array;
|
|
82
88
|
textEncode: (text: string) => Uint8Array;
|
|
83
89
|
textDecode: (buf: ArrayBufferLike) => string;
|
|
84
90
|
toDataUrl: (textOrBuf: string | ArrayBuffer, contentType?: string) => string;
|
|
85
|
-
concatBytes: (...args: Uint8Array[]) => Uint8Array;
|
|
86
91
|
toBase64: (input?: string) => string;
|
|
87
92
|
fromBase64: (input?: string) => string;
|
|
88
93
|
bytesToBase64: (bytes: Uint8Array) => string;
|
|
@@ -91,6 +96,19 @@ declare const dUtil: {
|
|
|
91
96
|
fromUtf8: (utftext: string) => string;
|
|
92
97
|
toUtf8Bytes: (content: string) => Uint8Array;
|
|
93
98
|
fromUtf8Bytes: (utf8Bytes: Uint8Array) => string;
|
|
99
|
+
pkcs7Padding: (plaintext: Uint8Array, blockSize: number) => Uint8Array;
|
|
100
|
+
pkcs7Unpadding: (ciphertext: Uint8Array) => Uint8Array;
|
|
101
|
+
bytes2str: (bytes: Uint8Array) => string;
|
|
102
|
+
str2bytes: (str?: string) => Uint8Array;
|
|
103
|
+
str2hex: (str: string) => string;
|
|
104
|
+
hex2str: (hexstr: string) => string;
|
|
105
|
+
concatBytes: (...args: Uint8Array[]) => Uint8Array;
|
|
106
|
+
uint32ToBytes: (uint32: Uint32Array) => Uint8Array;
|
|
107
|
+
bytesToUint32: (bytes: Uint8Array) => Uint32Array;
|
|
108
|
+
hex2bytes: (hex: string) => Uint8Array;
|
|
109
|
+
bytes2hex: (bytes: Uint8Array) => string;
|
|
110
|
+
toUint32: (str: string) => Uint32Array;
|
|
111
|
+
fromUint32: (uint32: Uint32Array) => string;
|
|
94
112
|
gbk: {
|
|
95
113
|
gbkLength: (str: string) => number;
|
|
96
114
|
gbkCut: (source: string, len: number) => string;
|
|
@@ -295,8 +313,10 @@ declare const dHook: {
|
|
|
295
313
|
pipe: (func: import("./typings").Ddan.Function, callback?: ((result: import("./typings").Ddan.SafeResult<any>) => void) | undefined) => import("./modules/hook/modules/pipeline").default;
|
|
296
314
|
pipeline: (max?: number) => import("./modules/hook/modules/pipeline").default;
|
|
297
315
|
safeTask: (func: import("./typings").Ddan.Function, callback?: ((result: import("./typings").Ddan.SafeResult<any>) => void) | undefined) => import("./modules/hook/modules/safeTask").default;
|
|
298
|
-
logString: (data: any) =>
|
|
299
|
-
logParse: (logStr: string) =>
|
|
316
|
+
logString: (data: any) => string;
|
|
317
|
+
logParse: (logStr: string) => string;
|
|
318
|
+
logRString: (data: any) => Promise<string>;
|
|
319
|
+
logRParse: (logStr: string) => Promise<string>;
|
|
300
320
|
to: <T_2 = any, U extends object = any>(promise: Promise<T_2>, errorExt?: object | undefined) => Promise<[null, T_2] | [U, undefined]>;
|
|
301
321
|
go: <T_3 = any>(task?: import("./typings").Ddan.PFunction<T_3> | undefined) => Promise<[any, undefined] | [null, T_3]>;
|
|
302
322
|
delay: (ms?: number) => Promise<unknown>;
|
|
@@ -306,6 +326,16 @@ declare const dHook: {
|
|
|
306
326
|
decode: (base64Str: string) => string;
|
|
307
327
|
encodeByOss: (input: string) => string;
|
|
308
328
|
};
|
|
329
|
+
tea: {
|
|
330
|
+
TEAKey: string;
|
|
331
|
+
encrypt: (v: Uint32Array, teaKey: Uint32Array) => Uint32Array;
|
|
332
|
+
decrypt: (v: Uint32Array, teaKey: Uint32Array) => Uint32Array;
|
|
333
|
+
toTeaKey: (str: string) => Uint32Array;
|
|
334
|
+
encode: (plaintext: string, key: string) => string;
|
|
335
|
+
decode: (ciphertext: string, key: string) => string;
|
|
336
|
+
encodeBytes: (plainbytes: Uint8Array, key: string) => Uint8Array;
|
|
337
|
+
decodeBytes: (cipherbytes: Uint8Array, key: string) => Uint8Array;
|
|
338
|
+
};
|
|
309
339
|
uuid: (len?: number, radix?: number) => string;
|
|
310
340
|
guid: (len: number, prefix?: boolean, sep?: string) => string;
|
|
311
341
|
getHexString: (len: number) => string;
|
|
@@ -313,19 +343,14 @@ declare const dHook: {
|
|
|
313
343
|
keyLower: string;
|
|
314
344
|
keyUpper: string;
|
|
315
345
|
keyChars: string;
|
|
316
|
-
str2Hex: (str: string) => string;
|
|
317
|
-
hex2Str: (hexstr: string) => string;
|
|
318
346
|
str2ab: (content?: string, base64?: boolean) => ArrayBuffer;
|
|
319
347
|
ab2str: (data: ArrayBuffer, base64?: boolean) => string;
|
|
320
|
-
bytesToStr: (bytes: Uint8Array) => string;
|
|
321
|
-
strToBytes: (str?: string) => Uint8Array;
|
|
322
348
|
utf8ToBase64: (str: string) => string;
|
|
323
349
|
base64ToUtf8: (base64Str: string) => string;
|
|
324
350
|
getRandomBytes: (length: number) => Uint8Array;
|
|
325
351
|
textEncode: (text: string) => Uint8Array;
|
|
326
352
|
textDecode: (buf: ArrayBufferLike) => string;
|
|
327
353
|
toDataUrl: (textOrBuf: string | ArrayBuffer, contentType?: string) => string;
|
|
328
|
-
concatBytes: (...args: Uint8Array[]) => Uint8Array;
|
|
329
354
|
toBase64: (input?: string) => string;
|
|
330
355
|
fromBase64: (input?: string) => string;
|
|
331
356
|
bytesToBase64: (bytes: Uint8Array) => string;
|
|
@@ -334,6 +359,19 @@ declare const dHook: {
|
|
|
334
359
|
fromUtf8: (utftext: string) => string;
|
|
335
360
|
toUtf8Bytes: (content: string) => Uint8Array;
|
|
336
361
|
fromUtf8Bytes: (utf8Bytes: Uint8Array) => string;
|
|
362
|
+
pkcs7Padding: (plaintext: Uint8Array, blockSize: number) => Uint8Array;
|
|
363
|
+
pkcs7Unpadding: (ciphertext: Uint8Array) => Uint8Array;
|
|
364
|
+
bytes2str: (bytes: Uint8Array) => string;
|
|
365
|
+
str2bytes: (str?: string) => Uint8Array;
|
|
366
|
+
str2hex: (str: string) => string;
|
|
367
|
+
hex2str: (hexstr: string) => string;
|
|
368
|
+
concatBytes: (...args: Uint8Array[]) => Uint8Array;
|
|
369
|
+
uint32ToBytes: (uint32: Uint32Array) => Uint8Array;
|
|
370
|
+
bytesToUint32: (bytes: Uint8Array) => Uint32Array;
|
|
371
|
+
hex2bytes: (hex: string) => Uint8Array;
|
|
372
|
+
bytes2hex: (bytes: Uint8Array) => string;
|
|
373
|
+
toUint32: (str: string) => Uint32Array;
|
|
374
|
+
fromUint32: (uint32: Uint32Array) => string;
|
|
337
375
|
};
|
|
338
376
|
declare const dMini: {
|
|
339
377
|
mini: {
|
|
@@ -616,7 +654,7 @@ declare const dNode: {
|
|
|
616
654
|
brotliCompress: typeof import("./modules/node/brotli").brotliCompress;
|
|
617
655
|
brotliDecompress: typeof import("./modules/node/brotli").brotliDecompress;
|
|
618
656
|
};
|
|
619
|
-
export { dUtil, dHook, dWeb, dMini, dCdn, dStore, dJoker, dTracker, dLogger, dNode, KValue, Mapping };
|
|
657
|
+
export { dUtil, dHook, dWeb, dMini, dCdn, dStore, dJoker, dTracker, dLogger, dNode, Event, KValue, Mapping };
|
|
620
658
|
declare const _default: {
|
|
621
659
|
gbk: {
|
|
622
660
|
gbkLength: (str: string) => number;
|
|
@@ -657,8 +695,10 @@ declare const _default: {
|
|
|
657
695
|
pipe: (func: import("./typings").Ddan.Function, callback?: ((result: import("./typings").Ddan.SafeResult<any>) => void) | undefined) => import("./modules/hook/modules/pipeline").default;
|
|
658
696
|
pipeline: (max?: number) => import("./modules/hook/modules/pipeline").default;
|
|
659
697
|
safeTask: (func: import("./typings").Ddan.Function, callback?: ((result: import("./typings").Ddan.SafeResult<any>) => void) | undefined) => import("./modules/hook/modules/safeTask").default;
|
|
660
|
-
logString: (data: any) =>
|
|
661
|
-
logParse: (logStr: string) =>
|
|
698
|
+
logString: (data: any) => string;
|
|
699
|
+
logParse: (logStr: string) => string;
|
|
700
|
+
logRString: (data: any) => Promise<string>;
|
|
701
|
+
logRParse: (logStr: string) => Promise<string>;
|
|
662
702
|
to: <T_1 = any, U extends object = any>(promise: Promise<T_1>, errorExt?: object | undefined) => Promise<[null, T_1] | [U, undefined]>;
|
|
663
703
|
go: <T_2 = any>(task?: import("./typings").Ddan.PFunction<T_2> | undefined) => Promise<[any, undefined] | [null, T_2]>;
|
|
664
704
|
delay: (ms?: number) => Promise<unknown>;
|
|
@@ -792,6 +832,16 @@ declare const _default: {
|
|
|
792
832
|
decode: (base64Str: string) => string;
|
|
793
833
|
encodeByOss: (input: string) => string;
|
|
794
834
|
};
|
|
835
|
+
tea: {
|
|
836
|
+
TEAKey: string;
|
|
837
|
+
encrypt: (v: Uint32Array, teaKey: Uint32Array) => Uint32Array;
|
|
838
|
+
decrypt: (v: Uint32Array, teaKey: Uint32Array) => Uint32Array;
|
|
839
|
+
toTeaKey: (str: string) => Uint32Array;
|
|
840
|
+
encode: (plaintext: string, key: string) => string;
|
|
841
|
+
decode: (ciphertext: string, key: string) => string;
|
|
842
|
+
encodeBytes: (plainbytes: Uint8Array, key: string) => Uint8Array;
|
|
843
|
+
decodeBytes: (cipherbytes: Uint8Array, key: string) => Uint8Array;
|
|
844
|
+
};
|
|
795
845
|
uuid: (len?: number, radix?: number) => string;
|
|
796
846
|
guid: (len: number, prefix?: boolean, sep?: string) => string;
|
|
797
847
|
getHexString: (len: number) => string;
|
|
@@ -934,19 +984,14 @@ declare const _default: {
|
|
|
934
984
|
};
|
|
935
985
|
};
|
|
936
986
|
convert: {
|
|
937
|
-
str2Hex: (str: string) => string;
|
|
938
|
-
hex2Str: (hexstr: string) => string;
|
|
939
987
|
str2ab: (content?: string, base64?: boolean) => ArrayBuffer;
|
|
940
988
|
ab2str: (data: ArrayBuffer, base64?: boolean) => string;
|
|
941
|
-
bytesToStr: (bytes: Uint8Array) => string;
|
|
942
|
-
strToBytes: (str?: string) => Uint8Array;
|
|
943
989
|
utf8ToBase64: (str: string) => string;
|
|
944
990
|
base64ToUtf8: (base64Str: string) => string;
|
|
945
991
|
getRandomBytes: (length: number) => Uint8Array;
|
|
946
992
|
textEncode: (text: string) => Uint8Array;
|
|
947
993
|
textDecode: (buf: ArrayBufferLike) => string;
|
|
948
994
|
toDataUrl: (textOrBuf: string | ArrayBuffer, contentType?: string) => string;
|
|
949
|
-
concatBytes: (...args: Uint8Array[]) => Uint8Array;
|
|
950
995
|
toBase64: (input?: string) => string;
|
|
951
996
|
fromBase64: (input?: string) => string;
|
|
952
997
|
bytesToBase64: (bytes: Uint8Array) => string;
|
|
@@ -955,6 +1000,19 @@ declare const _default: {
|
|
|
955
1000
|
fromUtf8: (utftext: string) => string;
|
|
956
1001
|
toUtf8Bytes: (content: string) => Uint8Array;
|
|
957
1002
|
fromUtf8Bytes: (utf8Bytes: Uint8Array) => string;
|
|
1003
|
+
pkcs7Padding: (plaintext: Uint8Array, blockSize: number) => Uint8Array;
|
|
1004
|
+
pkcs7Unpadding: (ciphertext: Uint8Array) => Uint8Array;
|
|
1005
|
+
bytes2str: (bytes: Uint8Array) => string;
|
|
1006
|
+
str2bytes: (str?: string) => Uint8Array;
|
|
1007
|
+
str2hex: (str: string) => string;
|
|
1008
|
+
hex2str: (hexstr: string) => string;
|
|
1009
|
+
concatBytes: (...args: Uint8Array[]) => Uint8Array;
|
|
1010
|
+
uint32ToBytes: (uint32: Uint32Array) => Uint8Array;
|
|
1011
|
+
bytesToUint32: (bytes: Uint8Array) => Uint32Array;
|
|
1012
|
+
hex2bytes: (hex: string) => Uint8Array;
|
|
1013
|
+
bytes2hex: (bytes: Uint8Array) => string;
|
|
1014
|
+
toUint32: (str: string) => Uint32Array;
|
|
1015
|
+
fromUint32: (uint32: Uint32Array) => string;
|
|
958
1016
|
};
|
|
959
1017
|
KValue: typeof KValue;
|
|
960
1018
|
Mapping: typeof Mapping;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
bytes2str: (bytes: Uint8Array) => string;
|
|
3
|
+
str2bytes: (str?: string) => Uint8Array;
|
|
4
|
+
str2hex: (str: string) => string;
|
|
5
|
+
hex2str: (hexstr: string) => string;
|
|
6
|
+
concatBytes: (...args: Uint8Array[]) => Uint8Array;
|
|
7
|
+
uint32ToBytes: (uint32: Uint32Array) => Uint8Array;
|
|
8
|
+
bytesToUint32: (bytes: Uint8Array) => Uint32Array;
|
|
9
|
+
hex2bytes: (hex: string) => Uint8Array;
|
|
10
|
+
bytes2hex: (bytes: Uint8Array) => string;
|
|
11
|
+
toUint32: (str: string) => Uint32Array;
|
|
12
|
+
fromUint32: (uint32: Uint32Array) => string;
|
|
13
|
+
};
|
|
14
|
+
export default _default;
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
|
-
str2Hex: (str: string) => string;
|
|
3
|
-
hex2Str: (hexstr: string) => string;
|
|
4
2
|
str2ab: (content?: string, base64?: boolean) => ArrayBuffer;
|
|
5
3
|
ab2str: (data: ArrayBuffer, base64?: boolean) => string;
|
|
6
|
-
bytesToStr: (bytes: Uint8Array) => string;
|
|
7
|
-
strToBytes: (str?: string) => Uint8Array;
|
|
8
4
|
utf8ToBase64: (str: string) => string;
|
|
9
5
|
base64ToUtf8: (base64Str: string) => string;
|
|
10
6
|
getRandomBytes: (length: number) => Uint8Array;
|
|
11
7
|
textEncode: (text: string) => Uint8Array;
|
|
12
8
|
textDecode: (buf: ArrayBufferLike) => string;
|
|
13
9
|
toDataUrl: (textOrBuf: string | ArrayBuffer, contentType?: string) => string;
|
|
14
|
-
concatBytes: (...args: Uint8Array[]) => Uint8Array;
|
|
15
10
|
toBase64: (input?: string) => string;
|
|
16
11
|
fromBase64: (input?: string) => string;
|
|
17
12
|
bytesToBase64: (bytes: Uint8Array) => string;
|
|
@@ -20,5 +15,18 @@ declare const _default: {
|
|
|
20
15
|
fromUtf8: (utftext: string) => string;
|
|
21
16
|
toUtf8Bytes: (content: string) => Uint8Array;
|
|
22
17
|
fromUtf8Bytes: (utf8Bytes: Uint8Array) => string;
|
|
18
|
+
pkcs7Padding: (plaintext: Uint8Array, blockSize: number) => Uint8Array;
|
|
19
|
+
pkcs7Unpadding: (ciphertext: Uint8Array) => Uint8Array;
|
|
20
|
+
bytes2str: (bytes: Uint8Array) => string;
|
|
21
|
+
str2bytes: (str?: string) => Uint8Array;
|
|
22
|
+
str2hex: (str: string) => string;
|
|
23
|
+
hex2str: (hexstr: string) => string;
|
|
24
|
+
concatBytes: (...args: Uint8Array[]) => Uint8Array;
|
|
25
|
+
uint32ToBytes: (uint32: Uint32Array) => Uint8Array;
|
|
26
|
+
bytesToUint32: (bytes: Uint8Array) => Uint32Array;
|
|
27
|
+
hex2bytes: (hex: string) => Uint8Array;
|
|
28
|
+
bytes2hex: (bytes: Uint8Array) => string;
|
|
29
|
+
toUint32: (str: string) => Uint32Array;
|
|
30
|
+
fromUint32: (uint32: Uint32Array) => string;
|
|
23
31
|
};
|
|
24
32
|
export default _default;
|
|
@@ -4,6 +4,16 @@ declare const _default: {
|
|
|
4
4
|
decode: (base64Str: string) => string;
|
|
5
5
|
encodeByOss: (input: string) => string;
|
|
6
6
|
};
|
|
7
|
+
tea: {
|
|
8
|
+
TEAKey: string;
|
|
9
|
+
encrypt: (v: Uint32Array, teaKey: Uint32Array) => Uint32Array;
|
|
10
|
+
decrypt: (v: Uint32Array, teaKey: Uint32Array) => Uint32Array;
|
|
11
|
+
toTeaKey: (str: string) => Uint32Array;
|
|
12
|
+
encode: (plaintext: string, key: string) => string;
|
|
13
|
+
decode: (ciphertext: string, key: string) => string;
|
|
14
|
+
encodeBytes: (plainbytes: Uint8Array, key: string) => Uint8Array;
|
|
15
|
+
decodeBytes: (cipherbytes: Uint8Array, key: string) => Uint8Array;
|
|
16
|
+
};
|
|
7
17
|
uuid: (len?: number, radix?: number) => string;
|
|
8
18
|
guid: (len: number, prefix?: boolean, sep?: string) => string;
|
|
9
19
|
getHexString: (len: number) => string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
TEAKey: string;
|
|
3
|
+
encrypt: (v: Uint32Array, teaKey: Uint32Array) => Uint32Array;
|
|
4
|
+
decrypt: (v: Uint32Array, teaKey: Uint32Array) => Uint32Array;
|
|
5
|
+
toTeaKey: (str: string) => Uint32Array;
|
|
6
|
+
encode: (plaintext: string, key: string) => string;
|
|
7
|
+
decode: (ciphertext: string, key: string) => string;
|
|
8
|
+
encodeBytes: (plainbytes: Uint8Array, key: string) => Uint8Array;
|
|
9
|
+
decodeBytes: (cipherbytes: Uint8Array, key: string) => Uint8Array;
|
|
10
|
+
};
|
|
11
|
+
export default _default;
|
|
@@ -25,8 +25,10 @@ declare const _default: {
|
|
|
25
25
|
pipe: (func: Ddan.Function, callback?: ((result: Ddan.SafeResult<any>) => void) | undefined) => DPipeline;
|
|
26
26
|
pipeline: (max?: number) => DPipeline;
|
|
27
27
|
safeTask: (func: Ddan.Function, callback?: ((result: Ddan.SafeResult<any>) => void) | undefined) => DSafeTask;
|
|
28
|
-
logString: (data: any) =>
|
|
29
|
-
logParse: (logStr: string) =>
|
|
28
|
+
logString: (data: any) => string;
|
|
29
|
+
logParse: (logStr: string) => string;
|
|
30
|
+
logRString: (data: any) => Promise<string>;
|
|
31
|
+
logRParse: (logStr: string) => Promise<string>;
|
|
30
32
|
to: <T = any, U extends object = any>(promise: Promise<T>, errorExt?: object | undefined) => Promise<[null, T] | [U, undefined]>;
|
|
31
33
|
go: <T_1 = any>(task?: Ddan.PFunction<T_1> | undefined) => Promise<[any, undefined] | [null, T_1]>;
|
|
32
34
|
delay: (ms?: number) => Promise<unknown>;
|