|
@@ -1,11 +1,35 @@
|
|
|
import axios from 'axios';
|
|
import axios from 'axios';
|
|
|
import qs from 'qs';
|
|
import qs from 'qs';
|
|
|
|
|
+import CryptoJS from 'crypto-js';
|
|
|
/* eslint-disable */
|
|
/* eslint-disable */
|
|
|
let baseUrl = process.env.VUE_APP_BASE_URL;
|
|
let baseUrl = process.env.VUE_APP_BASE_URL;
|
|
|
const axiosInstance = axios.create({
|
|
const axiosInstance = axios.create({
|
|
|
baseURL: baseUrl
|
|
baseURL: baseUrl
|
|
|
});
|
|
});
|
|
|
|
|
+function decrypt(content) {
|
|
|
|
|
+ const key = CryptoJS.enc.Hex.parse('6DF3AE10ADB6B41405DE92C1300CEA6A');
|
|
|
|
|
+ const cipherText = CryptoJS.enc.Hex.parse(content);
|
|
|
|
|
+ var decrypted = CryptoJS.AES.decrypt(
|
|
|
|
|
+ {
|
|
|
|
|
+ ciphertext: cipherText
|
|
|
|
|
+ },
|
|
|
|
|
+ key,
|
|
|
|
|
+ {
|
|
|
|
|
+ mode: CryptoJS.mode.ECB,
|
|
|
|
|
+ padding: CryptoJS.pad.Pkcs7
|
|
|
|
|
+ }
|
|
|
|
|
+ );
|
|
|
|
|
+ return decrypted.toString(CryptoJS.enc.Utf8);
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
|
|
+function encrypt(content) {
|
|
|
|
|
+ const key = CryptoJS.enc.Hex.parse('6DF3AE10ADB6B41405DE92C1300CEA6A');
|
|
|
|
|
+ var encrypted = CryptoJS.AES.encrypt(content, key, {
|
|
|
|
|
+ mode: CryptoJS.mode.ECB,
|
|
|
|
|
+ padding: CryptoJS.pad.Pkcs7
|
|
|
|
|
+ });
|
|
|
|
|
+ return encrypted.ciphertext.toString(CryptoJS.enc.Hex);
|
|
|
|
|
+}
|
|
|
axiosInstance.interceptors.request.use(
|
|
axiosInstance.interceptors.request.use(
|
|
|
function (config) {
|
|
function (config) {
|
|
|
config.headers = config.headers || {};
|
|
config.headers = config.headers || {};
|
|
@@ -22,6 +46,18 @@ axiosInstance.interceptors.request.use(
|
|
|
|
|
|
|
|
axiosInstance.interceptors.response.use(
|
|
axiosInstance.interceptors.response.use(
|
|
|
function (response) {
|
|
function (response) {
|
|
|
|
|
+ if (response.headers['content-encrypted'] === 'true') {
|
|
|
|
|
+ if (navigator.webdriver) {
|
|
|
|
|
+ throw new Error('webdriver detected');
|
|
|
|
|
+ }
|
|
|
|
|
+ let decrypted = decrypt(response.data);
|
|
|
|
|
+ console.log('decrypted', decrypted);
|
|
|
|
|
+ if (response.headers['content-type'].includes('application/json')) {
|
|
|
|
|
+ response.data = JSON.parse(decrypted);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ response.data = decrypted;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
return response;
|
|
return response;
|
|
|
},
|
|
},
|
|
|
function (error) {
|
|
function (error) {
|