qjutil 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.global.js +178 -0
- package/dist/index.js +5 -0
- package/dist/index.mjs +5 -0
- package/package.json +1 -1
- package/src/util/sign.ts +2 -8
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
declare function
|
|
1
|
+
declare function md5(str: string): string;
|
|
2
|
+
declare function raw(args: Record<string, any>): string;
|
|
2
3
|
|
|
4
|
+
declare const sign_md5: typeof md5;
|
|
3
5
|
declare const sign_raw: typeof raw;
|
|
4
6
|
declare namespace sign {
|
|
5
|
-
export { sign_raw as raw };
|
|
7
|
+
export { sign_md5 as md5, sign_raw as raw };
|
|
6
8
|
}
|
|
7
9
|
|
|
8
10
|
declare const _default: {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
declare function
|
|
1
|
+
declare function md5(str: string): string;
|
|
2
|
+
declare function raw(args: Record<string, any>): string;
|
|
2
3
|
|
|
4
|
+
declare const sign_md5: typeof md5;
|
|
3
5
|
declare const sign_raw: typeof raw;
|
|
4
6
|
declare namespace sign {
|
|
5
|
-
export { sign_raw as raw };
|
|
7
|
+
export { sign_md5 as md5, sign_raw as raw };
|
|
6
8
|
}
|
|
7
9
|
|
|
8
10
|
declare const _default: {
|
package/dist/index.global.js
CHANGED
|
@@ -1,16 +1,194 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
(() => {
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
5
|
var __export = (target, all) => {
|
|
5
6
|
for (var name in all)
|
|
6
7
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
7
8
|
};
|
|
9
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
8
10
|
|
|
9
11
|
// src/util/sign.ts
|
|
10
12
|
var sign_exports = {};
|
|
11
13
|
__export(sign_exports, {
|
|
14
|
+
md5: () => md5,
|
|
12
15
|
raw: () => raw
|
|
13
16
|
});
|
|
17
|
+
|
|
18
|
+
// node_modules/ts-md5/dist/index.es.js
|
|
19
|
+
var c = new Int32Array(4);
|
|
20
|
+
var _h = class _h {
|
|
21
|
+
constructor() {
|
|
22
|
+
__publicField(this, "_dataLength", 0);
|
|
23
|
+
__publicField(this, "_bufferLength", 0);
|
|
24
|
+
__publicField(this, "_state", new Int32Array(4));
|
|
25
|
+
__publicField(this, "_buffer", new ArrayBuffer(68));
|
|
26
|
+
__publicField(this, "_buffer8");
|
|
27
|
+
__publicField(this, "_buffer32");
|
|
28
|
+
this._buffer8 = new Uint8Array(this._buffer, 0, 68), this._buffer32 = new Uint32Array(this._buffer, 0, 17), this.start();
|
|
29
|
+
}
|
|
30
|
+
static hashStr(i, a = false) {
|
|
31
|
+
return this.onePassHasher.start().appendStr(i).end(a);
|
|
32
|
+
}
|
|
33
|
+
static hashAsciiStr(i, a = false) {
|
|
34
|
+
return this.onePassHasher.start().appendAsciiStr(i).end(a);
|
|
35
|
+
}
|
|
36
|
+
static _hex(i) {
|
|
37
|
+
const a = _h.hexChars, t = _h.hexOut;
|
|
38
|
+
let e, s, r, n;
|
|
39
|
+
for (n = 0; n < 4; n += 1)
|
|
40
|
+
for (s = n * 8, e = i[n], r = 0; r < 8; r += 2)
|
|
41
|
+
t[s + 1 + r] = a.charAt(e & 15), e >>>= 4, t[s + 0 + r] = a.charAt(e & 15), e >>>= 4;
|
|
42
|
+
return t.join("");
|
|
43
|
+
}
|
|
44
|
+
static _md5cycle(i, a) {
|
|
45
|
+
let t = i[0], e = i[1], s = i[2], r = i[3];
|
|
46
|
+
t += (e & s | ~e & r) + a[0] - 680876936 | 0, t = (t << 7 | t >>> 25) + e | 0, r += (t & e | ~t & s) + a[1] - 389564586 | 0, r = (r << 12 | r >>> 20) + t | 0, s += (r & t | ~r & e) + a[2] + 606105819 | 0, s = (s << 17 | s >>> 15) + r | 0, e += (s & r | ~s & t) + a[3] - 1044525330 | 0, e = (e << 22 | e >>> 10) + s | 0, t += (e & s | ~e & r) + a[4] - 176418897 | 0, t = (t << 7 | t >>> 25) + e | 0, r += (t & e | ~t & s) + a[5] + 1200080426 | 0, r = (r << 12 | r >>> 20) + t | 0, s += (r & t | ~r & e) + a[6] - 1473231341 | 0, s = (s << 17 | s >>> 15) + r | 0, e += (s & r | ~s & t) + a[7] - 45705983 | 0, e = (e << 22 | e >>> 10) + s | 0, t += (e & s | ~e & r) + a[8] + 1770035416 | 0, t = (t << 7 | t >>> 25) + e | 0, r += (t & e | ~t & s) + a[9] - 1958414417 | 0, r = (r << 12 | r >>> 20) + t | 0, s += (r & t | ~r & e) + a[10] - 42063 | 0, s = (s << 17 | s >>> 15) + r | 0, e += (s & r | ~s & t) + a[11] - 1990404162 | 0, e = (e << 22 | e >>> 10) + s | 0, t += (e & s | ~e & r) + a[12] + 1804603682 | 0, t = (t << 7 | t >>> 25) + e | 0, r += (t & e | ~t & s) + a[13] - 40341101 | 0, r = (r << 12 | r >>> 20) + t | 0, s += (r & t | ~r & e) + a[14] - 1502002290 | 0, s = (s << 17 | s >>> 15) + r | 0, e += (s & r | ~s & t) + a[15] + 1236535329 | 0, e = (e << 22 | e >>> 10) + s | 0, t += (e & r | s & ~r) + a[1] - 165796510 | 0, t = (t << 5 | t >>> 27) + e | 0, r += (t & s | e & ~s) + a[6] - 1069501632 | 0, r = (r << 9 | r >>> 23) + t | 0, s += (r & e | t & ~e) + a[11] + 643717713 | 0, s = (s << 14 | s >>> 18) + r | 0, e += (s & t | r & ~t) + a[0] - 373897302 | 0, e = (e << 20 | e >>> 12) + s | 0, t += (e & r | s & ~r) + a[5] - 701558691 | 0, t = (t << 5 | t >>> 27) + e | 0, r += (t & s | e & ~s) + a[10] + 38016083 | 0, r = (r << 9 | r >>> 23) + t | 0, s += (r & e | t & ~e) + a[15] - 660478335 | 0, s = (s << 14 | s >>> 18) + r | 0, e += (s & t | r & ~t) + a[4] - 405537848 | 0, e = (e << 20 | e >>> 12) + s | 0, t += (e & r | s & ~r) + a[9] + 568446438 | 0, t = (t << 5 | t >>> 27) + e | 0, r += (t & s | e & ~s) + a[14] - 1019803690 | 0, r = (r << 9 | r >>> 23) + t | 0, s += (r & e | t & ~e) + a[3] - 187363961 | 0, s = (s << 14 | s >>> 18) + r | 0, e += (s & t | r & ~t) + a[8] + 1163531501 | 0, e = (e << 20 | e >>> 12) + s | 0, t += (e & r | s & ~r) + a[13] - 1444681467 | 0, t = (t << 5 | t >>> 27) + e | 0, r += (t & s | e & ~s) + a[2] - 51403784 | 0, r = (r << 9 | r >>> 23) + t | 0, s += (r & e | t & ~e) + a[7] + 1735328473 | 0, s = (s << 14 | s >>> 18) + r | 0, e += (s & t | r & ~t) + a[12] - 1926607734 | 0, e = (e << 20 | e >>> 12) + s | 0, t += (e ^ s ^ r) + a[5] - 378558 | 0, t = (t << 4 | t >>> 28) + e | 0, r += (t ^ e ^ s) + a[8] - 2022574463 | 0, r = (r << 11 | r >>> 21) + t | 0, s += (r ^ t ^ e) + a[11] + 1839030562 | 0, s = (s << 16 | s >>> 16) + r | 0, e += (s ^ r ^ t) + a[14] - 35309556 | 0, e = (e << 23 | e >>> 9) + s | 0, t += (e ^ s ^ r) + a[1] - 1530992060 | 0, t = (t << 4 | t >>> 28) + e | 0, r += (t ^ e ^ s) + a[4] + 1272893353 | 0, r = (r << 11 | r >>> 21) + t | 0, s += (r ^ t ^ e) + a[7] - 155497632 | 0, s = (s << 16 | s >>> 16) + r | 0, e += (s ^ r ^ t) + a[10] - 1094730640 | 0, e = (e << 23 | e >>> 9) + s | 0, t += (e ^ s ^ r) + a[13] + 681279174 | 0, t = (t << 4 | t >>> 28) + e | 0, r += (t ^ e ^ s) + a[0] - 358537222 | 0, r = (r << 11 | r >>> 21) + t | 0, s += (r ^ t ^ e) + a[3] - 722521979 | 0, s = (s << 16 | s >>> 16) + r | 0, e += (s ^ r ^ t) + a[6] + 76029189 | 0, e = (e << 23 | e >>> 9) + s | 0, t += (e ^ s ^ r) + a[9] - 640364487 | 0, t = (t << 4 | t >>> 28) + e | 0, r += (t ^ e ^ s) + a[12] - 421815835 | 0, r = (r << 11 | r >>> 21) + t | 0, s += (r ^ t ^ e) + a[15] + 530742520 | 0, s = (s << 16 | s >>> 16) + r | 0, e += (s ^ r ^ t) + a[2] - 995338651 | 0, e = (e << 23 | e >>> 9) + s | 0, t += (s ^ (e | ~r)) + a[0] - 198630844 | 0, t = (t << 6 | t >>> 26) + e | 0, r += (e ^ (t | ~s)) + a[7] + 1126891415 | 0, r = (r << 10 | r >>> 22) + t | 0, s += (t ^ (r | ~e)) + a[14] - 1416354905 | 0, s = (s << 15 | s >>> 17) + r | 0, e += (r ^ (s | ~t)) + a[5] - 57434055 | 0, e = (e << 21 | e >>> 11) + s | 0, t += (s ^ (e | ~r)) + a[12] + 1700485571 | 0, t = (t << 6 | t >>> 26) + e | 0, r += (e ^ (t | ~s)) + a[3] - 1894986606 | 0, r = (r << 10 | r >>> 22) + t | 0, s += (t ^ (r | ~e)) + a[10] - 1051523 | 0, s = (s << 15 | s >>> 17) + r | 0, e += (r ^ (s | ~t)) + a[1] - 2054922799 | 0, e = (e << 21 | e >>> 11) + s | 0, t += (s ^ (e | ~r)) + a[8] + 1873313359 | 0, t = (t << 6 | t >>> 26) + e | 0, r += (e ^ (t | ~s)) + a[15] - 30611744 | 0, r = (r << 10 | r >>> 22) + t | 0, s += (t ^ (r | ~e)) + a[6] - 1560198380 | 0, s = (s << 15 | s >>> 17) + r | 0, e += (r ^ (s | ~t)) + a[13] + 1309151649 | 0, e = (e << 21 | e >>> 11) + s | 0, t += (s ^ (e | ~r)) + a[4] - 145523070 | 0, t = (t << 6 | t >>> 26) + e | 0, r += (e ^ (t | ~s)) + a[11] - 1120210379 | 0, r = (r << 10 | r >>> 22) + t | 0, s += (t ^ (r | ~e)) + a[2] + 718787259 | 0, s = (s << 15 | s >>> 17) + r | 0, e += (r ^ (s | ~t)) + a[9] - 343485551 | 0, e = (e << 21 | e >>> 11) + s | 0, i[0] = t + i[0] | 0, i[1] = e + i[1] | 0, i[2] = s + i[2] | 0, i[3] = r + i[3] | 0;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Initialise buffer to be hashed
|
|
50
|
+
*/
|
|
51
|
+
start() {
|
|
52
|
+
return this._dataLength = 0, this._bufferLength = 0, this._state.set(_h.stateIdentity), this;
|
|
53
|
+
}
|
|
54
|
+
// Char to code point to to array conversion:
|
|
55
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt
|
|
56
|
+
// #Example.3A_Fixing_charCodeAt_to_handle_non-Basic-Multilingual-Plane_characters_if_their_presence_earlier_in_the_string_is_unknown
|
|
57
|
+
/**
|
|
58
|
+
* Append a UTF-8 string to the hash buffer
|
|
59
|
+
* @param str String to append
|
|
60
|
+
*/
|
|
61
|
+
appendStr(i) {
|
|
62
|
+
const a = this._buffer8, t = this._buffer32;
|
|
63
|
+
let e = this._bufferLength, s, r;
|
|
64
|
+
for (r = 0; r < i.length; r += 1) {
|
|
65
|
+
if (s = i.charCodeAt(r), s < 128)
|
|
66
|
+
a[e++] = s;
|
|
67
|
+
else if (s < 2048)
|
|
68
|
+
a[e++] = (s >>> 6) + 192, a[e++] = s & 63 | 128;
|
|
69
|
+
else if (s < 55296 || s > 56319)
|
|
70
|
+
a[e++] = (s >>> 12) + 224, a[e++] = s >>> 6 & 63 | 128, a[e++] = s & 63 | 128;
|
|
71
|
+
else {
|
|
72
|
+
if (s = (s - 55296) * 1024 + (i.charCodeAt(++r) - 56320) + 65536, s > 1114111)
|
|
73
|
+
throw new Error(
|
|
74
|
+
"Unicode standard supports code points up to U+10FFFF"
|
|
75
|
+
);
|
|
76
|
+
a[e++] = (s >>> 18) + 240, a[e++] = s >>> 12 & 63 | 128, a[e++] = s >>> 6 & 63 | 128, a[e++] = s & 63 | 128;
|
|
77
|
+
}
|
|
78
|
+
e >= 64 && (this._dataLength += 64, _h._md5cycle(this._state, t), e -= 64, t[0] = t[16]);
|
|
79
|
+
}
|
|
80
|
+
return this._bufferLength = e, this;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Append an ASCII string to the hash buffer
|
|
84
|
+
* @param str String to append
|
|
85
|
+
*/
|
|
86
|
+
appendAsciiStr(i) {
|
|
87
|
+
const a = this._buffer8, t = this._buffer32;
|
|
88
|
+
let e = this._bufferLength, s, r = 0;
|
|
89
|
+
for (; ; ) {
|
|
90
|
+
for (s = Math.min(i.length - r, 64 - e); s--; )
|
|
91
|
+
a[e++] = i.charCodeAt(r++);
|
|
92
|
+
if (e < 64)
|
|
93
|
+
break;
|
|
94
|
+
this._dataLength += 64, _h._md5cycle(this._state, t), e = 0;
|
|
95
|
+
}
|
|
96
|
+
return this._bufferLength = e, this;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Append a byte array to the hash buffer
|
|
100
|
+
* @param input array to append
|
|
101
|
+
*/
|
|
102
|
+
appendByteArray(i) {
|
|
103
|
+
const a = this._buffer8, t = this._buffer32;
|
|
104
|
+
let e = this._bufferLength, s, r = 0;
|
|
105
|
+
for (; ; ) {
|
|
106
|
+
for (s = Math.min(i.length - r, 64 - e); s--; )
|
|
107
|
+
a[e++] = i[r++];
|
|
108
|
+
if (e < 64)
|
|
109
|
+
break;
|
|
110
|
+
this._dataLength += 64, _h._md5cycle(this._state, t), e = 0;
|
|
111
|
+
}
|
|
112
|
+
return this._bufferLength = e, this;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Get the state of the hash buffer
|
|
116
|
+
*/
|
|
117
|
+
getState() {
|
|
118
|
+
const i = this._state;
|
|
119
|
+
return {
|
|
120
|
+
buffer: String.fromCharCode.apply(null, Array.from(this._buffer8)),
|
|
121
|
+
buflen: this._bufferLength,
|
|
122
|
+
length: this._dataLength,
|
|
123
|
+
state: [i[0], i[1], i[2], i[3]]
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Override the current state of the hash buffer
|
|
128
|
+
* @param state New hash buffer state
|
|
129
|
+
*/
|
|
130
|
+
setState(i) {
|
|
131
|
+
const a = i.buffer, t = i.state, e = this._state;
|
|
132
|
+
let s;
|
|
133
|
+
for (this._dataLength = i.length, this._bufferLength = i.buflen, e[0] = t[0], e[1] = t[1], e[2] = t[2], e[3] = t[3], s = 0; s < a.length; s += 1)
|
|
134
|
+
this._buffer8[s] = a.charCodeAt(s);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Hash the current state of the hash buffer and return the result
|
|
138
|
+
* @param raw Whether to return the value as an `Int32Array`
|
|
139
|
+
*/
|
|
140
|
+
end(i = false) {
|
|
141
|
+
const a = this._bufferLength, t = this._buffer8, e = this._buffer32, s = (a >> 2) + 1;
|
|
142
|
+
this._dataLength += a;
|
|
143
|
+
const r = this._dataLength * 8;
|
|
144
|
+
if (t[a] = 128, t[a + 1] = t[a + 2] = t[a + 3] = 0, e.set(_h.buffer32Identity.subarray(s), s), a > 55 && (_h._md5cycle(this._state, e), e.set(_h.buffer32Identity)), r <= 4294967295)
|
|
145
|
+
e[14] = r;
|
|
146
|
+
else {
|
|
147
|
+
const n = r.toString(16).match(/(.*?)(.{0,8})$/);
|
|
148
|
+
if (n === null) return i ? c : "";
|
|
149
|
+
const o = parseInt(n[2], 16), _ = parseInt(n[1], 16) || 0;
|
|
150
|
+
e[14] = o, e[15] = _;
|
|
151
|
+
}
|
|
152
|
+
return _h._md5cycle(this._state, e), i ? this._state : _h._hex(this._state);
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
// Private Static Variables
|
|
156
|
+
__publicField(_h, "stateIdentity", new Int32Array([
|
|
157
|
+
1732584193,
|
|
158
|
+
-271733879,
|
|
159
|
+
-1732584194,
|
|
160
|
+
271733878
|
|
161
|
+
]));
|
|
162
|
+
__publicField(_h, "buffer32Identity", new Int32Array([
|
|
163
|
+
0,
|
|
164
|
+
0,
|
|
165
|
+
0,
|
|
166
|
+
0,
|
|
167
|
+
0,
|
|
168
|
+
0,
|
|
169
|
+
0,
|
|
170
|
+
0,
|
|
171
|
+
0,
|
|
172
|
+
0,
|
|
173
|
+
0,
|
|
174
|
+
0,
|
|
175
|
+
0,
|
|
176
|
+
0,
|
|
177
|
+
0,
|
|
178
|
+
0
|
|
179
|
+
]));
|
|
180
|
+
__publicField(_h, "hexChars", "0123456789abcdef");
|
|
181
|
+
__publicField(_h, "hexOut", []);
|
|
182
|
+
// Permanent instance is to use for one-call hashing
|
|
183
|
+
__publicField(_h, "onePassHasher", new _h());
|
|
184
|
+
var h = _h;
|
|
185
|
+
if (h.hashStr("hello") !== "5d41402abc4b2a76b9719d911017c592")
|
|
186
|
+
throw new Error("Md5 self test failed.");
|
|
187
|
+
|
|
188
|
+
// src/util/sign.ts
|
|
189
|
+
function md5(str) {
|
|
190
|
+
return h.hashStr(str);
|
|
191
|
+
}
|
|
14
192
|
function raw(args) {
|
|
15
193
|
let keys = Object.keys(args);
|
|
16
194
|
keys = keys.sort();
|
package/dist/index.js
CHANGED
|
@@ -27,8 +27,13 @@ module.exports = __toCommonJS(index_exports);
|
|
|
27
27
|
// src/util/sign.ts
|
|
28
28
|
var sign_exports = {};
|
|
29
29
|
__export(sign_exports, {
|
|
30
|
+
md5: () => md5,
|
|
30
31
|
raw: () => raw
|
|
31
32
|
});
|
|
33
|
+
var import_ts_md5 = require("ts-md5");
|
|
34
|
+
function md5(str) {
|
|
35
|
+
return import_ts_md5.Md5.hashStr(str);
|
|
36
|
+
}
|
|
32
37
|
function raw(args) {
|
|
33
38
|
let keys = Object.keys(args);
|
|
34
39
|
keys = keys.sort();
|
package/dist/index.mjs
CHANGED
|
@@ -7,8 +7,13 @@ var __export = (target, all) => {
|
|
|
7
7
|
// src/util/sign.ts
|
|
8
8
|
var sign_exports = {};
|
|
9
9
|
__export(sign_exports, {
|
|
10
|
+
md5: () => md5,
|
|
10
11
|
raw: () => raw
|
|
11
12
|
});
|
|
13
|
+
import { Md5 } from "ts-md5";
|
|
14
|
+
function md5(str) {
|
|
15
|
+
return Md5.hashStr(str);
|
|
16
|
+
}
|
|
12
17
|
function raw(args) {
|
|
13
18
|
let keys = Object.keys(args);
|
|
14
19
|
keys = keys.sort();
|
package/package.json
CHANGED
package/src/util/sign.ts
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
import { Md5 } from 'ts-md5';
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
md5:md5,
|
|
5
|
-
raw:raw
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
function md5(str:string){
|
|
2
|
+
export function md5(str:string){
|
|
9
3
|
return Md5.hashStr(str)
|
|
10
4
|
}
|
|
11
5
|
|
|
12
|
-
function raw(args:Record<string, any>) {
|
|
6
|
+
export function raw(args:Record<string, any>) {
|
|
13
7
|
let keys = Object.keys(args);
|
|
14
8
|
//参数名ASCII码从小到大排序(字典序)
|
|
15
9
|
keys = keys.sort();
|