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.
- package/dist/commonjs-virtual-dir/index.js +3 -5
- package/dist/commonjs-virtual-dir/index2.js +5 -2
- package/dist/commonjs-virtual-dir/index3.js +5 -2
- package/dist/commonjs-virtual-dir/index4.js +2 -4
- package/dist/commonjs-virtual-dir/index5.js +4 -0
- package/dist/commonjs-virtual-dir/index6.js +4 -0
- package/dist/commonjs-virtual-dir/index7.js +4 -0
- package/dist/commonjs-virtual-dir/index8.js +4 -0
- package/dist/main.d.ts +92 -10
- package/dist/main.js +44 -40
- package/dist/src/outside-call/utils.js +1 -1
- package/dist/src/shield/crypto/const.js +4 -0
- package/dist/src/shield/crypto/index.js +53 -0
- package/dist/src/shield/crypto/sm2.js +7 -0
- package/dist/src/shield/crypto/sm4.js +15 -0
- package/dist/src/shield/crypto/util.js +29 -0
- package/dist/src/shield/gcm-crypto/axios-adapter.js +25 -23
- package/dist/src/shield/gcm-crypto/index.js +16 -15
- package/dist/vendor/base64-js/index.js +52 -0
- 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/vendor/gm-crypt/index.js +10 -0
- package/dist/vendor/gm-crypt/src/crypt.js +60 -0
- package/dist/vendor/gm-crypt/src/sm4.js +513 -0
- package/dist/vendor/ieee754/index.js +1 -1
- package/dist/vendor/jsbn/index.js +714 -0
- package/dist/vendor/sdp-transform/lib/index.js +1 -1
- package/dist/vendor/sm-crypto/src/index.js +14 -0
- package/dist/vendor/sm-crypto/src/sm2/asn1.js +86 -0
- package/dist/vendor/sm-crypto/src/sm2/ec.js +205 -0
- package/dist/vendor/sm-crypto/src/sm2/index.js +114 -0
- package/dist/vendor/sm-crypto/src/sm2/sm3.js +71 -0
- package/dist/vendor/sm-crypto/src/sm2/utils.js +95 -0
- package/dist/vendor/sm-crypto/src/sm3/index.js +50 -0
- package/dist/vendor/sm-crypto/src/sm4/index.js +408 -0
- package/dist/vendor/token-types/lib/index.js +1 -1
- package/dist/vite-plugins/index.d.ts +42 -0
- package/package.json +13 -13
|
@@ -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,
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
};
|