@bee.js/node 0.0.44 → 0.0.46
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/JWT/beeJWT.js +2 -2
- package/package.json +1 -1
- package/tools/guid.js +13 -13
- package/tools/hash.js +3 -4
package/lib/JWT/beeJWT.js
CHANGED
|
@@ -26,7 +26,7 @@ module.exports = function token(_payload = null, header = {}) {
|
|
|
26
26
|
payload = JSON.stringify(payload);
|
|
27
27
|
payload = new Buffer.from(payload).toString("base64");
|
|
28
28
|
|
|
29
|
-
const signature = HMACSHA256(`${header}.${payload}`, secret);
|
|
29
|
+
const signature = HMACSHA256(`${header}.${payload}`, secret).toString();
|
|
30
30
|
const token = new Buffer.from(`${header}.${payload}.${signature}`).toString(
|
|
31
31
|
"base64"
|
|
32
32
|
);
|
|
@@ -53,7 +53,7 @@ module.exports = function token(_payload = null, header = {}) {
|
|
|
53
53
|
const header = array[0];
|
|
54
54
|
const payload = array[1];
|
|
55
55
|
|
|
56
|
-
const signature = HMACSHA256(`${header}.${payload}`, secret);
|
|
56
|
+
const signature = HMACSHA256(`${header}.${payload}`, secret).toString();
|
|
57
57
|
|
|
58
58
|
return token === `${header}.${payload}.${signature}`
|
|
59
59
|
? new Buffer.from(payload, "base64").toString("ascii")
|
package/package.json
CHANGED
package/tools/guid.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
const uuid
|
|
1
|
+
const uuid = require("uuid");
|
|
2
2
|
|
|
3
3
|
module.exports = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
4
|
+
uuid: uuid.v4,
|
|
5
|
+
|
|
6
|
+
guid: function (fn, param) {
|
|
7
|
+
return fn ? uuid[fn](param) : uuid.v4();
|
|
8
|
+
},
|
|
9
|
+
|
|
10
|
+
guidToBin: function (param) {
|
|
11
|
+
return typeof param == "string" && param.length == 36
|
|
12
|
+
? "0x" + param.replace(/-/g, "")
|
|
13
|
+
: param;
|
|
14
|
+
},
|
|
15
|
+
};
|
package/tools/hash.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import md5 from "crypto-js/md5";
|
|
1
|
+
const cryptoJS = require("crypto-js");
|
|
3
2
|
|
|
4
3
|
module.exports = {
|
|
5
|
-
md5,
|
|
6
|
-
|
|
4
|
+
md5: (string) => cryptoJS.MD5(string).toString(),
|
|
5
|
+
HmacMD5: (string, key = "") => CryptoJS.HmacMD5(string, key).toString(),
|
|
7
6
|
};
|