@zip.js/zip.js 2.8.53 → 2.8.55
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/README.md +1 -1
- package/deno.json +2 -1
- package/dist/zip-core-external.js +737 -491
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +745 -490
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +776 -525
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +738 -510
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +776 -525
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +790 -525
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +791 -526
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +746 -491
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +746 -491
- package/dist/zip-native.min.js +1 -1
- package/dist/zip-web-worker-native.js +1 -1
- package/dist/zip-web-worker.js +1 -1
- package/dist/zip.js +747 -492
- package/dist/zip.min.js +1 -1
- package/eslint.config.mjs +1 -0
- package/index-native.cjs +790 -525
- package/index-native.min.js +1 -1
- package/index.cjs +791 -526
- package/index.d.cts +422 -49
- package/index.d.ts +422 -49
- package/index.min.js +1 -1
- package/lib/core/configuration.js +62 -21
- package/lib/core/constants.js +13 -1
- package/lib/core/io.js +33 -27
- package/lib/core/options.js +44 -2
- package/lib/core/streams/aes-crypto-stream.js +12 -12
- package/lib/core/util/decode-text.js +11 -2
- package/lib/core/web-worker-base.js +3 -2
- package/lib/core/web-worker-inline-native.js +1 -1
- package/lib/core/web-worker-inline-wasm.js +1 -1
- package/lib/core/zip-fs.js +39 -32
- package/lib/core/zip-reader.js +100 -38
- package/lib/core/zip-writer.js +301 -177
- package/lib/core/zlib-streams-inline.js +1 -1
- package/lib/zip-core-base.js +6 -1
- package/lib/zip-core-reader.js +1 -0
- package/lib/zip-core-writer.js +5 -0
- package/package.json +8 -2
|
@@ -36,6 +36,7 @@ const COMPRESSION_METHOD_AES = 0x63;
|
|
|
36
36
|
|
|
37
37
|
const LOCAL_FILE_HEADER_SIGNATURE = 0x04034b50;
|
|
38
38
|
const SPLIT_ZIP_FILE_SIGNATURE = 0x08074b50;
|
|
39
|
+
const TEMPORARY_SPLIT_ZIP_FILE_SIGNATURE = 0x30304b50;
|
|
39
40
|
const DATA_DESCRIPTOR_RECORD_SIGNATURE = SPLIT_ZIP_FILE_SIGNATURE;
|
|
40
41
|
const ARCHIVE_EXTRA_DATA_SIGNATURE = 0x08064b50;
|
|
41
42
|
const DIGITAL_SIGNATURE_RECORD_SIGNATURE = 0x05054b50;
|
|
@@ -52,6 +53,7 @@ const ZIP64_END_OF_CENTRAL_DIR_TOTAL_LENGTH = END_OF_CENTRAL_DIR_LENGTH + ZIP64_
|
|
|
52
53
|
const DATA_DESCRIPTOR_RECORD_LENGTH = 12;
|
|
53
54
|
const DATA_DESCRIPTOR_RECORD_ZIP_64_LENGTH = 20;
|
|
54
55
|
const DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH = 4;
|
|
56
|
+
const SPLIT_ZIP_FILE_SIGNATURE_LENGTH = 4;
|
|
55
57
|
|
|
56
58
|
const EXTRAFIELD_TYPE_ZIP64 = 0x0001;
|
|
57
59
|
const EXTRAFIELD_TYPE_AES = 0x9901;
|
|
@@ -74,6 +76,7 @@ const BITFLAG_LEVEL_SUPER_FAST_MASK = 0b110;
|
|
|
74
76
|
const BITFLAG_DATA_DESCRIPTOR = 0b1000;
|
|
75
77
|
const BITFLAG_STRONG_ENCRYPTION = 0b1000000;
|
|
76
78
|
const BITFLAG_LANG_ENCODING_FLAG = 0b100000000000;
|
|
79
|
+
const BITFLAG_MASKED_LOCAL_HEADERS = 0b10000000000000;
|
|
77
80
|
const FILE_ATTR_MSDOS_DIR_MASK = 0b10000;
|
|
78
81
|
const FILE_ATTR_MSDOS_READONLY_MASK = 0x01;
|
|
79
82
|
const FILE_ATTR_MSDOS_HIDDEN_MASK = 0x02;
|
|
@@ -103,6 +106,8 @@ const HEADER_OFFSET_VERSION = 0;
|
|
|
103
106
|
const HEADER_OFFSET_SIGNATURE = 10;
|
|
104
107
|
const HEADER_OFFSET_COMPRESSED_SIZE = 14;
|
|
105
108
|
const HEADER_OFFSET_UNCOMPRESSED_SIZE = 18;
|
|
109
|
+
const HEADER_OFFSET_FILENAME_LENGTH = 22;
|
|
110
|
+
const HEADER_OFFSET_EXTRAFIELD_LENGTH = 24;
|
|
106
111
|
const LOCAL_HEADER_COMMON_OFFSET = 4;
|
|
107
112
|
|
|
108
113
|
const MAX_DATE = new Date(2107, 11, 31, 23, 59, 58);
|
|
@@ -115,9 +120,116 @@ const FUNCTION_TYPE = "function";
|
|
|
115
120
|
const OBJECT_TYPE = "object";
|
|
116
121
|
const STRING_TYPE = "string";
|
|
117
122
|
const NUMBER_TYPE = "number";
|
|
123
|
+
const BOOLEAN_TYPE = "boolean";
|
|
118
124
|
|
|
119
125
|
const EMPTY_UINT8_ARRAY = new Uint8Array();
|
|
120
126
|
|
|
127
|
+
/*
|
|
128
|
+
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
129
|
+
|
|
130
|
+
Redistribution and use in source and binary forms, with or without
|
|
131
|
+
modification, are permitted provided that the following conditions are met:
|
|
132
|
+
|
|
133
|
+
1. Redistributions of source code must retain the above copyright notice,
|
|
134
|
+
this list of conditions and the following disclaimer.
|
|
135
|
+
|
|
136
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
137
|
+
notice, this list of conditions and the following disclaimer in
|
|
138
|
+
the documentation and/or other materials provided with the distribution.
|
|
139
|
+
|
|
140
|
+
3. The names of the authors may not be used to endorse or promote products
|
|
141
|
+
derived from this software without specific prior written permission.
|
|
142
|
+
|
|
143
|
+
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
144
|
+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
145
|
+
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
146
|
+
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
147
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
148
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
149
|
+
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
150
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
151
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
152
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
153
|
+
*/
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
const OPTION_FILENAME_ENCODING = "filenameEncoding";
|
|
157
|
+
const OPTION_COMMENT_ENCODING = "commentEncoding";
|
|
158
|
+
const OPTION_DECODE_TEXT = "decodeText";
|
|
159
|
+
const OPTION_EXTRACT_PREPENDED_DATA = "extractPrependedData";
|
|
160
|
+
const OPTION_EXTRACT_APPENDED_DATA = "extractAppendedData";
|
|
161
|
+
const OPTION_PASSWORD = "password";
|
|
162
|
+
const OPTION_RAW_PASSWORD = "rawPassword";
|
|
163
|
+
const OPTION_PASS_THROUGH = "passThrough";
|
|
164
|
+
const OPTION_SIGNAL = "signal";
|
|
165
|
+
const OPTION_CHECK_PASSWORD_ONLY = "checkPasswordOnly";
|
|
166
|
+
const OPTION_CHECK_OVERLAPPING_ENTRY_ONLY = "checkOverlappingEntryOnly";
|
|
167
|
+
const OPTION_CHECK_OVERLAPPING_ENTRY = "checkOverlappingEntry";
|
|
168
|
+
const OPTION_CHECK_AMBIGUITY = "checkAmbiguity";
|
|
169
|
+
const OPTION_CHECK_LOCAL_DIRECTORY = "checkLocalDirectory";
|
|
170
|
+
const OPTION_CHECK_SIGNATURE = "checkSignature";
|
|
171
|
+
const OPTION_CHECK_CRC32 = "checkCrc32";
|
|
172
|
+
const OPTION_CHECK_AUTHENTICATION_CODE = "checkAuthenticationCode";
|
|
173
|
+
const OPTION_USE_WEB_WORKERS = "useWebWorkers";
|
|
174
|
+
const OPTION_USE_COMPRESSION_STREAM = "useCompressionStream";
|
|
175
|
+
const OPTION_TRANSFER_STREAMS = "transferStreams";
|
|
176
|
+
const OPTION_PREVENT_CLOSE = "preventClose";
|
|
177
|
+
const OPTION_ENCRYPTION_STRENGTH = "encryptionStrength";
|
|
178
|
+
const OPTION_EXTENDED_TIMESTAMP = "extendedTimestamp";
|
|
179
|
+
const OPTION_NTFS_TIMESTAMP = "ntfsTimestamp";
|
|
180
|
+
const OPTION_KEEP_ORDER = "keepOrder";
|
|
181
|
+
const OPTION_LEVEL = "level";
|
|
182
|
+
const OPTION_BUFFERED_WRITE = "bufferedWrite";
|
|
183
|
+
const OPTION_CREATE_TEMP_STREAM = "createTempStream";
|
|
184
|
+
const OPTION_DATA_DESCRIPTOR_SIGNATURE = "dataDescriptorSignature";
|
|
185
|
+
const OPTION_USE_UNICODE_FILE_NAMES = "useUnicodeFileNames";
|
|
186
|
+
const OPTION_DATA_DESCRIPTOR = "dataDescriptor";
|
|
187
|
+
const OPTION_SUPPORT_ZIP64_SPLIT_FILE = "supportZip64SplitFile";
|
|
188
|
+
const OPTION_ENCODE_TEXT = "encodeText";
|
|
189
|
+
const OPTION_OFFSET = "offset";
|
|
190
|
+
const OPTION_USDZ = "usdz";
|
|
191
|
+
const OPTION_UNIX_EXTRA_FIELD_TYPE = "unixExtraFieldType";
|
|
192
|
+
const OPTION_LOCAL_EXTRA_FIELD = "localExtraField";
|
|
193
|
+
const OPTION_STRICTNESS = "strictness";
|
|
194
|
+
const OPTION_FILENAME_VALIDATION = "filenameValidation";
|
|
195
|
+
const OPTION_NORMALIZE_FILENAME = "normalizeFilename";
|
|
196
|
+
const OPTION_MAX_APPENDED_DATA_SIZE = "maxAppendedDataSize";
|
|
197
|
+
const OPTION_DECRYPT_CENTRAL_DIRECTORY = "decryptCentralDirectory";
|
|
198
|
+
const OPTION_SIGN_CENTRAL_DIRECTORY = "signCentralDirectory";
|
|
199
|
+
const TEXT_TYPE_FILENAME = "filename";
|
|
200
|
+
const TEXT_TYPE_COMMENT = "comment";
|
|
201
|
+
const STRICTNESS_STRICT = "strict";
|
|
202
|
+
const STRICTNESS_BALANCED = "balanced";
|
|
203
|
+
const STRICTNESS_TOLERANT = "tolerant";
|
|
204
|
+
|
|
205
|
+
const ERR_INVALID_FUNCTION_OPTION = "Invalid option (must be a function)";
|
|
206
|
+
const ERR_INVALID_SIGNAL = "Invalid signal (must be an AbortSignal instance)";
|
|
207
|
+
const ERR_INVALID_PASSWORD_TYPE = "Invalid password (password must be a string, rawPassword must be a Uint8Array)";
|
|
208
|
+
|
|
209
|
+
function checkFunctionOption(value) {
|
|
210
|
+
if (value && typeof value != FUNCTION_TYPE) {
|
|
211
|
+
throw new Error(ERR_INVALID_FUNCTION_OPTION);
|
|
212
|
+
}
|
|
213
|
+
return value;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function checkSignalOption(signal) {
|
|
217
|
+
if (signal && (typeof signal.addEventListener != FUNCTION_TYPE || typeof signal.aborted != BOOLEAN_TYPE)) {
|
|
218
|
+
throw new Error(ERR_INVALID_SIGNAL);
|
|
219
|
+
}
|
|
220
|
+
return signal || UNDEFINED_VALUE;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function checkPasswordOption(password, rawPassword) {
|
|
224
|
+
if ((password && typeof password != STRING_TYPE) || (rawPassword && !(rawPassword instanceof Uint8Array))) {
|
|
225
|
+
throw new Error(ERR_INVALID_PASSWORD_TYPE);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function toNumber(value) {
|
|
230
|
+
return typeof value == STRING_TYPE && value.trim() ? Number(value) : value;
|
|
231
|
+
}
|
|
232
|
+
|
|
121
233
|
/*
|
|
122
234
|
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
123
235
|
|
|
@@ -147,7 +259,10 @@ const EMPTY_UINT8_ARRAY = new Uint8Array();
|
|
|
147
259
|
*/
|
|
148
260
|
|
|
149
261
|
|
|
262
|
+
const DEFAULT_CHUNK_SIZE$1 = 64 * 1024;
|
|
150
263
|
const MINIMUM_CHUNK_SIZE = 64;
|
|
264
|
+
const MINIMUM_PROPERTY_VALUE = 1;
|
|
265
|
+
const ERR_INVALID_MAX_WORKERS = "Invalid maxWorkers (must be an integer greater than 0)";
|
|
151
266
|
let maxWorkers = 2;
|
|
152
267
|
try {
|
|
153
268
|
if (typeof navigator != UNDEFINED_TYPE && navigator.hardwareConcurrency) {
|
|
@@ -159,7 +274,7 @@ try {
|
|
|
159
274
|
const DEFAULT_CONFIGURATION = {
|
|
160
275
|
workerURI: "./core/web-worker-wasm.js",
|
|
161
276
|
wasmURI: "./core/streams/zlib-wasm/zlib-streams.wasm",
|
|
162
|
-
chunkSize:
|
|
277
|
+
chunkSize: DEFAULT_CHUNK_SIZE$1,
|
|
163
278
|
maxWorkers,
|
|
164
279
|
terminateWorkerTimeout: 5000,
|
|
165
280
|
workerStarvationTimeout: 5000,
|
|
@@ -171,24 +286,38 @@ const DEFAULT_CONFIGURATION = {
|
|
|
171
286
|
DecompressionStream: typeof DecompressionStream != UNDEFINED_TYPE && DecompressionStream
|
|
172
287
|
};
|
|
173
288
|
|
|
174
|
-
const
|
|
289
|
+
const PROPERTY_NAME_MAX_WORKERS = "maxWorkers";
|
|
290
|
+
|
|
291
|
+
const STRING_PROPERTY_NAMES = [
|
|
175
292
|
"baseURI",
|
|
176
293
|
"wasmURI",
|
|
177
|
-
"workerURI"
|
|
178
|
-
|
|
294
|
+
"workerURI"
|
|
295
|
+
];
|
|
296
|
+
const BOOLEAN_PROPERTY_NAMES = [
|
|
297
|
+
"useCompressionStream",
|
|
298
|
+
"useWebWorkers",
|
|
299
|
+
"transferStreams"
|
|
300
|
+
];
|
|
301
|
+
const NUMBER_PROPERTY_NAMES = [
|
|
179
302
|
"chunkSize",
|
|
180
|
-
|
|
303
|
+
PROPERTY_NAME_MAX_WORKERS,
|
|
181
304
|
"terminateWorkerTimeout",
|
|
182
305
|
"workerStarvationTimeout",
|
|
183
|
-
"workerStartupTimeout"
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
"
|
|
306
|
+
"workerStartupTimeout"
|
|
307
|
+
];
|
|
308
|
+
const FUNCTION_PROPERTY_NAMES = [
|
|
309
|
+
"createWorker",
|
|
187
310
|
"CompressionStream",
|
|
188
311
|
"DecompressionStream",
|
|
189
312
|
"CompressionStreamFallback",
|
|
190
313
|
"DecompressionStreamFallback"
|
|
191
314
|
];
|
|
315
|
+
const CONFIGURABLE_PROPERTY_NAMES = [
|
|
316
|
+
...STRING_PROPERTY_NAMES,
|
|
317
|
+
...BOOLEAN_PROPERTY_NAMES,
|
|
318
|
+
...NUMBER_PROPERTY_NAMES,
|
|
319
|
+
...FUNCTION_PROPERTY_NAMES
|
|
320
|
+
];
|
|
192
321
|
|
|
193
322
|
const config = { ...DEFAULT_CONFIGURATION };
|
|
194
323
|
|
|
@@ -197,20 +326,43 @@ function getConfiguration() {
|
|
|
197
326
|
}
|
|
198
327
|
|
|
199
328
|
function getChunkSize(config) {
|
|
200
|
-
return
|
|
329
|
+
return normalizeChunkSize(config.chunkSize);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
function normalizeChunkSize(chunkSize) {
|
|
333
|
+
chunkSize = toNumber(chunkSize);
|
|
334
|
+
return Number.isInteger(chunkSize) && chunkSize >= MINIMUM_PROPERTY_VALUE ? Math.max(chunkSize, MINIMUM_CHUNK_SIZE) : DEFAULT_CHUNK_SIZE$1;
|
|
201
335
|
}
|
|
202
336
|
|
|
203
337
|
function configure(configuration) {
|
|
204
|
-
|
|
338
|
+
Object.assign(config, checkConfiguration(normalizeConfiguration(configuration)));
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
function checkConfiguration(configuration) {
|
|
342
|
+
const checkedConfiguration = {};
|
|
205
343
|
for (const propertyName of CONFIGURABLE_PROPERTY_NAMES) {
|
|
206
344
|
const propertyValue = configuration[propertyName];
|
|
207
345
|
if (propertyValue !== UNDEFINED_VALUE) {
|
|
208
|
-
|
|
346
|
+
checkedConfiguration[propertyName] = checkPropertyValue(propertyName, propertyValue);
|
|
209
347
|
}
|
|
210
348
|
}
|
|
349
|
+
return checkedConfiguration;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
function checkPropertyValue(propertyName, propertyValue) {
|
|
353
|
+
if (NUMBER_PROPERTY_NAMES.includes(propertyName)) {
|
|
354
|
+
propertyValue = toNumber(propertyValue);
|
|
355
|
+
if (propertyName == PROPERTY_NAME_MAX_WORKERS && (!Number.isInteger(propertyValue) || propertyValue < MINIMUM_PROPERTY_VALUE)) {
|
|
356
|
+
throw new Error(ERR_INVALID_MAX_WORKERS);
|
|
357
|
+
}
|
|
358
|
+
} else if (FUNCTION_PROPERTY_NAMES.includes(propertyName)) {
|
|
359
|
+
checkFunctionOption(propertyValue);
|
|
360
|
+
}
|
|
361
|
+
return propertyValue;
|
|
211
362
|
}
|
|
212
363
|
|
|
213
364
|
function normalizeConfiguration(configuration) {
|
|
365
|
+
configuration = configuration || {};
|
|
214
366
|
const { CompressionStreamZlib, DecompressionStreamZlib } = configuration;
|
|
215
367
|
if (CompressionStreamZlib === UNDEFINED_VALUE && DecompressionStreamZlib === UNDEFINED_VALUE) {
|
|
216
368
|
return configuration;
|
|
@@ -226,14 +378,9 @@ function normalizeConfiguration(configuration) {
|
|
|
226
378
|
}
|
|
227
379
|
|
|
228
380
|
function setDefaultConfiguration(configuration) {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
if (propertyValue !== UNDEFINED_VALUE) {
|
|
233
|
-
DEFAULT_CONFIGURATION[propertyName] = propertyValue;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
configure(configuration);
|
|
381
|
+
const checkedConfiguration = checkConfiguration(normalizeConfiguration(configuration));
|
|
382
|
+
Object.assign(DEFAULT_CONFIGURATION, checkedConfiguration);
|
|
383
|
+
Object.assign(config, checkedConfiguration);
|
|
237
384
|
}
|
|
238
385
|
|
|
239
386
|
function resetConfiguration() {
|
|
@@ -1425,13 +1572,13 @@ class AESDecryptionStream extends TransformStream {
|
|
|
1425
1572
|
const {
|
|
1426
1573
|
ctr,
|
|
1427
1574
|
hmac,
|
|
1428
|
-
|
|
1575
|
+
pendingInput,
|
|
1429
1576
|
ready
|
|
1430
1577
|
} = this;
|
|
1431
1578
|
if (hmac && ctr) {
|
|
1432
1579
|
await ready;
|
|
1433
|
-
const chunkToDecrypt = subarray(
|
|
1434
|
-
const originalAuthenticationCode = subarray(
|
|
1580
|
+
const chunkToDecrypt = subarray(pendingInput, 0, pendingInput.length - AUTHENTICATION_CODE_LENGTH);
|
|
1581
|
+
const originalAuthenticationCode = subarray(pendingInput, pendingInput.length - AUTHENTICATION_CODE_LENGTH);
|
|
1435
1582
|
let decryptedChunkArray = EMPTY_UINT8_ARRAY;
|
|
1436
1583
|
if (chunkToDecrypt.length) {
|
|
1437
1584
|
const encryptedChunk = toBits(codecBytes, chunkToDecrypt);
|
|
@@ -1440,7 +1587,7 @@ class AESDecryptionStream extends TransformStream {
|
|
|
1440
1587
|
decryptedChunkArray = fromBits(codecBytes, decryptedChunk);
|
|
1441
1588
|
}
|
|
1442
1589
|
const authenticationCode = subarray(fromBits(codecBytes, hmac.digest()), 0, AUTHENTICATION_CODE_LENGTH);
|
|
1443
|
-
let invalidAuthenticationCode =
|
|
1590
|
+
let invalidAuthenticationCode = pendingInput.length < AUTHENTICATION_CODE_LENGTH ? 1 : 0;
|
|
1444
1591
|
for (let indexByte = 0; indexByte < AUTHENTICATION_CODE_LENGTH; indexByte++) {
|
|
1445
1592
|
invalidAuthenticationCode |= authenticationCode[indexByte] ^ originalAuthenticationCode[indexByte];
|
|
1446
1593
|
}
|
|
@@ -1484,14 +1631,14 @@ class AESEncryptionStream extends TransformStream {
|
|
|
1484
1631
|
const {
|
|
1485
1632
|
ctr,
|
|
1486
1633
|
hmac,
|
|
1487
|
-
|
|
1634
|
+
pendingInput,
|
|
1488
1635
|
ready
|
|
1489
1636
|
} = this;
|
|
1490
1637
|
if (hmac && ctr) {
|
|
1491
1638
|
await ready;
|
|
1492
1639
|
let encryptedChunkArray = EMPTY_UINT8_ARRAY;
|
|
1493
|
-
if (
|
|
1494
|
-
const encryptedChunk = ctr.update(toBits(codecBytes,
|
|
1640
|
+
if (pendingInput.length) {
|
|
1641
|
+
const encryptedChunk = ctr.update(toBits(codecBytes, pendingInput));
|
|
1495
1642
|
hmac.update(encryptedChunk);
|
|
1496
1643
|
encryptedChunkArray = fromBits(codecBytes, encryptedChunk);
|
|
1497
1644
|
}
|
|
@@ -1508,7 +1655,7 @@ function initAesCrypto(aesCrypto, password, rawPassword, encryptionStrength) {
|
|
|
1508
1655
|
ready: new Promise(resolve => aesCrypto.resolveReady = resolve),
|
|
1509
1656
|
password: encodePassword(password, rawPassword),
|
|
1510
1657
|
strength: encryptionStrength - 1,
|
|
1511
|
-
|
|
1658
|
+
pendingInput: EMPTY_UINT8_ARRAY
|
|
1512
1659
|
});
|
|
1513
1660
|
}
|
|
1514
1661
|
|
|
@@ -1516,10 +1663,10 @@ function append(aesCrypto, input, output, paddingStart, paddingEnd, verifyAuthen
|
|
|
1516
1663
|
const {
|
|
1517
1664
|
ctr,
|
|
1518
1665
|
hmac,
|
|
1519
|
-
|
|
1666
|
+
pendingInput
|
|
1520
1667
|
} = aesCrypto;
|
|
1521
|
-
if (
|
|
1522
|
-
input = concat(
|
|
1668
|
+
if (pendingInput.length) {
|
|
1669
|
+
input = concat(pendingInput, input);
|
|
1523
1670
|
}
|
|
1524
1671
|
const inputLength = input.length - paddingEnd;
|
|
1525
1672
|
output = expand(output, paddingStart + (inputLength - (inputLength % BLOCK_LENGTH)));
|
|
@@ -1535,7 +1682,7 @@ function append(aesCrypto, input, output, paddingStart, paddingEnd, verifyAuthen
|
|
|
1535
1682
|
}
|
|
1536
1683
|
output.set(fromBits(codecBytes, outputChunk), offset + paddingStart);
|
|
1537
1684
|
}
|
|
1538
|
-
aesCrypto.
|
|
1685
|
+
aesCrypto.pendingInput = subarray(input, offset);
|
|
1539
1686
|
return output;
|
|
1540
1687
|
}
|
|
1541
1688
|
|
|
@@ -3312,6 +3459,96 @@ async function terminateWorkers() {
|
|
|
3312
3459
|
resetWebWorkerSupport();
|
|
3313
3460
|
}
|
|
3314
3461
|
|
|
3462
|
+
/*
|
|
3463
|
+
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
3464
|
+
|
|
3465
|
+
Redistribution and use in source and binary forms, with or without
|
|
3466
|
+
modification, are permitted provided that the following conditions are met:
|
|
3467
|
+
|
|
3468
|
+
1. Redistributions of source code must retain the above copyright notice,
|
|
3469
|
+
this list of conditions and the following disclaimer.
|
|
3470
|
+
|
|
3471
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
3472
|
+
notice, this list of conditions and the following disclaimer in
|
|
3473
|
+
the documentation and/or other materials provided with the distribution.
|
|
3474
|
+
|
|
3475
|
+
3. The names of the authors may not be used to endorse or promote products
|
|
3476
|
+
derived from this software without specific prior written permission.
|
|
3477
|
+
|
|
3478
|
+
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
3479
|
+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
3480
|
+
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
3481
|
+
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
3482
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
3483
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
3484
|
+
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
3485
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
3486
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
3487
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
3488
|
+
*/
|
|
3489
|
+
|
|
3490
|
+
/* global TextDecoder */
|
|
3491
|
+
|
|
3492
|
+
const CP437 = "\0☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ".split("");
|
|
3493
|
+
const VALID_CP437 = CP437.length == 256;
|
|
3494
|
+
|
|
3495
|
+
function decodeCP437(stringValue) {
|
|
3496
|
+
if (VALID_CP437) {
|
|
3497
|
+
let result = "";
|
|
3498
|
+
for (let indexCharacter = 0; indexCharacter < stringValue.length; indexCharacter++) {
|
|
3499
|
+
result += CP437[stringValue[indexCharacter]];
|
|
3500
|
+
}
|
|
3501
|
+
return result;
|
|
3502
|
+
} else {
|
|
3503
|
+
return new TextDecoder().decode(stringValue);
|
|
3504
|
+
}
|
|
3505
|
+
}
|
|
3506
|
+
|
|
3507
|
+
/*
|
|
3508
|
+
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
3509
|
+
|
|
3510
|
+
Redistribution and use in source and binary forms, with or without
|
|
3511
|
+
modification, are permitted provided that the following conditions are met:
|
|
3512
|
+
|
|
3513
|
+
1. Redistributions of source code must retain the above copyright notice,
|
|
3514
|
+
this list of conditions and the following disclaimer.
|
|
3515
|
+
|
|
3516
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
3517
|
+
notice, this list of conditions and the following disclaimer in
|
|
3518
|
+
the documentation and/or other materials provided with the distribution.
|
|
3519
|
+
|
|
3520
|
+
3. The names of the authors may not be used to endorse or promote products
|
|
3521
|
+
derived from this software without specific prior written permission.
|
|
3522
|
+
|
|
3523
|
+
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
3524
|
+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
3525
|
+
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
3526
|
+
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
3527
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
3528
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
3529
|
+
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
3530
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
3531
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
3532
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
3533
|
+
*/
|
|
3534
|
+
|
|
3535
|
+
|
|
3536
|
+
function decodeText(value, encoding) {
|
|
3537
|
+
return decode(value, encoding, true);
|
|
3538
|
+
}
|
|
3539
|
+
|
|
3540
|
+
function decodeTextRemovingBOM(value, encoding) {
|
|
3541
|
+
return decode(value, encoding, false);
|
|
3542
|
+
}
|
|
3543
|
+
|
|
3544
|
+
function decode(value, encoding, ignoreBOM) {
|
|
3545
|
+
if (encoding && encoding.trim().toLowerCase() == "cp437") {
|
|
3546
|
+
return decodeCP437(value);
|
|
3547
|
+
} else {
|
|
3548
|
+
return new TextDecoder(encoding, { ignoreBOM }).decode(value);
|
|
3549
|
+
}
|
|
3550
|
+
}
|
|
3551
|
+
|
|
3315
3552
|
/*
|
|
3316
3553
|
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
3317
3554
|
|
|
@@ -3384,6 +3621,7 @@ class Reader extends Stream {
|
|
|
3384
3621
|
createReadable({ offset = 0, size, chunkSize = getChunkSize(getConfiguration()) } = {}) {
|
|
3385
3622
|
const reader = this;
|
|
3386
3623
|
let chunkOffset = 0;
|
|
3624
|
+
chunkSize = normalizeChunkSize(chunkSize);
|
|
3387
3625
|
return new ReadableStream({
|
|
3388
3626
|
async pull(controller) {
|
|
3389
3627
|
const dataSize = size === UNDEFINED_VALUE ? chunkSize : Math.min(chunkSize, size - chunkOffset);
|
|
@@ -3391,7 +3629,7 @@ class Reader extends Stream {
|
|
|
3391
3629
|
if (data.length) {
|
|
3392
3630
|
controller.enqueue(data);
|
|
3393
3631
|
}
|
|
3394
|
-
if ((chunkOffset + chunkSize >= size) || (
|
|
3632
|
+
if ((chunkOffset + chunkSize >= size) || (!data.length && dataSize)) {
|
|
3395
3633
|
controller.close();
|
|
3396
3634
|
} else {
|
|
3397
3635
|
chunkOffset += chunkSize;
|
|
@@ -3471,31 +3709,31 @@ class Data64URIWriter extends Writer {
|
|
|
3471
3709
|
Object.assign(this, {
|
|
3472
3710
|
contentType,
|
|
3473
3711
|
data: "data:" + (contentType || "") + ";base64,",
|
|
3474
|
-
|
|
3712
|
+
pendingCharacters: ""
|
|
3475
3713
|
});
|
|
3476
3714
|
}
|
|
3477
3715
|
|
|
3478
3716
|
writeUint8Array(array) {
|
|
3479
3717
|
const writer = this;
|
|
3480
3718
|
let indexArray;
|
|
3481
|
-
let dataString = writer.
|
|
3482
|
-
const delta = writer.
|
|
3483
|
-
writer.
|
|
3719
|
+
let dataString = writer.pendingCharacters;
|
|
3720
|
+
const delta = writer.pendingCharacters.length;
|
|
3721
|
+
writer.pendingCharacters = "";
|
|
3484
3722
|
for (indexArray = 0; indexArray < (Math.floor((delta + array.length) / 3) * 3) - delta; indexArray++) {
|
|
3485
3723
|
dataString += String.fromCharCode(array[indexArray]);
|
|
3486
3724
|
}
|
|
3487
3725
|
for (; indexArray < array.length; indexArray++) {
|
|
3488
|
-
writer.
|
|
3726
|
+
writer.pendingCharacters += String.fromCharCode(array[indexArray]);
|
|
3489
3727
|
}
|
|
3490
3728
|
if (dataString.length > 2) {
|
|
3491
3729
|
writer.data += btoa(dataString);
|
|
3492
3730
|
} else {
|
|
3493
|
-
writer.
|
|
3731
|
+
writer.pendingCharacters = dataString + writer.pendingCharacters;
|
|
3494
3732
|
}
|
|
3495
3733
|
}
|
|
3496
3734
|
|
|
3497
3735
|
getData() {
|
|
3498
|
-
return this.data + btoa(this.
|
|
3736
|
+
return this.data + btoa(this.pendingCharacters);
|
|
3499
3737
|
}
|
|
3500
3738
|
}
|
|
3501
3739
|
|
|
@@ -3525,7 +3763,7 @@ class BlobReader extends Reader {
|
|
|
3525
3763
|
constructor(blob) {
|
|
3526
3764
|
super();
|
|
3527
3765
|
Object.assign(this, {
|
|
3528
|
-
blob,
|
|
3766
|
+
sourceBlob: blob,
|
|
3529
3767
|
size: blob.size
|
|
3530
3768
|
});
|
|
3531
3769
|
if (!blobSliceProbe) {
|
|
@@ -3535,13 +3773,13 @@ class BlobReader extends Reader {
|
|
|
3535
3773
|
|
|
3536
3774
|
createReadable(options) {
|
|
3537
3775
|
const reader = this;
|
|
3538
|
-
const {
|
|
3776
|
+
const { sourceBlob, size } = reader;
|
|
3539
3777
|
const { offset = 0, size: readSize = size - offset } = options || {};
|
|
3540
3778
|
if (!offset && readSize >= size) {
|
|
3541
|
-
return toCompatibleReadable(
|
|
3779
|
+
return toCompatibleReadable(sourceBlob.stream());
|
|
3542
3780
|
}
|
|
3543
3781
|
if (blobSliceReliable) {
|
|
3544
|
-
return toCompatibleReadable(
|
|
3782
|
+
return toCompatibleReadable(sourceBlob.slice(offset, offset + readSize).stream());
|
|
3545
3783
|
}
|
|
3546
3784
|
return super.createReadable(options);
|
|
3547
3785
|
}
|
|
@@ -3550,7 +3788,7 @@ class BlobReader extends Reader {
|
|
|
3550
3788
|
const reader = this;
|
|
3551
3789
|
const offsetEnd = offset + length;
|
|
3552
3790
|
const readsWholeBlob = !offset && offsetEnd >= reader.size;
|
|
3553
|
-
const blob = readsWholeBlob ? reader.
|
|
3791
|
+
const blob = readsWholeBlob ? reader.sourceBlob : reader.sourceBlob.slice(offset, offsetEnd);
|
|
3554
3792
|
let arrayBuffer = await blob.arrayBuffer();
|
|
3555
3793
|
const sliceIgnoredByBuggyImplementation = arrayBuffer.byteLength > length;
|
|
3556
3794
|
if (sliceIgnoredByBuggyImplementation) {
|
|
@@ -3572,12 +3810,12 @@ class BlobWriter extends Stream {
|
|
|
3572
3810
|
}
|
|
3573
3811
|
});
|
|
3574
3812
|
writer.contentType = contentType;
|
|
3575
|
-
writer.
|
|
3576
|
-
writer.
|
|
3813
|
+
writer.blobPromise = streamToBlob(transformStream.readable, contentType);
|
|
3814
|
+
writer.blobPromise.catch(() => { });
|
|
3577
3815
|
}
|
|
3578
3816
|
|
|
3579
3817
|
getData() {
|
|
3580
|
-
return this.
|
|
3818
|
+
return this.blobPromise;
|
|
3581
3819
|
}
|
|
3582
3820
|
}
|
|
3583
3821
|
|
|
@@ -3591,7 +3829,7 @@ class TextReader extends BlobReader {
|
|
|
3591
3829
|
class TextWriter extends BlobWriter {
|
|
3592
3830
|
|
|
3593
3831
|
constructor(encoding) {
|
|
3594
|
-
super(
|
|
3832
|
+
super();
|
|
3595
3833
|
Object.assign(this, {
|
|
3596
3834
|
encoding,
|
|
3597
3835
|
utf8: !encoding || encoding.toLowerCase() == "utf-8"
|
|
@@ -3607,14 +3845,7 @@ class TextWriter extends BlobWriter {
|
|
|
3607
3845
|
if (blob.text && utf8) {
|
|
3608
3846
|
return blob.text();
|
|
3609
3847
|
} else {
|
|
3610
|
-
|
|
3611
|
-
return new Promise((resolve, reject) => {
|
|
3612
|
-
Object.assign(reader, {
|
|
3613
|
-
onload: ({ target }) => resolve(target.result),
|
|
3614
|
-
onerror: () => reject(reader.error)
|
|
3615
|
-
});
|
|
3616
|
-
reader.readAsText(blob, encoding);
|
|
3617
|
-
});
|
|
3848
|
+
return decodeTextRemovingBOM(new Uint8Array(await blob.arrayBuffer()), encoding);
|
|
3618
3849
|
}
|
|
3619
3850
|
}
|
|
3620
3851
|
}
|
|
@@ -4282,85 +4513,13 @@ function readUint8Array(reader, offset, size) {
|
|
|
4282
4513
|
return reader.readUint8Array(offset, size);
|
|
4283
4514
|
}
|
|
4284
4515
|
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
1. Redistributions of source code must retain the above copyright notice,
|
|
4292
|
-
this list of conditions and the following disclaimer.
|
|
4293
|
-
|
|
4294
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
4295
|
-
notice, this list of conditions and the following disclaimer in
|
|
4296
|
-
the documentation and/or other materials provided with the distribution.
|
|
4297
|
-
|
|
4298
|
-
3. The names of the authors may not be used to endorse or promote products
|
|
4299
|
-
derived from this software without specific prior written permission.
|
|
4300
|
-
|
|
4301
|
-
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
4302
|
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
4303
|
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
4304
|
-
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
4305
|
-
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
4306
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
4307
|
-
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
4308
|
-
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
4309
|
-
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
4310
|
-
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
4311
|
-
*/
|
|
4312
|
-
|
|
4313
|
-
/* global TextDecoder */
|
|
4314
|
-
|
|
4315
|
-
const CP437 = "\0☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ".split("");
|
|
4316
|
-
const VALID_CP437 = CP437.length == 256;
|
|
4317
|
-
|
|
4318
|
-
function decodeCP437(stringValue) {
|
|
4319
|
-
if (VALID_CP437) {
|
|
4320
|
-
let result = "";
|
|
4321
|
-
for (let indexCharacter = 0; indexCharacter < stringValue.length; indexCharacter++) {
|
|
4322
|
-
result += CP437[stringValue[indexCharacter]];
|
|
4323
|
-
}
|
|
4324
|
-
return result;
|
|
4325
|
-
} else {
|
|
4326
|
-
return new TextDecoder().decode(stringValue);
|
|
4327
|
-
}
|
|
4328
|
-
}
|
|
4329
|
-
|
|
4330
|
-
/*
|
|
4331
|
-
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
4332
|
-
|
|
4333
|
-
Redistribution and use in source and binary forms, with or without
|
|
4334
|
-
modification, are permitted provided that the following conditions are met:
|
|
4335
|
-
|
|
4336
|
-
1. Redistributions of source code must retain the above copyright notice,
|
|
4337
|
-
this list of conditions and the following disclaimer.
|
|
4338
|
-
|
|
4339
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
4340
|
-
notice, this list of conditions and the following disclaimer in
|
|
4341
|
-
the documentation and/or other materials provided with the distribution.
|
|
4342
|
-
|
|
4343
|
-
3. The names of the authors may not be used to endorse or promote products
|
|
4344
|
-
derived from this software without specific prior written permission.
|
|
4345
|
-
|
|
4346
|
-
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
4347
|
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
4348
|
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
4349
|
-
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
4350
|
-
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
4351
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
4352
|
-
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
4353
|
-
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
4354
|
-
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
4355
|
-
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
4356
|
-
*/
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
function decodeText(value, encoding) {
|
|
4360
|
-
if (encoding && encoding.trim().toLowerCase() == "cp437") {
|
|
4361
|
-
return decodeCP437(value);
|
|
4516
|
+
function createReadable(reader, options) {
|
|
4517
|
+
if (reader.createReadable) {
|
|
4518
|
+
return reader.createReadable(options);
|
|
4519
|
+
} else if (reader.readUint8Array) {
|
|
4520
|
+
return Reader.prototype.createReadable.call(reader, options);
|
|
4362
4521
|
} else {
|
|
4363
|
-
return
|
|
4522
|
+
return reader.readable;
|
|
4364
4523
|
}
|
|
4365
4524
|
}
|
|
4366
4525
|
|
|
@@ -4520,83 +4679,6 @@ class Entry {
|
|
|
4520
4679
|
|
|
4521
4680
|
}
|
|
4522
4681
|
|
|
4523
|
-
/*
|
|
4524
|
-
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
4525
|
-
|
|
4526
|
-
Redistribution and use in source and binary forms, with or without
|
|
4527
|
-
modification, are permitted provided that the following conditions are met:
|
|
4528
|
-
|
|
4529
|
-
1. Redistributions of source code must retain the above copyright notice,
|
|
4530
|
-
this list of conditions and the following disclaimer.
|
|
4531
|
-
|
|
4532
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
4533
|
-
notice, this list of conditions and the following disclaimer in
|
|
4534
|
-
the documentation and/or other materials provided with the distribution.
|
|
4535
|
-
|
|
4536
|
-
3. The names of the authors may not be used to endorse or promote products
|
|
4537
|
-
derived from this software without specific prior written permission.
|
|
4538
|
-
|
|
4539
|
-
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
4540
|
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
4541
|
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
4542
|
-
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
4543
|
-
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
4544
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
4545
|
-
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
4546
|
-
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
4547
|
-
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
4548
|
-
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
4549
|
-
*/
|
|
4550
|
-
|
|
4551
|
-
const OPTION_FILENAME_ENCODING = "filenameEncoding";
|
|
4552
|
-
const OPTION_COMMENT_ENCODING = "commentEncoding";
|
|
4553
|
-
const OPTION_DECODE_TEXT = "decodeText";
|
|
4554
|
-
const OPTION_EXTRACT_PREPENDED_DATA = "extractPrependedData";
|
|
4555
|
-
const OPTION_EXTRACT_APPENDED_DATA = "extractAppendedData";
|
|
4556
|
-
const OPTION_PASSWORD = "password";
|
|
4557
|
-
const OPTION_RAW_PASSWORD = "rawPassword";
|
|
4558
|
-
const OPTION_PASS_THROUGH = "passThrough";
|
|
4559
|
-
const OPTION_SIGNAL = "signal";
|
|
4560
|
-
const OPTION_CHECK_PASSWORD_ONLY = "checkPasswordOnly";
|
|
4561
|
-
const OPTION_CHECK_OVERLAPPING_ENTRY_ONLY = "checkOverlappingEntryOnly";
|
|
4562
|
-
const OPTION_CHECK_OVERLAPPING_ENTRY = "checkOverlappingEntry";
|
|
4563
|
-
const OPTION_CHECK_AMBIGUITY = "checkAmbiguity";
|
|
4564
|
-
const OPTION_CHECK_LOCAL_DIRECTORY = "checkLocalDirectory";
|
|
4565
|
-
const OPTION_CHECK_SIGNATURE = "checkSignature";
|
|
4566
|
-
const OPTION_CHECK_CRC32 = "checkCrc32";
|
|
4567
|
-
const OPTION_CHECK_AUTHENTICATION_CODE = "checkAuthenticationCode";
|
|
4568
|
-
const OPTION_USE_WEB_WORKERS = "useWebWorkers";
|
|
4569
|
-
const OPTION_USE_COMPRESSION_STREAM = "useCompressionStream";
|
|
4570
|
-
const OPTION_TRANSFER_STREAMS = "transferStreams";
|
|
4571
|
-
const OPTION_PREVENT_CLOSE = "preventClose";
|
|
4572
|
-
const OPTION_ENCRYPTION_STRENGTH = "encryptionStrength";
|
|
4573
|
-
const OPTION_EXTENDED_TIMESTAMP = "extendedTimestamp";
|
|
4574
|
-
const OPTION_NTFS_TIMESTAMP = "ntfsTimestamp";
|
|
4575
|
-
const OPTION_KEEP_ORDER = "keepOrder";
|
|
4576
|
-
const OPTION_LEVEL = "level";
|
|
4577
|
-
const OPTION_BUFFERED_WRITE = "bufferedWrite";
|
|
4578
|
-
const OPTION_CREATE_TEMP_STREAM = "createTempStream";
|
|
4579
|
-
const OPTION_DATA_DESCRIPTOR_SIGNATURE = "dataDescriptorSignature";
|
|
4580
|
-
const OPTION_USE_UNICODE_FILE_NAMES = "useUnicodeFileNames";
|
|
4581
|
-
const OPTION_DATA_DESCRIPTOR = "dataDescriptor";
|
|
4582
|
-
const OPTION_SUPPORT_ZIP64_SPLIT_FILE = "supportZip64SplitFile";
|
|
4583
|
-
const OPTION_ENCODE_TEXT = "encodeText";
|
|
4584
|
-
const OPTION_OFFSET = "offset";
|
|
4585
|
-
const OPTION_USDZ = "usdz";
|
|
4586
|
-
const OPTION_UNIX_EXTRA_FIELD_TYPE = "unixExtraFieldType";
|
|
4587
|
-
const OPTION_LOCAL_EXTRA_FIELD = "localExtraField";
|
|
4588
|
-
const OPTION_STRICTNESS = "strictness";
|
|
4589
|
-
const OPTION_FILENAME_VALIDATION = "filenameValidation";
|
|
4590
|
-
const OPTION_NORMALIZE_FILENAME = "normalizeFilename";
|
|
4591
|
-
const OPTION_MAX_APPENDED_DATA_SIZE = "maxAppendedDataSize";
|
|
4592
|
-
const OPTION_DECRYPT_CENTRAL_DIRECTORY = "decryptCentralDirectory";
|
|
4593
|
-
const OPTION_SIGN_CENTRAL_DIRECTORY = "signCentralDirectory";
|
|
4594
|
-
const TEXT_TYPE_FILENAME = "filename";
|
|
4595
|
-
const TEXT_TYPE_COMMENT = "comment";
|
|
4596
|
-
const STRICTNESS_STRICT = "strict";
|
|
4597
|
-
const STRICTNESS_BALANCED = "balanced";
|
|
4598
|
-
const STRICTNESS_TOLERANT = "tolerant";
|
|
4599
|
-
|
|
4600
4682
|
/*
|
|
4601
4683
|
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
4602
4684
|
|
|
@@ -4637,6 +4719,7 @@ const ERR_UNSUPPORTED_ENCRYPTION = "Encryption method not supported";
|
|
|
4637
4719
|
const ERR_UNSUPPORTED_COMPRESSION$1 = "Compression method not supported";
|
|
4638
4720
|
const ERR_SPLIT_ZIP_FILE = "Split zip file";
|
|
4639
4721
|
const ERR_OVERLAPPING_ENTRY = "Overlapping entry found";
|
|
4722
|
+
const ERR_ENTRY_DATA_OUT_OF_BOUNDS = "Entry data out of bounds";
|
|
4640
4723
|
const ERR_AMBIGUOUS_ARCHIVE = "Ambiguous archive";
|
|
4641
4724
|
const ERR_ENCRYPTED_CENTRAL_DIRECTORY = "Encrypted central directory is not supported";
|
|
4642
4725
|
const ERR_UNSAFE_FILENAME = "Unsafe filename";
|
|
@@ -4657,7 +4740,7 @@ const ZIP64_PROPERTIES = [
|
|
|
4657
4740
|
];
|
|
4658
4741
|
const ZIP64_EXTRACTION = {
|
|
4659
4742
|
[MAX_16_BITS]: {
|
|
4660
|
-
getValue: getUint32,
|
|
4743
|
+
getValue: getUint32$1,
|
|
4661
4744
|
bytes: 4
|
|
4662
4745
|
},
|
|
4663
4746
|
[MAX_32_BITS]: {
|
|
@@ -4666,6 +4749,7 @@ const ZIP64_EXTRACTION = {
|
|
|
4666
4749
|
}
|
|
4667
4750
|
};
|
|
4668
4751
|
const MAX_END_OF_CENTRAL_DIR_PROBES = 64;
|
|
4752
|
+
const MAX_DEFLATE_EXPANSION_RATIO = 1032;
|
|
4669
4753
|
const CENTRAL_DIRECTORY_UNREACHABLE = 0;
|
|
4670
4754
|
const CENTRAL_DIRECTORY_PLAUSIBLE = 1;
|
|
4671
4755
|
const CENTRAL_DIRECTORY_REACHABLE = 2;
|
|
@@ -4676,7 +4760,6 @@ class ZipReader {
|
|
|
4676
4760
|
Object.assign(this, {
|
|
4677
4761
|
reader: new GenericReader(reader),
|
|
4678
4762
|
options,
|
|
4679
|
-
config: getConfiguration(),
|
|
4680
4763
|
readRanges: new Map()
|
|
4681
4764
|
});
|
|
4682
4765
|
}
|
|
@@ -4684,7 +4767,6 @@ class ZipReader {
|
|
|
4684
4767
|
async* getEntriesGenerator(options = {}) {
|
|
4685
4768
|
const zipReader = this;
|
|
4686
4769
|
let { reader } = zipReader;
|
|
4687
|
-
const { config } = zipReader;
|
|
4688
4770
|
await initStream(reader);
|
|
4689
4771
|
if (reader.size === UNDEFINED_VALUE || !reader.readUint8Array) {
|
|
4690
4772
|
reader = new BlobReader(await streamToBlob(reader.readable));
|
|
@@ -4701,9 +4783,7 @@ class ZipReader {
|
|
|
4701
4783
|
const normalizeFilename = getOptionValue$1(zipReader, options, OPTION_NORMALIZE_FILENAME);
|
|
4702
4784
|
const { endOfDirectoryInfo, endOfDirectoryReachingEndCount } = await findEndOfCentralDirectory(reader, rejectAmbiguousEndOfDirectory, maxAppendedDataSize);
|
|
4703
4785
|
if (!endOfDirectoryInfo) {
|
|
4704
|
-
|
|
4705
|
-
const signatureView = getDataView(signatureArray);
|
|
4706
|
-
if (getUint32(signatureView) == SPLIT_ZIP_FILE_SIGNATURE) {
|
|
4786
|
+
if (await startsWithSplitZipSignature$1(reader)) {
|
|
4707
4787
|
throw new Error(ERR_SPLIT_ZIP_FILE);
|
|
4708
4788
|
} else {
|
|
4709
4789
|
throw new Error(ERR_EOCDR_NOT_FOUND);
|
|
@@ -4713,22 +4793,23 @@ class ZipReader {
|
|
|
4713
4793
|
throwAmbiguousArchive("multiple end of central directory records");
|
|
4714
4794
|
}
|
|
4715
4795
|
const endOfDirectoryView = getDataView(endOfDirectoryInfo);
|
|
4716
|
-
let directoryDataLength = getUint32(endOfDirectoryView, 12);
|
|
4717
|
-
let directoryDataOffset = getUint32(endOfDirectoryView, 16);
|
|
4796
|
+
let directoryDataLength = getUint32$1(endOfDirectoryView, 12);
|
|
4797
|
+
let directoryDataOffset = getUint32$1(endOfDirectoryView, 16);
|
|
4718
4798
|
const commentOffset = endOfDirectoryInfo.offset;
|
|
4719
|
-
const commentLength = getUint16(endOfDirectoryView, 20);
|
|
4799
|
+
const commentLength = getUint16$1(endOfDirectoryView, 20);
|
|
4720
4800
|
const appendedDataOffset = commentOffset + END_OF_CENTRAL_DIR_LENGTH + commentLength;
|
|
4721
4801
|
if (reader.size - appendedDataOffset > maxAppendedDataSize) {
|
|
4722
4802
|
throwAmbiguousArchive("appended data");
|
|
4723
4803
|
}
|
|
4724
|
-
let lastDiskNumber = getUint16(endOfDirectoryView, 4);
|
|
4804
|
+
let lastDiskNumber = getUint16$1(endOfDirectoryView, 4);
|
|
4725
4805
|
const expectedLastDiskNumber = reader.lastDiskNumber || 0;
|
|
4726
|
-
let diskNumber = getUint16(endOfDirectoryView, 6);
|
|
4727
|
-
let filesLength = getUint16(endOfDirectoryView, 10);
|
|
4806
|
+
let diskNumber = getUint16$1(endOfDirectoryView, 6);
|
|
4807
|
+
let filesLength = getUint16$1(endOfDirectoryView, 10);
|
|
4728
4808
|
let prependedDataLength = 0;
|
|
4729
4809
|
let startOffset;
|
|
4730
4810
|
let zip64EndOfDirectory;
|
|
4731
4811
|
let zip64EndOfDirectoryVersion2;
|
|
4812
|
+
let zip64EndOfDirectoryLength = ZIP64_END_OF_CENTRAL_DIR_LENGTH;
|
|
4732
4813
|
let directoryEncryptionInfo;
|
|
4733
4814
|
const requiresZip64 = directoryDataOffset == MAX_32_BITS || directoryDataLength == MAX_32_BITS || filesLength == MAX_16_BITS || diskNumber == MAX_16_BITS;
|
|
4734
4815
|
if (directoryDataOffset != MAX_32_BITS && diskNumber != MAX_16_BITS) {
|
|
@@ -4740,12 +4821,12 @@ class ZipReader {
|
|
|
4740
4821
|
EMPTY_UINT8_ARRAY;
|
|
4741
4822
|
const endOfDirectoryLocatorView = getDataView(endOfDirectoryLocatorArray);
|
|
4742
4823
|
if (endOfDirectoryLocatorArray.length == ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH &&
|
|
4743
|
-
getUint32(endOfDirectoryLocatorView, 0) == ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE) {
|
|
4744
|
-
directoryDataOffset = getDiskOffset$1(reader, getUint32(endOfDirectoryLocatorView, 4)) + getBigUint64(endOfDirectoryLocatorView, 8);
|
|
4824
|
+
getUint32$1(endOfDirectoryLocatorView, 0) == ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE) {
|
|
4825
|
+
directoryDataOffset = getDiskOffset$1(reader, getUint32$1(endOfDirectoryLocatorView, 4)) + getBigUint64(endOfDirectoryLocatorView, 8);
|
|
4745
4826
|
let endOfDirectoryArray = await readUint8Array(reader, directoryDataOffset, ZIP64_END_OF_CENTRAL_DIR_LENGTH);
|
|
4746
4827
|
let endOfDirectoryView = getDataView(endOfDirectoryArray);
|
|
4747
4828
|
const expectedDirectoryDataOffset = endOfDirectoryInfo.offset - ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH - ZIP64_END_OF_CENTRAL_DIR_LENGTH;
|
|
4748
|
-
if ((endOfDirectoryArray.length < ZIP64_END_OF_CENTRAL_DIR_LENGTH || getUint32(endOfDirectoryView, 0) != ZIP64_END_OF_CENTRAL_DIR_SIGNATURE) &&
|
|
4829
|
+
if ((endOfDirectoryArray.length < ZIP64_END_OF_CENTRAL_DIR_LENGTH || getUint32$1(endOfDirectoryView, 0) != ZIP64_END_OF_CENTRAL_DIR_SIGNATURE) &&
|
|
4749
4830
|
directoryDataOffset != expectedDirectoryDataOffset && expectedDirectoryDataOffset >= 0) {
|
|
4750
4831
|
const originalDirectoryDataOffset = directoryDataOffset;
|
|
4751
4832
|
directoryDataOffset = expectedDirectoryDataOffset;
|
|
@@ -4755,7 +4836,7 @@ class ZipReader {
|
|
|
4755
4836
|
endOfDirectoryArray = await readUint8Array(reader, directoryDataOffset, ZIP64_END_OF_CENTRAL_DIR_LENGTH);
|
|
4756
4837
|
endOfDirectoryView = getDataView(endOfDirectoryArray);
|
|
4757
4838
|
}
|
|
4758
|
-
if (endOfDirectoryArray.length < ZIP64_END_OF_CENTRAL_DIR_LENGTH || getUint32(endOfDirectoryView, 0) != ZIP64_END_OF_CENTRAL_DIR_SIGNATURE) {
|
|
4839
|
+
if (endOfDirectoryArray.length < ZIP64_END_OF_CENTRAL_DIR_LENGTH || getUint32$1(endOfDirectoryView, 0) != ZIP64_END_OF_CENTRAL_DIR_SIGNATURE) {
|
|
4759
4840
|
throw new Error(ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND);
|
|
4760
4841
|
}
|
|
4761
4842
|
zip64EndOfDirectory = true;
|
|
@@ -4765,18 +4846,19 @@ class ZipReader {
|
|
|
4765
4846
|
Number(getBigUint64(endOfDirectoryView, 4)) - (ZIP64_END_OF_CENTRAL_DIR_LENGTH - 12),
|
|
4766
4847
|
reader.size - directoryDataOffset - ZIP64_END_OF_CENTRAL_DIR_LENGTH);
|
|
4767
4848
|
if (extensibleDataLength > 0) {
|
|
4849
|
+
zip64EndOfDirectoryLength += extensibleDataLength;
|
|
4768
4850
|
const rawExtensibleData = await readUint8Array(reader, directoryDataOffset + ZIP64_END_OF_CENTRAL_DIR_LENGTH, extensibleDataLength);
|
|
4769
4851
|
directoryEncryptionInfo = getDirectoryEncryptionInfo(rawExtensibleData);
|
|
4770
4852
|
}
|
|
4771
4853
|
}
|
|
4772
4854
|
if (lastDiskNumber == MAX_16_BITS) {
|
|
4773
|
-
lastDiskNumber = getUint32(endOfDirectoryView, 16);
|
|
4774
|
-
} else if (checkAmbiguity && lastDiskNumber != getUint32(endOfDirectoryView, 16)) {
|
|
4855
|
+
lastDiskNumber = getUint32$1(endOfDirectoryView, 16);
|
|
4856
|
+
} else if (checkAmbiguity && lastDiskNumber != getUint32$1(endOfDirectoryView, 16)) {
|
|
4775
4857
|
throwAmbiguousArchive("mismatched zip64 end of central directory record");
|
|
4776
4858
|
}
|
|
4777
4859
|
if (diskNumber == MAX_16_BITS) {
|
|
4778
|
-
diskNumber = getUint32(endOfDirectoryView, 20);
|
|
4779
|
-
} else if (checkAmbiguity && diskNumber != getUint32(endOfDirectoryView, 20)) {
|
|
4860
|
+
diskNumber = getUint32$1(endOfDirectoryView, 20);
|
|
4861
|
+
} else if (checkAmbiguity && diskNumber != getUint32$1(endOfDirectoryView, 20)) {
|
|
4780
4862
|
throwAmbiguousArchive("mismatched zip64 end of central directory record");
|
|
4781
4863
|
}
|
|
4782
4864
|
if (filesLength == MAX_16_BITS) {
|
|
@@ -4794,7 +4876,7 @@ class ZipReader {
|
|
|
4794
4876
|
}
|
|
4795
4877
|
let declaredDirectoryDataLength = directoryDataLength;
|
|
4796
4878
|
const centralDirectoryEndOffset = endOfDirectoryInfo.offset -
|
|
4797
|
-
(zip64EndOfDirectory ?
|
|
4879
|
+
(zip64EndOfDirectory ? zip64EndOfDirectoryLength + ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH : 0);
|
|
4798
4880
|
if (directoryDataOffset >= reader.size) {
|
|
4799
4881
|
prependedDataLength = reader.size - directoryDataOffset - directoryDataLength - END_OF_CENTRAL_DIR_LENGTH;
|
|
4800
4882
|
directoryDataOffset = reader.size - directoryDataLength - END_OF_CENTRAL_DIR_LENGTH;
|
|
@@ -4814,11 +4896,13 @@ class ZipReader {
|
|
|
4814
4896
|
}
|
|
4815
4897
|
const expectedDirectoryDataOffset = centralDirectoryEndOffset - directoryDataLength;
|
|
4816
4898
|
if (directoryDataOffset != expectedDirectoryDataOffset && diskNumber == lastDiskNumber) {
|
|
4817
|
-
const storedPointsAtDirectory = getUint32(directoryView, offset) == CENTRAL_FILE_HEADER_SIGNATURE
|
|
4899
|
+
const storedPointsAtDirectory = getUint32$1(directoryView, offset) == CENTRAL_FILE_HEADER_SIGNATURE ||
|
|
4900
|
+
Boolean(directoryEncryptionInfo && directoryEncryptionInfo.compressedSize) ||
|
|
4901
|
+
detectEncryptedCentralDirectory(directoryView);
|
|
4818
4902
|
let reconcile = !storedPointsAtDirectory;
|
|
4819
4903
|
if (!reconcile && expectedDirectoryDataOffset >= 0 && expectedDirectoryDataOffset + 4 <= reader.size) {
|
|
4820
4904
|
const expectedSignatureArray = await readUint8Array(reader, expectedDirectoryDataOffset, 4);
|
|
4821
|
-
reconcile = getUint32(getDataView(expectedSignatureArray), 0) == CENTRAL_FILE_HEADER_SIGNATURE;
|
|
4905
|
+
reconcile = getUint32$1(getDataView(expectedSignatureArray), 0) == CENTRAL_FILE_HEADER_SIGNATURE;
|
|
4822
4906
|
}
|
|
4823
4907
|
if (reconcile) {
|
|
4824
4908
|
const originalDirectoryDataOffset = directoryDataOffset;
|
|
@@ -4842,12 +4926,14 @@ class ZipReader {
|
|
|
4842
4926
|
}
|
|
4843
4927
|
zipReader.directoryOffset = directoryDataOffset;
|
|
4844
4928
|
zipReader.directoryLength = declaredDirectoryDataLength;
|
|
4845
|
-
const decryptCentralDirectory =
|
|
4846
|
-
let decryptedDirectory;
|
|
4929
|
+
const decryptCentralDirectory = getFunctionOptionValue$1(zipReader, options, OPTION_DECRYPT_CENTRAL_DIRECTORY);
|
|
4930
|
+
let decryptedDirectory, dataAfterEncryptedDirectory;
|
|
4847
4931
|
if (decryptCentralDirectory && filesLength && directoryArray.length >= 4 &&
|
|
4848
|
-
getUint32(directoryView, 0) != CENTRAL_FILE_HEADER_SIGNATURE &&
|
|
4932
|
+
getUint32$1(directoryView, 0) != CENTRAL_FILE_HEADER_SIGNATURE &&
|
|
4849
4933
|
(zip64EndOfDirectoryVersion2 || detectEncryptedCentralDirectory(directoryView))) {
|
|
4850
|
-
|
|
4934
|
+
const encryptedDirectoryDataLength = getEncryptedDirectoryDataLength(directoryEncryptionInfo, declaredDirectoryDataLength, directoryArray.length);
|
|
4935
|
+
dataAfterEncryptedDirectory = directoryArray.subarray(encryptedDirectoryDataLength);
|
|
4936
|
+
directoryArray = await decryptCentralDirectory(directoryArray.subarray(0, encryptedDirectoryDataLength), directoryEncryptionInfo);
|
|
4851
4937
|
directoryView = getDataView(directoryArray);
|
|
4852
4938
|
declaredDirectoryDataLength = directoryArray.length;
|
|
4853
4939
|
decryptedDirectory = true;
|
|
@@ -4858,8 +4944,8 @@ class ZipReader {
|
|
|
4858
4944
|
const filenames = checkAmbiguity ? new Set() : UNDEFINED_VALUE;
|
|
4859
4945
|
let duplicateFilename;
|
|
4860
4946
|
for (let indexFile = 0; indexFile < filesLength; indexFile++) {
|
|
4861
|
-
const fileEntry = new ZipEntry(reader,
|
|
4862
|
-
if (offset + CENTRAL_FILE_HEADER_LENGTH > directoryArray.length || getUint32(directoryView, offset) != CENTRAL_FILE_HEADER_SIGNATURE) {
|
|
4947
|
+
const fileEntry = new ZipEntry(reader, zipReader.options);
|
|
4948
|
+
if (offset + CENTRAL_FILE_HEADER_LENGTH > directoryArray.length || getUint32$1(directoryView, offset) != CENTRAL_FILE_HEADER_SIGNATURE) {
|
|
4863
4949
|
if (indexFile == 0 && !decryptedDirectory && (zip64EndOfDirectoryVersion2 || detectEncryptedCentralDirectory(directoryView))) {
|
|
4864
4950
|
throw new Error(ERR_ENCRYPTED_CENTRAL_DIRECTORY);
|
|
4865
4951
|
}
|
|
@@ -4870,16 +4956,16 @@ class ZipReader {
|
|
|
4870
4956
|
const filenameOffset = offset + CENTRAL_FILE_HEADER_LENGTH;
|
|
4871
4957
|
const extraFieldOffset = filenameOffset + fileEntry.filenameLength;
|
|
4872
4958
|
const commentOffset = extraFieldOffset + fileEntry.extraFieldLength;
|
|
4873
|
-
const versionMadeBy = getUint16(directoryView, offset + 4);
|
|
4959
|
+
const versionMadeBy = getUint16$1(directoryView, offset + 4);
|
|
4874
4960
|
const msDosCompatible = versionMadeBy >> 8 == 0;
|
|
4875
4961
|
const unixCompatible = versionMadeBy >> 8 == 3;
|
|
4876
4962
|
const rawFilename = directoryArray.subarray(filenameOffset, extraFieldOffset);
|
|
4877
|
-
const commentLength = getUint16(directoryView, offset + 32);
|
|
4963
|
+
const commentLength = getUint16$1(directoryView, offset + 32);
|
|
4878
4964
|
const endOffset = commentOffset + commentLength;
|
|
4879
4965
|
const rawComment = directoryArray.subarray(commentOffset, endOffset);
|
|
4880
4966
|
const filenameUTF8 = languageEncodingFlag;
|
|
4881
4967
|
const commentUTF8 = languageEncodingFlag;
|
|
4882
|
-
const externalFileAttributes = getUint32(directoryView, offset + 38);
|
|
4968
|
+
const externalFileAttributes = getUint32$1(directoryView, offset + 38);
|
|
4883
4969
|
const msdosAttributesRaw = externalFileAttributes & MAX_8_BITS;
|
|
4884
4970
|
const msdosAttributes = {
|
|
4885
4971
|
readOnly: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_READONLY_MASK),
|
|
@@ -4888,8 +4974,8 @@ class ZipReader {
|
|
|
4888
4974
|
directory: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_DIR_MASK),
|
|
4889
4975
|
archive: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_ARCHIVE_MASK)
|
|
4890
4976
|
};
|
|
4891
|
-
const offsetFileEntry = getUint32(directoryView, offset + 42);
|
|
4892
|
-
const decode =
|
|
4977
|
+
const offsetFileEntry = getUint32$1(directoryView, offset + 42);
|
|
4978
|
+
const decode = getFunctionOptionValue$1(zipReader, options, OPTION_DECODE_TEXT) || decodeText;
|
|
4893
4979
|
const rawFilenameEncoding = filenameUTF8 ? CHARSET_UTF8 : filenameEncoding || CHARSET_CP437;
|
|
4894
4980
|
const rawCommentEncoding = commentUTF8 ? CHARSET_UTF8 : commentEncoding || CHARSET_CP437;
|
|
4895
4981
|
let filename = decode(rawFilename, rawFilenameEncoding, TEXT_TYPE_FILENAME);
|
|
@@ -4913,6 +4999,7 @@ class ZipReader {
|
|
|
4913
4999
|
}
|
|
4914
5000
|
Object.assign(fileEntry, {
|
|
4915
5001
|
index: indexFile,
|
|
5002
|
+
decryptedDirectory,
|
|
4916
5003
|
versionMadeBy,
|
|
4917
5004
|
msDosCompatible,
|
|
4918
5005
|
zip64: false,
|
|
@@ -4920,8 +5007,8 @@ class ZipReader {
|
|
|
4920
5007
|
uncompressedSize: 0,
|
|
4921
5008
|
commentLength,
|
|
4922
5009
|
offset: offsetFileEntry,
|
|
4923
|
-
diskNumberStart: getUint16(directoryView, offset + 34),
|
|
4924
|
-
internalFileAttributes: getUint16(directoryView, offset + 36),
|
|
5010
|
+
diskNumberStart: getUint16$1(directoryView, offset + 34),
|
|
5011
|
+
internalFileAttributes: getUint16$1(directoryView, offset + 36),
|
|
4925
5012
|
externalFileAttributes,
|
|
4926
5013
|
msdosAttributesRaw,
|
|
4927
5014
|
msdosAttributes,
|
|
@@ -4989,12 +5076,11 @@ class ZipReader {
|
|
|
4989
5076
|
yield entry;
|
|
4990
5077
|
}
|
|
4991
5078
|
let offsetAfterSignature = offset;
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
|
|
4997
|
-
}
|
|
5079
|
+
const digitalSignature = readDigitalSignature(directoryArray.subarray(offset)) ||
|
|
5080
|
+
(decryptedDirectory ? readDigitalSignature(dataAfterEncryptedDirectory) : UNDEFINED_VALUE);
|
|
5081
|
+
if (digitalSignature) {
|
|
5082
|
+
zipReader.digitalSignature = digitalSignature;
|
|
5083
|
+
offsetAfterSignature = offset + 6 + digitalSignature.length;
|
|
4998
5084
|
}
|
|
4999
5085
|
if (checkAmbiguity && offset != declaredDirectoryDataLength && offsetAfterSignature != declaredDirectoryDataLength) {
|
|
5000
5086
|
throwAmbiguousArchive("trailing central directory data");
|
|
@@ -5002,13 +5088,17 @@ class ZipReader {
|
|
|
5002
5088
|
if (duplicateFilename) {
|
|
5003
5089
|
throwAmbiguousArchive("duplicate filename");
|
|
5004
5090
|
}
|
|
5005
|
-
if (checkAmbiguity && (prependedDataLength || (filesLength && startOffset > 0))) {
|
|
5006
|
-
throwAmbiguousArchive("prepended data");
|
|
5007
|
-
}
|
|
5008
5091
|
const extractPrependedData = getOptionValue$1(zipReader, options, OPTION_EXTRACT_PREPENDED_DATA);
|
|
5009
5092
|
const extractAppendedData = getOptionValue$1(zipReader, options, OPTION_EXTRACT_APPENDED_DATA);
|
|
5093
|
+
const splitZipSignatureLength = (checkAmbiguity || extractPrependedData) && filesLength &&
|
|
5094
|
+
startOffset == SPLIT_ZIP_FILE_SIGNATURE_LENGTH && await startsWithSplitZipMarker(reader) ? SPLIT_ZIP_FILE_SIGNATURE_LENGTH : 0;
|
|
5095
|
+
if (checkAmbiguity && (prependedDataLength || (filesLength && startOffset > splitZipSignatureLength))) {
|
|
5096
|
+
throwAmbiguousArchive("prepended data");
|
|
5097
|
+
}
|
|
5010
5098
|
if (extractPrependedData) {
|
|
5011
|
-
zipReader.prependedData = startOffset >
|
|
5099
|
+
zipReader.prependedData = startOffset > splitZipSignatureLength ?
|
|
5100
|
+
await readUint8Array(reader, splitZipSignatureLength, startOffset - splitZipSignatureLength) :
|
|
5101
|
+
EMPTY_UINT8_ARRAY;
|
|
5012
5102
|
}
|
|
5013
5103
|
zipReader.comment = commentLength ? await readUint8Array(reader, commentOffset + END_OF_CENTRAL_DIR_LENGTH, commentLength) : EMPTY_UINT8_ARRAY;
|
|
5014
5104
|
if (extractAppendedData) {
|
|
@@ -5075,16 +5165,16 @@ class ZipReaderStream {
|
|
|
5075
5165
|
|
|
5076
5166
|
class ZipEntry {
|
|
5077
5167
|
|
|
5078
|
-
constructor(reader,
|
|
5168
|
+
constructor(reader, options) {
|
|
5079
5169
|
Object.assign(this, {
|
|
5080
5170
|
reader,
|
|
5081
|
-
config,
|
|
5082
5171
|
options
|
|
5083
5172
|
});
|
|
5084
5173
|
}
|
|
5085
5174
|
|
|
5086
5175
|
async getData(writer, fileEntry, readRanges, options = {}) {
|
|
5087
5176
|
const zipEntry = this;
|
|
5177
|
+
const config = getConfiguration();
|
|
5088
5178
|
const {
|
|
5089
5179
|
reader,
|
|
5090
5180
|
index,
|
|
@@ -5093,7 +5183,6 @@ class ZipEntry {
|
|
|
5093
5183
|
extraFieldAES,
|
|
5094
5184
|
extraFieldZip64,
|
|
5095
5185
|
compressionMethod,
|
|
5096
|
-
config,
|
|
5097
5186
|
bitFlag,
|
|
5098
5187
|
rawBitFlag,
|
|
5099
5188
|
crc32,
|
|
@@ -5111,6 +5200,7 @@ class ZipEntry {
|
|
|
5111
5200
|
let password = getOptionValue$1(zipEntry, options, OPTION_PASSWORD);
|
|
5112
5201
|
let rawPassword = getOptionValue$1(zipEntry, options, OPTION_RAW_PASSWORD);
|
|
5113
5202
|
const passThrough = getOptionValue$1(zipEntry, options, OPTION_PASS_THROUGH);
|
|
5203
|
+
checkPasswordOption(password, rawPassword);
|
|
5114
5204
|
password = password && password.length && password;
|
|
5115
5205
|
rawPassword = rawPassword && rawPassword.length && rawPassword;
|
|
5116
5206
|
if (extraFieldAES) {
|
|
@@ -5118,7 +5208,7 @@ class ZipEntry {
|
|
|
5118
5208
|
throw new Error(ERR_UNSUPPORTED_COMPRESSION$1);
|
|
5119
5209
|
}
|
|
5120
5210
|
}
|
|
5121
|
-
if (dataArray.length < HEADER_SIZE || getUint32(dataView, 0) != LOCAL_FILE_HEADER_SIGNATURE) {
|
|
5211
|
+
if (dataArray.length < HEADER_SIZE || getUint32$1(dataView, 0) != LOCAL_FILE_HEADER_SIGNATURE) {
|
|
5122
5212
|
throw new Error(ERR_LOCAL_FILE_HEADER_NOT_FOUND);
|
|
5123
5213
|
}
|
|
5124
5214
|
readCommonHeader(localDirectory, dataView, 4);
|
|
@@ -5180,9 +5270,12 @@ class ZipEntry {
|
|
|
5180
5270
|
}
|
|
5181
5271
|
}
|
|
5182
5272
|
const dataOffset = localHeaderOffset + HEADER_SIZE + filenameLength + extraFieldLength;
|
|
5273
|
+
if (dataOffset + compressedSize > reader.size) {
|
|
5274
|
+
throw new Error(ERR_ENTRY_DATA_OUT_OF_BOUNDS);
|
|
5275
|
+
}
|
|
5183
5276
|
const size = compressedSize;
|
|
5184
5277
|
const readable = toCompatibleReadable(reader.createReadable({ offset: dataOffset, size }));
|
|
5185
|
-
const signal = getOptionValue$1(zipEntry, options, OPTION_SIGNAL);
|
|
5278
|
+
const signal = checkSignalOption(getOptionValue$1(zipEntry, options, OPTION_SIGNAL));
|
|
5186
5279
|
const checkPasswordOnly = getOptionValue$1(zipEntry, options, OPTION_CHECK_PASSWORD_ONLY);
|
|
5187
5280
|
let checkOverlappingEntry = getOptionValue$1(zipEntry, options, OPTION_CHECK_OVERLAPPING_ENTRY);
|
|
5188
5281
|
const checkOverlappingEntryOnly = getOptionValue$1(zipEntry, options, OPTION_CHECK_OVERLAPPING_ENTRY_ONLY);
|
|
@@ -5190,6 +5283,8 @@ class ZipEntry {
|
|
|
5190
5283
|
checkOverlappingEntry = true;
|
|
5191
5284
|
}
|
|
5192
5285
|
const { onstart, onprogress, onend } = options;
|
|
5286
|
+
const compressed = compressionMethod != COMPRESSION_METHOD_STORE && !passThrough;
|
|
5287
|
+
const outputSize = passThrough ? compressedSize : uncompressedSize;
|
|
5193
5288
|
const deflate64 = compressionMethod == COMPRESSION_METHOD_DEFLATE_64;
|
|
5194
5289
|
let useCompressionStream = getOptionValue$1(zipEntry, options, OPTION_USE_COMPRESSION_STREAM);
|
|
5195
5290
|
if (deflate64) {
|
|
@@ -5210,9 +5305,9 @@ class ZipEntry {
|
|
|
5210
5305
|
checkCrc32,
|
|
5211
5306
|
checkAuthenticationCode: getOptionValue$1(zipEntry, options, OPTION_CHECK_AUTHENTICATION_CODE),
|
|
5212
5307
|
passwordVerification: zipCrypto && (dataDescriptor ? ((rawLastModDate >>> 8) & MAX_8_BITS) : ((crc32 >>> 24) & MAX_8_BITS)),
|
|
5213
|
-
outputSize
|
|
5308
|
+
outputSize,
|
|
5214
5309
|
crc32,
|
|
5215
|
-
compressed
|
|
5310
|
+
compressed,
|
|
5216
5311
|
encrypted,
|
|
5217
5312
|
useWebWorkers: getOptionValue$1(zipEntry, options, OPTION_USE_WEB_WORKERS),
|
|
5218
5313
|
useCompressionStream,
|
|
@@ -5249,11 +5344,11 @@ class ZipEntry {
|
|
|
5249
5344
|
writer = new WritableStream();
|
|
5250
5345
|
}
|
|
5251
5346
|
writer = new GenericWriter(writer);
|
|
5252
|
-
await initStream(writer,
|
|
5347
|
+
await initStream(writer, getDecodableOutputSize(outputSize, compressedSize, compressed));
|
|
5253
5348
|
({ writable } = writer);
|
|
5254
|
-
const { outputSize } = await runWorker({ readable, writable }, workerOptions);
|
|
5255
|
-
writer.size +=
|
|
5256
|
-
if (
|
|
5349
|
+
const { outputSize: writtenSize } = await runWorker({ readable, writable }, workerOptions);
|
|
5350
|
+
writer.size += writtenSize;
|
|
5351
|
+
if (writtenSize != outputSize) {
|
|
5257
5352
|
throw new Error(ERR_INVALID_UNCOMPRESSED_SIZE);
|
|
5258
5353
|
}
|
|
5259
5354
|
}
|
|
@@ -5287,26 +5382,47 @@ class ZipEntry {
|
|
|
5287
5382
|
function detectEncryptedCentralDirectory(directoryView) {
|
|
5288
5383
|
const maxOffset = Math.min(directoryView.byteLength, 1024) - 3;
|
|
5289
5384
|
for (let offset = 0; offset < maxOffset; offset++) {
|
|
5290
|
-
if (getUint32(directoryView, offset) == ARCHIVE_EXTRA_DATA_SIGNATURE) {
|
|
5385
|
+
if (getUint32$1(directoryView, offset) == ARCHIVE_EXTRA_DATA_SIGNATURE) {
|
|
5291
5386
|
return true;
|
|
5292
5387
|
}
|
|
5293
5388
|
}
|
|
5294
5389
|
return false;
|
|
5295
5390
|
}
|
|
5296
5391
|
|
|
5392
|
+
function readDigitalSignature(signatureRecordArray) {
|
|
5393
|
+
if (signatureRecordArray.length >= 6) {
|
|
5394
|
+
const signatureRecordView = getDataView(signatureRecordArray);
|
|
5395
|
+
if (getUint32$1(signatureRecordView, 0) == DIGITAL_SIGNATURE_RECORD_SIGNATURE) {
|
|
5396
|
+
const signatureDataLength = getUint16$1(signatureRecordView, 4);
|
|
5397
|
+
if (6 + signatureDataLength <= signatureRecordArray.length) {
|
|
5398
|
+
return signatureRecordArray.subarray(6, 6 + signatureDataLength);
|
|
5399
|
+
}
|
|
5400
|
+
}
|
|
5401
|
+
}
|
|
5402
|
+
}
|
|
5403
|
+
|
|
5404
|
+
function getEncryptedDirectoryDataLength(directoryEncryptionInfo, declaredDirectoryDataLength, directoryDataLength) {
|
|
5405
|
+
const encryptedDirectoryDataLength = directoryEncryptionInfo && directoryEncryptionInfo.compressedSize ?
|
|
5406
|
+
directoryEncryptionInfo.compressedSize :
|
|
5407
|
+
declaredDirectoryDataLength;
|
|
5408
|
+
return encryptedDirectoryDataLength > 0 && encryptedDirectoryDataLength <= directoryDataLength ?
|
|
5409
|
+
encryptedDirectoryDataLength :
|
|
5410
|
+
directoryDataLength;
|
|
5411
|
+
}
|
|
5412
|
+
|
|
5297
5413
|
function getDirectoryEncryptionInfo(rawExtensibleData) {
|
|
5298
5414
|
const directoryEncryptionInfo = { rawExtensibleData };
|
|
5299
5415
|
if (rawExtensibleData.length >= 28) {
|
|
5300
5416
|
const extensibleDataView = getDataView(rawExtensibleData);
|
|
5301
|
-
const hashDataLength = getUint16(extensibleDataView, 26);
|
|
5417
|
+
const hashDataLength = getUint16$1(extensibleDataView, 26);
|
|
5302
5418
|
Object.assign(directoryEncryptionInfo, {
|
|
5303
|
-
compressionMethod: getUint16(extensibleDataView, 0),
|
|
5419
|
+
compressionMethod: getUint16$1(extensibleDataView, 0),
|
|
5304
5420
|
compressedSize: Number(getBigUint64(extensibleDataView, 2)),
|
|
5305
5421
|
uncompressedSize: Number(getBigUint64(extensibleDataView, 10)),
|
|
5306
|
-
encryptionAlgorithm: getUint16(extensibleDataView, 18),
|
|
5307
|
-
bitLength: getUint16(extensibleDataView, 20),
|
|
5308
|
-
flags: getUint16(extensibleDataView, 22),
|
|
5309
|
-
hashAlgorithm: getUint16(extensibleDataView, 24),
|
|
5422
|
+
encryptionAlgorithm: getUint16$1(extensibleDataView, 18),
|
|
5423
|
+
bitLength: getUint16$1(extensibleDataView, 20),
|
|
5424
|
+
flags: getUint16$1(extensibleDataView, 22),
|
|
5425
|
+
hashAlgorithm: getUint16$1(extensibleDataView, 24),
|
|
5310
5426
|
hashData: rawExtensibleData.subarray(28, 28 + hashDataLength)
|
|
5311
5427
|
});
|
|
5312
5428
|
}
|
|
@@ -5314,12 +5430,12 @@ function getDirectoryEncryptionInfo(rawExtensibleData) {
|
|
|
5314
5430
|
}
|
|
5315
5431
|
|
|
5316
5432
|
function readCommonHeader(directory, dataView, offset) {
|
|
5317
|
-
const rawBitFlag = directory.rawBitFlag = getUint16(dataView, offset + 2);
|
|
5433
|
+
const rawBitFlag = directory.rawBitFlag = getUint16$1(dataView, offset + 2);
|
|
5318
5434
|
const encrypted = (rawBitFlag & BITFLAG_ENCRYPTED) == BITFLAG_ENCRYPTED;
|
|
5319
|
-
const rawLastModDate = getUint32(dataView, offset + 6);
|
|
5435
|
+
const rawLastModDate = getUint32$1(dataView, offset + 6);
|
|
5320
5436
|
Object.assign(directory, {
|
|
5321
5437
|
encrypted,
|
|
5322
|
-
version: getUint16(dataView, offset),
|
|
5438
|
+
version: getUint16$1(dataView, offset),
|
|
5323
5439
|
bitFlag: {
|
|
5324
5440
|
level: (rawBitFlag & BITFLAG_LEVEL) >> 1,
|
|
5325
5441
|
dataDescriptor: (rawBitFlag & BITFLAG_DATA_DESCRIPTOR) == BITFLAG_DATA_DESCRIPTOR,
|
|
@@ -5327,8 +5443,8 @@ function readCommonHeader(directory, dataView, offset) {
|
|
|
5327
5443
|
},
|
|
5328
5444
|
rawLastModDate,
|
|
5329
5445
|
lastModDate: getDate(rawLastModDate),
|
|
5330
|
-
filenameLength: getUint16(dataView, offset + 22),
|
|
5331
|
-
extraFieldLength: getUint16(dataView, offset + 24)
|
|
5446
|
+
filenameLength: getUint16$1(dataView, offset + 22),
|
|
5447
|
+
extraFieldLength: getUint16$1(dataView, offset + 24)
|
|
5332
5448
|
});
|
|
5333
5449
|
}
|
|
5334
5450
|
|
|
@@ -5339,8 +5455,8 @@ function readCommonFooter(fileEntry, directory, dataView, offset, localDirectory
|
|
|
5339
5455
|
let offsetExtraField = 0;
|
|
5340
5456
|
try {
|
|
5341
5457
|
while (offsetExtraField < rawExtraField.length) {
|
|
5342
|
-
const type = getUint16(rawExtraFieldView, offsetExtraField);
|
|
5343
|
-
const size = getUint16(rawExtraFieldView, offsetExtraField + 2);
|
|
5458
|
+
const type = getUint16$1(rawExtraFieldView, offsetExtraField);
|
|
5459
|
+
const size = getUint16$1(rawExtraFieldView, offsetExtraField + 2);
|
|
5344
5460
|
extraField.set(type, {
|
|
5345
5461
|
type,
|
|
5346
5462
|
data: rawExtraField.slice(offsetExtraField + 4, offsetExtraField + 4 + size)
|
|
@@ -5350,12 +5466,12 @@ function readCommonFooter(fileEntry, directory, dataView, offset, localDirectory
|
|
|
5350
5466
|
} catch {
|
|
5351
5467
|
// ignored
|
|
5352
5468
|
}
|
|
5353
|
-
const compressionMethod = getUint16(dataView, offset + 4);
|
|
5469
|
+
const compressionMethod = getUint16$1(dataView, offset + 4);
|
|
5354
5470
|
Object.assign(directory, {
|
|
5355
|
-
signature: getUint32(dataView, offset + HEADER_OFFSET_SIGNATURE),
|
|
5356
|
-
crc32: getUint32(dataView, offset + HEADER_OFFSET_SIGNATURE),
|
|
5357
|
-
compressedSize: getUint32(dataView, offset + HEADER_OFFSET_COMPRESSED_SIZE),
|
|
5358
|
-
uncompressedSize: getUint32(dataView, offset + HEADER_OFFSET_UNCOMPRESSED_SIZE)
|
|
5471
|
+
signature: getUint32$1(dataView, offset + HEADER_OFFSET_SIGNATURE),
|
|
5472
|
+
crc32: getUint32$1(dataView, offset + HEADER_OFFSET_SIGNATURE),
|
|
5473
|
+
compressedSize: getUint32$1(dataView, offset + HEADER_OFFSET_COMPRESSED_SIZE),
|
|
5474
|
+
uncompressedSize: getUint32$1(dataView, offset + HEADER_OFFSET_UNCOMPRESSED_SIZE)
|
|
5359
5475
|
});
|
|
5360
5476
|
const extraFieldZip64 = extraField.get(EXTRAFIELD_TYPE_ZIP64);
|
|
5361
5477
|
if (extraFieldZip64) {
|
|
@@ -5444,11 +5560,11 @@ function readExtraFieldUnicode(extraFieldUnicode, propertyName, rawPropertyName,
|
|
|
5444
5560
|
computedCrc32.append(fileEntry[rawPropertyName]);
|
|
5445
5561
|
const computedCrc32View = getDataView(new Uint8Array(4));
|
|
5446
5562
|
computedCrc32View.setUint32(0, computedCrc32.get(), true);
|
|
5447
|
-
const nameCrc32 = getUint32(extraFieldView, 1);
|
|
5563
|
+
const nameCrc32 = getUint32$1(extraFieldView, 1);
|
|
5448
5564
|
Object.assign(extraFieldUnicode, {
|
|
5449
5565
|
version: getUint8(extraFieldView, 0),
|
|
5450
5566
|
[propertyName]: decodeText(extraFieldUnicode.data.subarray(5)),
|
|
5451
|
-
valid: !fileEntry.bitFlag.languageEncodingFlag && nameCrc32 == getUint32(computedCrc32View, 0)
|
|
5567
|
+
valid: !fileEntry.bitFlag.languageEncodingFlag && nameCrc32 == getUint32$1(computedCrc32View, 0)
|
|
5452
5568
|
});
|
|
5453
5569
|
if (extraFieldUnicode.valid) {
|
|
5454
5570
|
directory[propertyName] = extraFieldUnicode[propertyName];
|
|
@@ -5464,7 +5580,7 @@ function readExtraFieldAES(extraFieldAES, directory, compressionMethod) {
|
|
|
5464
5580
|
vendorId: getUint8(extraFieldView, 2),
|
|
5465
5581
|
strength,
|
|
5466
5582
|
originalCompressionMethod: compressionMethod,
|
|
5467
|
-
compressionMethod: getUint16(extraFieldView, 5)
|
|
5583
|
+
compressionMethod: getUint16$1(extraFieldView, 5)
|
|
5468
5584
|
});
|
|
5469
5585
|
directory.compressionMethod = extraFieldAES.compressionMethod;
|
|
5470
5586
|
if (extraFieldAES.vendorVersion != VENDOR_VERSION_AE_1$1) {
|
|
@@ -5478,8 +5594,8 @@ function readExtraFieldNTFS(extraFieldNTFS, directory) {
|
|
|
5478
5594
|
let tag1Data;
|
|
5479
5595
|
try {
|
|
5480
5596
|
while (offsetExtraField < extraFieldNTFS.data.length && !tag1Data) {
|
|
5481
|
-
const tagValue = getUint16(extraFieldView, offsetExtraField);
|
|
5482
|
-
const attributeSize = getUint16(extraFieldView, offsetExtraField + 2);
|
|
5597
|
+
const tagValue = getUint16$1(extraFieldView, offsetExtraField);
|
|
5598
|
+
const attributeSize = getUint16$1(extraFieldView, offsetExtraField + 2);
|
|
5483
5599
|
if (tagValue == EXTRAFIELD_TYPE_NTFS_TAG1) {
|
|
5484
5600
|
tag1Data = extraFieldNTFS.data.slice(offsetExtraField + 4, offsetExtraField + 4 + attributeSize);
|
|
5485
5601
|
}
|
|
@@ -5512,12 +5628,12 @@ function readExtraFieldUnixDates(extraField, directory) {
|
|
|
5512
5628
|
return;
|
|
5513
5629
|
}
|
|
5514
5630
|
const extraFieldView = getDataView(extraField.data);
|
|
5515
|
-
const lastAccessDate = new Date((getUint32(extraFieldView, 0) | 0) * 1000);
|
|
5516
|
-
const lastModDate = new Date((getUint32(extraFieldView, 4) | 0) * 1000);
|
|
5631
|
+
const lastAccessDate = new Date((getUint32$1(extraFieldView, 0) | 0) * 1000);
|
|
5632
|
+
const lastModDate = new Date((getUint32$1(extraFieldView, 4) | 0) * 1000);
|
|
5517
5633
|
const extraFieldData = { lastAccessDate, lastModDate };
|
|
5518
5634
|
if (extraField.data.length >= 12) {
|
|
5519
|
-
extraFieldData.uid = getUint16(extraFieldView, 8);
|
|
5520
|
-
extraFieldData.gid = getUint16(extraFieldView, 10);
|
|
5635
|
+
extraFieldData.uid = getUint16$1(extraFieldView, 8);
|
|
5636
|
+
extraFieldData.gid = getUint16$1(extraFieldView, 10);
|
|
5521
5637
|
}
|
|
5522
5638
|
Object.assign(extraField, extraFieldData);
|
|
5523
5639
|
Object.assign(directory, extraFieldData);
|
|
@@ -5537,8 +5653,8 @@ function readExtraFieldUnix(extraField, directory, isInfoZip) {
|
|
|
5537
5653
|
gid = unpackUnixId(extraField.data.subarray(offset, offset + gidSize));
|
|
5538
5654
|
Object.assign(extraField, { version, uid, gid });
|
|
5539
5655
|
} else if (extraField.data.length >= 4) {
|
|
5540
|
-
uid = getUint16(view, 0);
|
|
5541
|
-
gid = getUint16(view, 2);
|
|
5656
|
+
uid = getUint16$1(view, 0);
|
|
5657
|
+
gid = getUint16$1(view, 2);
|
|
5542
5658
|
Object.assign(extraField, { uid, gid });
|
|
5543
5659
|
}
|
|
5544
5660
|
if (uid !== UNDEFINED_VALUE) {
|
|
@@ -5588,7 +5704,7 @@ function readExtraFieldExtendedTimestamp(extraFieldExtendedTimestamp, directory,
|
|
|
5588
5704
|
let offset = 1;
|
|
5589
5705
|
timeProperties.forEach((propertyName, indexProperty) => {
|
|
5590
5706
|
if (extraFieldExtendedTimestamp.data.length >= offset + 4) {
|
|
5591
|
-
const time = getUint32(extraFieldView, offset);
|
|
5707
|
+
const time = getUint32$1(extraFieldView, offset);
|
|
5592
5708
|
directory[propertyName] = extraFieldExtendedTimestamp[propertyName] = new Date((time | 0) * 1000);
|
|
5593
5709
|
const rawPropertyName = timeRawProperties[indexProperty];
|
|
5594
5710
|
extraFieldExtendedTimestamp[rawPropertyName] = time;
|
|
@@ -5622,7 +5738,7 @@ async function detectOverlappingEntry({
|
|
|
5622
5738
|
const dataDescriptorArray = await readUint8Array(reader, dataOffset + compressedSize, dataDescriptorLength + DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH);
|
|
5623
5739
|
const dataDescriptorView = getDataView(dataDescriptorArray);
|
|
5624
5740
|
let signature = dataDescriptorArray.length == dataDescriptorLength + DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH &&
|
|
5625
|
-
getUint32(dataDescriptorView, 0) == DATA_DESCRIPTOR_RECORD_SIGNATURE;
|
|
5741
|
+
getUint32$1(dataDescriptorView, 0) == DATA_DESCRIPTOR_RECORD_SIGNATURE;
|
|
5626
5742
|
if (signature) {
|
|
5627
5743
|
const signedDataDescriptor = readDataDescriptor(dataDescriptorView, DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH, extraFieldZip64);
|
|
5628
5744
|
const matchCrc32 = (fileEntry.encrypted && !fileEntry.zipCrypto) || signedDataDescriptor.crc32 == crc32;
|
|
@@ -5656,15 +5772,15 @@ async function detectOverlappingEntry({
|
|
|
5656
5772
|
}
|
|
5657
5773
|
|
|
5658
5774
|
function readDataDescriptor(dataDescriptorView, offset, extraFieldZip64) {
|
|
5659
|
-
const crc32 = getUint32(dataDescriptorView, offset);
|
|
5775
|
+
const crc32 = getUint32$1(dataDescriptorView, offset);
|
|
5660
5776
|
let compressedSize;
|
|
5661
5777
|
let uncompressedSize;
|
|
5662
5778
|
if (extraFieldZip64) {
|
|
5663
5779
|
compressedSize = getBigUint64(dataDescriptorView, offset + 4);
|
|
5664
5780
|
uncompressedSize = getBigUint64(dataDescriptorView, offset + 12);
|
|
5665
5781
|
} else {
|
|
5666
|
-
compressedSize = getUint32(dataDescriptorView, offset + 4);
|
|
5667
|
-
uncompressedSize = getUint32(dataDescriptorView, offset + 8);
|
|
5782
|
+
compressedSize = getUint32$1(dataDescriptorView, offset + 4);
|
|
5783
|
+
uncompressedSize = getUint32$1(dataDescriptorView, offset + 8);
|
|
5668
5784
|
}
|
|
5669
5785
|
return { crc32, compressedSize, uncompressedSize };
|
|
5670
5786
|
}
|
|
@@ -5673,10 +5789,28 @@ function getDiskOffset$1(reader, diskNumber) {
|
|
|
5673
5789
|
return reader.getDiskOffset ? reader.getDiskOffset(diskNumber) : 0;
|
|
5674
5790
|
}
|
|
5675
5791
|
|
|
5792
|
+
async function startsWithSplitZipSignature$1(reader) {
|
|
5793
|
+
return await getFirstSignature(reader) == SPLIT_ZIP_FILE_SIGNATURE;
|
|
5794
|
+
}
|
|
5795
|
+
|
|
5796
|
+
async function startsWithSplitZipMarker(reader) {
|
|
5797
|
+
const signature = await getFirstSignature(reader);
|
|
5798
|
+
return signature == SPLIT_ZIP_FILE_SIGNATURE || signature == TEMPORARY_SPLIT_ZIP_FILE_SIGNATURE;
|
|
5799
|
+
}
|
|
5800
|
+
|
|
5801
|
+
async function getFirstSignature(reader) {
|
|
5802
|
+
const signatureArray = await readUint8Array(reader, 0, SPLIT_ZIP_FILE_SIGNATURE_LENGTH);
|
|
5803
|
+
return getUint32$1(getDataView(signatureArray));
|
|
5804
|
+
}
|
|
5805
|
+
|
|
5676
5806
|
function isStrictnessValue(value) {
|
|
5677
5807
|
return value === STRICTNESS_STRICT || value === STRICTNESS_BALANCED || value === STRICTNESS_TOLERANT;
|
|
5678
5808
|
}
|
|
5679
5809
|
|
|
5810
|
+
function getDecodableOutputSize(outputSize, compressedSize, compressed) {
|
|
5811
|
+
return Math.min(outputSize, compressed ? compressedSize * MAX_DEFLATE_EXPANSION_RATIO : compressedSize);
|
|
5812
|
+
}
|
|
5813
|
+
|
|
5680
5814
|
function getStrictness(options, inheritedOptions) {
|
|
5681
5815
|
return resolveStrictness(options, resolveStrictness(inheritedOptions, STRICTNESS_BALANCED));
|
|
5682
5816
|
}
|
|
@@ -5739,7 +5873,7 @@ function isUnsafeFilename(filename, filenameValidation) {
|
|
|
5739
5873
|
|
|
5740
5874
|
function getMaxAppendedDataSize(maxAppendedDataSize, strictness) {
|
|
5741
5875
|
if (maxAppendedDataSize !== UNDEFINED_VALUE) {
|
|
5742
|
-
const size = toNumber
|
|
5876
|
+
const size = toNumber(maxAppendedDataSize);
|
|
5743
5877
|
if (typeof size != NUMBER_TYPE || Number.isNaN(size) || size < 0) {
|
|
5744
5878
|
throw new Error(ERR_INVALID_MAX_APPENDED_DATA_SIZE);
|
|
5745
5879
|
}
|
|
@@ -5762,7 +5896,7 @@ async function findEndOfCentralDirectory(reader, rejectAmbiguous, maxAppendedDat
|
|
|
5762
5896
|
let plausibleEndOfDirectoryInfo;
|
|
5763
5897
|
let endOfDirectoryReachingEndCount = 0;
|
|
5764
5898
|
for await (const [anchoredView, anchoredOffset, anchoredArray, indexByte, offset] of scanEndOfCentralDirectory(reader, anchoredLength)) {
|
|
5765
|
-
const commentLength = getUint16(anchoredView, indexByte + 20);
|
|
5899
|
+
const commentLength = getUint16$1(anchoredView, indexByte + 20);
|
|
5766
5900
|
if (offset + END_OF_CENTRAL_DIR_LENGTH + commentLength == size) {
|
|
5767
5901
|
const reachability = await getCentralDirectoryReachability(reader, anchoredView, anchoredOffset, indexByte, offset, size, remoteProbeBudget);
|
|
5768
5902
|
if (reachability == CENTRAL_DIRECTORY_REACHABLE) {
|
|
@@ -5813,7 +5947,7 @@ async function* scanEndOfCentralDirectory(reader, scanLength) {
|
|
|
5813
5947
|
const scanArray = await readUint8Array(reader, scanOffset, scanLength);
|
|
5814
5948
|
const scanView = getDataView(scanArray);
|
|
5815
5949
|
for (let indexByte = scanArray.length - END_OF_CENTRAL_DIR_LENGTH; indexByte >= 0; indexByte--) {
|
|
5816
|
-
if (getUint32(scanView, indexByte) == END_OF_CENTRAL_DIR_SIGNATURE) {
|
|
5950
|
+
if (getUint32$1(scanView, indexByte) == END_OF_CENTRAL_DIR_SIGNATURE) {
|
|
5817
5951
|
yield [scanView, scanOffset, scanArray, indexByte, scanOffset + indexByte];
|
|
5818
5952
|
}
|
|
5819
5953
|
}
|
|
@@ -5824,9 +5958,9 @@ function getEndOfCentralDirectoryInfo(scanArray, indexByte, offset) {
|
|
|
5824
5958
|
}
|
|
5825
5959
|
|
|
5826
5960
|
async function getCentralDirectoryReachability(reader, view, anchoredOffset, indexByte, offset, size, remoteProbeBudget) {
|
|
5827
|
-
const filesLength = getUint16(view, indexByte + 10);
|
|
5828
|
-
const directoryDataLength = getUint32(view, indexByte + 12);
|
|
5829
|
-
const directoryDataOffset = getUint32(view, indexByte + 16);
|
|
5961
|
+
const filesLength = getUint16$1(view, indexByte + 10);
|
|
5962
|
+
const directoryDataLength = getUint32$1(view, indexByte + 12);
|
|
5963
|
+
const directoryDataOffset = getUint32$1(view, indexByte + 16);
|
|
5830
5964
|
if (filesLength == MAX_16_BITS || directoryDataLength == MAX_32_BITS || directoryDataOffset == MAX_32_BITS) {
|
|
5831
5965
|
const locatorSignature = await readSignature(reader, view, anchoredOffset, offset - ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH, size, remoteProbeBudget);
|
|
5832
5966
|
return locatorSignature == ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE ? CENTRAL_DIRECTORY_REACHABLE : CENTRAL_DIRECTORY_UNREACHABLE;
|
|
@@ -5834,7 +5968,7 @@ async function getCentralDirectoryReachability(reader, view, anchoredOffset, ind
|
|
|
5834
5968
|
if (!filesLength && !directoryDataLength) {
|
|
5835
5969
|
return CENTRAL_DIRECTORY_PLAUSIBLE;
|
|
5836
5970
|
}
|
|
5837
|
-
const directoryDiskNumber = getUint16(view, indexByte + 6);
|
|
5971
|
+
const directoryDiskNumber = getUint16$1(view, indexByte + 6);
|
|
5838
5972
|
for (const centralDirectoryOffset of [offset - directoryDataLength, getDiskOffset$1(reader, directoryDiskNumber) + directoryDataOffset]) {
|
|
5839
5973
|
if (await readSignature(reader, view, anchoredOffset, centralDirectoryOffset, size, remoteProbeBudget) == CENTRAL_FILE_HEADER_SIGNATURE) {
|
|
5840
5974
|
return CENTRAL_DIRECTORY_REACHABLE;
|
|
@@ -5848,19 +5982,21 @@ async function readSignature(reader, view, anchoredOffset, signatureOffset, size
|
|
|
5848
5982
|
return UNDEFINED_VALUE;
|
|
5849
5983
|
}
|
|
5850
5984
|
if (signatureOffset >= anchoredOffset) {
|
|
5851
|
-
return getUint32(view, signatureOffset - anchoredOffset);
|
|
5985
|
+
return getUint32$1(view, signatureOffset - anchoredOffset);
|
|
5852
5986
|
}
|
|
5853
5987
|
if (remoteProbeBudget.count > 0) {
|
|
5854
5988
|
remoteProbeBudget.count--;
|
|
5855
5989
|
const signatureArray = await readUint8Array(reader, signatureOffset, 4);
|
|
5856
|
-
return getUint32(getDataView(signatureArray), 0);
|
|
5990
|
+
return getUint32$1(getDataView(signatureArray), 0);
|
|
5857
5991
|
}
|
|
5858
5992
|
return UNDEFINED_VALUE;
|
|
5859
5993
|
}
|
|
5860
5994
|
|
|
5861
5995
|
function validateLocalDirectory(zipEntry, localDirectory, rawLocalFilename, checkLocalFilename) {
|
|
5862
5996
|
const { rawFilename } = zipEntry;
|
|
5863
|
-
|
|
5997
|
+
const maskedLocalDirectory = zipEntry.decryptedDirectory &&
|
|
5998
|
+
(localDirectory.rawBitFlag & BITFLAG_MASKED_LOCAL_HEADERS) == BITFLAG_MASKED_LOCAL_HEADERS;
|
|
5999
|
+
if (checkLocalFilename && !maskedLocalDirectory &&
|
|
5864
6000
|
(rawLocalFilename.length != rawFilename.length ||
|
|
5865
6001
|
rawLocalFilename.some((byteValue, indexByte) => byteValue != rawFilename[indexByte]))) {
|
|
5866
6002
|
throwAmbiguousArchive("mismatched local file header (filename)");
|
|
@@ -5871,7 +6007,7 @@ function validateLocalDirectory(zipEntry, localDirectory, rawLocalFilename, chec
|
|
|
5871
6007
|
if (localDirectory.compressionMethod != zipEntry.compressionMethod) {
|
|
5872
6008
|
throwAmbiguousArchive("mismatched local file header (compression method)");
|
|
5873
6009
|
}
|
|
5874
|
-
if (!localDirectory.bitFlag.dataDescriptor &&
|
|
6010
|
+
if (!localDirectory.bitFlag.dataDescriptor && !maskedLocalDirectory &&
|
|
5875
6011
|
(localDirectory.crc32 || localDirectory.compressedSize || localDirectory.uncompressedSize) &&
|
|
5876
6012
|
(localDirectory.crc32 != zipEntry.crc32 ||
|
|
5877
6013
|
localDirectory.compressedSize != zipEntry.compressedSize ||
|
|
@@ -5890,10 +6026,11 @@ function getOptionValue$1(zipReader, options, name) {
|
|
|
5890
6026
|
return options[name] === UNDEFINED_VALUE ? zipReader.options[name] : options[name];
|
|
5891
6027
|
}
|
|
5892
6028
|
|
|
5893
|
-
function
|
|
5894
|
-
return
|
|
6029
|
+
function getFunctionOptionValue$1(zipReader, options, name) {
|
|
6030
|
+
return checkFunctionOption(getOptionValue$1(zipReader, options, name));
|
|
5895
6031
|
}
|
|
5896
6032
|
|
|
6033
|
+
|
|
5897
6034
|
function getDate(timeRaw) {
|
|
5898
6035
|
const date = (timeRaw & 0xffff0000) >> 16, time = timeRaw & MAX_16_BITS;
|
|
5899
6036
|
return new Date(1980 + ((date & 0xFE00) >> 9), ((date & 0x01E0) >> 5) - 1, date & 0x001F, (time & 0xF800) >> 11, (time & 0x07E0) >> 5, (time & 0x001F) * 2, 0);
|
|
@@ -5907,11 +6044,11 @@ function getUint8(view, offset) {
|
|
|
5907
6044
|
return view.getUint8(offset);
|
|
5908
6045
|
}
|
|
5909
6046
|
|
|
5910
|
-
function getUint16(view, offset) {
|
|
6047
|
+
function getUint16$1(view, offset) {
|
|
5911
6048
|
return view.getUint16(offset, true);
|
|
5912
6049
|
}
|
|
5913
6050
|
|
|
5914
|
-
function getUint32(view, offset) {
|
|
6051
|
+
function getUint32$1(view, offset) {
|
|
5915
6052
|
return view.getUint32(offset, true);
|
|
5916
6053
|
}
|
|
5917
6054
|
|
|
@@ -5926,6 +6063,7 @@ var zipReader = /*#__PURE__*/Object.freeze({
|
|
|
5926
6063
|
ERR_CENTRAL_DIRECTORY_NOT_FOUND: ERR_CENTRAL_DIRECTORY_NOT_FOUND,
|
|
5927
6064
|
ERR_ENCRYPTED: ERR_ENCRYPTED,
|
|
5928
6065
|
ERR_ENCRYPTED_CENTRAL_DIRECTORY: ERR_ENCRYPTED_CENTRAL_DIRECTORY,
|
|
6066
|
+
ERR_ENTRY_DATA_OUT_OF_BOUNDS: ERR_ENTRY_DATA_OUT_OF_BOUNDS,
|
|
5929
6067
|
ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND: ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND,
|
|
5930
6068
|
ERR_EOCDR_NOT_FOUND: ERR_EOCDR_NOT_FOUND,
|
|
5931
6069
|
ERR_EXTRAFIELD_ZIP64_NOT_FOUND: ERR_EXTRAFIELD_ZIP64_NOT_FOUND,
|
|
@@ -5982,12 +6120,16 @@ const ERR_DUPLICATED_NAME = "File already exists";
|
|
|
5982
6120
|
const ERR_INVALID_COMMENT = "Zip file comment exceeds 64KB";
|
|
5983
6121
|
const ERR_INVALID_COMMENT_TYPE = "Invalid zip file comment (must be a Uint8Array)";
|
|
5984
6122
|
const ERR_INVALID_ENTRY_COMMENT = "File entry comment exceeds 64KB";
|
|
6123
|
+
const ERR_INVALID_ENTRY_COMMENT_TYPE = "Invalid file entry comment (must be a string)";
|
|
6124
|
+
const ERR_INVALID_DATE = "Invalid date (must be a valid Date instance)";
|
|
5985
6125
|
const ERR_INVALID_ENTRY_NAME = "File entry name exceeds 64KB";
|
|
5986
6126
|
const ERR_INVALID_VERSION = "Version exceeds 65535";
|
|
5987
6127
|
const ERR_INVALID_ENCRYPTION_STRENGTH = "The strength must equal 1, 2, or 3";
|
|
5988
6128
|
const ERR_UNSUPPORTED_ENCRYPTION_USDZ = "Encryption is not supported in USDZ files";
|
|
5989
6129
|
const ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH = "Encryption is not supported when the 'passThrough' option is set";
|
|
5990
|
-
const
|
|
6130
|
+
const ERR_INVALID_EXTRAFIELD = "Invalid extra field (must be a Map)";
|
|
6131
|
+
const ERR_INVALID_EXTRAFIELD_TYPE = "Invalid extra field type (must be integer 0..65535)";
|
|
6132
|
+
const ERR_INVALID_EXTRAFIELD_DATA_TYPE = "Invalid extra field data (must be a Uint8Array)";
|
|
5991
6133
|
const ERR_INVALID_EXTRAFIELD_DATA = "Extra field data exceeds 64KB";
|
|
5992
6134
|
const ERR_UNSUPPORTED_COMPRESSION = "Compression method not supported";
|
|
5993
6135
|
const MIN_UNIX_TIME = -2147483648;
|
|
@@ -5996,6 +6138,7 @@ const MIN_NTFS_TIME = BigInt(0);
|
|
|
5996
6138
|
const MAX_NTFS_TIME = BigInt("0x7fffffffffffffff");
|
|
5997
6139
|
const ERR_UNSUPPORTED_FORMAT = "Zip64 is not supported (set the 'zip64' option to 'true')";
|
|
5998
6140
|
const ERR_UNDEFINED_UNCOMPRESSED_SIZE = "Undefined uncompressed size";
|
|
6141
|
+
const ERR_UNDEFINED_COMPRESSION_METHOD = "Undefined compression method";
|
|
5999
6142
|
const ERR_UNDETERMINED_SIZE = "Undetermined size";
|
|
6000
6143
|
const ERR_UNDEFINED_READER = "Undefined reader";
|
|
6001
6144
|
const ERR_ZIP_NOT_EMPTY = "Zip file not empty";
|
|
@@ -6007,7 +6150,6 @@ const ERR_INVALID_UNIX_ID_SIZE = "uid/gid must be 0..65535 for unixExtraFieldTyp
|
|
|
6007
6150
|
const ERR_INVALID_MSDOS_ATTRIBUTES = "Invalid msdosAttributesRaw (must be integer 0..255)";
|
|
6008
6151
|
const ERR_INVALID_MSDOS_DATA = "Invalid msdosAttributes (must be an object with boolean flags)";
|
|
6009
6152
|
const ERR_INVALID_LEVEL = "Invalid level (must be integer 0..9)";
|
|
6010
|
-
const ERR_INVALID_PASSWORD_TYPE = "Invalid password (password must be a string, rawPassword must be a Uint8Array)";
|
|
6011
6153
|
const ERR_INVALID_SIGNATURE_DATA = "Signature data exceeds 64KB";
|
|
6012
6154
|
|
|
6013
6155
|
const EXTRAFIELD_DATA_AES = new Uint8Array([0x07, 0x00, 0x02, 0x00, 0x41, 0x45, 0x03, 0x00, 0x00]);
|
|
@@ -6032,8 +6174,7 @@ class ZipWriter {
|
|
|
6032
6174
|
writer,
|
|
6033
6175
|
addSplitZipSignature,
|
|
6034
6176
|
options,
|
|
6035
|
-
|
|
6036
|
-
files: new Map(),
|
|
6177
|
+
fileEntries: new Map(),
|
|
6037
6178
|
filenames: new Set(),
|
|
6038
6179
|
offset: options[OPTION_OFFSET] === UNDEFINED_VALUE ? writer.size || writer.writable.size || 0 : options[OPTION_OFFSET],
|
|
6039
6180
|
initialOffset: options[OPTION_OFFSET] === UNDEFINED_VALUE ? 0 : options[OPTION_OFFSET] - (writer.size || writer.writable.size || 0),
|
|
@@ -6054,14 +6195,23 @@ class ZipWriter {
|
|
|
6054
6195
|
await initStream(reader);
|
|
6055
6196
|
}
|
|
6056
6197
|
const { ZipReader } = await Promise.resolve().then(function () { return zipReader; });
|
|
6057
|
-
const zipReader$1 = new ZipReader(reader
|
|
6198
|
+
const zipReader$1 = new ZipReader(reader);
|
|
6058
6199
|
const entries = await zipReader$1.getEntries();
|
|
6059
6200
|
await zipReader$1.close();
|
|
6060
6201
|
await initStream(this.writer);
|
|
6061
|
-
|
|
6062
|
-
|
|
6202
|
+
const { directoryOffset } = zipReader$1;
|
|
6203
|
+
let splitZipSignatureLength = 0;
|
|
6204
|
+
if (this.addSplitZipSignature) {
|
|
6205
|
+
delete this.addSplitZipSignature;
|
|
6206
|
+
if (!await startsWithSplitZipSignature(reader)) {
|
|
6207
|
+
await writeData(this.writer, getSplitZipSignatureArray());
|
|
6208
|
+
splitZipSignatureLength = SPLIT_ZIP_FILE_SIGNATURE_LENGTH;
|
|
6209
|
+
this.offset += splitZipSignatureLength;
|
|
6210
|
+
}
|
|
6211
|
+
}
|
|
6212
|
+
const entryPositions = await copyZipData(this, reader, entries, directoryOffset, splitZipSignatureLength);
|
|
6063
6213
|
this.filenames = new Set(entries.map(entry => entry.filename));
|
|
6064
|
-
this.
|
|
6214
|
+
this.fileEntries = new Map(entries.map(entry => {
|
|
6065
6215
|
const {
|
|
6066
6216
|
version,
|
|
6067
6217
|
rawLastModDate,
|
|
@@ -6116,11 +6266,12 @@ class ZipWriter {
|
|
|
6116
6266
|
if (crc32 !== UNDEFINED_VALUE) {
|
|
6117
6267
|
setUint32(headerView, HEADER_OFFSET_SIGNATURE, crc32);
|
|
6118
6268
|
}
|
|
6269
|
+
const { offset, diskNumberStart } = entryPositions.get(entry);
|
|
6119
6270
|
Object.assign(entry, {
|
|
6120
6271
|
zip64UncompressedSize,
|
|
6121
6272
|
zip64CompressedSize,
|
|
6122
|
-
|
|
6123
|
-
diskNumberStart
|
|
6273
|
+
offset,
|
|
6274
|
+
diskNumberStart,
|
|
6124
6275
|
zip64DiskNumberStart: false,
|
|
6125
6276
|
rawExtraFieldZip64,
|
|
6126
6277
|
rawExtraFieldAES,
|
|
@@ -6140,11 +6291,8 @@ class ZipWriter {
|
|
|
6140
6291
|
async add(name = "", reader, options = {}) {
|
|
6141
6292
|
const zipWriter = this;
|
|
6142
6293
|
options = Object.assign({}, options);
|
|
6143
|
-
const {
|
|
6144
|
-
|
|
6145
|
-
config
|
|
6146
|
-
} = zipWriter;
|
|
6147
|
-
if (workers < config.maxWorkers) {
|
|
6294
|
+
const { pendingAddFileCalls } = zipWriter;
|
|
6295
|
+
if (workers < getConfiguration().maxWorkers) {
|
|
6148
6296
|
workers++;
|
|
6149
6297
|
} else {
|
|
6150
6298
|
await new Promise(resolve => pendingEntries.push(resolve));
|
|
@@ -6181,16 +6329,16 @@ class ZipWriter {
|
|
|
6181
6329
|
}
|
|
6182
6330
|
|
|
6183
6331
|
remove(entry) {
|
|
6184
|
-
const { filenames,
|
|
6332
|
+
const { filenames, fileEntries } = this;
|
|
6185
6333
|
// deno-lint-ignore valid-typeof
|
|
6186
6334
|
if (typeof entry == STRING_TYPE) {
|
|
6187
|
-
entry =
|
|
6335
|
+
entry = fileEntries.get(entry);
|
|
6188
6336
|
}
|
|
6189
6337
|
if (entry && entry.filename !== UNDEFINED_VALUE) {
|
|
6190
6338
|
const { filename } = entry;
|
|
6191
|
-
if (filenames.has(filename) &&
|
|
6339
|
+
if (filenames.has(filename) && fileEntries.has(filename)) {
|
|
6192
6340
|
filenames.delete(filename);
|
|
6193
|
-
|
|
6341
|
+
fileEntries.delete(filename);
|
|
6194
6342
|
return true;
|
|
6195
6343
|
}
|
|
6196
6344
|
}
|
|
@@ -6287,12 +6435,12 @@ async function addFile(zipWriter, name, reader, options) {
|
|
|
6287
6435
|
const metadataInfo = resolveMetadata(zipWriter, name, options);
|
|
6288
6436
|
const { comment } = metadataInfo;
|
|
6289
6437
|
const extraField = options[PROPERTY_NAME_EXTRA_FIELD];
|
|
6290
|
-
zipWriter.
|
|
6438
|
+
zipWriter.fileEntries.set(name, UNDEFINED_VALUE);
|
|
6291
6439
|
let fileEntry;
|
|
6292
6440
|
try {
|
|
6293
6441
|
const { resolvedOptions } = metadataInfo;
|
|
6294
6442
|
if (resolvedOptions.level != 0 && resolvedOptions.compressionMethod === UNDEFINED_VALUE &&
|
|
6295
|
-
!resolvedOptions.passThrough && !(await supportsDeflate(
|
|
6443
|
+
!resolvedOptions.passThrough && !(await supportsDeflate(getConfiguration()))) {
|
|
6296
6444
|
resolvedOptions.level = 0;
|
|
6297
6445
|
}
|
|
6298
6446
|
const sizesInfo = await resolveSizes(zipWriter, reader, metadataInfo, options);
|
|
@@ -6310,7 +6458,7 @@ async function addFile(zipWriter, name, reader, options) {
|
|
|
6310
6458
|
const metadataSize = getLength(headerInfo.localHeaderArray, dataDescriptorInfo.dataDescriptorArray);
|
|
6311
6459
|
fileEntry = await getFileEntry(zipWriter, name, reader, { headerInfo, dataDescriptorInfo, metadataSize }, options);
|
|
6312
6460
|
} catch (error) {
|
|
6313
|
-
zipWriter.
|
|
6461
|
+
zipWriter.fileEntries.delete(name);
|
|
6314
6462
|
throw error;
|
|
6315
6463
|
}
|
|
6316
6464
|
Object.assign(fileEntry, {
|
|
@@ -6354,9 +6502,9 @@ function resolveAttributes(zipWriter, name, options) {
|
|
|
6354
6502
|
if (unixExtraFieldType === UNDEFINED_VALUE && (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE)) {
|
|
6355
6503
|
unixExtraFieldType = INFOZIP_EXTRA_FIELD_TYPE;
|
|
6356
6504
|
}
|
|
6357
|
-
let msdosAttributesRaw =
|
|
6505
|
+
let msdosAttributesRaw = getNumberOptionValue(zipWriter, options, PROPERTY_NAME_MSDOS_ATTRIBUTES_RAW);
|
|
6358
6506
|
let msdosAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_MSDOS_ATTRIBUTES);
|
|
6359
|
-
const hasUnixMetadata = uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE || unixMode !== UNDEFINED_VALUE || unixExtraFieldType;
|
|
6507
|
+
const hasUnixMetadata = uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE || unixMode !== UNDEFINED_VALUE || unixExtraFieldType || executable;
|
|
6360
6508
|
const hasMsDosProvided = msdosAttributesRaw !== UNDEFINED_VALUE || msdosAttributes !== UNDEFINED_VALUE;
|
|
6361
6509
|
if (hasUnixMetadata) {
|
|
6362
6510
|
msDosCompatible = false;
|
|
@@ -6365,10 +6513,10 @@ function resolveAttributes(zipWriter, name, options) {
|
|
|
6365
6513
|
msDosCompatible = true;
|
|
6366
6514
|
versionMadeBy = (versionMadeBy & MAX_8_BITS);
|
|
6367
6515
|
}
|
|
6368
|
-
if (msdosAttributesRaw !== UNDEFINED_VALUE && (msdosAttributesRaw < 0 || msdosAttributesRaw > MAX_8_BITS)) {
|
|
6516
|
+
if (msdosAttributesRaw !== UNDEFINED_VALUE && (!Number.isInteger(msdosAttributesRaw) || msdosAttributesRaw < 0 || msdosAttributesRaw > MAX_8_BITS)) {
|
|
6369
6517
|
throw new Error(ERR_INVALID_MSDOS_ATTRIBUTES);
|
|
6370
6518
|
}
|
|
6371
|
-
if (msdosAttributes && typeof msdosAttributes !== OBJECT_TYPE) {
|
|
6519
|
+
if (msdosAttributes && (typeof msdosAttributes !== OBJECT_TYPE || Array.isArray(msdosAttributes))) {
|
|
6372
6520
|
throw new Error(ERR_INVALID_MSDOS_DATA);
|
|
6373
6521
|
}
|
|
6374
6522
|
if (versionMadeBy > MAX_16_BITS) {
|
|
@@ -6456,7 +6604,7 @@ function resolveAttributes(zipWriter, name, options) {
|
|
|
6456
6604
|
}
|
|
6457
6605
|
|
|
6458
6606
|
function resolveMetadata(zipWriter, name, options) {
|
|
6459
|
-
const encode =
|
|
6607
|
+
const encode = getFunctionOptionValue(zipWriter, options, OPTION_ENCODE_TEXT) || encodeText;
|
|
6460
6608
|
let rawFilename = encode(name, TEXT_TYPE_FILENAME);
|
|
6461
6609
|
if (rawFilename === UNDEFINED_VALUE) {
|
|
6462
6610
|
rawFilename = encodeText(name);
|
|
@@ -6465,6 +6613,10 @@ function resolveMetadata(zipWriter, name, options) {
|
|
|
6465
6613
|
throw new Error(ERR_INVALID_ENTRY_NAME);
|
|
6466
6614
|
}
|
|
6467
6615
|
const comment = options[PROPERTY_NAME_COMMENT] || "";
|
|
6616
|
+
// deno-lint-ignore valid-typeof
|
|
6617
|
+
if (typeof comment != STRING_TYPE) {
|
|
6618
|
+
throw new Error(ERR_INVALID_ENTRY_COMMENT_TYPE);
|
|
6619
|
+
}
|
|
6468
6620
|
let rawComment = encode(comment, TEXT_TYPE_COMMENT);
|
|
6469
6621
|
if (rawComment === UNDEFINED_VALUE) {
|
|
6470
6622
|
rawComment = encodeText(comment);
|
|
@@ -6476,16 +6628,14 @@ function resolveMetadata(zipWriter, name, options) {
|
|
|
6476
6628
|
if (version > MAX_16_BITS) {
|
|
6477
6629
|
throw new Error(ERR_INVALID_VERSION);
|
|
6478
6630
|
}
|
|
6479
|
-
const lastModDate =
|
|
6480
|
-
const lastAccessDate =
|
|
6481
|
-
const creationDate =
|
|
6631
|
+
const lastModDate = getDateOptionValue(zipWriter, options, PROPERTY_NAME_LAST_MODIFICATION_DATE, new Date());
|
|
6632
|
+
const lastAccessDate = getDateOptionValue(zipWriter, options, PROPERTY_NAME_LAST_ACCESS_DATE);
|
|
6633
|
+
const creationDate = getDateOptionValue(zipWriter, options, PROPERTY_NAME_CREATION_DATE);
|
|
6482
6634
|
const internalFileAttributes = getAliasedOptionValue(zipWriter, options, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES, PROPERTY_NAME_DEPRECATED_INTERNAL_FILE_ATTRIBUTES, 0);
|
|
6483
6635
|
const passThrough = getOptionValue(zipWriter, options, OPTION_PASS_THROUGH);
|
|
6484
6636
|
const password = getOptionValue(zipWriter, options, OPTION_PASSWORD);
|
|
6485
6637
|
const rawPassword = getOptionValue(zipWriter, options, OPTION_RAW_PASSWORD);
|
|
6486
|
-
|
|
6487
|
-
throw new Error(ERR_INVALID_PASSWORD_TYPE);
|
|
6488
|
-
}
|
|
6638
|
+
checkPasswordOption(password, rawPassword);
|
|
6489
6639
|
const encryptionStrength = getNumberOptionValue(zipWriter, options, OPTION_ENCRYPTION_STRENGTH, 3);
|
|
6490
6640
|
const zipCrypto = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIPCRYPTO);
|
|
6491
6641
|
const extendedTimestamp = getOptionValue(zipWriter, options, OPTION_EXTENDED_TIMESTAMP, true);
|
|
@@ -6494,9 +6644,9 @@ function resolveMetadata(zipWriter, name, options) {
|
|
|
6494
6644
|
const useWebWorkers = getOptionValue(zipWriter, options, OPTION_USE_WEB_WORKERS);
|
|
6495
6645
|
const transferStreams = getOptionValue(zipWriter, options, OPTION_TRANSFER_STREAMS);
|
|
6496
6646
|
const bufferedWrite = getOptionValue(zipWriter, options, OPTION_BUFFERED_WRITE);
|
|
6497
|
-
const createTempStream =
|
|
6647
|
+
const createTempStream = getFunctionOptionValue(zipWriter, options, OPTION_CREATE_TEMP_STREAM);
|
|
6498
6648
|
const dataDescriptorSignature = getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR_SIGNATURE, true);
|
|
6499
|
-
const signal = getOptionValue(zipWriter, options, OPTION_SIGNAL);
|
|
6649
|
+
const signal = checkSignalOption(getOptionValue(zipWriter, options, OPTION_SIGNAL));
|
|
6500
6650
|
const useUnicodeFileNames = getOptionValue(zipWriter, options, OPTION_USE_UNICODE_FILE_NAMES, true);
|
|
6501
6651
|
const compressionMethod = getOptionValue(zipWriter, options, PROPERTY_NAME_COMPRESSION_METHOD);
|
|
6502
6652
|
const registeredCodec = passThrough || compressionMethod === UNDEFINED_VALUE ? UNDEFINED_VALUE : getRegisteredCodec(compressionMethod);
|
|
@@ -6516,6 +6666,9 @@ function resolveMetadata(zipWriter, name, options) {
|
|
|
6516
6666
|
level = 0;
|
|
6517
6667
|
}
|
|
6518
6668
|
}
|
|
6669
|
+
if (passThrough) {
|
|
6670
|
+
level = UNDEFINED_VALUE;
|
|
6671
|
+
}
|
|
6519
6672
|
let useCompressionStream = getOptionValue(zipWriter, options, OPTION_USE_COMPRESSION_STREAM);
|
|
6520
6673
|
let dataDescriptor = getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR);
|
|
6521
6674
|
if (bufferedWrite && dataDescriptor === UNDEFINED_VALUE) {
|
|
@@ -6576,18 +6729,26 @@ function serializeExtraField(extraField) {
|
|
|
6576
6729
|
if (!extraField) {
|
|
6577
6730
|
return EMPTY_UINT8_ARRAY;
|
|
6578
6731
|
}
|
|
6732
|
+
if (!(extraField instanceof Map)) {
|
|
6733
|
+
throw new Error(ERR_INVALID_EXTRAFIELD);
|
|
6734
|
+
}
|
|
6579
6735
|
let extraFieldSize = 0;
|
|
6580
6736
|
let offset = 0;
|
|
6581
|
-
extraField.forEach(data => extraFieldSize += 4 + getLength(data));
|
|
6582
|
-
const rawExtraField = new Uint8Array(extraFieldSize);
|
|
6583
|
-
const rawExtraFieldView = getDataView(rawExtraField);
|
|
6584
6737
|
extraField.forEach((data, type) => {
|
|
6585
|
-
if (type > MAX_16_BITS) {
|
|
6738
|
+
if (!Number.isInteger(type) || type < 0 || type > MAX_16_BITS) {
|
|
6586
6739
|
throw new Error(ERR_INVALID_EXTRAFIELD_TYPE);
|
|
6587
6740
|
}
|
|
6741
|
+
if (!(data instanceof Uint8Array)) {
|
|
6742
|
+
throw new Error(ERR_INVALID_EXTRAFIELD_DATA_TYPE);
|
|
6743
|
+
}
|
|
6588
6744
|
if (getLength(data) > MAX_16_BITS) {
|
|
6589
6745
|
throw new Error(ERR_INVALID_EXTRAFIELD_DATA);
|
|
6590
6746
|
}
|
|
6747
|
+
extraFieldSize += 4 + getLength(data);
|
|
6748
|
+
});
|
|
6749
|
+
const rawExtraField = new Uint8Array(extraFieldSize);
|
|
6750
|
+
const rawExtraFieldView = getDataView(rawExtraField);
|
|
6751
|
+
extraField.forEach((data, type) => {
|
|
6591
6752
|
setUint16(rawExtraFieldView, offset, type);
|
|
6592
6753
|
setUint16(rawExtraFieldView, offset + 2, getLength(data));
|
|
6593
6754
|
arraySet(rawExtraField, data, offset + 4);
|
|
@@ -6619,6 +6780,9 @@ function resolveEntrySizes(zipWriter, hasContent, contentSize, metadata, options
|
|
|
6619
6780
|
if (uncompressedSize === UNDEFINED_VALUE) {
|
|
6620
6781
|
throw new Error(ERR_UNDEFINED_UNCOMPRESSED_SIZE);
|
|
6621
6782
|
}
|
|
6783
|
+
if (compressionMethod === UNDEFINED_VALUE) {
|
|
6784
|
+
throw new Error(ERR_UNDEFINED_COMPRESSION_METHOD);
|
|
6785
|
+
}
|
|
6622
6786
|
}
|
|
6623
6787
|
const zip64Enabled = zip64 === true;
|
|
6624
6788
|
const encrypted = getOptionValue(zipWriter, options, PROPERTY_NAME_ENCRYPTED);
|
|
@@ -6675,7 +6839,7 @@ function resolveEntrySizes(zipWriter, hasContent, contentSize, metadata, options
|
|
|
6675
6839
|
|
|
6676
6840
|
async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
|
|
6677
6841
|
const {
|
|
6678
|
-
|
|
6842
|
+
fileEntries,
|
|
6679
6843
|
writer
|
|
6680
6844
|
} = zipWriter;
|
|
6681
6845
|
const {
|
|
@@ -6697,12 +6861,12 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
|
|
|
6697
6861
|
let writerSizeBeforeEntry;
|
|
6698
6862
|
let flushedBufferedSize = 0;
|
|
6699
6863
|
let fileWriter;
|
|
6700
|
-
|
|
6864
|
+
fileEntries.set(name, fileEntry);
|
|
6701
6865
|
zipWriter.lastFileEntry = fileEntry;
|
|
6702
6866
|
try {
|
|
6703
6867
|
let lockPreviousFileEntry;
|
|
6704
6868
|
if (keepOrder) {
|
|
6705
|
-
lockPreviousFileEntry = previousFileEntry && previousFileEntry.
|
|
6869
|
+
lockPreviousFileEntry = previousFileEntry && previousFileEntry.lockFileEntry;
|
|
6706
6870
|
requestLockCurrentFileEntry();
|
|
6707
6871
|
}
|
|
6708
6872
|
if (options.bufferedWrite || !keepOrder || zipWriter.writerLocked || zipWriter.bufferedWrites || !dataDescriptor) {
|
|
@@ -6723,11 +6887,8 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
|
|
|
6723
6887
|
const diskOffset = getDiskOffset(writer);
|
|
6724
6888
|
if (zipWriter.addSplitZipSignature) {
|
|
6725
6889
|
delete zipWriter.addSplitZipSignature;
|
|
6726
|
-
|
|
6727
|
-
|
|
6728
|
-
setUint32(signatureArrayView, 0, SPLIT_ZIP_FILE_SIGNATURE);
|
|
6729
|
-
await writeData(writer, signatureArray);
|
|
6730
|
-
zipWriter.offset += 4;
|
|
6890
|
+
await writeData(writer, getSplitZipSignatureArray());
|
|
6891
|
+
zipWriter.offset += SPLIT_ZIP_FILE_SIGNATURE_LENGTH;
|
|
6731
6892
|
}
|
|
6732
6893
|
if (usdz && !bufferedWrite) {
|
|
6733
6894
|
appendExtraFieldUSDZ(entryInfo, zipWriter.offset - diskOffset);
|
|
@@ -6745,11 +6906,11 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
|
|
|
6745
6906
|
writerSizeBeforeEntry = writer.size;
|
|
6746
6907
|
await writeData(fileWriter, localHeaderArray);
|
|
6747
6908
|
}
|
|
6748
|
-
fileEntry = await createFileEntry(reader, fileWriter, fileEntry, entryInfo,
|
|
6909
|
+
fileEntry = await createFileEntry(reader, fileWriter, fileEntry, entryInfo, getConfiguration(), options);
|
|
6749
6910
|
if (!bufferedWrite) {
|
|
6750
6911
|
writingEntryData = false;
|
|
6751
6912
|
}
|
|
6752
|
-
|
|
6913
|
+
fileEntries.set(name, fileEntry);
|
|
6753
6914
|
fileEntry.filename = name;
|
|
6754
6915
|
if (bufferedWrite) {
|
|
6755
6916
|
await Promise.all([fileWriter.writable.getWriter().close(), lockPreviousFileEntry]);
|
|
@@ -6790,7 +6951,7 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
|
|
|
6790
6951
|
zipWriter.offset += flushedBufferedSize;
|
|
6791
6952
|
}
|
|
6792
6953
|
}
|
|
6793
|
-
|
|
6954
|
+
fileEntries.delete(name);
|
|
6794
6955
|
throw error;
|
|
6795
6956
|
} finally {
|
|
6796
6957
|
if (bufferedWrite) {
|
|
@@ -6812,7 +6973,7 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
|
|
|
6812
6973
|
}
|
|
6813
6974
|
|
|
6814
6975
|
function requestLockCurrentFileEntry() {
|
|
6815
|
-
fileEntry.
|
|
6976
|
+
fileEntry.lockFileEntry = new Promise(resolve => releaseLockCurrentFileEntry = resolve);
|
|
6816
6977
|
}
|
|
6817
6978
|
|
|
6818
6979
|
async function requestLockWriter() {
|
|
@@ -6832,7 +6993,7 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
|
|
|
6832
6993
|
}
|
|
6833
6994
|
}
|
|
6834
6995
|
|
|
6835
|
-
async function createFileEntry(reader, writer, { diskNumberStart,
|
|
6996
|
+
async function createFileEntry(reader, writer, { diskNumberStart, lockFileEntry }, entryInfo, config, options) {
|
|
6836
6997
|
const {
|
|
6837
6998
|
headerInfo,
|
|
6838
6999
|
dataDescriptorInfo,
|
|
@@ -6900,7 +7061,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
|
|
|
6900
7061
|
codecURI
|
|
6901
7062
|
} = options;
|
|
6902
7063
|
const fileEntry = {
|
|
6903
|
-
|
|
7064
|
+
lockFileEntry,
|
|
6904
7065
|
versionMadeBy,
|
|
6905
7066
|
zip64,
|
|
6906
7067
|
directory: Boolean(directory),
|
|
@@ -6942,7 +7103,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
|
|
|
6942
7103
|
}
|
|
6943
7104
|
const { writable } = writer;
|
|
6944
7105
|
if (reader) {
|
|
6945
|
-
const readable = toCompatibleReadable(
|
|
7106
|
+
const readable = toCompatibleReadable(createReadable(reader));
|
|
6946
7107
|
const size = reader.size;
|
|
6947
7108
|
const workerOptions = {
|
|
6948
7109
|
options: {
|
|
@@ -7054,14 +7215,14 @@ function getHeaderInfo(options) {
|
|
|
7054
7215
|
if (zip64 && (zip64UncompressedSize || zip64CompressedSize)) {
|
|
7055
7216
|
const length = 4 + 16;
|
|
7056
7217
|
const extraFieldZip64 = createRecordWriter(length);
|
|
7057
|
-
extraFieldZip64.
|
|
7058
|
-
extraFieldZip64.
|
|
7218
|
+
extraFieldZip64.writeUint16(EXTRAFIELD_TYPE_ZIP64);
|
|
7219
|
+
extraFieldZip64.writeUint16(length - 4);
|
|
7059
7220
|
rawLocalExtraFieldZip64 = extraFieldZip64.array;
|
|
7060
7221
|
if (zip64ExtraFieldComplete) {
|
|
7061
|
-
extraFieldZip64.
|
|
7222
|
+
extraFieldZip64.writeUint64(uncompressedSize);
|
|
7062
7223
|
if (uncompressedFile) {
|
|
7063
7224
|
const encryptionOverhead = encrypted ? (zipCrypto ? 12 : 16 + encryptionStrength * 4) : 0;
|
|
7064
|
-
extraFieldZip64.
|
|
7225
|
+
extraFieldZip64.writeUint64(passThrough ? 0 : uncompressedSize + encryptionOverhead);
|
|
7065
7226
|
}
|
|
7066
7227
|
}
|
|
7067
7228
|
} else {
|
|
@@ -7070,8 +7231,8 @@ function getHeaderInfo(options) {
|
|
|
7070
7231
|
let rawExtraFieldAES;
|
|
7071
7232
|
if (encrypted && !zipCrypto) {
|
|
7072
7233
|
const extraFieldAES = createRecordWriter(getLength(EXTRAFIELD_DATA_AES) + 2);
|
|
7073
|
-
extraFieldAES.
|
|
7074
|
-
extraFieldAES.
|
|
7234
|
+
extraFieldAES.writeUint16(EXTRAFIELD_TYPE_AES);
|
|
7235
|
+
extraFieldAES.writeBytes(EXTRAFIELD_DATA_AES);
|
|
7075
7236
|
rawExtraFieldAES = extraFieldAES.array;
|
|
7076
7237
|
rawExtraFieldAES[8] = encryptionStrength;
|
|
7077
7238
|
} else {
|
|
@@ -7087,15 +7248,15 @@ function getHeaderInfo(options) {
|
|
|
7087
7248
|
const extraFieldTimestampLength = 9 + (lastAccessDate ? 4 : 0) + (creationDate ? 4 : 0);
|
|
7088
7249
|
const extraFieldTimestamp = createRecordWriter(extraFieldTimestampLength);
|
|
7089
7250
|
extraFieldExtendedTimestampFlag = 0x1 + (lastAccessDate ? 0x2 : 0) + (creationDate ? 0x4 : 0);
|
|
7090
|
-
extraFieldTimestamp.
|
|
7091
|
-
extraFieldTimestamp.
|
|
7092
|
-
extraFieldTimestamp.
|
|
7093
|
-
extraFieldTimestamp.
|
|
7251
|
+
extraFieldTimestamp.writeUint16(EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
|
|
7252
|
+
extraFieldTimestamp.writeUint16(extraFieldTimestampLength - 4);
|
|
7253
|
+
extraFieldTimestamp.writeUint8(extraFieldExtendedTimestampFlag);
|
|
7254
|
+
extraFieldTimestamp.writeUint32(lastModTimeUnix);
|
|
7094
7255
|
if (lastAccessDate) {
|
|
7095
|
-
extraFieldTimestamp.
|
|
7256
|
+
extraFieldTimestamp.writeUint32(clampUnixTime(getTimeUnix(lastAccessDate)));
|
|
7096
7257
|
}
|
|
7097
7258
|
if (creationDate) {
|
|
7098
|
-
extraFieldTimestamp.
|
|
7259
|
+
extraFieldTimestamp.writeUint32(clampUnixTime(getTimeUnix(creationDate)));
|
|
7099
7260
|
}
|
|
7100
7261
|
rawExtraFieldExtendedTimestamp = extraFieldTimestamp.array;
|
|
7101
7262
|
} else {
|
|
@@ -7108,14 +7269,14 @@ function getHeaderInfo(options) {
|
|
|
7108
7269
|
try {
|
|
7109
7270
|
const lastModTimeNTFS = getTimeNTFS(lastModDate);
|
|
7110
7271
|
const extraFieldNTFS = createRecordWriter(36);
|
|
7111
|
-
extraFieldNTFS.
|
|
7112
|
-
extraFieldNTFS.
|
|
7272
|
+
extraFieldNTFS.writeUint16(EXTRAFIELD_TYPE_NTFS);
|
|
7273
|
+
extraFieldNTFS.writeUint16(32);
|
|
7113
7274
|
extraFieldNTFS.skip(4);
|
|
7114
|
-
extraFieldNTFS.
|
|
7115
|
-
extraFieldNTFS.
|
|
7116
|
-
extraFieldNTFS.
|
|
7117
|
-
extraFieldNTFS.
|
|
7118
|
-
extraFieldNTFS.
|
|
7275
|
+
extraFieldNTFS.writeUint16(EXTRAFIELD_TYPE_NTFS_TAG1);
|
|
7276
|
+
extraFieldNTFS.writeUint16(24);
|
|
7277
|
+
extraFieldNTFS.writeUint64(lastModTimeNTFS);
|
|
7278
|
+
extraFieldNTFS.writeUint64(lastAccessDate ? getTimeNTFS(lastAccessDate) : lastModTimeNTFS);
|
|
7279
|
+
extraFieldNTFS.writeUint64(creationDate ? getTimeNTFS(creationDate) : lastModTimeNTFS);
|
|
7119
7280
|
rawExtraFieldNTFS = extraFieldNTFS.array;
|
|
7120
7281
|
} catch {
|
|
7121
7282
|
rawExtraFieldNTFS = EMPTY_UINT8_ARRAY;
|
|
@@ -7134,20 +7295,20 @@ function getHeaderInfo(options) {
|
|
|
7134
7295
|
const gidBytes = packUnixId(gid);
|
|
7135
7296
|
const payloadLength = 3 + uidBytes.length + gidBytes.length;
|
|
7136
7297
|
const extraFieldUnix = createRecordWriter(4 + payloadLength);
|
|
7137
|
-
extraFieldUnix.
|
|
7138
|
-
extraFieldUnix.
|
|
7139
|
-
extraFieldUnix.
|
|
7140
|
-
extraFieldUnix.
|
|
7141
|
-
extraFieldUnix.
|
|
7142
|
-
extraFieldUnix.
|
|
7143
|
-
extraFieldUnix.
|
|
7298
|
+
extraFieldUnix.writeUint16(EXTRAFIELD_TYPE_INFOZIP);
|
|
7299
|
+
extraFieldUnix.writeUint16(payloadLength);
|
|
7300
|
+
extraFieldUnix.writeUint8(1);
|
|
7301
|
+
extraFieldUnix.writeUint8(uidBytes.length);
|
|
7302
|
+
extraFieldUnix.writeBytes(uidBytes);
|
|
7303
|
+
extraFieldUnix.writeUint8(gidBytes.length);
|
|
7304
|
+
extraFieldUnix.writeBytes(gidBytes);
|
|
7144
7305
|
rawExtraFieldUnix = extraFieldUnix.array;
|
|
7145
7306
|
} else if (unixExtraFieldType == UNIX_EXTRA_FIELD_TYPE && (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE)) {
|
|
7146
7307
|
const extraFieldUnix = createRecordWriter(8);
|
|
7147
|
-
extraFieldUnix.
|
|
7148
|
-
extraFieldUnix.
|
|
7149
|
-
extraFieldUnix.
|
|
7150
|
-
extraFieldUnix.
|
|
7308
|
+
extraFieldUnix.writeUint16(EXTRAFIELD_TYPE_UNIX);
|
|
7309
|
+
extraFieldUnix.writeUint16(4);
|
|
7310
|
+
extraFieldUnix.writeUint16((uid === UNDEFINED_VALUE ? 0 : uid) & MAX_16_BITS);
|
|
7311
|
+
extraFieldUnix.writeUint16((gid === UNDEFINED_VALUE ? 0 : gid) & MAX_16_BITS);
|
|
7151
7312
|
rawExtraFieldUnix = extraFieldUnix.array;
|
|
7152
7313
|
} else {
|
|
7153
7314
|
rawExtraFieldUnix = EMPTY_UINT8_ARRAY;
|
|
@@ -7197,18 +7358,18 @@ function getHeaderInfo(options) {
|
|
|
7197
7358
|
const localHeader = createRecordWriter(HEADER_SIZE + getLength(rawFilename) + extraFieldLength);
|
|
7198
7359
|
const localHeaderArray = localHeader.array;
|
|
7199
7360
|
const localHeaderView = getDataView(localHeaderArray);
|
|
7200
|
-
localHeader.
|
|
7201
|
-
localHeader.
|
|
7202
|
-
localHeader.
|
|
7361
|
+
localHeader.writeUint32(LOCAL_FILE_HEADER_SIGNATURE);
|
|
7362
|
+
localHeader.writeBytes(headerArray);
|
|
7363
|
+
localHeader.writeBytes(rawFilename);
|
|
7203
7364
|
if (writeLocalExtraFieldZip64) {
|
|
7204
|
-
localHeader.
|
|
7205
|
-
}
|
|
7206
|
-
localHeader.
|
|
7207
|
-
localHeader.
|
|
7208
|
-
localHeader.
|
|
7209
|
-
localHeader.
|
|
7210
|
-
localHeader.
|
|
7211
|
-
localHeader.
|
|
7365
|
+
localHeader.writeBytes(rawLocalExtraFieldZip64);
|
|
7366
|
+
}
|
|
7367
|
+
localHeader.writeBytes(rawExtraFieldAES);
|
|
7368
|
+
localHeader.writeBytes(rawExtraFieldExtendedTimestamp);
|
|
7369
|
+
localHeader.writeBytes(rawExtraFieldNTFS);
|
|
7370
|
+
localHeader.writeBytes(rawExtraFieldUnix);
|
|
7371
|
+
localHeader.writeBytes(rawExtraField);
|
|
7372
|
+
localHeader.writeBytes(rawLocalExtraField);
|
|
7212
7373
|
if (dataDescriptor) {
|
|
7213
7374
|
if (!zip64CompressedSize) {
|
|
7214
7375
|
setUint32(localHeaderView, HEADER_OFFSET_COMPRESSED_SIZE + LOCAL_HEADER_COMMON_OFFSET, 0);
|
|
@@ -7398,7 +7559,7 @@ function updateLocalHeader({
|
|
|
7398
7559
|
|
|
7399
7560
|
|
|
7400
7561
|
async function closeFile(zipWriter, comment, options) {
|
|
7401
|
-
const directoryDataLength = createDirectoryRecords(zipWriter.
|
|
7562
|
+
const directoryDataLength = createDirectoryRecords(zipWriter.fileEntries);
|
|
7402
7563
|
const { directoryStart, directoryArray } = await writeDirectoryRecords(zipWriter, directoryDataLength, options);
|
|
7403
7564
|
const signatureLength = await writeDigitalSignatureRecord(zipWriter, directoryArray, options);
|
|
7404
7565
|
await writeEndOfDirectoryRecord(zipWriter, comment, options, { directoryStart, directoryDataLength, signatureLength });
|
|
@@ -7428,19 +7589,19 @@ function createDirectoryRecords(files) {
|
|
|
7428
7589
|
if (zip64Offset || zip64DiskNumberStart || zip64UncompressedSize || zip64CompressedSize) {
|
|
7429
7590
|
const length = 4 + (zip64UncompressedSize ? 8 : 0) + (zip64CompressedSize ? 8 : 0) + (zip64Offset ? 8 : 0) + (zip64DiskNumberStart ? 4 : 0);
|
|
7430
7591
|
const extraFieldZip64 = createRecordWriter(length);
|
|
7431
|
-
extraFieldZip64.
|
|
7432
|
-
extraFieldZip64.
|
|
7592
|
+
extraFieldZip64.writeUint16(EXTRAFIELD_TYPE_ZIP64);
|
|
7593
|
+
extraFieldZip64.writeUint16(length - 4);
|
|
7433
7594
|
if (zip64UncompressedSize) {
|
|
7434
|
-
extraFieldZip64.
|
|
7595
|
+
extraFieldZip64.writeUint64(uncompressedSize);
|
|
7435
7596
|
}
|
|
7436
7597
|
if (zip64CompressedSize) {
|
|
7437
|
-
extraFieldZip64.
|
|
7598
|
+
extraFieldZip64.writeUint64(compressedSize);
|
|
7438
7599
|
}
|
|
7439
7600
|
if (zip64Offset) {
|
|
7440
|
-
extraFieldZip64.
|
|
7601
|
+
extraFieldZip64.writeUint64(fileEntry.offset);
|
|
7441
7602
|
}
|
|
7442
7603
|
if (zip64DiskNumberStart) {
|
|
7443
|
-
extraFieldZip64.
|
|
7604
|
+
extraFieldZip64.writeUint32(fileEntry.diskNumberStart);
|
|
7444
7605
|
}
|
|
7445
7606
|
rawExtraFieldZip64 = extraFieldZip64.array;
|
|
7446
7607
|
} else {
|
|
@@ -7453,10 +7614,10 @@ function createDirectoryRecords(files) {
|
|
|
7453
7614
|
const lastModTimeUnix = getTimeUnix(lastModDate);
|
|
7454
7615
|
if (extendedTimestamp && inUnixTimeRange(lastModTimeUnix)) {
|
|
7455
7616
|
const extraFieldTimestamp = createRecordWriter(9);
|
|
7456
|
-
extraFieldTimestamp.
|
|
7457
|
-
extraFieldTimestamp.
|
|
7458
|
-
extraFieldTimestamp.
|
|
7459
|
-
extraFieldTimestamp.
|
|
7617
|
+
extraFieldTimestamp.writeUint16(EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
|
|
7618
|
+
extraFieldTimestamp.writeUint16(5);
|
|
7619
|
+
extraFieldTimestamp.writeUint8(extraFieldExtendedTimestampFlag);
|
|
7620
|
+
extraFieldTimestamp.writeUint32(lastModTimeUnix);
|
|
7460
7621
|
rawExtraFieldTimestamp = extraFieldTimestamp.array;
|
|
7461
7622
|
} else {
|
|
7462
7623
|
rawExtraFieldTimestamp = EMPTY_UINT8_ARRAY;
|
|
@@ -7478,14 +7639,14 @@ function createDirectoryRecords(files) {
|
|
|
7478
7639
|
}
|
|
7479
7640
|
|
|
7480
7641
|
async function writeDirectoryRecords(zipWriter, directoryDataLength, options) {
|
|
7481
|
-
const {
|
|
7642
|
+
const { fileEntries, writer } = zipWriter;
|
|
7482
7643
|
const directoryArray = new Uint8Array(directoryDataLength);
|
|
7483
7644
|
await initStream(writer);
|
|
7484
7645
|
let offset = 0;
|
|
7485
7646
|
let directoryDiskOffset = 0;
|
|
7486
7647
|
let directoryStartDiskNumber = getDiskNumber(writer);
|
|
7487
7648
|
let directoryStartDiskOffset = getDiskOffset(writer);
|
|
7488
|
-
for (const [indexFileEntry, fileEntry] of Array.from(
|
|
7649
|
+
for (const [indexFileEntry, fileEntry] of Array.from(fileEntries.values()).entries()) {
|
|
7489
7650
|
const {
|
|
7490
7651
|
offset: fileEntryOffset,
|
|
7491
7652
|
rawFilename,
|
|
@@ -7530,28 +7691,28 @@ async function writeDirectoryRecords(zipWriter, directoryDataLength, options) {
|
|
|
7530
7691
|
setUint16(headerView, HEADER_OFFSET_VERSION, VERSION_ZIP64);
|
|
7531
7692
|
}
|
|
7532
7693
|
const directoryRecord = createRecordWriter(directoryRecordLength);
|
|
7533
|
-
directoryRecord.
|
|
7534
|
-
directoryRecord.
|
|
7535
|
-
directoryRecord.
|
|
7536
|
-
directoryRecord.
|
|
7537
|
-
directoryRecord.
|
|
7538
|
-
directoryRecord.
|
|
7539
|
-
directoryRecord.
|
|
7540
|
-
directoryRecord.
|
|
7541
|
-
directoryRecord.
|
|
7542
|
-
directoryRecord.
|
|
7543
|
-
directoryRecord.
|
|
7544
|
-
directoryRecord.
|
|
7545
|
-
directoryRecord.
|
|
7546
|
-
directoryRecord.
|
|
7547
|
-
directoryRecord.
|
|
7548
|
-
directoryRecord.
|
|
7549
|
-
directoryRecord.
|
|
7694
|
+
directoryRecord.writeUint32(CENTRAL_FILE_HEADER_SIGNATURE);
|
|
7695
|
+
directoryRecord.writeUint16(versionMadeBy);
|
|
7696
|
+
directoryRecord.writeBytes(headerArray.subarray(0, HEADER_SIZE - 4 - 2));
|
|
7697
|
+
directoryRecord.writeUint16(extraFieldLength);
|
|
7698
|
+
directoryRecord.writeUint16(getLength(rawComment));
|
|
7699
|
+
directoryRecord.writeUint16(zip64DiskNumberStart ? MAX_16_BITS : diskNumberStart);
|
|
7700
|
+
directoryRecord.writeUint16(internalFileAttributes);
|
|
7701
|
+
directoryRecord.writeUint32(externalFileAttributes);
|
|
7702
|
+
directoryRecord.writeUint32(zip64Offset ? MAX_32_BITS : fileEntryOffset);
|
|
7703
|
+
directoryRecord.writeBytes(rawFilename);
|
|
7704
|
+
directoryRecord.writeBytes(rawExtraFieldZip64);
|
|
7705
|
+
directoryRecord.writeBytes(rawExtraFieldAES);
|
|
7706
|
+
directoryRecord.writeBytes(rawExtraFieldExtendedTimestamp);
|
|
7707
|
+
directoryRecord.writeBytes(rawExtraFieldNTFS);
|
|
7708
|
+
directoryRecord.writeBytes(rawExtraFieldUnix);
|
|
7709
|
+
directoryRecord.writeBytes(rawExtraField);
|
|
7710
|
+
directoryRecord.writeBytes(rawComment);
|
|
7550
7711
|
arraySet(directoryArray, directoryRecord.array, offset);
|
|
7551
7712
|
offset += directoryRecordLength;
|
|
7552
7713
|
if (options.onprogress) {
|
|
7553
7714
|
try {
|
|
7554
|
-
await options.onprogress(indexFileEntry + 1,
|
|
7715
|
+
await options.onprogress(indexFileEntry + 1, fileEntries.size, new Entry(fileEntry));
|
|
7555
7716
|
} catch {
|
|
7556
7717
|
// ignored
|
|
7557
7718
|
}
|
|
@@ -7565,7 +7726,7 @@ async function writeDirectoryRecords(zipWriter, directoryDataLength, options) {
|
|
|
7565
7726
|
}
|
|
7566
7727
|
|
|
7567
7728
|
async function writeDigitalSignatureRecord(zipWriter, directoryArray, options) {
|
|
7568
|
-
const signCentralDirectory =
|
|
7729
|
+
const signCentralDirectory = getFunctionOptionValue(zipWriter, options, OPTION_SIGN_CENTRAL_DIRECTORY);
|
|
7569
7730
|
if (signCentralDirectory) {
|
|
7570
7731
|
const signatureData = await signCentralDirectory(directoryArray);
|
|
7571
7732
|
const signatureDataLength = getLength(signatureData);
|
|
@@ -7573,9 +7734,9 @@ async function writeDigitalSignatureRecord(zipWriter, directoryArray, options) {
|
|
|
7573
7734
|
throw new Error(ERR_INVALID_SIGNATURE_DATA);
|
|
7574
7735
|
}
|
|
7575
7736
|
const signatureRecord = createRecordWriter(6 + signatureDataLength);
|
|
7576
|
-
signatureRecord.
|
|
7577
|
-
signatureRecord.
|
|
7578
|
-
signatureRecord.
|
|
7737
|
+
signatureRecord.writeUint32(DIGITAL_SIGNATURE_RECORD_SIGNATURE);
|
|
7738
|
+
signatureRecord.writeUint16(signatureDataLength);
|
|
7739
|
+
signatureRecord.writeBytes(signatureData);
|
|
7579
7740
|
await writeData(zipWriter.writer, signatureRecord.array);
|
|
7580
7741
|
return 6 + signatureDataLength;
|
|
7581
7742
|
}
|
|
@@ -7586,7 +7747,7 @@ async function writeEndOfDirectoryRecord(zipWriter, comment, options, cdInfo) {
|
|
|
7586
7747
|
const { writer } = zipWriter;
|
|
7587
7748
|
const { directoryStart, signatureLength } = cdInfo;
|
|
7588
7749
|
let { directoryDataLength } = cdInfo;
|
|
7589
|
-
let
|
|
7750
|
+
let fileEntriesLength = zipWriter.fileEntries.size;
|
|
7590
7751
|
let diskNumber = directoryStart.diskNumber;
|
|
7591
7752
|
let directoryOffset = getSegmentOffset(zipWriter, directoryStart);
|
|
7592
7753
|
let lastDiskNumber = getDiskNumber(writer);
|
|
@@ -7594,7 +7755,7 @@ async function writeEndOfDirectoryRecord(zipWriter, comment, options, cdInfo) {
|
|
|
7594
7755
|
lastDiskNumber++;
|
|
7595
7756
|
}
|
|
7596
7757
|
let zip64 = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIP64);
|
|
7597
|
-
if (directoryOffset >= MAX_32_BITS || directoryDataLength >= MAX_32_BITS ||
|
|
7758
|
+
if (directoryOffset >= MAX_32_BITS || directoryDataLength >= MAX_32_BITS || fileEntriesLength >= MAX_16_BITS || lastDiskNumber >= MAX_16_BITS) {
|
|
7598
7759
|
if (zip64 === false) {
|
|
7599
7760
|
throw new Error(ERR_UNSUPPORTED_FORMAT);
|
|
7600
7761
|
} else {
|
|
@@ -7611,37 +7772,37 @@ async function writeEndOfDirectoryRecord(zipWriter, comment, options, cdInfo) {
|
|
|
7611
7772
|
}
|
|
7612
7773
|
lastDiskNumber = getDiskNumber(writer);
|
|
7613
7774
|
if (zip64) {
|
|
7614
|
-
endOfdirectoryRecord.
|
|
7615
|
-
endOfdirectoryRecord.
|
|
7616
|
-
endOfdirectoryRecord.
|
|
7617
|
-
endOfdirectoryRecord.
|
|
7618
|
-
endOfdirectoryRecord.
|
|
7619
|
-
endOfdirectoryRecord.
|
|
7620
|
-
endOfdirectoryRecord.
|
|
7621
|
-
endOfdirectoryRecord.
|
|
7622
|
-
endOfdirectoryRecord.
|
|
7623
|
-
endOfdirectoryRecord.
|
|
7624
|
-
endOfdirectoryRecord.
|
|
7625
|
-
endOfdirectoryRecord.
|
|
7626
|
-
endOfdirectoryRecord.
|
|
7627
|
-
endOfdirectoryRecord.
|
|
7775
|
+
endOfdirectoryRecord.writeUint32(ZIP64_END_OF_CENTRAL_DIR_SIGNATURE);
|
|
7776
|
+
endOfdirectoryRecord.writeUint64(44);
|
|
7777
|
+
endOfdirectoryRecord.writeUint16(45);
|
|
7778
|
+
endOfdirectoryRecord.writeUint16(45);
|
|
7779
|
+
endOfdirectoryRecord.writeUint32(lastDiskNumber);
|
|
7780
|
+
endOfdirectoryRecord.writeUint32(diskNumber);
|
|
7781
|
+
endOfdirectoryRecord.writeUint64(fileEntriesLength);
|
|
7782
|
+
endOfdirectoryRecord.writeUint64(fileEntriesLength);
|
|
7783
|
+
endOfdirectoryRecord.writeUint64(directoryDataLength);
|
|
7784
|
+
endOfdirectoryRecord.writeUint64(directoryOffset);
|
|
7785
|
+
endOfdirectoryRecord.writeUint32(ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE);
|
|
7786
|
+
endOfdirectoryRecord.writeUint32(lastDiskNumber);
|
|
7787
|
+
endOfdirectoryRecord.writeUint64(BigInt(getSegmentOffset(zipWriter, writer)) + BigInt(directoryDataLength) + BigInt(signatureLength));
|
|
7788
|
+
endOfdirectoryRecord.writeUint32(lastDiskNumber + 1);
|
|
7628
7789
|
const supportZip64SplitFile = getOptionValue(zipWriter, options, OPTION_SUPPORT_ZIP64_SPLIT_FILE, true);
|
|
7629
7790
|
if (supportZip64SplitFile) {
|
|
7630
7791
|
lastDiskNumber = MAX_16_BITS;
|
|
7631
7792
|
diskNumber = MAX_16_BITS;
|
|
7632
7793
|
}
|
|
7633
|
-
|
|
7794
|
+
fileEntriesLength = MAX_16_BITS;
|
|
7634
7795
|
directoryOffset = MAX_32_BITS;
|
|
7635
7796
|
directoryDataLength = MAX_32_BITS;
|
|
7636
7797
|
}
|
|
7637
|
-
endOfdirectoryRecord.
|
|
7638
|
-
endOfdirectoryRecord.
|
|
7639
|
-
endOfdirectoryRecord.
|
|
7640
|
-
endOfdirectoryRecord.
|
|
7641
|
-
endOfdirectoryRecord.
|
|
7642
|
-
endOfdirectoryRecord.
|
|
7643
|
-
endOfdirectoryRecord.
|
|
7644
|
-
endOfdirectoryRecord.
|
|
7798
|
+
endOfdirectoryRecord.writeUint32(END_OF_CENTRAL_DIR_SIGNATURE);
|
|
7799
|
+
endOfdirectoryRecord.writeUint16(lastDiskNumber);
|
|
7800
|
+
endOfdirectoryRecord.writeUint16(diskNumber);
|
|
7801
|
+
endOfdirectoryRecord.writeUint16(fileEntriesLength);
|
|
7802
|
+
endOfdirectoryRecord.writeUint16(fileEntriesLength);
|
|
7803
|
+
endOfdirectoryRecord.writeUint32(directoryDataLength);
|
|
7804
|
+
endOfdirectoryRecord.writeUint32(directoryOffset);
|
|
7805
|
+
endOfdirectoryRecord.writeUint16(commentLength);
|
|
7645
7806
|
await writeData(writer, endOfdirectoryRecord.array);
|
|
7646
7807
|
if (commentLength) {
|
|
7647
7808
|
await writeData(writer, comment);
|
|
@@ -7654,11 +7815,11 @@ function createRecordWriter(length) {
|
|
|
7654
7815
|
let offset = 0;
|
|
7655
7816
|
return {
|
|
7656
7817
|
array,
|
|
7657
|
-
|
|
7658
|
-
|
|
7659
|
-
|
|
7660
|
-
|
|
7661
|
-
|
|
7818
|
+
writeUint8: value => { setUint8(view, offset, value); offset += 1; },
|
|
7819
|
+
writeUint16: value => { setUint16(view, offset, value); offset += 2; },
|
|
7820
|
+
writeUint32: value => { setUint32(view, offset, value); offset += 4; },
|
|
7821
|
+
writeUint64: value => { setBigUint64(view, offset, BigInt(value)); offset += 8; },
|
|
7822
|
+
writeBytes: value => { arraySet(array, value, offset); offset += getLength(value); },
|
|
7662
7823
|
skip: count => offset += count
|
|
7663
7824
|
};
|
|
7664
7825
|
}
|
|
@@ -7682,6 +7843,71 @@ function getSegmentOffset(zipWriter, { diskNumber = 0, diskOffset = 0 }) {
|
|
|
7682
7843
|
return zipWriter.offset - diskOffset - (diskNumber ? zipWriter.initialOffset : 0);
|
|
7683
7844
|
}
|
|
7684
7845
|
|
|
7846
|
+
async function startsWithSplitZipSignature(reader) {
|
|
7847
|
+
const signatureArray = await readUint8Array(reader, 0, SPLIT_ZIP_FILE_SIGNATURE_LENGTH);
|
|
7848
|
+
return getUint32(getDataView(signatureArray), 0) == SPLIT_ZIP_FILE_SIGNATURE;
|
|
7849
|
+
}
|
|
7850
|
+
|
|
7851
|
+
async function copyZipData(zipWriter, reader, entries, directoryOffset, splitZipSignatureLength) {
|
|
7852
|
+
const { writer } = zipWriter;
|
|
7853
|
+
const entryPositions = new Map();
|
|
7854
|
+
if (writer.closeDisk) {
|
|
7855
|
+
const sortedEntries = Array.from(entries).sort((firstEntry, secondEntry) =>
|
|
7856
|
+
getSourceOffset(reader, firstEntry) - getSourceOffset(reader, secondEntry));
|
|
7857
|
+
let copiedLength = 0;
|
|
7858
|
+
for (const entry of sortedEntries) {
|
|
7859
|
+
const sourceOffset = getSourceOffset(reader, entry);
|
|
7860
|
+
await copyData(zipWriter, reader, copiedLength, sourceOffset - copiedLength);
|
|
7861
|
+
if (exceedsAvailableSize(writer, await getLocalHeaderLength(reader, sourceOffset))) {
|
|
7862
|
+
await writer.closeDisk();
|
|
7863
|
+
}
|
|
7864
|
+
entryPositions.set(entry, {
|
|
7865
|
+
offset: getSegmentOffset(zipWriter, writer),
|
|
7866
|
+
diskNumberStart: getDiskNumber(writer)
|
|
7867
|
+
});
|
|
7868
|
+
copiedLength = sourceOffset;
|
|
7869
|
+
}
|
|
7870
|
+
await copyData(zipWriter, reader, copiedLength, directoryOffset - copiedLength);
|
|
7871
|
+
} else {
|
|
7872
|
+
await copyData(zipWriter, reader, 0, directoryOffset);
|
|
7873
|
+
entries.forEach(entry => entryPositions.set(entry, {
|
|
7874
|
+
offset: splitZipSignatureLength + getSourceOffset(reader, entry),
|
|
7875
|
+
diskNumberStart: 0
|
|
7876
|
+
}));
|
|
7877
|
+
}
|
|
7878
|
+
return entryPositions;
|
|
7879
|
+
}
|
|
7880
|
+
|
|
7881
|
+
async function copyData(zipWriter, reader, offset, size) {
|
|
7882
|
+
if (size > 0) {
|
|
7883
|
+
const { writer } = zipWriter;
|
|
7884
|
+
await createReadable(reader, { offset, size }).pipeTo(writer.writable, { preventClose: true, preventAbort: true });
|
|
7885
|
+
writer.size += size;
|
|
7886
|
+
zipWriter.offset += size;
|
|
7887
|
+
}
|
|
7888
|
+
}
|
|
7889
|
+
|
|
7890
|
+
async function getLocalHeaderLength(reader, offset) {
|
|
7891
|
+
const headerArray = await readUint8Array(reader, offset, HEADER_SIZE);
|
|
7892
|
+
if (getLength(headerArray) < HEADER_SIZE) {
|
|
7893
|
+
return HEADER_SIZE;
|
|
7894
|
+
}
|
|
7895
|
+
const headerView = getDataView(headerArray);
|
|
7896
|
+
return HEADER_SIZE +
|
|
7897
|
+
getUint16(headerView, HEADER_OFFSET_FILENAME_LENGTH + LOCAL_HEADER_COMMON_OFFSET) +
|
|
7898
|
+
getUint16(headerView, HEADER_OFFSET_EXTRAFIELD_LENGTH + LOCAL_HEADER_COMMON_OFFSET);
|
|
7899
|
+
}
|
|
7900
|
+
|
|
7901
|
+
function getSourceOffset(reader, { offset, diskNumberStart }) {
|
|
7902
|
+
return offset + (reader.getDiskOffset ? reader.getDiskOffset(diskNumberStart) : 0);
|
|
7903
|
+
}
|
|
7904
|
+
|
|
7905
|
+
function getSplitZipSignatureArray() {
|
|
7906
|
+
const signatureArray = new Uint8Array(SPLIT_ZIP_FILE_SIGNATURE_LENGTH);
|
|
7907
|
+
setUint32(getDataView(signatureArray), 0, SPLIT_ZIP_FILE_SIGNATURE);
|
|
7908
|
+
return signatureArray;
|
|
7909
|
+
}
|
|
7910
|
+
|
|
7685
7911
|
async function writeData(writer, array) {
|
|
7686
7912
|
const { writable } = writer;
|
|
7687
7913
|
const streamWriter = writable.getWriter();
|
|
@@ -7733,6 +7959,21 @@ function getOptionValue(zipWriter, options, name, defaultValue) {
|
|
|
7733
7959
|
return result === UNDEFINED_VALUE ? defaultValue : result;
|
|
7734
7960
|
}
|
|
7735
7961
|
|
|
7962
|
+
function getDateOptionValue(zipWriter, options, name, defaultValue) {
|
|
7963
|
+
const date = getOptionValue(zipWriter, options, name, defaultValue);
|
|
7964
|
+
if (date === null) {
|
|
7965
|
+
return defaultValue;
|
|
7966
|
+
}
|
|
7967
|
+
if (date !== UNDEFINED_VALUE && (typeof date.getTime != FUNCTION_TYPE || Number.isNaN(date.getTime()))) {
|
|
7968
|
+
throw new Error(ERR_INVALID_DATE);
|
|
7969
|
+
}
|
|
7970
|
+
return date;
|
|
7971
|
+
}
|
|
7972
|
+
|
|
7973
|
+
function getFunctionOptionValue(zipWriter, options, name) {
|
|
7974
|
+
return checkFunctionOption(getOptionValue(zipWriter, options, name));
|
|
7975
|
+
}
|
|
7976
|
+
|
|
7736
7977
|
function getAliasedOptionValue(zipWriter, options, name, deprecatedName, defaultValue) {
|
|
7737
7978
|
const value = getAliasedValue(options, name, deprecatedName);
|
|
7738
7979
|
const result = value === UNDEFINED_VALUE ? getAliasedValue(zipWriter.options, name, deprecatedName) : value;
|
|
@@ -7747,9 +7988,6 @@ function getNumberOptionValue(zipWriter, options, name, defaultValue) {
|
|
|
7747
7988
|
return toNumber(getOptionValue(zipWriter, options, name, defaultValue));
|
|
7748
7989
|
}
|
|
7749
7990
|
|
|
7750
|
-
function toNumber(value) {
|
|
7751
|
-
return typeof value == STRING_TYPE && value.trim() ? Number(value) : value;
|
|
7752
|
-
}
|
|
7753
7991
|
|
|
7754
7992
|
function getMaximumCompressedSize(uncompressedSize) {
|
|
7755
7993
|
return uncompressedSize + (5 * (Math.floor(uncompressedSize / 16383) + 1));
|
|
@@ -7761,6 +7999,14 @@ function isCompressed(compressionMethod, level) {
|
|
|
7761
7999
|
: compressionMethod !== COMPRESSION_METHOD_STORE;
|
|
7762
8000
|
}
|
|
7763
8001
|
|
|
8002
|
+
function getUint16(view, offset) {
|
|
8003
|
+
return view.getUint16(offset, true);
|
|
8004
|
+
}
|
|
8005
|
+
|
|
8006
|
+
function getUint32(view, offset) {
|
|
8007
|
+
return view.getUint32(offset, true);
|
|
8008
|
+
}
|
|
8009
|
+
|
|
7764
8010
|
function setUint8(view, offset, value) {
|
|
7765
8011
|
view.setUint8(offset, value);
|
|
7766
8012
|
}
|
|
@@ -7804,9 +8050,9 @@ function getHeaderArrayData({
|
|
|
7804
8050
|
const headerRecord = createRecordWriter(HEADER_SIZE - 4);
|
|
7805
8051
|
const headerArray = headerRecord.array;
|
|
7806
8052
|
const headerView = getDataView(headerArray);
|
|
7807
|
-
headerRecord.
|
|
7808
|
-
headerRecord.
|
|
7809
|
-
headerRecord.
|
|
8053
|
+
headerRecord.writeUint16(version);
|
|
8054
|
+
headerRecord.writeUint16(bitFlag);
|
|
8055
|
+
headerRecord.writeUint16(compressionMethod);
|
|
7810
8056
|
if (rawLastModDate === UNDEFINED_VALUE) {
|
|
7811
8057
|
const dateArray = new Uint32Array(1);
|
|
7812
8058
|
const dateView = getDataView(dateArray);
|
|
@@ -7814,20 +8060,20 @@ function getHeaderArrayData({
|
|
|
7814
8060
|
setUint16(dateView, 2, ((((lastModDate.getFullYear() - 1980) << 4) | (lastModDate.getMonth() + 1)) << 5) | lastModDate.getDate());
|
|
7815
8061
|
rawLastModDate = dateArray[0];
|
|
7816
8062
|
}
|
|
7817
|
-
headerRecord.
|
|
8063
|
+
headerRecord.writeUint32(rawLastModDate);
|
|
7818
8064
|
headerRecord.skip(4);
|
|
7819
8065
|
if (zip64CompressedSize || compressedSize !== UNDEFINED_VALUE) {
|
|
7820
|
-
headerRecord.
|
|
8066
|
+
headerRecord.writeUint32(zip64CompressedSize ? MAX_32_BITS : compressedSize);
|
|
7821
8067
|
} else {
|
|
7822
8068
|
headerRecord.skip(4);
|
|
7823
8069
|
}
|
|
7824
8070
|
if (zip64UncompressedSize || uncompressedSize !== UNDEFINED_VALUE) {
|
|
7825
|
-
headerRecord.
|
|
8071
|
+
headerRecord.writeUint32(zip64UncompressedSize ? MAX_32_BITS : uncompressedSize);
|
|
7826
8072
|
} else {
|
|
7827
8073
|
headerRecord.skip(4);
|
|
7828
8074
|
}
|
|
7829
|
-
headerRecord.
|
|
7830
|
-
headerRecord.
|
|
8075
|
+
headerRecord.writeUint16(getLength(rawFilename));
|
|
8076
|
+
headerRecord.writeUint16(extraFieldLength);
|
|
7831
8077
|
return {
|
|
7832
8078
|
headerArray,
|
|
7833
8079
|
headerView,
|
|
@@ -8715,4 +8961,4 @@ function terminateWorkersAndModule() {
|
|
|
8715
8961
|
|
|
8716
8962
|
configureExternalAssets();
|
|
8717
8963
|
|
|
8718
|
-
export { BlobReader, BlobWriter, Data64URIReader, Data64URIWriter, ERR_AMBIGUOUS_ARCHIVE, ERR_BAD_FORMAT, ERR_CENTRAL_DIRECTORY_NOT_FOUND, ERR_DUPLICATED_NAME, ERR_ENCRYPTED, ERR_ENCRYPTED_CENTRAL_DIRECTORY, ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND, ERR_EOCDR_NOT_FOUND, ERR_EXTRAFIELD_ZIP64_NOT_FOUND, ERR_HTTP_RANGE, ERR_HTTP_RESOURCE_CHANGED, ERR_INVALID_AUTHENTICATION_CODE, ERR_INVALID_CODEC_DEFINITION, ERR_INVALID_CODEC_MODULE, ERR_INVALID_COMMENT, ERR_INVALID_COMMENT_TYPE, ERR_INVALID_COMPRESSED_DATA, ERR_INVALID_CRC32, ERR_INVALID_ENCRYPTION_STRENGTH, ERR_INVALID_ENTRY_COMMENT, ERR_INVALID_ENTRY_NAME, ERR_INVALID_EXTRAFIELD_DATA, ERR_INVALID_EXTRAFIELD_TYPE, ERR_INVALID_FILENAME_VALIDATION, ERR_INVALID_GID, ERR_INVALID_LEVEL, ERR_INVALID_MAX_APPENDED_DATA_SIZE, ERR_INVALID_MSDOS_ATTRIBUTES, ERR_INVALID_MSDOS_DATA, ERR_INVALID_PASSWORD, ERR_INVALID_PASSWORD_TYPE, ERR_INVALID_SIGNATURE, ERR_INVALID_SIGNATURE_DATA, ERR_INVALID_STRICTNESS, ERR_INVALID_UID, ERR_INVALID_UNCOMPRESSED_SIZE, ERR_INVALID_UNIX_EXTRA_FIELD_TYPE, ERR_INVALID_UNIX_ID_SIZE, ERR_INVALID_UNIX_MODE, ERR_INVALID_VERSION, ERR_ITERATOR_COMPLETED_TOO_SOON, ERR_LOCAL_FILE_HEADER_NOT_FOUND, ERR_OVERLAPPING_ENTRY, ERR_RESERVED_COMPRESSION_METHOD, ERR_SPLIT_ZIP_FILE, ERR_UNDEFINED_READER, ERR_UNDEFINED_UNCOMPRESSED_SIZE, ERR_UNDETERMINED_SIZE, ERR_UNSAFE_FILENAME, ERR_UNSUPPORTED_COMPRESSION$1 as ERR_UNSUPPORTED_COMPRESSION, ERR_UNSUPPORTED_CONTEXT, ERR_UNSUPPORTED_CRYPTO_API, ERR_UNSUPPORTED_ENCRYPTION, ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH, ERR_UNSUPPORTED_ENCRYPTION_USDZ, ERR_UNSUPPORTED_FORMAT, ERR_WORKER_STARTUP_TIMEOUT, ERR_WRITER_NOT_INITIALIZED, ERR_ZIP_NOT_EMPTY, HttpRangeReader, HttpReader, Reader, SplitDataReader, SplitDataWriter, TextReader, TextWriter, Uint8ArrayReader, Uint8ArrayWriter, Writer, ZipReader, ZipReaderStream, ZipWriter, ZipWriterStream, configure, createBlobTempStream, createOPFSTempStream, createSyncAccessHandleTempStream, getMimeType, registerCodec, resetConfiguration, terminateWorkersAndModule as terminateWorkers, unregisterCodec };
|
|
8964
|
+
export { BlobReader, BlobWriter, Data64URIReader, Data64URIWriter, ERR_AMBIGUOUS_ARCHIVE, ERR_BAD_FORMAT, ERR_CENTRAL_DIRECTORY_NOT_FOUND, ERR_DUPLICATED_NAME, ERR_ENCRYPTED, ERR_ENCRYPTED_CENTRAL_DIRECTORY, ERR_ENTRY_DATA_OUT_OF_BOUNDS, ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND, ERR_EOCDR_NOT_FOUND, ERR_EXTRAFIELD_ZIP64_NOT_FOUND, ERR_HTTP_RANGE, ERR_HTTP_RESOURCE_CHANGED, ERR_INVALID_AUTHENTICATION_CODE, ERR_INVALID_CODEC_DEFINITION, ERR_INVALID_CODEC_MODULE, ERR_INVALID_COMMENT, ERR_INVALID_COMMENT_TYPE, ERR_INVALID_COMPRESSED_DATA, ERR_INVALID_CRC32, ERR_INVALID_DATE, ERR_INVALID_ENCRYPTION_STRENGTH, ERR_INVALID_ENTRY_COMMENT, ERR_INVALID_ENTRY_COMMENT_TYPE, ERR_INVALID_ENTRY_NAME, ERR_INVALID_EXTRAFIELD, ERR_INVALID_EXTRAFIELD_DATA, ERR_INVALID_EXTRAFIELD_DATA_TYPE, ERR_INVALID_EXTRAFIELD_TYPE, ERR_INVALID_FILENAME_VALIDATION, ERR_INVALID_FUNCTION_OPTION, ERR_INVALID_GID, ERR_INVALID_LEVEL, ERR_INVALID_MAX_APPENDED_DATA_SIZE, ERR_INVALID_MAX_WORKERS, ERR_INVALID_MSDOS_ATTRIBUTES, ERR_INVALID_MSDOS_DATA, ERR_INVALID_PASSWORD, ERR_INVALID_PASSWORD_TYPE, ERR_INVALID_SIGNAL, ERR_INVALID_SIGNATURE, ERR_INVALID_SIGNATURE_DATA, ERR_INVALID_STRICTNESS, ERR_INVALID_UID, ERR_INVALID_UNCOMPRESSED_SIZE, ERR_INVALID_UNIX_EXTRA_FIELD_TYPE, ERR_INVALID_UNIX_ID_SIZE, ERR_INVALID_UNIX_MODE, ERR_INVALID_VERSION, ERR_ITERATOR_COMPLETED_TOO_SOON, ERR_LOCAL_FILE_HEADER_NOT_FOUND, ERR_OVERLAPPING_ENTRY, ERR_RESERVED_COMPRESSION_METHOD, ERR_SPLIT_ZIP_FILE, ERR_UNDEFINED_COMPRESSION_METHOD, ERR_UNDEFINED_READER, ERR_UNDEFINED_UNCOMPRESSED_SIZE, ERR_UNDETERMINED_SIZE, ERR_UNSAFE_FILENAME, ERR_UNSUPPORTED_COMPRESSION$1 as ERR_UNSUPPORTED_COMPRESSION, ERR_UNSUPPORTED_CONTEXT, ERR_UNSUPPORTED_CRYPTO_API, ERR_UNSUPPORTED_ENCRYPTION, ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH, ERR_UNSUPPORTED_ENCRYPTION_USDZ, ERR_UNSUPPORTED_FORMAT, ERR_WORKER_STARTUP_TIMEOUT, ERR_WRITER_NOT_INITIALIZED, ERR_ZIP_NOT_EMPTY, HttpRangeReader, HttpReader, Reader, SplitDataReader, SplitDataWriter, TextReader, TextWriter, Uint8ArrayReader, Uint8ArrayWriter, Writer, ZipReader, ZipReaderStream, ZipWriter, ZipWriterStream, configure, createBlobTempStream, createOPFSTempStream, createSyncAccessHandleTempStream, getMimeType, registerCodec, resetConfiguration, terminateWorkersAndModule as terminateWorkers, unregisterCodec };
|