@zip.js/zip.js 2.8.52 → 2.8.54
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 +839 -528
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +847 -527
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +880 -557
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +829 -538
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +880 -557
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +895 -558
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +894 -557
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +849 -529
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +849 -529
- 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 +848 -528
- package/dist/zip.min.js +1 -1
- package/eslint.config.mjs +2 -1
- package/index-native.cjs +895 -558
- package/index-native.min.js +1 -1
- package/index.cjs +894 -557
- package/index.d.cts +672 -78
- package/index.d.ts +672 -78
- package/index.min.js +1 -1
- package/lib/core/codec-worker-web.js +13 -4
- package/lib/core/configuration.js +62 -21
- package/lib/core/constants.js +16 -1
- package/lib/core/io.js +44 -29
- package/lib/core/options.js +46 -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-entry.js +8 -0
- package/lib/core/zip-fs.js +38 -27
- package/lib/core/zip-reader.js +149 -60
- package/lib/core/zip-writer.js +329 -189
- 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 +11 -3
|
@@ -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;
|
|
@@ -93,6 +95,9 @@ const VERSION_DEFLATE = 0x14;
|
|
|
93
95
|
const VERSION_ZIP64 = 0x2D;
|
|
94
96
|
const VERSION_AES = 0x33;
|
|
95
97
|
|
|
98
|
+
const VERSION_MADE_BY_MSDOS = 0x0014;
|
|
99
|
+
const VERSION_MADE_BY_UNIX = 0x0300;
|
|
100
|
+
|
|
96
101
|
const DIRECTORY_SIGNATURE = "/";
|
|
97
102
|
|
|
98
103
|
const HEADER_SIZE = 30;
|
|
@@ -100,6 +105,8 @@ const HEADER_OFFSET_VERSION = 0;
|
|
|
100
105
|
const HEADER_OFFSET_SIGNATURE = 10;
|
|
101
106
|
const HEADER_OFFSET_COMPRESSED_SIZE = 14;
|
|
102
107
|
const HEADER_OFFSET_UNCOMPRESSED_SIZE = 18;
|
|
108
|
+
const HEADER_OFFSET_FILENAME_LENGTH = 22;
|
|
109
|
+
const HEADER_OFFSET_EXTRAFIELD_LENGTH = 24;
|
|
103
110
|
const LOCAL_HEADER_COMMON_OFFSET = 4;
|
|
104
111
|
|
|
105
112
|
const MAX_DATE = new Date(2107, 11, 31, 23, 59, 58);
|
|
@@ -112,9 +119,116 @@ const FUNCTION_TYPE = "function";
|
|
|
112
119
|
const OBJECT_TYPE = "object";
|
|
113
120
|
const STRING_TYPE = "string";
|
|
114
121
|
const NUMBER_TYPE = "number";
|
|
122
|
+
const BOOLEAN_TYPE = "boolean";
|
|
115
123
|
|
|
116
124
|
const EMPTY_UINT8_ARRAY = new Uint8Array();
|
|
117
125
|
|
|
126
|
+
/*
|
|
127
|
+
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
128
|
+
|
|
129
|
+
Redistribution and use in source and binary forms, with or without
|
|
130
|
+
modification, are permitted provided that the following conditions are met:
|
|
131
|
+
|
|
132
|
+
1. Redistributions of source code must retain the above copyright notice,
|
|
133
|
+
this list of conditions and the following disclaimer.
|
|
134
|
+
|
|
135
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
136
|
+
notice, this list of conditions and the following disclaimer in
|
|
137
|
+
the documentation and/or other materials provided with the distribution.
|
|
138
|
+
|
|
139
|
+
3. The names of the authors may not be used to endorse or promote products
|
|
140
|
+
derived from this software without specific prior written permission.
|
|
141
|
+
|
|
142
|
+
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
143
|
+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
144
|
+
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
145
|
+
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
146
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
147
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
148
|
+
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
149
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
150
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
151
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
152
|
+
*/
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
const OPTION_FILENAME_ENCODING = "filenameEncoding";
|
|
156
|
+
const OPTION_COMMENT_ENCODING = "commentEncoding";
|
|
157
|
+
const OPTION_DECODE_TEXT = "decodeText";
|
|
158
|
+
const OPTION_EXTRACT_PREPENDED_DATA = "extractPrependedData";
|
|
159
|
+
const OPTION_EXTRACT_APPENDED_DATA = "extractAppendedData";
|
|
160
|
+
const OPTION_PASSWORD = "password";
|
|
161
|
+
const OPTION_RAW_PASSWORD = "rawPassword";
|
|
162
|
+
const OPTION_PASS_THROUGH = "passThrough";
|
|
163
|
+
const OPTION_SIGNAL = "signal";
|
|
164
|
+
const OPTION_CHECK_PASSWORD_ONLY = "checkPasswordOnly";
|
|
165
|
+
const OPTION_CHECK_OVERLAPPING_ENTRY_ONLY = "checkOverlappingEntryOnly";
|
|
166
|
+
const OPTION_CHECK_OVERLAPPING_ENTRY = "checkOverlappingEntry";
|
|
167
|
+
const OPTION_CHECK_AMBIGUITY = "checkAmbiguity";
|
|
168
|
+
const OPTION_CHECK_LOCAL_DIRECTORY = "checkLocalDirectory";
|
|
169
|
+
const OPTION_CHECK_SIGNATURE = "checkSignature";
|
|
170
|
+
const OPTION_CHECK_CRC32 = "checkCrc32";
|
|
171
|
+
const OPTION_CHECK_AUTHENTICATION_CODE = "checkAuthenticationCode";
|
|
172
|
+
const OPTION_USE_WEB_WORKERS = "useWebWorkers";
|
|
173
|
+
const OPTION_USE_COMPRESSION_STREAM = "useCompressionStream";
|
|
174
|
+
const OPTION_TRANSFER_STREAMS = "transferStreams";
|
|
175
|
+
const OPTION_PREVENT_CLOSE = "preventClose";
|
|
176
|
+
const OPTION_ENCRYPTION_STRENGTH = "encryptionStrength";
|
|
177
|
+
const OPTION_EXTENDED_TIMESTAMP = "extendedTimestamp";
|
|
178
|
+
const OPTION_NTFS_TIMESTAMP = "ntfsTimestamp";
|
|
179
|
+
const OPTION_KEEP_ORDER = "keepOrder";
|
|
180
|
+
const OPTION_LEVEL = "level";
|
|
181
|
+
const OPTION_BUFFERED_WRITE = "bufferedWrite";
|
|
182
|
+
const OPTION_CREATE_TEMP_STREAM = "createTempStream";
|
|
183
|
+
const OPTION_DATA_DESCRIPTOR_SIGNATURE = "dataDescriptorSignature";
|
|
184
|
+
const OPTION_USE_UNICODE_FILE_NAMES = "useUnicodeFileNames";
|
|
185
|
+
const OPTION_DATA_DESCRIPTOR = "dataDescriptor";
|
|
186
|
+
const OPTION_SUPPORT_ZIP64_SPLIT_FILE = "supportZip64SplitFile";
|
|
187
|
+
const OPTION_ENCODE_TEXT = "encodeText";
|
|
188
|
+
const OPTION_OFFSET = "offset";
|
|
189
|
+
const OPTION_USDZ = "usdz";
|
|
190
|
+
const OPTION_UNIX_EXTRA_FIELD_TYPE = "unixExtraFieldType";
|
|
191
|
+
const OPTION_LOCAL_EXTRA_FIELD = "localExtraField";
|
|
192
|
+
const OPTION_STRICTNESS = "strictness";
|
|
193
|
+
const OPTION_FILENAME_VALIDATION = "filenameValidation";
|
|
194
|
+
const OPTION_NORMALIZE_FILENAME = "normalizeFilename";
|
|
195
|
+
const OPTION_MAX_APPENDED_DATA_SIZE = "maxAppendedDataSize";
|
|
196
|
+
const OPTION_DECRYPT_CENTRAL_DIRECTORY = "decryptCentralDirectory";
|
|
197
|
+
const OPTION_SIGN_CENTRAL_DIRECTORY = "signCentralDirectory";
|
|
198
|
+
const TEXT_TYPE_FILENAME = "filename";
|
|
199
|
+
const TEXT_TYPE_COMMENT = "comment";
|
|
200
|
+
const STRICTNESS_STRICT = "strict";
|
|
201
|
+
const STRICTNESS_BALANCED = "balanced";
|
|
202
|
+
const STRICTNESS_TOLERANT = "tolerant";
|
|
203
|
+
|
|
204
|
+
const ERR_INVALID_FUNCTION_OPTION = "Invalid option (must be a function)";
|
|
205
|
+
const ERR_INVALID_SIGNAL = "Invalid signal (must be an AbortSignal instance)";
|
|
206
|
+
const ERR_INVALID_PASSWORD_TYPE = "Invalid password (password must be a string, rawPassword must be a Uint8Array)";
|
|
207
|
+
|
|
208
|
+
function checkFunctionOption(value) {
|
|
209
|
+
if (value && typeof value != FUNCTION_TYPE) {
|
|
210
|
+
throw new Error(ERR_INVALID_FUNCTION_OPTION);
|
|
211
|
+
}
|
|
212
|
+
return value;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function checkSignalOption(signal) {
|
|
216
|
+
if (signal && (typeof signal.addEventListener != FUNCTION_TYPE || typeof signal.aborted != BOOLEAN_TYPE)) {
|
|
217
|
+
throw new Error(ERR_INVALID_SIGNAL);
|
|
218
|
+
}
|
|
219
|
+
return signal || UNDEFINED_VALUE;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function checkPasswordOption(password, rawPassword) {
|
|
223
|
+
if ((password && typeof password != STRING_TYPE) || (rawPassword && !(rawPassword instanceof Uint8Array))) {
|
|
224
|
+
throw new Error(ERR_INVALID_PASSWORD_TYPE);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function toNumber(value) {
|
|
229
|
+
return typeof value == STRING_TYPE && value.trim() ? Number(value) : value;
|
|
230
|
+
}
|
|
231
|
+
|
|
118
232
|
/*
|
|
119
233
|
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
120
234
|
|
|
@@ -144,7 +258,10 @@ const EMPTY_UINT8_ARRAY = new Uint8Array();
|
|
|
144
258
|
*/
|
|
145
259
|
|
|
146
260
|
|
|
261
|
+
const DEFAULT_CHUNK_SIZE$1 = 64 * 1024;
|
|
147
262
|
const MINIMUM_CHUNK_SIZE = 64;
|
|
263
|
+
const MINIMUM_PROPERTY_VALUE = 1;
|
|
264
|
+
const ERR_INVALID_MAX_WORKERS = "Invalid maxWorkers (must be an integer greater than 0)";
|
|
148
265
|
let maxWorkers = 2;
|
|
149
266
|
try {
|
|
150
267
|
if (typeof navigator != UNDEFINED_TYPE && navigator.hardwareConcurrency) {
|
|
@@ -156,7 +273,7 @@ try {
|
|
|
156
273
|
const DEFAULT_CONFIGURATION = {
|
|
157
274
|
workerURI: "./core/web-worker-wasm.js",
|
|
158
275
|
wasmURI: "./core/streams/zlib-wasm/zlib-streams.wasm",
|
|
159
|
-
chunkSize:
|
|
276
|
+
chunkSize: DEFAULT_CHUNK_SIZE$1,
|
|
160
277
|
maxWorkers,
|
|
161
278
|
terminateWorkerTimeout: 5000,
|
|
162
279
|
workerStarvationTimeout: 5000,
|
|
@@ -168,24 +285,38 @@ const DEFAULT_CONFIGURATION = {
|
|
|
168
285
|
DecompressionStream: typeof DecompressionStream != UNDEFINED_TYPE && DecompressionStream
|
|
169
286
|
};
|
|
170
287
|
|
|
171
|
-
const
|
|
288
|
+
const PROPERTY_NAME_MAX_WORKERS = "maxWorkers";
|
|
289
|
+
|
|
290
|
+
const STRING_PROPERTY_NAMES = [
|
|
172
291
|
"baseURI",
|
|
173
292
|
"wasmURI",
|
|
174
|
-
"workerURI"
|
|
175
|
-
|
|
293
|
+
"workerURI"
|
|
294
|
+
];
|
|
295
|
+
const BOOLEAN_PROPERTY_NAMES = [
|
|
296
|
+
"useCompressionStream",
|
|
297
|
+
"useWebWorkers",
|
|
298
|
+
"transferStreams"
|
|
299
|
+
];
|
|
300
|
+
const NUMBER_PROPERTY_NAMES = [
|
|
176
301
|
"chunkSize",
|
|
177
|
-
|
|
302
|
+
PROPERTY_NAME_MAX_WORKERS,
|
|
178
303
|
"terminateWorkerTimeout",
|
|
179
304
|
"workerStarvationTimeout",
|
|
180
|
-
"workerStartupTimeout"
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
"
|
|
305
|
+
"workerStartupTimeout"
|
|
306
|
+
];
|
|
307
|
+
const FUNCTION_PROPERTY_NAMES = [
|
|
308
|
+
"createWorker",
|
|
184
309
|
"CompressionStream",
|
|
185
310
|
"DecompressionStream",
|
|
186
311
|
"CompressionStreamFallback",
|
|
187
312
|
"DecompressionStreamFallback"
|
|
188
313
|
];
|
|
314
|
+
const CONFIGURABLE_PROPERTY_NAMES = [
|
|
315
|
+
...STRING_PROPERTY_NAMES,
|
|
316
|
+
...BOOLEAN_PROPERTY_NAMES,
|
|
317
|
+
...NUMBER_PROPERTY_NAMES,
|
|
318
|
+
...FUNCTION_PROPERTY_NAMES
|
|
319
|
+
];
|
|
189
320
|
|
|
190
321
|
const config = { ...DEFAULT_CONFIGURATION };
|
|
191
322
|
|
|
@@ -194,20 +325,43 @@ function getConfiguration() {
|
|
|
194
325
|
}
|
|
195
326
|
|
|
196
327
|
function getChunkSize(config) {
|
|
197
|
-
return
|
|
328
|
+
return normalizeChunkSize(config.chunkSize);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
function normalizeChunkSize(chunkSize) {
|
|
332
|
+
chunkSize = toNumber(chunkSize);
|
|
333
|
+
return Number.isInteger(chunkSize) && chunkSize >= MINIMUM_PROPERTY_VALUE ? Math.max(chunkSize, MINIMUM_CHUNK_SIZE) : DEFAULT_CHUNK_SIZE$1;
|
|
198
334
|
}
|
|
199
335
|
|
|
200
336
|
function configure(configuration) {
|
|
201
|
-
|
|
337
|
+
Object.assign(config, checkConfiguration(normalizeConfiguration(configuration)));
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
function checkConfiguration(configuration) {
|
|
341
|
+
const checkedConfiguration = {};
|
|
202
342
|
for (const propertyName of CONFIGURABLE_PROPERTY_NAMES) {
|
|
203
343
|
const propertyValue = configuration[propertyName];
|
|
204
344
|
if (propertyValue !== UNDEFINED_VALUE) {
|
|
205
|
-
|
|
345
|
+
checkedConfiguration[propertyName] = checkPropertyValue(propertyName, propertyValue);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
return checkedConfiguration;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
function checkPropertyValue(propertyName, propertyValue) {
|
|
352
|
+
if (NUMBER_PROPERTY_NAMES.includes(propertyName)) {
|
|
353
|
+
propertyValue = toNumber(propertyValue);
|
|
354
|
+
if (propertyName == PROPERTY_NAME_MAX_WORKERS && (!Number.isInteger(propertyValue) || propertyValue < MINIMUM_PROPERTY_VALUE)) {
|
|
355
|
+
throw new Error(ERR_INVALID_MAX_WORKERS);
|
|
206
356
|
}
|
|
357
|
+
} else if (FUNCTION_PROPERTY_NAMES.includes(propertyName)) {
|
|
358
|
+
checkFunctionOption(propertyValue);
|
|
207
359
|
}
|
|
360
|
+
return propertyValue;
|
|
208
361
|
}
|
|
209
362
|
|
|
210
363
|
function normalizeConfiguration(configuration) {
|
|
364
|
+
configuration = configuration || {};
|
|
211
365
|
const { CompressionStreamZlib, DecompressionStreamZlib } = configuration;
|
|
212
366
|
if (CompressionStreamZlib === UNDEFINED_VALUE && DecompressionStreamZlib === UNDEFINED_VALUE) {
|
|
213
367
|
return configuration;
|
|
@@ -223,14 +377,9 @@ function normalizeConfiguration(configuration) {
|
|
|
223
377
|
}
|
|
224
378
|
|
|
225
379
|
function setDefaultConfiguration(configuration) {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
if (propertyValue !== UNDEFINED_VALUE) {
|
|
230
|
-
DEFAULT_CONFIGURATION[propertyName] = propertyValue;
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
configure(configuration);
|
|
380
|
+
const checkedConfiguration = checkConfiguration(normalizeConfiguration(configuration));
|
|
381
|
+
Object.assign(DEFAULT_CONFIGURATION, checkedConfiguration);
|
|
382
|
+
Object.assign(config, checkedConfiguration);
|
|
234
383
|
}
|
|
235
384
|
|
|
236
385
|
function resetConfiguration() {
|
|
@@ -1422,13 +1571,13 @@ class AESDecryptionStream extends TransformStream {
|
|
|
1422
1571
|
const {
|
|
1423
1572
|
ctr,
|
|
1424
1573
|
hmac,
|
|
1425
|
-
|
|
1574
|
+
pendingInput,
|
|
1426
1575
|
ready
|
|
1427
1576
|
} = this;
|
|
1428
1577
|
if (hmac && ctr) {
|
|
1429
1578
|
await ready;
|
|
1430
|
-
const chunkToDecrypt = subarray(
|
|
1431
|
-
const originalAuthenticationCode = subarray(
|
|
1579
|
+
const chunkToDecrypt = subarray(pendingInput, 0, pendingInput.length - AUTHENTICATION_CODE_LENGTH);
|
|
1580
|
+
const originalAuthenticationCode = subarray(pendingInput, pendingInput.length - AUTHENTICATION_CODE_LENGTH);
|
|
1432
1581
|
let decryptedChunkArray = EMPTY_UINT8_ARRAY;
|
|
1433
1582
|
if (chunkToDecrypt.length) {
|
|
1434
1583
|
const encryptedChunk = toBits(codecBytes, chunkToDecrypt);
|
|
@@ -1437,7 +1586,7 @@ class AESDecryptionStream extends TransformStream {
|
|
|
1437
1586
|
decryptedChunkArray = fromBits(codecBytes, decryptedChunk);
|
|
1438
1587
|
}
|
|
1439
1588
|
const authenticationCode = subarray(fromBits(codecBytes, hmac.digest()), 0, AUTHENTICATION_CODE_LENGTH);
|
|
1440
|
-
let invalidAuthenticationCode =
|
|
1589
|
+
let invalidAuthenticationCode = pendingInput.length < AUTHENTICATION_CODE_LENGTH ? 1 : 0;
|
|
1441
1590
|
for (let indexByte = 0; indexByte < AUTHENTICATION_CODE_LENGTH; indexByte++) {
|
|
1442
1591
|
invalidAuthenticationCode |= authenticationCode[indexByte] ^ originalAuthenticationCode[indexByte];
|
|
1443
1592
|
}
|
|
@@ -1481,14 +1630,14 @@ class AESEncryptionStream extends TransformStream {
|
|
|
1481
1630
|
const {
|
|
1482
1631
|
ctr,
|
|
1483
1632
|
hmac,
|
|
1484
|
-
|
|
1633
|
+
pendingInput,
|
|
1485
1634
|
ready
|
|
1486
1635
|
} = this;
|
|
1487
1636
|
if (hmac && ctr) {
|
|
1488
1637
|
await ready;
|
|
1489
1638
|
let encryptedChunkArray = EMPTY_UINT8_ARRAY;
|
|
1490
|
-
if (
|
|
1491
|
-
const encryptedChunk = ctr.update(toBits(codecBytes,
|
|
1639
|
+
if (pendingInput.length) {
|
|
1640
|
+
const encryptedChunk = ctr.update(toBits(codecBytes, pendingInput));
|
|
1492
1641
|
hmac.update(encryptedChunk);
|
|
1493
1642
|
encryptedChunkArray = fromBits(codecBytes, encryptedChunk);
|
|
1494
1643
|
}
|
|
@@ -1505,7 +1654,7 @@ function initAesCrypto(aesCrypto, password, rawPassword, encryptionStrength) {
|
|
|
1505
1654
|
ready: new Promise(resolve => aesCrypto.resolveReady = resolve),
|
|
1506
1655
|
password: encodePassword(password, rawPassword),
|
|
1507
1656
|
strength: encryptionStrength - 1,
|
|
1508
|
-
|
|
1657
|
+
pendingInput: EMPTY_UINT8_ARRAY
|
|
1509
1658
|
});
|
|
1510
1659
|
}
|
|
1511
1660
|
|
|
@@ -1513,10 +1662,10 @@ function append(aesCrypto, input, output, paddingStart, paddingEnd, verifyAuthen
|
|
|
1513
1662
|
const {
|
|
1514
1663
|
ctr,
|
|
1515
1664
|
hmac,
|
|
1516
|
-
|
|
1665
|
+
pendingInput
|
|
1517
1666
|
} = aesCrypto;
|
|
1518
|
-
if (
|
|
1519
|
-
input = concat(
|
|
1667
|
+
if (pendingInput.length) {
|
|
1668
|
+
input = concat(pendingInput, input);
|
|
1520
1669
|
}
|
|
1521
1670
|
const inputLength = input.length - paddingEnd;
|
|
1522
1671
|
output = expand(output, paddingStart + (inputLength - (inputLength % BLOCK_LENGTH)));
|
|
@@ -1532,7 +1681,7 @@ function append(aesCrypto, input, output, paddingStart, paddingEnd, verifyAuthen
|
|
|
1532
1681
|
}
|
|
1533
1682
|
output.set(fromBits(codecBytes, outputChunk), offset + paddingStart);
|
|
1534
1683
|
}
|
|
1535
|
-
aesCrypto.
|
|
1684
|
+
aesCrypto.pendingInput = subarray(input, offset);
|
|
1536
1685
|
return output;
|
|
1537
1686
|
}
|
|
1538
1687
|
|
|
@@ -2787,6 +2936,7 @@ function createWebWorkerInterface(workerData, config) {
|
|
|
2787
2936
|
worker,
|
|
2788
2937
|
workerAlive: false,
|
|
2789
2938
|
terminated: false,
|
|
2939
|
+
startupError: null,
|
|
2790
2940
|
interface: {
|
|
2791
2941
|
run: async () => {
|
|
2792
2942
|
try {
|
|
@@ -2814,6 +2964,13 @@ function createWebWorkerInterface(workerData, config) {
|
|
|
2814
2964
|
}
|
|
2815
2965
|
|
|
2816
2966
|
async function runWebWorker(workerData, config) {
|
|
2967
|
+
if (!workerData.worker) {
|
|
2968
|
+
const { startupError } = workerData;
|
|
2969
|
+
workerData.startupError = null;
|
|
2970
|
+
const error = startupError || new Error(ERR_WORKER_STARTUP_TIMEOUT);
|
|
2971
|
+
error.workerStartupFailed = true;
|
|
2972
|
+
throw error;
|
|
2973
|
+
}
|
|
2817
2974
|
let resolveResult, rejectResult;
|
|
2818
2975
|
const result = new Promise((resolve, reject) => {
|
|
2819
2976
|
resolveResult = resolve;
|
|
@@ -3027,11 +3184,12 @@ function onWorkerError(event, workerData) {
|
|
|
3027
3184
|
if (!workerAlive) {
|
|
3028
3185
|
workerData.worker = null;
|
|
3029
3186
|
}
|
|
3187
|
+
let error = event.error || new Error(event.message || ERROR_EVENT_TYPE);
|
|
3188
|
+
if (!workerAlive) {
|
|
3189
|
+
error = Object.assign(new Error(error.message || ERROR_EVENT_TYPE), { workerStartupFailed: true });
|
|
3190
|
+
workerData.startupError = error;
|
|
3191
|
+
}
|
|
3030
3192
|
if (rejectResult) {
|
|
3031
|
-
let error = event.error || new Error(event.message || ERROR_EVENT_TYPE);
|
|
3032
|
-
if (!workerAlive) {
|
|
3033
|
-
error = Object.assign(new Error(error.message || ERROR_EVENT_TYPE), { workerStartupFailed: true });
|
|
3034
|
-
}
|
|
3035
3193
|
rejectResult(error);
|
|
3036
3194
|
if (writer) {
|
|
3037
3195
|
writer.releaseLock();
|
|
@@ -3300,6 +3458,96 @@ async function terminateWorkers() {
|
|
|
3300
3458
|
resetWebWorkerSupport();
|
|
3301
3459
|
}
|
|
3302
3460
|
|
|
3461
|
+
/*
|
|
3462
|
+
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
3463
|
+
|
|
3464
|
+
Redistribution and use in source and binary forms, with or without
|
|
3465
|
+
modification, are permitted provided that the following conditions are met:
|
|
3466
|
+
|
|
3467
|
+
1. Redistributions of source code must retain the above copyright notice,
|
|
3468
|
+
this list of conditions and the following disclaimer.
|
|
3469
|
+
|
|
3470
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
3471
|
+
notice, this list of conditions and the following disclaimer in
|
|
3472
|
+
the documentation and/or other materials provided with the distribution.
|
|
3473
|
+
|
|
3474
|
+
3. The names of the authors may not be used to endorse or promote products
|
|
3475
|
+
derived from this software without specific prior written permission.
|
|
3476
|
+
|
|
3477
|
+
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
3478
|
+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
3479
|
+
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
3480
|
+
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
3481
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
3482
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
3483
|
+
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
3484
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
3485
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
3486
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
3487
|
+
*/
|
|
3488
|
+
|
|
3489
|
+
/* global TextDecoder */
|
|
3490
|
+
|
|
3491
|
+
const CP437 = "\0☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ".split("");
|
|
3492
|
+
const VALID_CP437 = CP437.length == 256;
|
|
3493
|
+
|
|
3494
|
+
function decodeCP437(stringValue) {
|
|
3495
|
+
if (VALID_CP437) {
|
|
3496
|
+
let result = "";
|
|
3497
|
+
for (let indexCharacter = 0; indexCharacter < stringValue.length; indexCharacter++) {
|
|
3498
|
+
result += CP437[stringValue[indexCharacter]];
|
|
3499
|
+
}
|
|
3500
|
+
return result;
|
|
3501
|
+
} else {
|
|
3502
|
+
return new TextDecoder().decode(stringValue);
|
|
3503
|
+
}
|
|
3504
|
+
}
|
|
3505
|
+
|
|
3506
|
+
/*
|
|
3507
|
+
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
3508
|
+
|
|
3509
|
+
Redistribution and use in source and binary forms, with or without
|
|
3510
|
+
modification, are permitted provided that the following conditions are met:
|
|
3511
|
+
|
|
3512
|
+
1. Redistributions of source code must retain the above copyright notice,
|
|
3513
|
+
this list of conditions and the following disclaimer.
|
|
3514
|
+
|
|
3515
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
3516
|
+
notice, this list of conditions and the following disclaimer in
|
|
3517
|
+
the documentation and/or other materials provided with the distribution.
|
|
3518
|
+
|
|
3519
|
+
3. The names of the authors may not be used to endorse or promote products
|
|
3520
|
+
derived from this software without specific prior written permission.
|
|
3521
|
+
|
|
3522
|
+
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
3523
|
+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
3524
|
+
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
3525
|
+
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
3526
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
3527
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
3528
|
+
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
3529
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
3530
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
3531
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
3532
|
+
*/
|
|
3533
|
+
|
|
3534
|
+
|
|
3535
|
+
function decodeText(value, encoding) {
|
|
3536
|
+
return decode(value, encoding, true);
|
|
3537
|
+
}
|
|
3538
|
+
|
|
3539
|
+
function decodeTextRemovingBOM(value, encoding) {
|
|
3540
|
+
return decode(value, encoding, false);
|
|
3541
|
+
}
|
|
3542
|
+
|
|
3543
|
+
function decode(value, encoding, ignoreBOM) {
|
|
3544
|
+
if (encoding && encoding.trim().toLowerCase() == "cp437") {
|
|
3545
|
+
return decodeCP437(value);
|
|
3546
|
+
} else {
|
|
3547
|
+
return new TextDecoder(encoding, { ignoreBOM }).decode(value);
|
|
3548
|
+
}
|
|
3549
|
+
}
|
|
3550
|
+
|
|
3303
3551
|
/*
|
|
3304
3552
|
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
3305
3553
|
|
|
@@ -3372,6 +3620,7 @@ class Reader extends Stream {
|
|
|
3372
3620
|
createReadable({ offset = 0, size, chunkSize = getChunkSize(getConfiguration()) } = {}) {
|
|
3373
3621
|
const reader = this;
|
|
3374
3622
|
let chunkOffset = 0;
|
|
3623
|
+
chunkSize = normalizeChunkSize(chunkSize);
|
|
3375
3624
|
return new ReadableStream({
|
|
3376
3625
|
async pull(controller) {
|
|
3377
3626
|
const dataSize = size === UNDEFINED_VALUE ? chunkSize : Math.min(chunkSize, size - chunkOffset);
|
|
@@ -3379,7 +3628,7 @@ class Reader extends Stream {
|
|
|
3379
3628
|
if (data.length) {
|
|
3380
3629
|
controller.enqueue(data);
|
|
3381
3630
|
}
|
|
3382
|
-
if ((chunkOffset + chunkSize >= size) || (
|
|
3631
|
+
if ((chunkOffset + chunkSize >= size) || (!data.length && dataSize)) {
|
|
3383
3632
|
controller.close();
|
|
3384
3633
|
} else {
|
|
3385
3634
|
chunkOffset += chunkSize;
|
|
@@ -3459,31 +3708,31 @@ class Data64URIWriter extends Writer {
|
|
|
3459
3708
|
Object.assign(this, {
|
|
3460
3709
|
contentType,
|
|
3461
3710
|
data: "data:" + (contentType || "") + ";base64,",
|
|
3462
|
-
|
|
3711
|
+
pendingCharacters: ""
|
|
3463
3712
|
});
|
|
3464
3713
|
}
|
|
3465
3714
|
|
|
3466
3715
|
writeUint8Array(array) {
|
|
3467
3716
|
const writer = this;
|
|
3468
3717
|
let indexArray;
|
|
3469
|
-
let dataString = writer.
|
|
3470
|
-
const delta = writer.
|
|
3471
|
-
writer.
|
|
3718
|
+
let dataString = writer.pendingCharacters;
|
|
3719
|
+
const delta = writer.pendingCharacters.length;
|
|
3720
|
+
writer.pendingCharacters = "";
|
|
3472
3721
|
for (indexArray = 0; indexArray < (Math.floor((delta + array.length) / 3) * 3) - delta; indexArray++) {
|
|
3473
3722
|
dataString += String.fromCharCode(array[indexArray]);
|
|
3474
3723
|
}
|
|
3475
3724
|
for (; indexArray < array.length; indexArray++) {
|
|
3476
|
-
writer.
|
|
3725
|
+
writer.pendingCharacters += String.fromCharCode(array[indexArray]);
|
|
3477
3726
|
}
|
|
3478
3727
|
if (dataString.length > 2) {
|
|
3479
3728
|
writer.data += btoa(dataString);
|
|
3480
3729
|
} else {
|
|
3481
|
-
writer.
|
|
3730
|
+
writer.pendingCharacters = dataString + writer.pendingCharacters;
|
|
3482
3731
|
}
|
|
3483
3732
|
}
|
|
3484
3733
|
|
|
3485
3734
|
getData() {
|
|
3486
|
-
return this.data + btoa(this.
|
|
3735
|
+
return this.data + btoa(this.pendingCharacters);
|
|
3487
3736
|
}
|
|
3488
3737
|
}
|
|
3489
3738
|
|
|
@@ -3513,7 +3762,7 @@ class BlobReader extends Reader {
|
|
|
3513
3762
|
constructor(blob) {
|
|
3514
3763
|
super();
|
|
3515
3764
|
Object.assign(this, {
|
|
3516
|
-
blob,
|
|
3765
|
+
sourceBlob: blob,
|
|
3517
3766
|
size: blob.size
|
|
3518
3767
|
});
|
|
3519
3768
|
if (!blobSliceProbe) {
|
|
@@ -3523,13 +3772,13 @@ class BlobReader extends Reader {
|
|
|
3523
3772
|
|
|
3524
3773
|
createReadable(options) {
|
|
3525
3774
|
const reader = this;
|
|
3526
|
-
const {
|
|
3775
|
+
const { sourceBlob, size } = reader;
|
|
3527
3776
|
const { offset = 0, size: readSize = size - offset } = options || {};
|
|
3528
3777
|
if (!offset && readSize >= size) {
|
|
3529
|
-
return toCompatibleReadable(
|
|
3778
|
+
return toCompatibleReadable(sourceBlob.stream());
|
|
3530
3779
|
}
|
|
3531
3780
|
if (blobSliceReliable) {
|
|
3532
|
-
return toCompatibleReadable(
|
|
3781
|
+
return toCompatibleReadable(sourceBlob.slice(offset, offset + readSize).stream());
|
|
3533
3782
|
}
|
|
3534
3783
|
return super.createReadable(options);
|
|
3535
3784
|
}
|
|
@@ -3538,7 +3787,7 @@ class BlobReader extends Reader {
|
|
|
3538
3787
|
const reader = this;
|
|
3539
3788
|
const offsetEnd = offset + length;
|
|
3540
3789
|
const readsWholeBlob = !offset && offsetEnd >= reader.size;
|
|
3541
|
-
const blob = readsWholeBlob ? reader.
|
|
3790
|
+
const blob = readsWholeBlob ? reader.sourceBlob : reader.sourceBlob.slice(offset, offsetEnd);
|
|
3542
3791
|
let arrayBuffer = await blob.arrayBuffer();
|
|
3543
3792
|
const sliceIgnoredByBuggyImplementation = arrayBuffer.byteLength > length;
|
|
3544
3793
|
if (sliceIgnoredByBuggyImplementation) {
|
|
@@ -3560,12 +3809,12 @@ class BlobWriter extends Stream {
|
|
|
3560
3809
|
}
|
|
3561
3810
|
});
|
|
3562
3811
|
writer.contentType = contentType;
|
|
3563
|
-
writer.
|
|
3564
|
-
writer.
|
|
3812
|
+
writer.blobPromise = streamToBlob(transformStream.readable, contentType);
|
|
3813
|
+
writer.blobPromise.catch(() => { });
|
|
3565
3814
|
}
|
|
3566
3815
|
|
|
3567
3816
|
getData() {
|
|
3568
|
-
return this.
|
|
3817
|
+
return this.blobPromise;
|
|
3569
3818
|
}
|
|
3570
3819
|
}
|
|
3571
3820
|
|
|
@@ -3599,7 +3848,7 @@ function getTextSize(text) {
|
|
|
3599
3848
|
class TextWriter extends BlobWriter {
|
|
3600
3849
|
|
|
3601
3850
|
constructor(encoding) {
|
|
3602
|
-
super(
|
|
3851
|
+
super();
|
|
3603
3852
|
Object.assign(this, {
|
|
3604
3853
|
encoding,
|
|
3605
3854
|
utf8: !encoding || encoding.toLowerCase() == "utf-8"
|
|
@@ -3615,14 +3864,7 @@ class TextWriter extends BlobWriter {
|
|
|
3615
3864
|
if (blob.text && utf8) {
|
|
3616
3865
|
return blob.text();
|
|
3617
3866
|
} else {
|
|
3618
|
-
|
|
3619
|
-
return new Promise((resolve, reject) => {
|
|
3620
|
-
Object.assign(reader, {
|
|
3621
|
-
onload: ({ target }) => resolve(target.result),
|
|
3622
|
-
onerror: () => reject(reader.error)
|
|
3623
|
-
});
|
|
3624
|
-
reader.readAsText(blob, encoding);
|
|
3625
|
-
});
|
|
3867
|
+
return decodeTextRemovingBOM(new Uint8Array(await blob.arrayBuffer()), encoding);
|
|
3626
3868
|
}
|
|
3627
3869
|
}
|
|
3628
3870
|
}
|
|
@@ -4080,9 +4322,8 @@ class SplitDataReader extends Reader {
|
|
|
4080
4322
|
|
|
4081
4323
|
async init() {
|
|
4082
4324
|
const reader = this;
|
|
4083
|
-
const { readers } = reader;
|
|
4084
4325
|
reader.lastDiskNumber = 0;
|
|
4085
|
-
await Promise.all(readers.map(
|
|
4326
|
+
const readers = reader.readers = await Promise.all(reader.readers.map(initDiskReader));
|
|
4086
4327
|
reader.diskOffsets = readers.map(diskReader => {
|
|
4087
4328
|
const diskOffset = reader.size;
|
|
4088
4329
|
reader.size += diskReader.size;
|
|
@@ -4277,89 +4518,27 @@ async function initStream(stream, initSize) {
|
|
|
4277
4518
|
}
|
|
4278
4519
|
}
|
|
4279
4520
|
|
|
4280
|
-
function
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
Redistribution and use in source and binary forms, with or without
|
|
4288
|
-
modification, are permitted provided that the following conditions are met:
|
|
4289
|
-
|
|
4290
|
-
1. Redistributions of source code must retain the above copyright notice,
|
|
4291
|
-
this list of conditions and the following disclaimer.
|
|
4292
|
-
|
|
4293
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
4294
|
-
notice, this list of conditions and the following disclaimer in
|
|
4295
|
-
the documentation and/or other materials provided with the distribution.
|
|
4296
|
-
|
|
4297
|
-
3. The names of the authors may not be used to endorse or promote products
|
|
4298
|
-
derived from this software without specific prior written permission.
|
|
4299
|
-
|
|
4300
|
-
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
4301
|
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
4302
|
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
4303
|
-
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
4304
|
-
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
4305
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
4306
|
-
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
4307
|
-
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
4308
|
-
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
4309
|
-
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
4310
|
-
*/
|
|
4311
|
-
|
|
4312
|
-
/* global TextDecoder */
|
|
4313
|
-
|
|
4314
|
-
const CP437 = "\0☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ".split("");
|
|
4315
|
-
const VALID_CP437 = CP437.length == 256;
|
|
4316
|
-
|
|
4317
|
-
function decodeCP437(stringValue) {
|
|
4318
|
-
if (VALID_CP437) {
|
|
4319
|
-
let result = "";
|
|
4320
|
-
for (let indexCharacter = 0; indexCharacter < stringValue.length; indexCharacter++) {
|
|
4321
|
-
result += CP437[stringValue[indexCharacter]];
|
|
4322
|
-
}
|
|
4323
|
-
return result;
|
|
4324
|
-
} else {
|
|
4325
|
-
return new TextDecoder().decode(stringValue);
|
|
4521
|
+
async function initDiskReader(diskReader) {
|
|
4522
|
+
diskReader = new GenericReader(diskReader);
|
|
4523
|
+
await initStream(diskReader);
|
|
4524
|
+
if (diskReader.size === UNDEFINED_VALUE || !diskReader.readUint8Array) {
|
|
4525
|
+
diskReader = new BlobReader(await streamToBlob(diskReader.readable));
|
|
4526
|
+
await initStream(diskReader);
|
|
4326
4527
|
}
|
|
4528
|
+
return diskReader;
|
|
4327
4529
|
}
|
|
4328
4530
|
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
Redistribution and use in source and binary forms, with or without
|
|
4333
|
-
modification, are permitted provided that the following conditions are met:
|
|
4334
|
-
|
|
4335
|
-
1. Redistributions of source code must retain the above copyright notice,
|
|
4336
|
-
this list of conditions and the following disclaimer.
|
|
4337
|
-
|
|
4338
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
4339
|
-
notice, this list of conditions and the following disclaimer in
|
|
4340
|
-
the documentation and/or other materials provided with the distribution.
|
|
4341
|
-
|
|
4342
|
-
3. The names of the authors may not be used to endorse or promote products
|
|
4343
|
-
derived from this software without specific prior written permission.
|
|
4344
|
-
|
|
4345
|
-
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
4346
|
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
4347
|
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
4348
|
-
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
4349
|
-
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
4350
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
4351
|
-
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
4352
|
-
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
4353
|
-
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
4354
|
-
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
4355
|
-
*/
|
|
4356
|
-
|
|
4531
|
+
function readUint8Array(reader, offset, size) {
|
|
4532
|
+
return reader.readUint8Array(offset, size);
|
|
4533
|
+
}
|
|
4357
4534
|
|
|
4358
|
-
function
|
|
4359
|
-
if (
|
|
4360
|
-
return
|
|
4535
|
+
function createReadable(reader, options) {
|
|
4536
|
+
if (reader.createReadable) {
|
|
4537
|
+
return reader.createReadable(options);
|
|
4538
|
+
} else if (reader.readUint8Array) {
|
|
4539
|
+
return Reader.prototype.createReadable.call(reader, options);
|
|
4361
4540
|
} else {
|
|
4362
|
-
return
|
|
4541
|
+
return reader.readable;
|
|
4363
4542
|
}
|
|
4364
4543
|
}
|
|
4365
4544
|
|
|
@@ -4435,6 +4614,10 @@ const PROPERTY_NAME_SETUID = "setuid";
|
|
|
4435
4614
|
const PROPERTY_NAME_SETGID = "setgid";
|
|
4436
4615
|
const PROPERTY_NAME_STICKY = "sticky";
|
|
4437
4616
|
const PROPERTY_NAME_BITFLAG = "bitFlag";
|
|
4617
|
+
const PROPERTY_NAME_RAW_BITFLAG = "rawBitFlag";
|
|
4618
|
+
const PROPERTY_NAME_FILENAME_LENGTH = "filenameLength";
|
|
4619
|
+
const PROPERTY_NAME_EXTRA_FIELD_LENGTH = "extraFieldLength";
|
|
4620
|
+
const PROPERTY_NAME_UNIX_EXTERNAL_UPPER = "unixExternalUpper";
|
|
4438
4621
|
const PROPERTY_NAME_FILENAME_UTF8 = "filenameUTF8";
|
|
4439
4622
|
const PROPERTY_NAME_COMMENT_UTF8 = "commentUTF8";
|
|
4440
4623
|
const PROPERTY_NAME_RAW_EXTRA_FIELD = "rawExtraField";
|
|
@@ -4487,10 +4670,14 @@ const PROPERTY_NAMES = [
|
|
|
4487
4670
|
PROPERTY_NAME_UID,
|
|
4488
4671
|
PROPERTY_NAME_GID,
|
|
4489
4672
|
PROPERTY_NAME_UNIX_MODE,
|
|
4673
|
+
PROPERTY_NAME_UNIX_EXTERNAL_UPPER,
|
|
4490
4674
|
PROPERTY_NAME_SETUID,
|
|
4491
4675
|
PROPERTY_NAME_SETGID,
|
|
4492
4676
|
PROPERTY_NAME_STICKY,
|
|
4493
4677
|
PROPERTY_NAME_BITFLAG,
|
|
4678
|
+
PROPERTY_NAME_RAW_BITFLAG,
|
|
4679
|
+
PROPERTY_NAME_FILENAME_LENGTH,
|
|
4680
|
+
PROPERTY_NAME_EXTRA_FIELD_LENGTH,
|
|
4494
4681
|
PROPERTY_NAME_FILENAME_UTF8,
|
|
4495
4682
|
PROPERTY_NAME_COMMENT_UTF8,
|
|
4496
4683
|
PROPERTY_NAME_RAW_EXTRA_FIELD,
|
|
@@ -4511,82 +4698,6 @@ class Entry {
|
|
|
4511
4698
|
|
|
4512
4699
|
}
|
|
4513
4700
|
|
|
4514
|
-
/*
|
|
4515
|
-
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
4516
|
-
|
|
4517
|
-
Redistribution and use in source and binary forms, with or without
|
|
4518
|
-
modification, are permitted provided that the following conditions are met:
|
|
4519
|
-
|
|
4520
|
-
1. Redistributions of source code must retain the above copyright notice,
|
|
4521
|
-
this list of conditions and the following disclaimer.
|
|
4522
|
-
|
|
4523
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
4524
|
-
notice, this list of conditions and the following disclaimer in
|
|
4525
|
-
the documentation and/or other materials provided with the distribution.
|
|
4526
|
-
|
|
4527
|
-
3. The names of the authors may not be used to endorse or promote products
|
|
4528
|
-
derived from this software without specific prior written permission.
|
|
4529
|
-
|
|
4530
|
-
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
4531
|
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
4532
|
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
4533
|
-
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
4534
|
-
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
4535
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
4536
|
-
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
4537
|
-
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
4538
|
-
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
4539
|
-
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
4540
|
-
*/
|
|
4541
|
-
|
|
4542
|
-
const OPTION_FILENAME_ENCODING = "filenameEncoding";
|
|
4543
|
-
const OPTION_COMMENT_ENCODING = "commentEncoding";
|
|
4544
|
-
const OPTION_DECODE_TEXT = "decodeText";
|
|
4545
|
-
const OPTION_EXTRACT_PREPENDED_DATA = "extractPrependedData";
|
|
4546
|
-
const OPTION_EXTRACT_APPENDED_DATA = "extractAppendedData";
|
|
4547
|
-
const OPTION_PASSWORD = "password";
|
|
4548
|
-
const OPTION_RAW_PASSWORD = "rawPassword";
|
|
4549
|
-
const OPTION_PASS_THROUGH = "passThrough";
|
|
4550
|
-
const OPTION_SIGNAL = "signal";
|
|
4551
|
-
const OPTION_CHECK_PASSWORD_ONLY = "checkPasswordOnly";
|
|
4552
|
-
const OPTION_CHECK_OVERLAPPING_ENTRY_ONLY = "checkOverlappingEntryOnly";
|
|
4553
|
-
const OPTION_CHECK_OVERLAPPING_ENTRY = "checkOverlappingEntry";
|
|
4554
|
-
const OPTION_CHECK_AMBIGUITY = "checkAmbiguity";
|
|
4555
|
-
const OPTION_CHECK_SIGNATURE = "checkSignature";
|
|
4556
|
-
const OPTION_CHECK_CRC32 = "checkCrc32";
|
|
4557
|
-
const OPTION_CHECK_AUTHENTICATION_CODE = "checkAuthenticationCode";
|
|
4558
|
-
const OPTION_USE_WEB_WORKERS = "useWebWorkers";
|
|
4559
|
-
const OPTION_USE_COMPRESSION_STREAM = "useCompressionStream";
|
|
4560
|
-
const OPTION_TRANSFER_STREAMS = "transferStreams";
|
|
4561
|
-
const OPTION_PREVENT_CLOSE = "preventClose";
|
|
4562
|
-
const OPTION_ENCRYPTION_STRENGTH = "encryptionStrength";
|
|
4563
|
-
const OPTION_EXTENDED_TIMESTAMP = "extendedTimestamp";
|
|
4564
|
-
const OPTION_NTFS_TIMESTAMP = "ntfsTimestamp";
|
|
4565
|
-
const OPTION_KEEP_ORDER = "keepOrder";
|
|
4566
|
-
const OPTION_LEVEL = "level";
|
|
4567
|
-
const OPTION_BUFFERED_WRITE = "bufferedWrite";
|
|
4568
|
-
const OPTION_CREATE_TEMP_STREAM = "createTempStream";
|
|
4569
|
-
const OPTION_DATA_DESCRIPTOR_SIGNATURE = "dataDescriptorSignature";
|
|
4570
|
-
const OPTION_USE_UNICODE_FILE_NAMES = "useUnicodeFileNames";
|
|
4571
|
-
const OPTION_DATA_DESCRIPTOR = "dataDescriptor";
|
|
4572
|
-
const OPTION_SUPPORT_ZIP64_SPLIT_FILE = "supportZip64SplitFile";
|
|
4573
|
-
const OPTION_ENCODE_TEXT = "encodeText";
|
|
4574
|
-
const OPTION_OFFSET = "offset";
|
|
4575
|
-
const OPTION_USDZ = "usdz";
|
|
4576
|
-
const OPTION_UNIX_EXTRA_FIELD_TYPE = "unixExtraFieldType";
|
|
4577
|
-
const OPTION_LOCAL_EXTRA_FIELD = "localExtraField";
|
|
4578
|
-
const OPTION_STRICTNESS = "strictness";
|
|
4579
|
-
const OPTION_FILENAME_VALIDATION = "filenameValidation";
|
|
4580
|
-
const OPTION_NORMALIZE_FILENAME = "normalizeFilename";
|
|
4581
|
-
const OPTION_MAX_APPENDED_DATA_SIZE = "maxAppendedDataSize";
|
|
4582
|
-
const OPTION_DECRYPT_CENTRAL_DIRECTORY = "decryptCentralDirectory";
|
|
4583
|
-
const OPTION_SIGN_CENTRAL_DIRECTORY = "signCentralDirectory";
|
|
4584
|
-
const TEXT_TYPE_FILENAME = "filename";
|
|
4585
|
-
const TEXT_TYPE_COMMENT = "comment";
|
|
4586
|
-
const STRICTNESS_STRICT = "strict";
|
|
4587
|
-
const STRICTNESS_BALANCED = "balanced";
|
|
4588
|
-
const STRICTNESS_TOLERANT = "tolerant";
|
|
4589
|
-
|
|
4590
4701
|
/*
|
|
4591
4702
|
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
4592
4703
|
|
|
@@ -4627,6 +4738,7 @@ const ERR_UNSUPPORTED_ENCRYPTION = "Encryption method not supported";
|
|
|
4627
4738
|
const ERR_UNSUPPORTED_COMPRESSION$1 = "Compression method not supported";
|
|
4628
4739
|
const ERR_SPLIT_ZIP_FILE = "Split zip file";
|
|
4629
4740
|
const ERR_OVERLAPPING_ENTRY = "Overlapping entry found";
|
|
4741
|
+
const ERR_ENTRY_DATA_OUT_OF_BOUNDS = "Entry data out of bounds";
|
|
4630
4742
|
const ERR_AMBIGUOUS_ARCHIVE = "Ambiguous archive";
|
|
4631
4743
|
const ERR_ENCRYPTED_CENTRAL_DIRECTORY = "Encrypted central directory is not supported";
|
|
4632
4744
|
const ERR_UNSAFE_FILENAME = "Unsafe filename";
|
|
@@ -4647,7 +4759,7 @@ const ZIP64_PROPERTIES = [
|
|
|
4647
4759
|
];
|
|
4648
4760
|
const ZIP64_EXTRACTION = {
|
|
4649
4761
|
[MAX_16_BITS]: {
|
|
4650
|
-
getValue: getUint32,
|
|
4762
|
+
getValue: getUint32$1,
|
|
4651
4763
|
bytes: 4
|
|
4652
4764
|
},
|
|
4653
4765
|
[MAX_32_BITS]: {
|
|
@@ -4656,6 +4768,7 @@ const ZIP64_EXTRACTION = {
|
|
|
4656
4768
|
}
|
|
4657
4769
|
};
|
|
4658
4770
|
const MAX_END_OF_CENTRAL_DIR_PROBES = 64;
|
|
4771
|
+
const MAX_DEFLATE_EXPANSION_RATIO = 1032;
|
|
4659
4772
|
const CENTRAL_DIRECTORY_UNREACHABLE = 0;
|
|
4660
4773
|
const CENTRAL_DIRECTORY_PLAUSIBLE = 1;
|
|
4661
4774
|
const CENTRAL_DIRECTORY_REACHABLE = 2;
|
|
@@ -4666,7 +4779,6 @@ class ZipReader {
|
|
|
4666
4779
|
Object.assign(this, {
|
|
4667
4780
|
reader: new GenericReader(reader),
|
|
4668
4781
|
options,
|
|
4669
|
-
config: getConfiguration(),
|
|
4670
4782
|
readRanges: new Map()
|
|
4671
4783
|
});
|
|
4672
4784
|
}
|
|
@@ -4674,7 +4786,6 @@ class ZipReader {
|
|
|
4674
4786
|
async* getEntriesGenerator(options = {}) {
|
|
4675
4787
|
const zipReader = this;
|
|
4676
4788
|
let { reader } = zipReader;
|
|
4677
|
-
const { config } = zipReader;
|
|
4678
4789
|
await initStream(reader);
|
|
4679
4790
|
if (reader.size === UNDEFINED_VALUE || !reader.readUint8Array) {
|
|
4680
4791
|
reader = new BlobReader(await streamToBlob(reader.readable));
|
|
@@ -4683,7 +4794,7 @@ class ZipReader {
|
|
|
4683
4794
|
if (reader.size < END_OF_CENTRAL_DIR_LENGTH) {
|
|
4684
4795
|
throw new Error(ERR_BAD_FORMAT);
|
|
4685
4796
|
}
|
|
4686
|
-
const strictness = getStrictness(
|
|
4797
|
+
const strictness = getStrictness(options, zipReader.options);
|
|
4687
4798
|
const checkAmbiguity = strictness == STRICTNESS_STRICT;
|
|
4688
4799
|
const rejectAmbiguousEndOfDirectory = strictness != STRICTNESS_TOLERANT;
|
|
4689
4800
|
const maxAppendedDataSize = getMaxAppendedDataSize(getOptionValue$1(zipReader, options, OPTION_MAX_APPENDED_DATA_SIZE), strictness);
|
|
@@ -4691,9 +4802,7 @@ class ZipReader {
|
|
|
4691
4802
|
const normalizeFilename = getOptionValue$1(zipReader, options, OPTION_NORMALIZE_FILENAME);
|
|
4692
4803
|
const { endOfDirectoryInfo, endOfDirectoryReachingEndCount } = await findEndOfCentralDirectory(reader, rejectAmbiguousEndOfDirectory, maxAppendedDataSize);
|
|
4693
4804
|
if (!endOfDirectoryInfo) {
|
|
4694
|
-
|
|
4695
|
-
const signatureView = getDataView(signatureArray);
|
|
4696
|
-
if (getUint32(signatureView) == SPLIT_ZIP_FILE_SIGNATURE) {
|
|
4805
|
+
if (await startsWithSplitZipSignature$1(reader)) {
|
|
4697
4806
|
throw new Error(ERR_SPLIT_ZIP_FILE);
|
|
4698
4807
|
} else {
|
|
4699
4808
|
throw new Error(ERR_EOCDR_NOT_FOUND);
|
|
@@ -4703,18 +4812,18 @@ class ZipReader {
|
|
|
4703
4812
|
throwAmbiguousArchive("multiple end of central directory records");
|
|
4704
4813
|
}
|
|
4705
4814
|
const endOfDirectoryView = getDataView(endOfDirectoryInfo);
|
|
4706
|
-
let directoryDataLength = getUint32(endOfDirectoryView, 12);
|
|
4707
|
-
let directoryDataOffset = getUint32(endOfDirectoryView, 16);
|
|
4815
|
+
let directoryDataLength = getUint32$1(endOfDirectoryView, 12);
|
|
4816
|
+
let directoryDataOffset = getUint32$1(endOfDirectoryView, 16);
|
|
4708
4817
|
const commentOffset = endOfDirectoryInfo.offset;
|
|
4709
|
-
const commentLength = getUint16(endOfDirectoryView, 20);
|
|
4818
|
+
const commentLength = getUint16$1(endOfDirectoryView, 20);
|
|
4710
4819
|
const appendedDataOffset = commentOffset + END_OF_CENTRAL_DIR_LENGTH + commentLength;
|
|
4711
4820
|
if (reader.size - appendedDataOffset > maxAppendedDataSize) {
|
|
4712
4821
|
throwAmbiguousArchive("appended data");
|
|
4713
4822
|
}
|
|
4714
|
-
let lastDiskNumber = getUint16(endOfDirectoryView, 4);
|
|
4823
|
+
let lastDiskNumber = getUint16$1(endOfDirectoryView, 4);
|
|
4715
4824
|
const expectedLastDiskNumber = reader.lastDiskNumber || 0;
|
|
4716
|
-
let diskNumber = getUint16(endOfDirectoryView, 6);
|
|
4717
|
-
let filesLength = getUint16(endOfDirectoryView, 10);
|
|
4825
|
+
let diskNumber = getUint16$1(endOfDirectoryView, 6);
|
|
4826
|
+
let filesLength = getUint16$1(endOfDirectoryView, 10);
|
|
4718
4827
|
let prependedDataLength = 0;
|
|
4719
4828
|
let startOffset;
|
|
4720
4829
|
let zip64EndOfDirectory;
|
|
@@ -4730,12 +4839,12 @@ class ZipReader {
|
|
|
4730
4839
|
EMPTY_UINT8_ARRAY;
|
|
4731
4840
|
const endOfDirectoryLocatorView = getDataView(endOfDirectoryLocatorArray);
|
|
4732
4841
|
if (endOfDirectoryLocatorArray.length == ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH &&
|
|
4733
|
-
getUint32(endOfDirectoryLocatorView, 0) == ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE) {
|
|
4734
|
-
directoryDataOffset = getDiskOffset$1(reader, getUint32(endOfDirectoryLocatorView, 4)) + getBigUint64(endOfDirectoryLocatorView, 8);
|
|
4842
|
+
getUint32$1(endOfDirectoryLocatorView, 0) == ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE) {
|
|
4843
|
+
directoryDataOffset = getDiskOffset$1(reader, getUint32$1(endOfDirectoryLocatorView, 4)) + getBigUint64(endOfDirectoryLocatorView, 8);
|
|
4735
4844
|
let endOfDirectoryArray = await readUint8Array(reader, directoryDataOffset, ZIP64_END_OF_CENTRAL_DIR_LENGTH);
|
|
4736
4845
|
let endOfDirectoryView = getDataView(endOfDirectoryArray);
|
|
4737
4846
|
const expectedDirectoryDataOffset = endOfDirectoryInfo.offset - ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH - ZIP64_END_OF_CENTRAL_DIR_LENGTH;
|
|
4738
|
-
if ((endOfDirectoryArray.length < ZIP64_END_OF_CENTRAL_DIR_LENGTH || getUint32(endOfDirectoryView, 0) != ZIP64_END_OF_CENTRAL_DIR_SIGNATURE) &&
|
|
4847
|
+
if ((endOfDirectoryArray.length < ZIP64_END_OF_CENTRAL_DIR_LENGTH || getUint32$1(endOfDirectoryView, 0) != ZIP64_END_OF_CENTRAL_DIR_SIGNATURE) &&
|
|
4739
4848
|
directoryDataOffset != expectedDirectoryDataOffset && expectedDirectoryDataOffset >= 0) {
|
|
4740
4849
|
const originalDirectoryDataOffset = directoryDataOffset;
|
|
4741
4850
|
directoryDataOffset = expectedDirectoryDataOffset;
|
|
@@ -4745,7 +4854,7 @@ class ZipReader {
|
|
|
4745
4854
|
endOfDirectoryArray = await readUint8Array(reader, directoryDataOffset, ZIP64_END_OF_CENTRAL_DIR_LENGTH);
|
|
4746
4855
|
endOfDirectoryView = getDataView(endOfDirectoryArray);
|
|
4747
4856
|
}
|
|
4748
|
-
if (endOfDirectoryArray.length < ZIP64_END_OF_CENTRAL_DIR_LENGTH || getUint32(endOfDirectoryView, 0) != ZIP64_END_OF_CENTRAL_DIR_SIGNATURE) {
|
|
4857
|
+
if (endOfDirectoryArray.length < ZIP64_END_OF_CENTRAL_DIR_LENGTH || getUint32$1(endOfDirectoryView, 0) != ZIP64_END_OF_CENTRAL_DIR_SIGNATURE) {
|
|
4749
4858
|
throw new Error(ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND);
|
|
4750
4859
|
}
|
|
4751
4860
|
zip64EndOfDirectory = true;
|
|
@@ -4760,13 +4869,13 @@ class ZipReader {
|
|
|
4760
4869
|
}
|
|
4761
4870
|
}
|
|
4762
4871
|
if (lastDiskNumber == MAX_16_BITS) {
|
|
4763
|
-
lastDiskNumber = getUint32(endOfDirectoryView, 16);
|
|
4764
|
-
} else if (checkAmbiguity && lastDiskNumber != getUint32(endOfDirectoryView, 16)) {
|
|
4872
|
+
lastDiskNumber = getUint32$1(endOfDirectoryView, 16);
|
|
4873
|
+
} else if (checkAmbiguity && lastDiskNumber != getUint32$1(endOfDirectoryView, 16)) {
|
|
4765
4874
|
throwAmbiguousArchive("mismatched zip64 end of central directory record");
|
|
4766
4875
|
}
|
|
4767
4876
|
if (diskNumber == MAX_16_BITS) {
|
|
4768
|
-
diskNumber = getUint32(endOfDirectoryView, 20);
|
|
4769
|
-
} else if (checkAmbiguity && diskNumber != getUint32(endOfDirectoryView, 20)) {
|
|
4877
|
+
diskNumber = getUint32$1(endOfDirectoryView, 20);
|
|
4878
|
+
} else if (checkAmbiguity && diskNumber != getUint32$1(endOfDirectoryView, 20)) {
|
|
4770
4879
|
throwAmbiguousArchive("mismatched zip64 end of central directory record");
|
|
4771
4880
|
}
|
|
4772
4881
|
if (filesLength == MAX_16_BITS) {
|
|
@@ -4804,11 +4913,11 @@ class ZipReader {
|
|
|
4804
4913
|
}
|
|
4805
4914
|
const expectedDirectoryDataOffset = centralDirectoryEndOffset - directoryDataLength;
|
|
4806
4915
|
if (directoryDataOffset != expectedDirectoryDataOffset && diskNumber == lastDiskNumber) {
|
|
4807
|
-
const storedPointsAtDirectory = getUint32(directoryView, offset) == CENTRAL_FILE_HEADER_SIGNATURE;
|
|
4916
|
+
const storedPointsAtDirectory = getUint32$1(directoryView, offset) == CENTRAL_FILE_HEADER_SIGNATURE;
|
|
4808
4917
|
let reconcile = !storedPointsAtDirectory;
|
|
4809
4918
|
if (!reconcile && expectedDirectoryDataOffset >= 0 && expectedDirectoryDataOffset + 4 <= reader.size) {
|
|
4810
4919
|
const expectedSignatureArray = await readUint8Array(reader, expectedDirectoryDataOffset, 4);
|
|
4811
|
-
reconcile = getUint32(getDataView(expectedSignatureArray), 0) == CENTRAL_FILE_HEADER_SIGNATURE;
|
|
4920
|
+
reconcile = getUint32$1(getDataView(expectedSignatureArray), 0) == CENTRAL_FILE_HEADER_SIGNATURE;
|
|
4812
4921
|
}
|
|
4813
4922
|
if (reconcile) {
|
|
4814
4923
|
const originalDirectoryDataOffset = directoryDataOffset;
|
|
@@ -4832,10 +4941,10 @@ class ZipReader {
|
|
|
4832
4941
|
}
|
|
4833
4942
|
zipReader.directoryOffset = directoryDataOffset;
|
|
4834
4943
|
zipReader.directoryLength = declaredDirectoryDataLength;
|
|
4835
|
-
const decryptCentralDirectory =
|
|
4944
|
+
const decryptCentralDirectory = getFunctionOptionValue$1(zipReader, options, OPTION_DECRYPT_CENTRAL_DIRECTORY);
|
|
4836
4945
|
let decryptedDirectory;
|
|
4837
4946
|
if (decryptCentralDirectory && filesLength && directoryArray.length >= 4 &&
|
|
4838
|
-
getUint32(directoryView, 0) != CENTRAL_FILE_HEADER_SIGNATURE &&
|
|
4947
|
+
getUint32$1(directoryView, 0) != CENTRAL_FILE_HEADER_SIGNATURE &&
|
|
4839
4948
|
(zip64EndOfDirectoryVersion2 || detectEncryptedCentralDirectory(directoryView))) {
|
|
4840
4949
|
directoryArray = await decryptCentralDirectory(directoryArray, directoryEncryptionInfo);
|
|
4841
4950
|
directoryView = getDataView(directoryArray);
|
|
@@ -4848,8 +4957,8 @@ class ZipReader {
|
|
|
4848
4957
|
const filenames = checkAmbiguity ? new Set() : UNDEFINED_VALUE;
|
|
4849
4958
|
let duplicateFilename;
|
|
4850
4959
|
for (let indexFile = 0; indexFile < filesLength; indexFile++) {
|
|
4851
|
-
const fileEntry = new ZipEntry$1(reader,
|
|
4852
|
-
if (offset + CENTRAL_FILE_HEADER_LENGTH > directoryArray.length || getUint32(directoryView, offset) != CENTRAL_FILE_HEADER_SIGNATURE) {
|
|
4960
|
+
const fileEntry = new ZipEntry$1(reader, zipReader.options);
|
|
4961
|
+
if (offset + CENTRAL_FILE_HEADER_LENGTH > directoryArray.length || getUint32$1(directoryView, offset) != CENTRAL_FILE_HEADER_SIGNATURE) {
|
|
4853
4962
|
if (indexFile == 0 && !decryptedDirectory && (zip64EndOfDirectoryVersion2 || detectEncryptedCentralDirectory(directoryView))) {
|
|
4854
4963
|
throw new Error(ERR_ENCRYPTED_CENTRAL_DIRECTORY);
|
|
4855
4964
|
}
|
|
@@ -4860,16 +4969,16 @@ class ZipReader {
|
|
|
4860
4969
|
const filenameOffset = offset + CENTRAL_FILE_HEADER_LENGTH;
|
|
4861
4970
|
const extraFieldOffset = filenameOffset + fileEntry.filenameLength;
|
|
4862
4971
|
const commentOffset = extraFieldOffset + fileEntry.extraFieldLength;
|
|
4863
|
-
const versionMadeBy = getUint16(directoryView, offset + 4);
|
|
4972
|
+
const versionMadeBy = getUint16$1(directoryView, offset + 4);
|
|
4864
4973
|
const msDosCompatible = versionMadeBy >> 8 == 0;
|
|
4865
4974
|
const unixCompatible = versionMadeBy >> 8 == 3;
|
|
4866
4975
|
const rawFilename = directoryArray.subarray(filenameOffset, extraFieldOffset);
|
|
4867
|
-
const commentLength = getUint16(directoryView, offset + 32);
|
|
4976
|
+
const commentLength = getUint16$1(directoryView, offset + 32);
|
|
4868
4977
|
const endOffset = commentOffset + commentLength;
|
|
4869
4978
|
const rawComment = directoryArray.subarray(commentOffset, endOffset);
|
|
4870
4979
|
const filenameUTF8 = languageEncodingFlag;
|
|
4871
4980
|
const commentUTF8 = languageEncodingFlag;
|
|
4872
|
-
const externalFileAttributes = getUint32(directoryView, offset + 38);
|
|
4981
|
+
const externalFileAttributes = getUint32$1(directoryView, offset + 38);
|
|
4873
4982
|
const msdosAttributesRaw = externalFileAttributes & MAX_8_BITS;
|
|
4874
4983
|
const msdosAttributes = {
|
|
4875
4984
|
readOnly: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_READONLY_MASK),
|
|
@@ -4878,8 +4987,8 @@ class ZipReader {
|
|
|
4878
4987
|
directory: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_DIR_MASK),
|
|
4879
4988
|
archive: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_ARCHIVE_MASK)
|
|
4880
4989
|
};
|
|
4881
|
-
const offsetFileEntry = getUint32(directoryView, offset + 42);
|
|
4882
|
-
const decode =
|
|
4990
|
+
const offsetFileEntry = getUint32$1(directoryView, offset + 42);
|
|
4991
|
+
const decode = getFunctionOptionValue$1(zipReader, options, OPTION_DECODE_TEXT) || decodeText;
|
|
4883
4992
|
const rawFilenameEncoding = filenameUTF8 ? CHARSET_UTF8 : filenameEncoding || CHARSET_CP437;
|
|
4884
4993
|
const rawCommentEncoding = commentUTF8 ? CHARSET_UTF8 : commentEncoding || CHARSET_CP437;
|
|
4885
4994
|
let filename = decode(rawFilename, rawFilenameEncoding, TEXT_TYPE_FILENAME);
|
|
@@ -4905,12 +5014,13 @@ class ZipReader {
|
|
|
4905
5014
|
index: indexFile,
|
|
4906
5015
|
versionMadeBy,
|
|
4907
5016
|
msDosCompatible,
|
|
5017
|
+
zip64: false,
|
|
4908
5018
|
compressedSize: 0,
|
|
4909
5019
|
uncompressedSize: 0,
|
|
4910
5020
|
commentLength,
|
|
4911
5021
|
offset: offsetFileEntry,
|
|
4912
|
-
diskNumberStart: getUint16(directoryView, offset + 34),
|
|
4913
|
-
internalFileAttributes: getUint16(directoryView, offset + 36),
|
|
5022
|
+
diskNumberStart: getUint16$1(directoryView, offset + 34),
|
|
5023
|
+
internalFileAttributes: getUint16$1(directoryView, offset + 36),
|
|
4914
5024
|
externalFileAttributes,
|
|
4915
5025
|
msdosAttributesRaw,
|
|
4916
5026
|
msdosAttributes,
|
|
@@ -4978,8 +5088,8 @@ class ZipReader {
|
|
|
4978
5088
|
yield entry;
|
|
4979
5089
|
}
|
|
4980
5090
|
let offsetAfterSignature = offset;
|
|
4981
|
-
if (offset + 6 <= directoryArray.length && getUint32(directoryView, offset) == DIGITAL_SIGNATURE_RECORD_SIGNATURE) {
|
|
4982
|
-
const signatureDataLength = getUint16(directoryView, offset + 4);
|
|
5091
|
+
if (offset + 6 <= directoryArray.length && getUint32$1(directoryView, offset) == DIGITAL_SIGNATURE_RECORD_SIGNATURE) {
|
|
5092
|
+
const signatureDataLength = getUint16$1(directoryView, offset + 4);
|
|
4983
5093
|
if (offset + 6 + signatureDataLength <= directoryArray.length) {
|
|
4984
5094
|
zipReader.digitalSignature = directoryArray.subarray(offset + 6, offset + 6 + signatureDataLength);
|
|
4985
5095
|
offsetAfterSignature = offset + 6 + signatureDataLength;
|
|
@@ -4991,13 +5101,17 @@ class ZipReader {
|
|
|
4991
5101
|
if (duplicateFilename) {
|
|
4992
5102
|
throwAmbiguousArchive("duplicate filename");
|
|
4993
5103
|
}
|
|
4994
|
-
if (checkAmbiguity && (prependedDataLength || (filesLength && startOffset > 0))) {
|
|
4995
|
-
throwAmbiguousArchive("prepended data");
|
|
4996
|
-
}
|
|
4997
5104
|
const extractPrependedData = getOptionValue$1(zipReader, options, OPTION_EXTRACT_PREPENDED_DATA);
|
|
4998
5105
|
const extractAppendedData = getOptionValue$1(zipReader, options, OPTION_EXTRACT_APPENDED_DATA);
|
|
5106
|
+
const splitZipSignatureLength = (checkAmbiguity || extractPrependedData) && filesLength &&
|
|
5107
|
+
startOffset == SPLIT_ZIP_FILE_SIGNATURE_LENGTH && await startsWithSplitZipMarker(reader) ? SPLIT_ZIP_FILE_SIGNATURE_LENGTH : 0;
|
|
5108
|
+
if (checkAmbiguity && (prependedDataLength || (filesLength && startOffset > splitZipSignatureLength))) {
|
|
5109
|
+
throwAmbiguousArchive("prepended data");
|
|
5110
|
+
}
|
|
4999
5111
|
if (extractPrependedData) {
|
|
5000
|
-
zipReader.prependedData = startOffset >
|
|
5112
|
+
zipReader.prependedData = startOffset > splitZipSignatureLength ?
|
|
5113
|
+
await readUint8Array(reader, splitZipSignatureLength, startOffset - splitZipSignatureLength) :
|
|
5114
|
+
EMPTY_UINT8_ARRAY;
|
|
5001
5115
|
}
|
|
5002
5116
|
zipReader.comment = commentLength ? await readUint8Array(reader, commentOffset + END_OF_CENTRAL_DIR_LENGTH, commentLength) : EMPTY_UINT8_ARRAY;
|
|
5003
5117
|
if (extractAppendedData) {
|
|
@@ -5064,16 +5178,16 @@ class ZipReaderStream {
|
|
|
5064
5178
|
|
|
5065
5179
|
let ZipEntry$1 = class ZipEntry {
|
|
5066
5180
|
|
|
5067
|
-
constructor(reader,
|
|
5181
|
+
constructor(reader, options) {
|
|
5068
5182
|
Object.assign(this, {
|
|
5069
5183
|
reader,
|
|
5070
|
-
config,
|
|
5071
5184
|
options
|
|
5072
5185
|
});
|
|
5073
5186
|
}
|
|
5074
5187
|
|
|
5075
5188
|
async getData(writer, fileEntry, readRanges, options = {}) {
|
|
5076
5189
|
const zipEntry = this;
|
|
5190
|
+
const config = getConfiguration();
|
|
5077
5191
|
const {
|
|
5078
5192
|
reader,
|
|
5079
5193
|
index,
|
|
@@ -5082,7 +5196,6 @@ let ZipEntry$1 = class ZipEntry {
|
|
|
5082
5196
|
extraFieldAES,
|
|
5083
5197
|
extraFieldZip64,
|
|
5084
5198
|
compressionMethod,
|
|
5085
|
-
config,
|
|
5086
5199
|
bitFlag,
|
|
5087
5200
|
rawBitFlag,
|
|
5088
5201
|
crc32,
|
|
@@ -5100,6 +5213,7 @@ let ZipEntry$1 = class ZipEntry {
|
|
|
5100
5213
|
let password = getOptionValue$1(zipEntry, options, OPTION_PASSWORD);
|
|
5101
5214
|
let rawPassword = getOptionValue$1(zipEntry, options, OPTION_RAW_PASSWORD);
|
|
5102
5215
|
const passThrough = getOptionValue$1(zipEntry, options, OPTION_PASS_THROUGH);
|
|
5216
|
+
checkPasswordOption(password, rawPassword);
|
|
5103
5217
|
password = password && password.length && password;
|
|
5104
5218
|
rawPassword = rawPassword && rawPassword.length && rawPassword;
|
|
5105
5219
|
if (extraFieldAES) {
|
|
@@ -5107,7 +5221,7 @@ let ZipEntry$1 = class ZipEntry {
|
|
|
5107
5221
|
throw new Error(ERR_UNSUPPORTED_COMPRESSION$1);
|
|
5108
5222
|
}
|
|
5109
5223
|
}
|
|
5110
|
-
if (dataArray.length < HEADER_SIZE || getUint32(dataView, 0) != LOCAL_FILE_HEADER_SIGNATURE) {
|
|
5224
|
+
if (dataArray.length < HEADER_SIZE || getUint32$1(dataView, 0) != LOCAL_FILE_HEADER_SIGNATURE) {
|
|
5111
5225
|
throw new Error(ERR_LOCAL_FILE_HEADER_NOT_FOUND);
|
|
5112
5226
|
}
|
|
5113
5227
|
readCommonHeader(localDirectory, dataView, 4);
|
|
@@ -5115,9 +5229,12 @@ let ZipEntry$1 = class ZipEntry {
|
|
|
5115
5229
|
extraFieldLength,
|
|
5116
5230
|
filenameLength
|
|
5117
5231
|
} = localDirectory;
|
|
5118
|
-
const
|
|
5232
|
+
const checkLocalDirectoryOption = getOptionValue$1(zipEntry, options, OPTION_CHECK_LOCAL_DIRECTORY);
|
|
5233
|
+
const entryStrictness = getStrictness(options, zipEntry.options);
|
|
5234
|
+
const checkLocalDirectory = getCheckLocalDirectory(checkLocalDirectoryOption, entryStrictness);
|
|
5235
|
+
const checkLocalFilename = getCheckLocalFilename(checkLocalDirectoryOption, entryStrictness);
|
|
5119
5236
|
let rawLocalFilename = EMPTY_UINT8_ARRAY;
|
|
5120
|
-
if (
|
|
5237
|
+
if (checkLocalFilename && (filenameLength || extraFieldLength)) {
|
|
5121
5238
|
const trailingDataArray = await readUint8Array(reader, localHeaderOffset + HEADER_SIZE, filenameLength + extraFieldLength);
|
|
5122
5239
|
rawLocalFilename = trailingDataArray.subarray(0, filenameLength);
|
|
5123
5240
|
localDirectory.rawExtraField = trailingDataArray.subarray(filenameLength);
|
|
@@ -5126,17 +5243,26 @@ let ZipEntry$1 = class ZipEntry {
|
|
|
5126
5243
|
await readUint8Array(reader, localHeaderOffset + HEADER_SIZE + filenameLength, extraFieldLength) :
|
|
5127
5244
|
EMPTY_UINT8_ARRAY;
|
|
5128
5245
|
}
|
|
5246
|
+
if (checkLocalFilename) {
|
|
5247
|
+
localDirectory.rawFilename = rawLocalFilename;
|
|
5248
|
+
}
|
|
5129
5249
|
readCommonFooter(zipEntry, localDirectory, dataView, 4, true);
|
|
5130
|
-
if (
|
|
5131
|
-
|
|
5250
|
+
if (checkLocalDirectory) {
|
|
5251
|
+
validateLocalDirectory(zipEntry, localDirectory, rawLocalFilename, checkLocalFilename);
|
|
5132
5252
|
}
|
|
5133
|
-
const { lastAccessDate, creationDate } = localDirectory;
|
|
5253
|
+
const { lastAccessDate, creationDate, uid, gid } = localDirectory;
|
|
5134
5254
|
if (lastAccessDate) {
|
|
5135
5255
|
fileEntry.lastAccessDate = lastAccessDate;
|
|
5136
5256
|
}
|
|
5137
5257
|
if (creationDate) {
|
|
5138
5258
|
fileEntry.creationDate = creationDate;
|
|
5139
5259
|
}
|
|
5260
|
+
if (uid !== UNDEFINED_VALUE && fileEntry.uid === UNDEFINED_VALUE) {
|
|
5261
|
+
fileEntry.uid = uid;
|
|
5262
|
+
}
|
|
5263
|
+
if (gid !== UNDEFINED_VALUE && fileEntry.gid === UNDEFINED_VALUE) {
|
|
5264
|
+
fileEntry.gid = gid;
|
|
5265
|
+
}
|
|
5140
5266
|
const encrypted = zipEntry.encrypted && localDirectory.encrypted && !passThrough;
|
|
5141
5267
|
const zipCrypto = encrypted && !extraFieldAES;
|
|
5142
5268
|
if (!passThrough) {
|
|
@@ -5157,9 +5283,12 @@ let ZipEntry$1 = class ZipEntry {
|
|
|
5157
5283
|
}
|
|
5158
5284
|
}
|
|
5159
5285
|
const dataOffset = localHeaderOffset + HEADER_SIZE + filenameLength + extraFieldLength;
|
|
5286
|
+
if (dataOffset + compressedSize > reader.size) {
|
|
5287
|
+
throw new Error(ERR_ENTRY_DATA_OUT_OF_BOUNDS);
|
|
5288
|
+
}
|
|
5160
5289
|
const size = compressedSize;
|
|
5161
5290
|
const readable = toCompatibleReadable(reader.createReadable({ offset: dataOffset, size }));
|
|
5162
|
-
const signal = getOptionValue$1(zipEntry, options, OPTION_SIGNAL);
|
|
5291
|
+
const signal = checkSignalOption(getOptionValue$1(zipEntry, options, OPTION_SIGNAL));
|
|
5163
5292
|
const checkPasswordOnly = getOptionValue$1(zipEntry, options, OPTION_CHECK_PASSWORD_ONLY);
|
|
5164
5293
|
let checkOverlappingEntry = getOptionValue$1(zipEntry, options, OPTION_CHECK_OVERLAPPING_ENTRY);
|
|
5165
5294
|
const checkOverlappingEntryOnly = getOptionValue$1(zipEntry, options, OPTION_CHECK_OVERLAPPING_ENTRY_ONLY);
|
|
@@ -5167,6 +5296,8 @@ let ZipEntry$1 = class ZipEntry {
|
|
|
5167
5296
|
checkOverlappingEntry = true;
|
|
5168
5297
|
}
|
|
5169
5298
|
const { onstart, onprogress, onend } = options;
|
|
5299
|
+
const compressed = compressionMethod != COMPRESSION_METHOD_STORE && !passThrough;
|
|
5300
|
+
const outputSize = passThrough ? compressedSize : uncompressedSize;
|
|
5170
5301
|
const deflate64 = compressionMethod == COMPRESSION_METHOD_DEFLATE_64;
|
|
5171
5302
|
let useCompressionStream = getOptionValue$1(zipEntry, options, OPTION_USE_COMPRESSION_STREAM);
|
|
5172
5303
|
if (deflate64) {
|
|
@@ -5187,9 +5318,9 @@ let ZipEntry$1 = class ZipEntry {
|
|
|
5187
5318
|
checkCrc32,
|
|
5188
5319
|
checkAuthenticationCode: getOptionValue$1(zipEntry, options, OPTION_CHECK_AUTHENTICATION_CODE),
|
|
5189
5320
|
passwordVerification: zipCrypto && (dataDescriptor ? ((rawLastModDate >>> 8) & MAX_8_BITS) : ((crc32 >>> 24) & MAX_8_BITS)),
|
|
5190
|
-
outputSize
|
|
5321
|
+
outputSize,
|
|
5191
5322
|
crc32,
|
|
5192
|
-
compressed
|
|
5323
|
+
compressed,
|
|
5193
5324
|
encrypted,
|
|
5194
5325
|
useWebWorkers: getOptionValue$1(zipEntry, options, OPTION_USE_WEB_WORKERS),
|
|
5195
5326
|
useCompressionStream,
|
|
@@ -5226,11 +5357,11 @@ let ZipEntry$1 = class ZipEntry {
|
|
|
5226
5357
|
writer = new WritableStream();
|
|
5227
5358
|
}
|
|
5228
5359
|
writer = new GenericWriter(writer);
|
|
5229
|
-
await initStream(writer,
|
|
5360
|
+
await initStream(writer, getDecodableOutputSize(outputSize, compressedSize, compressed));
|
|
5230
5361
|
({ writable } = writer);
|
|
5231
|
-
const { outputSize } = await runWorker({ readable, writable }, workerOptions);
|
|
5232
|
-
writer.size +=
|
|
5233
|
-
if (
|
|
5362
|
+
const { outputSize: writtenSize } = await runWorker({ readable, writable }, workerOptions);
|
|
5363
|
+
writer.size += writtenSize;
|
|
5364
|
+
if (writtenSize != outputSize) {
|
|
5234
5365
|
throw new Error(ERR_INVALID_UNCOMPRESSED_SIZE);
|
|
5235
5366
|
}
|
|
5236
5367
|
}
|
|
@@ -5264,7 +5395,7 @@ let ZipEntry$1 = class ZipEntry {
|
|
|
5264
5395
|
function detectEncryptedCentralDirectory(directoryView) {
|
|
5265
5396
|
const maxOffset = Math.min(directoryView.byteLength, 1024) - 3;
|
|
5266
5397
|
for (let offset = 0; offset < maxOffset; offset++) {
|
|
5267
|
-
if (getUint32(directoryView, offset) == ARCHIVE_EXTRA_DATA_SIGNATURE) {
|
|
5398
|
+
if (getUint32$1(directoryView, offset) == ARCHIVE_EXTRA_DATA_SIGNATURE) {
|
|
5268
5399
|
return true;
|
|
5269
5400
|
}
|
|
5270
5401
|
}
|
|
@@ -5275,15 +5406,15 @@ function getDirectoryEncryptionInfo(rawExtensibleData) {
|
|
|
5275
5406
|
const directoryEncryptionInfo = { rawExtensibleData };
|
|
5276
5407
|
if (rawExtensibleData.length >= 28) {
|
|
5277
5408
|
const extensibleDataView = getDataView(rawExtensibleData);
|
|
5278
|
-
const hashDataLength = getUint16(extensibleDataView, 26);
|
|
5409
|
+
const hashDataLength = getUint16$1(extensibleDataView, 26);
|
|
5279
5410
|
Object.assign(directoryEncryptionInfo, {
|
|
5280
|
-
compressionMethod: getUint16(extensibleDataView, 0),
|
|
5411
|
+
compressionMethod: getUint16$1(extensibleDataView, 0),
|
|
5281
5412
|
compressedSize: Number(getBigUint64(extensibleDataView, 2)),
|
|
5282
5413
|
uncompressedSize: Number(getBigUint64(extensibleDataView, 10)),
|
|
5283
|
-
encryptionAlgorithm: getUint16(extensibleDataView, 18),
|
|
5284
|
-
bitLength: getUint16(extensibleDataView, 20),
|
|
5285
|
-
flags: getUint16(extensibleDataView, 22),
|
|
5286
|
-
hashAlgorithm: getUint16(extensibleDataView, 24),
|
|
5414
|
+
encryptionAlgorithm: getUint16$1(extensibleDataView, 18),
|
|
5415
|
+
bitLength: getUint16$1(extensibleDataView, 20),
|
|
5416
|
+
flags: getUint16$1(extensibleDataView, 22),
|
|
5417
|
+
hashAlgorithm: getUint16$1(extensibleDataView, 24),
|
|
5287
5418
|
hashData: rawExtensibleData.subarray(28, 28 + hashDataLength)
|
|
5288
5419
|
});
|
|
5289
5420
|
}
|
|
@@ -5291,12 +5422,12 @@ function getDirectoryEncryptionInfo(rawExtensibleData) {
|
|
|
5291
5422
|
}
|
|
5292
5423
|
|
|
5293
5424
|
function readCommonHeader(directory, dataView, offset) {
|
|
5294
|
-
const rawBitFlag = directory.rawBitFlag = getUint16(dataView, offset + 2);
|
|
5425
|
+
const rawBitFlag = directory.rawBitFlag = getUint16$1(dataView, offset + 2);
|
|
5295
5426
|
const encrypted = (rawBitFlag & BITFLAG_ENCRYPTED) == BITFLAG_ENCRYPTED;
|
|
5296
|
-
const rawLastModDate = getUint32(dataView, offset + 6);
|
|
5427
|
+
const rawLastModDate = getUint32$1(dataView, offset + 6);
|
|
5297
5428
|
Object.assign(directory, {
|
|
5298
5429
|
encrypted,
|
|
5299
|
-
version: getUint16(dataView, offset),
|
|
5430
|
+
version: getUint16$1(dataView, offset),
|
|
5300
5431
|
bitFlag: {
|
|
5301
5432
|
level: (rawBitFlag & BITFLAG_LEVEL) >> 1,
|
|
5302
5433
|
dataDescriptor: (rawBitFlag & BITFLAG_DATA_DESCRIPTOR) == BITFLAG_DATA_DESCRIPTOR,
|
|
@@ -5304,8 +5435,8 @@ function readCommonHeader(directory, dataView, offset) {
|
|
|
5304
5435
|
},
|
|
5305
5436
|
rawLastModDate,
|
|
5306
5437
|
lastModDate: getDate(rawLastModDate),
|
|
5307
|
-
filenameLength: getUint16(dataView, offset + 22),
|
|
5308
|
-
extraFieldLength: getUint16(dataView, offset + 24)
|
|
5438
|
+
filenameLength: getUint16$1(dataView, offset + 22),
|
|
5439
|
+
extraFieldLength: getUint16$1(dataView, offset + 24)
|
|
5309
5440
|
});
|
|
5310
5441
|
}
|
|
5311
5442
|
|
|
@@ -5316,8 +5447,8 @@ function readCommonFooter(fileEntry, directory, dataView, offset, localDirectory
|
|
|
5316
5447
|
let offsetExtraField = 0;
|
|
5317
5448
|
try {
|
|
5318
5449
|
while (offsetExtraField < rawExtraField.length) {
|
|
5319
|
-
const type = getUint16(rawExtraFieldView, offsetExtraField);
|
|
5320
|
-
const size = getUint16(rawExtraFieldView, offsetExtraField + 2);
|
|
5450
|
+
const type = getUint16$1(rawExtraFieldView, offsetExtraField);
|
|
5451
|
+
const size = getUint16$1(rawExtraFieldView, offsetExtraField + 2);
|
|
5321
5452
|
extraField.set(type, {
|
|
5322
5453
|
type,
|
|
5323
5454
|
data: rawExtraField.slice(offsetExtraField + 4, offsetExtraField + 4 + size)
|
|
@@ -5327,12 +5458,12 @@ function readCommonFooter(fileEntry, directory, dataView, offset, localDirectory
|
|
|
5327
5458
|
} catch {
|
|
5328
5459
|
// ignored
|
|
5329
5460
|
}
|
|
5330
|
-
const compressionMethod = getUint16(dataView, offset + 4);
|
|
5461
|
+
const compressionMethod = getUint16$1(dataView, offset + 4);
|
|
5331
5462
|
Object.assign(directory, {
|
|
5332
|
-
signature: getUint32(dataView, offset + HEADER_OFFSET_SIGNATURE),
|
|
5333
|
-
crc32: getUint32(dataView, offset + HEADER_OFFSET_SIGNATURE),
|
|
5334
|
-
compressedSize: getUint32(dataView, offset + HEADER_OFFSET_COMPRESSED_SIZE),
|
|
5335
|
-
uncompressedSize: getUint32(dataView, offset + HEADER_OFFSET_UNCOMPRESSED_SIZE)
|
|
5463
|
+
signature: getUint32$1(dataView, offset + HEADER_OFFSET_SIGNATURE),
|
|
5464
|
+
crc32: getUint32$1(dataView, offset + HEADER_OFFSET_SIGNATURE),
|
|
5465
|
+
compressedSize: getUint32$1(dataView, offset + HEADER_OFFSET_COMPRESSED_SIZE),
|
|
5466
|
+
uncompressedSize: getUint32$1(dataView, offset + HEADER_OFFSET_UNCOMPRESSED_SIZE)
|
|
5336
5467
|
});
|
|
5337
5468
|
const extraFieldZip64 = extraField.get(EXTRAFIELD_TYPE_ZIP64);
|
|
5338
5469
|
if (extraFieldZip64) {
|
|
@@ -5372,10 +5503,12 @@ function readCommonFooter(fileEntry, directory, dataView, offset, localDirectory
|
|
|
5372
5503
|
directory.extraFieldNTFS = extraFieldNTFS;
|
|
5373
5504
|
}
|
|
5374
5505
|
const extraFieldUnix = extraField.get(EXTRAFIELD_TYPE_UNIX);
|
|
5506
|
+
let unixIdsRead;
|
|
5375
5507
|
if (extraFieldUnix) {
|
|
5376
|
-
readExtraFieldUnix(extraFieldUnix, directory, false);
|
|
5508
|
+
unixIdsRead = readExtraFieldUnix(extraFieldUnix, directory, false);
|
|
5377
5509
|
directory.extraFieldUnix = extraFieldUnix;
|
|
5378
|
-
}
|
|
5510
|
+
}
|
|
5511
|
+
if (!unixIdsRead) {
|
|
5379
5512
|
const extraFieldInfoZip = extraField.get(EXTRAFIELD_TYPE_INFOZIP);
|
|
5380
5513
|
if (extraFieldInfoZip) {
|
|
5381
5514
|
readExtraFieldUnix(extraFieldInfoZip, directory, true);
|
|
@@ -5419,11 +5552,11 @@ function readExtraFieldUnicode(extraFieldUnicode, propertyName, rawPropertyName,
|
|
|
5419
5552
|
computedCrc32.append(fileEntry[rawPropertyName]);
|
|
5420
5553
|
const computedCrc32View = getDataView(new Uint8Array(4));
|
|
5421
5554
|
computedCrc32View.setUint32(0, computedCrc32.get(), true);
|
|
5422
|
-
const nameCrc32 = getUint32(extraFieldView, 1);
|
|
5555
|
+
const nameCrc32 = getUint32$1(extraFieldView, 1);
|
|
5423
5556
|
Object.assign(extraFieldUnicode, {
|
|
5424
5557
|
version: getUint8(extraFieldView, 0),
|
|
5425
5558
|
[propertyName]: decodeText(extraFieldUnicode.data.subarray(5)),
|
|
5426
|
-
valid: !fileEntry.bitFlag.languageEncodingFlag && nameCrc32 == getUint32(computedCrc32View, 0)
|
|
5559
|
+
valid: !fileEntry.bitFlag.languageEncodingFlag && nameCrc32 == getUint32$1(computedCrc32View, 0)
|
|
5427
5560
|
});
|
|
5428
5561
|
if (extraFieldUnicode.valid) {
|
|
5429
5562
|
directory[propertyName] = extraFieldUnicode[propertyName];
|
|
@@ -5439,7 +5572,7 @@ function readExtraFieldAES(extraFieldAES, directory, compressionMethod) {
|
|
|
5439
5572
|
vendorId: getUint8(extraFieldView, 2),
|
|
5440
5573
|
strength,
|
|
5441
5574
|
originalCompressionMethod: compressionMethod,
|
|
5442
|
-
compressionMethod: getUint16(extraFieldView, 5)
|
|
5575
|
+
compressionMethod: getUint16$1(extraFieldView, 5)
|
|
5443
5576
|
});
|
|
5444
5577
|
directory.compressionMethod = extraFieldAES.compressionMethod;
|
|
5445
5578
|
if (extraFieldAES.vendorVersion != VENDOR_VERSION_AE_1$1) {
|
|
@@ -5453,8 +5586,8 @@ function readExtraFieldNTFS(extraFieldNTFS, directory) {
|
|
|
5453
5586
|
let tag1Data;
|
|
5454
5587
|
try {
|
|
5455
5588
|
while (offsetExtraField < extraFieldNTFS.data.length && !tag1Data) {
|
|
5456
|
-
const tagValue = getUint16(extraFieldView, offsetExtraField);
|
|
5457
|
-
const attributeSize = getUint16(extraFieldView, offsetExtraField + 2);
|
|
5589
|
+
const tagValue = getUint16$1(extraFieldView, offsetExtraField);
|
|
5590
|
+
const attributeSize = getUint16$1(extraFieldView, offsetExtraField + 2);
|
|
5458
5591
|
if (tagValue == EXTRAFIELD_TYPE_NTFS_TAG1) {
|
|
5459
5592
|
tag1Data = extraFieldNTFS.data.slice(offsetExtraField + 4, offsetExtraField + 4 + attributeSize);
|
|
5460
5593
|
}
|
|
@@ -5478,7 +5611,7 @@ function readExtraFieldNTFS(extraFieldNTFS, directory) {
|
|
|
5478
5611
|
const creationDate = getDateNTFS(rawCreationDate);
|
|
5479
5612
|
const extraFieldData = { lastModDate, lastAccessDate, creationDate };
|
|
5480
5613
|
Object.assign(extraFieldNTFS, extraFieldData);
|
|
5481
|
-
Object.assign(directory, extraFieldData);
|
|
5614
|
+
Object.assign(directory, extraFieldData, { rawLastAccessDate, rawCreationDate });
|
|
5482
5615
|
}
|
|
5483
5616
|
}
|
|
5484
5617
|
|
|
@@ -5487,12 +5620,12 @@ function readExtraFieldUnixDates(extraField, directory) {
|
|
|
5487
5620
|
return;
|
|
5488
5621
|
}
|
|
5489
5622
|
const extraFieldView = getDataView(extraField.data);
|
|
5490
|
-
const lastAccessDate = new Date((getUint32(extraFieldView, 0) | 0) * 1000);
|
|
5491
|
-
const lastModDate = new Date((getUint32(extraFieldView, 4) | 0) * 1000);
|
|
5623
|
+
const lastAccessDate = new Date((getUint32$1(extraFieldView, 0) | 0) * 1000);
|
|
5624
|
+
const lastModDate = new Date((getUint32$1(extraFieldView, 4) | 0) * 1000);
|
|
5492
5625
|
const extraFieldData = { lastAccessDate, lastModDate };
|
|
5493
5626
|
if (extraField.data.length >= 12) {
|
|
5494
|
-
extraFieldData.uid = getUint16(extraFieldView, 8);
|
|
5495
|
-
extraFieldData.gid = getUint16(extraFieldView, 10);
|
|
5627
|
+
extraFieldData.uid = getUint16$1(extraFieldView, 8);
|
|
5628
|
+
extraFieldData.gid = getUint16$1(extraFieldView, 10);
|
|
5496
5629
|
}
|
|
5497
5630
|
Object.assign(extraField, extraFieldData);
|
|
5498
5631
|
Object.assign(directory, extraFieldData);
|
|
@@ -5512,8 +5645,8 @@ function readExtraFieldUnix(extraField, directory, isInfoZip) {
|
|
|
5512
5645
|
gid = unpackUnixId(extraField.data.subarray(offset, offset + gidSize));
|
|
5513
5646
|
Object.assign(extraField, { version, uid, gid });
|
|
5514
5647
|
} else if (extraField.data.length >= 4) {
|
|
5515
|
-
uid = getUint16(view, 0);
|
|
5516
|
-
gid = getUint16(view, 2);
|
|
5648
|
+
uid = getUint16$1(view, 0);
|
|
5649
|
+
gid = getUint16$1(view, 2);
|
|
5517
5650
|
Object.assign(extraField, { uid, gid });
|
|
5518
5651
|
}
|
|
5519
5652
|
if (uid !== UNDEFINED_VALUE) {
|
|
@@ -5522,6 +5655,7 @@ function readExtraFieldUnix(extraField, directory, isInfoZip) {
|
|
|
5522
5655
|
if (gid !== UNDEFINED_VALUE) {
|
|
5523
5656
|
directory.gid = gid;
|
|
5524
5657
|
}
|
|
5658
|
+
return uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE;
|
|
5525
5659
|
} catch {
|
|
5526
5660
|
// ignored
|
|
5527
5661
|
}
|
|
@@ -5562,7 +5696,7 @@ function readExtraFieldExtendedTimestamp(extraFieldExtendedTimestamp, directory,
|
|
|
5562
5696
|
let offset = 1;
|
|
5563
5697
|
timeProperties.forEach((propertyName, indexProperty) => {
|
|
5564
5698
|
if (extraFieldExtendedTimestamp.data.length >= offset + 4) {
|
|
5565
|
-
const time = getUint32(extraFieldView, offset);
|
|
5699
|
+
const time = getUint32$1(extraFieldView, offset);
|
|
5566
5700
|
directory[propertyName] = extraFieldExtendedTimestamp[propertyName] = new Date((time | 0) * 1000);
|
|
5567
5701
|
const rawPropertyName = timeRawProperties[indexProperty];
|
|
5568
5702
|
extraFieldExtendedTimestamp[rawPropertyName] = time;
|
|
@@ -5594,26 +5728,25 @@ async function detectOverlappingEntry({
|
|
|
5594
5728
|
}
|
|
5595
5729
|
if (dataDescriptorLength) {
|
|
5596
5730
|
const dataDescriptorArray = await readUint8Array(reader, dataOffset + compressedSize, dataDescriptorLength + DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH);
|
|
5597
|
-
const
|
|
5598
|
-
|
|
5599
|
-
|
|
5600
|
-
|
|
5601
|
-
|
|
5602
|
-
|
|
5603
|
-
if (extraFieldZip64) {
|
|
5604
|
-
readCompressedSize = getBigUint64(getDataView(dataDescriptorArray), 8);
|
|
5605
|
-
readUncompressedSize = getBigUint64(getDataView(dataDescriptorArray), 16);
|
|
5606
|
-
} else {
|
|
5607
|
-
readCompressedSize = getUint32(getDataView(dataDescriptorArray), 8);
|
|
5608
|
-
readUncompressedSize = getUint32(getDataView(dataDescriptorArray), 12);
|
|
5609
|
-
}
|
|
5610
|
-
const matchCrc32 = (fileEntry.encrypted && !fileEntry.zipCrypto) || readCrc32 == crc32;
|
|
5731
|
+
const dataDescriptorView = getDataView(dataDescriptorArray);
|
|
5732
|
+
let signature = dataDescriptorArray.length == dataDescriptorLength + DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH &&
|
|
5733
|
+
getUint32$1(dataDescriptorView, 0) == DATA_DESCRIPTOR_RECORD_SIGNATURE;
|
|
5734
|
+
if (signature) {
|
|
5735
|
+
const signedDataDescriptor = readDataDescriptor(dataDescriptorView, DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH, extraFieldZip64);
|
|
5736
|
+
const matchCrc32 = (fileEntry.encrypted && !fileEntry.zipCrypto) || signedDataDescriptor.crc32 == crc32;
|
|
5611
5737
|
if (matchCrc32 &&
|
|
5612
|
-
|
|
5613
|
-
|
|
5738
|
+
signedDataDescriptor.compressedSize == compressedSize &&
|
|
5739
|
+
signedDataDescriptor.uncompressedSize == uncompressedSize) {
|
|
5614
5740
|
dataDescriptorLength += DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH;
|
|
5741
|
+
} else {
|
|
5742
|
+
signature = false;
|
|
5615
5743
|
}
|
|
5616
5744
|
}
|
|
5745
|
+
if (dataDescriptorArray.length >= dataDescriptorLength) {
|
|
5746
|
+
const localDataDescriptor = readDataDescriptor(dataDescriptorView, signature ? DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH : 0, extraFieldZip64);
|
|
5747
|
+
localDataDescriptor.signature = signature;
|
|
5748
|
+
fileEntry.localDirectory.dataDescriptor = localDataDescriptor;
|
|
5749
|
+
}
|
|
5617
5750
|
}
|
|
5618
5751
|
const range = {
|
|
5619
5752
|
start: offset,
|
|
@@ -5630,22 +5763,80 @@ async function detectOverlappingEntry({
|
|
|
5630
5763
|
readRanges.set(index, range);
|
|
5631
5764
|
}
|
|
5632
5765
|
|
|
5766
|
+
function readDataDescriptor(dataDescriptorView, offset, extraFieldZip64) {
|
|
5767
|
+
const crc32 = getUint32$1(dataDescriptorView, offset);
|
|
5768
|
+
let compressedSize;
|
|
5769
|
+
let uncompressedSize;
|
|
5770
|
+
if (extraFieldZip64) {
|
|
5771
|
+
compressedSize = getBigUint64(dataDescriptorView, offset + 4);
|
|
5772
|
+
uncompressedSize = getBigUint64(dataDescriptorView, offset + 12);
|
|
5773
|
+
} else {
|
|
5774
|
+
compressedSize = getUint32$1(dataDescriptorView, offset + 4);
|
|
5775
|
+
uncompressedSize = getUint32$1(dataDescriptorView, offset + 8);
|
|
5776
|
+
}
|
|
5777
|
+
return { crc32, compressedSize, uncompressedSize };
|
|
5778
|
+
}
|
|
5779
|
+
|
|
5633
5780
|
function getDiskOffset$1(reader, diskNumber) {
|
|
5634
5781
|
return reader.getDiskOffset ? reader.getDiskOffset(diskNumber) : 0;
|
|
5635
5782
|
}
|
|
5636
5783
|
|
|
5784
|
+
async function startsWithSplitZipSignature$1(reader) {
|
|
5785
|
+
return await getFirstSignature(reader) == SPLIT_ZIP_FILE_SIGNATURE;
|
|
5786
|
+
}
|
|
5787
|
+
|
|
5788
|
+
async function startsWithSplitZipMarker(reader) {
|
|
5789
|
+
const signature = await getFirstSignature(reader);
|
|
5790
|
+
return signature == SPLIT_ZIP_FILE_SIGNATURE || signature == TEMPORARY_SPLIT_ZIP_FILE_SIGNATURE;
|
|
5791
|
+
}
|
|
5792
|
+
|
|
5793
|
+
async function getFirstSignature(reader) {
|
|
5794
|
+
const signatureArray = await readUint8Array(reader, 0, SPLIT_ZIP_FILE_SIGNATURE_LENGTH);
|
|
5795
|
+
return getUint32$1(getDataView(signatureArray));
|
|
5796
|
+
}
|
|
5797
|
+
|
|
5637
5798
|
function isStrictnessValue(value) {
|
|
5638
5799
|
return value === STRICTNESS_STRICT || value === STRICTNESS_BALANCED || value === STRICTNESS_TOLERANT;
|
|
5639
5800
|
}
|
|
5640
5801
|
|
|
5641
|
-
function
|
|
5642
|
-
|
|
5643
|
-
|
|
5802
|
+
function getDecodableOutputSize(outputSize, compressedSize, compressed) {
|
|
5803
|
+
return Math.min(outputSize, compressed ? compressedSize * MAX_DEFLATE_EXPANSION_RATIO : compressedSize);
|
|
5804
|
+
}
|
|
5805
|
+
|
|
5806
|
+
function getStrictness(options, inheritedOptions) {
|
|
5807
|
+
return resolveStrictness(options, resolveStrictness(inheritedOptions, STRICTNESS_BALANCED));
|
|
5808
|
+
}
|
|
5809
|
+
|
|
5810
|
+
function resolveStrictness(options, inheritedStrictness) {
|
|
5811
|
+
const strictness = options[OPTION_STRICTNESS];
|
|
5812
|
+
if (strictness !== UNDEFINED_VALUE) {
|
|
5813
|
+
if (!isStrictnessValue(strictness)) {
|
|
5814
|
+
throw new Error(ERR_INVALID_STRICTNESS);
|
|
5815
|
+
}
|
|
5816
|
+
return strictness;
|
|
5817
|
+
}
|
|
5818
|
+
const checkAmbiguity = options[OPTION_CHECK_AMBIGUITY];
|
|
5819
|
+
if (checkAmbiguity === UNDEFINED_VALUE) {
|
|
5820
|
+
return inheritedStrictness;
|
|
5644
5821
|
}
|
|
5645
|
-
if (
|
|
5646
|
-
|
|
5822
|
+
if (checkAmbiguity) {
|
|
5823
|
+
return STRICTNESS_STRICT;
|
|
5647
5824
|
}
|
|
5648
|
-
return
|
|
5825
|
+
return inheritedStrictness == STRICTNESS_TOLERANT ? STRICTNESS_TOLERANT : STRICTNESS_BALANCED;
|
|
5826
|
+
}
|
|
5827
|
+
|
|
5828
|
+
function getCheckLocalDirectory(checkLocalDirectory, strictness) {
|
|
5829
|
+
if (checkLocalDirectory === UNDEFINED_VALUE) {
|
|
5830
|
+
return strictness != STRICTNESS_TOLERANT;
|
|
5831
|
+
}
|
|
5832
|
+
return Boolean(checkLocalDirectory);
|
|
5833
|
+
}
|
|
5834
|
+
|
|
5835
|
+
function getCheckLocalFilename(checkLocalFilename, strictness) {
|
|
5836
|
+
if (checkLocalFilename === UNDEFINED_VALUE) {
|
|
5837
|
+
return strictness == STRICTNESS_STRICT;
|
|
5838
|
+
}
|
|
5839
|
+
return Boolean(checkLocalFilename);
|
|
5649
5840
|
}
|
|
5650
5841
|
|
|
5651
5842
|
function getFilenameValidation(filenameValidation, strictness) {
|
|
@@ -5674,7 +5865,7 @@ function isUnsafeFilename(filename, filenameValidation) {
|
|
|
5674
5865
|
|
|
5675
5866
|
function getMaxAppendedDataSize(maxAppendedDataSize, strictness) {
|
|
5676
5867
|
if (maxAppendedDataSize !== UNDEFINED_VALUE) {
|
|
5677
|
-
const size = toNumber
|
|
5868
|
+
const size = toNumber(maxAppendedDataSize);
|
|
5678
5869
|
if (typeof size != NUMBER_TYPE || Number.isNaN(size) || size < 0) {
|
|
5679
5870
|
throw new Error(ERR_INVALID_MAX_APPENDED_DATA_SIZE);
|
|
5680
5871
|
}
|
|
@@ -5697,7 +5888,7 @@ async function findEndOfCentralDirectory(reader, rejectAmbiguous, maxAppendedDat
|
|
|
5697
5888
|
let plausibleEndOfDirectoryInfo;
|
|
5698
5889
|
let endOfDirectoryReachingEndCount = 0;
|
|
5699
5890
|
for await (const [anchoredView, anchoredOffset, anchoredArray, indexByte, offset] of scanEndOfCentralDirectory(reader, anchoredLength)) {
|
|
5700
|
-
const commentLength = getUint16(anchoredView, indexByte + 20);
|
|
5891
|
+
const commentLength = getUint16$1(anchoredView, indexByte + 20);
|
|
5701
5892
|
if (offset + END_OF_CENTRAL_DIR_LENGTH + commentLength == size) {
|
|
5702
5893
|
const reachability = await getCentralDirectoryReachability(reader, anchoredView, anchoredOffset, indexByte, offset, size, remoteProbeBudget);
|
|
5703
5894
|
if (reachability == CENTRAL_DIRECTORY_REACHABLE) {
|
|
@@ -5748,7 +5939,7 @@ async function* scanEndOfCentralDirectory(reader, scanLength) {
|
|
|
5748
5939
|
const scanArray = await readUint8Array(reader, scanOffset, scanLength);
|
|
5749
5940
|
const scanView = getDataView(scanArray);
|
|
5750
5941
|
for (let indexByte = scanArray.length - END_OF_CENTRAL_DIR_LENGTH; indexByte >= 0; indexByte--) {
|
|
5751
|
-
if (getUint32(scanView, indexByte) == END_OF_CENTRAL_DIR_SIGNATURE) {
|
|
5942
|
+
if (getUint32$1(scanView, indexByte) == END_OF_CENTRAL_DIR_SIGNATURE) {
|
|
5752
5943
|
yield [scanView, scanOffset, scanArray, indexByte, scanOffset + indexByte];
|
|
5753
5944
|
}
|
|
5754
5945
|
}
|
|
@@ -5759,9 +5950,9 @@ function getEndOfCentralDirectoryInfo(scanArray, indexByte, offset) {
|
|
|
5759
5950
|
}
|
|
5760
5951
|
|
|
5761
5952
|
async function getCentralDirectoryReachability(reader, view, anchoredOffset, indexByte, offset, size, remoteProbeBudget) {
|
|
5762
|
-
const filesLength = getUint16(view, indexByte + 10);
|
|
5763
|
-
const directoryDataLength = getUint32(view, indexByte + 12);
|
|
5764
|
-
const directoryDataOffset = getUint32(view, indexByte + 16);
|
|
5953
|
+
const filesLength = getUint16$1(view, indexByte + 10);
|
|
5954
|
+
const directoryDataLength = getUint32$1(view, indexByte + 12);
|
|
5955
|
+
const directoryDataOffset = getUint32$1(view, indexByte + 16);
|
|
5765
5956
|
if (filesLength == MAX_16_BITS || directoryDataLength == MAX_32_BITS || directoryDataOffset == MAX_32_BITS) {
|
|
5766
5957
|
const locatorSignature = await readSignature(reader, view, anchoredOffset, offset - ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH, size, remoteProbeBudget);
|
|
5767
5958
|
return locatorSignature == ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE ? CENTRAL_DIRECTORY_REACHABLE : CENTRAL_DIRECTORY_UNREACHABLE;
|
|
@@ -5769,7 +5960,7 @@ async function getCentralDirectoryReachability(reader, view, anchoredOffset, ind
|
|
|
5769
5960
|
if (!filesLength && !directoryDataLength) {
|
|
5770
5961
|
return CENTRAL_DIRECTORY_PLAUSIBLE;
|
|
5771
5962
|
}
|
|
5772
|
-
const directoryDiskNumber = getUint16(view, indexByte + 6);
|
|
5963
|
+
const directoryDiskNumber = getUint16$1(view, indexByte + 6);
|
|
5773
5964
|
for (const centralDirectoryOffset of [offset - directoryDataLength, getDiskOffset$1(reader, directoryDiskNumber) + directoryDataOffset]) {
|
|
5774
5965
|
if (await readSignature(reader, view, anchoredOffset, centralDirectoryOffset, size, remoteProbeBudget) == CENTRAL_FILE_HEADER_SIGNATURE) {
|
|
5775
5966
|
return CENTRAL_DIRECTORY_REACHABLE;
|
|
@@ -5783,20 +5974,21 @@ async function readSignature(reader, view, anchoredOffset, signatureOffset, size
|
|
|
5783
5974
|
return UNDEFINED_VALUE;
|
|
5784
5975
|
}
|
|
5785
5976
|
if (signatureOffset >= anchoredOffset) {
|
|
5786
|
-
return getUint32(view, signatureOffset - anchoredOffset);
|
|
5977
|
+
return getUint32$1(view, signatureOffset - anchoredOffset);
|
|
5787
5978
|
}
|
|
5788
5979
|
if (remoteProbeBudget.count > 0) {
|
|
5789
5980
|
remoteProbeBudget.count--;
|
|
5790
5981
|
const signatureArray = await readUint8Array(reader, signatureOffset, 4);
|
|
5791
|
-
return getUint32(getDataView(signatureArray), 0);
|
|
5982
|
+
return getUint32$1(getDataView(signatureArray), 0);
|
|
5792
5983
|
}
|
|
5793
5984
|
return UNDEFINED_VALUE;
|
|
5794
5985
|
}
|
|
5795
5986
|
|
|
5796
|
-
function
|
|
5987
|
+
function validateLocalDirectory(zipEntry, localDirectory, rawLocalFilename, checkLocalFilename) {
|
|
5797
5988
|
const { rawFilename } = zipEntry;
|
|
5798
|
-
if (
|
|
5799
|
-
rawLocalFilename.
|
|
5989
|
+
if (checkLocalFilename &&
|
|
5990
|
+
(rawLocalFilename.length != rawFilename.length ||
|
|
5991
|
+
rawLocalFilename.some((byteValue, indexByte) => byteValue != rawFilename[indexByte]))) {
|
|
5800
5992
|
throwAmbiguousArchive("mismatched local file header (filename)");
|
|
5801
5993
|
}
|
|
5802
5994
|
if ((localDirectory.rawBitFlag & BITFLAG_AMBIGUITY_MASK) != (zipEntry.rawBitFlag & BITFLAG_AMBIGUITY_MASK)) {
|
|
@@ -5824,10 +6016,11 @@ function getOptionValue$1(zipReader, options, name) {
|
|
|
5824
6016
|
return options[name] === UNDEFINED_VALUE ? zipReader.options[name] : options[name];
|
|
5825
6017
|
}
|
|
5826
6018
|
|
|
5827
|
-
function
|
|
5828
|
-
return
|
|
6019
|
+
function getFunctionOptionValue$1(zipReader, options, name) {
|
|
6020
|
+
return checkFunctionOption(getOptionValue$1(zipReader, options, name));
|
|
5829
6021
|
}
|
|
5830
6022
|
|
|
6023
|
+
|
|
5831
6024
|
function getDate(timeRaw) {
|
|
5832
6025
|
const date = (timeRaw & 0xffff0000) >> 16, time = timeRaw & MAX_16_BITS;
|
|
5833
6026
|
return new Date(1980 + ((date & 0xFE00) >> 9), ((date & 0x01E0) >> 5) - 1, date & 0x001F, (time & 0xF800) >> 11, (time & 0x07E0) >> 5, (time & 0x001F) * 2, 0);
|
|
@@ -5841,11 +6034,11 @@ function getUint8(view, offset) {
|
|
|
5841
6034
|
return view.getUint8(offset);
|
|
5842
6035
|
}
|
|
5843
6036
|
|
|
5844
|
-
function getUint16(view, offset) {
|
|
6037
|
+
function getUint16$1(view, offset) {
|
|
5845
6038
|
return view.getUint16(offset, true);
|
|
5846
6039
|
}
|
|
5847
6040
|
|
|
5848
|
-
function getUint32(view, offset) {
|
|
6041
|
+
function getUint32$1(view, offset) {
|
|
5849
6042
|
return view.getUint32(offset, true);
|
|
5850
6043
|
}
|
|
5851
6044
|
|
|
@@ -5860,6 +6053,7 @@ var zipReader = /*#__PURE__*/Object.freeze({
|
|
|
5860
6053
|
ERR_CENTRAL_DIRECTORY_NOT_FOUND: ERR_CENTRAL_DIRECTORY_NOT_FOUND,
|
|
5861
6054
|
ERR_ENCRYPTED: ERR_ENCRYPTED,
|
|
5862
6055
|
ERR_ENCRYPTED_CENTRAL_DIRECTORY: ERR_ENCRYPTED_CENTRAL_DIRECTORY,
|
|
6056
|
+
ERR_ENTRY_DATA_OUT_OF_BOUNDS: ERR_ENTRY_DATA_OUT_OF_BOUNDS,
|
|
5863
6057
|
ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND: ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND,
|
|
5864
6058
|
ERR_EOCDR_NOT_FOUND: ERR_EOCDR_NOT_FOUND,
|
|
5865
6059
|
ERR_EXTRAFIELD_ZIP64_NOT_FOUND: ERR_EXTRAFIELD_ZIP64_NOT_FOUND,
|
|
@@ -5914,13 +6108,18 @@ var zipReader = /*#__PURE__*/Object.freeze({
|
|
|
5914
6108
|
|
|
5915
6109
|
const ERR_DUPLICATED_NAME = "File already exists";
|
|
5916
6110
|
const ERR_INVALID_COMMENT = "Zip file comment exceeds 64KB";
|
|
6111
|
+
const ERR_INVALID_COMMENT_TYPE = "Invalid zip file comment (must be a Uint8Array)";
|
|
5917
6112
|
const ERR_INVALID_ENTRY_COMMENT = "File entry comment exceeds 64KB";
|
|
6113
|
+
const ERR_INVALID_ENTRY_COMMENT_TYPE = "Invalid file entry comment (must be a string)";
|
|
6114
|
+
const ERR_INVALID_DATE = "Invalid date (must be a valid Date instance)";
|
|
5918
6115
|
const ERR_INVALID_ENTRY_NAME = "File entry name exceeds 64KB";
|
|
5919
6116
|
const ERR_INVALID_VERSION = "Version exceeds 65535";
|
|
5920
6117
|
const ERR_INVALID_ENCRYPTION_STRENGTH = "The strength must equal 1, 2, or 3";
|
|
5921
6118
|
const ERR_UNSUPPORTED_ENCRYPTION_USDZ = "Encryption is not supported in USDZ files";
|
|
5922
6119
|
const ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH = "Encryption is not supported when the 'passThrough' option is set";
|
|
5923
|
-
const
|
|
6120
|
+
const ERR_INVALID_EXTRAFIELD = "Invalid extra field (must be a Map)";
|
|
6121
|
+
const ERR_INVALID_EXTRAFIELD_TYPE = "Invalid extra field type (must be integer 0..65535)";
|
|
6122
|
+
const ERR_INVALID_EXTRAFIELD_DATA_TYPE = "Invalid extra field data (must be a Uint8Array)";
|
|
5924
6123
|
const ERR_INVALID_EXTRAFIELD_DATA = "Extra field data exceeds 64KB";
|
|
5925
6124
|
const ERR_UNSUPPORTED_COMPRESSION = "Compression method not supported";
|
|
5926
6125
|
const MIN_UNIX_TIME = -2147483648;
|
|
@@ -5940,7 +6139,6 @@ const ERR_INVALID_UNIX_ID_SIZE = "uid/gid must be 0..65535 for unixExtraFieldTyp
|
|
|
5940
6139
|
const ERR_INVALID_MSDOS_ATTRIBUTES = "Invalid msdosAttributesRaw (must be integer 0..255)";
|
|
5941
6140
|
const ERR_INVALID_MSDOS_DATA = "Invalid msdosAttributes (must be an object with boolean flags)";
|
|
5942
6141
|
const ERR_INVALID_LEVEL = "Invalid level (must be integer 0..9)";
|
|
5943
|
-
const ERR_INVALID_PASSWORD_TYPE = "Invalid password (password must be a string, rawPassword must be a Uint8Array)";
|
|
5944
6142
|
const ERR_INVALID_SIGNATURE_DATA = "Signature data exceeds 64KB";
|
|
5945
6143
|
|
|
5946
6144
|
const EXTRAFIELD_DATA_AES = new Uint8Array([0x07, 0x00, 0x02, 0x00, 0x41, 0x45, 0x03, 0x00, 0x00]);
|
|
@@ -5965,8 +6163,7 @@ class ZipWriter {
|
|
|
5965
6163
|
writer,
|
|
5966
6164
|
addSplitZipSignature,
|
|
5967
6165
|
options,
|
|
5968
|
-
|
|
5969
|
-
files: new Map(),
|
|
6166
|
+
fileEntries: new Map(),
|
|
5970
6167
|
filenames: new Set(),
|
|
5971
6168
|
offset: options[OPTION_OFFSET] === UNDEFINED_VALUE ? writer.size || writer.writable.size || 0 : options[OPTION_OFFSET],
|
|
5972
6169
|
initialOffset: options[OPTION_OFFSET] === UNDEFINED_VALUE ? 0 : options[OPTION_OFFSET] - (writer.size || writer.writable.size || 0),
|
|
@@ -5982,15 +6179,28 @@ class ZipWriter {
|
|
|
5982
6179
|
}
|
|
5983
6180
|
reader = new GenericReader(reader);
|
|
5984
6181
|
await initStream(reader);
|
|
6182
|
+
if (reader.size === UNDEFINED_VALUE || !reader.readUint8Array) {
|
|
6183
|
+
reader = new BlobReader(await streamToBlob(reader.readable));
|
|
6184
|
+
await initStream(reader);
|
|
6185
|
+
}
|
|
5985
6186
|
const { ZipReader } = await Promise.resolve().then(function () { return zipReader; });
|
|
5986
|
-
const zipReader$1 = new ZipReader(reader
|
|
6187
|
+
const zipReader$1 = new ZipReader(reader);
|
|
5987
6188
|
const entries = await zipReader$1.getEntries();
|
|
5988
6189
|
await zipReader$1.close();
|
|
5989
6190
|
await initStream(this.writer);
|
|
5990
|
-
|
|
5991
|
-
|
|
6191
|
+
const { directoryOffset } = zipReader$1;
|
|
6192
|
+
let splitZipSignatureLength = 0;
|
|
6193
|
+
if (this.addSplitZipSignature) {
|
|
6194
|
+
delete this.addSplitZipSignature;
|
|
6195
|
+
if (!await startsWithSplitZipSignature(reader)) {
|
|
6196
|
+
await writeData(this.writer, getSplitZipSignatureArray());
|
|
6197
|
+
splitZipSignatureLength = SPLIT_ZIP_FILE_SIGNATURE_LENGTH;
|
|
6198
|
+
this.offset += splitZipSignatureLength;
|
|
6199
|
+
}
|
|
6200
|
+
}
|
|
6201
|
+
const entryPositions = await copyZipData(this, reader, entries, directoryOffset, splitZipSignatureLength);
|
|
5992
6202
|
this.filenames = new Set(entries.map(entry => entry.filename));
|
|
5993
|
-
this.
|
|
6203
|
+
this.fileEntries = new Map(entries.map(entry => {
|
|
5994
6204
|
const {
|
|
5995
6205
|
version,
|
|
5996
6206
|
rawLastModDate,
|
|
@@ -6045,11 +6255,12 @@ class ZipWriter {
|
|
|
6045
6255
|
if (crc32 !== UNDEFINED_VALUE) {
|
|
6046
6256
|
setUint32(headerView, HEADER_OFFSET_SIGNATURE, crc32);
|
|
6047
6257
|
}
|
|
6258
|
+
const { offset, diskNumberStart } = entryPositions.get(entry);
|
|
6048
6259
|
Object.assign(entry, {
|
|
6049
6260
|
zip64UncompressedSize,
|
|
6050
6261
|
zip64CompressedSize,
|
|
6051
|
-
|
|
6052
|
-
diskNumberStart
|
|
6262
|
+
offset,
|
|
6263
|
+
diskNumberStart,
|
|
6053
6264
|
zip64DiskNumberStart: false,
|
|
6054
6265
|
rawExtraFieldZip64,
|
|
6055
6266
|
rawExtraFieldAES,
|
|
@@ -6069,11 +6280,8 @@ class ZipWriter {
|
|
|
6069
6280
|
async add(name = "", reader, options = {}) {
|
|
6070
6281
|
const zipWriter = this;
|
|
6071
6282
|
options = Object.assign({}, options);
|
|
6072
|
-
const {
|
|
6073
|
-
|
|
6074
|
-
config
|
|
6075
|
-
} = zipWriter;
|
|
6076
|
-
if (workers < config.maxWorkers) {
|
|
6283
|
+
const { pendingAddFileCalls } = zipWriter;
|
|
6284
|
+
if (workers < getConfiguration().maxWorkers) {
|
|
6077
6285
|
workers++;
|
|
6078
6286
|
} else {
|
|
6079
6287
|
await new Promise(resolve => pendingEntries.push(resolve));
|
|
@@ -6110,16 +6318,16 @@ class ZipWriter {
|
|
|
6110
6318
|
}
|
|
6111
6319
|
|
|
6112
6320
|
remove(entry) {
|
|
6113
|
-
const { filenames,
|
|
6321
|
+
const { filenames, fileEntries } = this;
|
|
6114
6322
|
// deno-lint-ignore valid-typeof
|
|
6115
6323
|
if (typeof entry == STRING_TYPE) {
|
|
6116
|
-
entry =
|
|
6324
|
+
entry = fileEntries.get(entry);
|
|
6117
6325
|
}
|
|
6118
6326
|
if (entry && entry.filename !== UNDEFINED_VALUE) {
|
|
6119
6327
|
const { filename } = entry;
|
|
6120
|
-
if (filenames.has(filename) &&
|
|
6328
|
+
if (filenames.has(filename) && fileEntries.has(filename)) {
|
|
6121
6329
|
filenames.delete(filename);
|
|
6122
|
-
|
|
6330
|
+
fileEntries.delete(filename);
|
|
6123
6331
|
return true;
|
|
6124
6332
|
}
|
|
6125
6333
|
}
|
|
@@ -6130,6 +6338,9 @@ class ZipWriter {
|
|
|
6130
6338
|
const zipWriter = this;
|
|
6131
6339
|
const { pendingAddFileCalls, writer } = this;
|
|
6132
6340
|
const { writable } = writer;
|
|
6341
|
+
if (!(comment instanceof Uint8Array)) {
|
|
6342
|
+
throw new Error(ERR_INVALID_COMMENT_TYPE);
|
|
6343
|
+
}
|
|
6133
6344
|
if (getLength(comment) > MAX_16_BITS) {
|
|
6134
6345
|
throw new Error(ERR_INVALID_COMMENT);
|
|
6135
6346
|
}
|
|
@@ -6213,12 +6424,12 @@ async function addFile(zipWriter, name, reader, options) {
|
|
|
6213
6424
|
const metadataInfo = resolveMetadata(zipWriter, name, options);
|
|
6214
6425
|
const { comment } = metadataInfo;
|
|
6215
6426
|
const extraField = options[PROPERTY_NAME_EXTRA_FIELD];
|
|
6216
|
-
zipWriter.
|
|
6427
|
+
zipWriter.fileEntries.set(name, UNDEFINED_VALUE);
|
|
6217
6428
|
let fileEntry;
|
|
6218
6429
|
try {
|
|
6219
6430
|
const { resolvedOptions } = metadataInfo;
|
|
6220
6431
|
if (resolvedOptions.level != 0 && resolvedOptions.compressionMethod === UNDEFINED_VALUE &&
|
|
6221
|
-
!resolvedOptions.passThrough && !(await supportsDeflate(
|
|
6432
|
+
!resolvedOptions.passThrough && !(await supportsDeflate(getConfiguration()))) {
|
|
6222
6433
|
resolvedOptions.level = 0;
|
|
6223
6434
|
}
|
|
6224
6435
|
const sizesInfo = await resolveSizes(zipWriter, reader, metadataInfo, options);
|
|
@@ -6226,8 +6437,6 @@ async function addFile(zipWriter, name, reader, options) {
|
|
|
6226
6437
|
const diskOffset = getDiskOffset(zipWriter.writer);
|
|
6227
6438
|
const diskNumber = getDiskNumber(zipWriter.writer);
|
|
6228
6439
|
options = Object.assign({}, options, attributesInfo.resolvedOptions, metadataInfo.resolvedOptions, sizesInfo.resolvedOptions, {
|
|
6229
|
-
internalFileAttribute: metadataInfo.resolvedOptions.internalFileAttributes,
|
|
6230
|
-
externalFileAttribute: attributesInfo.resolvedOptions.externalFileAttributes,
|
|
6231
6440
|
signature: options[PROPERTY_NAME_SIGNATURE],
|
|
6232
6441
|
crc32: options.crc32 === UNDEFINED_VALUE ? options[PROPERTY_NAME_SIGNATURE] : options.crc32,
|
|
6233
6442
|
offset: zipWriter.offset - diskOffset,
|
|
@@ -6238,17 +6447,23 @@ async function addFile(zipWriter, name, reader, options) {
|
|
|
6238
6447
|
const metadataSize = getLength(headerInfo.localHeaderArray, dataDescriptorInfo.dataDescriptorArray);
|
|
6239
6448
|
fileEntry = await getFileEntry(zipWriter, name, reader, { headerInfo, dataDescriptorInfo, metadataSize }, options);
|
|
6240
6449
|
} catch (error) {
|
|
6241
|
-
zipWriter.
|
|
6450
|
+
zipWriter.fileEntries.delete(name);
|
|
6242
6451
|
throw error;
|
|
6243
6452
|
}
|
|
6244
|
-
Object.assign(fileEntry, {
|
|
6453
|
+
Object.assign(fileEntry, {
|
|
6454
|
+
name,
|
|
6455
|
+
comment,
|
|
6456
|
+
extraField,
|
|
6457
|
+
[PROPERTY_NAME_DEPRECATED_INTERNAL_FILE_ATTRIBUTES]: fileEntry.internalFileAttributes,
|
|
6458
|
+
[PROPERTY_NAME_DEPRECATED_EXTERNAL_FILE_ATTRIBUTES]: fileEntry.externalFileAttributes
|
|
6459
|
+
});
|
|
6245
6460
|
return new Entry(fileEntry);
|
|
6246
6461
|
}
|
|
6247
6462
|
|
|
6248
6463
|
function resolveAttributes(zipWriter, name, options) {
|
|
6249
6464
|
name = name.trim();
|
|
6250
6465
|
let msDosCompatible = getOptionValue(zipWriter, options, PROPERTY_NAME_MS_DOS_COMPATIBLE);
|
|
6251
|
-
let versionMadeBy = getOptionValue(zipWriter, options, PROPERTY_NAME_VERSION_MADE_BY, msDosCompatible ?
|
|
6466
|
+
let versionMadeBy = getOptionValue(zipWriter, options, PROPERTY_NAME_VERSION_MADE_BY, msDosCompatible ? VERSION_MADE_BY_MSDOS : VERSION_MADE_BY_UNIX);
|
|
6252
6467
|
const executable = getOptionValue(zipWriter, options, PROPERTY_NAME_EXECUTABLE);
|
|
6253
6468
|
const uid = getNumberOptionValue(zipWriter, options, PROPERTY_NAME_UID);
|
|
6254
6469
|
const gid = getNumberOptionValue(zipWriter, options, PROPERTY_NAME_GID);
|
|
@@ -6276,21 +6491,21 @@ function resolveAttributes(zipWriter, name, options) {
|
|
|
6276
6491
|
if (unixExtraFieldType === UNDEFINED_VALUE && (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE)) {
|
|
6277
6492
|
unixExtraFieldType = INFOZIP_EXTRA_FIELD_TYPE$1;
|
|
6278
6493
|
}
|
|
6279
|
-
let msdosAttributesRaw =
|
|
6494
|
+
let msdosAttributesRaw = getNumberOptionValue(zipWriter, options, PROPERTY_NAME_MSDOS_ATTRIBUTES_RAW);
|
|
6280
6495
|
let msdosAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_MSDOS_ATTRIBUTES);
|
|
6281
|
-
const hasUnixMetadata = uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE || unixMode !== UNDEFINED_VALUE || unixExtraFieldType;
|
|
6496
|
+
const hasUnixMetadata = uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE || unixMode !== UNDEFINED_VALUE || unixExtraFieldType || executable;
|
|
6282
6497
|
const hasMsDosProvided = msdosAttributesRaw !== UNDEFINED_VALUE || msdosAttributes !== UNDEFINED_VALUE;
|
|
6283
6498
|
if (hasUnixMetadata) {
|
|
6284
6499
|
msDosCompatible = false;
|
|
6285
|
-
versionMadeBy = (versionMadeBy &
|
|
6500
|
+
versionMadeBy = (versionMadeBy & MAX_8_BITS) | VERSION_MADE_BY_UNIX;
|
|
6286
6501
|
} else if (hasMsDosProvided) {
|
|
6287
6502
|
msDosCompatible = true;
|
|
6288
6503
|
versionMadeBy = (versionMadeBy & MAX_8_BITS);
|
|
6289
6504
|
}
|
|
6290
|
-
if (msdosAttributesRaw !== UNDEFINED_VALUE && (msdosAttributesRaw < 0 || msdosAttributesRaw > MAX_8_BITS)) {
|
|
6505
|
+
if (msdosAttributesRaw !== UNDEFINED_VALUE && (!Number.isInteger(msdosAttributesRaw) || msdosAttributesRaw < 0 || msdosAttributesRaw > MAX_8_BITS)) {
|
|
6291
6506
|
throw new Error(ERR_INVALID_MSDOS_ATTRIBUTES);
|
|
6292
6507
|
}
|
|
6293
|
-
if (msdosAttributes && typeof msdosAttributes !== OBJECT_TYPE) {
|
|
6508
|
+
if (msdosAttributes && (typeof msdosAttributes !== OBJECT_TYPE || Array.isArray(msdosAttributes))) {
|
|
6294
6509
|
throw new Error(ERR_INVALID_MSDOS_DATA);
|
|
6295
6510
|
}
|
|
6296
6511
|
if (versionMadeBy > MAX_16_BITS) {
|
|
@@ -6322,11 +6537,10 @@ function resolveAttributes(zipWriter, name, options) {
|
|
|
6322
6537
|
externalFileAttributes = FILE_ATTR_UNIX_DEFAULT_MASK << 16;
|
|
6323
6538
|
}
|
|
6324
6539
|
}
|
|
6325
|
-
let unixExternalUpper;
|
|
6326
6540
|
if (!msDosCompatible) {
|
|
6327
6541
|
const unixModeProvided = unixMode !== UNDEFINED_VALUE || Boolean(setuid || setgid || sticky);
|
|
6328
|
-
|
|
6329
|
-
unixMode = unixMode === UNDEFINED_VALUE ?
|
|
6542
|
+
const defaultUnixMode = (externalFileAttributes >> 16) & MAX_16_BITS;
|
|
6543
|
+
unixMode = unixMode === UNDEFINED_VALUE ? defaultUnixMode : (unixMode & MAX_16_BITS);
|
|
6330
6544
|
if (setuid) {
|
|
6331
6545
|
unixMode |= FILE_ATTR_UNIX_SETUID_MASK;
|
|
6332
6546
|
} else {
|
|
@@ -6355,17 +6569,20 @@ function resolveAttributes(zipWriter, name, options) {
|
|
|
6355
6569
|
if (hasMsDosProvided) {
|
|
6356
6570
|
externalFileAttributes = (externalFileAttributes & MAX_32_BITS) | (msdosAttributesRaw & MAX_8_BITS);
|
|
6357
6571
|
}
|
|
6572
|
+
const unixExternalUpper = (externalFileAttributes >> 16) & MAX_16_BITS;
|
|
6573
|
+
const symlink = unixMode !== UNDEFINED_VALUE && ((unixMode & FILE_ATTR_UNIX_TYPE_MASK) == FILE_ATTR_UNIX_TYPE_SYMLINK);
|
|
6358
6574
|
return {
|
|
6359
6575
|
name,
|
|
6360
6576
|
resolvedOptions: {
|
|
6361
6577
|
versionMadeBy,
|
|
6362
|
-
msDosCompatible,
|
|
6578
|
+
msDosCompatible: Boolean(msDosCompatible),
|
|
6363
6579
|
externalFileAttributes,
|
|
6364
6580
|
unixExternalUpper,
|
|
6365
6581
|
uid,
|
|
6366
6582
|
gid,
|
|
6367
6583
|
unixMode,
|
|
6368
6584
|
unixExtraFieldType,
|
|
6585
|
+
symlink,
|
|
6369
6586
|
setuid,
|
|
6370
6587
|
setgid,
|
|
6371
6588
|
sticky,
|
|
@@ -6376,7 +6593,7 @@ function resolveAttributes(zipWriter, name, options) {
|
|
|
6376
6593
|
}
|
|
6377
6594
|
|
|
6378
6595
|
function resolveMetadata(zipWriter, name, options) {
|
|
6379
|
-
const encode =
|
|
6596
|
+
const encode = getFunctionOptionValue(zipWriter, options, OPTION_ENCODE_TEXT) || encodeText;
|
|
6380
6597
|
let rawFilename = encode(name, TEXT_TYPE_FILENAME);
|
|
6381
6598
|
if (rawFilename === UNDEFINED_VALUE) {
|
|
6382
6599
|
rawFilename = encodeText(name);
|
|
@@ -6385,6 +6602,10 @@ function resolveMetadata(zipWriter, name, options) {
|
|
|
6385
6602
|
throw new Error(ERR_INVALID_ENTRY_NAME);
|
|
6386
6603
|
}
|
|
6387
6604
|
const comment = options[PROPERTY_NAME_COMMENT] || "";
|
|
6605
|
+
// deno-lint-ignore valid-typeof
|
|
6606
|
+
if (typeof comment != STRING_TYPE) {
|
|
6607
|
+
throw new Error(ERR_INVALID_ENTRY_COMMENT_TYPE);
|
|
6608
|
+
}
|
|
6388
6609
|
let rawComment = encode(comment, TEXT_TYPE_COMMENT);
|
|
6389
6610
|
if (rawComment === UNDEFINED_VALUE) {
|
|
6390
6611
|
rawComment = encodeText(comment);
|
|
@@ -6396,16 +6617,14 @@ function resolveMetadata(zipWriter, name, options) {
|
|
|
6396
6617
|
if (version > MAX_16_BITS) {
|
|
6397
6618
|
throw new Error(ERR_INVALID_VERSION);
|
|
6398
6619
|
}
|
|
6399
|
-
const lastModDate =
|
|
6400
|
-
const lastAccessDate =
|
|
6401
|
-
const creationDate =
|
|
6620
|
+
const lastModDate = getDateOptionValue(zipWriter, options, PROPERTY_NAME_LAST_MODIFICATION_DATE, new Date());
|
|
6621
|
+
const lastAccessDate = getDateOptionValue(zipWriter, options, PROPERTY_NAME_LAST_ACCESS_DATE);
|
|
6622
|
+
const creationDate = getDateOptionValue(zipWriter, options, PROPERTY_NAME_CREATION_DATE);
|
|
6402
6623
|
const internalFileAttributes = getAliasedOptionValue(zipWriter, options, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES, PROPERTY_NAME_DEPRECATED_INTERNAL_FILE_ATTRIBUTES, 0);
|
|
6403
6624
|
const passThrough = getOptionValue(zipWriter, options, OPTION_PASS_THROUGH);
|
|
6404
6625
|
const password = getOptionValue(zipWriter, options, OPTION_PASSWORD);
|
|
6405
6626
|
const rawPassword = getOptionValue(zipWriter, options, OPTION_RAW_PASSWORD);
|
|
6406
|
-
|
|
6407
|
-
throw new Error(ERR_INVALID_PASSWORD_TYPE);
|
|
6408
|
-
}
|
|
6627
|
+
checkPasswordOption(password, rawPassword);
|
|
6409
6628
|
const encryptionStrength = getNumberOptionValue(zipWriter, options, OPTION_ENCRYPTION_STRENGTH, 3);
|
|
6410
6629
|
const zipCrypto = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIPCRYPTO);
|
|
6411
6630
|
const extendedTimestamp = getOptionValue(zipWriter, options, OPTION_EXTENDED_TIMESTAMP, true);
|
|
@@ -6414,9 +6633,9 @@ function resolveMetadata(zipWriter, name, options) {
|
|
|
6414
6633
|
const useWebWorkers = getOptionValue(zipWriter, options, OPTION_USE_WEB_WORKERS);
|
|
6415
6634
|
const transferStreams = getOptionValue(zipWriter, options, OPTION_TRANSFER_STREAMS);
|
|
6416
6635
|
const bufferedWrite = getOptionValue(zipWriter, options, OPTION_BUFFERED_WRITE);
|
|
6417
|
-
const createTempStream =
|
|
6636
|
+
const createTempStream = getFunctionOptionValue(zipWriter, options, OPTION_CREATE_TEMP_STREAM);
|
|
6418
6637
|
const dataDescriptorSignature = getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR_SIGNATURE, true);
|
|
6419
|
-
const signal = getOptionValue(zipWriter, options, OPTION_SIGNAL);
|
|
6638
|
+
const signal = checkSignalOption(getOptionValue(zipWriter, options, OPTION_SIGNAL));
|
|
6420
6639
|
const useUnicodeFileNames = getOptionValue(zipWriter, options, OPTION_USE_UNICODE_FILE_NAMES, true);
|
|
6421
6640
|
const compressionMethod = getOptionValue(zipWriter, options, PROPERTY_NAME_COMPRESSION_METHOD);
|
|
6422
6641
|
const registeredCodec = passThrough || compressionMethod === UNDEFINED_VALUE ? UNDEFINED_VALUE : getRegisteredCodec(compressionMethod);
|
|
@@ -6496,18 +6715,26 @@ function serializeExtraField(extraField) {
|
|
|
6496
6715
|
if (!extraField) {
|
|
6497
6716
|
return EMPTY_UINT8_ARRAY;
|
|
6498
6717
|
}
|
|
6718
|
+
if (!(extraField instanceof Map)) {
|
|
6719
|
+
throw new Error(ERR_INVALID_EXTRAFIELD);
|
|
6720
|
+
}
|
|
6499
6721
|
let extraFieldSize = 0;
|
|
6500
6722
|
let offset = 0;
|
|
6501
|
-
extraField.forEach(data => extraFieldSize += 4 + getLength(data));
|
|
6502
|
-
const rawExtraField = new Uint8Array(extraFieldSize);
|
|
6503
|
-
const rawExtraFieldView = getDataView(rawExtraField);
|
|
6504
6723
|
extraField.forEach((data, type) => {
|
|
6505
|
-
if (type > MAX_16_BITS) {
|
|
6724
|
+
if (!Number.isInteger(type) || type < 0 || type > MAX_16_BITS) {
|
|
6506
6725
|
throw new Error(ERR_INVALID_EXTRAFIELD_TYPE);
|
|
6507
6726
|
}
|
|
6727
|
+
if (!(data instanceof Uint8Array)) {
|
|
6728
|
+
throw new Error(ERR_INVALID_EXTRAFIELD_DATA_TYPE);
|
|
6729
|
+
}
|
|
6508
6730
|
if (getLength(data) > MAX_16_BITS) {
|
|
6509
6731
|
throw new Error(ERR_INVALID_EXTRAFIELD_DATA);
|
|
6510
6732
|
}
|
|
6733
|
+
extraFieldSize += 4 + getLength(data);
|
|
6734
|
+
});
|
|
6735
|
+
const rawExtraField = new Uint8Array(extraFieldSize);
|
|
6736
|
+
const rawExtraFieldView = getDataView(rawExtraField);
|
|
6737
|
+
extraField.forEach((data, type) => {
|
|
6511
6738
|
setUint16(rawExtraFieldView, offset, type);
|
|
6512
6739
|
setUint16(rawExtraFieldView, offset + 2, getLength(data));
|
|
6513
6740
|
arraySet(rawExtraField, data, offset + 4);
|
|
@@ -6594,10 +6821,13 @@ function resolveEntrySizes(zipWriter, hasContent, contentSize, metadata, options
|
|
|
6594
6821
|
}
|
|
6595
6822
|
|
|
6596
6823
|
async function getEntriesSize(writerOptions, entries, writeOrderGuaranteed, comment) {
|
|
6597
|
-
const zipWriter = { options: writerOptions
|
|
6598
|
-
if (writerOptions[OPTION_SIGN_CENTRAL_DIRECTORY]) {
|
|
6824
|
+
const zipWriter = { options: writerOptions };
|
|
6825
|
+
if (checkFunctionOption(writerOptions[OPTION_SIGN_CENTRAL_DIRECTORY])) {
|
|
6599
6826
|
throw new Error(ERR_UNDETERMINED_SIZE);
|
|
6600
6827
|
}
|
|
6828
|
+
if (comment !== UNDEFINED_VALUE && !(comment instanceof Uint8Array)) {
|
|
6829
|
+
throw new Error(ERR_INVALID_COMMENT_TYPE);
|
|
6830
|
+
}
|
|
6601
6831
|
const commentLength = getLength(comment);
|
|
6602
6832
|
if (commentLength > MAX_16_BITS) {
|
|
6603
6833
|
throw new Error(ERR_INVALID_COMMENT);
|
|
@@ -6618,7 +6848,7 @@ async function getEntriesSize(writerOptions, entries, writeOrderGuaranteed, comm
|
|
|
6618
6848
|
({ name } = attributesInfo);
|
|
6619
6849
|
const { resolvedOptions: metadata } = resolveMetadata(zipWriter, name, options);
|
|
6620
6850
|
if (metadata.level != 0 && metadata.compressionMethod === UNDEFINED_VALUE &&
|
|
6621
|
-
!metadata.passThrough && !(await supportsDeflate(
|
|
6851
|
+
!metadata.passThrough && !(await supportsDeflate(getConfiguration()))) {
|
|
6622
6852
|
metadata.level = 0;
|
|
6623
6853
|
}
|
|
6624
6854
|
const hasContent = !getOptionValue(zipWriter, options, PROPERTY_NAME_DIRECTORY);
|
|
@@ -6667,7 +6897,7 @@ async function getEntriesSize(writerOptions, entries, writeOrderGuaranteed, comm
|
|
|
6667
6897
|
|
|
6668
6898
|
async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
|
|
6669
6899
|
const {
|
|
6670
|
-
|
|
6900
|
+
fileEntries,
|
|
6671
6901
|
writer
|
|
6672
6902
|
} = zipWriter;
|
|
6673
6903
|
const {
|
|
@@ -6689,12 +6919,12 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
|
|
|
6689
6919
|
let writerSizeBeforeEntry;
|
|
6690
6920
|
let flushedBufferedSize = 0;
|
|
6691
6921
|
let fileWriter;
|
|
6692
|
-
|
|
6922
|
+
fileEntries.set(name, fileEntry);
|
|
6693
6923
|
zipWriter.lastFileEntry = fileEntry;
|
|
6694
6924
|
try {
|
|
6695
6925
|
let lockPreviousFileEntry;
|
|
6696
6926
|
if (keepOrder) {
|
|
6697
|
-
lockPreviousFileEntry = previousFileEntry && previousFileEntry.
|
|
6927
|
+
lockPreviousFileEntry = previousFileEntry && previousFileEntry.lockFileEntry;
|
|
6698
6928
|
requestLockCurrentFileEntry();
|
|
6699
6929
|
}
|
|
6700
6930
|
if (options.bufferedWrite || !keepOrder || zipWriter.writerLocked || zipWriter.bufferedWrites || !dataDescriptor) {
|
|
@@ -6715,11 +6945,8 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
|
|
|
6715
6945
|
const diskOffset = getDiskOffset(writer);
|
|
6716
6946
|
if (zipWriter.addSplitZipSignature) {
|
|
6717
6947
|
delete zipWriter.addSplitZipSignature;
|
|
6718
|
-
|
|
6719
|
-
|
|
6720
|
-
setUint32(signatureArrayView, 0, SPLIT_ZIP_FILE_SIGNATURE);
|
|
6721
|
-
await writeData(writer, signatureArray);
|
|
6722
|
-
zipWriter.offset += 4;
|
|
6948
|
+
await writeData(writer, getSplitZipSignatureArray());
|
|
6949
|
+
zipWriter.offset += SPLIT_ZIP_FILE_SIGNATURE_LENGTH;
|
|
6723
6950
|
}
|
|
6724
6951
|
if (usdz && !bufferedWrite) {
|
|
6725
6952
|
appendExtraFieldUSDZ(entryInfo, zipWriter.offset - diskOffset);
|
|
@@ -6737,11 +6964,11 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
|
|
|
6737
6964
|
writerSizeBeforeEntry = writer.size;
|
|
6738
6965
|
await writeData(fileWriter, localHeaderArray);
|
|
6739
6966
|
}
|
|
6740
|
-
fileEntry = await createFileEntry(reader, fileWriter, fileEntry, entryInfo,
|
|
6967
|
+
fileEntry = await createFileEntry(reader, fileWriter, fileEntry, entryInfo, getConfiguration(), options);
|
|
6741
6968
|
if (!bufferedWrite) {
|
|
6742
6969
|
writingEntryData = false;
|
|
6743
6970
|
}
|
|
6744
|
-
|
|
6971
|
+
fileEntries.set(name, fileEntry);
|
|
6745
6972
|
fileEntry.filename = name;
|
|
6746
6973
|
if (bufferedWrite) {
|
|
6747
6974
|
await Promise.all([fileWriter.writable.getWriter().close(), lockPreviousFileEntry]);
|
|
@@ -6782,7 +7009,7 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
|
|
|
6782
7009
|
zipWriter.offset += flushedBufferedSize;
|
|
6783
7010
|
}
|
|
6784
7011
|
}
|
|
6785
|
-
|
|
7012
|
+
fileEntries.delete(name);
|
|
6786
7013
|
throw error;
|
|
6787
7014
|
} finally {
|
|
6788
7015
|
if (bufferedWrite) {
|
|
@@ -6804,7 +7031,7 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
|
|
|
6804
7031
|
}
|
|
6805
7032
|
|
|
6806
7033
|
function requestLockCurrentFileEntry() {
|
|
6807
|
-
fileEntry.
|
|
7034
|
+
fileEntry.lockFileEntry = new Promise(resolve => releaseLockCurrentFileEntry = resolve);
|
|
6808
7035
|
}
|
|
6809
7036
|
|
|
6810
7037
|
async function requestLockWriter() {
|
|
@@ -6824,7 +7051,7 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
|
|
|
6824
7051
|
}
|
|
6825
7052
|
}
|
|
6826
7053
|
|
|
6827
|
-
async function createFileEntry(reader, writer, { diskNumberStart,
|
|
7054
|
+
async function createFileEntry(reader, writer, { diskNumberStart, lockFileEntry }, entryInfo, config, options) {
|
|
6828
7055
|
const {
|
|
6829
7056
|
headerInfo,
|
|
6830
7057
|
dataDescriptorInfo,
|
|
@@ -6879,6 +7106,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
|
|
|
6879
7106
|
uid,
|
|
6880
7107
|
gid,
|
|
6881
7108
|
unixMode,
|
|
7109
|
+
symlink,
|
|
6882
7110
|
setuid,
|
|
6883
7111
|
setgid,
|
|
6884
7112
|
sticky,
|
|
@@ -6891,7 +7119,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
|
|
|
6891
7119
|
codecURI
|
|
6892
7120
|
} = options;
|
|
6893
7121
|
const fileEntry = {
|
|
6894
|
-
|
|
7122
|
+
lockFileEntry,
|
|
6895
7123
|
versionMadeBy,
|
|
6896
7124
|
zip64,
|
|
6897
7125
|
directory: Boolean(directory),
|
|
@@ -6915,6 +7143,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
|
|
|
6915
7143
|
uid,
|
|
6916
7144
|
gid,
|
|
6917
7145
|
unixMode,
|
|
7146
|
+
symlink: Boolean(symlink),
|
|
6918
7147
|
setuid,
|
|
6919
7148
|
setgid,
|
|
6920
7149
|
sticky,
|
|
@@ -6932,7 +7161,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
|
|
|
6932
7161
|
}
|
|
6933
7162
|
const { writable } = writer;
|
|
6934
7163
|
if (reader) {
|
|
6935
|
-
const readable = toCompatibleReadable(
|
|
7164
|
+
const readable = toCompatibleReadable(createReadable(reader));
|
|
6936
7165
|
const size = reader.size;
|
|
6937
7166
|
const workerOptions = {
|
|
6938
7167
|
options: {
|
|
@@ -6995,8 +7224,8 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
|
|
|
6995
7224
|
rawLastModDate,
|
|
6996
7225
|
creationDate,
|
|
6997
7226
|
lastAccessDate,
|
|
6998
|
-
encrypted,
|
|
6999
|
-
zipCrypto,
|
|
7227
|
+
encrypted: Boolean(encrypted),
|
|
7228
|
+
zipCrypto: Boolean(zipCrypto),
|
|
7000
7229
|
size: metadataSize + compressedSize,
|
|
7001
7230
|
compressionMethod,
|
|
7002
7231
|
version,
|
|
@@ -7044,14 +7273,14 @@ function getHeaderInfo(options) {
|
|
|
7044
7273
|
if (zip64 && (zip64UncompressedSize || zip64CompressedSize)) {
|
|
7045
7274
|
const length = 4 + 16;
|
|
7046
7275
|
const extraFieldZip64 = createRecordWriter(length);
|
|
7047
|
-
extraFieldZip64.
|
|
7048
|
-
extraFieldZip64.
|
|
7276
|
+
extraFieldZip64.writeUint16(EXTRAFIELD_TYPE_ZIP64);
|
|
7277
|
+
extraFieldZip64.writeUint16(length - 4);
|
|
7049
7278
|
rawLocalExtraFieldZip64 = extraFieldZip64.array;
|
|
7050
7279
|
if (zip64ExtraFieldComplete) {
|
|
7051
|
-
extraFieldZip64.
|
|
7280
|
+
extraFieldZip64.writeUint64(uncompressedSize);
|
|
7052
7281
|
if (uncompressedFile) {
|
|
7053
7282
|
const encryptionOverhead = encrypted ? (zipCrypto ? 12 : 16 + encryptionStrength * 4) : 0;
|
|
7054
|
-
extraFieldZip64.
|
|
7283
|
+
extraFieldZip64.writeUint64(passThrough ? 0 : uncompressedSize + encryptionOverhead);
|
|
7055
7284
|
}
|
|
7056
7285
|
}
|
|
7057
7286
|
} else {
|
|
@@ -7060,8 +7289,8 @@ function getHeaderInfo(options) {
|
|
|
7060
7289
|
let rawExtraFieldAES;
|
|
7061
7290
|
if (encrypted && !zipCrypto) {
|
|
7062
7291
|
const extraFieldAES = createRecordWriter(getLength(EXTRAFIELD_DATA_AES) + 2);
|
|
7063
|
-
extraFieldAES.
|
|
7064
|
-
extraFieldAES.
|
|
7292
|
+
extraFieldAES.writeUint16(EXTRAFIELD_TYPE_AES);
|
|
7293
|
+
extraFieldAES.writeBytes(EXTRAFIELD_DATA_AES);
|
|
7065
7294
|
rawExtraFieldAES = extraFieldAES.array;
|
|
7066
7295
|
rawExtraFieldAES[8] = encryptionStrength;
|
|
7067
7296
|
} else {
|
|
@@ -7077,15 +7306,15 @@ function getHeaderInfo(options) {
|
|
|
7077
7306
|
const extraFieldTimestampLength = 9 + (lastAccessDate ? 4 : 0) + (creationDate ? 4 : 0);
|
|
7078
7307
|
const extraFieldTimestamp = createRecordWriter(extraFieldTimestampLength);
|
|
7079
7308
|
extraFieldExtendedTimestampFlag = 0x1 + (lastAccessDate ? 0x2 : 0) + (creationDate ? 0x4 : 0);
|
|
7080
|
-
extraFieldTimestamp.
|
|
7081
|
-
extraFieldTimestamp.
|
|
7082
|
-
extraFieldTimestamp.
|
|
7083
|
-
extraFieldTimestamp.
|
|
7309
|
+
extraFieldTimestamp.writeUint16(EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
|
|
7310
|
+
extraFieldTimestamp.writeUint16(extraFieldTimestampLength - 4);
|
|
7311
|
+
extraFieldTimestamp.writeUint8(extraFieldExtendedTimestampFlag);
|
|
7312
|
+
extraFieldTimestamp.writeUint32(lastModTimeUnix);
|
|
7084
7313
|
if (lastAccessDate) {
|
|
7085
|
-
extraFieldTimestamp.
|
|
7314
|
+
extraFieldTimestamp.writeUint32(clampUnixTime(getTimeUnix(lastAccessDate)));
|
|
7086
7315
|
}
|
|
7087
7316
|
if (creationDate) {
|
|
7088
|
-
extraFieldTimestamp.
|
|
7317
|
+
extraFieldTimestamp.writeUint32(clampUnixTime(getTimeUnix(creationDate)));
|
|
7089
7318
|
}
|
|
7090
7319
|
rawExtraFieldExtendedTimestamp = extraFieldTimestamp.array;
|
|
7091
7320
|
} else {
|
|
@@ -7098,14 +7327,14 @@ function getHeaderInfo(options) {
|
|
|
7098
7327
|
try {
|
|
7099
7328
|
const lastModTimeNTFS = getTimeNTFS(lastModDate);
|
|
7100
7329
|
const extraFieldNTFS = createRecordWriter(36);
|
|
7101
|
-
extraFieldNTFS.
|
|
7102
|
-
extraFieldNTFS.
|
|
7330
|
+
extraFieldNTFS.writeUint16(EXTRAFIELD_TYPE_NTFS);
|
|
7331
|
+
extraFieldNTFS.writeUint16(32);
|
|
7103
7332
|
extraFieldNTFS.skip(4);
|
|
7104
|
-
extraFieldNTFS.
|
|
7105
|
-
extraFieldNTFS.
|
|
7106
|
-
extraFieldNTFS.
|
|
7107
|
-
extraFieldNTFS.
|
|
7108
|
-
extraFieldNTFS.
|
|
7333
|
+
extraFieldNTFS.writeUint16(EXTRAFIELD_TYPE_NTFS_TAG1);
|
|
7334
|
+
extraFieldNTFS.writeUint16(24);
|
|
7335
|
+
extraFieldNTFS.writeUint64(lastModTimeNTFS);
|
|
7336
|
+
extraFieldNTFS.writeUint64(lastAccessDate ? getTimeNTFS(lastAccessDate) : lastModTimeNTFS);
|
|
7337
|
+
extraFieldNTFS.writeUint64(creationDate ? getTimeNTFS(creationDate) : lastModTimeNTFS);
|
|
7109
7338
|
rawExtraFieldNTFS = extraFieldNTFS.array;
|
|
7110
7339
|
} catch {
|
|
7111
7340
|
rawExtraFieldNTFS = EMPTY_UINT8_ARRAY;
|
|
@@ -7124,20 +7353,20 @@ function getHeaderInfo(options) {
|
|
|
7124
7353
|
const gidBytes = packUnixId(gid);
|
|
7125
7354
|
const payloadLength = 3 + uidBytes.length + gidBytes.length;
|
|
7126
7355
|
const extraFieldUnix = createRecordWriter(4 + payloadLength);
|
|
7127
|
-
extraFieldUnix.
|
|
7128
|
-
extraFieldUnix.
|
|
7129
|
-
extraFieldUnix.
|
|
7130
|
-
extraFieldUnix.
|
|
7131
|
-
extraFieldUnix.
|
|
7132
|
-
extraFieldUnix.
|
|
7133
|
-
extraFieldUnix.
|
|
7356
|
+
extraFieldUnix.writeUint16(EXTRAFIELD_TYPE_INFOZIP);
|
|
7357
|
+
extraFieldUnix.writeUint16(payloadLength);
|
|
7358
|
+
extraFieldUnix.writeUint8(1);
|
|
7359
|
+
extraFieldUnix.writeUint8(uidBytes.length);
|
|
7360
|
+
extraFieldUnix.writeBytes(uidBytes);
|
|
7361
|
+
extraFieldUnix.writeUint8(gidBytes.length);
|
|
7362
|
+
extraFieldUnix.writeBytes(gidBytes);
|
|
7134
7363
|
rawExtraFieldUnix = extraFieldUnix.array;
|
|
7135
7364
|
} else if (unixExtraFieldType == UNIX_EXTRA_FIELD_TYPE && (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE)) {
|
|
7136
7365
|
const extraFieldUnix = createRecordWriter(8);
|
|
7137
|
-
extraFieldUnix.
|
|
7138
|
-
extraFieldUnix.
|
|
7139
|
-
extraFieldUnix.
|
|
7140
|
-
extraFieldUnix.
|
|
7366
|
+
extraFieldUnix.writeUint16(EXTRAFIELD_TYPE_UNIX);
|
|
7367
|
+
extraFieldUnix.writeUint16(4);
|
|
7368
|
+
extraFieldUnix.writeUint16((uid === UNDEFINED_VALUE ? 0 : uid) & MAX_16_BITS);
|
|
7369
|
+
extraFieldUnix.writeUint16((gid === UNDEFINED_VALUE ? 0 : gid) & MAX_16_BITS);
|
|
7141
7370
|
rawExtraFieldUnix = extraFieldUnix.array;
|
|
7142
7371
|
} else {
|
|
7143
7372
|
rawExtraFieldUnix = EMPTY_UINT8_ARRAY;
|
|
@@ -7187,18 +7416,18 @@ function getHeaderInfo(options) {
|
|
|
7187
7416
|
const localHeader = createRecordWriter(HEADER_SIZE + getLength(rawFilename) + extraFieldLength);
|
|
7188
7417
|
const localHeaderArray = localHeader.array;
|
|
7189
7418
|
const localHeaderView = getDataView(localHeaderArray);
|
|
7190
|
-
localHeader.
|
|
7191
|
-
localHeader.
|
|
7192
|
-
localHeader.
|
|
7419
|
+
localHeader.writeUint32(LOCAL_FILE_HEADER_SIGNATURE);
|
|
7420
|
+
localHeader.writeBytes(headerArray);
|
|
7421
|
+
localHeader.writeBytes(rawFilename);
|
|
7193
7422
|
if (writeLocalExtraFieldZip64) {
|
|
7194
|
-
localHeader.
|
|
7195
|
-
}
|
|
7196
|
-
localHeader.
|
|
7197
|
-
localHeader.
|
|
7198
|
-
localHeader.
|
|
7199
|
-
localHeader.
|
|
7200
|
-
localHeader.
|
|
7201
|
-
localHeader.
|
|
7423
|
+
localHeader.writeBytes(rawLocalExtraFieldZip64);
|
|
7424
|
+
}
|
|
7425
|
+
localHeader.writeBytes(rawExtraFieldAES);
|
|
7426
|
+
localHeader.writeBytes(rawExtraFieldExtendedTimestamp);
|
|
7427
|
+
localHeader.writeBytes(rawExtraFieldNTFS);
|
|
7428
|
+
localHeader.writeBytes(rawExtraFieldUnix);
|
|
7429
|
+
localHeader.writeBytes(rawExtraField);
|
|
7430
|
+
localHeader.writeBytes(rawLocalExtraField);
|
|
7202
7431
|
if (dataDescriptor) {
|
|
7203
7432
|
if (!zip64CompressedSize) {
|
|
7204
7433
|
setUint32(localHeaderView, HEADER_OFFSET_COMPRESSED_SIZE + LOCAL_HEADER_COMMON_OFFSET, 0);
|
|
@@ -7388,7 +7617,7 @@ function updateLocalHeader({
|
|
|
7388
7617
|
|
|
7389
7618
|
|
|
7390
7619
|
async function closeFile(zipWriter, comment, options) {
|
|
7391
|
-
const directoryDataLength = createDirectoryRecords(zipWriter.
|
|
7620
|
+
const directoryDataLength = createDirectoryRecords(zipWriter.fileEntries);
|
|
7392
7621
|
const { directoryStart, directoryArray } = await writeDirectoryRecords(zipWriter, directoryDataLength, options);
|
|
7393
7622
|
const signatureLength = await writeDigitalSignatureRecord(zipWriter, directoryArray, options);
|
|
7394
7623
|
await writeEndOfDirectoryRecord(zipWriter, comment, options, { directoryStart, directoryDataLength, signatureLength });
|
|
@@ -7418,19 +7647,19 @@ function createDirectoryRecords(files) {
|
|
|
7418
7647
|
if (zip64Offset || zip64DiskNumberStart || zip64UncompressedSize || zip64CompressedSize) {
|
|
7419
7648
|
const length = 4 + (zip64UncompressedSize ? 8 : 0) + (zip64CompressedSize ? 8 : 0) + (zip64Offset ? 8 : 0) + (zip64DiskNumberStart ? 4 : 0);
|
|
7420
7649
|
const extraFieldZip64 = createRecordWriter(length);
|
|
7421
|
-
extraFieldZip64.
|
|
7422
|
-
extraFieldZip64.
|
|
7650
|
+
extraFieldZip64.writeUint16(EXTRAFIELD_TYPE_ZIP64);
|
|
7651
|
+
extraFieldZip64.writeUint16(length - 4);
|
|
7423
7652
|
if (zip64UncompressedSize) {
|
|
7424
|
-
extraFieldZip64.
|
|
7653
|
+
extraFieldZip64.writeUint64(uncompressedSize);
|
|
7425
7654
|
}
|
|
7426
7655
|
if (zip64CompressedSize) {
|
|
7427
|
-
extraFieldZip64.
|
|
7656
|
+
extraFieldZip64.writeUint64(compressedSize);
|
|
7428
7657
|
}
|
|
7429
7658
|
if (zip64Offset) {
|
|
7430
|
-
extraFieldZip64.
|
|
7659
|
+
extraFieldZip64.writeUint64(fileEntry.offset);
|
|
7431
7660
|
}
|
|
7432
7661
|
if (zip64DiskNumberStart) {
|
|
7433
|
-
extraFieldZip64.
|
|
7662
|
+
extraFieldZip64.writeUint32(fileEntry.diskNumberStart);
|
|
7434
7663
|
}
|
|
7435
7664
|
rawExtraFieldZip64 = extraFieldZip64.array;
|
|
7436
7665
|
} else {
|
|
@@ -7443,10 +7672,10 @@ function createDirectoryRecords(files) {
|
|
|
7443
7672
|
const lastModTimeUnix = getTimeUnix(lastModDate);
|
|
7444
7673
|
if (extendedTimestamp && inUnixTimeRange(lastModTimeUnix)) {
|
|
7445
7674
|
const extraFieldTimestamp = createRecordWriter(9);
|
|
7446
|
-
extraFieldTimestamp.
|
|
7447
|
-
extraFieldTimestamp.
|
|
7448
|
-
extraFieldTimestamp.
|
|
7449
|
-
extraFieldTimestamp.
|
|
7675
|
+
extraFieldTimestamp.writeUint16(EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
|
|
7676
|
+
extraFieldTimestamp.writeUint16(5);
|
|
7677
|
+
extraFieldTimestamp.writeUint8(extraFieldExtendedTimestampFlag);
|
|
7678
|
+
extraFieldTimestamp.writeUint32(lastModTimeUnix);
|
|
7450
7679
|
rawExtraFieldTimestamp = extraFieldTimestamp.array;
|
|
7451
7680
|
} else {
|
|
7452
7681
|
rawExtraFieldTimestamp = EMPTY_UINT8_ARRAY;
|
|
@@ -7468,14 +7697,14 @@ function createDirectoryRecords(files) {
|
|
|
7468
7697
|
}
|
|
7469
7698
|
|
|
7470
7699
|
async function writeDirectoryRecords(zipWriter, directoryDataLength, options) {
|
|
7471
|
-
const {
|
|
7700
|
+
const { fileEntries, writer } = zipWriter;
|
|
7472
7701
|
const directoryArray = new Uint8Array(directoryDataLength);
|
|
7473
7702
|
await initStream(writer);
|
|
7474
7703
|
let offset = 0;
|
|
7475
7704
|
let directoryDiskOffset = 0;
|
|
7476
7705
|
let directoryStartDiskNumber = getDiskNumber(writer);
|
|
7477
7706
|
let directoryStartDiskOffset = getDiskOffset(writer);
|
|
7478
|
-
for (const [indexFileEntry, fileEntry] of Array.from(
|
|
7707
|
+
for (const [indexFileEntry, fileEntry] of Array.from(fileEntries.values()).entries()) {
|
|
7479
7708
|
const {
|
|
7480
7709
|
offset: fileEntryOffset,
|
|
7481
7710
|
rawFilename,
|
|
@@ -7520,28 +7749,28 @@ async function writeDirectoryRecords(zipWriter, directoryDataLength, options) {
|
|
|
7520
7749
|
setUint16(headerView, HEADER_OFFSET_VERSION, VERSION_ZIP64);
|
|
7521
7750
|
}
|
|
7522
7751
|
const directoryRecord = createRecordWriter(directoryRecordLength);
|
|
7523
|
-
directoryRecord.
|
|
7524
|
-
directoryRecord.
|
|
7525
|
-
directoryRecord.
|
|
7526
|
-
directoryRecord.
|
|
7527
|
-
directoryRecord.
|
|
7528
|
-
directoryRecord.
|
|
7529
|
-
directoryRecord.
|
|
7530
|
-
directoryRecord.
|
|
7531
|
-
directoryRecord.
|
|
7532
|
-
directoryRecord.
|
|
7533
|
-
directoryRecord.
|
|
7534
|
-
directoryRecord.
|
|
7535
|
-
directoryRecord.
|
|
7536
|
-
directoryRecord.
|
|
7537
|
-
directoryRecord.
|
|
7538
|
-
directoryRecord.
|
|
7539
|
-
directoryRecord.
|
|
7752
|
+
directoryRecord.writeUint32(CENTRAL_FILE_HEADER_SIGNATURE);
|
|
7753
|
+
directoryRecord.writeUint16(versionMadeBy);
|
|
7754
|
+
directoryRecord.writeBytes(headerArray.subarray(0, HEADER_SIZE - 4 - 2));
|
|
7755
|
+
directoryRecord.writeUint16(extraFieldLength);
|
|
7756
|
+
directoryRecord.writeUint16(getLength(rawComment));
|
|
7757
|
+
directoryRecord.writeUint16(zip64DiskNumberStart ? MAX_16_BITS : diskNumberStart);
|
|
7758
|
+
directoryRecord.writeUint16(internalFileAttributes);
|
|
7759
|
+
directoryRecord.writeUint32(externalFileAttributes);
|
|
7760
|
+
directoryRecord.writeUint32(zip64Offset ? MAX_32_BITS : fileEntryOffset);
|
|
7761
|
+
directoryRecord.writeBytes(rawFilename);
|
|
7762
|
+
directoryRecord.writeBytes(rawExtraFieldZip64);
|
|
7763
|
+
directoryRecord.writeBytes(rawExtraFieldAES);
|
|
7764
|
+
directoryRecord.writeBytes(rawExtraFieldExtendedTimestamp);
|
|
7765
|
+
directoryRecord.writeBytes(rawExtraFieldNTFS);
|
|
7766
|
+
directoryRecord.writeBytes(rawExtraFieldUnix);
|
|
7767
|
+
directoryRecord.writeBytes(rawExtraField);
|
|
7768
|
+
directoryRecord.writeBytes(rawComment);
|
|
7540
7769
|
arraySet(directoryArray, directoryRecord.array, offset);
|
|
7541
7770
|
offset += directoryRecordLength;
|
|
7542
7771
|
if (options.onprogress) {
|
|
7543
7772
|
try {
|
|
7544
|
-
await options.onprogress(indexFileEntry + 1,
|
|
7773
|
+
await options.onprogress(indexFileEntry + 1, fileEntries.size, new Entry(fileEntry));
|
|
7545
7774
|
} catch {
|
|
7546
7775
|
// ignored
|
|
7547
7776
|
}
|
|
@@ -7555,7 +7784,7 @@ async function writeDirectoryRecords(zipWriter, directoryDataLength, options) {
|
|
|
7555
7784
|
}
|
|
7556
7785
|
|
|
7557
7786
|
async function writeDigitalSignatureRecord(zipWriter, directoryArray, options) {
|
|
7558
|
-
const signCentralDirectory =
|
|
7787
|
+
const signCentralDirectory = getFunctionOptionValue(zipWriter, options, OPTION_SIGN_CENTRAL_DIRECTORY);
|
|
7559
7788
|
if (signCentralDirectory) {
|
|
7560
7789
|
const signatureData = await signCentralDirectory(directoryArray);
|
|
7561
7790
|
const signatureDataLength = getLength(signatureData);
|
|
@@ -7563,9 +7792,9 @@ async function writeDigitalSignatureRecord(zipWriter, directoryArray, options) {
|
|
|
7563
7792
|
throw new Error(ERR_INVALID_SIGNATURE_DATA);
|
|
7564
7793
|
}
|
|
7565
7794
|
const signatureRecord = createRecordWriter(6 + signatureDataLength);
|
|
7566
|
-
signatureRecord.
|
|
7567
|
-
signatureRecord.
|
|
7568
|
-
signatureRecord.
|
|
7795
|
+
signatureRecord.writeUint32(DIGITAL_SIGNATURE_RECORD_SIGNATURE);
|
|
7796
|
+
signatureRecord.writeUint16(signatureDataLength);
|
|
7797
|
+
signatureRecord.writeBytes(signatureData);
|
|
7569
7798
|
await writeData(zipWriter.writer, signatureRecord.array);
|
|
7570
7799
|
return 6 + signatureDataLength;
|
|
7571
7800
|
}
|
|
@@ -7576,7 +7805,7 @@ async function writeEndOfDirectoryRecord(zipWriter, comment, options, cdInfo) {
|
|
|
7576
7805
|
const { writer } = zipWriter;
|
|
7577
7806
|
const { directoryStart, signatureLength } = cdInfo;
|
|
7578
7807
|
let { directoryDataLength } = cdInfo;
|
|
7579
|
-
let
|
|
7808
|
+
let fileEntriesLength = zipWriter.fileEntries.size;
|
|
7580
7809
|
let diskNumber = directoryStart.diskNumber;
|
|
7581
7810
|
let directoryOffset = getSegmentOffset(zipWriter, directoryStart);
|
|
7582
7811
|
let lastDiskNumber = getDiskNumber(writer);
|
|
@@ -7584,7 +7813,7 @@ async function writeEndOfDirectoryRecord(zipWriter, comment, options, cdInfo) {
|
|
|
7584
7813
|
lastDiskNumber++;
|
|
7585
7814
|
}
|
|
7586
7815
|
let zip64 = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIP64);
|
|
7587
|
-
if (directoryOffset >= MAX_32_BITS || directoryDataLength >= MAX_32_BITS ||
|
|
7816
|
+
if (directoryOffset >= MAX_32_BITS || directoryDataLength >= MAX_32_BITS || fileEntriesLength >= MAX_16_BITS || lastDiskNumber >= MAX_16_BITS) {
|
|
7588
7817
|
if (zip64 === false) {
|
|
7589
7818
|
throw new Error(ERR_UNSUPPORTED_FORMAT);
|
|
7590
7819
|
} else {
|
|
@@ -7601,37 +7830,37 @@ async function writeEndOfDirectoryRecord(zipWriter, comment, options, cdInfo) {
|
|
|
7601
7830
|
}
|
|
7602
7831
|
lastDiskNumber = getDiskNumber(writer);
|
|
7603
7832
|
if (zip64) {
|
|
7604
|
-
endOfdirectoryRecord.
|
|
7605
|
-
endOfdirectoryRecord.
|
|
7606
|
-
endOfdirectoryRecord.
|
|
7607
|
-
endOfdirectoryRecord.
|
|
7608
|
-
endOfdirectoryRecord.
|
|
7609
|
-
endOfdirectoryRecord.
|
|
7610
|
-
endOfdirectoryRecord.
|
|
7611
|
-
endOfdirectoryRecord.
|
|
7612
|
-
endOfdirectoryRecord.
|
|
7613
|
-
endOfdirectoryRecord.
|
|
7614
|
-
endOfdirectoryRecord.
|
|
7615
|
-
endOfdirectoryRecord.
|
|
7616
|
-
endOfdirectoryRecord.
|
|
7617
|
-
endOfdirectoryRecord.
|
|
7833
|
+
endOfdirectoryRecord.writeUint32(ZIP64_END_OF_CENTRAL_DIR_SIGNATURE);
|
|
7834
|
+
endOfdirectoryRecord.writeUint64(44);
|
|
7835
|
+
endOfdirectoryRecord.writeUint16(45);
|
|
7836
|
+
endOfdirectoryRecord.writeUint16(45);
|
|
7837
|
+
endOfdirectoryRecord.writeUint32(lastDiskNumber);
|
|
7838
|
+
endOfdirectoryRecord.writeUint32(diskNumber);
|
|
7839
|
+
endOfdirectoryRecord.writeUint64(fileEntriesLength);
|
|
7840
|
+
endOfdirectoryRecord.writeUint64(fileEntriesLength);
|
|
7841
|
+
endOfdirectoryRecord.writeUint64(directoryDataLength);
|
|
7842
|
+
endOfdirectoryRecord.writeUint64(directoryOffset);
|
|
7843
|
+
endOfdirectoryRecord.writeUint32(ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE);
|
|
7844
|
+
endOfdirectoryRecord.writeUint32(lastDiskNumber);
|
|
7845
|
+
endOfdirectoryRecord.writeUint64(BigInt(getSegmentOffset(zipWriter, writer)) + BigInt(directoryDataLength) + BigInt(signatureLength));
|
|
7846
|
+
endOfdirectoryRecord.writeUint32(lastDiskNumber + 1);
|
|
7618
7847
|
const supportZip64SplitFile = getOptionValue(zipWriter, options, OPTION_SUPPORT_ZIP64_SPLIT_FILE, true);
|
|
7619
7848
|
if (supportZip64SplitFile) {
|
|
7620
7849
|
lastDiskNumber = MAX_16_BITS;
|
|
7621
7850
|
diskNumber = MAX_16_BITS;
|
|
7622
7851
|
}
|
|
7623
|
-
|
|
7852
|
+
fileEntriesLength = MAX_16_BITS;
|
|
7624
7853
|
directoryOffset = MAX_32_BITS;
|
|
7625
7854
|
directoryDataLength = MAX_32_BITS;
|
|
7626
7855
|
}
|
|
7627
|
-
endOfdirectoryRecord.
|
|
7628
|
-
endOfdirectoryRecord.
|
|
7629
|
-
endOfdirectoryRecord.
|
|
7630
|
-
endOfdirectoryRecord.
|
|
7631
|
-
endOfdirectoryRecord.
|
|
7632
|
-
endOfdirectoryRecord.
|
|
7633
|
-
endOfdirectoryRecord.
|
|
7634
|
-
endOfdirectoryRecord.
|
|
7856
|
+
endOfdirectoryRecord.writeUint32(END_OF_CENTRAL_DIR_SIGNATURE);
|
|
7857
|
+
endOfdirectoryRecord.writeUint16(lastDiskNumber);
|
|
7858
|
+
endOfdirectoryRecord.writeUint16(diskNumber);
|
|
7859
|
+
endOfdirectoryRecord.writeUint16(fileEntriesLength);
|
|
7860
|
+
endOfdirectoryRecord.writeUint16(fileEntriesLength);
|
|
7861
|
+
endOfdirectoryRecord.writeUint32(directoryDataLength);
|
|
7862
|
+
endOfdirectoryRecord.writeUint32(directoryOffset);
|
|
7863
|
+
endOfdirectoryRecord.writeUint16(commentLength);
|
|
7635
7864
|
await writeData(writer, endOfdirectoryRecord.array);
|
|
7636
7865
|
if (commentLength) {
|
|
7637
7866
|
await writeData(writer, comment);
|
|
@@ -7644,11 +7873,11 @@ function createRecordWriter(length) {
|
|
|
7644
7873
|
let offset = 0;
|
|
7645
7874
|
return {
|
|
7646
7875
|
array,
|
|
7647
|
-
|
|
7648
|
-
|
|
7649
|
-
|
|
7650
|
-
|
|
7651
|
-
|
|
7876
|
+
writeUint8: value => { setUint8(view, offset, value); offset += 1; },
|
|
7877
|
+
writeUint16: value => { setUint16(view, offset, value); offset += 2; },
|
|
7878
|
+
writeUint32: value => { setUint32(view, offset, value); offset += 4; },
|
|
7879
|
+
writeUint64: value => { setBigUint64(view, offset, BigInt(value)); offset += 8; },
|
|
7880
|
+
writeBytes: value => { arraySet(array, value, offset); offset += getLength(value); },
|
|
7652
7881
|
skip: count => offset += count
|
|
7653
7882
|
};
|
|
7654
7883
|
}
|
|
@@ -7672,6 +7901,71 @@ function getSegmentOffset(zipWriter, { diskNumber = 0, diskOffset = 0 }) {
|
|
|
7672
7901
|
return zipWriter.offset - diskOffset - (diskNumber ? zipWriter.initialOffset : 0);
|
|
7673
7902
|
}
|
|
7674
7903
|
|
|
7904
|
+
async function startsWithSplitZipSignature(reader) {
|
|
7905
|
+
const signatureArray = await readUint8Array(reader, 0, SPLIT_ZIP_FILE_SIGNATURE_LENGTH);
|
|
7906
|
+
return getUint32(getDataView(signatureArray), 0) == SPLIT_ZIP_FILE_SIGNATURE;
|
|
7907
|
+
}
|
|
7908
|
+
|
|
7909
|
+
async function copyZipData(zipWriter, reader, entries, directoryOffset, splitZipSignatureLength) {
|
|
7910
|
+
const { writer } = zipWriter;
|
|
7911
|
+
const entryPositions = new Map();
|
|
7912
|
+
if (writer.closeDisk) {
|
|
7913
|
+
const sortedEntries = Array.from(entries).sort((firstEntry, secondEntry) =>
|
|
7914
|
+
getSourceOffset(reader, firstEntry) - getSourceOffset(reader, secondEntry));
|
|
7915
|
+
let copiedLength = 0;
|
|
7916
|
+
for (const entry of sortedEntries) {
|
|
7917
|
+
const sourceOffset = getSourceOffset(reader, entry);
|
|
7918
|
+
await copyData(zipWriter, reader, copiedLength, sourceOffset - copiedLength);
|
|
7919
|
+
if (exceedsAvailableSize(writer, await getLocalHeaderLength(reader, sourceOffset))) {
|
|
7920
|
+
await writer.closeDisk();
|
|
7921
|
+
}
|
|
7922
|
+
entryPositions.set(entry, {
|
|
7923
|
+
offset: getSegmentOffset(zipWriter, writer),
|
|
7924
|
+
diskNumberStart: getDiskNumber(writer)
|
|
7925
|
+
});
|
|
7926
|
+
copiedLength = sourceOffset;
|
|
7927
|
+
}
|
|
7928
|
+
await copyData(zipWriter, reader, copiedLength, directoryOffset - copiedLength);
|
|
7929
|
+
} else {
|
|
7930
|
+
await copyData(zipWriter, reader, 0, directoryOffset);
|
|
7931
|
+
entries.forEach(entry => entryPositions.set(entry, {
|
|
7932
|
+
offset: splitZipSignatureLength + getSourceOffset(reader, entry),
|
|
7933
|
+
diskNumberStart: 0
|
|
7934
|
+
}));
|
|
7935
|
+
}
|
|
7936
|
+
return entryPositions;
|
|
7937
|
+
}
|
|
7938
|
+
|
|
7939
|
+
async function copyData(zipWriter, reader, offset, size) {
|
|
7940
|
+
if (size > 0) {
|
|
7941
|
+
const { writer } = zipWriter;
|
|
7942
|
+
await createReadable(reader, { offset, size }).pipeTo(writer.writable, { preventClose: true, preventAbort: true });
|
|
7943
|
+
writer.size += size;
|
|
7944
|
+
zipWriter.offset += size;
|
|
7945
|
+
}
|
|
7946
|
+
}
|
|
7947
|
+
|
|
7948
|
+
async function getLocalHeaderLength(reader, offset) {
|
|
7949
|
+
const headerArray = await readUint8Array(reader, offset, HEADER_SIZE);
|
|
7950
|
+
if (getLength(headerArray) < HEADER_SIZE) {
|
|
7951
|
+
return HEADER_SIZE;
|
|
7952
|
+
}
|
|
7953
|
+
const headerView = getDataView(headerArray);
|
|
7954
|
+
return HEADER_SIZE +
|
|
7955
|
+
getUint16(headerView, HEADER_OFFSET_FILENAME_LENGTH + LOCAL_HEADER_COMMON_OFFSET) +
|
|
7956
|
+
getUint16(headerView, HEADER_OFFSET_EXTRAFIELD_LENGTH + LOCAL_HEADER_COMMON_OFFSET);
|
|
7957
|
+
}
|
|
7958
|
+
|
|
7959
|
+
function getSourceOffset(reader, { offset, diskNumberStart }) {
|
|
7960
|
+
return offset + (reader.getDiskOffset ? reader.getDiskOffset(diskNumberStart) : 0);
|
|
7961
|
+
}
|
|
7962
|
+
|
|
7963
|
+
function getSplitZipSignatureArray() {
|
|
7964
|
+
const signatureArray = new Uint8Array(SPLIT_ZIP_FILE_SIGNATURE_LENGTH);
|
|
7965
|
+
setUint32(getDataView(signatureArray), 0, SPLIT_ZIP_FILE_SIGNATURE);
|
|
7966
|
+
return signatureArray;
|
|
7967
|
+
}
|
|
7968
|
+
|
|
7675
7969
|
async function writeData(writer, array) {
|
|
7676
7970
|
const { writable } = writer;
|
|
7677
7971
|
const streamWriter = writable.getWriter();
|
|
@@ -7723,6 +8017,21 @@ function getOptionValue(zipWriter, options, name, defaultValue) {
|
|
|
7723
8017
|
return result === UNDEFINED_VALUE ? defaultValue : result;
|
|
7724
8018
|
}
|
|
7725
8019
|
|
|
8020
|
+
function getDateOptionValue(zipWriter, options, name, defaultValue) {
|
|
8021
|
+
const date = getOptionValue(zipWriter, options, name, defaultValue);
|
|
8022
|
+
if (date === null) {
|
|
8023
|
+
return defaultValue;
|
|
8024
|
+
}
|
|
8025
|
+
if (date !== UNDEFINED_VALUE && (typeof date.getTime != FUNCTION_TYPE || Number.isNaN(date.getTime()))) {
|
|
8026
|
+
throw new Error(ERR_INVALID_DATE);
|
|
8027
|
+
}
|
|
8028
|
+
return date;
|
|
8029
|
+
}
|
|
8030
|
+
|
|
8031
|
+
function getFunctionOptionValue(zipWriter, options, name) {
|
|
8032
|
+
return checkFunctionOption(getOptionValue(zipWriter, options, name));
|
|
8033
|
+
}
|
|
8034
|
+
|
|
7726
8035
|
function getAliasedOptionValue(zipWriter, options, name, deprecatedName, defaultValue) {
|
|
7727
8036
|
const value = getAliasedValue(options, name, deprecatedName);
|
|
7728
8037
|
const result = value === UNDEFINED_VALUE ? getAliasedValue(zipWriter.options, name, deprecatedName) : value;
|
|
@@ -7737,9 +8046,6 @@ function getNumberOptionValue(zipWriter, options, name, defaultValue) {
|
|
|
7737
8046
|
return toNumber(getOptionValue(zipWriter, options, name, defaultValue));
|
|
7738
8047
|
}
|
|
7739
8048
|
|
|
7740
|
-
function toNumber(value) {
|
|
7741
|
-
return typeof value == STRING_TYPE && value.trim() ? Number(value) : value;
|
|
7742
|
-
}
|
|
7743
8049
|
|
|
7744
8050
|
function getMaximumCompressedSize(uncompressedSize) {
|
|
7745
8051
|
return uncompressedSize + (5 * (Math.floor(uncompressedSize / 16383) + 1));
|
|
@@ -7751,6 +8057,14 @@ function isCompressed(compressionMethod, level) {
|
|
|
7751
8057
|
: compressionMethod !== COMPRESSION_METHOD_STORE;
|
|
7752
8058
|
}
|
|
7753
8059
|
|
|
8060
|
+
function getUint16(view, offset) {
|
|
8061
|
+
return view.getUint16(offset, true);
|
|
8062
|
+
}
|
|
8063
|
+
|
|
8064
|
+
function getUint32(view, offset) {
|
|
8065
|
+
return view.getUint32(offset, true);
|
|
8066
|
+
}
|
|
8067
|
+
|
|
7754
8068
|
function setUint8(view, offset, value) {
|
|
7755
8069
|
view.setUint8(offset, value);
|
|
7756
8070
|
}
|
|
@@ -7794,9 +8108,9 @@ function getHeaderArrayData({
|
|
|
7794
8108
|
const headerRecord = createRecordWriter(HEADER_SIZE - 4);
|
|
7795
8109
|
const headerArray = headerRecord.array;
|
|
7796
8110
|
const headerView = getDataView(headerArray);
|
|
7797
|
-
headerRecord.
|
|
7798
|
-
headerRecord.
|
|
7799
|
-
headerRecord.
|
|
8111
|
+
headerRecord.writeUint16(version);
|
|
8112
|
+
headerRecord.writeUint16(bitFlag);
|
|
8113
|
+
headerRecord.writeUint16(compressionMethod);
|
|
7800
8114
|
if (rawLastModDate === UNDEFINED_VALUE) {
|
|
7801
8115
|
const dateArray = new Uint32Array(1);
|
|
7802
8116
|
const dateView = getDataView(dateArray);
|
|
@@ -7804,20 +8118,20 @@ function getHeaderArrayData({
|
|
|
7804
8118
|
setUint16(dateView, 2, ((((lastModDate.getFullYear() - 1980) << 4) | (lastModDate.getMonth() + 1)) << 5) | lastModDate.getDate());
|
|
7805
8119
|
rawLastModDate = dateArray[0];
|
|
7806
8120
|
}
|
|
7807
|
-
headerRecord.
|
|
8121
|
+
headerRecord.writeUint32(rawLastModDate);
|
|
7808
8122
|
headerRecord.skip(4);
|
|
7809
8123
|
if (zip64CompressedSize || compressedSize !== UNDEFINED_VALUE) {
|
|
7810
|
-
headerRecord.
|
|
8124
|
+
headerRecord.writeUint32(zip64CompressedSize ? MAX_32_BITS : compressedSize);
|
|
7811
8125
|
} else {
|
|
7812
8126
|
headerRecord.skip(4);
|
|
7813
8127
|
}
|
|
7814
8128
|
if (zip64UncompressedSize || uncompressedSize !== UNDEFINED_VALUE) {
|
|
7815
|
-
headerRecord.
|
|
8129
|
+
headerRecord.writeUint32(zip64UncompressedSize ? MAX_32_BITS : uncompressedSize);
|
|
7816
8130
|
} else {
|
|
7817
8131
|
headerRecord.skip(4);
|
|
7818
8132
|
}
|
|
7819
|
-
headerRecord.
|
|
7820
|
-
headerRecord.
|
|
8133
|
+
headerRecord.writeUint16(getLength(rawFilename));
|
|
8134
|
+
headerRecord.writeUint16(extraFieldLength);
|
|
7821
8135
|
return {
|
|
7822
8136
|
headerArray,
|
|
7823
8137
|
headerView,
|
|
@@ -8737,6 +9051,7 @@ configureExternalAssets();
|
|
|
8737
9051
|
const ERR_ENTRY_EXISTS = "Entry filename already exists";
|
|
8738
9052
|
const ERR_READABLE_CONSUMED = "Readable stream already consumed";
|
|
8739
9053
|
const ERR_INVALID_PASS_THROUGH = "Invalid passThrough option (use readerOptions.passThrough or set uncompressedSize for each entry)";
|
|
9054
|
+
const ERR_INVALID_READER_OPTIONS = "Invalid readerOptions (must be an object)";
|
|
8740
9055
|
const ERR_ABORT_EXPORT = "zipjs-abort-export";
|
|
8741
9056
|
const ERR_ABORTED = "The operation was aborted";
|
|
8742
9057
|
const ABORT_ERROR_NAME = "AbortError";
|
|
@@ -8769,13 +9084,14 @@ class ZipEntry {
|
|
|
8769
9084
|
fs,
|
|
8770
9085
|
name,
|
|
8771
9086
|
data: params.data,
|
|
8772
|
-
options: params.options,
|
|
9087
|
+
options: params.options && Object.assign({}, params.options),
|
|
8773
9088
|
id: fs.entryIdCounter++,
|
|
8774
9089
|
parent,
|
|
8775
9090
|
children: [],
|
|
8776
9091
|
uncompressedSize: params.uncompressedSize || 0,
|
|
8777
9092
|
undeterminedSize: params.undeterminedSize || params.uncompressedSize === UNDEFINED_VALUE,
|
|
8778
|
-
passThrough: params.passThrough
|
|
9093
|
+
passThrough: params.passThrough,
|
|
9094
|
+
defaultLastModDate: params.defaultLastModDate || new Date()
|
|
8779
9095
|
});
|
|
8780
9096
|
if (parent || !fs.root) {
|
|
8781
9097
|
fs.entries[zipEntry.id] = zipEntry;
|
|
@@ -8785,12 +9101,6 @@ class ZipEntry {
|
|
|
8785
9101
|
}
|
|
8786
9102
|
}
|
|
8787
9103
|
|
|
8788
|
-
moveTo(target) {
|
|
8789
|
-
// deprecated
|
|
8790
|
-
const zipEntry = this;
|
|
8791
|
-
zipEntry.fs.move(zipEntry, target);
|
|
8792
|
-
}
|
|
8793
|
-
|
|
8794
9104
|
getFullname() {
|
|
8795
9105
|
return this.getRelativeName();
|
|
8796
9106
|
}
|
|
@@ -8822,6 +9132,11 @@ class ZipEntry {
|
|
|
8822
9132
|
this.name = name;
|
|
8823
9133
|
}
|
|
8824
9134
|
}
|
|
9135
|
+
|
|
9136
|
+
setOptions(options) {
|
|
9137
|
+
const entryOptions = Object.assign({}, this.options, options);
|
|
9138
|
+
this.options = Object.fromEntries(Object.entries(entryOptions).filter(([, value]) => value !== UNDEFINED_VALUE));
|
|
9139
|
+
}
|
|
8825
9140
|
}
|
|
8826
9141
|
|
|
8827
9142
|
class ZipFileEntry extends ZipEntry {
|
|
@@ -8848,7 +9163,7 @@ class ZipFileEntry extends ZipEntry {
|
|
|
8848
9163
|
const reader = zipEntry.reader = createReader(zipEntry.Reader, zipEntry.data, options);
|
|
8849
9164
|
const dataSize = zipEntry.uncompressedSize || reader.size;
|
|
8850
9165
|
await Promise.all([initStream(reader), initStream(writer, dataSize)]);
|
|
8851
|
-
const
|
|
9166
|
+
const signal = checkSignalOption(options.signal);
|
|
8852
9167
|
const readable = createProgressReadable(zipEntry, reader, options, signal);
|
|
8853
9168
|
const preventClose = !ownsWritable(writer) && Boolean(options.preventClose);
|
|
8854
9169
|
zipEntry.uncompressedSize = reader.size;
|
|
@@ -9066,10 +9381,6 @@ class ZipDirectoryEntry extends ZipEntry {
|
|
|
9066
9381
|
});
|
|
9067
9382
|
}
|
|
9068
9383
|
|
|
9069
|
-
addData(name, params) {
|
|
9070
|
-
return addChild(this, name, params);
|
|
9071
|
-
}
|
|
9072
|
-
|
|
9073
9384
|
importBlob(blob, options) {
|
|
9074
9385
|
return this.importZip(new BlobReader(blob), options);
|
|
9075
9386
|
}
|
|
@@ -9183,7 +9494,7 @@ class ZipDirectoryEntry extends ZipEntry {
|
|
|
9183
9494
|
if (options.bufferedWrite === UNDEFINED_VALUE) {
|
|
9184
9495
|
options.bufferedWrite = true;
|
|
9185
9496
|
}
|
|
9186
|
-
const [readers] = await Promise.all([initReaders(zipEntry, options.readerOptions), initStream(writer)]);
|
|
9497
|
+
const [readers] = await Promise.all([initReaders(zipEntry, checkReaderOptions(options.readerOptions)), initStream(writer)]);
|
|
9187
9498
|
const zipWriter = new ZipWriter(writer, options);
|
|
9188
9499
|
await exportZip(zipWriter, zipEntry, getTotalSize([zipEntry], getUncompressedSize), options, readers);
|
|
9189
9500
|
await zipWriter.close(options.globalComment);
|
|
@@ -9193,12 +9504,13 @@ class ZipDirectoryEntry extends ZipEntry {
|
|
|
9193
9504
|
getExportedSize(options = {}) {
|
|
9194
9505
|
const zipEntry = this;
|
|
9195
9506
|
options = Object.assign({}, options);
|
|
9507
|
+
checkReaderOptions(options.readerOptions);
|
|
9196
9508
|
if (options.bufferedWrite === UNDEFINED_VALUE) {
|
|
9197
9509
|
options.bufferedWrite = true;
|
|
9198
9510
|
}
|
|
9199
9511
|
const writeOrderGuaranteed = !options.bufferedWrite ||
|
|
9200
9512
|
(options.keepOrder !== false && zipEntry.children.every(child => !child.children.length));
|
|
9201
|
-
return getEntriesSize(options,
|
|
9513
|
+
return getEntriesSize(options, zipEntry.getChildren({ recursive: true }).filter(child => !isImplicitDirectory(child)).map(child => {
|
|
9202
9514
|
const { name, entryOptions } = getChildEntryOptions(child, zipEntry, options);
|
|
9203
9515
|
return { name, size: child.directory ? 0 : getDeterminedSize(child, isPassThrough(child, options)), options: entryOptions };
|
|
9204
9516
|
}), writeOrderGuaranteed, options.globalComment);
|
|
@@ -9237,7 +9549,7 @@ class ZipDirectoryEntry extends ZipEntry {
|
|
|
9237
9549
|
}
|
|
9238
9550
|
|
|
9239
9551
|
|
|
9240
|
-
class
|
|
9552
|
+
class ZipFS {
|
|
9241
9553
|
|
|
9242
9554
|
constructor() {
|
|
9243
9555
|
resetFS(this);
|
|
@@ -9353,10 +9665,6 @@ class FS {
|
|
|
9353
9665
|
return this.root.addFile(file, options);
|
|
9354
9666
|
}
|
|
9355
9667
|
|
|
9356
|
-
addData(name, params) {
|
|
9357
|
-
return this.root.addData(name, params);
|
|
9358
|
-
}
|
|
9359
|
-
|
|
9360
9668
|
importBlob(blob, options) {
|
|
9361
9669
|
resetFS(this);
|
|
9362
9670
|
return this.root.importBlob(blob, options);
|
|
@@ -9424,7 +9732,7 @@ class FS {
|
|
|
9424
9732
|
}
|
|
9425
9733
|
}
|
|
9426
9734
|
|
|
9427
|
-
const fs = { FS, ZipDirectoryEntry, ZipFileEntry };
|
|
9735
|
+
const fs = { FS: ZipFS, ZipDirectoryEntry, ZipFileEntry };
|
|
9428
9736
|
|
|
9429
9737
|
function getTotalSize(entries, getEntrySize) {
|
|
9430
9738
|
let size = 0;
|
|
@@ -9568,7 +9876,7 @@ function detach(entry) {
|
|
|
9568
9876
|
}
|
|
9569
9877
|
|
|
9570
9878
|
function forwardAbort(signal, abortController) {
|
|
9571
|
-
if (!signal) {
|
|
9879
|
+
if (!checkSignalOption(signal)) {
|
|
9572
9880
|
return () => { };
|
|
9573
9881
|
}
|
|
9574
9882
|
if (signal.aborted) {
|
|
@@ -9664,7 +9972,7 @@ function getChildEntryOptions(child, selectedEntry, options) {
|
|
|
9664
9972
|
};
|
|
9665
9973
|
}
|
|
9666
9974
|
}
|
|
9667
|
-
const entryOptions = Object.assign({}, zipEntryMetadata, options,
|
|
9975
|
+
const entryOptions = Object.assign({ lastModDate: child.defaultLastModDate }, zipEntryMetadata, options, childOptions, passThroughOptions, { directory: child.directory });
|
|
9668
9976
|
if (!child.directory && entryOptions.passThrough && entryOptions.uncompressedSize === UNDEFINED_VALUE) {
|
|
9669
9977
|
throw new Error(ERR_INVALID_PASS_THROUGH);
|
|
9670
9978
|
}
|
|
@@ -9679,11 +9987,22 @@ function getDeterminedSize(child, passThrough) {
|
|
|
9679
9987
|
return child.undeterminedSize ? UNDEFINED_VALUE : getExtractedSize(child, passThrough);
|
|
9680
9988
|
}
|
|
9681
9989
|
|
|
9990
|
+
function checkReaderOptions(readerOptions) {
|
|
9991
|
+
if (readerOptions && (typeof readerOptions != OBJECT_TYPE || Array.isArray(readerOptions))) {
|
|
9992
|
+
throw new Error(ERR_INVALID_READER_OPTIONS);
|
|
9993
|
+
}
|
|
9994
|
+
return readerOptions;
|
|
9995
|
+
}
|
|
9996
|
+
|
|
9682
9997
|
function isPassThrough(child, options) {
|
|
9683
9998
|
const { readerOptions } = options;
|
|
9684
9999
|
return Boolean(!child.directory && (child.passThrough || (readerOptions && readerOptions.passThrough)));
|
|
9685
10000
|
}
|
|
9686
10001
|
|
|
10002
|
+
function isImplicitDirectory(child) {
|
|
10003
|
+
return child.directory && child.data === null;
|
|
10004
|
+
}
|
|
10005
|
+
|
|
9687
10006
|
function getUserExtraField(extraField) {
|
|
9688
10007
|
if (extraField) {
|
|
9689
10008
|
const userExtraField = new Map();
|
|
@@ -9701,7 +10020,7 @@ function getUserExtraField(extraField) {
|
|
|
9701
10020
|
async function exportZip(zipWriter, entry, totalSize, options, readers) {
|
|
9702
10021
|
const { onstart, onprogress, onend, onentryprogress } = options;
|
|
9703
10022
|
const selectedEntry = entry;
|
|
9704
|
-
const totalEntries = getTotalSize(entry.children, ()
|
|
10023
|
+
const totalEntries = getTotalSize(entry.children, child => isImplicitDirectory(child) ? 0 : 1);
|
|
9705
10024
|
let writtenSize = 0;
|
|
9706
10025
|
let writtenEntries = 0;
|
|
9707
10026
|
if (onstart) {
|
|
@@ -9730,6 +10049,9 @@ async function exportZip(zipWriter, entry, totalSize, options, readers) {
|
|
|
9730
10049
|
}
|
|
9731
10050
|
|
|
9732
10051
|
async function addChild(child) {
|
|
10052
|
+
if (isImplicitDirectory(child)) {
|
|
10053
|
+
return;
|
|
10054
|
+
}
|
|
9733
10055
|
const { name, entryOptions } = getChildEntryOptions(child, selectedEntry, options);
|
|
9734
10056
|
let entryWrittenSize = 0;
|
|
9735
10057
|
const entryMetadata = await zipWriter.add(name, readers.get(child), Object.assign(entryOptions, {
|
|
@@ -9763,7 +10085,7 @@ function addFileSystemHandle(zipEntry, handle, options) {
|
|
|
9763
10085
|
if (handle.kind == "file") {
|
|
9764
10086
|
const file = await handle.getFile();
|
|
9765
10087
|
addedEntries.push(
|
|
9766
|
-
parentEntry
|
|
10088
|
+
addChild(parentEntry, file.name, {
|
|
9767
10089
|
Reader: function () {
|
|
9768
10090
|
const readable = file.stream();
|
|
9769
10091
|
const size = file.size;
|
|
@@ -9797,10 +10119,11 @@ function addFileSystemHandle(zipEntry, handle, options) {
|
|
|
9797
10119
|
|
|
9798
10120
|
async function exportFileSystemHandle(zipEntry, directoryHandle, options) {
|
|
9799
10121
|
const { onstart, onprogress, onend } = options;
|
|
10122
|
+
const readerOptions = checkReaderOptions(options.readerOptions);
|
|
9800
10123
|
const abortController = new AbortController();
|
|
9801
10124
|
const { signal } = abortController;
|
|
9802
10125
|
const releaseSignal = forwardAbort(options.signal, abortController);
|
|
9803
|
-
const getDataOptions = Object.assign({}, options,
|
|
10126
|
+
const getDataOptions = Object.assign({}, options, readerOptions, {
|
|
9804
10127
|
signal,
|
|
9805
10128
|
onstart: UNDEFINED_VALUE,
|
|
9806
10129
|
onprogress: UNDEFINED_VALUE,
|
|
@@ -9994,4 +10317,4 @@ function addChild(parent, name, params, directory) {
|
|
|
9994
10317
|
}
|
|
9995
10318
|
}
|
|
9996
10319
|
|
|
9997
|
-
export { BlobReader, BlobWriter, Data64URIReader, Data64URIWriter, ERR_ABORTED, ERR_AMBIGUOUS_ARCHIVE, ERR_BAD_FORMAT, ERR_CENTRAL_DIRECTORY_NOT_FOUND, ERR_DUPLICATED_NAME, ERR_ENCRYPTED, ERR_ENCRYPTED_CENTRAL_DIRECTORY, ERR_ENTRY_EXISTS, 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_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_PASS_THROUGH, 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_READABLE_CONSUMED, 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, fs, getMimeType, registerCodec, resetConfiguration, terminateWorkersAndModule as terminateWorkers, unregisterCodec };
|
|
10320
|
+
export { BlobReader, BlobWriter, Data64URIReader, Data64URIWriter, ERR_ABORTED, 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_ENTRY_EXISTS, 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_PASS_THROUGH, ERR_INVALID_READER_OPTIONS, 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_READABLE_CONSUMED, 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, ZipDirectoryEntry, ZipEntry, ZipFS, ZipFileEntry, ZipReader, ZipReaderStream, ZipWriter, ZipWriterStream, configure, createBlobTempStream, createOPFSTempStream, createSyncAccessHandleTempStream, fs, getMimeType, registerCodec, resetConfiguration, terminateWorkersAndModule as terminateWorkers, unregisterCodec };
|