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
@@ -0,0 +1,154 @@
1
+ import { hexToBytes as d, abytes as x, bytesToHex as m, isBytes as h, concatBytes as U } from "../../hashes/esm/utils.js";
2
+ import { anumber as C, randomBytes as G, utf8ToBytes as J } from "../../hashes/esm/utils.js";
3
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
4
+ const g = /* @__PURE__ */ BigInt(0), p = /* @__PURE__ */ BigInt(1);
5
+ function I(t, e = "") {
6
+ if (typeof t != "boolean") {
7
+ const n = e && `"${e}"`;
8
+ throw new Error(n + "expected boolean, got type=" + typeof t);
9
+ }
10
+ return t;
11
+ }
12
+ function _(t, e, n = "") {
13
+ const o = h(t), i = t?.length, r = e !== void 0;
14
+ if (!o || r && i !== e) {
15
+ const f = n && `"${n}" `, c = r ? ` of length ${e}` : "", u = o ? `length=${i}` : `type=${typeof t}`;
16
+ throw new Error(f + "expected Uint8Array" + c + ", got " + u);
17
+ }
18
+ return t;
19
+ }
20
+ function k(t) {
21
+ const e = t.toString(16);
22
+ return e.length & 1 ? "0" + e : e;
23
+ }
24
+ function E(t) {
25
+ if (typeof t != "string")
26
+ throw new Error("hex string expected, got " + typeof t);
27
+ return t === "" ? g : BigInt("0x" + t);
28
+ }
29
+ function j(t) {
30
+ return E(m(t));
31
+ }
32
+ function H(t) {
33
+ return x(t), E(m(Uint8Array.from(t).reverse()));
34
+ }
35
+ function T(t, e) {
36
+ return d(t.toString(16).padStart(e * 2, "0"));
37
+ }
38
+ function O(t, e) {
39
+ return T(t, e).reverse();
40
+ }
41
+ function S(t, e, n) {
42
+ let o;
43
+ if (typeof e == "string")
44
+ try {
45
+ o = d(e);
46
+ } catch (r) {
47
+ throw new Error(t + " must be hex string or Uint8Array, cause: " + r);
48
+ }
49
+ else if (h(e))
50
+ o = Uint8Array.from(e);
51
+ else
52
+ throw new Error(t + " must be hex string or Uint8Array");
53
+ const i = o.length;
54
+ if (typeof n == "number" && i !== n)
55
+ throw new Error(t + " of length " + n + " expected, got " + i);
56
+ return o;
57
+ }
58
+ const l = (t) => typeof t == "bigint" && g <= t;
59
+ function $(t, e, n) {
60
+ return l(t) && l(e) && l(n) && e <= t && t < n;
61
+ }
62
+ function M(t, e, n, o) {
63
+ if (!$(e, n, o))
64
+ throw new Error("expected valid " + t + ": " + n + " <= n < " + o + ", got " + e);
65
+ }
66
+ function N(t) {
67
+ let e;
68
+ for (e = 0; t > g; t >>= p, e += 1)
69
+ ;
70
+ return e;
71
+ }
72
+ const R = (t) => (p << BigInt(t)) - p;
73
+ function z(t, e, n) {
74
+ if (typeof t != "number" || t < 2)
75
+ throw new Error("hashLen must be a number");
76
+ if (typeof e != "number" || e < 2)
77
+ throw new Error("qByteLen must be a number");
78
+ if (typeof n != "function")
79
+ throw new Error("hmacFn must be a function");
80
+ const o = (s) => new Uint8Array(s), i = (s) => Uint8Array.of(s);
81
+ let r = o(t), f = o(t), c = 0;
82
+ const u = () => {
83
+ r.fill(1), f.fill(0), c = 0;
84
+ }, y = (...s) => n(f, r, ...s), w = (s = o(0)) => {
85
+ f = y(i(0), s), r = y(), s.length !== 0 && (f = y(i(1), s), r = y());
86
+ }, B = () => {
87
+ if (c++ >= 1e3)
88
+ throw new Error("drbg: tried 1000 values");
89
+ let s = 0;
90
+ const a = [];
91
+ for (; s < e; ) {
92
+ r = y();
93
+ const b = r.slice();
94
+ a.push(b), s += r.length;
95
+ }
96
+ return U(...a);
97
+ };
98
+ return (s, a) => {
99
+ u(), w(s);
100
+ let b;
101
+ for (; !(b = a(B())); )
102
+ w();
103
+ return u(), b;
104
+ };
105
+ }
106
+ function D(t, e, n = {}) {
107
+ if (!t || typeof t != "object")
108
+ throw new Error("expected valid options object");
109
+ function o(i, r, f) {
110
+ const c = t[i];
111
+ if (f && c === void 0)
112
+ return;
113
+ const u = typeof c;
114
+ if (u !== r || c === null)
115
+ throw new Error(`param "${i}" is invalid: expected ${r}, got ${u}`);
116
+ }
117
+ Object.entries(e).forEach(([i, r]) => o(i, r, !1)), Object.entries(n).forEach(([i, r]) => o(i, r, !0));
118
+ }
119
+ function F(t) {
120
+ const e = /* @__PURE__ */ new WeakMap();
121
+ return (n, ...o) => {
122
+ const i = e.get(n);
123
+ if (i !== void 0)
124
+ return i;
125
+ const r = t(n, ...o);
126
+ return e.set(n, r), r;
127
+ };
128
+ }
129
+ export {
130
+ I as _abool2,
131
+ _ as _abytes2,
132
+ D as _validateObject,
133
+ M as aInRange,
134
+ x as abytes,
135
+ C as anumber,
136
+ N as bitLen,
137
+ R as bitMask,
138
+ m as bytesToHex,
139
+ j as bytesToNumberBE,
140
+ H as bytesToNumberLE,
141
+ U as concatBytes,
142
+ z as createHmacDrbg,
143
+ S as ensureBytes,
144
+ d as hexToBytes,
145
+ E as hexToNumber,
146
+ $ as inRange,
147
+ h as isBytes,
148
+ F as memoized,
149
+ T as numberToBytesBE,
150
+ O as numberToBytesLE,
151
+ k as numberToHexUnpadded,
152
+ G as randomBytes,
153
+ J as utf8ToBytes
154
+ };
@@ -0,0 +1,4 @@
1
+ const o = typeof globalThis == "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
2
+ export {
3
+ o as crypto
4
+ };
@@ -0,0 +1,45 @@
1
+ import { Hash as d, ahash as u, toBytes as H, clean as l, aexists as a, abytes as p } from "./utils.js";
2
+ class r extends d {
3
+ constructor(t, i) {
4
+ super(), this.finished = !1, this.destroyed = !1, u(t);
5
+ const h = H(i);
6
+ if (this.iHash = t.create(), typeof this.iHash.update != "function")
7
+ throw new Error("Expected instance of class which extends utils.Hash");
8
+ this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
9
+ const o = this.blockLen, e = new Uint8Array(o);
10
+ e.set(h.length > o ? t.create().update(h).digest() : h);
11
+ for (let s = 0; s < e.length; s++)
12
+ e[s] ^= 54;
13
+ this.iHash.update(e), this.oHash = t.create();
14
+ for (let s = 0; s < e.length; s++)
15
+ e[s] ^= 106;
16
+ this.oHash.update(e), l(e);
17
+ }
18
+ update(t) {
19
+ return a(this), this.iHash.update(t), this;
20
+ }
21
+ digestInto(t) {
22
+ a(this), p(t, this.outputLen), this.finished = !0, this.iHash.digestInto(t), this.oHash.update(t), this.oHash.digestInto(t), this.destroy();
23
+ }
24
+ digest() {
25
+ const t = new Uint8Array(this.oHash.outputLen);
26
+ return this.digestInto(t), t;
27
+ }
28
+ _cloneInto(t) {
29
+ t || (t = Object.create(Object.getPrototypeOf(this), {}));
30
+ const { oHash: i, iHash: h, finished: o, destroyed: e, blockLen: s, outputLen: c } = this;
31
+ return t = t, t.finished = o, t.destroyed = e, t.blockLen = s, t.outputLen = c, t.oHash = i._cloneInto(t.oHash), t.iHash = h._cloneInto(t.iHash), t;
32
+ }
33
+ clone() {
34
+ return this._cloneInto();
35
+ }
36
+ destroy() {
37
+ this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy();
38
+ }
39
+ }
40
+ const y = (n, t, i) => new r(n, t).update(i).digest();
41
+ y.create = (n, t) => new r(n, t);
42
+ export {
43
+ r as HMAC,
44
+ y as hmac
45
+ };
@@ -0,0 +1,112 @@
1
+ import { crypto as s } from "./crypto.js";
2
+ /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
3
+ function h(e) {
4
+ return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array";
5
+ }
6
+ function d(e) {
7
+ if (!Number.isSafeInteger(e) || e < 0)
8
+ throw new Error("positive integer expected, got " + e);
9
+ }
10
+ function c(e, ...t) {
11
+ if (!h(e))
12
+ throw new Error("Uint8Array expected");
13
+ if (t.length > 0 && !t.includes(e.length))
14
+ throw new Error("Uint8Array expected of length " + t + ", got length=" + e.length);
15
+ }
16
+ function m(e) {
17
+ if (typeof e != "function" || typeof e.create != "function")
18
+ throw new Error("Hash should be wrapped by utils.createHasher");
19
+ d(e.outputLen), d(e.blockLen);
20
+ }
21
+ function x(e, t = !0) {
22
+ if (e.destroyed)
23
+ throw new Error("Hash instance has been destroyed");
24
+ if (t && e.finished)
25
+ throw new Error("Hash#digest() has already been called");
26
+ }
27
+ function E(...e) {
28
+ for (let t = 0; t < e.length; t++)
29
+ e[t].fill(0);
30
+ }
31
+ const y = /* @ts-ignore */ typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", w = /* @__PURE__ */ Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0"));
32
+ function U(e) {
33
+ if (c(e), y)
34
+ return e.toHex();
35
+ let t = "";
36
+ for (let r = 0; r < e.length; r++)
37
+ t += w[e[r]];
38
+ return t;
39
+ }
40
+ const f = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
41
+ function l(e) {
42
+ if (e >= f._0 && e <= f._9)
43
+ return e - f._0;
44
+ if (e >= f.A && e <= f.F)
45
+ return e - (f.A - 10);
46
+ if (e >= f.a && e <= f.f)
47
+ return e - (f.a - 10);
48
+ }
49
+ function B(e) {
50
+ if (typeof e != "string")
51
+ throw new Error("hex string expected, got " + typeof e);
52
+ if (y)
53
+ return Uint8Array.fromHex(e);
54
+ const t = e.length, r = t / 2;
55
+ if (t % 2)
56
+ throw new Error("hex string expected, got unpadded hex of length " + t);
57
+ const n = new Uint8Array(r);
58
+ for (let o = 0, i = 0; o < r; o++, i += 2) {
59
+ const u = l(e.charCodeAt(i)), a = l(e.charCodeAt(i + 1));
60
+ if (u === void 0 || a === void 0) {
61
+ const g = e[i] + e[i + 1];
62
+ throw new Error('hex string expected, got non-hex character "' + g + '" at index ' + i);
63
+ }
64
+ n[o] = u * 16 + a;
65
+ }
66
+ return n;
67
+ }
68
+ function p(e) {
69
+ if (typeof e != "string")
70
+ throw new Error("string expected");
71
+ return new Uint8Array(new TextEncoder().encode(e));
72
+ }
73
+ function H(e) {
74
+ return typeof e == "string" && (e = p(e)), c(e), e;
75
+ }
76
+ function _(...e) {
77
+ let t = 0;
78
+ for (let n = 0; n < e.length; n++) {
79
+ const o = e[n];
80
+ c(o), t += o.length;
81
+ }
82
+ const r = new Uint8Array(t);
83
+ for (let n = 0, o = 0; n < e.length; n++) {
84
+ const i = e[n];
85
+ r.set(i, o), o += i.length;
86
+ }
87
+ return r;
88
+ }
89
+ class T {
90
+ }
91
+ function b(e = 32) {
92
+ if (s && typeof s.getRandomValues == "function")
93
+ return s.getRandomValues(new Uint8Array(e));
94
+ if (s && typeof s.randomBytes == "function")
95
+ return Uint8Array.from(s.randomBytes(e));
96
+ throw new Error("crypto.getRandomValues must be defined");
97
+ }
98
+ export {
99
+ T as Hash,
100
+ c as abytes,
101
+ x as aexists,
102
+ m as ahash,
103
+ d as anumber,
104
+ U as bytesToHex,
105
+ E as clean,
106
+ _ as concatBytes,
107
+ B as hexToBytes,
108
+ h as isBytes,
109
+ b as randomBytes,
110
+ H as toBytes,
111
+ p as utf8ToBytes
112
+ };
@@ -1,4 +1,4 @@
1
- import { __exports as n } from "../../commonjs-virtual-dir/index7.js";
1
+ import { __exports as n } from "../../commonjs-virtual-dir/index5.js";
2
2
  /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
3
3
  var d;
4
4
  function q() {
@@ -1,4 +1,4 @@
1
- import { __exports as r } from "../../../commonjs-virtual-dir/index5.js";
1
+ import { __exports as r } from "../../../commonjs-virtual-dir/index4.js";
2
2
  import { __require as t } from "./parser.js";
3
3
  import { __require as m } from "./writer.js";
4
4
  import { __require as p } from "./grammar.js";