Comparing version 1.1.10 to 1.1.11
import axios from 'axios'; | ||
import md5 from 'js-md5'; | ||
import CryptoJS from 'crypto-js' | ||
const { base64decode } = require('nodejs-base64') | ||
var CancelToken = axios.CancelToken; | ||
@@ -43,2 +46,20 @@ var source = CancelToken.source(); | ||
} | ||
/** | ||
* @function 对登录的时候密码进行解密 | ||
* @param {String} word 要被解密的文本 | ||
* @param {String} keyStr 密钥 | ||
* @param {String} ivStr 偏移量 | ||
* @returns {String} 返回解密后的文本 | ||
*/ | ||
let decrypt = function(word, keyStr, ivStr) { | ||
const key = CryptoJS.enc.Utf8.parse(keyStr) | ||
const iv = CryptoJS.enc.Utf8.parse(ivStr) | ||
const decrypt = CryptoJS.AES.decrypt(word, key, { | ||
iv, | ||
mode: CryptoJS.mode.CBC, | ||
padding: CryptoJS.pad.Pkcs7, | ||
}) | ||
const decryptedStr = CryptoJS.enc.Utf8.stringify(decrypt).toString() | ||
return decryptedStr | ||
} | ||
export default function({store, isloaded = false, whiteList = []}) { | ||
@@ -154,2 +175,3 @@ /** | ||
config.headers['X-Timestamp'] = timestamp | ||
config.headers['Accept-Language'] = store.state.Language === 0 ? 'zh-CN' : 'en-US' | ||
if (store.state.TOKEN) { | ||
@@ -167,2 +189,8 @@ config.headers['X-XSRF-TOKEN'] = store.state.TOKEN | ||
}) | ||
// 判断是否需要解密 | ||
if (result.data.isEncrypt) { | ||
let data = base64decode(base64decode(result.data.data).split('').reverse().join('')) | ||
data = decrypt(data, 'One@-!Sports456G', 'One@-!SportsG654') | ||
result.data.data = JSON.parse(data) | ||
} | ||
// console.log(result) | ||
@@ -169,0 +197,0 @@ /* result 为服务器响应回来的数据 */ |
{ | ||
"name": "one-sport", | ||
"version": "1.1.10", | ||
"version": "1.1.11", | ||
"description": "use for one-sport company", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
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
10487
272