module-develop-kit 1.4.3 → 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.
- package/dist/commonjs-virtual-dir/browser.js +2 -5
- package/dist/commonjs-virtual-dir/browser2.js +5 -2
- package/dist/commonjs-virtual-dir/index2.js +3 -5
- package/dist/commonjs-virtual-dir/index3.js +5 -3
- package/dist/main.d.ts +44 -2
- package/dist/src/outside-call/utils.js +1 -1
- package/dist/src/shield/crypto/sm4.js +1 -1
- package/dist/src/shield/gcm-crypto/axios-adapter.js +13 -11
- package/dist/src/shield/gcm-crypto/index.js +12 -11
- package/dist/vendor/@tokenizer/inflate/lib/ZipHandler.js +1 -1
- package/dist/vendor/debug/src/browser.js +1 -1
- package/dist/vendor/file-type/source/detectors/zip.js +64 -60
- package/dist/vendor/file-type/source/index.js +146 -130
- package/dist/vendor/file-type/source/supported.js +4 -2
- package/dist/vite-plugins/index.d.ts +42 -0
- package/package.json +13 -13
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
var t = o();
|
|
4
|
-
const a = /* @__PURE__ */ r(t);
|
|
1
|
+
import { __require as r } from "../vendor/gm-crypt/index.js";
|
|
2
|
+
var p = r();
|
|
5
3
|
export {
|
|
6
|
-
|
|
4
|
+
p as g
|
|
7
5
|
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { getDefaultExportFromCjs as r } from "./_commonjsHelpers.js";
|
|
2
|
+
import { __require as o } from "../vendor/sdp-transform/lib/index.js";
|
|
3
|
+
var t = o();
|
|
4
|
+
const a = /* @__PURE__ */ r(t);
|
|
3
5
|
export {
|
|
4
|
-
|
|
6
|
+
a as default
|
|
5
7
|
};
|
package/dist/main.d.ts
CHANGED
|
@@ -479,7 +479,7 @@ export declare function requestDataEncryption(publicKey: string, _data?: TData):
|
|
|
479
479
|
/**
|
|
480
480
|
* gcm 加密请求拦截器
|
|
481
481
|
*/
|
|
482
|
-
export declare const requestDataGcmCryptoInterceptor: <T>(config: InternalAxiosRequestConfig<T>) => Promise<InternalAxiosRequestConfig<T>>;
|
|
482
|
+
export declare const requestDataGcmCryptoInterceptor: <T>(config: InternalAxiosRequestConfig<T>) => Promise<InternalAxiosRequestConfig<T, any>>;
|
|
483
483
|
|
|
484
484
|
/**
|
|
485
485
|
* 请求数据通过gcm模式加密
|
|
@@ -510,7 +510,7 @@ export declare function responseDataEncryption<T>(stepCb: (_headers: {
|
|
|
510
510
|
*/
|
|
511
511
|
export declare const responseDataGcmCryptoInterceptor: <T extends {
|
|
512
512
|
data: unknown;
|
|
513
|
-
}>(response: AxiosResponse<T>) => AxiosResponse<T, any, {}>;
|
|
513
|
+
}>(response: AxiosResponse<T>) => AxiosResponse<T, any, {}, any>;
|
|
514
514
|
|
|
515
515
|
/**
|
|
516
516
|
* 响应数据通过gcm模式解密
|
|
@@ -652,3 +652,45 @@ export declare const useCall: (callBack?: (status: ECallStatus, callStatusText:
|
|
|
652
652
|
};
|
|
653
653
|
|
|
654
654
|
export { }
|
|
655
|
+
|
|
656
|
+
|
|
657
|
+
|
|
658
|
+
declare module "axios" {
|
|
659
|
+
export interface InternalAxiosRequestConfig {
|
|
660
|
+
/**
|
|
661
|
+
* 是否启用请求加密
|
|
662
|
+
* @default false
|
|
663
|
+
*/
|
|
664
|
+
enableRequestCrypto?: boolean;
|
|
665
|
+
|
|
666
|
+
/**
|
|
667
|
+
* 是否启用响应加密
|
|
668
|
+
* @default false
|
|
669
|
+
*/
|
|
670
|
+
enableResponseCrypto?: boolean;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
// eslint-disable-next-line
|
|
674
|
+
export interface AxiosRequestConfig<D = any> {
|
|
675
|
+
/**
|
|
676
|
+
* 是否启用请求加密
|
|
677
|
+
* @default false
|
|
678
|
+
*/
|
|
679
|
+
enableRequestCrypto?: boolean;
|
|
680
|
+
|
|
681
|
+
/**
|
|
682
|
+
* 是否启用响应加密
|
|
683
|
+
* @default false
|
|
684
|
+
*/
|
|
685
|
+
enableResponseCrypto?: boolean;
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
declare module "gm-crypt" {
|
|
690
|
+
export class sm4 {
|
|
691
|
+
// eslint-disable-next-line
|
|
692
|
+
public constructor(options: { key: string; iv: string; mode?: "cbc" | "ecb"; cipherType?: "base64" | "text" }) {}
|
|
693
|
+
public encrypt(data: string): string;
|
|
694
|
+
public decrypt(encryptedData: string): string;
|
|
695
|
+
}
|
|
696
|
+
}
|
|
@@ -7,8 +7,8 @@ import { isNullOrUndefined as f } from "../../utils/is.js";
|
|
|
7
7
|
import "vue";
|
|
8
8
|
const g = {
|
|
9
9
|
install: (e, t) => {
|
|
10
|
-
r.init(t), t.router.beforeEach(async (o, c,
|
|
11
|
-
await r.initPublicKey(),
|
|
10
|
+
r.init(t), t.router.beforeEach(async (o, c, s) => {
|
|
11
|
+
await r.initPublicKey(), s();
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
14
|
}, x = (e) => {
|
|
@@ -34,8 +34,8 @@ const i = (e, t) => e && (e[t] || e.get(t)) || "", R = async (e) => {
|
|
|
34
34
|
d(e.url)
|
|
35
35
|
);
|
|
36
36
|
if (e.data = f(e.data) ? e.data : o, r.isEnableResponseCrypto(e)) {
|
|
37
|
-
const { publicKey: c, privateKey:
|
|
38
|
-
y.set(c, { privateKey:
|
|
37
|
+
const { publicKey: c, privateKey: s } = K.generateKeyPairHex();
|
|
38
|
+
y.set(c, { privateKey: s, timestamp: Date.now() }), e.headers.set(a.gcmPublicKey, c);
|
|
39
39
|
}
|
|
40
40
|
return e.headers.set(t), e;
|
|
41
41
|
}, H = (e) => {
|
|
@@ -49,8 +49,8 @@ const i = (e, t) => e && (e[t] || e.get(t)) || "", R = async (e) => {
|
|
|
49
49
|
const o = y.get(t);
|
|
50
50
|
if (y.delete(t), !o)
|
|
51
51
|
throw new Error("[gcm-crypto] Private key not found, possible security issue or expired request");
|
|
52
|
-
const { privateKey: c } = o, { data:
|
|
53
|
-
if (f(
|
|
52
|
+
const { privateKey: c } = o, { data: s, ...C } = e.data;
|
|
53
|
+
if (f(s))
|
|
54
54
|
return e;
|
|
55
55
|
const p = i(e.headers, a.encryptIv), u = i(e.headers, a.encryptKey), m = i(e.headers, a.encryptTag);
|
|
56
56
|
if (!p || !u || !m)
|
|
@@ -59,17 +59,19 @@ const i = (e, t) => e && (e[t] || e.get(t)) || "", R = async (e) => {
|
|
|
59
59
|
r.responseBeforeCryptoCallBacks.forEach((b) => {
|
|
60
60
|
b(e);
|
|
61
61
|
});
|
|
62
|
-
const
|
|
62
|
+
const n = w(c, D(u));
|
|
63
63
|
e.data = {
|
|
64
64
|
...C,
|
|
65
|
-
data: E(
|
|
65
|
+
data: E(n, s, d(e.config.url), {
|
|
66
66
|
[a.encryptIv]: p,
|
|
67
|
-
[a.encryptKey]:
|
|
67
|
+
[a.encryptKey]: n,
|
|
68
68
|
[a.encryptTag]: m
|
|
69
69
|
})
|
|
70
70
|
};
|
|
71
|
-
} catch (
|
|
72
|
-
throw new Error(`[gcm-crypto] Decryption failed: ${
|
|
71
|
+
} catch (n) {
|
|
72
|
+
throw new Error(`[gcm-crypto] Decryption failed: ${n instanceof Error ? n.message : String(n)}`, {
|
|
73
|
+
cause: n
|
|
74
|
+
});
|
|
73
75
|
}
|
|
74
76
|
return e;
|
|
75
77
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { sm4 as
|
|
1
|
+
import { sm4 as u } from "../../../vendor/sm-crypto-v2/dist/index.js";
|
|
2
2
|
import { EGcmHeaderKey as r } from "./constants.js";
|
|
3
|
-
import { generateHex as y, dataToStr as T, stringToUtf8Bytes as
|
|
4
|
-
const v = (
|
|
5
|
-
const t = y(12), e = y(16), { output: o, tag: a } =
|
|
3
|
+
import { generateHex as y, dataToStr as T, stringToUtf8Bytes as d, bytesToBase64 as m, hexToBase64 as f, sm2Encrypt as E, base64ToHex as i, utf8BytesToString as S } from "./utils.js";
|
|
4
|
+
const v = (c, n, p) => {
|
|
5
|
+
const t = y(12), e = y(16), { output: o, tag: a } = u.encrypt(T(n), e, {
|
|
6
6
|
mode: "gcm",
|
|
7
7
|
iv: t,
|
|
8
|
-
associatedData:
|
|
8
|
+
associatedData: d(`uri=${p}`),
|
|
9
9
|
output: "array",
|
|
10
10
|
outputTag: !0
|
|
11
11
|
});
|
|
@@ -15,25 +15,26 @@ const v = (s, c, n) => {
|
|
|
15
15
|
headers: {
|
|
16
16
|
[r.encryptIv]: t,
|
|
17
17
|
[r.encryptTag]: m(a),
|
|
18
|
-
[r.encryptKey]: f(E(
|
|
18
|
+
[r.encryptKey]: f(E(c, e))
|
|
19
19
|
},
|
|
20
20
|
data: {
|
|
21
21
|
body: m(o)
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
|
-
}, w = (
|
|
25
|
-
const e = t[r.encryptIv], o = i(t[r.encryptTag]), a =
|
|
24
|
+
}, w = (c, n, p, t) => {
|
|
25
|
+
const e = t[r.encryptIv], o = i(t[r.encryptTag]), a = u.decrypt(i(n), c, {
|
|
26
26
|
mode: "gcm",
|
|
27
27
|
iv: e,
|
|
28
|
-
associatedData:
|
|
28
|
+
associatedData: d(`uri=${p}`),
|
|
29
29
|
output: "array",
|
|
30
30
|
tag: o
|
|
31
31
|
}), g = S(a);
|
|
32
32
|
try {
|
|
33
33
|
return JSON.parse(g);
|
|
34
|
-
} catch (
|
|
34
|
+
} catch (s) {
|
|
35
35
|
throw new Error(
|
|
36
|
-
`[gcm-crypto] Failed to parse decrypted data as JSON: ${
|
|
36
|
+
`[gcm-crypto] Failed to parse decrypted data as JSON: ${s instanceof Error ? s.message : String(s)}`,
|
|
37
|
+
{ cause: s }
|
|
37
38
|
);
|
|
38
39
|
}
|
|
39
40
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UINT32_LE as h, StringType as k } from "../../../token-types/lib/index.js";
|
|
2
|
-
import D from "../../../../commonjs-virtual-dir/
|
|
2
|
+
import D from "../../../../commonjs-virtual-dir/browser2.js";
|
|
3
3
|
import { Signature as c, EndOfCentralDirectoryRecordToken as L, FileHeader as E, DataDescriptor as y, LocalFileHeaderToken as S } from "./ZipToken.js";
|
|
4
4
|
function m(s) {
|
|
5
5
|
const t = new Uint8Array(h.len);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { UINT32_LE as
|
|
2
|
-
import { EndOfStreamError as
|
|
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 {
|
|
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(
|
|
23
|
-
|
|
22
|
+
start(a) {
|
|
23
|
+
a.enqueue(e), a.close();
|
|
24
24
|
}
|
|
25
25
|
}).pipeThrough(new DecompressionStream("deflate-raw")).getReader(), s = [];
|
|
26
|
-
let
|
|
26
|
+
let c = 0;
|
|
27
27
|
try {
|
|
28
28
|
for (; ; ) {
|
|
29
|
-
const { done:
|
|
30
|
-
if (
|
|
29
|
+
const { done: a, value: m } = await i.read();
|
|
30
|
+
if (a)
|
|
31
31
|
break;
|
|
32
|
-
if (
|
|
33
|
-
throw await i.cancel()
|
|
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
|
|
43
|
+
const o = new Uint8Array(c);
|
|
40
44
|
let p = 0;
|
|
41
|
-
for (const
|
|
42
|
-
|
|
43
|
-
return
|
|
45
|
+
for (const a of s)
|
|
46
|
+
o.set(a, p), p += a.length;
|
|
47
|
+
return o;
|
|
44
48
|
}
|
|
45
|
-
function
|
|
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
|
|
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
|
|
57
|
-
if (e instanceof
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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,
|
|
198
|
+
const S = 134695760, f = 16, $ = f - 1;
|
|
195
199
|
function j(e, t) {
|
|
196
|
-
if (e.length <
|
|
200
|
+
if (e.length < f)
|
|
197
201
|
return -1;
|
|
198
|
-
const r = e.length -
|
|
202
|
+
const r = e.length - f;
|
|
199
203
|
for (let n = 0; n <= r; n++)
|
|
200
|
-
if (
|
|
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
|
|
208
|
+
async function G(e, { shouldBuffer: t, maximumLength: r = d } = {}) {
|
|
205
209
|
const { syncBuffer: n } = e, { length: i } = n, s = [];
|
|
206
|
-
let
|
|
210
|
+
let c = 0;
|
|
207
211
|
for (; ; ) {
|
|
208
|
-
const
|
|
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 (
|
|
212
|
-
throw new
|
|
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 (
|
|
222
|
-
return
|
|
225
|
+
if (h(e.tokenizer) || (e.knownSizeDescriptorScannedBytes += c), !!t)
|
|
226
|
+
return R(s, c);
|
|
223
227
|
}
|
|
224
|
-
function
|
|
225
|
-
return
|
|
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
|
|
231
|
+
async function J(e, t, { shouldBuffer: r, maximumDescriptorLength: n = d } = {}) {
|
|
228
232
|
if (t.dataDescriptor && t.compressedSize === 0)
|
|
229
|
-
return
|
|
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:
|
|
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 =
|
|
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
|
|
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
|
|
272
|
+
const c = await J(this, i, {
|
|
269
273
|
shouldBuffer: !!s.handler,
|
|
270
|
-
maximumDescriptorLength: Math.min(d,
|
|
274
|
+
maximumDescriptorLength: Math.min(d, q(this, n))
|
|
271
275
|
});
|
|
272
|
-
if (s.handler && await this.inflate(i,
|
|
273
|
-
const
|
|
274
|
-
if (await this.tokenizer.readBuffer(
|
|
275
|
-
throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position -
|
|
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
|
|
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 =
|
|
287
|
+
const r = O(), n = U();
|
|
284
288
|
try {
|
|
285
289
|
await new y(e).unzip((s) => {
|
|
286
|
-
if (
|
|
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
|
|
289
|
-
if (!
|
|
290
|
-
return t =
|
|
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
|
|
312
|
-
t =
|
|
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
|
|
320
|
-
m && (t =
|
|
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 (!
|
|
336
|
+
if (!_(s))
|
|
333
337
|
throw s;
|
|
334
|
-
r.isParsingContentTypes && (r.isParsingContentTypes = !1, r.hasUnparseableContentTypes = !0), !t && s instanceof
|
|
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 =
|
|
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"
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { UINT32_BE as T, UINT16_BE as p, StringType as S, UINT16_LE as g, UINT32_LE as
|
|
2
|
-
import { fromWebStream as
|
|
1
|
+
import { UINT32_BE as T, UINT16_BE as p, StringType as S, UINT16_LE as g, UINT32_LE as z } from "../../token-types/lib/index.js";
|
|
2
|
+
import { fromWebStream as I, fromBuffer as M, fromBlob as O } from "../../strtok3/lib/core.js";
|
|
3
3
|
import "../../@tokenizer/inflate/lib/ZipHandler.js";
|
|
4
|
-
import { GzipHandler as
|
|
5
|
-
import { concatUint8Arrays as
|
|
6
|
-
import { stringToBytes as
|
|
4
|
+
import { GzipHandler as P } from "../../@tokenizer/inflate/lib/GzipHandler.js";
|
|
5
|
+
import { concatUint8Arrays as j } from "../../uint8array-extras/index.js";
|
|
6
|
+
import { stringToBytes as A, uint32SyncSafeToken as L, tarHeaderChecksumMatches as R } from "./tokens.js";
|
|
7
7
|
import { mimeTypes as N, extensions as U } from "./supported.js";
|
|
8
8
|
import { ParserHardLimitError as q, hasUnknownFileSize as l, checkBytes as h, safeIgnore as F, maximumUntrustedSkipSizeInBytes as b } from "./parser.js";
|
|
9
9
|
import { detectZip as G } from "./detectors/zip.js";
|
|
@@ -11,71 +11,75 @@ import { detectEbml as _ } from "./detectors/ebml.js";
|
|
|
11
11
|
import { detectPng as H } from "./detectors/png.js";
|
|
12
12
|
import { detectAsf as V } from "./detectors/asf.js";
|
|
13
13
|
import { EndOfStreamError as d } from "../../strtok3/lib/stream/Errors.js";
|
|
14
|
-
const k = 4100, W = k -
|
|
15
|
-
function J(
|
|
16
|
-
return Number.isFinite(
|
|
14
|
+
const k = 4100, W = k - 4, $ = b, K = 1, B = 100, w = b, X = 512, v = 256, Z = 1024 * 1024, D = b;
|
|
15
|
+
function J(s) {
|
|
16
|
+
return Number.isFinite(s) ? Math.max(1, Math.trunc(s)) : k;
|
|
17
17
|
}
|
|
18
|
-
function Q(
|
|
19
|
-
return Number.isFinite(
|
|
18
|
+
function Q(s) {
|
|
19
|
+
return Number.isFinite(s) ? Math.max(0, Math.min(W, Math.trunc(s))) : 0;
|
|
20
20
|
}
|
|
21
|
-
function Y(
|
|
22
|
-
return Number.isFinite(
|
|
21
|
+
function Y(s) {
|
|
22
|
+
return Number.isFinite(s) ? Math.max(0, s) : Number.MAX_SAFE_INTEGER;
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
return import(
|
|
24
|
+
function E(s) {
|
|
25
|
+
return import(
|
|
26
|
+
/* @vite-ignore */
|
|
27
|
+
/* webpackIgnore: true */
|
|
28
|
+
s
|
|
29
|
+
);
|
|
26
30
|
}
|
|
27
|
-
function ee(
|
|
28
|
-
return
|
|
31
|
+
function ee(s) {
|
|
32
|
+
return s.pipeThrough(new TransformStream());
|
|
29
33
|
}
|
|
30
|
-
function
|
|
31
|
-
return e === void 0 ?
|
|
32
|
-
|
|
33
|
-
new Promise((
|
|
34
|
+
function C(s, e) {
|
|
35
|
+
return e === void 0 ? s.read() : (e.throwIfAborted(), Promise.race([
|
|
36
|
+
s.read(),
|
|
37
|
+
new Promise((i, r) => {
|
|
34
38
|
e.addEventListener("abort", () => {
|
|
35
|
-
|
|
39
|
+
r(e.reason), s.cancel(e.reason).catch(() => {
|
|
36
40
|
});
|
|
37
41
|
}, { once: !0 });
|
|
38
42
|
})
|
|
39
43
|
]));
|
|
40
44
|
}
|
|
41
|
-
function te(
|
|
42
|
-
const
|
|
43
|
-
let
|
|
45
|
+
function te(s, e) {
|
|
46
|
+
const i = s.getReader();
|
|
47
|
+
let r = 0, t = !1, n = !1;
|
|
44
48
|
const c = async (x) => {
|
|
45
|
-
|
|
49
|
+
t || n || (n = !0, await i.cancel(x));
|
|
46
50
|
};
|
|
47
51
|
return new ReadableStream({
|
|
48
52
|
async pull(x) {
|
|
49
|
-
if (
|
|
53
|
+
if (r >= e) {
|
|
50
54
|
x.close(), await c();
|
|
51
55
|
return;
|
|
52
56
|
}
|
|
53
|
-
const { done: f, value: a } = await
|
|
57
|
+
const { done: f, value: a } = await i.read();
|
|
54
58
|
if (f || !a) {
|
|
55
|
-
|
|
59
|
+
t = !0, x.close();
|
|
56
60
|
return;
|
|
57
61
|
}
|
|
58
|
-
const u = e -
|
|
62
|
+
const u = e - r;
|
|
59
63
|
if (a.length > u) {
|
|
60
|
-
x.enqueue(a.subarray(0, u)),
|
|
64
|
+
x.enqueue(a.subarray(0, u)), r += u, x.close(), await c();
|
|
61
65
|
return;
|
|
62
66
|
}
|
|
63
|
-
x.enqueue(a),
|
|
67
|
+
x.enqueue(a), r += a.length;
|
|
64
68
|
},
|
|
65
69
|
async cancel(x) {
|
|
66
70
|
await c(x);
|
|
67
71
|
}
|
|
68
72
|
});
|
|
69
73
|
}
|
|
70
|
-
async function le(
|
|
71
|
-
return new y(e).fromStream(
|
|
74
|
+
async function le(s, e) {
|
|
75
|
+
return new y(e).fromStream(s);
|
|
72
76
|
}
|
|
73
77
|
class y {
|
|
74
78
|
constructor(e) {
|
|
75
|
-
const
|
|
79
|
+
const i = Q(e?.mpegOffsetTolerance);
|
|
76
80
|
this.options = {
|
|
77
81
|
...e,
|
|
78
|
-
mpegOffsetTolerance:
|
|
82
|
+
mpegOffsetTolerance: i
|
|
79
83
|
}, this.detectors = [
|
|
80
84
|
...this.options.customDetectors ?? [],
|
|
81
85
|
{ id: "core", detect: this.detectConfident },
|
|
@@ -90,23 +94,23 @@ class y {
|
|
|
90
94
|
};
|
|
91
95
|
}
|
|
92
96
|
createTokenizerFromWebStream(e) {
|
|
93
|
-
return
|
|
97
|
+
return I(ee(e), this.getTokenizerOptions());
|
|
94
98
|
}
|
|
95
|
-
async parseTokenizer(e,
|
|
96
|
-
this.detectionReentryCount =
|
|
97
|
-
const
|
|
98
|
-
for (const
|
|
99
|
-
let
|
|
99
|
+
async parseTokenizer(e, i = 0) {
|
|
100
|
+
this.detectionReentryCount = i;
|
|
101
|
+
const r = e.position;
|
|
102
|
+
for (const t of this.detectors) {
|
|
103
|
+
let n;
|
|
100
104
|
try {
|
|
101
|
-
|
|
105
|
+
n = await t.detect(e);
|
|
102
106
|
} catch (c) {
|
|
103
107
|
if (c instanceof d || c instanceof q)
|
|
104
108
|
return;
|
|
105
109
|
throw c;
|
|
106
110
|
}
|
|
107
|
-
if (
|
|
108
|
-
return
|
|
109
|
-
if (
|
|
111
|
+
if (n)
|
|
112
|
+
return n;
|
|
113
|
+
if (r !== e.position)
|
|
110
114
|
return;
|
|
111
115
|
}
|
|
112
116
|
}
|
|
@@ -120,68 +124,68 @@ class y {
|
|
|
120
124
|
async fromBuffer(e) {
|
|
121
125
|
if (!(e instanceof Uint8Array || e instanceof ArrayBuffer))
|
|
122
126
|
throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof e}\``);
|
|
123
|
-
const
|
|
124
|
-
if (
|
|
125
|
-
return this.fromTokenizer(
|
|
127
|
+
const i = e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
128
|
+
if (i?.length > 1)
|
|
129
|
+
return this.fromTokenizer(M(i, this.getTokenizerOptions()));
|
|
126
130
|
}
|
|
127
131
|
async fromBlob(e) {
|
|
128
132
|
this.options.signal?.throwIfAborted();
|
|
129
|
-
const
|
|
130
|
-
return this.fromTokenizer(
|
|
133
|
+
const i = O(e, this.getTokenizerOptions());
|
|
134
|
+
return this.fromTokenizer(i);
|
|
131
135
|
}
|
|
132
136
|
async fromStream(e) {
|
|
133
137
|
this.options.signal?.throwIfAborted();
|
|
134
|
-
const
|
|
135
|
-
return this.fromTokenizer(
|
|
138
|
+
const i = this.createTokenizerFromWebStream(e);
|
|
139
|
+
return this.fromTokenizer(i);
|
|
136
140
|
}
|
|
137
141
|
async fromFile(e) {
|
|
138
142
|
this.options.signal?.throwIfAborted();
|
|
139
|
-
const [{ default:
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
]),
|
|
143
|
-
if (!
|
|
144
|
-
await
|
|
143
|
+
const [{ default: i }, { FileTokenizer: r }] = await Promise.all([
|
|
144
|
+
E("node:fs/promises"),
|
|
145
|
+
E("strtok3")
|
|
146
|
+
]), t = await i.open(e, i.constants.O_RDONLY | i.constants.O_NONBLOCK), n = await t.stat();
|
|
147
|
+
if (!n.isFile()) {
|
|
148
|
+
await t.close();
|
|
145
149
|
return;
|
|
146
150
|
}
|
|
147
|
-
const c = new
|
|
151
|
+
const c = new r(t, {
|
|
148
152
|
...this.getTokenizerOptions(),
|
|
149
|
-
fileInfo: { path: e, size:
|
|
153
|
+
fileInfo: { path: e, size: n.size }
|
|
150
154
|
});
|
|
151
155
|
return this.fromTokenizer(c);
|
|
152
156
|
}
|
|
153
|
-
async toDetectionStream(e,
|
|
157
|
+
async toDetectionStream(e, i) {
|
|
154
158
|
this.options.signal?.throwIfAborted();
|
|
155
|
-
const
|
|
156
|
-
let
|
|
159
|
+
const r = J(i?.sampleSize ?? k);
|
|
160
|
+
let t, n = !1;
|
|
157
161
|
const c = e.getReader(), x = [];
|
|
158
162
|
let f = 0;
|
|
159
163
|
try {
|
|
160
|
-
for (; f <
|
|
161
|
-
const { value: m, done: o } = await
|
|
164
|
+
for (; f < r; ) {
|
|
165
|
+
const { value: m, done: o } = await C(c, this.options.signal);
|
|
162
166
|
if (o || !m) {
|
|
163
|
-
|
|
167
|
+
n = !0;
|
|
164
168
|
break;
|
|
165
169
|
}
|
|
166
170
|
x.push(m), f += m.length;
|
|
167
171
|
}
|
|
168
|
-
if (!
|
|
169
|
-
const { value: m, done: o } = await
|
|
170
|
-
o || !m ?
|
|
172
|
+
if (!n && f === r) {
|
|
173
|
+
const { value: m, done: o } = await C(c, this.options.signal);
|
|
174
|
+
o || !m ? n = !0 : (x.push(m), f += m.length);
|
|
171
175
|
}
|
|
172
176
|
} finally {
|
|
173
177
|
c.releaseLock();
|
|
174
178
|
}
|
|
175
179
|
if (f > 0) {
|
|
176
|
-
const m = x.length === 1 ? x[0] :
|
|
180
|
+
const m = x.length === 1 ? x[0] : j(x);
|
|
177
181
|
try {
|
|
178
|
-
|
|
182
|
+
t = await this.fromBuffer(m.subarray(0, r));
|
|
179
183
|
} catch (o) {
|
|
180
184
|
if (!(o instanceof d))
|
|
181
185
|
throw o;
|
|
182
|
-
|
|
186
|
+
t = void 0;
|
|
183
187
|
}
|
|
184
|
-
!
|
|
188
|
+
!n && t?.ext === "pages" && (t = {
|
|
185
189
|
ext: "zip",
|
|
186
190
|
mime: "application/zip"
|
|
187
191
|
});
|
|
@@ -195,7 +199,7 @@ class y {
|
|
|
195
199
|
o.enqueue(m);
|
|
196
200
|
}
|
|
197
201
|
}), u = e.pipeThrough(a);
|
|
198
|
-
return u.fileType =
|
|
202
|
+
return u.fileType = t, u;
|
|
199
203
|
}
|
|
200
204
|
async detectGzip(e) {
|
|
201
205
|
if (this.gzipProbeDepth >= K)
|
|
@@ -203,25 +207,25 @@ class y {
|
|
|
203
207
|
ext: "gz",
|
|
204
208
|
mime: "application/gzip"
|
|
205
209
|
};
|
|
206
|
-
const
|
|
207
|
-
let
|
|
208
|
-
if (
|
|
210
|
+
const i = new P(e), r = te(i.inflate(), $), t = l(e);
|
|
211
|
+
let n, c, x, f;
|
|
212
|
+
if (t) {
|
|
209
213
|
const a = new AbortController();
|
|
210
|
-
|
|
211
|
-
a.abort(new DOMException(`Operation timed out after ${
|
|
212
|
-
},
|
|
214
|
+
n = setTimeout(() => {
|
|
215
|
+
a.abort(new DOMException(`Operation timed out after ${B} ms`, "TimeoutError"));
|
|
216
|
+
}, B), c = this.options.signal === void 0 ? a.signal : AbortSignal.any([this.options.signal, a.signal]), x = new y({
|
|
213
217
|
...this.options,
|
|
214
218
|
signal: c
|
|
215
219
|
}), x.gzipProbeDepth = this.gzipProbeDepth + 1;
|
|
216
220
|
} else
|
|
217
221
|
this.gzipProbeDepth++;
|
|
218
222
|
try {
|
|
219
|
-
f = await (x ?? this).fromStream(
|
|
223
|
+
f = await (x ?? this).fromStream(r);
|
|
220
224
|
} catch (a) {
|
|
221
225
|
if (a?.name === "AbortError" && c?.reason?.name !== "TimeoutError")
|
|
222
226
|
throw a;
|
|
223
227
|
} finally {
|
|
224
|
-
clearTimeout(
|
|
228
|
+
clearTimeout(n), t || this.gzipProbeDepth--;
|
|
225
229
|
}
|
|
226
230
|
return f?.ext === "tar" ? {
|
|
227
231
|
ext: "tar.gz",
|
|
@@ -231,11 +235,11 @@ class y {
|
|
|
231
235
|
mime: "application/gzip"
|
|
232
236
|
};
|
|
233
237
|
}
|
|
234
|
-
check(e,
|
|
235
|
-
return h(this.buffer, e,
|
|
238
|
+
check(e, i) {
|
|
239
|
+
return h(this.buffer, e, i);
|
|
236
240
|
}
|
|
237
|
-
checkString(e,
|
|
238
|
-
return this.check(
|
|
241
|
+
checkString(e, i) {
|
|
242
|
+
return this.check(A(e, i?.encoding), i);
|
|
239
243
|
}
|
|
240
244
|
// Detections with a high degree of certainty in identifying the correct file type
|
|
241
245
|
detectConfident = async (e) => {
|
|
@@ -308,23 +312,23 @@ class y {
|
|
|
308
312
|
maximumLength: 6,
|
|
309
313
|
reason: "ID3 header prefix"
|
|
310
314
|
});
|
|
311
|
-
const t = await e.readToken(
|
|
312
|
-
if (!Number.isFinite(t) || t < 0 ||
|
|
315
|
+
const t = await e.readToken(L), n = l(e);
|
|
316
|
+
if (!Number.isFinite(t) || t < 0 || n && (t > w || e.position + t > w))
|
|
313
317
|
return;
|
|
314
318
|
if (e.position + t > e.fileInfo.size)
|
|
315
|
-
return
|
|
319
|
+
return n ? void 0 : {
|
|
316
320
|
ext: "mp3",
|
|
317
321
|
mime: "audio/mpeg"
|
|
318
322
|
};
|
|
319
323
|
try {
|
|
320
324
|
await F(e, t, {
|
|
321
|
-
maximumLength:
|
|
325
|
+
maximumLength: n ? w : e.fileInfo.size,
|
|
322
326
|
reason: "ID3 payload"
|
|
323
327
|
});
|
|
324
|
-
} catch (
|
|
325
|
-
if (
|
|
328
|
+
} catch (c) {
|
|
329
|
+
if (c instanceof d)
|
|
326
330
|
return;
|
|
327
|
-
throw
|
|
331
|
+
throw c;
|
|
328
332
|
}
|
|
329
333
|
return this.detectionReentryCount >= v ? void 0 : (this.detectionReentryCount++, this.parseTokenizer(e, this.detectionReentryCount));
|
|
330
334
|
}
|
|
@@ -608,13 +612,13 @@ class y {
|
|
|
608
612
|
mime: "application/vnd.ms-htmlhelp"
|
|
609
613
|
};
|
|
610
614
|
if (this.check([202, 254, 186, 190])) {
|
|
611
|
-
const t = T.get(this.buffer, 4),
|
|
615
|
+
const t = T.get(this.buffer, 4), n = p.get(this.buffer, 6);
|
|
612
616
|
if (t > 0 && t <= 30)
|
|
613
617
|
return {
|
|
614
618
|
ext: "macho",
|
|
615
619
|
mime: "application/x-mach-binary"
|
|
616
620
|
};
|
|
617
|
-
if (
|
|
621
|
+
if (n > 30)
|
|
618
622
|
return {
|
|
619
623
|
ext: "class",
|
|
620
624
|
mime: "application/java-vm"
|
|
@@ -893,8 +897,8 @@ class y {
|
|
|
893
897
|
const t = new DataView(this.buffer.buffer).getUint32(12, !0);
|
|
894
898
|
if (t > 12 && this.buffer.length >= t + 16)
|
|
895
899
|
try {
|
|
896
|
-
const
|
|
897
|
-
if (JSON.parse(
|
|
900
|
+
const n = new TextDecoder().decode(this.buffer.subarray(16, t + 16));
|
|
901
|
+
if (JSON.parse(n).files)
|
|
898
902
|
return {
|
|
899
903
|
ext: "asar",
|
|
900
904
|
mime: "application/x-asar"
|
|
@@ -963,7 +967,7 @@ class y {
|
|
|
963
967
|
ext: "jmp",
|
|
964
968
|
mime: "application/x-jmp-data"
|
|
965
969
|
};
|
|
966
|
-
if (await e.peekBuffer(this.buffer, { length: Math.min(512, e.fileInfo.size), mayBeLess: !0 }), this.checkString("ustar", { offset: 257 }) && (this.checkString("\0", { offset: 262 }) || this.checkString(" ", { offset: 262 })) || this.check([0, 0, 0, 0, 0, 0], { offset: 257 }) &&
|
|
970
|
+
if (await e.peekBuffer(this.buffer, { length: Math.min(512, e.fileInfo.size), mayBeLess: !0 }), this.checkString("ustar", { offset: 257 }) && (this.checkString("\0", { offset: 262 }) || this.checkString(" ", { offset: 262 })) || this.check([0, 0, 0, 0, 0, 0], { offset: 257 }) && R(this.buffer))
|
|
967
971
|
return {
|
|
968
972
|
ext: "tar",
|
|
969
973
|
mime: "application/x-tar"
|
|
@@ -987,12 +991,25 @@ class y {
|
|
|
987
991
|
ext: "pgp",
|
|
988
992
|
mime: "application/pgp-encrypted"
|
|
989
993
|
};
|
|
994
|
+
const i = 32769, r = 5;
|
|
995
|
+
if (e.supportsRandomAccess() && e.fileInfo.size >= i + r) {
|
|
996
|
+
const t = new Uint8Array(r);
|
|
997
|
+
if (await e.peekBuffer(t, {
|
|
998
|
+
position: i,
|
|
999
|
+
length: r,
|
|
1000
|
+
mayBeLess: !0
|
|
1001
|
+
}), h(t, A("CD001")))
|
|
1002
|
+
return {
|
|
1003
|
+
ext: "iso",
|
|
1004
|
+
mime: "application/x-iso9660-image"
|
|
1005
|
+
};
|
|
1006
|
+
}
|
|
990
1007
|
};
|
|
991
1008
|
// Detections with limited supporting data, resulting in a higher likelihood of false positives
|
|
992
1009
|
detectImprecise = async (e) => {
|
|
993
1010
|
this.buffer = new Uint8Array(k);
|
|
994
|
-
const
|
|
995
|
-
if (await e.peekBuffer(this.buffer, { length: Math.min(8,
|
|
1011
|
+
const i = Y(e.fileInfo.size);
|
|
1012
|
+
if (await e.peekBuffer(this.buffer, { length: Math.min(8, i), mayBeLess: !0 }), this.check([0, 0, 1, 186]) || this.check([0, 0, 1, 179]))
|
|
996
1013
|
return {
|
|
997
1014
|
ext: "mpg",
|
|
998
1015
|
mime: "video/mpeg"
|
|
@@ -1012,16 +1029,16 @@ class y {
|
|
|
1012
1029
|
ext: "cur",
|
|
1013
1030
|
mime: "image/x-icon"
|
|
1014
1031
|
};
|
|
1015
|
-
if (await e.peekBuffer(this.buffer, { length: Math.min(
|
|
1016
|
-
for (let
|
|
1017
|
-
const
|
|
1018
|
-
if (
|
|
1019
|
-
return
|
|
1032
|
+
if (await e.peekBuffer(this.buffer, { length: Math.min(4 + this.options.mpegOffsetTolerance, i), mayBeLess: !0 }), this.buffer.length >= 4 + this.options.mpegOffsetTolerance)
|
|
1033
|
+
for (let r = 0; r <= this.options.mpegOffsetTolerance; ++r) {
|
|
1034
|
+
const t = this.scanMpeg(r);
|
|
1035
|
+
if (t)
|
|
1036
|
+
return t;
|
|
1020
1037
|
}
|
|
1021
1038
|
};
|
|
1022
1039
|
async readTiffTag(e) {
|
|
1023
|
-
const
|
|
1024
|
-
switch (await this.tokenizer.ignore(10),
|
|
1040
|
+
const i = await this.tokenizer.readToken(e ? p : g);
|
|
1041
|
+
switch (await this.tokenizer.ignore(10), i) {
|
|
1025
1042
|
case 50341:
|
|
1026
1043
|
return {
|
|
1027
1044
|
ext: "arw",
|
|
@@ -1035,27 +1052,27 @@ class y {
|
|
|
1035
1052
|
}
|
|
1036
1053
|
}
|
|
1037
1054
|
async readTiffIFD(e) {
|
|
1038
|
-
const
|
|
1039
|
-
if (!(
|
|
1040
|
-
for (let
|
|
1041
|
-
const
|
|
1042
|
-
if (
|
|
1043
|
-
return
|
|
1055
|
+
const i = await this.tokenizer.readToken(e ? p : g);
|
|
1056
|
+
if (!(i > X) && !(l(this.tokenizer) && 2 + i * 12 > D))
|
|
1057
|
+
for (let r = 0; r < i; ++r) {
|
|
1058
|
+
const t = await this.readTiffTag(e);
|
|
1059
|
+
if (t)
|
|
1060
|
+
return t;
|
|
1044
1061
|
}
|
|
1045
1062
|
}
|
|
1046
1063
|
async readTiffHeader(e) {
|
|
1047
|
-
const
|
|
1064
|
+
const i = {
|
|
1048
1065
|
ext: "tif",
|
|
1049
1066
|
mime: "image/tiff"
|
|
1050
|
-
},
|
|
1051
|
-
if (
|
|
1052
|
-
if (
|
|
1067
|
+
}, r = (e ? p : g).get(this.buffer, 2), t = (e ? T : z).get(this.buffer, 4);
|
|
1068
|
+
if (r === 42) {
|
|
1069
|
+
if (t >= 6) {
|
|
1053
1070
|
if (this.checkString("CR", { offset: 8 }))
|
|
1054
1071
|
return {
|
|
1055
1072
|
ext: "cr2",
|
|
1056
1073
|
mime: "image/x-canon-cr2"
|
|
1057
1074
|
};
|
|
1058
|
-
if (
|
|
1075
|
+
if (t >= 8) {
|
|
1059
1076
|
const x = (e ? p : g).get(this.buffer, 8), f = (e ? p : g).get(this.buffer, 10);
|
|
1060
1077
|
if (x === 28 && f === 254 || x === 31 && f === 11)
|
|
1061
1078
|
return {
|
|
@@ -1064,12 +1081,12 @@ class y {
|
|
|
1064
1081
|
};
|
|
1065
1082
|
}
|
|
1066
1083
|
}
|
|
1067
|
-
if (l(this.tokenizer) &&
|
|
1068
|
-
return
|
|
1069
|
-
const
|
|
1084
|
+
if (l(this.tokenizer) && t > Z)
|
|
1085
|
+
return i;
|
|
1086
|
+
const n = l(this.tokenizer) ? D : this.tokenizer.fileInfo.size;
|
|
1070
1087
|
try {
|
|
1071
|
-
await F(this.tokenizer,
|
|
1072
|
-
maximumLength:
|
|
1088
|
+
await F(this.tokenizer, t, {
|
|
1089
|
+
maximumLength: n,
|
|
1073
1090
|
reason: "TIFF IFD offset"
|
|
1074
1091
|
});
|
|
1075
1092
|
} catch (x) {
|
|
@@ -1085,10 +1102,10 @@ class y {
|
|
|
1085
1102
|
return;
|
|
1086
1103
|
throw x;
|
|
1087
1104
|
}
|
|
1088
|
-
return c ??
|
|
1105
|
+
return c ?? i;
|
|
1089
1106
|
}
|
|
1090
|
-
if (
|
|
1091
|
-
return
|
|
1107
|
+
if (r === 43)
|
|
1108
|
+
return i;
|
|
1092
1109
|
}
|
|
1093
1110
|
/**
|
|
1094
1111
|
Scan check MPEG 1 or 2 Layer 3 header, or 'layer 0' for ADTS (MPEG sync-word 0xFFE).
|
|
@@ -1099,13 +1116,12 @@ class y {
|
|
|
1099
1116
|
scanMpeg(e) {
|
|
1100
1117
|
if (this.check([255, 224], { offset: e, mask: [255, 224] })) {
|
|
1101
1118
|
if (this.check([16], { offset: e + 1, mask: [22] }))
|
|
1102
|
-
return
|
|
1103
|
-
ext: "aac",
|
|
1104
|
-
mime: "audio/aac"
|
|
1105
|
-
} : {
|
|
1119
|
+
return {
|
|
1106
1120
|
ext: "aac",
|
|
1107
1121
|
mime: "audio/aac"
|
|
1108
1122
|
};
|
|
1123
|
+
if (this.check([255, 254], { offset: e }) || this.check([8], { offset: e + 1, mask: [24] }) || this.check([240], { offset: e + 2, mask: [240] }) || this.check([12], { offset: e + 2, mask: [12] }))
|
|
1124
|
+
return;
|
|
1109
1125
|
if (this.check([2], { offset: e + 1, mask: [6] }))
|
|
1110
1126
|
return {
|
|
1111
1127
|
ext: "mp3",
|
|
@@ -181,7 +181,8 @@ const a = [
|
|
|
181
181
|
"dat",
|
|
182
182
|
"key",
|
|
183
183
|
"numbers",
|
|
184
|
-
"pages"
|
|
184
|
+
"pages",
|
|
185
|
+
"iso"
|
|
185
186
|
], i = [
|
|
186
187
|
"image/jpeg",
|
|
187
188
|
"image/png",
|
|
@@ -364,7 +365,8 @@ const a = [
|
|
|
364
365
|
"application/x-jmp-data",
|
|
365
366
|
"application/vnd.apple.keynote",
|
|
366
367
|
"application/vnd.apple.numbers",
|
|
367
|
-
"application/vnd.apple.pages"
|
|
368
|
+
"application/vnd.apple.pages",
|
|
369
|
+
"application/x-iso9660-image"
|
|
368
370
|
];
|
|
369
371
|
export {
|
|
370
372
|
a as extensions,
|
|
@@ -204,3 +204,45 @@ export declare const vitePluginRouterRandomParams: () => Plugin_2;
|
|
|
204
204
|
export declare function vitePluginSri(options?: SriPluginOptions): PluginOption;
|
|
205
205
|
|
|
206
206
|
export { }
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
declare module "axios" {
|
|
211
|
+
export interface InternalAxiosRequestConfig {
|
|
212
|
+
/**
|
|
213
|
+
* 是否启用请求加密
|
|
214
|
+
* @default false
|
|
215
|
+
*/
|
|
216
|
+
enableRequestCrypto?: boolean;
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* 是否启用响应加密
|
|
220
|
+
* @default false
|
|
221
|
+
*/
|
|
222
|
+
enableResponseCrypto?: boolean;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// eslint-disable-next-line
|
|
226
|
+
export interface AxiosRequestConfig<D = any> {
|
|
227
|
+
/**
|
|
228
|
+
* 是否启用请求加密
|
|
229
|
+
* @default false
|
|
230
|
+
*/
|
|
231
|
+
enableRequestCrypto?: boolean;
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* 是否启用响应加密
|
|
235
|
+
* @default false
|
|
236
|
+
*/
|
|
237
|
+
enableResponseCrypto?: boolean;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
declare module "gm-crypt" {
|
|
242
|
+
export class sm4 {
|
|
243
|
+
// eslint-disable-next-line
|
|
244
|
+
public constructor(options: { key: string; iv: string; mode?: "cbc" | "ecb"; cipherType?: "base64" | "text" }) {}
|
|
245
|
+
public encrypt(data: string): string;
|
|
246
|
+
public decrypt(encryptedData: string): string;
|
|
247
|
+
}
|
|
248
|
+
}
|
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.
|
|
4
|
+
"version": "1.5.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "前端项目通用工具包",
|
|
7
7
|
"module": "dist/main.js",
|
|
@@ -36,31 +36,31 @@
|
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@babel/core": "^7.28.4",
|
|
38
38
|
"@babel/preset-env": "^7.28.3",
|
|
39
|
-
"@lonely9/eslint-config-team": "^1.
|
|
40
|
-
"@microsoft/api-extractor": "^7.
|
|
39
|
+
"@lonely9/eslint-config-team": "^1.4.0",
|
|
40
|
+
"@microsoft/api-extractor": "^7.59.1",
|
|
41
41
|
"@types/babel__core": "^7.20.5",
|
|
42
42
|
"@types/crypto-js": "^4.2.2",
|
|
43
43
|
"@types/node": "^24.4.0",
|
|
44
44
|
"@types/sdp-transform": "^2.15.0",
|
|
45
45
|
"@types/sm-crypto": "^0.3.4",
|
|
46
46
|
"@vitejs/plugin-legacy": "^7.2.1",
|
|
47
|
-
"axios": "^1.
|
|
48
|
-
"cross-env": "^10.
|
|
49
|
-
"eslint": "^
|
|
50
|
-
"jsdom": "^
|
|
47
|
+
"axios": "^1.20.0",
|
|
48
|
+
"cross-env": "^10.1.0",
|
|
49
|
+
"eslint": "^10.10.0",
|
|
50
|
+
"jsdom": "^30.1.0",
|
|
51
51
|
"parse5": "^8.0.1",
|
|
52
|
-
"prettier": "^3.
|
|
52
|
+
"prettier": "^3.9.8",
|
|
53
53
|
"sdp-transform": "^2.15.0",
|
|
54
|
-
"terser": "^5.
|
|
54
|
+
"terser": "^5.51.2",
|
|
55
55
|
"typescript": "^5.9.2",
|
|
56
|
-
"unplugin-dts": "^1.
|
|
56
|
+
"unplugin-dts": "^1.1.0",
|
|
57
57
|
"vite": "^7.1.5",
|
|
58
58
|
"vitest": "^3.2.4",
|
|
59
|
-
"vue": "^3.5.
|
|
60
|
-
"vue-tsc": "^3.
|
|
59
|
+
"vue": "^3.5.43",
|
|
60
|
+
"vue-tsc": "^3.3.11"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"file-type": "^22.
|
|
63
|
+
"file-type": "^22.1.1",
|
|
64
64
|
"gm-crypt": "^0.0.2",
|
|
65
65
|
"jssip": "^3.10.1",
|
|
66
66
|
"nanoid": "^5.1.11",
|