xctc-utils 1.2.2 → 1.2.3

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.
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.decrypt = exports.encrypt = void 0;
7
7
  var crypto_js_1 = __importDefault(require("crypto-js"));
8
8
  var utils_1 = require("../utils");
9
+ var index_1 = require("../storage/index");
9
10
  function formatVal(val) {
10
11
  var key = "5uMz4R8r0926DkC8";
11
12
  if (val)
@@ -36,7 +37,9 @@ function decrypt(word, key, iv) {
36
37
  var decrypt = crypto_js_1.default.AES.decrypt(src, key, { iv: iv, mode: crypto_js_1.default.mode.CBC, padding: crypto_js_1.default.pad.Pkcs7 });
37
38
  var decryptedStr = decrypt.toString(crypto_js_1.default.enc.Utf8);
38
39
  var data = decryptedStr.toString();
40
+ (0, index_1.useSessionStorage)("decryptData1", data);
39
41
  if ((0, utils_1.isJson)(data)) {
42
+ (0, index_1.useSessionStorage)("decryptData2", data);
40
43
  return JSON.parse(data);
41
44
  }
42
45
  else {
@@ -67,9 +67,10 @@ function weixinUrlCode(config) {
67
67
  var stateKey = weixinConfig['stateKey'] || "weixinState";
68
68
  (0, index_1.useSessionStorage)(stateKey, hrefState);
69
69
  var stateObj = (0, crypto_1.decrypt)(hrefState, cryptoConfig(cryptokey).key, cryptoConfig(cryptoiv).iv);
70
+ (0, index_1.useSessionStorage)("".concat(stateKey, "Obj1"), stateObj);
70
71
  if (stateObj instanceof Object)
71
72
  stateObj = JSON.stringify(stateObj);
72
- (0, index_1.useSessionStorage)("".concat(stateKey, "Obj"), stateObj);
73
+ (0, index_1.useSessionStorage)("".concat(stateKey, "Obj2"), stateObj);
73
74
  }
74
75
  }
75
76
  // 将 state进行本地存储,存储完成后跳转到微信授权页面
@@ -105,6 +106,7 @@ function weixinLogin(code) {
105
106
  if (!http)
106
107
  return;
107
108
  (0, index_1.useSessionStorage)("weixinLoginParams", JSON.stringify(obj));
109
+ // 调试字段 isPassLogin ,为true 时不继续执行微信登录,前端可拿到 code 给后端测试
108
110
  if (weixinConfig === null || weixinConfig === void 0 ? void 0 : weixinConfig.isPassLogin)
109
111
  return;
110
112
  weixinConfig.http(obj).then(function (res) {
@@ -113,17 +115,6 @@ function weixinLogin(code) {
113
115
  return weixinCode();
114
116
  }
115
117
  var data = res === null || res === void 0 ? void 0 : res.data;
116
- // if( data instanceof Object ){
117
- // useSessionStorage( "weixinLoginData" , JSON.stringify(data) )
118
- // }else{
119
- // useSessionStorage( "weixinLoginStatus" , `微信登录失败:${res.code};${res.msg}` )
120
- // }
121
- var resobj = {
122
- code: res.code,
123
- msg: res.msg,
124
- data: res.data
125
- };
126
- (0, index_1.useSessionStorage)("weixinLoginData", JSON.stringify(resobj));
127
118
  for (var key in data) {
128
119
  var item = data[key];
129
120
  if (item instanceof Object) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xctc-utils",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "description": "localStorage存储\r ```\r sessionStorage存储\r ```\r crypto-js加密、解密\r ```\r 微信授权登录、微信分享\r ```\r 设备环境获取\r ```\r 是否是微信浏览器\r ```\r 时间戳转时间,字符串转时间戳",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",