iboot-http-client 1.0.3 → 1.0.5
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/iboot-http-client.cjs.js +1 -1
- package/dist/iboot-http-client.cjs.js.map +1 -1
- package/dist/iboot-http-client.es.js +140 -126
- package/dist/iboot-http-client.es.js.map +1 -1
- package/dist/iboot-http-client.umd.js +1 -1
- package/dist/iboot-http-client.umd.js.map +1 -1
- package/dist/types/http-client.d.ts +3 -2
- package/package.json +61 -61
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import C from "js-md5";
|
|
2
|
-
import
|
|
2
|
+
import p from "crypto-js";
|
|
3
3
|
import N from "pino";
|
|
4
|
-
const
|
|
4
|
+
const M = {
|
|
5
5
|
GENERAL: 0,
|
|
6
6
|
PHONE: 1,
|
|
7
7
|
EMAIL: 2
|
|
@@ -9,7 +9,7 @@ const $ = {
|
|
|
9
9
|
TYPE_MGT: 0,
|
|
10
10
|
TYPE_C: 1,
|
|
11
11
|
TYPE_B: 2
|
|
12
|
-
},
|
|
12
|
+
}, $ = {
|
|
13
13
|
FROM_WEB: 1,
|
|
14
14
|
FROM_PC: 2,
|
|
15
15
|
FROM_WX_MINI_PRO: 3,
|
|
@@ -17,23 +17,23 @@ const $ = {
|
|
|
17
17
|
FROM_WX_E: 5,
|
|
18
18
|
FROM_APP: 6,
|
|
19
19
|
FROM_DEVICE: 7
|
|
20
|
-
},
|
|
20
|
+
}, W = {
|
|
21
21
|
unknown: 0,
|
|
22
22
|
male: 1,
|
|
23
23
|
female: 2
|
|
24
|
-
},
|
|
25
|
-
const t =
|
|
24
|
+
}, E = (n) => Array.isArray(n) || typeof n == "object" && Object.prototype.toString.call(n) === "[object Array]", I = (n) => {
|
|
25
|
+
const t = n, e = "ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678", r = e.length;
|
|
26
26
|
let s = "";
|
|
27
|
-
for (let
|
|
27
|
+
for (let o = 0; o < t; o++)
|
|
28
28
|
s += e.charAt(Math.floor(Math.random() * r));
|
|
29
29
|
return s;
|
|
30
|
-
}, R = (
|
|
30
|
+
}, R = (n, t) => {
|
|
31
31
|
const e = {};
|
|
32
|
-
return
|
|
33
|
-
const
|
|
34
|
-
|
|
32
|
+
return n.split("&").forEach((s) => {
|
|
33
|
+
const o = s.split("=");
|
|
34
|
+
o[1] && (e[o[0]] = o[1]);
|
|
35
35
|
}), e;
|
|
36
|
-
}, m = (
|
|
36
|
+
}, m = (n) => n == null || n == "" || n.length == 0 ? "" : encodeURIComponent(n).replace(/\(/g, "%28").replace(/\)/g, "%29").replace(/\'/g, "%27").replace(/\!/g, "%21").replace(/\~/g, "%7E"), U = "zh-CN", T = "_device_id_key", _ = "_current_website_key", w = "Get request error!", b = "Post request error!", y = {
|
|
37
37
|
"Device-Id": "Device-Id",
|
|
38
38
|
Lang: "Lang",
|
|
39
39
|
"Website-Id": "Website-Id",
|
|
@@ -46,22 +46,22 @@ const $ = {
|
|
|
46
46
|
token: "token",
|
|
47
47
|
user: "user"
|
|
48
48
|
}, O = () => {
|
|
49
|
-
const
|
|
50
|
-
return
|
|
51
|
-
},
|
|
52
|
-
localStorage.setItem(T,
|
|
53
|
-
}, k = async (
|
|
49
|
+
const n = localStorage.getItem(T) ?? "", t = localStorage.getItem(_), e = t != null ? JSON.parse(t) : null, r = {};
|
|
50
|
+
return n.length > 0 && (r["Device-Id"] = n), e && (r.Lang = e.language, e.websiteId && (r["Website-Id"] = e.websiteId), e.websiteNo && (r["Website-No"] = e.websiteNo)), r;
|
|
51
|
+
}, x = (n, t) => {
|
|
52
|
+
localStorage.setItem(T, n), t && localStorage.setItem(_, JSON.stringify(t));
|
|
53
|
+
}, k = async (n, t) => {
|
|
54
54
|
if (t?.data) {
|
|
55
|
-
const
|
|
56
|
-
|
|
55
|
+
const o = new URLSearchParams(t.data);
|
|
56
|
+
n.indexOf("?") != -1 ? n += `&${o}` : n += `?${o}`;
|
|
57
57
|
}
|
|
58
58
|
const e = O(), r = t?.heads;
|
|
59
59
|
if (r)
|
|
60
|
-
for (const
|
|
61
|
-
const c = r[
|
|
62
|
-
c && (e[
|
|
60
|
+
for (const o in r) {
|
|
61
|
+
const c = r[o];
|
|
62
|
+
c && (e[o] = c);
|
|
63
63
|
}
|
|
64
|
-
const s = await fetch(
|
|
64
|
+
const s = await fetch(n, {
|
|
65
65
|
method: "GET",
|
|
66
66
|
headers: e,
|
|
67
67
|
cache: t?.useCache ? "force-cache" : "default"
|
|
@@ -71,27 +71,18 @@ const $ = {
|
|
|
71
71
|
success: !1,
|
|
72
72
|
msg: s.statusText
|
|
73
73
|
};
|
|
74
|
-
},
|
|
75
|
-
const e = await k(o, t);
|
|
76
|
-
if (e.success)
|
|
77
|
-
return e.data;
|
|
78
|
-
if (t?.showError) {
|
|
79
|
-
t.showError(e.msg ?? w);
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
throw Error(e.msg ?? w);
|
|
83
|
-
}, S = async (o, t) => {
|
|
74
|
+
}, S = async (n, t) => {
|
|
84
75
|
const e = t?.data ?? {}, r = t?.heads;
|
|
85
76
|
let s;
|
|
86
|
-
const
|
|
87
|
-
if (e instanceof FormData ? s = e : (s = JSON.stringify(e),
|
|
77
|
+
const o = new Headers(O());
|
|
78
|
+
if (e instanceof FormData ? s = e : (s = JSON.stringify(e), o.set("Content-Type", "application/json")), r)
|
|
88
79
|
for (let l in r) {
|
|
89
80
|
const i = r[l];
|
|
90
|
-
i &&
|
|
81
|
+
i && o.set(l, i);
|
|
91
82
|
}
|
|
92
|
-
const c = await fetch(
|
|
83
|
+
const c = await fetch(n, {
|
|
93
84
|
method: "POST",
|
|
94
|
-
headers:
|
|
85
|
+
headers: o,
|
|
95
86
|
body: s
|
|
96
87
|
});
|
|
97
88
|
return c.ok ? await c.json() : {
|
|
@@ -99,27 +90,37 @@ const $ = {
|
|
|
99
90
|
success: !1,
|
|
100
91
|
msg: c.statusText
|
|
101
92
|
};
|
|
102
|
-
},
|
|
103
|
-
const e = await
|
|
93
|
+
}, j = async (n, t) => {
|
|
94
|
+
const e = await k(n, t);
|
|
104
95
|
if (e.success)
|
|
105
96
|
return e.data;
|
|
106
97
|
if (t?.showError) {
|
|
107
|
-
t.showError(e.msg ??
|
|
98
|
+
t.showError(e.msg ?? w);
|
|
108
99
|
return;
|
|
109
100
|
}
|
|
110
|
-
throw Error(e.msg ??
|
|
111
|
-
},
|
|
112
|
-
const e = await S(
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
101
|
+
throw Error(e.msg ?? w);
|
|
102
|
+
}, K = async (n, t) => {
|
|
103
|
+
const e = await S(n, t);
|
|
104
|
+
if (e.success)
|
|
105
|
+
return e.data;
|
|
106
|
+
if (t?.showError) {
|
|
107
|
+
t.showError(e.msg ?? b);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
throw Error(e.msg ?? b);
|
|
111
|
+
}, F = async (n, t) => {
|
|
112
|
+
const e = await S(n, t);
|
|
113
|
+
return e.success ? (t?.showSuccess && t.showSuccess(e.msg ?? "SUCCESS"), !0) : (t?.showError && t.showError(e.msg ?? b), !1);
|
|
114
|
+
}, H = (n) => {
|
|
115
|
+
const t = n.headers.get(y["Device-Id"]), e = n.headers.get(y.Lang), r = n.headers.get(y["Website-Id"]), s = n.headers.get(y["Website-No"]), o = {};
|
|
116
|
+
return t && t.length > 0 && (o.deviceId = t), e && e.length > 0 && (o.lang = e), r && r.length > 0 && (o.websiteId = r), s && s.length > 0 && (o.websiteNo = s), o;
|
|
117
|
+
}, G = (n) => {
|
|
118
|
+
const t = {}, e = n.get(h.IBOOT_DEVICE_ID)?.value, r = n.get(h.IBOOT_LOCALE)?.value, s = n.get(h.IBOOT_WEBSITE_ID)?.value, o = n.get(h.IBOOT_WEBSITE_NO)?.value;
|
|
119
|
+
return e && e.length > 0 && (t.deviceId = e), r && r.length > 0 && (t.lang = r), s && s.length > 0 && (t.websiteId = s), o && o.length > 0 && (t.websiteNo = o), t;
|
|
120
120
|
};
|
|
121
121
|
class J {
|
|
122
122
|
baseUrl;
|
|
123
|
+
helloMethod;
|
|
123
124
|
apiKey;
|
|
124
125
|
userType;
|
|
125
126
|
userFrom;
|
|
@@ -130,8 +131,8 @@ class J {
|
|
|
130
131
|
websiteNo;
|
|
131
132
|
_isDebug;
|
|
132
133
|
logger;
|
|
133
|
-
constructor({ deviceId: t, lang: e, websiteId: r, websiteNo: s, userType:
|
|
134
|
-
this.baseUrl = process.env.BASE_URL ?? "", this.apiKey = process.env.API_KEY ?? "", this.userType =
|
|
134
|
+
constructor({ deviceId: t, lang: e, websiteId: r, websiteNo: s, userType: o }) {
|
|
135
|
+
this.baseUrl = process.env.BASE_URL ?? "", this.helloMethod = process.env.HELLO_URL ?? "", this.apiKey = process.env.API_KEY ?? "", this.userType = o ?? A.TYPE_MGT, this.userFrom = process.env.USER_FROM || "1", this.deviceId = t ?? I(10), this.lang = e ?? U, this.websiteId = r, this.websiteNo = s, this._isDebug = process.env.NODE_ENV != "production", this.logger = N({
|
|
135
136
|
name: "iboot",
|
|
136
137
|
level: this._isDebug ? "debug" : "info",
|
|
137
138
|
nestedKey: "payload"
|
|
@@ -141,14 +142,14 @@ class J {
|
|
|
141
142
|
return this._isDebug;
|
|
142
143
|
}
|
|
143
144
|
encrypt(t) {
|
|
144
|
-
const e =
|
|
145
|
-
return
|
|
145
|
+
const e = p.enc.Utf8.parse(this.apiKey);
|
|
146
|
+
return p.AES.encrypt(t, e).toString();
|
|
146
147
|
}
|
|
147
148
|
decrypt(t) {
|
|
148
|
-
const e =
|
|
149
|
-
return
|
|
150
|
-
mode:
|
|
151
|
-
}).toString(
|
|
149
|
+
const e = p.enc.Utf8.parse(this.apiKey);
|
|
150
|
+
return p.AES.decrypt(t, e, {
|
|
151
|
+
mode: p.mode.ECB
|
|
152
|
+
}).toString(p.enc.Utf8);
|
|
152
153
|
}
|
|
153
154
|
getDeviceId() {
|
|
154
155
|
return this.deviceId;
|
|
@@ -161,37 +162,37 @@ class J {
|
|
|
161
162
|
if (s && typeof s == "string")
|
|
162
163
|
s = s.trim();
|
|
163
164
|
else if (s && typeof s == "object") {
|
|
164
|
-
if (
|
|
165
|
+
if (E(s)) {
|
|
165
166
|
if (s.length === 0)
|
|
166
167
|
continue;
|
|
167
|
-
for (let
|
|
168
|
-
const c = s[
|
|
168
|
+
for (let o = 0; o < s.length; o++) {
|
|
169
|
+
const c = s[o];
|
|
169
170
|
for (const l in c) {
|
|
170
171
|
const i = c[l] ?? void 0;
|
|
171
172
|
if (i) {
|
|
172
173
|
if (typeof i == "object")
|
|
173
|
-
|
|
174
|
+
E(i) && i.forEach((a, d) => {
|
|
174
175
|
if (a)
|
|
175
|
-
for (const
|
|
176
|
-
const u = a[
|
|
176
|
+
for (const g in a) {
|
|
177
|
+
const u = a[g];
|
|
177
178
|
if (u && u.toString().length > 0) {
|
|
178
|
-
const
|
|
179
|
-
e.push(r +
|
|
179
|
+
const f = `[${o.toString()}].${l + `[${d.toString()}].${g}`}=${m(u)}`;
|
|
180
|
+
e.push(r + f);
|
|
180
181
|
}
|
|
181
182
|
}
|
|
182
183
|
});
|
|
183
184
|
else if (i.toString().length > 0) {
|
|
184
|
-
const a = `[${
|
|
185
|
+
const a = `[${o.toString()}].${l}=${m(i.toString())}`;
|
|
185
186
|
e.push(r + a);
|
|
186
187
|
}
|
|
187
188
|
}
|
|
188
189
|
}
|
|
189
190
|
}
|
|
190
191
|
} else
|
|
191
|
-
for (const
|
|
192
|
-
const c = s[
|
|
192
|
+
for (const o in s) {
|
|
193
|
+
const c = s[o];
|
|
193
194
|
if (c != null && c != "" && c.length != 0) {
|
|
194
|
-
const l = `.${
|
|
195
|
+
const l = `.${o}=${m(c)}`;
|
|
195
196
|
e.push(r + l);
|
|
196
197
|
}
|
|
197
198
|
}
|
|
@@ -211,8 +212,8 @@ class J {
|
|
|
211
212
|
let a = t[i];
|
|
212
213
|
typeof a == "object" && (a = JSON.stringify(a)), s.push(i + "=" + a);
|
|
213
214
|
});
|
|
214
|
-
const
|
|
215
|
-
params:
|
|
215
|
+
const o = s.join("&"), c = C.md5((o + e).toLocaleUpperCase()), l = {
|
|
216
|
+
params: o,
|
|
216
217
|
md5: c
|
|
217
218
|
};
|
|
218
219
|
return this.logger.debug(l), c;
|
|
@@ -227,39 +228,54 @@ class J {
|
|
|
227
228
|
"Content-Type": "application/x-www-form-urlencoded",
|
|
228
229
|
"Res-Type": "json",
|
|
229
230
|
"Device-Id": this.deviceId,
|
|
230
|
-
Lang: this.lang,
|
|
231
231
|
"User-Type": e?.utype.toString() ?? this.userType.toString(),
|
|
232
232
|
"User-From": this.userFrom,
|
|
233
233
|
"Api-Key": this.apiKey
|
|
234
234
|
};
|
|
235
|
-
this.websiteId && this.websiteId.length > 0 && (r["Web-Id"] = this.websiteId), this.websiteNo && this.websiteNo.length > 0 && (r["Web-No"] = this.websiteNo), e && (e.token && e.token.length > 0 && e.username && e.username.length > 0 && (r.Authorization = e.token, r.Username = e.username), e.xcsrf && (r[e.xcsrf.csrfHeader] = e.xcsrf.csrfToken));
|
|
236
|
-
const s = R(t),
|
|
237
|
-
return r.Sign =
|
|
235
|
+
this.lang && this.lang.length > 0 && (r.Lang = this.lang), this.websiteId && this.websiteId.length > 0 && (r["Web-Id"] = this.websiteId), this.websiteNo && this.websiteNo.length > 0 && (r["Web-No"] = this.websiteNo), e && (e.token && e.token.length > 0 && e.username && e.username.length > 0 && (r.Authorization = e.token, r.Username = e.username), e.xcsrf && (r[e.xcsrf.csrfHeader] = e.xcsrf.csrfToken));
|
|
236
|
+
const s = R(t), o = await this.sign(s);
|
|
237
|
+
return r.Sign = o, r;
|
|
238
238
|
}
|
|
239
239
|
async helloIboot() {
|
|
240
|
-
|
|
241
|
-
if (t.length === 0)
|
|
240
|
+
if (this.helloMethod.length <= 0)
|
|
242
241
|
return this.apiKey;
|
|
243
|
-
const
|
|
242
|
+
const t = this.getApiUrl(this.helloMethod), e = {
|
|
244
243
|
"Content-Type": "application/x-www-form-urlencoded",
|
|
245
244
|
"Res-Type": "json",
|
|
246
245
|
"Api-Key": this.apiKey
|
|
247
|
-
},
|
|
246
|
+
}, r = {
|
|
247
|
+
url: t,
|
|
248
|
+
headers: e
|
|
249
|
+
};
|
|
250
|
+
this.logger.debug(r);
|
|
251
|
+
const s = await fetch(t, {
|
|
248
252
|
method: "GET",
|
|
249
|
-
headers:
|
|
253
|
+
headers: e,
|
|
250
254
|
credentials: "include",
|
|
251
255
|
cache: "force-cache"
|
|
252
256
|
});
|
|
253
|
-
if (s.ok)
|
|
254
|
-
|
|
257
|
+
if (s.ok) {
|
|
258
|
+
const o = await s.json();
|
|
259
|
+
return this.logger.debug({ result: o.data }), o.data;
|
|
260
|
+
}
|
|
255
261
|
throw new Error("hello iBoot error!");
|
|
256
262
|
}
|
|
257
263
|
getApiUrl(t) {
|
|
258
264
|
return `${this.baseUrl}/${t}`;
|
|
259
265
|
}
|
|
266
|
+
async csrf() {
|
|
267
|
+
const t = await this.get({
|
|
268
|
+
url: "guest/csrf"
|
|
269
|
+
});
|
|
270
|
+
if (t.success) {
|
|
271
|
+
const e = t.data;
|
|
272
|
+
if (e)
|
|
273
|
+
return e.csrfToken.toString();
|
|
274
|
+
}
|
|
275
|
+
}
|
|
260
276
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
261
277
|
async get({ url: t, data: e, token: r }) {
|
|
262
|
-
const s = this.assemblyParameter(e),
|
|
278
|
+
const s = this.assemblyParameter(e), o = this.convertUrlParameter(s), c = await this.assemblyHeader({ urlParams: o, token: r }), l = `${this.getApiUrl(t)}?${o.toString()}`, i = {
|
|
263
279
|
method: "GET",
|
|
264
280
|
url: l,
|
|
265
281
|
headers: c
|
|
@@ -272,7 +288,11 @@ class J {
|
|
|
272
288
|
credentials: "include",
|
|
273
289
|
cache: "force-cache"
|
|
274
290
|
});
|
|
275
|
-
|
|
291
|
+
if (a.ok) {
|
|
292
|
+
const d = await a.json();
|
|
293
|
+
return this.logger.debug({ result: d.data }), d;
|
|
294
|
+
}
|
|
295
|
+
return {
|
|
276
296
|
code: a.status,
|
|
277
297
|
success: !1,
|
|
278
298
|
msg: a.statusText
|
|
@@ -285,65 +305,59 @@ class J {
|
|
|
285
305
|
};
|
|
286
306
|
}
|
|
287
307
|
}
|
|
288
|
-
async csrf() {
|
|
289
|
-
const t = await this.get({
|
|
290
|
-
url: "guest/csrf"
|
|
291
|
-
});
|
|
292
|
-
if (t.success) {
|
|
293
|
-
const e = t.data;
|
|
294
|
-
if (e)
|
|
295
|
-
return e.csrfToken.toString();
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
308
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
299
309
|
async post({ url: t, data: e, token: r }) {
|
|
300
310
|
e = e ? { ...e } : {};
|
|
301
|
-
const s = e.buffer ?? void 0,
|
|
302
|
-
s && delete e.buffer,
|
|
311
|
+
const s = e.buffer ?? void 0, o = e.boundary ?? void 0;
|
|
312
|
+
s && delete e.buffer, o && delete e.boundary;
|
|
303
313
|
const c = this.assemblyParameter(e), l = this.convertUrlParameter(c), i = await this.assemblyHeader({ urlParams: l, token: r });
|
|
304
|
-
s &&
|
|
305
|
-
const a = this.getApiUrl(t),
|
|
314
|
+
s && o && (i["Content-Type"] = `multipart/form-data; boundary=${o}`);
|
|
315
|
+
const a = this.getApiUrl(t), d = {
|
|
306
316
|
method: "POST",
|
|
307
317
|
url: a,
|
|
308
318
|
headers: i
|
|
309
319
|
};
|
|
310
|
-
this.logger.info(
|
|
320
|
+
this.logger.info(d);
|
|
311
321
|
try {
|
|
312
|
-
const
|
|
322
|
+
const g = s ? `${a}?${l}` : a, u = await fetch(g, {
|
|
313
323
|
method: "POST",
|
|
314
324
|
headers: i,
|
|
315
325
|
body: s || l.toString(),
|
|
316
326
|
credentials: "include"
|
|
317
327
|
});
|
|
318
|
-
|
|
328
|
+
if (u.ok) {
|
|
329
|
+
const f = await u.json();
|
|
330
|
+
return this.logger.debug({ result: f.data }), f;
|
|
331
|
+
}
|
|
332
|
+
return {
|
|
319
333
|
code: u.status,
|
|
320
334
|
success: !1,
|
|
321
335
|
msg: u.statusText
|
|
322
336
|
};
|
|
323
|
-
} catch (
|
|
337
|
+
} catch (g) {
|
|
324
338
|
return {
|
|
325
339
|
code: 500,
|
|
326
340
|
success: !1,
|
|
327
|
-
msg:
|
|
341
|
+
msg: g?.toString() ?? "Server exception!"
|
|
328
342
|
};
|
|
329
343
|
}
|
|
330
344
|
}
|
|
331
345
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
332
346
|
async stream({ url: t, data: e, token: r }) {
|
|
333
347
|
e = e ? { ...e } : {};
|
|
334
|
-
const s = e.buffer ?? void 0,
|
|
335
|
-
s && delete e.buffer,
|
|
348
|
+
const s = e.buffer ?? void 0, o = e.boundary ?? void 0;
|
|
349
|
+
s && delete e.buffer, o && delete e.boundary;
|
|
336
350
|
const c = this.assemblyParameter(e), l = this.convertUrlParameter(c), i = await this.assemblyHeader({ urlParams: l, token: r });
|
|
337
|
-
s &&
|
|
351
|
+
s && o && (i["Content-Type"] = `multipart/form-data; boundary=${o}`), i.Connection = "keep-alive", i["X-Accel-Buffering"] = "no", i["Cache-Control"] = "no-cache";
|
|
338
352
|
const a = this.getApiUrl(t);
|
|
339
353
|
try {
|
|
340
|
-
const
|
|
354
|
+
const d = s ? `${a}?${l}` : a, g = {
|
|
341
355
|
method: "POST",
|
|
342
356
|
url: a,
|
|
343
357
|
headers: i
|
|
344
358
|
};
|
|
345
|
-
this.logger.info(
|
|
346
|
-
const u = await fetch(
|
|
359
|
+
this.logger.info(g);
|
|
360
|
+
const u = await fetch(d, {
|
|
347
361
|
method: "POST",
|
|
348
362
|
headers: i,
|
|
349
363
|
body: s || l.toString(),
|
|
@@ -360,8 +374,8 @@ class J {
|
|
|
360
374
|
Connection: "keep-alive"
|
|
361
375
|
}
|
|
362
376
|
});
|
|
363
|
-
} catch (
|
|
364
|
-
throw
|
|
377
|
+
} catch (d) {
|
|
378
|
+
throw d;
|
|
365
379
|
}
|
|
366
380
|
}
|
|
367
381
|
getUserInfo(t) {
|
|
@@ -372,8 +386,8 @@ class J {
|
|
|
372
386
|
const e = t.get("user")?.value;
|
|
373
387
|
let r = "", s = this.userType;
|
|
374
388
|
if (e && e.length > 0) {
|
|
375
|
-
const
|
|
376
|
-
r =
|
|
389
|
+
const o = JSON.parse(e);
|
|
390
|
+
r = o.username, s = o.userType.toString();
|
|
377
391
|
}
|
|
378
392
|
return {
|
|
379
393
|
username: r,
|
|
@@ -385,8 +399,8 @@ class J {
|
|
|
385
399
|
const e = t.get("user")?.value;
|
|
386
400
|
let r = "", s = this.userType;
|
|
387
401
|
if (e && e.length > 0) {
|
|
388
|
-
const
|
|
389
|
-
r =
|
|
402
|
+
const o = JSON.parse(e);
|
|
403
|
+
r = o.username, s = o.userType.toString();
|
|
390
404
|
}
|
|
391
405
|
return {
|
|
392
406
|
username: r,
|
|
@@ -396,17 +410,17 @@ class J {
|
|
|
396
410
|
};
|
|
397
411
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
398
412
|
setToken(t, e) {
|
|
399
|
-
const { id: r, name: s, username:
|
|
413
|
+
const { id: r, name: s, username: o, nickname: c, sex: l, headImg: i, token: a, lastLoginTime: d, tokenExpired: g, deviceId: u, userType: f, mustChangePwd: v } = t, P = {
|
|
400
414
|
id: r,
|
|
401
415
|
name: s,
|
|
402
|
-
username:
|
|
416
|
+
username: o,
|
|
403
417
|
nickname: c,
|
|
404
418
|
sex: l,
|
|
405
419
|
headImg: i,
|
|
406
|
-
lastLoginTime:
|
|
407
|
-
tokenExpired:
|
|
420
|
+
lastLoginTime: d,
|
|
421
|
+
tokenExpired: g,
|
|
408
422
|
deviceId: u,
|
|
409
|
-
userType:
|
|
423
|
+
userType: f,
|
|
410
424
|
status: 0,
|
|
411
425
|
accountType: 0,
|
|
412
426
|
enabled: !1,
|
|
@@ -441,13 +455,13 @@ class J {
|
|
|
441
455
|
}
|
|
442
456
|
}
|
|
443
457
|
export {
|
|
444
|
-
|
|
458
|
+
M as ACCOUNT_TYPE_MAP,
|
|
445
459
|
_ as CURRENT_WEBSITE_KEY,
|
|
446
460
|
U as DEFAULT_LOCALE,
|
|
447
461
|
T as DEVICE_ID_KEY,
|
|
448
462
|
J as HttpClient,
|
|
449
|
-
|
|
450
|
-
|
|
463
|
+
$ as USER_FORM_MAP,
|
|
464
|
+
W as USER_SEX_MAP,
|
|
451
465
|
A as USER_TYPE_MAP,
|
|
452
466
|
k as get,
|
|
453
467
|
H as getHttpClientOpts,
|
|
@@ -456,6 +470,6 @@ export {
|
|
|
456
470
|
K as iPost,
|
|
457
471
|
F as iPostSuccess,
|
|
458
472
|
S as post,
|
|
459
|
-
|
|
473
|
+
x as setDefaultRequestHeader
|
|
460
474
|
};
|
|
461
475
|
//# sourceMappingURL=iboot-http-client.es.js.map
|