@tmsfe/tms-core 0.0.182 → 0.0.184
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 +1 -1
- package/src/encrypt/encrypt-util.ts +3 -2
- package/src/encrypt/index.ts +22 -14
package/package.json
CHANGED
|
@@ -212,7 +212,7 @@ const eccUtil = {
|
|
|
212
212
|
return pre;
|
|
213
213
|
}, [])
|
|
214
214
|
.join('&');
|
|
215
|
-
baseUtil.logInfo('---客户端签名---:before', str);
|
|
215
|
+
// baseUtil.logInfo('---客户端签名---:before', str);
|
|
216
216
|
// 2. md5
|
|
217
217
|
const md5Str = md5(str);
|
|
218
218
|
const nonce = ecc.randomBytes(ecc.box.nonceLength);
|
|
@@ -346,11 +346,12 @@ const cryptRuleUtil = {
|
|
|
346
346
|
},
|
|
347
347
|
// 不参与加密的请求路径规则: { 允许的域名: 不需要加密的path }
|
|
348
348
|
_encryptPathRule: {
|
|
349
|
-
'tim.map.qq.com': ['^/user/login', '^/api/getClientConfigs', '^/basic/crypto/lastkey2'],
|
|
349
|
+
'tim.map.qq.com': ['^/user/login', '^/api/getClientConfigs', '^/basic/crypto/lastkey2', '^/uben/takecar/combine/v2/getRecommendPointAndEstimatePrice'],
|
|
350
350
|
'tim.sparta.html5.qq.com': [
|
|
351
351
|
'^/user/login',
|
|
352
352
|
'^/cnabroad', '^~/ReChargeCard/', '^/gasolinerecharge/v2/', '^/gasolinerecharge/rechargecard/',
|
|
353
353
|
'^/tde', '^/basic/crypto/lastkey2',
|
|
354
|
+
'^/uben/takecar/combine/v2/getRecommendPointAndEstimatePrice',
|
|
354
355
|
],
|
|
355
356
|
},
|
|
356
357
|
isHostValid: (url) => {
|
package/src/encrypt/index.ts
CHANGED
|
@@ -33,7 +33,7 @@ const requestInit = (utilFunc) => {
|
|
|
33
33
|
const { report, composeParamsFunc } = utilFunc;
|
|
34
34
|
encryptUtil.init(composeParamsFunc);
|
|
35
35
|
util.reportFunc = (...args) => {
|
|
36
|
-
util.logInfo(...args);
|
|
36
|
+
// util.logInfo(...args);
|
|
37
37
|
report('request_encrypt_log', ...args);
|
|
38
38
|
};
|
|
39
39
|
proxyWxRequest();
|
|
@@ -82,19 +82,27 @@ function proxyWxRequest(): void {
|
|
|
82
82
|
originalRequestApi.call(this, {
|
|
83
83
|
...originalOptions,
|
|
84
84
|
success: async (res) => {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
85
|
+
success?.call(this, res);
|
|
86
|
+
// 将验签逻辑放到异步线程执行,避免阻塞主流程
|
|
87
|
+
const handleVerificationAsync = () => {
|
|
88
|
+
try {
|
|
89
|
+
const {
|
|
90
|
+
success: dealSuccess,
|
|
91
|
+
msg, res: needDealHeader } = encryptUtil.dealRes(url, traceId, res.header, formatData);
|
|
92
|
+
// 性能埋点接口不走验签逻辑
|
|
93
|
+
if (dealSuccess) {
|
|
94
|
+
needDealHeader && encryptUtil.dealEncryptionSwitch(url, traceId, res.header).then((msg) => {
|
|
95
|
+
msg && util.reportFunc(url, traceId, msg);
|
|
96
|
+
});
|
|
97
|
+
} else {
|
|
98
|
+
util.reportFunc(url, traceparent, msg, `加密验签不通过: ${JSON.stringify(res)}`);
|
|
99
|
+
}
|
|
100
|
+
} catch (error) {
|
|
101
|
+
util.reportFunc(url, traceparent, `验签异步处理异常: ${error.message}`);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
// 使用setTimeout将验签逻辑推到下一个任务队列执行
|
|
105
|
+
setTimeout(handleVerificationAsync, 0);
|
|
98
106
|
},
|
|
99
107
|
header: { ...header, Traceparent: traceparent },
|
|
100
108
|
});
|