egova-admin-jssdk 0.0.7 → 0.0.9
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/service/index.js +3 -2
- package/lib/egova-admin-jssdk.mjs +24 -24
- package/package.json +1 -1
package/dist/service/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { adminAxios } from "../util/axios-util";
|
|
2
2
|
import { isNil } from "lodash-es";
|
|
3
3
|
import { saltData } from "../util/global";
|
|
4
|
-
import { crypto } from "
|
|
4
|
+
import { crypto } from "../util/crypto";
|
|
5
5
|
/**
|
|
6
6
|
* 获取部门人员
|
|
7
7
|
* @param params
|
|
@@ -55,7 +55,8 @@ export function getPublicKey() {
|
|
|
55
55
|
*/
|
|
56
56
|
export async function changeUserCryptogram(oldPwd, newPwd) {
|
|
57
57
|
if (!saltData.publicKey) {
|
|
58
|
-
const
|
|
58
|
+
const responseData = await getPublicKey();
|
|
59
|
+
const publicKeyRes = responseData.data;
|
|
59
60
|
if (publicKeyRes && !publicKeyRes.hasError) {
|
|
60
61
|
let data = publicKeyRes.result?.data || [];
|
|
61
62
|
if (data && data.length === 2) {
|
|
@@ -7,7 +7,7 @@ import A from "crypto-js";
|
|
|
7
7
|
import I from "qs";
|
|
8
8
|
import { toRaw as C } from "vue";
|
|
9
9
|
import { sm4 as E, sm2 as V } from "sm-crypto";
|
|
10
|
-
/*! egova-admin-jssdk v0.0.
|
|
10
|
+
/*! egova-admin-jssdk v0.0.9 */
|
|
11
11
|
function f(r) {
|
|
12
12
|
return r instanceof Element ? "element" : Object.prototype.toString.call(r).replace(/\[object\s(.+)\]/, "$1").toLowerCase();
|
|
13
13
|
}
|
|
@@ -25,7 +25,7 @@ class N {
|
|
|
25
25
|
*/
|
|
26
26
|
randomStr(t) {
|
|
27
27
|
const e = Math.ceil(t / 2), n = new Uint8Array(e);
|
|
28
|
-
return window.crypto.getRandomValues(n), Array.from(n).map((
|
|
28
|
+
return window.crypto.getRandomValues(n), Array.from(n).map((c) => c.toString(16).padStart(2, "0")).join("").substr(0, t);
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
31
|
* 随机生成len长度的纯数字字符串,比如randomNumberStr(16)得到 "1842442170233672"
|
|
@@ -44,12 +44,12 @@ class N {
|
|
|
44
44
|
* @param len
|
|
45
45
|
*/
|
|
46
46
|
getRandomPassword(t) {
|
|
47
|
-
const e = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", n = "abcdefghijklmnopqrstuvwxyz", o = "0123456789", s = ".~!@#$%^&*)(_+}{|:?><",
|
|
48
|
-
let
|
|
49
|
-
|
|
50
|
-
for (let
|
|
51
|
-
|
|
52
|
-
return
|
|
47
|
+
const e = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", n = "abcdefghijklmnopqrstuvwxyz", o = "0123456789", s = ".~!@#$%^&*)(_+}{|:?><", c = e + n + o + s;
|
|
48
|
+
let i = "";
|
|
49
|
+
i += this.getRandomChar(e), i += this.getRandomChar(n), i += this.getRandomChar(o), i += this.getRandomChar(s);
|
|
50
|
+
for (let a = i.length; a < t; a++)
|
|
51
|
+
i += this.getRandomChar(c);
|
|
52
|
+
return i = i.split("").sort(() => U(!0) - 0.5).join(""), i;
|
|
53
53
|
}
|
|
54
54
|
getRandomChar(t) {
|
|
55
55
|
const e = Math.floor(U(!0) * t.length);
|
|
@@ -57,7 +57,7 @@ class N {
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
const k = new N();
|
|
60
|
-
class
|
|
60
|
+
class D {
|
|
61
61
|
/**
|
|
62
62
|
* 清除 url 中重复的斜杠
|
|
63
63
|
* @param url 链接地址
|
|
@@ -68,8 +68,8 @@ class H {
|
|
|
68
68
|
return t.replace(/([^:]|^)\/{2,}/g, "$1/");
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
const P = new
|
|
72
|
-
class
|
|
71
|
+
const P = new D();
|
|
72
|
+
class H {
|
|
73
73
|
constructor(t) {
|
|
74
74
|
/**
|
|
75
75
|
* 应用标识
|
|
@@ -138,8 +138,8 @@ class D {
|
|
|
138
138
|
const o = f(n);
|
|
139
139
|
if (o === "object") {
|
|
140
140
|
const s = Object.keys(n).sort();
|
|
141
|
-
s.length === 0 ? t.push(`${e}={}`) : s.forEach((
|
|
142
|
-
this.formatEncodeParam(t, e === "" ? `${
|
|
141
|
+
s.length === 0 ? t.push(`${e}={}`) : s.forEach((c) => {
|
|
142
|
+
this.formatEncodeParam(t, e === "" ? `${c}` : `${e}[${c}]`, n[c]);
|
|
143
143
|
});
|
|
144
144
|
} else o === "array" ? n.length === 0 ? t.push(`${e}=[]`) : n.forEach((s) => {
|
|
145
145
|
this.formatEncodeParam(t, `${e}[]`, s);
|
|
@@ -180,8 +180,8 @@ class D {
|
|
|
180
180
|
try {
|
|
181
181
|
const { pathname: e, origin: n } = new URL(t, window.location.origin), o = this.urlSearchParams(t), s = this.generateSignatureOption();
|
|
182
182
|
u(o, s);
|
|
183
|
-
const
|
|
184
|
-
t = `${n}${
|
|
183
|
+
const c = this.sortParamByKey(o), a = `${P.cleanUrl(`/${e}`)}?${c}`, m = this.cryptoHash(a);
|
|
184
|
+
t = `${n}${a}&signature=${m}`;
|
|
185
185
|
} catch {
|
|
186
186
|
console.error("签名失败,请使用有效的链接", t);
|
|
187
187
|
}
|
|
@@ -196,35 +196,35 @@ class D {
|
|
|
196
196
|
signatureConfig(t) {
|
|
197
197
|
var e, n, o, s;
|
|
198
198
|
try {
|
|
199
|
-
const
|
|
199
|
+
const i = ((e = t.method) == null ? void 0 : e.toUpperCase()) === "GET", a = C(t.data), m = a !== null && typeof a == "object", b = ((o = (n = t.headers) == null ? void 0 : n["Content-Type"]) == null ? void 0 : o.toString()) || "", O = b.includes("multipart/form-data");
|
|
200
200
|
let S = b.includes("application/json");
|
|
201
|
-
!
|
|
201
|
+
!i && !b && m && (S = !0), u(t, { headers: { "App-Id": this.appIdCode.id } });
|
|
202
202
|
const g = {}, j = this.urlSearchParams(t.url);
|
|
203
203
|
if (u(g, j), !h(t.params)) {
|
|
204
204
|
const l = C(t.params);
|
|
205
205
|
this.removeNilValue(l), t.params = l, u(g, I.parse(I.stringify(l)));
|
|
206
206
|
}
|
|
207
|
-
!h(
|
|
207
|
+
!h(a) && m && !O && !S && u(g, a);
|
|
208
208
|
const w = this.generateSignatureOption();
|
|
209
209
|
u(g, w);
|
|
210
210
|
let $ = this.sortParamByKey(g);
|
|
211
211
|
if (S) {
|
|
212
|
-
const l = JSON.stringify(
|
|
213
|
-
this.isStringOverKB(l, 128) || (m ? $ += this.formatEncodeValue(l) : $ += this.formatEncodeValue(
|
|
212
|
+
const l = JSON.stringify(a);
|
|
213
|
+
this.isStringOverKB(l, 128) || (m ? $ += this.formatEncodeValue(l) : $ += this.formatEncodeValue(a));
|
|
214
214
|
}
|
|
215
215
|
let x = "";
|
|
216
216
|
(s = t.url) != null && s.startsWith("http") ? x = t.url : x = `${t.baseURL}/${t.url || ""}`;
|
|
217
217
|
const { pathname: T } = new URL(x, window.location.origin), v = `${P.cleanUrl(`/${T}`)}?${$}`;
|
|
218
218
|
w.signature = this.cryptoHash(v), t.params = u({}, t.params, w);
|
|
219
|
-
} catch (
|
|
220
|
-
console.error("签名失败",
|
|
219
|
+
} catch (c) {
|
|
220
|
+
console.error("签名失败", c);
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
224
|
const z = {
|
|
225
225
|
id: "mis",
|
|
226
226
|
code: "c9d8e36df18ef01ff0da74e0bb13151c"
|
|
227
|
-
}, F = new
|
|
227
|
+
}, F = new H(z);
|
|
228
228
|
class M {
|
|
229
229
|
constructor() {
|
|
230
230
|
p(this, "axiosInstance");
|
|
@@ -335,7 +335,7 @@ function q() {
|
|
|
335
335
|
async function it(r, t) {
|
|
336
336
|
var o, s;
|
|
337
337
|
if (!d.publicKey) {
|
|
338
|
-
const i = await q();
|
|
338
|
+
const i = (await q()).data;
|
|
339
339
|
if (i && !i.hasError) {
|
|
340
340
|
let a = ((o = i.result) == null ? void 0 : o.data) || [];
|
|
341
341
|
a.length === 2 && (d.type = a[0], d.publicKey = a[1]);
|