module-develop-kit 1.3.0 → 1.4.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.
Files changed (43) hide show
  1. package/dist/commonjs-virtual-dir/index.js +5 -3
  2. package/dist/commonjs-virtual-dir/index2.js +3 -3
  3. package/dist/commonjs-virtual-dir/index3.js +2 -7
  4. package/dist/commonjs-virtual-dir/index4.js +4 -2
  5. package/dist/commonjs-virtual-dir/index5.js +2 -2
  6. package/dist/main.d.ts +74 -28
  7. package/dist/main.js +40 -35
  8. package/dist/src/outside-call/utils.js +1 -1
  9. package/dist/src/shield/crypto/const.js +2 -2
  10. package/dist/src/shield/crypto/sm2.js +4 -4
  11. package/dist/src/shield/crypto/util.js +11 -23
  12. package/dist/src/shield/gcm-crypto/gcm.service.js +29 -0
  13. package/dist/src/shield/gcm-crypto/hex.js +18 -0
  14. package/dist/src/shield/gcm-crypto/index.js +40 -0
  15. package/dist/src/shield/gcm-crypto/init.js +61 -0
  16. package/dist/src/shield/gcm-crypto/string.js +10 -0
  17. package/dist/src/utils/is.js +4 -0
  18. package/dist/src/vite-plugins/vite-plugin-sri/index.js +4 -1
  19. package/dist/src/vite-plugins/vite-plugin-sri/internal.js +52 -53
  20. package/dist/types/axios.d.ts +16 -0
  21. package/dist/vendor/@noble/ciphers/esm/_polyval.js +116 -0
  22. package/dist/vendor/@noble/ciphers/esm/utils.js +68 -0
  23. package/dist/vendor/@noble/curves/esm/abstract/curve.js +203 -0
  24. package/dist/vendor/@noble/curves/esm/abstract/modular.js +240 -0
  25. package/dist/vendor/@noble/curves/esm/abstract/utils.js +10 -0
  26. package/dist/vendor/@noble/curves/esm/abstract/weierstrass.js +791 -0
  27. package/dist/vendor/@noble/curves/esm/utils.js +154 -0
  28. package/dist/vendor/@noble/hashes/esm/crypto.js +4 -0
  29. package/dist/vendor/@noble/hashes/esm/hmac.js +45 -0
  30. package/dist/vendor/@noble/hashes/esm/utils.js +112 -0
  31. package/dist/vendor/ieee754/index.js +1 -1
  32. package/dist/vendor/sdp-transform/lib/index.js +1 -1
  33. package/dist/vendor/sm-crypto-v2/dist/index.js +1004 -0
  34. package/dist/vendor/token-types/lib/index.js +1 -1
  35. package/package.json +3 -2
  36. package/dist/commonjs-virtual-dir/index7.js +0 -4
  37. package/dist/commonjs-virtual-dir/index8.js +0 -4
  38. package/dist/src/shield/crypto/index.js +0 -53
  39. package/dist/src/shield/crypto/sm4.js +0 -15
  40. package/dist/vendor/base64-js/index.js +0 -52
  41. package/dist/vendor/gm-crypt/index.js +0 -10
  42. package/dist/vendor/gm-crypt/src/crypt.js +0 -60
  43. package/dist/vendor/gm-crypt/src/sm4.js +0 -513
@@ -1,4 +1,4 @@
1
- import "../../../commonjs-virtual-dir/index4.js";
1
+ import "../../../commonjs-virtual-dir/index3.js";
2
2
  import { textDecode as i } from "../../@borewit/text-codec/lib/index.js";
3
3
  function r(e) {
4
4
  return new DataView(e.buffer, e.byteOffset);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "module-develop-kit",
3
3
  "author": "Front-End team",
4
- "version": "1.3.0",
4
+ "version": "1.4.0",
5
5
  "type": "module",
6
6
  "description": "前端项目通用工具包",
7
7
  "module": "dist/main.js",
@@ -64,6 +64,7 @@
64
64
  "gm-crypt": "^0.0.2",
65
65
  "jssip": "^3.10.1",
66
66
  "nanoid": "^5.1.11",
67
- "sm-crypto": "^0.3.13"
67
+ "sm-crypto": "^0.3.13",
68
+ "sm-crypto-v2": "^1.15.1"
68
69
  }
69
70
  }
@@ -1,4 +0,0 @@
1
- var e = {};
2
- export {
3
- e as __exports
4
- };
@@ -1,4 +0,0 @@
1
- var s = {};
2
- export {
3
- s as __exports
4
- };
@@ -1,53 +0,0 @@
1
- import { s as m } from "../../../commonjs-virtual-dir/index.js";
2
- import { EHeaderKey as a } from "./const.js";
3
- import { sm2Encrypt as d, generateKeyPairHex as g, sm2Decrypt as u } from "./sm2.js";
4
- import { sm4Encrypt as K, sm4Decrypt as S } from "./sm4.js";
5
- import { hexToBase64 as f, generateRandomString as p, base64ToHex as E, dataToStr as v } from "./util.js";
6
- function $(o, c) {
7
- const e = p(), n = p(), t = {
8
- body: K(
9
- {
10
- key: e,
11
- iv: n
12
- },
13
- c
14
- )
15
- }, r = f(d(o, e));
16
- return {
17
- headers: {
18
- "X-Encrypted-Iv": n,
19
- "X-Encrypted-Key": r
20
- },
21
- data: t
22
- };
23
- }
24
- async function h(o) {
25
- const { publicKey: c, privateKey: e } = g(), { data: n, headers: t } = await o({ "X-Public-Key": c }), r = t[a.encryptIv] || t[a.encryptIvLow], s = t[a.encryptKey] || t[a.encryptKeyLow], y = u(e, E(s)), i = S(
26
- {
27
- iv: r,
28
- key: y
29
- },
30
- n
31
- );
32
- return JSON.parse(i);
33
- }
34
- function k({
35
- uid: o = "",
36
- salt: c = "",
37
- ts: e = 0,
38
- data: n = "",
39
- ...t
40
- }) {
41
- const r = Date.now() + e, s = Math.random().toString(36).substring(2, 15), y = `${r}${o}${s}${v(n)}${c}`, i = m.sm3(y);
42
- return {
43
- ...t,
44
- "X-Sign-Timestamp": String(r),
45
- "X-Sign-Nonce": s,
46
- "X-Sign-Client": i
47
- };
48
- }
49
- export {
50
- k as antiReplyAttackStrategy,
51
- $ as requestDataEncryption,
52
- h as responseDataEncryption
53
- };
@@ -1,15 +0,0 @@
1
- import { g as o } from "../../../commonjs-virtual-dir/index2.js";
2
- import { dataToStr as r } from "./util.js";
3
- const c = "cbc", n = (t, e) => new o.sm4({
4
- key: t.key,
5
- iv: t.iv,
6
- mode: c
7
- }).decrypt(r(e)), p = (t, e) => new o.sm4({
8
- key: t.key,
9
- iv: t.iv,
10
- mode: c
11
- }).encrypt(r(e));
12
- export {
13
- n as sm4Decrypt,
14
- p as sm4Encrypt
15
- };
@@ -1,52 +0,0 @@
1
- import { __exports as F } from "../../commonjs-virtual-dir/index8.js";
2
- var A;
3
- function _() {
4
- if (A) return F;
5
- A = 1, F.byteLength = y, F.toByteArray = C, F.fromByteArray = B;
6
- for (var c = [], n = [], l = typeof Uint8Array < "u" ? Uint8Array : Array, d = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", s = 0, p = d.length; s < p; ++s)
7
- c[s] = d[s], n[d.charCodeAt(s)] = s;
8
- n[45] = 62, n[95] = 63;
9
- function x(r) {
10
- var e = r.length;
11
- if (e % 4 > 0)
12
- throw new Error("Invalid string. Length must be a multiple of 4");
13
- var a = r.indexOf("=");
14
- a === -1 && (a = e);
15
- var o = a === e ? 0 : 4 - a % 4;
16
- return [a, o];
17
- }
18
- function y(r) {
19
- var e = x(r), a = e[0], o = e[1];
20
- return (a + o) * 3 / 4 - o;
21
- }
22
- function i(r, e, a) {
23
- return (e + a) * 3 / 4 - a;
24
- }
25
- function C(r) {
26
- var e, a = x(r), o = a[0], v = a[1], t = new l(i(r, o, v)), h = 0, u = v > 0 ? o - 4 : o, f;
27
- for (f = 0; f < u; f += 4)
28
- e = n[r.charCodeAt(f)] << 18 | n[r.charCodeAt(f + 1)] << 12 | n[r.charCodeAt(f + 2)] << 6 | n[r.charCodeAt(f + 3)], t[h++] = e >> 16 & 255, t[h++] = e >> 8 & 255, t[h++] = e & 255;
29
- return v === 2 && (e = n[r.charCodeAt(f)] << 2 | n[r.charCodeAt(f + 1)] >> 4, t[h++] = e & 255), v === 1 && (e = n[r.charCodeAt(f)] << 10 | n[r.charCodeAt(f + 1)] << 4 | n[r.charCodeAt(f + 2)] >> 2, t[h++] = e >> 8 & 255, t[h++] = e & 255), t;
30
- }
31
- function L(r) {
32
- return c[r >> 18 & 63] + c[r >> 12 & 63] + c[r >> 6 & 63] + c[r & 63];
33
- }
34
- function g(r, e, a) {
35
- for (var o, v = [], t = e; t < a; t += 3)
36
- o = (r[t] << 16 & 16711680) + (r[t + 1] << 8 & 65280) + (r[t + 2] & 255), v.push(L(o));
37
- return v.join("");
38
- }
39
- function B(r) {
40
- for (var e, a = r.length, o = a % 3, v = [], t = 16383, h = 0, u = a - o; h < u; h += t)
41
- v.push(g(r, h, h + t > u ? u : h + t));
42
- return o === 1 ? (e = r[a - 1], v.push(
43
- c[e >> 2] + c[e << 4 & 63] + "=="
44
- )) : o === 2 && (e = (r[a - 2] << 8) + r[a - 1], v.push(
45
- c[e >> 10] + c[e >> 4 & 63] + c[e << 2 & 63] + "="
46
- )), v.join("");
47
- }
48
- return F;
49
- }
50
- export {
51
- _ as __require
52
- };
@@ -1,10 +0,0 @@
1
- import { __require as t } from "./src/sm4.js";
2
- var r, e;
3
- function m() {
4
- return e || (e = 1, r = {
5
- sm4: t()
6
- }), r;
7
- }
8
- export {
9
- m as __require
10
- };
@@ -1,60 +0,0 @@
1
- import { __require as a } from "../../base64-js/index.js";
2
- import n from "util";
3
- var t, d;
4
- function y() {
5
- if (d) return t;
6
- d = 1;
7
- const o = a();
8
- class c {
9
- /**
10
- * Converts a JS string to an UTF-8 uint8array.
11
- *
12
- * @static
13
- * @param {String} str 16-bit unicode string.
14
- * @return {Uint8Array} UTF-8 Uint8Array.
15
- * @memberof Crypt
16
- */
17
- static stringToArrayBufferInUtf8(e) {
18
- const r = typeof window > "u" ? n.TextEncoder : window.TextEncoder;
19
- return new r().encode(e);
20
- }
21
- /**
22
- * Converts an UTF-8 uint8array to a JS string.
23
- *
24
- * @static
25
- * @param {Uint8Array} strBuffer UTF-8 Uint8Array.
26
- * @return {String} 16-bit unicode string.
27
- * @memberof Crypt
28
- */
29
- static utf8ArrayBufferToString(e) {
30
- const r = typeof window > "u" ? n.TextDecoder : window.TextDecoder;
31
- return new r("utf-8").decode(e);
32
- }
33
- /**
34
- * crypt a utf8 byteArray to base64 string
35
- *
36
- * @static
37
- * @param {Uint8Array} strBuffer UTF-8 Uint8Array.
38
- * @returns {String} base64 str
39
- * @memberof Crypt
40
- */
41
- static arrayBufferToBase64(e) {
42
- return o.fromByteArray(e);
43
- }
44
- /**
45
- * crypt base64 stringa to utf8 byteArray
46
- *
47
- * @static
48
- * @param {String} base64 str
49
- * @returns {Uint8Array} strBuffer UTF-8 Uint8Array.
50
- * @memberof Crypt
51
- */
52
- static base64ToArrayBuffer(e) {
53
- return o.toByteArray(e);
54
- }
55
- }
56
- return t = c, t;
57
- }
58
- export {
59
- y as __require
60
- };