karl-common-util
Advanced tools
Comparing version 1.3.7 to 1.3.8
@@ -7,4 +7,2 @@ "use strict"; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
require("isomorphic-fetch"); | ||
@@ -338,38 +336,3 @@ | ||
}, null, undefined); | ||
}, | ||
buildAuthorization: function buildAuthorization(_ref3) { | ||
var data = _ref3.data, | ||
key = _ref3.key; | ||
var arr = []; | ||
for (var k in data) { | ||
arr.push({ k: k, v: data[k] }); | ||
} | ||
arr.sort(function (a, b) { | ||
//按小写的key进行排序 | ||
var ak = a.k.toLowerCase(); | ||
var bk = b.k.toLowerCase(); | ||
if (ak < bk) { | ||
return -1; | ||
} | ||
if (ak > bk) { | ||
return 1; | ||
} | ||
return 0; | ||
}); | ||
//对排序后的数组的值连接,末尾追加“avalon”字符串进行md5签名 | ||
var hash = crypto.createHash("md5"); | ||
var sign = arr.map(function (d) { | ||
if (_typeof(d.v) === "object") { | ||
return JSON.stringify(d.v); | ||
} else { | ||
return d.v; | ||
} | ||
}).join(""); | ||
sign += key; | ||
hash.update(sign); | ||
sign = hash.digest("hex"); | ||
sign = "Bearer " + sign; | ||
return sign; | ||
} | ||
}; |
{ | ||
"name": "karl-common-util", | ||
"version": "1.3.7", | ||
"version": "1.3.8", | ||
"description": "karl common lib for client and server", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -148,34 +148,2 @@ import "isomorphic-fetch" | ||
}, | ||
buildAuthorization: ({data, key}) => { | ||
let arr = [] | ||
for (let k in data) { | ||
arr.push({k: k, v: data[k]}) | ||
} | ||
arr.sort((a, b) => { | ||
//按小写的key进行排序 | ||
let ak = a.k.toLowerCase() | ||
let bk = b.k.toLowerCase() | ||
if (ak < bk) { | ||
return -1 | ||
} | ||
if (ak > bk) { | ||
return 1 | ||
} | ||
return 0 | ||
}) | ||
//对排序后的数组的值连接,末尾追加“avalon”字符串进行md5签名 | ||
let hash = crypto.createHash("md5") | ||
let sign = arr.map(d => { | ||
if(typeof (d.v) === "object"){ | ||
return JSON.stringify(d.v) | ||
}else { | ||
return d.v | ||
} | ||
}).join("") | ||
sign += key | ||
hash.update(sign) | ||
sign = hash.digest("hex") | ||
sign = "Bearer " + sign | ||
return sign | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
51608
1224