...
|
...
|
@@ -49,23 +49,28 @@ function makeSign(argument) { |
|
|
|
|
|
// 生成API签名,调用后端接口的时候有私钥校验
|
|
|
exports.apiSign = function(params) {
|
|
|
|
|
|
/* eslint-disable */
|
|
|
var sign = packageSort(Object.assign({
|
|
|
'client_type': 'web',
|
|
|
'private_key': privateKey.web,
|
|
|
'app_version': '3.8.2',
|
|
|
'os_version': 'yohobuy:h5',
|
|
|
'screen_size': '720x1280',
|
|
|
'v': '7'
|
|
|
client_type: 'web',
|
|
|
private_key: privateKey.web,
|
|
|
app_version: '3.8.2',
|
|
|
os_version: 'yohobuy:h5',
|
|
|
screen_size: '720x1280',
|
|
|
v: '7'
|
|
|
}, params));
|
|
|
|
|
|
/* eslint-enable */
|
|
|
|
|
|
return Object.assign(sign, {
|
|
|
client_secret: makeSign(sign)
|
|
|
|
|
|
client_secret: makeSign(sign) // eslint-disable-line camelcase
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 检查签名,APP 访问 H5 页面的时候需要检查
|
|
|
exports.checkSign = function(params) {
|
|
|
var clientSecret = params.client_secret,
|
|
|
var clientSecret = params.client_secret, // eslint-disable-line camelcase
|
|
|
sortedParams;
|
|
|
|
|
|
// 忽略部分参数
|
...
|
...
|
@@ -74,7 +79,7 @@ exports.checkSign = function(params) { |
|
|
delete params.debug_data;
|
|
|
delete params['/api'];
|
|
|
|
|
|
params.private_key = privateKey[params.client_type];
|
|
|
params.private_key = privateKey[params.client_type]; // eslint-disable-line camelcase
|
|
|
sortedParams = packageSort(params);
|
|
|
|
|
|
return clientSecret === makeSign(sortedParams);
|
...
|
...
|
@@ -82,7 +87,7 @@ exports.checkSign = function(params) { |
|
|
|
|
|
// 检查签名,APP 访问 H5 页面的时候需要检查, 有可能不同于上边的签名方式
|
|
|
exports.webSign = function(params) {
|
|
|
var privateKey = 'yohobuyapp';
|
|
|
var webPrivateKey = 'yohobuyapp';
|
|
|
|
|
|
return params.key === md5(md5(privateKey) + params.uid);
|
|
|
return params.key === md5(md5(webPrivateKey) + params.uid);
|
|
|
}; |
...
|
...
|
|