xctc-utils 1.2.8 → 1.3.0
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/dist/crypto/index.js +0 -3
- package/dist/weixin/index.js +20 -7
- package/package.json +1 -1
package/dist/crypto/index.js
CHANGED
|
@@ -6,7 +6,6 @@ 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");
|
|
10
9
|
function formatVal(val) {
|
|
11
10
|
var key = "5uMz4R8r0926DkC8";
|
|
12
11
|
if (val)
|
|
@@ -37,9 +36,7 @@ function decrypt(word, key, iv) {
|
|
|
37
36
|
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 });
|
|
38
37
|
var decryptedStr = decrypt.toString(crypto_js_1.default.enc.Utf8);
|
|
39
38
|
var data = decryptedStr.toString();
|
|
40
|
-
(0, index_1.useSessionStorage)("decryptData", data);
|
|
41
39
|
if ((0, utils_1.isJson)(data)) {
|
|
42
|
-
(0, index_1.useSessionStorage)("decryptData2222", JSON.stringify(data));
|
|
43
40
|
return JSON.parse(data);
|
|
44
41
|
}
|
|
45
42
|
else {
|
package/dist/weixin/index.js
CHANGED
|
@@ -18,8 +18,10 @@ function weixinUrlCode(config) {
|
|
|
18
18
|
var search = loc.search; // ?code=0916SzFa1KH9TA0Ke7Ha1AQx6446SzFr&state=123
|
|
19
19
|
// 获取地址栏返回 code 参数
|
|
20
20
|
var codeKey = weixinConfig['codeKey'];
|
|
21
|
-
if (!codeKey)
|
|
21
|
+
if (!codeKey) {
|
|
22
22
|
codeKey = "weixinCode";
|
|
23
|
+
weixinConfig['codeKey'] = codeKey;
|
|
24
|
+
}
|
|
23
25
|
var localCode = "";
|
|
24
26
|
if (codeKey)
|
|
25
27
|
localCode = (0, index_1.getSessionStorage)(codeKey);
|
|
@@ -64,12 +66,14 @@ function weixinUrlCode(config) {
|
|
|
64
66
|
var item = urlArr[k];
|
|
65
67
|
if (item.indexOf("state=") != -1) {
|
|
66
68
|
hrefState = item.substr(6);
|
|
67
|
-
var stateKey = weixinConfig['stateKey']
|
|
69
|
+
var stateKey = weixinConfig['stateKey'];
|
|
70
|
+
if (!stateKey) {
|
|
71
|
+
stateKey = "weixinState";
|
|
72
|
+
weixinConfig['stateKey'] = stateKey;
|
|
73
|
+
}
|
|
68
74
|
(0, index_1.useSessionStorage)(stateKey, hrefState);
|
|
69
75
|
var cryptoObj = cryptoConfig(cryptokey, cryptoiv);
|
|
70
|
-
(0, index_1.useSessionStorage)("cryptoObj", cryptoObj);
|
|
71
76
|
var stateObj = (0, crypto_1.decrypt)(hrefState, cryptoObj.key, cryptoObj.iv);
|
|
72
|
-
(0, index_1.useSessionStorage)("".concat(stateKey, "Obj111111"), stateObj);
|
|
73
77
|
if (stateObj instanceof Object)
|
|
74
78
|
stateObj = JSON.stringify(stateObj);
|
|
75
79
|
(0, index_1.useSessionStorage)("".concat(stateKey, "Obj"), stateObj);
|
|
@@ -126,11 +130,14 @@ function weixinLogin(code) {
|
|
|
126
130
|
}
|
|
127
131
|
var url = loc.origin;
|
|
128
132
|
var hashVal = loc.hash;
|
|
129
|
-
var state = (0, index_1.getSessionStorage)(stateKey);
|
|
133
|
+
var state = (0, index_1.getSessionStorage)(stateKey) || "";
|
|
130
134
|
var str = "";
|
|
131
|
-
(0, index_1.useSessionStorage)("
|
|
135
|
+
(0, index_1.useSessionStorage)("getstatedata===", state);
|
|
132
136
|
if (state) {
|
|
137
|
+
(0, index_1.useSessionStorage)("stateKey===", "".concat(stateKey, "Obj"));
|
|
133
138
|
var stateObj = (0, index_1.getSessionStorage)("".concat(stateKey, "Obj"));
|
|
139
|
+
(0, index_1.useSessionStorage)("getstateObj===", stateObj);
|
|
140
|
+
(0, index_1.useSessionStorage)("url11111===", url);
|
|
134
141
|
for (var key in stateObj) {
|
|
135
142
|
if (key == "path") {
|
|
136
143
|
if (stateObj[key][0] == "/") {
|
|
@@ -139,6 +146,7 @@ function weixinLogin(code) {
|
|
|
139
146
|
else {
|
|
140
147
|
url = "".concat(url, "/#/").concat(stateObj.path);
|
|
141
148
|
}
|
|
149
|
+
(0, index_1.useSessionStorage)("url22222===", url);
|
|
142
150
|
}
|
|
143
151
|
else {
|
|
144
152
|
str += "".concat(key, "=").concat(stateObj[key], "&");
|
|
@@ -149,6 +157,7 @@ function weixinLogin(code) {
|
|
|
149
157
|
url = "".concat(url, "?").concat(str);
|
|
150
158
|
}
|
|
151
159
|
}
|
|
160
|
+
(0, index_1.useSessionStorage)("url333333===", url);
|
|
152
161
|
loc.replace(url);
|
|
153
162
|
}
|
|
154
163
|
else {
|
|
@@ -187,8 +196,12 @@ function weixinCode() {
|
|
|
187
196
|
if (!weixinConfig['appId'])
|
|
188
197
|
return;
|
|
189
198
|
var scope = "snsapi_userinfo";
|
|
190
|
-
if (weixinConfig['scope'])
|
|
199
|
+
if (weixinConfig['scope']) {
|
|
191
200
|
scope = weixinConfig['scope'];
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
weixinConfig['scope'] = scope;
|
|
204
|
+
}
|
|
192
205
|
var base = "https://open.weixin.qq.com/connect/oauth2/authorize?";
|
|
193
206
|
var uri = encodeURIComponent(loc.href.split("?")[0]);
|
|
194
207
|
var config = "appid=".concat(weixinConfig.appId, "&redirect_uri=").concat(uri, "&response_type=code&scope=").concat(scope, "&state=state#wechat_redirect");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xctc-utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
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",
|