module-develop-kit 1.4.2 → 1.5.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 (39) hide show
  1. package/dist/commonjs-virtual-dir/index.js +3 -5
  2. package/dist/commonjs-virtual-dir/index2.js +5 -2
  3. package/dist/commonjs-virtual-dir/index3.js +5 -2
  4. package/dist/commonjs-virtual-dir/index4.js +2 -4
  5. package/dist/commonjs-virtual-dir/index5.js +4 -0
  6. package/dist/commonjs-virtual-dir/index6.js +4 -0
  7. package/dist/commonjs-virtual-dir/index7.js +4 -0
  8. package/dist/commonjs-virtual-dir/index8.js +4 -0
  9. package/dist/main.d.ts +92 -10
  10. package/dist/main.js +44 -40
  11. package/dist/src/outside-call/utils.js +1 -1
  12. package/dist/src/shield/crypto/const.js +4 -0
  13. package/dist/src/shield/crypto/index.js +53 -0
  14. package/dist/src/shield/crypto/sm2.js +7 -0
  15. package/dist/src/shield/crypto/sm4.js +15 -0
  16. package/dist/src/shield/crypto/util.js +29 -0
  17. package/dist/src/shield/gcm-crypto/axios-adapter.js +25 -23
  18. package/dist/src/shield/gcm-crypto/index.js +16 -15
  19. package/dist/vendor/base64-js/index.js +52 -0
  20. package/dist/vendor/file-type/source/detectors/zip.js +64 -60
  21. package/dist/vendor/file-type/source/index.js +146 -130
  22. package/dist/vendor/file-type/source/supported.js +4 -2
  23. package/dist/vendor/gm-crypt/index.js +10 -0
  24. package/dist/vendor/gm-crypt/src/crypt.js +60 -0
  25. package/dist/vendor/gm-crypt/src/sm4.js +513 -0
  26. package/dist/vendor/ieee754/index.js +1 -1
  27. package/dist/vendor/jsbn/index.js +714 -0
  28. package/dist/vendor/sdp-transform/lib/index.js +1 -1
  29. package/dist/vendor/sm-crypto/src/index.js +14 -0
  30. package/dist/vendor/sm-crypto/src/sm2/asn1.js +86 -0
  31. package/dist/vendor/sm-crypto/src/sm2/ec.js +205 -0
  32. package/dist/vendor/sm-crypto/src/sm2/index.js +114 -0
  33. package/dist/vendor/sm-crypto/src/sm2/sm3.js +71 -0
  34. package/dist/vendor/sm-crypto/src/sm2/utils.js +95 -0
  35. package/dist/vendor/sm-crypto/src/sm3/index.js +50 -0
  36. package/dist/vendor/sm-crypto/src/sm4/index.js +408 -0
  37. package/dist/vendor/token-types/lib/index.js +1 -1
  38. package/dist/vite-plugins/index.d.ts +42 -0
  39. package/package.json +13 -13
@@ -1,7 +1,7 @@
1
- import { UINT32_LE as h } from "../../../token-types/lib/index.js";
2
- import { EndOfStreamError as T } from "../../../strtok3/lib/stream/Errors.js";
1
+ import { UINT32_LE as x } from "../../../token-types/lib/index.js";
2
+ import { EndOfStreamError as k } from "../../../strtok3/lib/stream/Errors.js";
3
3
  import { ZipHandler as y } from "../../../@tokenizer/inflate/lib/ZipHandler.js";
4
- import { hasUnknownFileSize as f, ParserHardLimitError as x, hasExceededUnknownSizeScanBudget as w, maximumUntrustedSkipSizeInBytes as u, safeIgnore as C } from "../parser.js";
4
+ import { ParserHardLimitError as l, hasUnknownFileSize as h, hasExceededUnknownSizeScanBudget as w, maximumUntrustedSkipSizeInBytes as u, safeIgnore as C } from "../parser.js";
5
5
  const d = 1024 * 1024, E = 1024, F = 2 ** 31 - 1, D = d, P = /* @__PURE__ */ new Set([
6
6
  "Unexpected signature",
7
7
  "Encrypted ZIP",
@@ -19,42 +19,46 @@ const d = 1024 * 1024, E = 1024, F = 2 ** 31 - 1, D = d, P = /* @__PURE__ */ new
19
19
  ]);
20
20
  async function z(e, { maximumLength: t = d } = {}) {
21
21
  const i = new ReadableStream({
22
- start(c) {
23
- c.enqueue(e), c.close();
22
+ start(a) {
23
+ a.enqueue(e), a.close();
24
24
  }
25
25
  }).pipeThrough(new DecompressionStream("deflate-raw")).getReader(), s = [];
26
- let o = 0;
26
+ let c = 0;
27
27
  try {
28
28
  for (; ; ) {
29
- const { done: c, value: m } = await i.read();
30
- if (c)
29
+ const { done: a, value: m } = await i.read();
30
+ if (a)
31
31
  break;
32
- if (o += m.length, o > t)
33
- throw await i.cancel(), new Error(`ZIP entry decompressed data exceeds ${t} bytes`);
32
+ if (c += m.length, c > t)
33
+ throw await i.cancel().catch(() => {
34
+ }), new Error(`ZIP entry decompressed data exceeds ${t} bytes`);
34
35
  s.push(m);
35
36
  }
37
+ } catch (a) {
38
+ if (a.code !== "ERR_TRAILING_JUNK_AFTER_STREAM_END")
39
+ throw a;
36
40
  } finally {
37
41
  i.releaseLock();
38
42
  }
39
- const a = new Uint8Array(o);
43
+ const o = new Uint8Array(c);
40
44
  let p = 0;
41
- for (const c of s)
42
- a.set(c, p), p += c.length;
43
- return a;
45
+ for (const a of s)
46
+ o.set(a, p), p += a.length;
47
+ return o;
44
48
  }
45
- function L(e, t) {
49
+ function R(e, t) {
46
50
  const r = new Uint8Array(t);
47
51
  let n = 0;
48
52
  for (const i of e)
49
53
  r.set(i, n), n += i.length;
50
54
  return r;
51
55
  }
52
- function R(e) {
56
+ function L(e) {
53
57
  const t = e.fileInfo.size, r = Number.isFinite(t) ? Math.max(0, t - e.position) : Number.MAX_SAFE_INTEGER;
54
58
  return Math.min(r, F);
55
59
  }
56
- function U(e) {
57
- if (e instanceof T || e instanceof x)
60
+ function _(e) {
61
+ if (e instanceof k || e instanceof l)
58
62
  return !0;
59
63
  if (!(e instanceof Error))
60
64
  return !1;
@@ -72,7 +76,7 @@ function v(e, t = d) {
72
76
  return !1;
73
77
  return !0;
74
78
  }
75
- function O() {
79
+ function U() {
76
80
  return {
77
81
  hasDocumentEntry: !1,
78
82
  hasMasterSlideEntry: !1,
@@ -87,7 +91,7 @@ function b(e) {
87
91
  if (e.hasDocumentEntry)
88
92
  return e.hasMasterSlideEntry ? { ext: "key", mime: "application/vnd.apple.keynote" } : e.hasTablesEntry ? { ext: "numbers", mime: "application/vnd.apple.numbers" } : { ext: "pages", mime: "application/vnd.apple.pages" };
89
93
  }
90
- function k(e) {
94
+ function T(e) {
91
95
  switch (e = e.toLowerCase(), e) {
92
96
  case "application/epub+zip":
93
97
  return { ext: "epub", mime: e };
@@ -141,7 +145,7 @@ function k(e) {
141
145
  return { ext: "3mf", mime: "model/3mf" };
142
146
  }
143
147
  }
144
- function _() {
148
+ function O() {
145
149
  return {
146
150
  hasContentTypesEntry: !1,
147
151
  hasParsedContentTypesEntry: !1,
@@ -153,7 +157,7 @@ function _() {
153
157
  hasThreeDimensionalModelEntry: !1
154
158
  };
155
159
  }
156
- function W(e, t) {
160
+ function N(e, t) {
157
161
  t.startsWith("word/") && (e.hasWordDirectory = !0), t.startsWith("ppt/") && (e.hasPresentationDirectory = !0), t.startsWith("xl/") && (e.hasSpreadsheetDirectory = !0), t.startsWith("3D/") && t.endsWith(".model") && (e.hasThreeDimensionalModelEntry = !0);
158
162
  }
159
163
  function Z(e) {
@@ -182,7 +186,7 @@ function I(e) {
182
186
  if (!(!e.hasContentTypesEntry || e.hasUnparseableContentTypes || e.isParsingContentTypes || e.hasParsedContentTypesEntry))
183
187
  return Z(e);
184
188
  }
185
- function N(e) {
189
+ function W(e) {
186
190
  const t = e.indexOf('.main+xml"');
187
191
  if (t === -1) {
188
192
  const i = "application/vnd.ms-package.3dmanufacturing-3dmodel+xml";
@@ -191,25 +195,25 @@ function N(e) {
191
195
  const r = e.slice(0, t), n = r.lastIndexOf('"');
192
196
  return r.slice(n + 1);
193
197
  }
194
- const S = 134695760, l = 16, $ = l - 1;
198
+ const S = 134695760, f = 16, $ = f - 1;
195
199
  function j(e, t) {
196
- if (e.length < l)
200
+ if (e.length < f)
197
201
  return -1;
198
- const r = e.length - l;
202
+ const r = e.length - f;
199
203
  for (let n = 0; n <= r; n++)
200
- if (h.get(e, n) === S && h.get(e, n + 8) === t + n)
204
+ if (x.get(e, n) === S && x.get(e, n + 8) === t + n)
201
205
  return n;
202
206
  return -1;
203
207
  }
204
- async function q(e, { shouldBuffer: t, maximumLength: r = d } = {}) {
208
+ async function G(e, { shouldBuffer: t, maximumLength: r = d } = {}) {
205
209
  const { syncBuffer: n } = e, { length: i } = n, s = [];
206
- let o = 0;
210
+ let c = 0;
207
211
  for (; ; ) {
208
- const a = await e.tokenizer.peekBuffer(n, { mayBeLess: !0 }), p = j(n.subarray(0, a), o), c = p >= 0 ? 0 : a === i ? Math.min($, a - 1) : 0, m = p >= 0 ? p : a - c;
212
+ const o = await e.tokenizer.peekBuffer(n, { mayBeLess: !0 }), p = j(n.subarray(0, o), c), a = p >= 0 ? 0 : o === i ? Math.min($, o - 1) : 0, m = p >= 0 ? p : o - a;
209
213
  if (m === 0)
210
214
  break;
211
- if (o += m, o > r)
212
- throw new Error(`ZIP entry compressed data exceeds ${r} bytes`);
215
+ if (c += m, c > r)
216
+ throw new l(`ZIP entry data descriptor not found within ${r} bytes`);
213
217
  if (t) {
214
218
  const g = new Uint8Array(m);
215
219
  await e.tokenizer.readBuffer(g), s.push(g);
@@ -218,26 +222,26 @@ async function q(e, { shouldBuffer: t, maximumLength: r = d } = {}) {
218
222
  if (p >= 0)
219
223
  break;
220
224
  }
221
- if (f(e.tokenizer) || (e.knownSizeDescriptorScannedBytes += o), !!t)
222
- return L(s, o);
225
+ if (h(e.tokenizer) || (e.knownSizeDescriptorScannedBytes += c), !!t)
226
+ return R(s, c);
223
227
  }
224
- function G(e, t) {
225
- return f(e.tokenizer) ? Math.max(0, u - (e.tokenizer.position - t)) : Math.max(0, d - e.knownSizeDescriptorScannedBytes);
228
+ function q(e, t) {
229
+ return h(e.tokenizer) ? Math.max(0, u - (e.tokenizer.position - t)) : Math.max(0, d - e.knownSizeDescriptorScannedBytes);
226
230
  }
227
- async function Q(e, t, { shouldBuffer: r, maximumDescriptorLength: n = d } = {}) {
231
+ async function J(e, t, { shouldBuffer: r, maximumDescriptorLength: n = d } = {}) {
228
232
  if (t.dataDescriptor && t.compressedSize === 0)
229
- return q(e, {
233
+ return G(e, {
230
234
  shouldBuffer: r,
231
235
  maximumLength: n
232
236
  });
233
237
  if (!r) {
234
238
  await C(e.tokenizer, t.compressedSize, {
235
- maximumLength: f(e.tokenizer) ? d : e.tokenizer.fileInfo.size,
239
+ maximumLength: h(e.tokenizer) ? d : e.tokenizer.fileInfo.size,
236
240
  reason: "ZIP entry compressed data"
237
241
  });
238
242
  return;
239
243
  }
240
- const i = R(e.tokenizer);
244
+ const i = L(e.tokenizer);
241
245
  if (!Number.isFinite(t.compressedSize) || t.compressedSize < 0 || t.compressedSize > i)
242
246
  throw new Error(`ZIP entry compressed data exceeds ${i} bytes`);
243
247
  const s = new Uint8Array(t.compressedSize);
@@ -257,7 +261,7 @@ y.prototype.unzip = async function(e) {
257
261
  this.knownSizeDescriptorScannedBytes = 0;
258
262
  do {
259
263
  if (w(this.tokenizer, n, u))
260
- throw new x(`ZIP stream probing exceeds ${u} bytes`);
264
+ throw new l(`ZIP stream probing exceeds ${u} bytes`);
261
265
  const i = await this.readLocalFileHeader();
262
266
  if (!i)
263
267
  break;
@@ -265,29 +269,29 @@ y.prototype.unzip = async function(e) {
265
269
  throw new Error(`ZIP entry count exceeds ${E}`);
266
270
  const s = e(i);
267
271
  t = !!s.stop, await this.tokenizer.ignore(i.extraFieldLength);
268
- const o = await Q(this, i, {
272
+ const c = await J(this, i, {
269
273
  shouldBuffer: !!s.handler,
270
- maximumDescriptorLength: Math.min(d, G(this, n))
274
+ maximumDescriptorLength: Math.min(d, q(this, n))
271
275
  });
272
- if (s.handler && await this.inflate(i, o, s.handler), i.dataDescriptor) {
273
- const a = new Uint8Array(l);
274
- if (await this.tokenizer.readBuffer(a), h.get(a, 0) !== S)
275
- throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position - a.length}`);
276
+ if (s.handler && await this.inflate(i, c, s.handler), i.dataDescriptor) {
277
+ const o = new Uint8Array(f);
278
+ if (await this.tokenizer.readBuffer(o), x.get(o, 0) !== S)
279
+ throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position - o.length}`);
276
280
  }
277
281
  if (w(this.tokenizer, n, u))
278
- throw new x(`ZIP stream probing exceeds ${u} bytes`);
282
+ throw new l(`ZIP stream probing exceeds ${u} bytes`);
279
283
  } while (!t);
280
284
  };
281
285
  async function Y(e) {
282
286
  let t;
283
- const r = _(), n = O();
287
+ const r = O(), n = U();
284
288
  try {
285
289
  await new y(e).unzip((s) => {
286
- if (W(r, s.filename), A(n, s.filename), n.hasDocumentEntry && (n.hasMasterSlideEntry || n.hasTablesEntry))
290
+ if (N(r, s.filename), A(n, s.filename), n.hasDocumentEntry && (n.hasMasterSlideEntry || n.hasTablesEntry))
287
291
  return t = b(n), { stop: !0 };
288
- const o = s.filename === "[Content_Types].xml", a = I(r);
289
- if (!o && a)
290
- return t = a, {
292
+ const c = s.filename === "[Content_Types].xml", o = I(r);
293
+ if (!c && o)
294
+ return t = o, {
291
295
  stop: !0
292
296
  };
293
297
  switch (s.filename) {
@@ -308,16 +312,16 @@ async function Y(e) {
308
312
  case "mimetype":
309
313
  return v(s, D) ? {
310
314
  async handler(p) {
311
- const c = new TextDecoder("utf-8").decode(p).trim();
312
- t = k(c);
315
+ const a = new TextDecoder("utf-8").decode(p).trim();
316
+ t = T(a);
313
317
  },
314
318
  stop: !0
315
319
  } : {};
316
320
  case "[Content_Types].xml":
317
321
  return r.hasContentTypesEntry = !0, v(s, D) ? (r.isParsingContentTypes = !0, {
318
322
  async handler(p) {
319
- const c = new TextDecoder("utf-8").decode(p), m = N(c);
320
- m && (t = k(m)), r.hasParsedContentTypesEntry = !0, r.isParsingContentTypes = !1;
323
+ const a = new TextDecoder("utf-8").decode(p), m = W(a);
324
+ m && (t = T(m)), r.hasParsedContentTypesEntry = !0, r.isParsingContentTypes = !1;
321
325
  },
322
326
  stop: !0
323
327
  }) : (r.hasUnparseableContentTypes = !0, {});
@@ -329,11 +333,11 @@ async function Y(e) {
329
333
  }
330
334
  });
331
335
  } catch (s) {
332
- if (!U(s))
336
+ if (!_(s))
333
337
  throw s;
334
- r.isParsingContentTypes && (r.isParsingContentTypes = !1, r.hasUnparseableContentTypes = !0), !t && s instanceof T && !r.hasContentTypesEntry && (t = Z(r));
338
+ r.isParsingContentTypes && (r.isParsingContentTypes = !1, r.hasUnparseableContentTypes = !0), !t && (s instanceof k || s instanceof l) && !r.hasContentTypesEntry && (t = Z(r));
335
339
  }
336
- const i = f(e) && n.hasDocumentEntry && !n.hasMasterSlideEntry && !n.hasTablesEntry && !n.hasCalculationEngineEntry ? void 0 : b(n);
340
+ const i = h(e) && n.hasDocumentEntry && !n.hasMasterSlideEntry && !n.hasTablesEntry && !n.hasCalculationEngineEntry ? void 0 : b(n);
337
341
  return t ?? I(r) ?? i ?? {
338
342
  ext: "zip",
339
343
  mime: "application/zip"