@tmsfe/tms-core 0.0.164 → 0.0.166
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/package.json
CHANGED
|
@@ -556,7 +556,7 @@ const dealEncryptionSwitch = async (path: string, traceId: string, resHeader): P
|
|
|
556
556
|
|
|
557
557
|
/**
|
|
558
558
|
* 处理非加密请求的响应
|
|
559
|
-
* @params path traceId resHeader reqData
|
|
559
|
+
* @params path traceId resHeader reqData
|
|
560
560
|
* @returns 是否需要根据响应内容处理加密开关
|
|
561
561
|
*/
|
|
562
562
|
const dealRes = (path: string, traceId: string, resHeader, reqData): BaseResp<boolean> => {
|
|
@@ -574,7 +574,7 @@ const dealRes = (path: string, traceId: string, resHeader, reqData): BaseResp<bo
|
|
|
574
574
|
eccUtil._updateGlobalPublicKeyInfo(false, resHeader);
|
|
575
575
|
}
|
|
576
576
|
return new baseUtil.BaseRespFac(!cryptRuleUtil.isPerformanceReport(path, reqData));
|
|
577
|
-
}
|
|
577
|
+
};
|
|
578
578
|
|
|
579
579
|
const encryptUtil = {
|
|
580
580
|
init, // 初始化加密工具
|
package/src/encrypt/index.ts
CHANGED
|
@@ -27,7 +27,7 @@ let originalRequestApi;
|
|
|
27
27
|
let originalUploadFileApi;
|
|
28
28
|
// 劫持wx.request和wx.uploadFile函数
|
|
29
29
|
const requestInit = (utilFunc) => {
|
|
30
|
-
if (!wx.
|
|
30
|
+
if (!wx.reqCryptoFlag) {
|
|
31
31
|
originalRequestApi = wx.request;
|
|
32
32
|
// 初始化参数加签函数和性能上报函数
|
|
33
33
|
const { report, composeParamsFunc } = utilFunc;
|
|
@@ -37,12 +37,12 @@ const requestInit = (utilFunc) => {
|
|
|
37
37
|
report('request_encrypt_log', ...args);
|
|
38
38
|
};
|
|
39
39
|
proxyWxRequest();
|
|
40
|
-
wx.
|
|
40
|
+
wx.reqCryptoFlag = true;
|
|
41
41
|
}
|
|
42
|
-
if (!wx.
|
|
42
|
+
if (!wx.uploadFileCryptoFlag) {
|
|
43
43
|
originalUploadFileApi = wx.uploadFile;
|
|
44
44
|
proxyWxUploadFile();
|
|
45
|
-
wx.
|
|
45
|
+
wx.uploadFileCryptoFlag = true;
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
48
|
|
|
@@ -79,8 +79,8 @@ function proxyWxRequest(): void {
|
|
|
79
79
|
originalRequestApi.call(this, {
|
|
80
80
|
...originalOptions,
|
|
81
81
|
success: async (res) => {
|
|
82
|
-
const {
|
|
83
|
-
res.header, formatData);
|
|
82
|
+
const {
|
|
83
|
+
success: dealSuccess, res: needDealHeader } = encryptUtil.dealRes(url, traceId, res.header, formatData);
|
|
84
84
|
// 性能埋点接口不走验签逻辑
|
|
85
85
|
if (dealSuccess) {
|
|
86
86
|
needDealHeader && encryptUtil.dealEncryptionSwitch(url, traceId, res.header);
|