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.
@@ -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 "@/util/crypto";
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 publicKeyRes = await getPublicKey();
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.7 */
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((i) => i.toString(16).padStart(2, "0")).join("").substr(0, t);
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 = ".~!@#$%^&*)(_+}{|:?><", i = e + n + o + s;
48
- let a = "";
49
- a += this.getRandomChar(e), a += this.getRandomChar(n), a += this.getRandomChar(o), a += this.getRandomChar(s);
50
- for (let c = a.length; c < t; c++)
51
- a += this.getRandomChar(i);
52
- return a = a.split("").sort(() => U(!0) - 0.5).join(""), a;
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 H {
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 H();
72
- class D {
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((i) => {
142
- this.formatEncodeParam(t, e === "" ? `${i}` : `${e}[${i}]`, n[i]);
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 i = this.sortParamByKey(o), c = `${P.cleanUrl(`/${e}`)}?${i}`, m = this.cryptoHash(c);
184
- t = `${n}${c}&signature=${m}`;
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 a = ((e = t.method) == null ? void 0 : e.toUpperCase()) === "GET", c = C(t.data), m = c !== null && typeof c == "object", b = ((o = (n = t.headers) == null ? void 0 : n["Content-Type"]) == null ? void 0 : o.toString()) || "", O = b.includes("multipart/form-data");
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
- !a && !b && m && (S = !0), u(t, { headers: { "App-Id": this.appIdCode.id } });
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(c) && m && !O && !S && u(g, c);
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(c);
213
- this.isStringOverKB(l, 128) || (m ? $ += this.formatEncodeValue(l) : $ += this.formatEncodeValue(c));
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 (i) {
220
- console.error("签名失败", i);
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 D(z);
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]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "egova-admin-jssdk",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "build": "run-p type-check build-lib build-type",