xctc-utils 1.2.1 → 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 {
@@ -6,6 +6,7 @@ interface configOption {
6
6
  stateKey?: string;
7
7
  cryptoiv?: string;
8
8
  cryptokey?: string;
9
+ isPassLogin?: boolean;
9
10
  }
10
11
  export declare function weixinUrlCode(config: configOption): void;
11
12
  interface ShareConfig {
@@ -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,18 +106,15 @@ function weixinLogin(code) {
105
106
  if (!http)
106
107
  return;
107
108
  (0, index_1.useSessionStorage)("weixinLoginParams", JSON.stringify(obj));
109
+ // 调试字段 isPassLogin ,为true 时不继续执行微信登录,前端可拿到 code 给后端测试
110
+ if (weixinConfig === null || weixinConfig === void 0 ? void 0 : weixinConfig.isPassLogin)
111
+ return;
108
112
  weixinConfig.http(obj).then(function (res) {
109
113
  if (res.code == 40163) {
110
114
  // 未登录则先执行登录
111
115
  return weixinCode();
112
116
  }
113
117
  var data = res === null || res === void 0 ? void 0 : res.data;
114
- if (data instanceof Object) {
115
- (0, index_1.useSessionStorage)("weixinLoginData", JSON.stringify(data));
116
- }
117
- else {
118
- (0, index_1.useSessionStorage)("weixinLoginStatus", "\u5FAE\u4FE1\u767B\u5F55\u5931\u8D25\uFF1A".concat(res.code, "\uFF1B").concat(res.msg));
119
- }
120
118
  for (var key in data) {
121
119
  var item = data[key];
122
120
  if (item instanceof Object) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xctc-utils",
3
- "version": "1.2.1",
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",