dream-common 1.1.20 → 1.1.21
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/lib/CryptoJS/HttpData.js +31 -31
- package/package.json +1 -1
package/lib/CryptoJS/HttpData.js
CHANGED
|
@@ -4,39 +4,33 @@ import {decodeBase58,encodeBase58} from "./Base58";
|
|
|
4
4
|
export const reqEncrypt = (orgId, content) => {
|
|
5
5
|
return reqDataEncrypt(orgId,"1.0.0","MD5","AES", content);
|
|
6
6
|
}
|
|
7
|
-
export const respDecrypt = (
|
|
8
|
-
return respDataDecrypt(orgId,"1.0.0","MD5","AES", content);
|
|
9
|
-
}
|
|
10
|
-
export const respDataDecrypt = (obj) => {
|
|
7
|
+
export const respDecrypt = (obj) => {
|
|
11
8
|
try {
|
|
12
|
-
if (
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
obj[key] = [];
|
|
28
|
-
}
|
|
29
|
-
obj[key].push(value);
|
|
30
|
-
} else {
|
|
31
|
-
obj[key] = value;
|
|
9
|
+
if (obj.encType === "NONE") {
|
|
10
|
+
return obj.data;
|
|
11
|
+
} else {
|
|
12
|
+
let signStr = decodeBase58(obj.signData);
|
|
13
|
+
let encData = encodeBase58(aesDecrypt(md5_16(signStr), obj.encData));
|
|
14
|
+
let obj = {};
|
|
15
|
+
let pairs = encData.split('&');
|
|
16
|
+
for (let i = 0; i < pairs.length; i++) {
|
|
17
|
+
let pair = pairs[i].split('=');
|
|
18
|
+
let key = pair[0];
|
|
19
|
+
let value = pair[1] || '';
|
|
20
|
+
if (key.substring(key.length - 2) === '[]') {
|
|
21
|
+
key = key.substring(0, key.length - 2);
|
|
22
|
+
if (!obj[key]) {
|
|
23
|
+
obj[key] = [];
|
|
32
24
|
}
|
|
25
|
+
obj[key].push(value);
|
|
26
|
+
} else {
|
|
27
|
+
obj[key] = value;
|
|
33
28
|
}
|
|
34
|
-
return obj.data;
|
|
35
29
|
}
|
|
36
|
-
|
|
37
|
-
return obj;
|
|
30
|
+
return obj.data;
|
|
38
31
|
}
|
|
39
32
|
} catch (e) {
|
|
33
|
+
console.log(e);
|
|
40
34
|
return {};
|
|
41
35
|
}
|
|
42
36
|
|
|
@@ -46,11 +40,16 @@ export const respDataDecrypt = (obj) => {
|
|
|
46
40
|
|
|
47
41
|
export const reqDataEncrypt = (orgId,version,signType,encType, content) => {
|
|
48
42
|
let obj = {
|
|
49
|
-
"orgId": orgId,
|
|
50
|
-
"version": version,
|
|
51
|
-
"signType": signType,
|
|
52
|
-
"encType": encType,
|
|
43
|
+
"orgId": orgId || "Client",
|
|
44
|
+
"version": version|| "1.0.0",
|
|
45
|
+
"signType": signType || "NONE",
|
|
46
|
+
"encType": encType|| "NONE",
|
|
53
47
|
};
|
|
48
|
+
if (encType === "NONE") {
|
|
49
|
+
obj.data = content;
|
|
50
|
+
obj.timestamp = new Date().getTime();
|
|
51
|
+
return obj;
|
|
52
|
+
}
|
|
54
53
|
try {
|
|
55
54
|
// 如果obj不是一个对象或者是null,直接返回它
|
|
56
55
|
if (typeof content !== 'object' || content === null || JSON.stringify(content) === "{}") {
|
|
@@ -81,6 +80,7 @@ export const reqDataEncrypt = (orgId,version,signType,encType, content) => {
|
|
|
81
80
|
obj.timestamp = new Date().getTime();
|
|
82
81
|
return obj;
|
|
83
82
|
} catch (e) {
|
|
83
|
+
console.log(e);
|
|
84
84
|
obj.signType ="NONE";
|
|
85
85
|
obj.encType ="NONE";
|
|
86
86
|
obj.data = content;
|