module-develop-kit 1.1.0 → 1.2.1
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 +5 -2
- package/dist/commonjs-virtual-dir/browser2.js +4 -0
- package/dist/commonjs-virtual-dir/index2.js +5 -3
- package/dist/commonjs-virtual-dir/index3.js +3 -5
- package/dist/commonjs-virtual-dir/index4.js +2 -4
- package/dist/commonjs-virtual-dir/index5.js +2 -2
- package/dist/commonjs-virtual-dir/index6.js +2 -2
- package/dist/commonjs-virtual-dir/index7.js +4 -0
- package/dist/commonjs-virtual-dir/index8.js +4 -0
- package/dist/main.d.ts +140 -29
- package/dist/main.js +34 -22
- package/dist/src/outside-call/utils.js +1 -1
- package/dist/src/shield/crypto/sm4.js +1 -1
- package/dist/src/shield/file-detection.js +143 -0
- package/dist/vendor/@borewit/text-codec/lib/index.js +181 -0
- package/dist/vendor/@tokenizer/inflate/lib/GzipHandler.js +21 -0
- package/dist/vendor/@tokenizer/inflate/lib/ZipHandler.js +156 -0
- package/dist/vendor/@tokenizer/inflate/lib/ZipToken.js +71 -0
- package/dist/vendor/base64-js/index.js +1 -1
- package/dist/vendor/debug/src/browser.js +1 -1
- package/dist/vendor/file-type/source/detectors/asf.js +74 -0
- package/dist/vendor/file-type/source/detectors/ebml.js +61 -0
- package/dist/vendor/file-type/source/detectors/png.js +64 -0
- package/dist/vendor/file-type/source/detectors/zip.js +344 -0
- package/dist/vendor/file-type/source/index.js +1135 -0
- package/dist/vendor/file-type/source/parser.js +49 -0
- package/dist/vendor/file-type/source/supported.js +372 -0
- package/dist/vendor/file-type/source/tokens.js +40 -0
- package/dist/vendor/ieee754/index.js +30 -0
- package/dist/vendor/jsbn/index.js +1 -1
- package/dist/vendor/sdp-transform/lib/index.js +1 -1
- package/dist/vendor/strtok3/lib/AbstractTokenizer.js +92 -0
- package/dist/vendor/strtok3/lib/BlobTokenizer.js +48 -0
- package/dist/vendor/strtok3/lib/BufferTokenizer.js +47 -0
- package/dist/vendor/strtok3/lib/ReadStreamTokenizer.js +91 -0
- package/dist/vendor/strtok3/lib/core.js +22 -0
- package/dist/vendor/strtok3/lib/stream/AbstractStreamReader.js +51 -0
- package/dist/vendor/strtok3/lib/stream/Errors.js +16 -0
- package/dist/vendor/strtok3/lib/stream/WebStreamByobReader.js +18 -0
- package/dist/vendor/strtok3/lib/stream/WebStreamDefaultReader.js +45 -0
- package/dist/vendor/strtok3/lib/stream/WebStreamReader.js +15 -0
- package/dist/vendor/strtok3/lib/stream/WebStreamReaderFactory.js +15 -0
- package/dist/vendor/token-types/lib/index.js +81 -0
- package/dist/vendor/uint8array-extras/index.js +45 -0
- package/package.json +2 -1
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
const g = {
|
|
2
|
+
128: "€",
|
|
3
|
+
130: "‚",
|
|
4
|
+
131: "ƒ",
|
|
5
|
+
132: "„",
|
|
6
|
+
133: "…",
|
|
7
|
+
134: "†",
|
|
8
|
+
135: "‡",
|
|
9
|
+
136: "ˆ",
|
|
10
|
+
137: "‰",
|
|
11
|
+
138: "Š",
|
|
12
|
+
139: "‹",
|
|
13
|
+
140: "Œ",
|
|
14
|
+
142: "Ž",
|
|
15
|
+
145: "‘",
|
|
16
|
+
146: "’",
|
|
17
|
+
147: "“",
|
|
18
|
+
148: "”",
|
|
19
|
+
149: "•",
|
|
20
|
+
150: "–",
|
|
21
|
+
151: "—",
|
|
22
|
+
152: "˜",
|
|
23
|
+
153: "™",
|
|
24
|
+
154: "š",
|
|
25
|
+
155: "›",
|
|
26
|
+
156: "œ",
|
|
27
|
+
158: "ž",
|
|
28
|
+
159: "Ÿ"
|
|
29
|
+
};
|
|
30
|
+
for (const [e, o] of Object.entries(g))
|
|
31
|
+
;
|
|
32
|
+
let a;
|
|
33
|
+
function w() {
|
|
34
|
+
if (!(typeof globalThis.TextDecoder > "u"))
|
|
35
|
+
return a ?? (a = new globalThis.TextDecoder("utf-8"));
|
|
36
|
+
}
|
|
37
|
+
const d = 32 * 1024, r = 65533;
|
|
38
|
+
function L(e, o = "utf-8") {
|
|
39
|
+
switch (o.toLowerCase()) {
|
|
40
|
+
case "utf-8":
|
|
41
|
+
case "utf8": {
|
|
42
|
+
const n = w();
|
|
43
|
+
return n ? n.decode(e) : T(e);
|
|
44
|
+
}
|
|
45
|
+
case "utf-16le":
|
|
46
|
+
return E(e);
|
|
47
|
+
case "us-ascii":
|
|
48
|
+
case "ascii":
|
|
49
|
+
return m(e);
|
|
50
|
+
case "latin1":
|
|
51
|
+
case "iso-8859-1":
|
|
52
|
+
return v(e);
|
|
53
|
+
case "windows-1252":
|
|
54
|
+
return D(e);
|
|
55
|
+
default:
|
|
56
|
+
throw new RangeError(`Encoding '${o}' not supported`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function s(e, o) {
|
|
60
|
+
o.length !== 0 && (e.push(String.fromCharCode.apply(null, o)), o.length = 0);
|
|
61
|
+
}
|
|
62
|
+
function i(e, o, n) {
|
|
63
|
+
o.push(n), o.length >= d && s(e, o);
|
|
64
|
+
}
|
|
65
|
+
function j(e, o, n) {
|
|
66
|
+
if (n <= 65535) {
|
|
67
|
+
i(e, o, n);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
n -= 65536, i(e, o, 55296 + (n >> 10)), i(e, o, 56320 + (n & 1023));
|
|
71
|
+
}
|
|
72
|
+
function T(e) {
|
|
73
|
+
const o = [], n = [];
|
|
74
|
+
let t = 0;
|
|
75
|
+
for (e.length >= 3 && e[0] === 239 && e[1] === 187 && e[2] === 191 && (t = 3); t < e.length; ) {
|
|
76
|
+
const f = e[t];
|
|
77
|
+
if (f <= 127) {
|
|
78
|
+
i(o, n, f), t++;
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
if (f < 194 || f > 244) {
|
|
82
|
+
i(o, n, r), t++;
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if (f <= 223) {
|
|
86
|
+
if (t + 1 >= e.length) {
|
|
87
|
+
i(o, n, r), t++;
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
const u = e[t + 1];
|
|
91
|
+
if ((u & 192) !== 128) {
|
|
92
|
+
i(o, n, r), t++;
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
const l = (f & 31) << 6 | u & 63;
|
|
96
|
+
i(o, n, l), t += 2;
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
if (f <= 239) {
|
|
100
|
+
if (t + 2 >= e.length) {
|
|
101
|
+
i(o, n, r), t++;
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
const u = e[t + 1], l = e[t + 2];
|
|
105
|
+
if (!((u & 192) === 128 && (l & 192) === 128 && !(f === 224 && u < 160) && // overlong
|
|
106
|
+
!(f === 237 && u >= 160))) {
|
|
107
|
+
i(o, n, r), t++;
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
const C = (f & 15) << 12 | (u & 63) << 6 | l & 63;
|
|
111
|
+
i(o, n, C), t += 3;
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
if (t + 3 >= e.length) {
|
|
115
|
+
i(o, n, r), t++;
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
const c = e[t + 1], x = e[t + 2], h = e[t + 3];
|
|
119
|
+
if (!((c & 192) === 128 && (x & 192) === 128 && (h & 192) === 128 && !(f === 240 && c < 144) && // overlong
|
|
120
|
+
!(f === 244 && c > 143))) {
|
|
121
|
+
i(o, n, r), t++;
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
const p = (f & 7) << 18 | (c & 63) << 12 | (x & 63) << 6 | h & 63;
|
|
125
|
+
j(o, n, p), t += 4;
|
|
126
|
+
}
|
|
127
|
+
return s(o, n), o.join("");
|
|
128
|
+
}
|
|
129
|
+
function E(e) {
|
|
130
|
+
const o = [], n = [], t = e.length;
|
|
131
|
+
let f = 0;
|
|
132
|
+
for (; f + 1 < t; ) {
|
|
133
|
+
const c = e[f] | e[f + 1] << 8;
|
|
134
|
+
if (f += 2, c >= 55296 && c <= 56319) {
|
|
135
|
+
if (f + 1 < t) {
|
|
136
|
+
const x = e[f] | e[f + 1] << 8;
|
|
137
|
+
x >= 56320 && x <= 57343 ? (i(o, n, c), i(o, n, x), f += 2) : i(o, n, r);
|
|
138
|
+
} else
|
|
139
|
+
i(o, n, r);
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
if (c >= 56320 && c <= 57343) {
|
|
143
|
+
i(o, n, r);
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
i(o, n, c);
|
|
147
|
+
}
|
|
148
|
+
return f < t && i(o, n, r), s(o, n), o.join("");
|
|
149
|
+
}
|
|
150
|
+
function m(e) {
|
|
151
|
+
const o = [];
|
|
152
|
+
for (let n = 0; n < e.length; n += d) {
|
|
153
|
+
const t = Math.min(e.length, n + d), f = new Array(t - n);
|
|
154
|
+
for (let c = n, x = 0; c < t; c++, x++)
|
|
155
|
+
f[x] = e[c] & 127;
|
|
156
|
+
o.push(String.fromCharCode.apply(null, f));
|
|
157
|
+
}
|
|
158
|
+
return o.join("");
|
|
159
|
+
}
|
|
160
|
+
function v(e) {
|
|
161
|
+
const o = [];
|
|
162
|
+
for (let n = 0; n < e.length; n += d) {
|
|
163
|
+
const t = Math.min(e.length, n + d), f = new Array(t - n);
|
|
164
|
+
for (let c = n, x = 0; c < t; c++, x++)
|
|
165
|
+
f[x] = e[c];
|
|
166
|
+
o.push(String.fromCharCode.apply(null, f));
|
|
167
|
+
}
|
|
168
|
+
return o.join("");
|
|
169
|
+
}
|
|
170
|
+
function D(e) {
|
|
171
|
+
const o = [];
|
|
172
|
+
let n = "";
|
|
173
|
+
for (let t = 0; t < e.length; t++) {
|
|
174
|
+
const f = e[t], c = f >= 128 && f <= 159 ? g[f] : void 0;
|
|
175
|
+
n += c ?? String.fromCharCode(f), n.length >= d && (o.push(n), n = "");
|
|
176
|
+
}
|
|
177
|
+
return n && o.push(n), o.join("");
|
|
178
|
+
}
|
|
179
|
+
export {
|
|
180
|
+
L as textDecode
|
|
181
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
class a {
|
|
2
|
+
constructor(e) {
|
|
3
|
+
this.tokenizer = e;
|
|
4
|
+
}
|
|
5
|
+
inflate() {
|
|
6
|
+
const e = this.tokenizer;
|
|
7
|
+
return new ReadableStream({
|
|
8
|
+
async pull(r) {
|
|
9
|
+
const t = new Uint8Array(1024), n = await e.readBuffer(t, { mayBeLess: !0 });
|
|
10
|
+
if (n === 0) {
|
|
11
|
+
r.close();
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
r.enqueue(t.subarray(0, n));
|
|
15
|
+
}
|
|
16
|
+
}).pipeThrough(new DecompressionStream("gzip"));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
a as GzipHandler
|
|
21
|
+
};
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { UINT32_LE as h, StringType as k } from "../../../token-types/lib/index.js";
|
|
2
|
+
import D from "../../../../commonjs-virtual-dir/browser.js";
|
|
3
|
+
import { Signature as c, EndOfCentralDirectoryRecordToken as L, FileHeader as E, DataDescriptor as y, LocalFileHeaderToken as S } from "./ZipToken.js";
|
|
4
|
+
function m(s) {
|
|
5
|
+
const t = new Uint8Array(h.len);
|
|
6
|
+
return h.put(t, 0, s), t;
|
|
7
|
+
}
|
|
8
|
+
const o = D("tokenizer:inflate"), p = 256 * 1024, C = m(c.DataDescriptor), l = m(c.EndOfCentralDirectory);
|
|
9
|
+
class z {
|
|
10
|
+
constructor(t) {
|
|
11
|
+
this.tokenizer = t, this.syncBuffer = new Uint8Array(p);
|
|
12
|
+
}
|
|
13
|
+
async isZip() {
|
|
14
|
+
return await this.peekSignature() === c.LocalFileHeader;
|
|
15
|
+
}
|
|
16
|
+
peekSignature() {
|
|
17
|
+
return this.tokenizer.peekToken(h);
|
|
18
|
+
}
|
|
19
|
+
async findEndOfCentralDirectoryLocator() {
|
|
20
|
+
const t = this.tokenizer, n = Math.min(16 * 1024, t.fileInfo.size), r = this.syncBuffer.subarray(0, n);
|
|
21
|
+
await this.tokenizer.readBuffer(r, { position: t.fileInfo.size - n });
|
|
22
|
+
for (let e = r.length - 4; e >= 0; e--)
|
|
23
|
+
if (r[e] === l[0] && r[e + 1] === l[1] && r[e + 2] === l[2] && r[e + 3] === l[3])
|
|
24
|
+
return t.fileInfo.size - n + e;
|
|
25
|
+
return -1;
|
|
26
|
+
}
|
|
27
|
+
async readCentralDirectory() {
|
|
28
|
+
if (!this.tokenizer.supportsRandomAccess()) {
|
|
29
|
+
o("Cannot reading central-directory without random-read support");
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
o("Reading central-directory...");
|
|
33
|
+
const t = this.tokenizer.position, n = await this.findEndOfCentralDirectoryLocator();
|
|
34
|
+
if (n > 0) {
|
|
35
|
+
o("Central-directory 32-bit signature found");
|
|
36
|
+
const r = await this.tokenizer.readToken(L, n), e = [];
|
|
37
|
+
this.tokenizer.setPosition(r.offsetOfStartOfCd);
|
|
38
|
+
for (let i = 0; i < r.nrOfEntriesOfSize; ++i) {
|
|
39
|
+
const a = await this.tokenizer.readToken(E);
|
|
40
|
+
if (a.signature !== c.CentralFileHeader)
|
|
41
|
+
throw new Error("Expected Central-File-Header signature");
|
|
42
|
+
a.filename = await this.tokenizer.readToken(new k(a.filenameLength, "utf-8")), await this.tokenizer.ignore(a.extraFieldLength), await this.tokenizer.ignore(a.fileCommentLength), e.push(a), o(`Add central-directory file-entry: n=${i + 1}/${e.length}: filename=${e[i].filename}`);
|
|
43
|
+
}
|
|
44
|
+
return this.tokenizer.setPosition(t), e;
|
|
45
|
+
}
|
|
46
|
+
this.tokenizer.setPosition(t);
|
|
47
|
+
}
|
|
48
|
+
async unzip(t) {
|
|
49
|
+
const n = await this.readCentralDirectory();
|
|
50
|
+
if (n)
|
|
51
|
+
return this.iterateOverCentralDirectory(n, t);
|
|
52
|
+
let r = !1;
|
|
53
|
+
do {
|
|
54
|
+
const e = await this.readLocalFileHeader();
|
|
55
|
+
if (!e)
|
|
56
|
+
break;
|
|
57
|
+
const i = t(e);
|
|
58
|
+
r = !!i.stop;
|
|
59
|
+
let a;
|
|
60
|
+
if (await this.tokenizer.ignore(e.extraFieldLength), e.dataDescriptor && e.compressedSize === 0) {
|
|
61
|
+
const u = [];
|
|
62
|
+
let d = p;
|
|
63
|
+
o("Compressed-file-size unknown, scanning for next data-descriptor-signature....");
|
|
64
|
+
let f = -1;
|
|
65
|
+
for (; f < 0 && d === p; ) {
|
|
66
|
+
d = await this.tokenizer.peekBuffer(this.syncBuffer, { mayBeLess: !0 }), f = F(this.syncBuffer.subarray(0, d), C);
|
|
67
|
+
const w = f >= 0 ? f : d;
|
|
68
|
+
if (i.handler) {
|
|
69
|
+
const g = new Uint8Array(w);
|
|
70
|
+
await this.tokenizer.readBuffer(g), u.push(g);
|
|
71
|
+
} else
|
|
72
|
+
await this.tokenizer.ignore(w);
|
|
73
|
+
}
|
|
74
|
+
o(`Found data-descriptor-signature at pos=${this.tokenizer.position}`), i.handler && await this.inflate(e, T(u), i.handler);
|
|
75
|
+
} else
|
|
76
|
+
i.handler ? (o(`Reading compressed-file-data: ${e.compressedSize} bytes`), a = new Uint8Array(e.compressedSize), await this.tokenizer.readBuffer(a), await this.inflate(e, a, i.handler)) : (o(`Ignoring compressed-file-data: ${e.compressedSize} bytes`), await this.tokenizer.ignore(e.compressedSize));
|
|
77
|
+
if (o(`Reading data-descriptor at pos=${this.tokenizer.position}`), e.dataDescriptor && (await this.tokenizer.readToken(y)).signature !== 134695760)
|
|
78
|
+
throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position - y.len}`);
|
|
79
|
+
} while (!r);
|
|
80
|
+
}
|
|
81
|
+
async iterateOverCentralDirectory(t, n) {
|
|
82
|
+
for (const r of t) {
|
|
83
|
+
const e = n(r);
|
|
84
|
+
if (e.handler) {
|
|
85
|
+
this.tokenizer.setPosition(r.relativeOffsetOfLocalHeader);
|
|
86
|
+
const i = await this.readLocalFileHeader();
|
|
87
|
+
if (i) {
|
|
88
|
+
await this.tokenizer.ignore(i.extraFieldLength);
|
|
89
|
+
const a = new Uint8Array(r.compressedSize);
|
|
90
|
+
await this.tokenizer.readBuffer(a), await this.inflate(i, a, e.handler);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (e.stop)
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
async inflate(t, n, r) {
|
|
98
|
+
if (t.compressedMethod === 0)
|
|
99
|
+
return r(n);
|
|
100
|
+
if (t.compressedMethod !== 8)
|
|
101
|
+
throw new Error(`Unsupported ZIP compression method: ${t.compressedMethod}`);
|
|
102
|
+
o(`Decompress filename=${t.filename}, compressed-size=${n.length}`);
|
|
103
|
+
const e = await z.decompressDeflateRaw(n);
|
|
104
|
+
return r(e);
|
|
105
|
+
}
|
|
106
|
+
static async decompressDeflateRaw(t) {
|
|
107
|
+
const n = new ReadableStream({
|
|
108
|
+
start(i) {
|
|
109
|
+
i.enqueue(t), i.close();
|
|
110
|
+
}
|
|
111
|
+
}), r = new DecompressionStream("deflate-raw"), e = n.pipeThrough(r);
|
|
112
|
+
try {
|
|
113
|
+
const a = await new Response(e).arrayBuffer();
|
|
114
|
+
return new Uint8Array(a);
|
|
115
|
+
} catch (i) {
|
|
116
|
+
const a = i instanceof Error ? `Failed to deflate ZIP entry: ${i.message}` : "Unknown decompression error in ZIP entry";
|
|
117
|
+
throw new TypeError(a);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
async readLocalFileHeader() {
|
|
121
|
+
const t = await this.tokenizer.peekToken(h);
|
|
122
|
+
if (t === c.LocalFileHeader) {
|
|
123
|
+
const n = await this.tokenizer.readToken(S);
|
|
124
|
+
return n.filename = await this.tokenizer.readToken(new k(n.filenameLength, "utf-8")), n;
|
|
125
|
+
}
|
|
126
|
+
if (t === c.CentralFileHeader)
|
|
127
|
+
return !1;
|
|
128
|
+
throw t === 3759263696 ? new Error("Encrypted ZIP") : new Error("Unexpected signature");
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function F(s, t) {
|
|
132
|
+
const n = s.length, r = t.length;
|
|
133
|
+
if (r > n)
|
|
134
|
+
return -1;
|
|
135
|
+
for (let e = 0; e <= n - r; e++) {
|
|
136
|
+
let i = !0;
|
|
137
|
+
for (let a = 0; a < r; a++)
|
|
138
|
+
if (s[e + a] !== t[a]) {
|
|
139
|
+
i = !1;
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
if (i)
|
|
143
|
+
return e;
|
|
144
|
+
}
|
|
145
|
+
return -1;
|
|
146
|
+
}
|
|
147
|
+
function T(s) {
|
|
148
|
+
const t = s.reduce((e, i) => e + i.length, 0), n = new Uint8Array(t);
|
|
149
|
+
let r = 0;
|
|
150
|
+
for (const e of s)
|
|
151
|
+
n.set(e, r), r += e.length;
|
|
152
|
+
return n;
|
|
153
|
+
}
|
|
154
|
+
export {
|
|
155
|
+
z as ZipHandler
|
|
156
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { UINT16_LE as t, UINT32_LE as n } from "../../../token-types/lib/index.js";
|
|
2
|
+
const s = {
|
|
3
|
+
LocalFileHeader: 67324752,
|
|
4
|
+
DataDescriptor: 134695760,
|
|
5
|
+
CentralFileHeader: 33639248,
|
|
6
|
+
EndOfCentralDirectory: 101010256
|
|
7
|
+
}, o = {
|
|
8
|
+
get(e) {
|
|
9
|
+
return {
|
|
10
|
+
signature: n.get(e, 0),
|
|
11
|
+
compressedSize: n.get(e, 8),
|
|
12
|
+
uncompressedSize: n.get(e, 12)
|
|
13
|
+
};
|
|
14
|
+
},
|
|
15
|
+
len: 16
|
|
16
|
+
}, l = {
|
|
17
|
+
get(e) {
|
|
18
|
+
const i = t.get(e, 6);
|
|
19
|
+
return {
|
|
20
|
+
signature: n.get(e, 0),
|
|
21
|
+
minVersion: t.get(e, 4),
|
|
22
|
+
dataDescriptor: !!(i & 8),
|
|
23
|
+
compressedMethod: t.get(e, 8),
|
|
24
|
+
compressedSize: n.get(e, 18),
|
|
25
|
+
uncompressedSize: n.get(e, 22),
|
|
26
|
+
filenameLength: t.get(e, 26),
|
|
27
|
+
extraFieldLength: t.get(e, 28),
|
|
28
|
+
filename: null
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
len: 30
|
|
32
|
+
}, c = {
|
|
33
|
+
get(e) {
|
|
34
|
+
return {
|
|
35
|
+
signature: n.get(e, 0),
|
|
36
|
+
nrOfThisDisk: t.get(e, 4),
|
|
37
|
+
nrOfThisDiskWithTheStart: t.get(e, 6),
|
|
38
|
+
nrOfEntriesOnThisDisk: t.get(e, 8),
|
|
39
|
+
nrOfEntriesOfSize: t.get(e, 10),
|
|
40
|
+
sizeOfCd: n.get(e, 12),
|
|
41
|
+
offsetOfStartOfCd: n.get(e, 16),
|
|
42
|
+
zipFileCommentLength: t.get(e, 20)
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
len: 22
|
|
46
|
+
}, d = {
|
|
47
|
+
get(e) {
|
|
48
|
+
const i = t.get(e, 8);
|
|
49
|
+
return {
|
|
50
|
+
signature: n.get(e, 0),
|
|
51
|
+
minVersion: t.get(e, 6),
|
|
52
|
+
dataDescriptor: !!(i & 8),
|
|
53
|
+
compressedMethod: t.get(e, 10),
|
|
54
|
+
compressedSize: n.get(e, 20),
|
|
55
|
+
uncompressedSize: n.get(e, 24),
|
|
56
|
+
filenameLength: t.get(e, 28),
|
|
57
|
+
extraFieldLength: t.get(e, 30),
|
|
58
|
+
fileCommentLength: t.get(e, 32),
|
|
59
|
+
relativeOffsetOfLocalHeader: n.get(e, 42),
|
|
60
|
+
filename: null
|
|
61
|
+
};
|
|
62
|
+
},
|
|
63
|
+
len: 46
|
|
64
|
+
};
|
|
65
|
+
export {
|
|
66
|
+
o as DataDescriptor,
|
|
67
|
+
c as EndOfCentralDirectoryRecordToken,
|
|
68
|
+
d as FileHeader,
|
|
69
|
+
l as LocalFileHeaderToken,
|
|
70
|
+
s as Signature
|
|
71
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { UINT64_LE as p } from "../../../token-types/lib/index.js";
|
|
2
|
+
import { EndOfStreamError as h } from "../../../strtok3/lib/stream/Errors.js";
|
|
3
|
+
import { safeReadBuffer as o, safeIgnore as d, hasUnknownFileSize as u, hasExceededUnknownSizeScanBudget as F, maximumUntrustedSkipSizeInBytes as S, checkBytes as n, ParserHardLimitError as w } from "../parser.js";
|
|
4
|
+
const y = 512, c = 1024 * 1024;
|
|
5
|
+
async function b(e) {
|
|
6
|
+
let a = !1;
|
|
7
|
+
try {
|
|
8
|
+
async function i() {
|
|
9
|
+
const x = new Uint8Array(16);
|
|
10
|
+
return await o(e, x, void 0, {
|
|
11
|
+
maximumLength: x.length,
|
|
12
|
+
reason: "ASF header GUID"
|
|
13
|
+
}), {
|
|
14
|
+
id: x,
|
|
15
|
+
size: Number(await e.readToken(p))
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
await d(e, 30, {
|
|
19
|
+
maximumLength: 30,
|
|
20
|
+
reason: "ASF header prelude"
|
|
21
|
+
});
|
|
22
|
+
const s = u(e), l = e.position;
|
|
23
|
+
let f = 0;
|
|
24
|
+
for (; e.position + 24 < e.fileInfo.size && (f++, !(f > y || F(e, l, S))); ) {
|
|
25
|
+
const x = e.position, m = await i();
|
|
26
|
+
let t = m.size - 24;
|
|
27
|
+
if (!Number.isFinite(t) || t < 0) {
|
|
28
|
+
a = !0;
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
if (n(m.id, [145, 7, 220, 183, 183, 169, 207, 17, 142, 230, 0, 192, 12, 32, 83, 101])) {
|
|
32
|
+
const r = new Uint8Array(16);
|
|
33
|
+
if (t -= await o(e, r, void 0, {
|
|
34
|
+
maximumLength: r.length,
|
|
35
|
+
reason: "ASF stream type GUID"
|
|
36
|
+
}), n(r, [64, 158, 105, 248, 77, 91, 207, 17, 168, 253, 0, 128, 95, 92, 68, 43]))
|
|
37
|
+
return {
|
|
38
|
+
ext: "asf",
|
|
39
|
+
mime: "audio/x-ms-asf"
|
|
40
|
+
};
|
|
41
|
+
if (n(r, [192, 239, 25, 188, 77, 91, 207, 17, 168, 253, 0, 128, 95, 92, 68, 43]))
|
|
42
|
+
return {
|
|
43
|
+
ext: "asf",
|
|
44
|
+
mime: "video/x-ms-asf"
|
|
45
|
+
};
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
if (s && t > c) {
|
|
49
|
+
a = !0;
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
if (await d(e, t, {
|
|
53
|
+
maximumLength: s ? c : e.fileInfo.size,
|
|
54
|
+
reason: "ASF header payload"
|
|
55
|
+
}), e.position <= x) {
|
|
56
|
+
a = !0;
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
} catch (i) {
|
|
61
|
+
if (i instanceof h || i instanceof w)
|
|
62
|
+
u(e) && (a = !0);
|
|
63
|
+
else
|
|
64
|
+
throw i;
|
|
65
|
+
}
|
|
66
|
+
if (!a)
|
|
67
|
+
return {
|
|
68
|
+
ext: "asf",
|
|
69
|
+
mime: "application/vnd.ms-asf"
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
export {
|
|
73
|
+
b as detectAsf
|
|
74
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { StringType as p, UINT8 as g } from "../../../token-types/lib/index.js";
|
|
2
|
+
import { getUintBE as l } from "../../../uint8array-extras/index.js";
|
|
3
|
+
import { hasExceededUnknownSizeScanBudget as h, getSafeBound as y, hasUnknownFileSize as r, safeIgnore as b, safeReadBuffer as E, maximumUntrustedSkipSizeInBytes as x } from "../parser.js";
|
|
4
|
+
const c = 64, u = 1024 * 1024, S = 256;
|
|
5
|
+
async function V(t) {
|
|
6
|
+
async function o() {
|
|
7
|
+
const i = await t.peekNumber(g);
|
|
8
|
+
let n = 128, a = 0;
|
|
9
|
+
for (; (i & n) === 0 && n !== 0; )
|
|
10
|
+
++a, n >>= 1;
|
|
11
|
+
const e = new Uint8Array(a + 1);
|
|
12
|
+
return await E(t, e, void 0, {
|
|
13
|
+
maximumLength: e.length,
|
|
14
|
+
reason: "EBML field"
|
|
15
|
+
}), e;
|
|
16
|
+
}
|
|
17
|
+
async function s() {
|
|
18
|
+
const i = await o(), n = await o();
|
|
19
|
+
n[0] ^= 128 >> n.length - 1;
|
|
20
|
+
const a = Math.min(6, n.length), e = new DataView(i.buffer), m = new DataView(n.buffer, n.length - a, a);
|
|
21
|
+
return {
|
|
22
|
+
id: l(e),
|
|
23
|
+
len: l(m)
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
async function d(i) {
|
|
27
|
+
let n = 0;
|
|
28
|
+
for (; i > 0; ) {
|
|
29
|
+
if (n++, n > S || h(t, f, x))
|
|
30
|
+
return;
|
|
31
|
+
const a = t.position, e = await s();
|
|
32
|
+
if (e.id === 17026) {
|
|
33
|
+
if (e.len > c)
|
|
34
|
+
return;
|
|
35
|
+
const m = y(e.len, c, "EBML DocType");
|
|
36
|
+
return (await t.readToken(new p(m))).replaceAll(new RegExp("\\0.*$", "gv"), "");
|
|
37
|
+
}
|
|
38
|
+
if (r(t) && (!Number.isFinite(e.len) || e.len < 0 || e.len > u) || (await b(t, e.len, {
|
|
39
|
+
maximumLength: r(t) ? u : t.fileInfo.size,
|
|
40
|
+
reason: "EBML payload"
|
|
41
|
+
}), --i, t.position <= a))
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const w = await s(), f = t.position;
|
|
46
|
+
switch (await d(w.len)) {
|
|
47
|
+
case "webm":
|
|
48
|
+
return {
|
|
49
|
+
ext: "webm",
|
|
50
|
+
mime: "video/webm"
|
|
51
|
+
};
|
|
52
|
+
case "matroska":
|
|
53
|
+
return {
|
|
54
|
+
ext: "mkv",
|
|
55
|
+
mime: "video/matroska"
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
export {
|
|
60
|
+
V as detectEbml
|
|
61
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { StringType as f, INT32_BE as p } from "../../../token-types/lib/index.js";
|
|
2
|
+
import { EndOfStreamError as h } from "../../../strtok3/lib/stream/Errors.js";
|
|
3
|
+
import { hasUnknownFileSize as l, hasExceededUnknownSizeScanBudget as d, safeIgnore as y, ParserHardLimitError as w } from "../parser.js";
|
|
4
|
+
const S = 512, I = 16 * 1024 * 1024, s = 1024 * 1024;
|
|
5
|
+
function P(n) {
|
|
6
|
+
return (n.codePointAt(0) & 32) !== 0;
|
|
7
|
+
}
|
|
8
|
+
async function B(n) {
|
|
9
|
+
const t = {
|
|
10
|
+
ext: "png",
|
|
11
|
+
mime: "image/png"
|
|
12
|
+
}, u = {
|
|
13
|
+
ext: "apng",
|
|
14
|
+
mime: "image/apng"
|
|
15
|
+
};
|
|
16
|
+
await n.ignore(8);
|
|
17
|
+
async function c() {
|
|
18
|
+
return {
|
|
19
|
+
length: await n.readToken(p),
|
|
20
|
+
type: await n.readToken(new f(4, "latin1"))
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
const a = l(n), g = n.position;
|
|
24
|
+
let o = 0, i = !1;
|
|
25
|
+
do {
|
|
26
|
+
if (o++, o > S || d(n, g, I))
|
|
27
|
+
break;
|
|
28
|
+
const m = n.position, e = await c();
|
|
29
|
+
if (e.length < 0)
|
|
30
|
+
return;
|
|
31
|
+
if (e.type === "IHDR") {
|
|
32
|
+
if (e.length !== 13)
|
|
33
|
+
return;
|
|
34
|
+
i = !0;
|
|
35
|
+
}
|
|
36
|
+
switch (e.type) {
|
|
37
|
+
case "IDAT":
|
|
38
|
+
return t;
|
|
39
|
+
case "acTL":
|
|
40
|
+
return u;
|
|
41
|
+
default:
|
|
42
|
+
if (!i && e.type !== "CgBI")
|
|
43
|
+
return;
|
|
44
|
+
if (a && e.length > s)
|
|
45
|
+
return i && P(e.type) ? t : void 0;
|
|
46
|
+
try {
|
|
47
|
+
await y(n, e.length + 4, {
|
|
48
|
+
maximumLength: a ? s + 4 : n.fileInfo.size,
|
|
49
|
+
reason: "PNG chunk payload"
|
|
50
|
+
});
|
|
51
|
+
} catch (r) {
|
|
52
|
+
if (!a && (r instanceof w || r instanceof h))
|
|
53
|
+
return t;
|
|
54
|
+
throw r;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (n.position <= m)
|
|
58
|
+
break;
|
|
59
|
+
} while (n.position + 8 < n.fileInfo.size);
|
|
60
|
+
return t;
|
|
61
|
+
}
|
|
62
|
+
export {
|
|
63
|
+
B as detectPng
|
|
64
|
+
};
|