@tmsfe/tms-core 0.0.145 → 0.0.147

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmsfe/tms-core",
3
- "version": "0.0.145",
3
+ "version": "0.0.147",
4
4
  "description": "tms运行时框架",
5
5
  "repository": {
6
6
  "type": "git",
package/src/encrypt.js CHANGED
@@ -58,10 +58,13 @@ function _getEccPublicId() {
58
58
  }
59
59
  // 检查path是否符合下发的路由前缀
60
60
  function _checkPathInEnablePrefix(path) {
61
+ if (!_getEccPublicKey()) {
62
+ return false;
63
+ }
61
64
  if (wx.$_publicKey && wx.$_publicKey.path === '*') {
62
65
  return true;
63
66
  }
64
- const prefixArr = wx.$_publicKey && wx.$_publicKey.path ? wx.$_publicKey.path.split(',').map(item => item.trim()): [];
67
+ const prefixArr = wx.$_publicKey && wx.$_publicKey.path ? wx.$_publicKey.path.split(',').map(item => item.trim()) : [];
65
68
  for (let i = 0, len = prefixArr.length; i < len; i++) {
66
69
  if (path.indexOf(prefixArr[i]) > -1) {
67
70
  return true;
@@ -247,9 +250,6 @@ const encryptPathRule = {
247
250
  ],
248
251
  };
249
252
  function needsEncryption(url, params) {
250
- if (!_getEccPublicKey()) {
251
- return false;
252
- }
253
253
  // 判断是否属于加密白名单, 如果不符合,直接返回false, 如果符合,则走下面的逻辑
254
254
  const enablePathPrefix = _checkPathInEnablePrefix(url);
255
255
  if (!enablePathPrefix) {
package/src/request.js CHANGED
@@ -349,7 +349,7 @@ export default class Request {
349
349
  // wx请求封装成promise
350
350
  async wxRequest(path, method, header = {}, data, needReport, seqId) {
351
351
  if (needReport && path.indexOf('basic/event/upload') < 0) {
352
- console.log(
352
+ logger.log(
353
353
  'tms-performance-log',
354
354
  'request_encrypt_log', 'main', 'send_unencrypt_request', seqId,
355
355
  !!wx.$_publicKey, Request.requestEncryptOpen, path,
@@ -381,7 +381,6 @@ export default class Request {
381
381
  encryptObj.updateDecryptKey(res.data.resData);
382
382
  } catch (e) {
383
383
  encryptObj.updateDecryptKey(null);
384
- console.log('tms-performance-log', 'request_encrypt_log', 'main', 'refresh_encrypt_key_false', e);
385
384
  }
386
385
  }
387
386
 
@@ -478,7 +477,6 @@ export default class Request {
478
477
  header: encryptHeader, data: encryptData, aesKey,
479
478
  } = encryptObj.reqEncrypt(method, data, header, '');
480
479
  // 2. 发送请求
481
- console.log('tms-performance-log', 'request_encrypt_log', 'main', 'send_encrypt_request', seqId, '', '', path);
482
480
  const result = await this.wxRequest(finalUrl, method, encryptHeader, encryptData, false, seqId);
483
481
  const { header: resHeader, data: resData } = result;
484
482
  // 3. 解密响应
@@ -487,14 +485,9 @@ export default class Request {
487
485
  reporter.reportPerformance('request_encrypt_log', 'main', 'local_response_decrypt_fail', seqId);
488
486
  return this.createRequestTask(path, param, method, header, false);
489
487
  }
490
- console.log('tms-performance-log', 'request_encrypt_log', 'main', 'decrypt_response_success', seqId);
491
488
  // 4. 处理解密失败的响应
492
489
  const errCodeType = encryptObj.getErrcodeType(decryptData.errCode, decryptData.errMsg);
493
490
  if (errCodeType === encryptObj.reqErrType.pubKeyInvalid) { // 秘钥失效
494
- console.log('tms-performance-log',
495
- 'request_encrypt_log', 'main', 'remote_response_decrypt_fail',
496
- seqId, decryptData.errCode, retryTimes,
497
- );
498
491
  const encryptSwitch = await this.dealEncryptionSwitch(resHeader, true);
499
492
  if (retryTimes > 2) {
500
493
  throw new Error('解密失败,请重试');
@@ -502,10 +495,6 @@ export default class Request {
502
495
  return this.createRequestTask(path, param, method, header, encryptSwitch, retryTimes + 1);
503
496
  }
504
497
  if (errCodeType === encryptObj.reqErrType.decryptError) { // 解密失败
505
- console.log('tms-performance-log',
506
- 'request_encrypt_log', 'main', 'remote_response_decrypt_fail',
507
- seqId, decryptData.errCode, retryTimes,
508
- );
509
498
  return this.createRequestTask(path, param, method, header, false);
510
499
  }
511
500
  if (errCodeType === encryptObj.reqErrType.cryptoDisabled) { // 加密关闭