@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.
Files changed (49) hide show
  1. package/README.md +1 -1
  2. package/deno.json +2 -1
  3. package/dist/zip-core-external.js +839 -528
  4. package/dist/zip-core-external.min.js +1 -1
  5. package/dist/zip-core.js +847 -527
  6. package/dist/zip-core.min.js +1 -1
  7. package/dist/zip-fs-core-external.js +880 -557
  8. package/dist/zip-fs-core-external.min.js +1 -1
  9. package/dist/zip-fs-core.js +829 -538
  10. package/dist/zip-fs-core.min.js +1 -1
  11. package/dist/zip-fs-external.js +880 -557
  12. package/dist/zip-fs-external.min.js +1 -1
  13. package/dist/zip-fs-native.js +895 -558
  14. package/dist/zip-fs-native.min.js +1 -1
  15. package/dist/zip-fs.js +894 -557
  16. package/dist/zip-fs.min.js +1 -1
  17. package/dist/zip-legacy.js +849 -529
  18. package/dist/zip-legacy.min.js +1 -1
  19. package/dist/zip-native.js +849 -529
  20. package/dist/zip-native.min.js +1 -1
  21. package/dist/zip-web-worker-native.js +1 -1
  22. package/dist/zip-web-worker.js +1 -1
  23. package/dist/zip.js +848 -528
  24. package/dist/zip.min.js +1 -1
  25. package/eslint.config.mjs +2 -1
  26. package/index-native.cjs +895 -558
  27. package/index-native.min.js +1 -1
  28. package/index.cjs +894 -557
  29. package/index.d.cts +672 -78
  30. package/index.d.ts +672 -78
  31. package/index.min.js +1 -1
  32. package/lib/core/codec-worker-web.js +13 -4
  33. package/lib/core/configuration.js +62 -21
  34. package/lib/core/constants.js +16 -1
  35. package/lib/core/io.js +44 -29
  36. package/lib/core/options.js +46 -2
  37. package/lib/core/streams/aes-crypto-stream.js +12 -12
  38. package/lib/core/util/decode-text.js +11 -2
  39. package/lib/core/web-worker-base.js +3 -2
  40. package/lib/core/web-worker-inline-native.js +1 -1
  41. package/lib/core/web-worker-inline-wasm.js +1 -1
  42. package/lib/core/zip-entry.js +8 -0
  43. package/lib/core/zip-fs.js +38 -27
  44. package/lib/core/zip-reader.js +149 -60
  45. package/lib/core/zip-writer.js +329 -189
  46. package/lib/zip-core-base.js +6 -1
  47. package/lib/zip-core-reader.js +1 -0
  48. package/lib/zip-core-writer.js +5 -0
  49. package/package.json +11 -3
package/dist/zip-core.js CHANGED
@@ -45,6 +45,7 @@
45
45
 
46
46
  const LOCAL_FILE_HEADER_SIGNATURE = 0x04034b50;
47
47
  const SPLIT_ZIP_FILE_SIGNATURE = 0x08074b50;
48
+ const TEMPORARY_SPLIT_ZIP_FILE_SIGNATURE = 0x30304b50;
48
49
  const DATA_DESCRIPTOR_RECORD_SIGNATURE = SPLIT_ZIP_FILE_SIGNATURE;
49
50
  const ARCHIVE_EXTRA_DATA_SIGNATURE = 0x08064b50;
50
51
  const DIGITAL_SIGNATURE_RECORD_SIGNATURE = 0x05054b50;
@@ -61,6 +62,7 @@
61
62
  const DATA_DESCRIPTOR_RECORD_LENGTH = 12;
62
63
  const DATA_DESCRIPTOR_RECORD_ZIP_64_LENGTH = 20;
63
64
  const DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH = 4;
65
+ const SPLIT_ZIP_FILE_SIGNATURE_LENGTH = 4;
64
66
 
65
67
  const EXTRAFIELD_TYPE_ZIP64 = 0x0001;
66
68
  const EXTRAFIELD_TYPE_AES = 0x9901;
@@ -102,6 +104,9 @@
102
104
  const VERSION_ZIP64 = 0x2D;
103
105
  const VERSION_AES = 0x33;
104
106
 
107
+ const VERSION_MADE_BY_MSDOS = 0x0014;
108
+ const VERSION_MADE_BY_UNIX = 0x0300;
109
+
105
110
  const DIRECTORY_SIGNATURE = "/";
106
111
 
107
112
  const HEADER_SIZE = 30;
@@ -109,6 +114,8 @@
109
114
  const HEADER_OFFSET_SIGNATURE = 10;
110
115
  const HEADER_OFFSET_COMPRESSED_SIZE = 14;
111
116
  const HEADER_OFFSET_UNCOMPRESSED_SIZE = 18;
117
+ const HEADER_OFFSET_FILENAME_LENGTH = 22;
118
+ const HEADER_OFFSET_EXTRAFIELD_LENGTH = 24;
112
119
  const LOCAL_HEADER_COMMON_OFFSET = 4;
113
120
 
114
121
  const MAX_DATE = new Date(2107, 11, 31, 23, 59, 58);
@@ -121,9 +128,116 @@
121
128
  const OBJECT_TYPE = "object";
122
129
  const STRING_TYPE = "string";
123
130
  const NUMBER_TYPE = "number";
131
+ const BOOLEAN_TYPE = "boolean";
124
132
 
125
133
  const EMPTY_UINT8_ARRAY = new Uint8Array();
126
134
 
135
+ /*
136
+ Copyright (c) 2022 Gildas Lormeau. All rights reserved.
137
+
138
+ Redistribution and use in source and binary forms, with or without
139
+ modification, are permitted provided that the following conditions are met:
140
+
141
+ 1. Redistributions of source code must retain the above copyright notice,
142
+ this list of conditions and the following disclaimer.
143
+
144
+ 2. Redistributions in binary form must reproduce the above copyright
145
+ notice, this list of conditions and the following disclaimer in
146
+ the documentation and/or other materials provided with the distribution.
147
+
148
+ 3. The names of the authors may not be used to endorse or promote products
149
+ derived from this software without specific prior written permission.
150
+
151
+ THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
152
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
153
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
154
+ INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
155
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
156
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
157
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
158
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
159
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
160
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
161
+ */
162
+
163
+
164
+ const OPTION_FILENAME_ENCODING = "filenameEncoding";
165
+ const OPTION_COMMENT_ENCODING = "commentEncoding";
166
+ const OPTION_DECODE_TEXT = "decodeText";
167
+ const OPTION_EXTRACT_PREPENDED_DATA = "extractPrependedData";
168
+ const OPTION_EXTRACT_APPENDED_DATA = "extractAppendedData";
169
+ const OPTION_PASSWORD = "password";
170
+ const OPTION_RAW_PASSWORD = "rawPassword";
171
+ const OPTION_PASS_THROUGH = "passThrough";
172
+ const OPTION_SIGNAL = "signal";
173
+ const OPTION_CHECK_PASSWORD_ONLY = "checkPasswordOnly";
174
+ const OPTION_CHECK_OVERLAPPING_ENTRY_ONLY = "checkOverlappingEntryOnly";
175
+ const OPTION_CHECK_OVERLAPPING_ENTRY = "checkOverlappingEntry";
176
+ const OPTION_CHECK_AMBIGUITY = "checkAmbiguity";
177
+ const OPTION_CHECK_LOCAL_DIRECTORY = "checkLocalDirectory";
178
+ const OPTION_CHECK_SIGNATURE = "checkSignature";
179
+ const OPTION_CHECK_CRC32 = "checkCrc32";
180
+ const OPTION_CHECK_AUTHENTICATION_CODE = "checkAuthenticationCode";
181
+ const OPTION_USE_WEB_WORKERS = "useWebWorkers";
182
+ const OPTION_USE_COMPRESSION_STREAM = "useCompressionStream";
183
+ const OPTION_TRANSFER_STREAMS = "transferStreams";
184
+ const OPTION_PREVENT_CLOSE = "preventClose";
185
+ const OPTION_ENCRYPTION_STRENGTH = "encryptionStrength";
186
+ const OPTION_EXTENDED_TIMESTAMP = "extendedTimestamp";
187
+ const OPTION_NTFS_TIMESTAMP = "ntfsTimestamp";
188
+ const OPTION_KEEP_ORDER = "keepOrder";
189
+ const OPTION_LEVEL = "level";
190
+ const OPTION_BUFFERED_WRITE = "bufferedWrite";
191
+ const OPTION_CREATE_TEMP_STREAM = "createTempStream";
192
+ const OPTION_DATA_DESCRIPTOR_SIGNATURE = "dataDescriptorSignature";
193
+ const OPTION_USE_UNICODE_FILE_NAMES = "useUnicodeFileNames";
194
+ const OPTION_DATA_DESCRIPTOR = "dataDescriptor";
195
+ const OPTION_SUPPORT_ZIP64_SPLIT_FILE = "supportZip64SplitFile";
196
+ const OPTION_ENCODE_TEXT = "encodeText";
197
+ const OPTION_OFFSET = "offset";
198
+ const OPTION_USDZ = "usdz";
199
+ const OPTION_UNIX_EXTRA_FIELD_TYPE = "unixExtraFieldType";
200
+ const OPTION_LOCAL_EXTRA_FIELD = "localExtraField";
201
+ const OPTION_STRICTNESS = "strictness";
202
+ const OPTION_FILENAME_VALIDATION = "filenameValidation";
203
+ const OPTION_NORMALIZE_FILENAME = "normalizeFilename";
204
+ const OPTION_MAX_APPENDED_DATA_SIZE = "maxAppendedDataSize";
205
+ const OPTION_DECRYPT_CENTRAL_DIRECTORY = "decryptCentralDirectory";
206
+ const OPTION_SIGN_CENTRAL_DIRECTORY = "signCentralDirectory";
207
+ const TEXT_TYPE_FILENAME = "filename";
208
+ const TEXT_TYPE_COMMENT = "comment";
209
+ const STRICTNESS_STRICT = "strict";
210
+ const STRICTNESS_BALANCED = "balanced";
211
+ const STRICTNESS_TOLERANT = "tolerant";
212
+
213
+ const ERR_INVALID_FUNCTION_OPTION = "Invalid option (must be a function)";
214
+ const ERR_INVALID_SIGNAL = "Invalid signal (must be an AbortSignal instance)";
215
+ const ERR_INVALID_PASSWORD_TYPE = "Invalid password (password must be a string, rawPassword must be a Uint8Array)";
216
+
217
+ function checkFunctionOption(value) {
218
+ if (value && typeof value != FUNCTION_TYPE) {
219
+ throw new Error(ERR_INVALID_FUNCTION_OPTION);
220
+ }
221
+ return value;
222
+ }
223
+
224
+ function checkSignalOption(signal) {
225
+ if (signal && (typeof signal.addEventListener != FUNCTION_TYPE || typeof signal.aborted != BOOLEAN_TYPE)) {
226
+ throw new Error(ERR_INVALID_SIGNAL);
227
+ }
228
+ return signal || UNDEFINED_VALUE;
229
+ }
230
+
231
+ function checkPasswordOption(password, rawPassword) {
232
+ if ((password && typeof password != STRING_TYPE) || (rawPassword && !(rawPassword instanceof Uint8Array))) {
233
+ throw new Error(ERR_INVALID_PASSWORD_TYPE);
234
+ }
235
+ }
236
+
237
+ function toNumber(value) {
238
+ return typeof value == STRING_TYPE && value.trim() ? Number(value) : value;
239
+ }
240
+
127
241
  /*
128
242
  Copyright (c) 2025 Gildas Lormeau. All rights reserved.
129
243
 
@@ -153,7 +267,10 @@
153
267
  */
154
268
 
155
269
 
270
+ const DEFAULT_CHUNK_SIZE$1 = 64 * 1024;
156
271
  const MINIMUM_CHUNK_SIZE = 64;
272
+ const MINIMUM_PROPERTY_VALUE = 1;
273
+ const ERR_INVALID_MAX_WORKERS = "Invalid maxWorkers (must be an integer greater than 0)";
157
274
  let maxWorkers = 2;
158
275
  try {
159
276
  if (typeof navigator != UNDEFINED_TYPE && navigator.hardwareConcurrency) {
@@ -165,7 +282,7 @@
165
282
  const DEFAULT_CONFIGURATION = {
166
283
  workerURI: "./core/web-worker-wasm.js",
167
284
  wasmURI: "./core/streams/zlib-wasm/zlib-streams.wasm",
168
- chunkSize: 64 * 1024,
285
+ chunkSize: DEFAULT_CHUNK_SIZE$1,
169
286
  maxWorkers,
170
287
  terminateWorkerTimeout: 5000,
171
288
  workerStarvationTimeout: 5000,
@@ -177,24 +294,38 @@
177
294
  DecompressionStream: typeof DecompressionStream != UNDEFINED_TYPE && DecompressionStream
178
295
  };
179
296
 
180
- const CONFIGURABLE_PROPERTY_NAMES = [
297
+ const PROPERTY_NAME_MAX_WORKERS = "maxWorkers";
298
+
299
+ const STRING_PROPERTY_NAMES = [
181
300
  "baseURI",
182
301
  "wasmURI",
183
- "workerURI",
184
- "createWorker",
302
+ "workerURI"
303
+ ];
304
+ const BOOLEAN_PROPERTY_NAMES = [
305
+ "useCompressionStream",
306
+ "useWebWorkers",
307
+ "transferStreams"
308
+ ];
309
+ const NUMBER_PROPERTY_NAMES = [
185
310
  "chunkSize",
186
- "maxWorkers",
311
+ PROPERTY_NAME_MAX_WORKERS,
187
312
  "terminateWorkerTimeout",
188
313
  "workerStarvationTimeout",
189
- "workerStartupTimeout",
190
- "useCompressionStream",
191
- "useWebWorkers",
192
- "transferStreams",
314
+ "workerStartupTimeout"
315
+ ];
316
+ const FUNCTION_PROPERTY_NAMES = [
317
+ "createWorker",
193
318
  "CompressionStream",
194
319
  "DecompressionStream",
195
320
  "CompressionStreamFallback",
196
321
  "DecompressionStreamFallback"
197
322
  ];
323
+ const CONFIGURABLE_PROPERTY_NAMES = [
324
+ ...STRING_PROPERTY_NAMES,
325
+ ...BOOLEAN_PROPERTY_NAMES,
326
+ ...NUMBER_PROPERTY_NAMES,
327
+ ...FUNCTION_PROPERTY_NAMES
328
+ ];
198
329
 
199
330
  const config = { ...DEFAULT_CONFIGURATION };
200
331
 
@@ -203,20 +334,43 @@
203
334
  }
204
335
 
205
336
  function getChunkSize(config) {
206
- return Math.max(config.chunkSize, MINIMUM_CHUNK_SIZE);
337
+ return normalizeChunkSize(config.chunkSize);
338
+ }
339
+
340
+ function normalizeChunkSize(chunkSize) {
341
+ chunkSize = toNumber(chunkSize);
342
+ return Number.isInteger(chunkSize) && chunkSize >= MINIMUM_PROPERTY_VALUE ? Math.max(chunkSize, MINIMUM_CHUNK_SIZE) : DEFAULT_CHUNK_SIZE$1;
207
343
  }
208
344
 
209
345
  function configure(configuration) {
210
- configuration = normalizeConfiguration(configuration);
346
+ Object.assign(config, checkConfiguration(normalizeConfiguration(configuration)));
347
+ }
348
+
349
+ function checkConfiguration(configuration) {
350
+ const checkedConfiguration = {};
211
351
  for (const propertyName of CONFIGURABLE_PROPERTY_NAMES) {
212
352
  const propertyValue = configuration[propertyName];
213
353
  if (propertyValue !== UNDEFINED_VALUE) {
214
- config[propertyName] = propertyValue;
354
+ checkedConfiguration[propertyName] = checkPropertyValue(propertyName, propertyValue);
215
355
  }
216
356
  }
357
+ return checkedConfiguration;
358
+ }
359
+
360
+ function checkPropertyValue(propertyName, propertyValue) {
361
+ if (NUMBER_PROPERTY_NAMES.includes(propertyName)) {
362
+ propertyValue = toNumber(propertyValue);
363
+ if (propertyName == PROPERTY_NAME_MAX_WORKERS && (!Number.isInteger(propertyValue) || propertyValue < MINIMUM_PROPERTY_VALUE)) {
364
+ throw new Error(ERR_INVALID_MAX_WORKERS);
365
+ }
366
+ } else if (FUNCTION_PROPERTY_NAMES.includes(propertyName)) {
367
+ checkFunctionOption(propertyValue);
368
+ }
369
+ return propertyValue;
217
370
  }
218
371
 
219
372
  function normalizeConfiguration(configuration) {
373
+ configuration = configuration || {};
220
374
  const { CompressionStreamZlib, DecompressionStreamZlib } = configuration;
221
375
  if (CompressionStreamZlib === UNDEFINED_VALUE && DecompressionStreamZlib === UNDEFINED_VALUE) {
222
376
  return configuration;
@@ -232,14 +386,9 @@
232
386
  }
233
387
 
234
388
  function setDefaultConfiguration(configuration) {
235
- configuration = normalizeConfiguration(configuration);
236
- for (const propertyName of CONFIGURABLE_PROPERTY_NAMES) {
237
- const propertyValue = configuration[propertyName];
238
- if (propertyValue !== UNDEFINED_VALUE) {
239
- DEFAULT_CONFIGURATION[propertyName] = propertyValue;
240
- }
241
- }
242
- configure(configuration);
389
+ const checkedConfiguration = checkConfiguration(normalizeConfiguration(configuration));
390
+ Object.assign(DEFAULT_CONFIGURATION, checkedConfiguration);
391
+ Object.assign(config, checkedConfiguration);
243
392
  }
244
393
 
245
394
  function resetConfiguration() {
@@ -1395,13 +1544,13 @@
1395
1544
  const {
1396
1545
  ctr,
1397
1546
  hmac,
1398
- pending,
1547
+ pendingInput,
1399
1548
  ready
1400
1549
  } = this;
1401
1550
  if (hmac && ctr) {
1402
1551
  await ready;
1403
- const chunkToDecrypt = subarray(pending, 0, pending.length - AUTHENTICATION_CODE_LENGTH);
1404
- const originalAuthenticationCode = subarray(pending, pending.length - AUTHENTICATION_CODE_LENGTH);
1552
+ const chunkToDecrypt = subarray(pendingInput, 0, pendingInput.length - AUTHENTICATION_CODE_LENGTH);
1553
+ const originalAuthenticationCode = subarray(pendingInput, pendingInput.length - AUTHENTICATION_CODE_LENGTH);
1405
1554
  let decryptedChunkArray = EMPTY_UINT8_ARRAY;
1406
1555
  if (chunkToDecrypt.length) {
1407
1556
  const encryptedChunk = toBits(codecBytes, chunkToDecrypt);
@@ -1410,7 +1559,7 @@
1410
1559
  decryptedChunkArray = fromBits(codecBytes, decryptedChunk);
1411
1560
  }
1412
1561
  const authenticationCode = subarray(fromBits(codecBytes, hmac.digest()), 0, AUTHENTICATION_CODE_LENGTH);
1413
- let invalidAuthenticationCode = pending.length < AUTHENTICATION_CODE_LENGTH ? 1 : 0;
1562
+ let invalidAuthenticationCode = pendingInput.length < AUTHENTICATION_CODE_LENGTH ? 1 : 0;
1414
1563
  for (let indexByte = 0; indexByte < AUTHENTICATION_CODE_LENGTH; indexByte++) {
1415
1564
  invalidAuthenticationCode |= authenticationCode[indexByte] ^ originalAuthenticationCode[indexByte];
1416
1565
  }
@@ -1454,14 +1603,14 @@
1454
1603
  const {
1455
1604
  ctr,
1456
1605
  hmac,
1457
- pending,
1606
+ pendingInput,
1458
1607
  ready
1459
1608
  } = this;
1460
1609
  if (hmac && ctr) {
1461
1610
  await ready;
1462
1611
  let encryptedChunkArray = EMPTY_UINT8_ARRAY;
1463
- if (pending.length) {
1464
- const encryptedChunk = ctr.update(toBits(codecBytes, pending));
1612
+ if (pendingInput.length) {
1613
+ const encryptedChunk = ctr.update(toBits(codecBytes, pendingInput));
1465
1614
  hmac.update(encryptedChunk);
1466
1615
  encryptedChunkArray = fromBits(codecBytes, encryptedChunk);
1467
1616
  }
@@ -1478,7 +1627,7 @@
1478
1627
  ready: new Promise(resolve => aesCrypto.resolveReady = resolve),
1479
1628
  password: encodePassword(password, rawPassword),
1480
1629
  strength: encryptionStrength - 1,
1481
- pending: EMPTY_UINT8_ARRAY
1630
+ pendingInput: EMPTY_UINT8_ARRAY
1482
1631
  });
1483
1632
  }
1484
1633
 
@@ -1486,10 +1635,10 @@
1486
1635
  const {
1487
1636
  ctr,
1488
1637
  hmac,
1489
- pending
1638
+ pendingInput
1490
1639
  } = aesCrypto;
1491
- if (pending.length) {
1492
- input = concat(pending, input);
1640
+ if (pendingInput.length) {
1641
+ input = concat(pendingInput, input);
1493
1642
  }
1494
1643
  const inputLength = input.length - paddingEnd;
1495
1644
  output = expand(output, paddingStart + (inputLength - (inputLength % BLOCK_LENGTH)));
@@ -1505,7 +1654,7 @@
1505
1654
  }
1506
1655
  output.set(fromBits(codecBytes, outputChunk), offset + paddingStart);
1507
1656
  }
1508
- aesCrypto.pending = subarray(input, offset);
1657
+ aesCrypto.pendingInput = subarray(input, offset);
1509
1658
  return output;
1510
1659
  }
1511
1660
 
@@ -2756,6 +2905,7 @@
2756
2905
  worker,
2757
2906
  workerAlive: false,
2758
2907
  terminated: false,
2908
+ startupError: null,
2759
2909
  interface: {
2760
2910
  run: async () => {
2761
2911
  try {
@@ -2783,6 +2933,13 @@
2783
2933
  }
2784
2934
 
2785
2935
  async function runWebWorker(workerData, config) {
2936
+ if (!workerData.worker) {
2937
+ const { startupError } = workerData;
2938
+ workerData.startupError = null;
2939
+ const error = startupError || new Error(ERR_WORKER_STARTUP_TIMEOUT);
2940
+ error.workerStartupFailed = true;
2941
+ throw error;
2942
+ }
2786
2943
  let resolveResult, rejectResult;
2787
2944
  const result = new Promise((resolve, reject) => {
2788
2945
  resolveResult = resolve;
@@ -2996,11 +3153,12 @@
2996
3153
  if (!workerAlive) {
2997
3154
  workerData.worker = null;
2998
3155
  }
3156
+ let error = event.error || new Error(event.message || ERROR_EVENT_TYPE);
3157
+ if (!workerAlive) {
3158
+ error = Object.assign(new Error(error.message || ERROR_EVENT_TYPE), { workerStartupFailed: true });
3159
+ workerData.startupError = error;
3160
+ }
2999
3161
  if (rejectResult) {
3000
- let error = event.error || new Error(event.message || ERROR_EVENT_TYPE);
3001
- if (!workerAlive) {
3002
- error = Object.assign(new Error(error.message || ERROR_EVENT_TYPE), { workerStartupFailed: true });
3003
- }
3004
3162
  rejectResult(error);
3005
3163
  if (writer) {
3006
3164
  writer.releaseLock();
@@ -3269,6 +3427,96 @@
3269
3427
  resetWebWorkerSupport();
3270
3428
  }
3271
3429
 
3430
+ /*
3431
+ Copyright (c) 2022 Gildas Lormeau. All rights reserved.
3432
+
3433
+ Redistribution and use in source and binary forms, with or without
3434
+ modification, are permitted provided that the following conditions are met:
3435
+
3436
+ 1. Redistributions of source code must retain the above copyright notice,
3437
+ this list of conditions and the following disclaimer.
3438
+
3439
+ 2. Redistributions in binary form must reproduce the above copyright
3440
+ notice, this list of conditions and the following disclaimer in
3441
+ the documentation and/or other materials provided with the distribution.
3442
+
3443
+ 3. The names of the authors may not be used to endorse or promote products
3444
+ derived from this software without specific prior written permission.
3445
+
3446
+ THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
3447
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
3448
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
3449
+ INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
3450
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3451
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
3452
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
3453
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
3454
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
3455
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3456
+ */
3457
+
3458
+ /* global TextDecoder */
3459
+
3460
+ const CP437 = "\0☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ".split("");
3461
+ const VALID_CP437 = CP437.length == 256;
3462
+
3463
+ function decodeCP437(stringValue) {
3464
+ if (VALID_CP437) {
3465
+ let result = "";
3466
+ for (let indexCharacter = 0; indexCharacter < stringValue.length; indexCharacter++) {
3467
+ result += CP437[stringValue[indexCharacter]];
3468
+ }
3469
+ return result;
3470
+ } else {
3471
+ return new TextDecoder().decode(stringValue);
3472
+ }
3473
+ }
3474
+
3475
+ /*
3476
+ Copyright (c) 2022 Gildas Lormeau. All rights reserved.
3477
+
3478
+ Redistribution and use in source and binary forms, with or without
3479
+ modification, are permitted provided that the following conditions are met:
3480
+
3481
+ 1. Redistributions of source code must retain the above copyright notice,
3482
+ this list of conditions and the following disclaimer.
3483
+
3484
+ 2. Redistributions in binary form must reproduce the above copyright
3485
+ notice, this list of conditions and the following disclaimer in
3486
+ the documentation and/or other materials provided with the distribution.
3487
+
3488
+ 3. The names of the authors may not be used to endorse or promote products
3489
+ derived from this software without specific prior written permission.
3490
+
3491
+ THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
3492
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
3493
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
3494
+ INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
3495
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3496
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
3497
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
3498
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
3499
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
3500
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3501
+ */
3502
+
3503
+
3504
+ function decodeText(value, encoding) {
3505
+ return decode(value, encoding, true);
3506
+ }
3507
+
3508
+ function decodeTextRemovingBOM(value, encoding) {
3509
+ return decode(value, encoding, false);
3510
+ }
3511
+
3512
+ function decode(value, encoding, ignoreBOM) {
3513
+ if (encoding && encoding.trim().toLowerCase() == "cp437") {
3514
+ return decodeCP437(value);
3515
+ } else {
3516
+ return new TextDecoder(encoding, { ignoreBOM }).decode(value);
3517
+ }
3518
+ }
3519
+
3272
3520
  /*
3273
3521
  Copyright (c) 2025 Gildas Lormeau. All rights reserved.
3274
3522
 
@@ -3341,6 +3589,7 @@
3341
3589
  createReadable({ offset = 0, size, chunkSize = getChunkSize(getConfiguration()) } = {}) {
3342
3590
  const reader = this;
3343
3591
  let chunkOffset = 0;
3592
+ chunkSize = normalizeChunkSize(chunkSize);
3344
3593
  return new ReadableStream({
3345
3594
  async pull(controller) {
3346
3595
  const dataSize = size === UNDEFINED_VALUE ? chunkSize : Math.min(chunkSize, size - chunkOffset);
@@ -3348,7 +3597,7 @@
3348
3597
  if (data.length) {
3349
3598
  controller.enqueue(data);
3350
3599
  }
3351
- if ((chunkOffset + chunkSize >= size) || (size === UNDEFINED_VALUE && !data.length && dataSize)) {
3600
+ if ((chunkOffset + chunkSize >= size) || (!data.length && dataSize)) {
3352
3601
  controller.close();
3353
3602
  } else {
3354
3603
  chunkOffset += chunkSize;
@@ -3428,31 +3677,31 @@
3428
3677
  Object.assign(this, {
3429
3678
  contentType,
3430
3679
  data: "data:" + (contentType || "") + ";base64,",
3431
- pending: []
3680
+ pendingCharacters: ""
3432
3681
  });
3433
3682
  }
3434
3683
 
3435
3684
  writeUint8Array(array) {
3436
3685
  const writer = this;
3437
3686
  let indexArray;
3438
- let dataString = writer.pending;
3439
- const delta = writer.pending.length;
3440
- writer.pending = "";
3687
+ let dataString = writer.pendingCharacters;
3688
+ const delta = writer.pendingCharacters.length;
3689
+ writer.pendingCharacters = "";
3441
3690
  for (indexArray = 0; indexArray < (Math.floor((delta + array.length) / 3) * 3) - delta; indexArray++) {
3442
3691
  dataString += String.fromCharCode(array[indexArray]);
3443
3692
  }
3444
3693
  for (; indexArray < array.length; indexArray++) {
3445
- writer.pending += String.fromCharCode(array[indexArray]);
3694
+ writer.pendingCharacters += String.fromCharCode(array[indexArray]);
3446
3695
  }
3447
3696
  if (dataString.length > 2) {
3448
3697
  writer.data += btoa(dataString);
3449
3698
  } else {
3450
- writer.pending = dataString + writer.pending;
3699
+ writer.pendingCharacters = dataString + writer.pendingCharacters;
3451
3700
  }
3452
3701
  }
3453
3702
 
3454
3703
  getData() {
3455
- return this.data + btoa(this.pending);
3704
+ return this.data + btoa(this.pendingCharacters);
3456
3705
  }
3457
3706
  }
3458
3707
 
@@ -3482,7 +3731,7 @@
3482
3731
  constructor(blob) {
3483
3732
  super();
3484
3733
  Object.assign(this, {
3485
- blob,
3734
+ sourceBlob: blob,
3486
3735
  size: blob.size
3487
3736
  });
3488
3737
  if (!blobSliceProbe) {
@@ -3492,13 +3741,13 @@
3492
3741
 
3493
3742
  createReadable(options) {
3494
3743
  const reader = this;
3495
- const { blob, size } = reader;
3744
+ const { sourceBlob, size } = reader;
3496
3745
  const { offset = 0, size: readSize = size - offset } = options || {};
3497
3746
  if (!offset && readSize >= size) {
3498
- return toCompatibleReadable(blob.stream());
3747
+ return toCompatibleReadable(sourceBlob.stream());
3499
3748
  }
3500
3749
  if (blobSliceReliable) {
3501
- return toCompatibleReadable(blob.slice(offset, offset + readSize).stream());
3750
+ return toCompatibleReadable(sourceBlob.slice(offset, offset + readSize).stream());
3502
3751
  }
3503
3752
  return super.createReadable(options);
3504
3753
  }
@@ -3507,7 +3756,7 @@
3507
3756
  const reader = this;
3508
3757
  const offsetEnd = offset + length;
3509
3758
  const readsWholeBlob = !offset && offsetEnd >= reader.size;
3510
- const blob = readsWholeBlob ? reader.blob : reader.blob.slice(offset, offsetEnd);
3759
+ const blob = readsWholeBlob ? reader.sourceBlob : reader.sourceBlob.slice(offset, offsetEnd);
3511
3760
  let arrayBuffer = await blob.arrayBuffer();
3512
3761
  const sliceIgnoredByBuggyImplementation = arrayBuffer.byteLength > length;
3513
3762
  if (sliceIgnoredByBuggyImplementation) {
@@ -3529,12 +3778,12 @@
3529
3778
  }
3530
3779
  });
3531
3780
  writer.contentType = contentType;
3532
- writer.blob = streamToBlob(transformStream.readable, contentType);
3533
- writer.blob.catch(() => { });
3781
+ writer.blobPromise = streamToBlob(transformStream.readable, contentType);
3782
+ writer.blobPromise.catch(() => { });
3534
3783
  }
3535
3784
 
3536
3785
  getData() {
3537
- return this.blob;
3786
+ return this.blobPromise;
3538
3787
  }
3539
3788
  }
3540
3789
 
@@ -3548,7 +3797,7 @@
3548
3797
  class TextWriter extends BlobWriter {
3549
3798
 
3550
3799
  constructor(encoding) {
3551
- super(encoding);
3800
+ super();
3552
3801
  Object.assign(this, {
3553
3802
  encoding,
3554
3803
  utf8: !encoding || encoding.toLowerCase() == "utf-8"
@@ -3564,14 +3813,7 @@
3564
3813
  if (blob.text && utf8) {
3565
3814
  return blob.text();
3566
3815
  } else {
3567
- const reader = new FileReader();
3568
- return new Promise((resolve, reject) => {
3569
- Object.assign(reader, {
3570
- onload: ({ target }) => resolve(target.result),
3571
- onerror: () => reject(reader.error)
3572
- });
3573
- reader.readAsText(blob, encoding);
3574
- });
3816
+ return decodeTextRemovingBOM(new Uint8Array(await blob.arrayBuffer()), encoding);
3575
3817
  }
3576
3818
  }
3577
3819
  }
@@ -4029,9 +4271,8 @@
4029
4271
 
4030
4272
  async init() {
4031
4273
  const reader = this;
4032
- const { readers } = reader;
4033
4274
  reader.lastDiskNumber = 0;
4034
- await Promise.all(readers.map(diskReader => initStream(diskReader)));
4275
+ const readers = reader.readers = await Promise.all(reader.readers.map(initDiskReader));
4035
4276
  reader.diskOffsets = readers.map(diskReader => {
4036
4277
  const diskOffset = reader.size;
4037
4278
  reader.size += diskReader.size;
@@ -4226,89 +4467,27 @@
4226
4467
  }
4227
4468
  }
4228
4469
 
4229
- function readUint8Array(reader, offset, size) {
4230
- return reader.readUint8Array(offset, size);
4231
- }
4232
-
4233
- /*
4234
- Copyright (c) 2022 Gildas Lormeau. All rights reserved.
4235
-
4236
- Redistribution and use in source and binary forms, with or without
4237
- modification, are permitted provided that the following conditions are met:
4238
-
4239
- 1. Redistributions of source code must retain the above copyright notice,
4240
- this list of conditions and the following disclaimer.
4241
-
4242
- 2. Redistributions in binary form must reproduce the above copyright
4243
- notice, this list of conditions and the following disclaimer in
4244
- the documentation and/or other materials provided with the distribution.
4245
-
4246
- 3. The names of the authors may not be used to endorse or promote products
4247
- derived from this software without specific prior written permission.
4248
-
4249
- THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
4250
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
4251
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
4252
- INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
4253
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
4254
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
4255
- OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
4256
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
4257
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
4258
- EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4259
- */
4260
-
4261
- /* global TextDecoder */
4262
-
4263
- const CP437 = "\0☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ".split("");
4264
- const VALID_CP437 = CP437.length == 256;
4265
-
4266
- function decodeCP437(stringValue) {
4267
- if (VALID_CP437) {
4268
- let result = "";
4269
- for (let indexCharacter = 0; indexCharacter < stringValue.length; indexCharacter++) {
4270
- result += CP437[stringValue[indexCharacter]];
4271
- }
4272
- return result;
4273
- } else {
4274
- return new TextDecoder().decode(stringValue);
4470
+ async function initDiskReader(diskReader) {
4471
+ diskReader = new GenericReader(diskReader);
4472
+ await initStream(diskReader);
4473
+ if (diskReader.size === UNDEFINED_VALUE || !diskReader.readUint8Array) {
4474
+ diskReader = new BlobReader(await streamToBlob(diskReader.readable));
4475
+ await initStream(diskReader);
4275
4476
  }
4477
+ return diskReader;
4276
4478
  }
4277
4479
 
4278
- /*
4279
- Copyright (c) 2022 Gildas Lormeau. All rights reserved.
4280
-
4281
- Redistribution and use in source and binary forms, with or without
4282
- modification, are permitted provided that the following conditions are met:
4283
-
4284
- 1. Redistributions of source code must retain the above copyright notice,
4285
- this list of conditions and the following disclaimer.
4286
-
4287
- 2. Redistributions in binary form must reproduce the above copyright
4288
- notice, this list of conditions and the following disclaimer in
4289
- the documentation and/or other materials provided with the distribution.
4290
-
4291
- 3. The names of the authors may not be used to endorse or promote products
4292
- derived from this software without specific prior written permission.
4293
-
4294
- THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
4295
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
4296
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
4297
- INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
4298
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
4299
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
4300
- OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
4301
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
4302
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
4303
- EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4304
- */
4305
-
4480
+ function readUint8Array(reader, offset, size) {
4481
+ return reader.readUint8Array(offset, size);
4482
+ }
4306
4483
 
4307
- function decodeText(value, encoding) {
4308
- if (encoding && encoding.trim().toLowerCase() == "cp437") {
4309
- return decodeCP437(value);
4484
+ function createReadable(reader, options) {
4485
+ if (reader.createReadable) {
4486
+ return reader.createReadable(options);
4487
+ } else if (reader.readUint8Array) {
4488
+ return Reader.prototype.createReadable.call(reader, options);
4310
4489
  } else {
4311
- return new TextDecoder(encoding, { ignoreBOM: true }).decode(value);
4490
+ return reader.readable;
4312
4491
  }
4313
4492
  }
4314
4493
 
@@ -4384,6 +4563,10 @@
4384
4563
  const PROPERTY_NAME_SETGID = "setgid";
4385
4564
  const PROPERTY_NAME_STICKY = "sticky";
4386
4565
  const PROPERTY_NAME_BITFLAG = "bitFlag";
4566
+ const PROPERTY_NAME_RAW_BITFLAG = "rawBitFlag";
4567
+ const PROPERTY_NAME_FILENAME_LENGTH = "filenameLength";
4568
+ const PROPERTY_NAME_EXTRA_FIELD_LENGTH = "extraFieldLength";
4569
+ const PROPERTY_NAME_UNIX_EXTERNAL_UPPER = "unixExternalUpper";
4387
4570
  const PROPERTY_NAME_FILENAME_UTF8 = "filenameUTF8";
4388
4571
  const PROPERTY_NAME_COMMENT_UTF8 = "commentUTF8";
4389
4572
  const PROPERTY_NAME_RAW_EXTRA_FIELD = "rawExtraField";
@@ -4436,10 +4619,14 @@
4436
4619
  PROPERTY_NAME_UID,
4437
4620
  PROPERTY_NAME_GID,
4438
4621
  PROPERTY_NAME_UNIX_MODE,
4622
+ PROPERTY_NAME_UNIX_EXTERNAL_UPPER,
4439
4623
  PROPERTY_NAME_SETUID,
4440
4624
  PROPERTY_NAME_SETGID,
4441
4625
  PROPERTY_NAME_STICKY,
4442
4626
  PROPERTY_NAME_BITFLAG,
4627
+ PROPERTY_NAME_RAW_BITFLAG,
4628
+ PROPERTY_NAME_FILENAME_LENGTH,
4629
+ PROPERTY_NAME_EXTRA_FIELD_LENGTH,
4443
4630
  PROPERTY_NAME_FILENAME_UTF8,
4444
4631
  PROPERTY_NAME_COMMENT_UTF8,
4445
4632
  PROPERTY_NAME_RAW_EXTRA_FIELD,
@@ -4460,82 +4647,6 @@
4460
4647
 
4461
4648
  }
4462
4649
 
4463
- /*
4464
- Copyright (c) 2022 Gildas Lormeau. All rights reserved.
4465
-
4466
- Redistribution and use in source and binary forms, with or without
4467
- modification, are permitted provided that the following conditions are met:
4468
-
4469
- 1. Redistributions of source code must retain the above copyright notice,
4470
- this list of conditions and the following disclaimer.
4471
-
4472
- 2. Redistributions in binary form must reproduce the above copyright
4473
- notice, this list of conditions and the following disclaimer in
4474
- the documentation and/or other materials provided with the distribution.
4475
-
4476
- 3. The names of the authors may not be used to endorse or promote products
4477
- derived from this software without specific prior written permission.
4478
-
4479
- THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
4480
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
4481
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
4482
- INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
4483
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
4484
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
4485
- OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
4486
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
4487
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
4488
- EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4489
- */
4490
-
4491
- const OPTION_FILENAME_ENCODING = "filenameEncoding";
4492
- const OPTION_COMMENT_ENCODING = "commentEncoding";
4493
- const OPTION_DECODE_TEXT = "decodeText";
4494
- const OPTION_EXTRACT_PREPENDED_DATA = "extractPrependedData";
4495
- const OPTION_EXTRACT_APPENDED_DATA = "extractAppendedData";
4496
- const OPTION_PASSWORD = "password";
4497
- const OPTION_RAW_PASSWORD = "rawPassword";
4498
- const OPTION_PASS_THROUGH = "passThrough";
4499
- const OPTION_SIGNAL = "signal";
4500
- const OPTION_CHECK_PASSWORD_ONLY = "checkPasswordOnly";
4501
- const OPTION_CHECK_OVERLAPPING_ENTRY_ONLY = "checkOverlappingEntryOnly";
4502
- const OPTION_CHECK_OVERLAPPING_ENTRY = "checkOverlappingEntry";
4503
- const OPTION_CHECK_AMBIGUITY = "checkAmbiguity";
4504
- const OPTION_CHECK_SIGNATURE = "checkSignature";
4505
- const OPTION_CHECK_CRC32 = "checkCrc32";
4506
- const OPTION_CHECK_AUTHENTICATION_CODE = "checkAuthenticationCode";
4507
- const OPTION_USE_WEB_WORKERS = "useWebWorkers";
4508
- const OPTION_USE_COMPRESSION_STREAM = "useCompressionStream";
4509
- const OPTION_TRANSFER_STREAMS = "transferStreams";
4510
- const OPTION_PREVENT_CLOSE = "preventClose";
4511
- const OPTION_ENCRYPTION_STRENGTH = "encryptionStrength";
4512
- const OPTION_EXTENDED_TIMESTAMP = "extendedTimestamp";
4513
- const OPTION_NTFS_TIMESTAMP = "ntfsTimestamp";
4514
- const OPTION_KEEP_ORDER = "keepOrder";
4515
- const OPTION_LEVEL = "level";
4516
- const OPTION_BUFFERED_WRITE = "bufferedWrite";
4517
- const OPTION_CREATE_TEMP_STREAM = "createTempStream";
4518
- const OPTION_DATA_DESCRIPTOR_SIGNATURE = "dataDescriptorSignature";
4519
- const OPTION_USE_UNICODE_FILE_NAMES = "useUnicodeFileNames";
4520
- const OPTION_DATA_DESCRIPTOR = "dataDescriptor";
4521
- const OPTION_SUPPORT_ZIP64_SPLIT_FILE = "supportZip64SplitFile";
4522
- const OPTION_ENCODE_TEXT = "encodeText";
4523
- const OPTION_OFFSET = "offset";
4524
- const OPTION_USDZ = "usdz";
4525
- const OPTION_UNIX_EXTRA_FIELD_TYPE = "unixExtraFieldType";
4526
- const OPTION_LOCAL_EXTRA_FIELD = "localExtraField";
4527
- const OPTION_STRICTNESS = "strictness";
4528
- const OPTION_FILENAME_VALIDATION = "filenameValidation";
4529
- const OPTION_NORMALIZE_FILENAME = "normalizeFilename";
4530
- const OPTION_MAX_APPENDED_DATA_SIZE = "maxAppendedDataSize";
4531
- const OPTION_DECRYPT_CENTRAL_DIRECTORY = "decryptCentralDirectory";
4532
- const OPTION_SIGN_CENTRAL_DIRECTORY = "signCentralDirectory";
4533
- const TEXT_TYPE_FILENAME = "filename";
4534
- const TEXT_TYPE_COMMENT = "comment";
4535
- const STRICTNESS_STRICT = "strict";
4536
- const STRICTNESS_BALANCED = "balanced";
4537
- const STRICTNESS_TOLERANT = "tolerant";
4538
-
4539
4650
  /*
4540
4651
  Copyright (c) 2025 Gildas Lormeau. All rights reserved.
4541
4652
 
@@ -4576,6 +4687,7 @@
4576
4687
  const ERR_UNSUPPORTED_COMPRESSION$1 = "Compression method not supported";
4577
4688
  const ERR_SPLIT_ZIP_FILE = "Split zip file";
4578
4689
  const ERR_OVERLAPPING_ENTRY = "Overlapping entry found";
4690
+ const ERR_ENTRY_DATA_OUT_OF_BOUNDS = "Entry data out of bounds";
4579
4691
  const ERR_AMBIGUOUS_ARCHIVE = "Ambiguous archive";
4580
4692
  const ERR_ENCRYPTED_CENTRAL_DIRECTORY = "Encrypted central directory is not supported";
4581
4693
  const ERR_UNSAFE_FILENAME = "Unsafe filename";
@@ -4596,7 +4708,7 @@
4596
4708
  ];
4597
4709
  const ZIP64_EXTRACTION = {
4598
4710
  [MAX_16_BITS]: {
4599
- getValue: getUint32,
4711
+ getValue: getUint32$1,
4600
4712
  bytes: 4
4601
4713
  },
4602
4714
  [MAX_32_BITS]: {
@@ -4605,6 +4717,7 @@
4605
4717
  }
4606
4718
  };
4607
4719
  const MAX_END_OF_CENTRAL_DIR_PROBES = 64;
4720
+ const MAX_DEFLATE_EXPANSION_RATIO = 1032;
4608
4721
  const CENTRAL_DIRECTORY_UNREACHABLE = 0;
4609
4722
  const CENTRAL_DIRECTORY_PLAUSIBLE = 1;
4610
4723
  const CENTRAL_DIRECTORY_REACHABLE = 2;
@@ -4615,7 +4728,6 @@
4615
4728
  Object.assign(this, {
4616
4729
  reader: new GenericReader(reader),
4617
4730
  options,
4618
- config: getConfiguration(),
4619
4731
  readRanges: new Map()
4620
4732
  });
4621
4733
  }
@@ -4623,7 +4735,6 @@
4623
4735
  async* getEntriesGenerator(options = {}) {
4624
4736
  const zipReader = this;
4625
4737
  let { reader } = zipReader;
4626
- const { config } = zipReader;
4627
4738
  await initStream(reader);
4628
4739
  if (reader.size === UNDEFINED_VALUE || !reader.readUint8Array) {
4629
4740
  reader = new BlobReader(await streamToBlob(reader.readable));
@@ -4632,7 +4743,7 @@
4632
4743
  if (reader.size < END_OF_CENTRAL_DIR_LENGTH) {
4633
4744
  throw new Error(ERR_BAD_FORMAT);
4634
4745
  }
4635
- const strictness = getStrictness(getOptionValue$1(zipReader, options, OPTION_STRICTNESS), getOptionValue$1(zipReader, options, OPTION_CHECK_AMBIGUITY));
4746
+ const strictness = getStrictness(options, zipReader.options);
4636
4747
  const checkAmbiguity = strictness == STRICTNESS_STRICT;
4637
4748
  const rejectAmbiguousEndOfDirectory = strictness != STRICTNESS_TOLERANT;
4638
4749
  const maxAppendedDataSize = getMaxAppendedDataSize(getOptionValue$1(zipReader, options, OPTION_MAX_APPENDED_DATA_SIZE), strictness);
@@ -4640,9 +4751,7 @@
4640
4751
  const normalizeFilename = getOptionValue$1(zipReader, options, OPTION_NORMALIZE_FILENAME);
4641
4752
  const { endOfDirectoryInfo, endOfDirectoryReachingEndCount } = await findEndOfCentralDirectory(reader, rejectAmbiguousEndOfDirectory, maxAppendedDataSize);
4642
4753
  if (!endOfDirectoryInfo) {
4643
- const signatureArray = await readUint8Array(reader, 0, 4);
4644
- const signatureView = getDataView(signatureArray);
4645
- if (getUint32(signatureView) == SPLIT_ZIP_FILE_SIGNATURE) {
4754
+ if (await startsWithSplitZipSignature$1(reader)) {
4646
4755
  throw new Error(ERR_SPLIT_ZIP_FILE);
4647
4756
  } else {
4648
4757
  throw new Error(ERR_EOCDR_NOT_FOUND);
@@ -4652,18 +4761,18 @@
4652
4761
  throwAmbiguousArchive("multiple end of central directory records");
4653
4762
  }
4654
4763
  const endOfDirectoryView = getDataView(endOfDirectoryInfo);
4655
- let directoryDataLength = getUint32(endOfDirectoryView, 12);
4656
- let directoryDataOffset = getUint32(endOfDirectoryView, 16);
4764
+ let directoryDataLength = getUint32$1(endOfDirectoryView, 12);
4765
+ let directoryDataOffset = getUint32$1(endOfDirectoryView, 16);
4657
4766
  const commentOffset = endOfDirectoryInfo.offset;
4658
- const commentLength = getUint16(endOfDirectoryView, 20);
4767
+ const commentLength = getUint16$1(endOfDirectoryView, 20);
4659
4768
  const appendedDataOffset = commentOffset + END_OF_CENTRAL_DIR_LENGTH + commentLength;
4660
4769
  if (reader.size - appendedDataOffset > maxAppendedDataSize) {
4661
4770
  throwAmbiguousArchive("appended data");
4662
4771
  }
4663
- let lastDiskNumber = getUint16(endOfDirectoryView, 4);
4772
+ let lastDiskNumber = getUint16$1(endOfDirectoryView, 4);
4664
4773
  const expectedLastDiskNumber = reader.lastDiskNumber || 0;
4665
- let diskNumber = getUint16(endOfDirectoryView, 6);
4666
- let filesLength = getUint16(endOfDirectoryView, 10);
4774
+ let diskNumber = getUint16$1(endOfDirectoryView, 6);
4775
+ let filesLength = getUint16$1(endOfDirectoryView, 10);
4667
4776
  let prependedDataLength = 0;
4668
4777
  let startOffset;
4669
4778
  let zip64EndOfDirectory;
@@ -4679,12 +4788,12 @@
4679
4788
  EMPTY_UINT8_ARRAY;
4680
4789
  const endOfDirectoryLocatorView = getDataView(endOfDirectoryLocatorArray);
4681
4790
  if (endOfDirectoryLocatorArray.length == ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH &&
4682
- getUint32(endOfDirectoryLocatorView, 0) == ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE) {
4683
- directoryDataOffset = getDiskOffset$1(reader, getUint32(endOfDirectoryLocatorView, 4)) + getBigUint64(endOfDirectoryLocatorView, 8);
4791
+ getUint32$1(endOfDirectoryLocatorView, 0) == ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE) {
4792
+ directoryDataOffset = getDiskOffset$1(reader, getUint32$1(endOfDirectoryLocatorView, 4)) + getBigUint64(endOfDirectoryLocatorView, 8);
4684
4793
  let endOfDirectoryArray = await readUint8Array(reader, directoryDataOffset, ZIP64_END_OF_CENTRAL_DIR_LENGTH);
4685
4794
  let endOfDirectoryView = getDataView(endOfDirectoryArray);
4686
4795
  const expectedDirectoryDataOffset = endOfDirectoryInfo.offset - ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH - ZIP64_END_OF_CENTRAL_DIR_LENGTH;
4687
- if ((endOfDirectoryArray.length < ZIP64_END_OF_CENTRAL_DIR_LENGTH || getUint32(endOfDirectoryView, 0) != ZIP64_END_OF_CENTRAL_DIR_SIGNATURE) &&
4796
+ if ((endOfDirectoryArray.length < ZIP64_END_OF_CENTRAL_DIR_LENGTH || getUint32$1(endOfDirectoryView, 0) != ZIP64_END_OF_CENTRAL_DIR_SIGNATURE) &&
4688
4797
  directoryDataOffset != expectedDirectoryDataOffset && expectedDirectoryDataOffset >= 0) {
4689
4798
  const originalDirectoryDataOffset = directoryDataOffset;
4690
4799
  directoryDataOffset = expectedDirectoryDataOffset;
@@ -4694,7 +4803,7 @@
4694
4803
  endOfDirectoryArray = await readUint8Array(reader, directoryDataOffset, ZIP64_END_OF_CENTRAL_DIR_LENGTH);
4695
4804
  endOfDirectoryView = getDataView(endOfDirectoryArray);
4696
4805
  }
4697
- if (endOfDirectoryArray.length < ZIP64_END_OF_CENTRAL_DIR_LENGTH || getUint32(endOfDirectoryView, 0) != ZIP64_END_OF_CENTRAL_DIR_SIGNATURE) {
4806
+ if (endOfDirectoryArray.length < ZIP64_END_OF_CENTRAL_DIR_LENGTH || getUint32$1(endOfDirectoryView, 0) != ZIP64_END_OF_CENTRAL_DIR_SIGNATURE) {
4698
4807
  throw new Error(ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND);
4699
4808
  }
4700
4809
  zip64EndOfDirectory = true;
@@ -4709,13 +4818,13 @@
4709
4818
  }
4710
4819
  }
4711
4820
  if (lastDiskNumber == MAX_16_BITS) {
4712
- lastDiskNumber = getUint32(endOfDirectoryView, 16);
4713
- } else if (checkAmbiguity && lastDiskNumber != getUint32(endOfDirectoryView, 16)) {
4821
+ lastDiskNumber = getUint32$1(endOfDirectoryView, 16);
4822
+ } else if (checkAmbiguity && lastDiskNumber != getUint32$1(endOfDirectoryView, 16)) {
4714
4823
  throwAmbiguousArchive("mismatched zip64 end of central directory record");
4715
4824
  }
4716
4825
  if (diskNumber == MAX_16_BITS) {
4717
- diskNumber = getUint32(endOfDirectoryView, 20);
4718
- } else if (checkAmbiguity && diskNumber != getUint32(endOfDirectoryView, 20)) {
4826
+ diskNumber = getUint32$1(endOfDirectoryView, 20);
4827
+ } else if (checkAmbiguity && diskNumber != getUint32$1(endOfDirectoryView, 20)) {
4719
4828
  throwAmbiguousArchive("mismatched zip64 end of central directory record");
4720
4829
  }
4721
4830
  if (filesLength == MAX_16_BITS) {
@@ -4753,11 +4862,11 @@
4753
4862
  }
4754
4863
  const expectedDirectoryDataOffset = centralDirectoryEndOffset - directoryDataLength;
4755
4864
  if (directoryDataOffset != expectedDirectoryDataOffset && diskNumber == lastDiskNumber) {
4756
- const storedPointsAtDirectory = getUint32(directoryView, offset) == CENTRAL_FILE_HEADER_SIGNATURE;
4865
+ const storedPointsAtDirectory = getUint32$1(directoryView, offset) == CENTRAL_FILE_HEADER_SIGNATURE;
4757
4866
  let reconcile = !storedPointsAtDirectory;
4758
4867
  if (!reconcile && expectedDirectoryDataOffset >= 0 && expectedDirectoryDataOffset + 4 <= reader.size) {
4759
4868
  const expectedSignatureArray = await readUint8Array(reader, expectedDirectoryDataOffset, 4);
4760
- reconcile = getUint32(getDataView(expectedSignatureArray), 0) == CENTRAL_FILE_HEADER_SIGNATURE;
4869
+ reconcile = getUint32$1(getDataView(expectedSignatureArray), 0) == CENTRAL_FILE_HEADER_SIGNATURE;
4761
4870
  }
4762
4871
  if (reconcile) {
4763
4872
  const originalDirectoryDataOffset = directoryDataOffset;
@@ -4781,10 +4890,10 @@
4781
4890
  }
4782
4891
  zipReader.directoryOffset = directoryDataOffset;
4783
4892
  zipReader.directoryLength = declaredDirectoryDataLength;
4784
- const decryptCentralDirectory = getOptionValue$1(zipReader, options, OPTION_DECRYPT_CENTRAL_DIRECTORY);
4893
+ const decryptCentralDirectory = getFunctionOptionValue$1(zipReader, options, OPTION_DECRYPT_CENTRAL_DIRECTORY);
4785
4894
  let decryptedDirectory;
4786
4895
  if (decryptCentralDirectory && filesLength && directoryArray.length >= 4 &&
4787
- getUint32(directoryView, 0) != CENTRAL_FILE_HEADER_SIGNATURE &&
4896
+ getUint32$1(directoryView, 0) != CENTRAL_FILE_HEADER_SIGNATURE &&
4788
4897
  (zip64EndOfDirectoryVersion2 || detectEncryptedCentralDirectory(directoryView))) {
4789
4898
  directoryArray = await decryptCentralDirectory(directoryArray, directoryEncryptionInfo);
4790
4899
  directoryView = getDataView(directoryArray);
@@ -4797,8 +4906,8 @@
4797
4906
  const filenames = checkAmbiguity ? new Set() : UNDEFINED_VALUE;
4798
4907
  let duplicateFilename;
4799
4908
  for (let indexFile = 0; indexFile < filesLength; indexFile++) {
4800
- const fileEntry = new ZipEntry(reader, config, zipReader.options);
4801
- if (offset + CENTRAL_FILE_HEADER_LENGTH > directoryArray.length || getUint32(directoryView, offset) != CENTRAL_FILE_HEADER_SIGNATURE) {
4909
+ const fileEntry = new ZipEntry(reader, zipReader.options);
4910
+ if (offset + CENTRAL_FILE_HEADER_LENGTH > directoryArray.length || getUint32$1(directoryView, offset) != CENTRAL_FILE_HEADER_SIGNATURE) {
4802
4911
  if (indexFile == 0 && !decryptedDirectory && (zip64EndOfDirectoryVersion2 || detectEncryptedCentralDirectory(directoryView))) {
4803
4912
  throw new Error(ERR_ENCRYPTED_CENTRAL_DIRECTORY);
4804
4913
  }
@@ -4809,16 +4918,16 @@
4809
4918
  const filenameOffset = offset + CENTRAL_FILE_HEADER_LENGTH;
4810
4919
  const extraFieldOffset = filenameOffset + fileEntry.filenameLength;
4811
4920
  const commentOffset = extraFieldOffset + fileEntry.extraFieldLength;
4812
- const versionMadeBy = getUint16(directoryView, offset + 4);
4921
+ const versionMadeBy = getUint16$1(directoryView, offset + 4);
4813
4922
  const msDosCompatible = versionMadeBy >> 8 == 0;
4814
4923
  const unixCompatible = versionMadeBy >> 8 == 3;
4815
4924
  const rawFilename = directoryArray.subarray(filenameOffset, extraFieldOffset);
4816
- const commentLength = getUint16(directoryView, offset + 32);
4925
+ const commentLength = getUint16$1(directoryView, offset + 32);
4817
4926
  const endOffset = commentOffset + commentLength;
4818
4927
  const rawComment = directoryArray.subarray(commentOffset, endOffset);
4819
4928
  const filenameUTF8 = languageEncodingFlag;
4820
4929
  const commentUTF8 = languageEncodingFlag;
4821
- const externalFileAttributes = getUint32(directoryView, offset + 38);
4930
+ const externalFileAttributes = getUint32$1(directoryView, offset + 38);
4822
4931
  const msdosAttributesRaw = externalFileAttributes & MAX_8_BITS;
4823
4932
  const msdosAttributes = {
4824
4933
  readOnly: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_READONLY_MASK),
@@ -4827,8 +4936,8 @@
4827
4936
  directory: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_DIR_MASK),
4828
4937
  archive: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_ARCHIVE_MASK)
4829
4938
  };
4830
- const offsetFileEntry = getUint32(directoryView, offset + 42);
4831
- const decode = getOptionValue$1(zipReader, options, OPTION_DECODE_TEXT) || decodeText;
4939
+ const offsetFileEntry = getUint32$1(directoryView, offset + 42);
4940
+ const decode = getFunctionOptionValue$1(zipReader, options, OPTION_DECODE_TEXT) || decodeText;
4832
4941
  const rawFilenameEncoding = filenameUTF8 ? CHARSET_UTF8 : filenameEncoding || CHARSET_CP437;
4833
4942
  const rawCommentEncoding = commentUTF8 ? CHARSET_UTF8 : commentEncoding || CHARSET_CP437;
4834
4943
  let filename = decode(rawFilename, rawFilenameEncoding, TEXT_TYPE_FILENAME);
@@ -4854,12 +4963,13 @@
4854
4963
  index: indexFile,
4855
4964
  versionMadeBy,
4856
4965
  msDosCompatible,
4966
+ zip64: false,
4857
4967
  compressedSize: 0,
4858
4968
  uncompressedSize: 0,
4859
4969
  commentLength,
4860
4970
  offset: offsetFileEntry,
4861
- diskNumberStart: getUint16(directoryView, offset + 34),
4862
- internalFileAttributes: getUint16(directoryView, offset + 36),
4971
+ diskNumberStart: getUint16$1(directoryView, offset + 34),
4972
+ internalFileAttributes: getUint16$1(directoryView, offset + 36),
4863
4973
  externalFileAttributes,
4864
4974
  msdosAttributesRaw,
4865
4975
  msdosAttributes,
@@ -4927,8 +5037,8 @@
4927
5037
  yield entry;
4928
5038
  }
4929
5039
  let offsetAfterSignature = offset;
4930
- if (offset + 6 <= directoryArray.length && getUint32(directoryView, offset) == DIGITAL_SIGNATURE_RECORD_SIGNATURE) {
4931
- const signatureDataLength = getUint16(directoryView, offset + 4);
5040
+ if (offset + 6 <= directoryArray.length && getUint32$1(directoryView, offset) == DIGITAL_SIGNATURE_RECORD_SIGNATURE) {
5041
+ const signatureDataLength = getUint16$1(directoryView, offset + 4);
4932
5042
  if (offset + 6 + signatureDataLength <= directoryArray.length) {
4933
5043
  zipReader.digitalSignature = directoryArray.subarray(offset + 6, offset + 6 + signatureDataLength);
4934
5044
  offsetAfterSignature = offset + 6 + signatureDataLength;
@@ -4940,13 +5050,17 @@
4940
5050
  if (duplicateFilename) {
4941
5051
  throwAmbiguousArchive("duplicate filename");
4942
5052
  }
4943
- if (checkAmbiguity && (prependedDataLength || (filesLength && startOffset > 0))) {
4944
- throwAmbiguousArchive("prepended data");
4945
- }
4946
5053
  const extractPrependedData = getOptionValue$1(zipReader, options, OPTION_EXTRACT_PREPENDED_DATA);
4947
5054
  const extractAppendedData = getOptionValue$1(zipReader, options, OPTION_EXTRACT_APPENDED_DATA);
5055
+ const splitZipSignatureLength = (checkAmbiguity || extractPrependedData) && filesLength &&
5056
+ startOffset == SPLIT_ZIP_FILE_SIGNATURE_LENGTH && await startsWithSplitZipMarker(reader) ? SPLIT_ZIP_FILE_SIGNATURE_LENGTH : 0;
5057
+ if (checkAmbiguity && (prependedDataLength || (filesLength && startOffset > splitZipSignatureLength))) {
5058
+ throwAmbiguousArchive("prepended data");
5059
+ }
4948
5060
  if (extractPrependedData) {
4949
- zipReader.prependedData = startOffset > 0 ? await readUint8Array(reader, 0, startOffset) : EMPTY_UINT8_ARRAY;
5061
+ zipReader.prependedData = startOffset > splitZipSignatureLength ?
5062
+ await readUint8Array(reader, splitZipSignatureLength, startOffset - splitZipSignatureLength) :
5063
+ EMPTY_UINT8_ARRAY;
4950
5064
  }
4951
5065
  zipReader.comment = commentLength ? await readUint8Array(reader, commentOffset + END_OF_CENTRAL_DIR_LENGTH, commentLength) : EMPTY_UINT8_ARRAY;
4952
5066
  if (extractAppendedData) {
@@ -5013,16 +5127,16 @@
5013
5127
 
5014
5128
  class ZipEntry {
5015
5129
 
5016
- constructor(reader, config, options) {
5130
+ constructor(reader, options) {
5017
5131
  Object.assign(this, {
5018
5132
  reader,
5019
- config,
5020
5133
  options
5021
5134
  });
5022
5135
  }
5023
5136
 
5024
5137
  async getData(writer, fileEntry, readRanges, options = {}) {
5025
5138
  const zipEntry = this;
5139
+ const config = getConfiguration();
5026
5140
  const {
5027
5141
  reader,
5028
5142
  index,
@@ -5031,7 +5145,6 @@
5031
5145
  extraFieldAES,
5032
5146
  extraFieldZip64,
5033
5147
  compressionMethod,
5034
- config,
5035
5148
  bitFlag,
5036
5149
  rawBitFlag,
5037
5150
  crc32,
@@ -5049,6 +5162,7 @@
5049
5162
  let password = getOptionValue$1(zipEntry, options, OPTION_PASSWORD);
5050
5163
  let rawPassword = getOptionValue$1(zipEntry, options, OPTION_RAW_PASSWORD);
5051
5164
  const passThrough = getOptionValue$1(zipEntry, options, OPTION_PASS_THROUGH);
5165
+ checkPasswordOption(password, rawPassword);
5052
5166
  password = password && password.length && password;
5053
5167
  rawPassword = rawPassword && rawPassword.length && rawPassword;
5054
5168
  if (extraFieldAES) {
@@ -5056,7 +5170,7 @@
5056
5170
  throw new Error(ERR_UNSUPPORTED_COMPRESSION$1);
5057
5171
  }
5058
5172
  }
5059
- if (dataArray.length < HEADER_SIZE || getUint32(dataView, 0) != LOCAL_FILE_HEADER_SIGNATURE) {
5173
+ if (dataArray.length < HEADER_SIZE || getUint32$1(dataView, 0) != LOCAL_FILE_HEADER_SIGNATURE) {
5060
5174
  throw new Error(ERR_LOCAL_FILE_HEADER_NOT_FOUND);
5061
5175
  }
5062
5176
  readCommonHeader(localDirectory, dataView, 4);
@@ -5064,9 +5178,12 @@
5064
5178
  extraFieldLength,
5065
5179
  filenameLength
5066
5180
  } = localDirectory;
5067
- const checkAmbiguity = getStrictness(getOptionValue$1(zipEntry, options, OPTION_STRICTNESS), getOptionValue$1(zipEntry, options, OPTION_CHECK_AMBIGUITY)) == STRICTNESS_STRICT;
5181
+ const checkLocalDirectoryOption = getOptionValue$1(zipEntry, options, OPTION_CHECK_LOCAL_DIRECTORY);
5182
+ const entryStrictness = getStrictness(options, zipEntry.options);
5183
+ const checkLocalDirectory = getCheckLocalDirectory(checkLocalDirectoryOption, entryStrictness);
5184
+ const checkLocalFilename = getCheckLocalFilename(checkLocalDirectoryOption, entryStrictness);
5068
5185
  let rawLocalFilename = EMPTY_UINT8_ARRAY;
5069
- if (checkAmbiguity && (filenameLength || extraFieldLength)) {
5186
+ if (checkLocalFilename && (filenameLength || extraFieldLength)) {
5070
5187
  const trailingDataArray = await readUint8Array(reader, localHeaderOffset + HEADER_SIZE, filenameLength + extraFieldLength);
5071
5188
  rawLocalFilename = trailingDataArray.subarray(0, filenameLength);
5072
5189
  localDirectory.rawExtraField = trailingDataArray.subarray(filenameLength);
@@ -5075,17 +5192,26 @@
5075
5192
  await readUint8Array(reader, localHeaderOffset + HEADER_SIZE + filenameLength, extraFieldLength) :
5076
5193
  EMPTY_UINT8_ARRAY;
5077
5194
  }
5195
+ if (checkLocalFilename) {
5196
+ localDirectory.rawFilename = rawLocalFilename;
5197
+ }
5078
5198
  readCommonFooter(zipEntry, localDirectory, dataView, 4, true);
5079
- if (checkAmbiguity) {
5080
- checkLocalDirectory(zipEntry, localDirectory, rawLocalFilename);
5199
+ if (checkLocalDirectory) {
5200
+ validateLocalDirectory(zipEntry, localDirectory, rawLocalFilename, checkLocalFilename);
5081
5201
  }
5082
- const { lastAccessDate, creationDate } = localDirectory;
5202
+ const { lastAccessDate, creationDate, uid, gid } = localDirectory;
5083
5203
  if (lastAccessDate) {
5084
5204
  fileEntry.lastAccessDate = lastAccessDate;
5085
5205
  }
5086
5206
  if (creationDate) {
5087
5207
  fileEntry.creationDate = creationDate;
5088
5208
  }
5209
+ if (uid !== UNDEFINED_VALUE && fileEntry.uid === UNDEFINED_VALUE) {
5210
+ fileEntry.uid = uid;
5211
+ }
5212
+ if (gid !== UNDEFINED_VALUE && fileEntry.gid === UNDEFINED_VALUE) {
5213
+ fileEntry.gid = gid;
5214
+ }
5089
5215
  const encrypted = zipEntry.encrypted && localDirectory.encrypted && !passThrough;
5090
5216
  const zipCrypto = encrypted && !extraFieldAES;
5091
5217
  if (!passThrough) {
@@ -5106,9 +5232,12 @@
5106
5232
  }
5107
5233
  }
5108
5234
  const dataOffset = localHeaderOffset + HEADER_SIZE + filenameLength + extraFieldLength;
5235
+ if (dataOffset + compressedSize > reader.size) {
5236
+ throw new Error(ERR_ENTRY_DATA_OUT_OF_BOUNDS);
5237
+ }
5109
5238
  const size = compressedSize;
5110
5239
  const readable = toCompatibleReadable(reader.createReadable({ offset: dataOffset, size }));
5111
- const signal = getOptionValue$1(zipEntry, options, OPTION_SIGNAL);
5240
+ const signal = checkSignalOption(getOptionValue$1(zipEntry, options, OPTION_SIGNAL));
5112
5241
  const checkPasswordOnly = getOptionValue$1(zipEntry, options, OPTION_CHECK_PASSWORD_ONLY);
5113
5242
  let checkOverlappingEntry = getOptionValue$1(zipEntry, options, OPTION_CHECK_OVERLAPPING_ENTRY);
5114
5243
  const checkOverlappingEntryOnly = getOptionValue$1(zipEntry, options, OPTION_CHECK_OVERLAPPING_ENTRY_ONLY);
@@ -5116,6 +5245,8 @@
5116
5245
  checkOverlappingEntry = true;
5117
5246
  }
5118
5247
  const { onstart, onprogress, onend } = options;
5248
+ const compressed = compressionMethod != COMPRESSION_METHOD_STORE && !passThrough;
5249
+ const outputSize = passThrough ? compressedSize : uncompressedSize;
5119
5250
  const deflate64 = compressionMethod == COMPRESSION_METHOD_DEFLATE_64;
5120
5251
  let useCompressionStream = getOptionValue$1(zipEntry, options, OPTION_USE_COMPRESSION_STREAM);
5121
5252
  if (deflate64) {
@@ -5136,9 +5267,9 @@
5136
5267
  checkCrc32,
5137
5268
  checkAuthenticationCode: getOptionValue$1(zipEntry, options, OPTION_CHECK_AUTHENTICATION_CODE),
5138
5269
  passwordVerification: zipCrypto && (dataDescriptor ? ((rawLastModDate >>> 8) & MAX_8_BITS) : ((crc32 >>> 24) & MAX_8_BITS)),
5139
- outputSize: passThrough ? compressedSize : uncompressedSize,
5270
+ outputSize,
5140
5271
  crc32,
5141
- compressed: compressionMethod != 0 && !passThrough,
5272
+ compressed,
5142
5273
  encrypted,
5143
5274
  useWebWorkers: getOptionValue$1(zipEntry, options, OPTION_USE_WEB_WORKERS),
5144
5275
  useCompressionStream,
@@ -5175,11 +5306,11 @@
5175
5306
  writer = new WritableStream();
5176
5307
  }
5177
5308
  writer = new GenericWriter(writer);
5178
- await initStream(writer, passThrough ? compressedSize : uncompressedSize);
5309
+ await initStream(writer, getDecodableOutputSize(outputSize, compressedSize, compressed));
5179
5310
  ({ writable } = writer);
5180
- const { outputSize } = await runWorker({ readable, writable }, workerOptions);
5181
- writer.size += outputSize;
5182
- if (outputSize != (passThrough ? compressedSize : uncompressedSize)) {
5311
+ const { outputSize: writtenSize } = await runWorker({ readable, writable }, workerOptions);
5312
+ writer.size += writtenSize;
5313
+ if (writtenSize != outputSize) {
5183
5314
  throw new Error(ERR_INVALID_UNCOMPRESSED_SIZE);
5184
5315
  }
5185
5316
  }
@@ -5213,7 +5344,7 @@
5213
5344
  function detectEncryptedCentralDirectory(directoryView) {
5214
5345
  const maxOffset = Math.min(directoryView.byteLength, 1024) - 3;
5215
5346
  for (let offset = 0; offset < maxOffset; offset++) {
5216
- if (getUint32(directoryView, offset) == ARCHIVE_EXTRA_DATA_SIGNATURE) {
5347
+ if (getUint32$1(directoryView, offset) == ARCHIVE_EXTRA_DATA_SIGNATURE) {
5217
5348
  return true;
5218
5349
  }
5219
5350
  }
@@ -5224,15 +5355,15 @@
5224
5355
  const directoryEncryptionInfo = { rawExtensibleData };
5225
5356
  if (rawExtensibleData.length >= 28) {
5226
5357
  const extensibleDataView = getDataView(rawExtensibleData);
5227
- const hashDataLength = getUint16(extensibleDataView, 26);
5358
+ const hashDataLength = getUint16$1(extensibleDataView, 26);
5228
5359
  Object.assign(directoryEncryptionInfo, {
5229
- compressionMethod: getUint16(extensibleDataView, 0),
5360
+ compressionMethod: getUint16$1(extensibleDataView, 0),
5230
5361
  compressedSize: Number(getBigUint64(extensibleDataView, 2)),
5231
5362
  uncompressedSize: Number(getBigUint64(extensibleDataView, 10)),
5232
- encryptionAlgorithm: getUint16(extensibleDataView, 18),
5233
- bitLength: getUint16(extensibleDataView, 20),
5234
- flags: getUint16(extensibleDataView, 22),
5235
- hashAlgorithm: getUint16(extensibleDataView, 24),
5363
+ encryptionAlgorithm: getUint16$1(extensibleDataView, 18),
5364
+ bitLength: getUint16$1(extensibleDataView, 20),
5365
+ flags: getUint16$1(extensibleDataView, 22),
5366
+ hashAlgorithm: getUint16$1(extensibleDataView, 24),
5236
5367
  hashData: rawExtensibleData.subarray(28, 28 + hashDataLength)
5237
5368
  });
5238
5369
  }
@@ -5240,12 +5371,12 @@
5240
5371
  }
5241
5372
 
5242
5373
  function readCommonHeader(directory, dataView, offset) {
5243
- const rawBitFlag = directory.rawBitFlag = getUint16(dataView, offset + 2);
5374
+ const rawBitFlag = directory.rawBitFlag = getUint16$1(dataView, offset + 2);
5244
5375
  const encrypted = (rawBitFlag & BITFLAG_ENCRYPTED) == BITFLAG_ENCRYPTED;
5245
- const rawLastModDate = getUint32(dataView, offset + 6);
5376
+ const rawLastModDate = getUint32$1(dataView, offset + 6);
5246
5377
  Object.assign(directory, {
5247
5378
  encrypted,
5248
- version: getUint16(dataView, offset),
5379
+ version: getUint16$1(dataView, offset),
5249
5380
  bitFlag: {
5250
5381
  level: (rawBitFlag & BITFLAG_LEVEL) >> 1,
5251
5382
  dataDescriptor: (rawBitFlag & BITFLAG_DATA_DESCRIPTOR) == BITFLAG_DATA_DESCRIPTOR,
@@ -5253,8 +5384,8 @@
5253
5384
  },
5254
5385
  rawLastModDate,
5255
5386
  lastModDate: getDate(rawLastModDate),
5256
- filenameLength: getUint16(dataView, offset + 22),
5257
- extraFieldLength: getUint16(dataView, offset + 24)
5387
+ filenameLength: getUint16$1(dataView, offset + 22),
5388
+ extraFieldLength: getUint16$1(dataView, offset + 24)
5258
5389
  });
5259
5390
  }
5260
5391
 
@@ -5265,8 +5396,8 @@
5265
5396
  let offsetExtraField = 0;
5266
5397
  try {
5267
5398
  while (offsetExtraField < rawExtraField.length) {
5268
- const type = getUint16(rawExtraFieldView, offsetExtraField);
5269
- const size = getUint16(rawExtraFieldView, offsetExtraField + 2);
5399
+ const type = getUint16$1(rawExtraFieldView, offsetExtraField);
5400
+ const size = getUint16$1(rawExtraFieldView, offsetExtraField + 2);
5270
5401
  extraField.set(type, {
5271
5402
  type,
5272
5403
  data: rawExtraField.slice(offsetExtraField + 4, offsetExtraField + 4 + size)
@@ -5276,12 +5407,12 @@
5276
5407
  } catch {
5277
5408
  // ignored
5278
5409
  }
5279
- const compressionMethod = getUint16(dataView, offset + 4);
5410
+ const compressionMethod = getUint16$1(dataView, offset + 4);
5280
5411
  Object.assign(directory, {
5281
- signature: getUint32(dataView, offset + HEADER_OFFSET_SIGNATURE),
5282
- crc32: getUint32(dataView, offset + HEADER_OFFSET_SIGNATURE),
5283
- compressedSize: getUint32(dataView, offset + HEADER_OFFSET_COMPRESSED_SIZE),
5284
- uncompressedSize: getUint32(dataView, offset + HEADER_OFFSET_UNCOMPRESSED_SIZE)
5412
+ signature: getUint32$1(dataView, offset + HEADER_OFFSET_SIGNATURE),
5413
+ crc32: getUint32$1(dataView, offset + HEADER_OFFSET_SIGNATURE),
5414
+ compressedSize: getUint32$1(dataView, offset + HEADER_OFFSET_COMPRESSED_SIZE),
5415
+ uncompressedSize: getUint32$1(dataView, offset + HEADER_OFFSET_UNCOMPRESSED_SIZE)
5285
5416
  });
5286
5417
  const extraFieldZip64 = extraField.get(EXTRAFIELD_TYPE_ZIP64);
5287
5418
  if (extraFieldZip64) {
@@ -5321,10 +5452,12 @@
5321
5452
  directory.extraFieldNTFS = extraFieldNTFS;
5322
5453
  }
5323
5454
  const extraFieldUnix = extraField.get(EXTRAFIELD_TYPE_UNIX);
5455
+ let unixIdsRead;
5324
5456
  if (extraFieldUnix) {
5325
- readExtraFieldUnix(extraFieldUnix, directory, false);
5457
+ unixIdsRead = readExtraFieldUnix(extraFieldUnix, directory, false);
5326
5458
  directory.extraFieldUnix = extraFieldUnix;
5327
- } else {
5459
+ }
5460
+ if (!unixIdsRead) {
5328
5461
  const extraFieldInfoZip = extraField.get(EXTRAFIELD_TYPE_INFOZIP);
5329
5462
  if (extraFieldInfoZip) {
5330
5463
  readExtraFieldUnix(extraFieldInfoZip, directory, true);
@@ -5368,11 +5501,11 @@
5368
5501
  computedCrc32.append(fileEntry[rawPropertyName]);
5369
5502
  const computedCrc32View = getDataView(new Uint8Array(4));
5370
5503
  computedCrc32View.setUint32(0, computedCrc32.get(), true);
5371
- const nameCrc32 = getUint32(extraFieldView, 1);
5504
+ const nameCrc32 = getUint32$1(extraFieldView, 1);
5372
5505
  Object.assign(extraFieldUnicode, {
5373
5506
  version: getUint8(extraFieldView, 0),
5374
5507
  [propertyName]: decodeText(extraFieldUnicode.data.subarray(5)),
5375
- valid: !fileEntry.bitFlag.languageEncodingFlag && nameCrc32 == getUint32(computedCrc32View, 0)
5508
+ valid: !fileEntry.bitFlag.languageEncodingFlag && nameCrc32 == getUint32$1(computedCrc32View, 0)
5376
5509
  });
5377
5510
  if (extraFieldUnicode.valid) {
5378
5511
  directory[propertyName] = extraFieldUnicode[propertyName];
@@ -5388,7 +5521,7 @@
5388
5521
  vendorId: getUint8(extraFieldView, 2),
5389
5522
  strength,
5390
5523
  originalCompressionMethod: compressionMethod,
5391
- compressionMethod: getUint16(extraFieldView, 5)
5524
+ compressionMethod: getUint16$1(extraFieldView, 5)
5392
5525
  });
5393
5526
  directory.compressionMethod = extraFieldAES.compressionMethod;
5394
5527
  if (extraFieldAES.vendorVersion != VENDOR_VERSION_AE_1$1) {
@@ -5402,8 +5535,8 @@
5402
5535
  let tag1Data;
5403
5536
  try {
5404
5537
  while (offsetExtraField < extraFieldNTFS.data.length && !tag1Data) {
5405
- const tagValue = getUint16(extraFieldView, offsetExtraField);
5406
- const attributeSize = getUint16(extraFieldView, offsetExtraField + 2);
5538
+ const tagValue = getUint16$1(extraFieldView, offsetExtraField);
5539
+ const attributeSize = getUint16$1(extraFieldView, offsetExtraField + 2);
5407
5540
  if (tagValue == EXTRAFIELD_TYPE_NTFS_TAG1) {
5408
5541
  tag1Data = extraFieldNTFS.data.slice(offsetExtraField + 4, offsetExtraField + 4 + attributeSize);
5409
5542
  }
@@ -5427,7 +5560,7 @@
5427
5560
  const creationDate = getDateNTFS(rawCreationDate);
5428
5561
  const extraFieldData = { lastModDate, lastAccessDate, creationDate };
5429
5562
  Object.assign(extraFieldNTFS, extraFieldData);
5430
- Object.assign(directory, extraFieldData);
5563
+ Object.assign(directory, extraFieldData, { rawLastAccessDate, rawCreationDate });
5431
5564
  }
5432
5565
  }
5433
5566
 
@@ -5436,12 +5569,12 @@
5436
5569
  return;
5437
5570
  }
5438
5571
  const extraFieldView = getDataView(extraField.data);
5439
- const lastAccessDate = new Date((getUint32(extraFieldView, 0) | 0) * 1000);
5440
- const lastModDate = new Date((getUint32(extraFieldView, 4) | 0) * 1000);
5572
+ const lastAccessDate = new Date((getUint32$1(extraFieldView, 0) | 0) * 1000);
5573
+ const lastModDate = new Date((getUint32$1(extraFieldView, 4) | 0) * 1000);
5441
5574
  const extraFieldData = { lastAccessDate, lastModDate };
5442
5575
  if (extraField.data.length >= 12) {
5443
- extraFieldData.uid = getUint16(extraFieldView, 8);
5444
- extraFieldData.gid = getUint16(extraFieldView, 10);
5576
+ extraFieldData.uid = getUint16$1(extraFieldView, 8);
5577
+ extraFieldData.gid = getUint16$1(extraFieldView, 10);
5445
5578
  }
5446
5579
  Object.assign(extraField, extraFieldData);
5447
5580
  Object.assign(directory, extraFieldData);
@@ -5461,8 +5594,8 @@
5461
5594
  gid = unpackUnixId(extraField.data.subarray(offset, offset + gidSize));
5462
5595
  Object.assign(extraField, { version, uid, gid });
5463
5596
  } else if (extraField.data.length >= 4) {
5464
- uid = getUint16(view, 0);
5465
- gid = getUint16(view, 2);
5597
+ uid = getUint16$1(view, 0);
5598
+ gid = getUint16$1(view, 2);
5466
5599
  Object.assign(extraField, { uid, gid });
5467
5600
  }
5468
5601
  if (uid !== UNDEFINED_VALUE) {
@@ -5471,6 +5604,7 @@
5471
5604
  if (gid !== UNDEFINED_VALUE) {
5472
5605
  directory.gid = gid;
5473
5606
  }
5607
+ return uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE;
5474
5608
  } catch {
5475
5609
  // ignored
5476
5610
  }
@@ -5511,7 +5645,7 @@
5511
5645
  let offset = 1;
5512
5646
  timeProperties.forEach((propertyName, indexProperty) => {
5513
5647
  if (extraFieldExtendedTimestamp.data.length >= offset + 4) {
5514
- const time = getUint32(extraFieldView, offset);
5648
+ const time = getUint32$1(extraFieldView, offset);
5515
5649
  directory[propertyName] = extraFieldExtendedTimestamp[propertyName] = new Date((time | 0) * 1000);
5516
5650
  const rawPropertyName = timeRawProperties[indexProperty];
5517
5651
  extraFieldExtendedTimestamp[rawPropertyName] = time;
@@ -5543,26 +5677,25 @@
5543
5677
  }
5544
5678
  if (dataDescriptorLength) {
5545
5679
  const dataDescriptorArray = await readUint8Array(reader, dataOffset + compressedSize, dataDescriptorLength + DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH);
5546
- const dataDescriptorSignature = dataDescriptorArray.length == dataDescriptorLength + DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH &&
5547
- getUint32(getDataView(dataDescriptorArray), 0) == DATA_DESCRIPTOR_RECORD_SIGNATURE;
5548
- if (dataDescriptorSignature) {
5549
- const readCrc32 = getUint32(getDataView(dataDescriptorArray), 4);
5550
- let readCompressedSize;
5551
- let readUncompressedSize;
5552
- if (extraFieldZip64) {
5553
- readCompressedSize = getBigUint64(getDataView(dataDescriptorArray), 8);
5554
- readUncompressedSize = getBigUint64(getDataView(dataDescriptorArray), 16);
5555
- } else {
5556
- readCompressedSize = getUint32(getDataView(dataDescriptorArray), 8);
5557
- readUncompressedSize = getUint32(getDataView(dataDescriptorArray), 12);
5558
- }
5559
- const matchCrc32 = (fileEntry.encrypted && !fileEntry.zipCrypto) || readCrc32 == crc32;
5680
+ const dataDescriptorView = getDataView(dataDescriptorArray);
5681
+ let signature = dataDescriptorArray.length == dataDescriptorLength + DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH &&
5682
+ getUint32$1(dataDescriptorView, 0) == DATA_DESCRIPTOR_RECORD_SIGNATURE;
5683
+ if (signature) {
5684
+ const signedDataDescriptor = readDataDescriptor(dataDescriptorView, DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH, extraFieldZip64);
5685
+ const matchCrc32 = (fileEntry.encrypted && !fileEntry.zipCrypto) || signedDataDescriptor.crc32 == crc32;
5560
5686
  if (matchCrc32 &&
5561
- readCompressedSize == compressedSize &&
5562
- readUncompressedSize == uncompressedSize) {
5687
+ signedDataDescriptor.compressedSize == compressedSize &&
5688
+ signedDataDescriptor.uncompressedSize == uncompressedSize) {
5563
5689
  dataDescriptorLength += DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH;
5690
+ } else {
5691
+ signature = false;
5564
5692
  }
5565
5693
  }
5694
+ if (dataDescriptorArray.length >= dataDescriptorLength) {
5695
+ const localDataDescriptor = readDataDescriptor(dataDescriptorView, signature ? DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH : 0, extraFieldZip64);
5696
+ localDataDescriptor.signature = signature;
5697
+ fileEntry.localDirectory.dataDescriptor = localDataDescriptor;
5698
+ }
5566
5699
  }
5567
5700
  const range = {
5568
5701
  start: offset,
@@ -5579,22 +5712,80 @@
5579
5712
  readRanges.set(index, range);
5580
5713
  }
5581
5714
 
5715
+ function readDataDescriptor(dataDescriptorView, offset, extraFieldZip64) {
5716
+ const crc32 = getUint32$1(dataDescriptorView, offset);
5717
+ let compressedSize;
5718
+ let uncompressedSize;
5719
+ if (extraFieldZip64) {
5720
+ compressedSize = getBigUint64(dataDescriptorView, offset + 4);
5721
+ uncompressedSize = getBigUint64(dataDescriptorView, offset + 12);
5722
+ } else {
5723
+ compressedSize = getUint32$1(dataDescriptorView, offset + 4);
5724
+ uncompressedSize = getUint32$1(dataDescriptorView, offset + 8);
5725
+ }
5726
+ return { crc32, compressedSize, uncompressedSize };
5727
+ }
5728
+
5582
5729
  function getDiskOffset$1(reader, diskNumber) {
5583
5730
  return reader.getDiskOffset ? reader.getDiskOffset(diskNumber) : 0;
5584
5731
  }
5585
5732
 
5733
+ async function startsWithSplitZipSignature$1(reader) {
5734
+ return await getFirstSignature(reader) == SPLIT_ZIP_FILE_SIGNATURE;
5735
+ }
5736
+
5737
+ async function startsWithSplitZipMarker(reader) {
5738
+ const signature = await getFirstSignature(reader);
5739
+ return signature == SPLIT_ZIP_FILE_SIGNATURE || signature == TEMPORARY_SPLIT_ZIP_FILE_SIGNATURE;
5740
+ }
5741
+
5742
+ async function getFirstSignature(reader) {
5743
+ const signatureArray = await readUint8Array(reader, 0, SPLIT_ZIP_FILE_SIGNATURE_LENGTH);
5744
+ return getUint32$1(getDataView(signatureArray));
5745
+ }
5746
+
5586
5747
  function isStrictnessValue(value) {
5587
5748
  return value === STRICTNESS_STRICT || value === STRICTNESS_BALANCED || value === STRICTNESS_TOLERANT;
5588
5749
  }
5589
5750
 
5590
- function getStrictness(strictness, checkAmbiguity) {
5591
- if (strictness === UNDEFINED_VALUE) {
5592
- return checkAmbiguity ? STRICTNESS_STRICT : STRICTNESS_BALANCED;
5751
+ function getDecodableOutputSize(outputSize, compressedSize, compressed) {
5752
+ return Math.min(outputSize, compressed ? compressedSize * MAX_DEFLATE_EXPANSION_RATIO : compressedSize);
5753
+ }
5754
+
5755
+ function getStrictness(options, inheritedOptions) {
5756
+ return resolveStrictness(options, resolveStrictness(inheritedOptions, STRICTNESS_BALANCED));
5757
+ }
5758
+
5759
+ function resolveStrictness(options, inheritedStrictness) {
5760
+ const strictness = options[OPTION_STRICTNESS];
5761
+ if (strictness !== UNDEFINED_VALUE) {
5762
+ if (!isStrictnessValue(strictness)) {
5763
+ throw new Error(ERR_INVALID_STRICTNESS);
5764
+ }
5765
+ return strictness;
5766
+ }
5767
+ const checkAmbiguity = options[OPTION_CHECK_AMBIGUITY];
5768
+ if (checkAmbiguity === UNDEFINED_VALUE) {
5769
+ return inheritedStrictness;
5770
+ }
5771
+ if (checkAmbiguity) {
5772
+ return STRICTNESS_STRICT;
5773
+ }
5774
+ return inheritedStrictness == STRICTNESS_TOLERANT ? STRICTNESS_TOLERANT : STRICTNESS_BALANCED;
5775
+ }
5776
+
5777
+ function getCheckLocalDirectory(checkLocalDirectory, strictness) {
5778
+ if (checkLocalDirectory === UNDEFINED_VALUE) {
5779
+ return strictness != STRICTNESS_TOLERANT;
5593
5780
  }
5594
- if (!isStrictnessValue(strictness)) {
5595
- throw new Error(ERR_INVALID_STRICTNESS);
5781
+ return Boolean(checkLocalDirectory);
5782
+ }
5783
+
5784
+ function getCheckLocalFilename(checkLocalFilename, strictness) {
5785
+ if (checkLocalFilename === UNDEFINED_VALUE) {
5786
+ return strictness == STRICTNESS_STRICT;
5596
5787
  }
5597
- return strictness;
5788
+ return Boolean(checkLocalFilename);
5598
5789
  }
5599
5790
 
5600
5791
  function getFilenameValidation(filenameValidation, strictness) {
@@ -5623,7 +5814,7 @@
5623
5814
 
5624
5815
  function getMaxAppendedDataSize(maxAppendedDataSize, strictness) {
5625
5816
  if (maxAppendedDataSize !== UNDEFINED_VALUE) {
5626
- const size = toNumber$1(maxAppendedDataSize);
5817
+ const size = toNumber(maxAppendedDataSize);
5627
5818
  if (typeof size != NUMBER_TYPE || Number.isNaN(size) || size < 0) {
5628
5819
  throw new Error(ERR_INVALID_MAX_APPENDED_DATA_SIZE);
5629
5820
  }
@@ -5646,7 +5837,7 @@
5646
5837
  let plausibleEndOfDirectoryInfo;
5647
5838
  let endOfDirectoryReachingEndCount = 0;
5648
5839
  for await (const [anchoredView, anchoredOffset, anchoredArray, indexByte, offset] of scanEndOfCentralDirectory(reader, anchoredLength)) {
5649
- const commentLength = getUint16(anchoredView, indexByte + 20);
5840
+ const commentLength = getUint16$1(anchoredView, indexByte + 20);
5650
5841
  if (offset + END_OF_CENTRAL_DIR_LENGTH + commentLength == size) {
5651
5842
  const reachability = await getCentralDirectoryReachability(reader, anchoredView, anchoredOffset, indexByte, offset, size, remoteProbeBudget);
5652
5843
  if (reachability == CENTRAL_DIRECTORY_REACHABLE) {
@@ -5697,7 +5888,7 @@
5697
5888
  const scanArray = await readUint8Array(reader, scanOffset, scanLength);
5698
5889
  const scanView = getDataView(scanArray);
5699
5890
  for (let indexByte = scanArray.length - END_OF_CENTRAL_DIR_LENGTH; indexByte >= 0; indexByte--) {
5700
- if (getUint32(scanView, indexByte) == END_OF_CENTRAL_DIR_SIGNATURE) {
5891
+ if (getUint32$1(scanView, indexByte) == END_OF_CENTRAL_DIR_SIGNATURE) {
5701
5892
  yield [scanView, scanOffset, scanArray, indexByte, scanOffset + indexByte];
5702
5893
  }
5703
5894
  }
@@ -5708,9 +5899,9 @@
5708
5899
  }
5709
5900
 
5710
5901
  async function getCentralDirectoryReachability(reader, view, anchoredOffset, indexByte, offset, size, remoteProbeBudget) {
5711
- const filesLength = getUint16(view, indexByte + 10);
5712
- const directoryDataLength = getUint32(view, indexByte + 12);
5713
- const directoryDataOffset = getUint32(view, indexByte + 16);
5902
+ const filesLength = getUint16$1(view, indexByte + 10);
5903
+ const directoryDataLength = getUint32$1(view, indexByte + 12);
5904
+ const directoryDataOffset = getUint32$1(view, indexByte + 16);
5714
5905
  if (filesLength == MAX_16_BITS || directoryDataLength == MAX_32_BITS || directoryDataOffset == MAX_32_BITS) {
5715
5906
  const locatorSignature = await readSignature(reader, view, anchoredOffset, offset - ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH, size, remoteProbeBudget);
5716
5907
  return locatorSignature == ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE ? CENTRAL_DIRECTORY_REACHABLE : CENTRAL_DIRECTORY_UNREACHABLE;
@@ -5718,7 +5909,7 @@
5718
5909
  if (!filesLength && !directoryDataLength) {
5719
5910
  return CENTRAL_DIRECTORY_PLAUSIBLE;
5720
5911
  }
5721
- const directoryDiskNumber = getUint16(view, indexByte + 6);
5912
+ const directoryDiskNumber = getUint16$1(view, indexByte + 6);
5722
5913
  for (const centralDirectoryOffset of [offset - directoryDataLength, getDiskOffset$1(reader, directoryDiskNumber) + directoryDataOffset]) {
5723
5914
  if (await readSignature(reader, view, anchoredOffset, centralDirectoryOffset, size, remoteProbeBudget) == CENTRAL_FILE_HEADER_SIGNATURE) {
5724
5915
  return CENTRAL_DIRECTORY_REACHABLE;
@@ -5732,20 +5923,21 @@
5732
5923
  return UNDEFINED_VALUE;
5733
5924
  }
5734
5925
  if (signatureOffset >= anchoredOffset) {
5735
- return getUint32(view, signatureOffset - anchoredOffset);
5926
+ return getUint32$1(view, signatureOffset - anchoredOffset);
5736
5927
  }
5737
5928
  if (remoteProbeBudget.count > 0) {
5738
5929
  remoteProbeBudget.count--;
5739
5930
  const signatureArray = await readUint8Array(reader, signatureOffset, 4);
5740
- return getUint32(getDataView(signatureArray), 0);
5931
+ return getUint32$1(getDataView(signatureArray), 0);
5741
5932
  }
5742
5933
  return UNDEFINED_VALUE;
5743
5934
  }
5744
5935
 
5745
- function checkLocalDirectory(zipEntry, localDirectory, rawLocalFilename) {
5936
+ function validateLocalDirectory(zipEntry, localDirectory, rawLocalFilename, checkLocalFilename) {
5746
5937
  const { rawFilename } = zipEntry;
5747
- if (rawLocalFilename.length != rawFilename.length ||
5748
- rawLocalFilename.some((byteValue, indexByte) => byteValue != rawFilename[indexByte])) {
5938
+ if (checkLocalFilename &&
5939
+ (rawLocalFilename.length != rawFilename.length ||
5940
+ rawLocalFilename.some((byteValue, indexByte) => byteValue != rawFilename[indexByte]))) {
5749
5941
  throwAmbiguousArchive("mismatched local file header (filename)");
5750
5942
  }
5751
5943
  if ((localDirectory.rawBitFlag & BITFLAG_AMBIGUITY_MASK) != (zipEntry.rawBitFlag & BITFLAG_AMBIGUITY_MASK)) {
@@ -5773,10 +5965,11 @@
5773
5965
  return options[name] === UNDEFINED_VALUE ? zipReader.options[name] : options[name];
5774
5966
  }
5775
5967
 
5776
- function toNumber$1(value) {
5777
- return typeof value == STRING_TYPE && value.trim() ? Number(value) : value;
5968
+ function getFunctionOptionValue$1(zipReader, options, name) {
5969
+ return checkFunctionOption(getOptionValue$1(zipReader, options, name));
5778
5970
  }
5779
5971
 
5972
+
5780
5973
  function getDate(timeRaw) {
5781
5974
  const date = (timeRaw & 0xffff0000) >> 16, time = timeRaw & MAX_16_BITS;
5782
5975
  return new Date(1980 + ((date & 0xFE00) >> 9), ((date & 0x01E0) >> 5) - 1, date & 0x001F, (time & 0xF800) >> 11, (time & 0x07E0) >> 5, (time & 0x001F) * 2, 0);
@@ -5790,11 +5983,11 @@
5790
5983
  return view.getUint8(offset);
5791
5984
  }
5792
5985
 
5793
- function getUint16(view, offset) {
5986
+ function getUint16$1(view, offset) {
5794
5987
  return view.getUint16(offset, true);
5795
5988
  }
5796
5989
 
5797
- function getUint32(view, offset) {
5990
+ function getUint32$1(view, offset) {
5798
5991
  return view.getUint32(offset, true);
5799
5992
  }
5800
5993
 
@@ -5809,6 +6002,7 @@
5809
6002
  ERR_CENTRAL_DIRECTORY_NOT_FOUND: ERR_CENTRAL_DIRECTORY_NOT_FOUND,
5810
6003
  ERR_ENCRYPTED: ERR_ENCRYPTED,
5811
6004
  ERR_ENCRYPTED_CENTRAL_DIRECTORY: ERR_ENCRYPTED_CENTRAL_DIRECTORY,
6005
+ ERR_ENTRY_DATA_OUT_OF_BOUNDS: ERR_ENTRY_DATA_OUT_OF_BOUNDS,
5812
6006
  ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND: ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND,
5813
6007
  ERR_EOCDR_NOT_FOUND: ERR_EOCDR_NOT_FOUND,
5814
6008
  ERR_EXTRAFIELD_ZIP64_NOT_FOUND: ERR_EXTRAFIELD_ZIP64_NOT_FOUND,
@@ -5863,13 +6057,18 @@
5863
6057
 
5864
6058
  const ERR_DUPLICATED_NAME = "File already exists";
5865
6059
  const ERR_INVALID_COMMENT = "Zip file comment exceeds 64KB";
6060
+ const ERR_INVALID_COMMENT_TYPE = "Invalid zip file comment (must be a Uint8Array)";
5866
6061
  const ERR_INVALID_ENTRY_COMMENT = "File entry comment exceeds 64KB";
6062
+ const ERR_INVALID_ENTRY_COMMENT_TYPE = "Invalid file entry comment (must be a string)";
6063
+ const ERR_INVALID_DATE = "Invalid date (must be a valid Date instance)";
5867
6064
  const ERR_INVALID_ENTRY_NAME = "File entry name exceeds 64KB";
5868
6065
  const ERR_INVALID_VERSION = "Version exceeds 65535";
5869
6066
  const ERR_INVALID_ENCRYPTION_STRENGTH = "The strength must equal 1, 2, or 3";
5870
6067
  const ERR_UNSUPPORTED_ENCRYPTION_USDZ = "Encryption is not supported in USDZ files";
5871
6068
  const ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH = "Encryption is not supported when the 'passThrough' option is set";
5872
- const ERR_INVALID_EXTRAFIELD_TYPE = "Extra field type exceeds 65535";
6069
+ const ERR_INVALID_EXTRAFIELD = "Invalid extra field (must be a Map)";
6070
+ const ERR_INVALID_EXTRAFIELD_TYPE = "Invalid extra field type (must be integer 0..65535)";
6071
+ const ERR_INVALID_EXTRAFIELD_DATA_TYPE = "Invalid extra field data (must be a Uint8Array)";
5873
6072
  const ERR_INVALID_EXTRAFIELD_DATA = "Extra field data exceeds 64KB";
5874
6073
  const ERR_UNSUPPORTED_COMPRESSION = "Compression method not supported";
5875
6074
  const MIN_UNIX_TIME = -2147483648;
@@ -5889,7 +6088,6 @@
5889
6088
  const ERR_INVALID_MSDOS_ATTRIBUTES = "Invalid msdosAttributesRaw (must be integer 0..255)";
5890
6089
  const ERR_INVALID_MSDOS_DATA = "Invalid msdosAttributes (must be an object with boolean flags)";
5891
6090
  const ERR_INVALID_LEVEL = "Invalid level (must be integer 0..9)";
5892
- const ERR_INVALID_PASSWORD_TYPE = "Invalid password (password must be a string, rawPassword must be a Uint8Array)";
5893
6091
  const ERR_INVALID_SIGNATURE_DATA = "Signature data exceeds 64KB";
5894
6092
 
5895
6093
  const EXTRAFIELD_DATA_AES = new Uint8Array([0x07, 0x00, 0x02, 0x00, 0x41, 0x45, 0x03, 0x00, 0x00]);
@@ -5914,8 +6112,7 @@
5914
6112
  writer,
5915
6113
  addSplitZipSignature,
5916
6114
  options,
5917
- config: getConfiguration(),
5918
- files: new Map(),
6115
+ fileEntries: new Map(),
5919
6116
  filenames: new Set(),
5920
6117
  offset: options[OPTION_OFFSET] === UNDEFINED_VALUE ? writer.size || writer.writable.size || 0 : options[OPTION_OFFSET],
5921
6118
  initialOffset: options[OPTION_OFFSET] === UNDEFINED_VALUE ? 0 : options[OPTION_OFFSET] - (writer.size || writer.writable.size || 0),
@@ -5931,15 +6128,28 @@
5931
6128
  }
5932
6129
  reader = new GenericReader(reader);
5933
6130
  await initStream(reader);
6131
+ if (reader.size === UNDEFINED_VALUE || !reader.readUint8Array) {
6132
+ reader = new BlobReader(await streamToBlob(reader.readable));
6133
+ await initStream(reader);
6134
+ }
5934
6135
  const { ZipReader } = await Promise.resolve().then(function () { return zipReader; });
5935
- const zipReader$1 = new ZipReader(reader.readable);
6136
+ const zipReader$1 = new ZipReader(reader);
5936
6137
  const entries = await zipReader$1.getEntries();
5937
6138
  await zipReader$1.close();
5938
6139
  await initStream(this.writer);
5939
- await reader.readable.pipeTo(this.writer.writable, { preventClose: true, preventAbort: true });
5940
- this.writer.size = this.offset = reader.size;
6140
+ const { directoryOffset } = zipReader$1;
6141
+ let splitZipSignatureLength = 0;
6142
+ if (this.addSplitZipSignature) {
6143
+ delete this.addSplitZipSignature;
6144
+ if (!await startsWithSplitZipSignature(reader)) {
6145
+ await writeData(this.writer, getSplitZipSignatureArray());
6146
+ splitZipSignatureLength = SPLIT_ZIP_FILE_SIGNATURE_LENGTH;
6147
+ this.offset += splitZipSignatureLength;
6148
+ }
6149
+ }
6150
+ const entryPositions = await copyZipData(this, reader, entries, directoryOffset, splitZipSignatureLength);
5941
6151
  this.filenames = new Set(entries.map(entry => entry.filename));
5942
- this.files = new Map(entries.map(entry => {
6152
+ this.fileEntries = new Map(entries.map(entry => {
5943
6153
  const {
5944
6154
  version,
5945
6155
  rawLastModDate,
@@ -5994,11 +6204,12 @@
5994
6204
  if (crc32 !== UNDEFINED_VALUE) {
5995
6205
  setUint32(headerView, HEADER_OFFSET_SIGNATURE, crc32);
5996
6206
  }
6207
+ const { offset, diskNumberStart } = entryPositions.get(entry);
5997
6208
  Object.assign(entry, {
5998
6209
  zip64UncompressedSize,
5999
6210
  zip64CompressedSize,
6000
- zip64Offset: zip64 && entry.offset >= MAX_32_BITS,
6001
- diskNumberStart: 0,
6211
+ offset,
6212
+ diskNumberStart,
6002
6213
  zip64DiskNumberStart: false,
6003
6214
  rawExtraFieldZip64,
6004
6215
  rawExtraFieldAES,
@@ -6018,11 +6229,8 @@
6018
6229
  async add(name = "", reader, options = {}) {
6019
6230
  const zipWriter = this;
6020
6231
  options = Object.assign({}, options);
6021
- const {
6022
- pendingAddFileCalls,
6023
- config
6024
- } = zipWriter;
6025
- if (workers < config.maxWorkers) {
6232
+ const { pendingAddFileCalls } = zipWriter;
6233
+ if (workers < getConfiguration().maxWorkers) {
6026
6234
  workers++;
6027
6235
  } else {
6028
6236
  await new Promise(resolve => pendingEntries.push(resolve));
@@ -6059,16 +6267,16 @@
6059
6267
  }
6060
6268
 
6061
6269
  remove(entry) {
6062
- const { filenames, files } = this;
6270
+ const { filenames, fileEntries } = this;
6063
6271
  // deno-lint-ignore valid-typeof
6064
6272
  if (typeof entry == STRING_TYPE) {
6065
- entry = files.get(entry);
6273
+ entry = fileEntries.get(entry);
6066
6274
  }
6067
6275
  if (entry && entry.filename !== UNDEFINED_VALUE) {
6068
6276
  const { filename } = entry;
6069
- if (filenames.has(filename) && files.has(filename)) {
6277
+ if (filenames.has(filename) && fileEntries.has(filename)) {
6070
6278
  filenames.delete(filename);
6071
- files.delete(filename);
6279
+ fileEntries.delete(filename);
6072
6280
  return true;
6073
6281
  }
6074
6282
  }
@@ -6079,6 +6287,9 @@
6079
6287
  const zipWriter = this;
6080
6288
  const { pendingAddFileCalls, writer } = this;
6081
6289
  const { writable } = writer;
6290
+ if (!(comment instanceof Uint8Array)) {
6291
+ throw new Error(ERR_INVALID_COMMENT_TYPE);
6292
+ }
6082
6293
  if (getLength(comment) > MAX_16_BITS) {
6083
6294
  throw new Error(ERR_INVALID_COMMENT);
6084
6295
  }
@@ -6162,12 +6373,12 @@
6162
6373
  const metadataInfo = resolveMetadata(zipWriter, name, options);
6163
6374
  const { comment } = metadataInfo;
6164
6375
  const extraField = options[PROPERTY_NAME_EXTRA_FIELD];
6165
- zipWriter.files.set(name, UNDEFINED_VALUE);
6376
+ zipWriter.fileEntries.set(name, UNDEFINED_VALUE);
6166
6377
  let fileEntry;
6167
6378
  try {
6168
6379
  const { resolvedOptions } = metadataInfo;
6169
6380
  if (resolvedOptions.level != 0 && resolvedOptions.compressionMethod === UNDEFINED_VALUE &&
6170
- !resolvedOptions.passThrough && !(await supportsDeflate(zipWriter.config))) {
6381
+ !resolvedOptions.passThrough && !(await supportsDeflate(getConfiguration()))) {
6171
6382
  resolvedOptions.level = 0;
6172
6383
  }
6173
6384
  const sizesInfo = await resolveSizes(zipWriter, reader, metadataInfo, options);
@@ -6175,8 +6386,6 @@
6175
6386
  const diskOffset = getDiskOffset(zipWriter.writer);
6176
6387
  const diskNumber = getDiskNumber(zipWriter.writer);
6177
6388
  options = Object.assign({}, options, attributesInfo.resolvedOptions, metadataInfo.resolvedOptions, sizesInfo.resolvedOptions, {
6178
- internalFileAttribute: metadataInfo.resolvedOptions.internalFileAttributes,
6179
- externalFileAttribute: attributesInfo.resolvedOptions.externalFileAttributes,
6180
6389
  signature: options[PROPERTY_NAME_SIGNATURE],
6181
6390
  crc32: options.crc32 === UNDEFINED_VALUE ? options[PROPERTY_NAME_SIGNATURE] : options.crc32,
6182
6391
  offset: zipWriter.offset - diskOffset,
@@ -6187,17 +6396,23 @@
6187
6396
  const metadataSize = getLength(headerInfo.localHeaderArray, dataDescriptorInfo.dataDescriptorArray);
6188
6397
  fileEntry = await getFileEntry(zipWriter, name, reader, { headerInfo, dataDescriptorInfo, metadataSize }, options);
6189
6398
  } catch (error) {
6190
- zipWriter.files.delete(name);
6399
+ zipWriter.fileEntries.delete(name);
6191
6400
  throw error;
6192
6401
  }
6193
- Object.assign(fileEntry, { name, comment, extraField });
6402
+ Object.assign(fileEntry, {
6403
+ name,
6404
+ comment,
6405
+ extraField,
6406
+ [PROPERTY_NAME_DEPRECATED_INTERNAL_FILE_ATTRIBUTES]: fileEntry.internalFileAttributes,
6407
+ [PROPERTY_NAME_DEPRECATED_EXTERNAL_FILE_ATTRIBUTES]: fileEntry.externalFileAttributes
6408
+ });
6194
6409
  return new Entry(fileEntry);
6195
6410
  }
6196
6411
 
6197
6412
  function resolveAttributes(zipWriter, name, options) {
6198
6413
  name = name.trim();
6199
6414
  let msDosCompatible = getOptionValue(zipWriter, options, PROPERTY_NAME_MS_DOS_COMPATIBLE);
6200
- let versionMadeBy = getOptionValue(zipWriter, options, PROPERTY_NAME_VERSION_MADE_BY, msDosCompatible ? 20 : 768);
6415
+ let versionMadeBy = getOptionValue(zipWriter, options, PROPERTY_NAME_VERSION_MADE_BY, msDosCompatible ? VERSION_MADE_BY_MSDOS : VERSION_MADE_BY_UNIX);
6201
6416
  const executable = getOptionValue(zipWriter, options, PROPERTY_NAME_EXECUTABLE);
6202
6417
  const uid = getNumberOptionValue(zipWriter, options, PROPERTY_NAME_UID);
6203
6418
  const gid = getNumberOptionValue(zipWriter, options, PROPERTY_NAME_GID);
@@ -6225,21 +6440,21 @@
6225
6440
  if (unixExtraFieldType === UNDEFINED_VALUE && (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE)) {
6226
6441
  unixExtraFieldType = INFOZIP_EXTRA_FIELD_TYPE;
6227
6442
  }
6228
- let msdosAttributesRaw = getOptionValue(zipWriter, options, PROPERTY_NAME_MSDOS_ATTRIBUTES_RAW);
6443
+ let msdosAttributesRaw = getNumberOptionValue(zipWriter, options, PROPERTY_NAME_MSDOS_ATTRIBUTES_RAW);
6229
6444
  let msdosAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_MSDOS_ATTRIBUTES);
6230
- const hasUnixMetadata = uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE || unixMode !== UNDEFINED_VALUE || unixExtraFieldType;
6445
+ const hasUnixMetadata = uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE || unixMode !== UNDEFINED_VALUE || unixExtraFieldType || executable;
6231
6446
  const hasMsDosProvided = msdosAttributesRaw !== UNDEFINED_VALUE || msdosAttributes !== UNDEFINED_VALUE;
6232
6447
  if (hasUnixMetadata) {
6233
6448
  msDosCompatible = false;
6234
- versionMadeBy = (versionMadeBy & MAX_16_BITS) | (3 << 8);
6449
+ versionMadeBy = (versionMadeBy & MAX_8_BITS) | VERSION_MADE_BY_UNIX;
6235
6450
  } else if (hasMsDosProvided) {
6236
6451
  msDosCompatible = true;
6237
6452
  versionMadeBy = (versionMadeBy & MAX_8_BITS);
6238
6453
  }
6239
- if (msdosAttributesRaw !== UNDEFINED_VALUE && (msdosAttributesRaw < 0 || msdosAttributesRaw > MAX_8_BITS)) {
6454
+ if (msdosAttributesRaw !== UNDEFINED_VALUE && (!Number.isInteger(msdosAttributesRaw) || msdosAttributesRaw < 0 || msdosAttributesRaw > MAX_8_BITS)) {
6240
6455
  throw new Error(ERR_INVALID_MSDOS_ATTRIBUTES);
6241
6456
  }
6242
- if (msdosAttributes && typeof msdosAttributes !== OBJECT_TYPE) {
6457
+ if (msdosAttributes && (typeof msdosAttributes !== OBJECT_TYPE || Array.isArray(msdosAttributes))) {
6243
6458
  throw new Error(ERR_INVALID_MSDOS_DATA);
6244
6459
  }
6245
6460
  if (versionMadeBy > MAX_16_BITS) {
@@ -6271,11 +6486,10 @@
6271
6486
  externalFileAttributes = FILE_ATTR_UNIX_DEFAULT_MASK << 16;
6272
6487
  }
6273
6488
  }
6274
- let unixExternalUpper;
6275
6489
  if (!msDosCompatible) {
6276
6490
  const unixModeProvided = unixMode !== UNDEFINED_VALUE || Boolean(setuid || setgid || sticky);
6277
- unixExternalUpper = (externalFileAttributes >> 16) & MAX_16_BITS;
6278
- unixMode = unixMode === UNDEFINED_VALUE ? unixExternalUpper : (unixMode & MAX_16_BITS);
6491
+ const defaultUnixMode = (externalFileAttributes >> 16) & MAX_16_BITS;
6492
+ unixMode = unixMode === UNDEFINED_VALUE ? defaultUnixMode : (unixMode & MAX_16_BITS);
6279
6493
  if (setuid) {
6280
6494
  unixMode |= FILE_ATTR_UNIX_SETUID_MASK;
6281
6495
  } else {
@@ -6304,17 +6518,20 @@
6304
6518
  if (hasMsDosProvided) {
6305
6519
  externalFileAttributes = (externalFileAttributes & MAX_32_BITS) | (msdosAttributesRaw & MAX_8_BITS);
6306
6520
  }
6521
+ const unixExternalUpper = (externalFileAttributes >> 16) & MAX_16_BITS;
6522
+ const symlink = unixMode !== UNDEFINED_VALUE && ((unixMode & FILE_ATTR_UNIX_TYPE_MASK) == FILE_ATTR_UNIX_TYPE_SYMLINK);
6307
6523
  return {
6308
6524
  name,
6309
6525
  resolvedOptions: {
6310
6526
  versionMadeBy,
6311
- msDosCompatible,
6527
+ msDosCompatible: Boolean(msDosCompatible),
6312
6528
  externalFileAttributes,
6313
6529
  unixExternalUpper,
6314
6530
  uid,
6315
6531
  gid,
6316
6532
  unixMode,
6317
6533
  unixExtraFieldType,
6534
+ symlink,
6318
6535
  setuid,
6319
6536
  setgid,
6320
6537
  sticky,
@@ -6325,7 +6542,7 @@
6325
6542
  }
6326
6543
 
6327
6544
  function resolveMetadata(zipWriter, name, options) {
6328
- const encode = getOptionValue(zipWriter, options, OPTION_ENCODE_TEXT, encodeText);
6545
+ const encode = getFunctionOptionValue(zipWriter, options, OPTION_ENCODE_TEXT) || encodeText;
6329
6546
  let rawFilename = encode(name, TEXT_TYPE_FILENAME);
6330
6547
  if (rawFilename === UNDEFINED_VALUE) {
6331
6548
  rawFilename = encodeText(name);
@@ -6334,6 +6551,10 @@
6334
6551
  throw new Error(ERR_INVALID_ENTRY_NAME);
6335
6552
  }
6336
6553
  const comment = options[PROPERTY_NAME_COMMENT] || "";
6554
+ // deno-lint-ignore valid-typeof
6555
+ if (typeof comment != STRING_TYPE) {
6556
+ throw new Error(ERR_INVALID_ENTRY_COMMENT_TYPE);
6557
+ }
6337
6558
  let rawComment = encode(comment, TEXT_TYPE_COMMENT);
6338
6559
  if (rawComment === UNDEFINED_VALUE) {
6339
6560
  rawComment = encodeText(comment);
@@ -6345,16 +6566,14 @@
6345
6566
  if (version > MAX_16_BITS) {
6346
6567
  throw new Error(ERR_INVALID_VERSION);
6347
6568
  }
6348
- const lastModDate = getOptionValue(zipWriter, options, PROPERTY_NAME_LAST_MODIFICATION_DATE, new Date());
6349
- const lastAccessDate = getOptionValue(zipWriter, options, PROPERTY_NAME_LAST_ACCESS_DATE);
6350
- const creationDate = getOptionValue(zipWriter, options, PROPERTY_NAME_CREATION_DATE);
6569
+ const lastModDate = getDateOptionValue(zipWriter, options, PROPERTY_NAME_LAST_MODIFICATION_DATE, new Date());
6570
+ const lastAccessDate = getDateOptionValue(zipWriter, options, PROPERTY_NAME_LAST_ACCESS_DATE);
6571
+ const creationDate = getDateOptionValue(zipWriter, options, PROPERTY_NAME_CREATION_DATE);
6351
6572
  const internalFileAttributes = getAliasedOptionValue(zipWriter, options, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES, PROPERTY_NAME_DEPRECATED_INTERNAL_FILE_ATTRIBUTES, 0);
6352
6573
  const passThrough = getOptionValue(zipWriter, options, OPTION_PASS_THROUGH);
6353
6574
  const password = getOptionValue(zipWriter, options, OPTION_PASSWORD);
6354
6575
  const rawPassword = getOptionValue(zipWriter, options, OPTION_RAW_PASSWORD);
6355
- if ((password && typeof password != STRING_TYPE) || (rawPassword && !(rawPassword instanceof Uint8Array))) {
6356
- throw new Error(ERR_INVALID_PASSWORD_TYPE);
6357
- }
6576
+ checkPasswordOption(password, rawPassword);
6358
6577
  const encryptionStrength = getNumberOptionValue(zipWriter, options, OPTION_ENCRYPTION_STRENGTH, 3);
6359
6578
  const zipCrypto = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIPCRYPTO);
6360
6579
  const extendedTimestamp = getOptionValue(zipWriter, options, OPTION_EXTENDED_TIMESTAMP, true);
@@ -6363,9 +6582,9 @@
6363
6582
  const useWebWorkers = getOptionValue(zipWriter, options, OPTION_USE_WEB_WORKERS);
6364
6583
  const transferStreams = getOptionValue(zipWriter, options, OPTION_TRANSFER_STREAMS);
6365
6584
  const bufferedWrite = getOptionValue(zipWriter, options, OPTION_BUFFERED_WRITE);
6366
- const createTempStream = getOptionValue(zipWriter, options, OPTION_CREATE_TEMP_STREAM);
6585
+ const createTempStream = getFunctionOptionValue(zipWriter, options, OPTION_CREATE_TEMP_STREAM);
6367
6586
  const dataDescriptorSignature = getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR_SIGNATURE, true);
6368
- const signal = getOptionValue(zipWriter, options, OPTION_SIGNAL);
6587
+ const signal = checkSignalOption(getOptionValue(zipWriter, options, OPTION_SIGNAL));
6369
6588
  const useUnicodeFileNames = getOptionValue(zipWriter, options, OPTION_USE_UNICODE_FILE_NAMES, true);
6370
6589
  const compressionMethod = getOptionValue(zipWriter, options, PROPERTY_NAME_COMPRESSION_METHOD);
6371
6590
  const registeredCodec = passThrough || compressionMethod === UNDEFINED_VALUE ? UNDEFINED_VALUE : getRegisteredCodec(compressionMethod);
@@ -6445,18 +6664,26 @@
6445
6664
  if (!extraField) {
6446
6665
  return EMPTY_UINT8_ARRAY;
6447
6666
  }
6667
+ if (!(extraField instanceof Map)) {
6668
+ throw new Error(ERR_INVALID_EXTRAFIELD);
6669
+ }
6448
6670
  let extraFieldSize = 0;
6449
6671
  let offset = 0;
6450
- extraField.forEach(data => extraFieldSize += 4 + getLength(data));
6451
- const rawExtraField = new Uint8Array(extraFieldSize);
6452
- const rawExtraFieldView = getDataView(rawExtraField);
6453
6672
  extraField.forEach((data, type) => {
6454
- if (type > MAX_16_BITS) {
6673
+ if (!Number.isInteger(type) || type < 0 || type > MAX_16_BITS) {
6455
6674
  throw new Error(ERR_INVALID_EXTRAFIELD_TYPE);
6456
6675
  }
6676
+ if (!(data instanceof Uint8Array)) {
6677
+ throw new Error(ERR_INVALID_EXTRAFIELD_DATA_TYPE);
6678
+ }
6457
6679
  if (getLength(data) > MAX_16_BITS) {
6458
6680
  throw new Error(ERR_INVALID_EXTRAFIELD_DATA);
6459
6681
  }
6682
+ extraFieldSize += 4 + getLength(data);
6683
+ });
6684
+ const rawExtraField = new Uint8Array(extraFieldSize);
6685
+ const rawExtraFieldView = getDataView(rawExtraField);
6686
+ extraField.forEach((data, type) => {
6460
6687
  setUint16(rawExtraFieldView, offset, type);
6461
6688
  setUint16(rawExtraFieldView, offset + 2, getLength(data));
6462
6689
  arraySet(rawExtraField, data, offset + 4);
@@ -6544,7 +6771,7 @@
6544
6771
 
6545
6772
  async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
6546
6773
  const {
6547
- files,
6774
+ fileEntries,
6548
6775
  writer
6549
6776
  } = zipWriter;
6550
6777
  const {
@@ -6566,12 +6793,12 @@
6566
6793
  let writerSizeBeforeEntry;
6567
6794
  let flushedBufferedSize = 0;
6568
6795
  let fileWriter;
6569
- files.set(name, fileEntry);
6796
+ fileEntries.set(name, fileEntry);
6570
6797
  zipWriter.lastFileEntry = fileEntry;
6571
6798
  try {
6572
6799
  let lockPreviousFileEntry;
6573
6800
  if (keepOrder) {
6574
- lockPreviousFileEntry = previousFileEntry && previousFileEntry.lock;
6801
+ lockPreviousFileEntry = previousFileEntry && previousFileEntry.lockFileEntry;
6575
6802
  requestLockCurrentFileEntry();
6576
6803
  }
6577
6804
  if (options.bufferedWrite || !keepOrder || zipWriter.writerLocked || zipWriter.bufferedWrites || !dataDescriptor) {
@@ -6592,11 +6819,8 @@
6592
6819
  const diskOffset = getDiskOffset(writer);
6593
6820
  if (zipWriter.addSplitZipSignature) {
6594
6821
  delete zipWriter.addSplitZipSignature;
6595
- const signatureArray = new Uint8Array(4);
6596
- const signatureArrayView = getDataView(signatureArray);
6597
- setUint32(signatureArrayView, 0, SPLIT_ZIP_FILE_SIGNATURE);
6598
- await writeData(writer, signatureArray);
6599
- zipWriter.offset += 4;
6822
+ await writeData(writer, getSplitZipSignatureArray());
6823
+ zipWriter.offset += SPLIT_ZIP_FILE_SIGNATURE_LENGTH;
6600
6824
  }
6601
6825
  if (usdz && !bufferedWrite) {
6602
6826
  appendExtraFieldUSDZ(entryInfo, zipWriter.offset - diskOffset);
@@ -6614,11 +6838,11 @@
6614
6838
  writerSizeBeforeEntry = writer.size;
6615
6839
  await writeData(fileWriter, localHeaderArray);
6616
6840
  }
6617
- fileEntry = await createFileEntry(reader, fileWriter, fileEntry, entryInfo, zipWriter.config, options);
6841
+ fileEntry = await createFileEntry(reader, fileWriter, fileEntry, entryInfo, getConfiguration(), options);
6618
6842
  if (!bufferedWrite) {
6619
6843
  writingEntryData = false;
6620
6844
  }
6621
- files.set(name, fileEntry);
6845
+ fileEntries.set(name, fileEntry);
6622
6846
  fileEntry.filename = name;
6623
6847
  if (bufferedWrite) {
6624
6848
  await Promise.all([fileWriter.writable.getWriter().close(), lockPreviousFileEntry]);
@@ -6659,7 +6883,7 @@
6659
6883
  zipWriter.offset += flushedBufferedSize;
6660
6884
  }
6661
6885
  }
6662
- files.delete(name);
6886
+ fileEntries.delete(name);
6663
6887
  throw error;
6664
6888
  } finally {
6665
6889
  if (bufferedWrite) {
@@ -6681,7 +6905,7 @@
6681
6905
  }
6682
6906
 
6683
6907
  function requestLockCurrentFileEntry() {
6684
- fileEntry.lock = new Promise(resolve => releaseLockCurrentFileEntry = resolve);
6908
+ fileEntry.lockFileEntry = new Promise(resolve => releaseLockCurrentFileEntry = resolve);
6685
6909
  }
6686
6910
 
6687
6911
  async function requestLockWriter() {
@@ -6701,7 +6925,7 @@
6701
6925
  }
6702
6926
  }
6703
6927
 
6704
- async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryInfo, config, options) {
6928
+ async function createFileEntry(reader, writer, { diskNumberStart, lockFileEntry }, entryInfo, config, options) {
6705
6929
  const {
6706
6930
  headerInfo,
6707
6931
  dataDescriptorInfo,
@@ -6756,6 +6980,7 @@
6756
6980
  uid,
6757
6981
  gid,
6758
6982
  unixMode,
6983
+ symlink,
6759
6984
  setuid,
6760
6985
  setgid,
6761
6986
  sticky,
@@ -6768,7 +6993,7 @@
6768
6993
  codecURI
6769
6994
  } = options;
6770
6995
  const fileEntry = {
6771
- lock,
6996
+ lockFileEntry,
6772
6997
  versionMadeBy,
6773
6998
  zip64,
6774
6999
  directory: Boolean(directory),
@@ -6792,6 +7017,7 @@
6792
7017
  uid,
6793
7018
  gid,
6794
7019
  unixMode,
7020
+ symlink: Boolean(symlink),
6795
7021
  setuid,
6796
7022
  setgid,
6797
7023
  sticky,
@@ -6809,7 +7035,7 @@
6809
7035
  }
6810
7036
  const { writable } = writer;
6811
7037
  if (reader) {
6812
- const readable = toCompatibleReadable(reader.createReadable ? reader.createReadable() : reader.readable);
7038
+ const readable = toCompatibleReadable(createReadable(reader));
6813
7039
  const size = reader.size;
6814
7040
  const workerOptions = {
6815
7041
  options: {
@@ -6872,8 +7098,8 @@
6872
7098
  rawLastModDate,
6873
7099
  creationDate,
6874
7100
  lastAccessDate,
6875
- encrypted,
6876
- zipCrypto,
7101
+ encrypted: Boolean(encrypted),
7102
+ zipCrypto: Boolean(zipCrypto),
6877
7103
  size: metadataSize + compressedSize,
6878
7104
  compressionMethod,
6879
7105
  version,
@@ -6921,14 +7147,14 @@
6921
7147
  if (zip64 && (zip64UncompressedSize || zip64CompressedSize)) {
6922
7148
  const length = 4 + 16;
6923
7149
  const extraFieldZip64 = createRecordWriter(length);
6924
- extraFieldZip64.uint16(EXTRAFIELD_TYPE_ZIP64);
6925
- extraFieldZip64.uint16(length - 4);
7150
+ extraFieldZip64.writeUint16(EXTRAFIELD_TYPE_ZIP64);
7151
+ extraFieldZip64.writeUint16(length - 4);
6926
7152
  rawLocalExtraFieldZip64 = extraFieldZip64.array;
6927
7153
  if (zip64ExtraFieldComplete) {
6928
- extraFieldZip64.uint64(uncompressedSize);
7154
+ extraFieldZip64.writeUint64(uncompressedSize);
6929
7155
  if (uncompressedFile) {
6930
7156
  const encryptionOverhead = encrypted ? (zipCrypto ? 12 : 16 + encryptionStrength * 4) : 0;
6931
- extraFieldZip64.uint64(passThrough ? 0 : uncompressedSize + encryptionOverhead);
7157
+ extraFieldZip64.writeUint64(passThrough ? 0 : uncompressedSize + encryptionOverhead);
6932
7158
  }
6933
7159
  }
6934
7160
  } else {
@@ -6937,8 +7163,8 @@
6937
7163
  let rawExtraFieldAES;
6938
7164
  if (encrypted && !zipCrypto) {
6939
7165
  const extraFieldAES = createRecordWriter(getLength(EXTRAFIELD_DATA_AES) + 2);
6940
- extraFieldAES.uint16(EXTRAFIELD_TYPE_AES);
6941
- extraFieldAES.bytes(EXTRAFIELD_DATA_AES);
7166
+ extraFieldAES.writeUint16(EXTRAFIELD_TYPE_AES);
7167
+ extraFieldAES.writeBytes(EXTRAFIELD_DATA_AES);
6942
7168
  rawExtraFieldAES = extraFieldAES.array;
6943
7169
  rawExtraFieldAES[8] = encryptionStrength;
6944
7170
  } else {
@@ -6954,15 +7180,15 @@
6954
7180
  const extraFieldTimestampLength = 9 + (lastAccessDate ? 4 : 0) + (creationDate ? 4 : 0);
6955
7181
  const extraFieldTimestamp = createRecordWriter(extraFieldTimestampLength);
6956
7182
  extraFieldExtendedTimestampFlag = 0x1 + (lastAccessDate ? 0x2 : 0) + (creationDate ? 0x4 : 0);
6957
- extraFieldTimestamp.uint16(EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
6958
- extraFieldTimestamp.uint16(extraFieldTimestampLength - 4);
6959
- extraFieldTimestamp.uint8(extraFieldExtendedTimestampFlag);
6960
- extraFieldTimestamp.uint32(lastModTimeUnix);
7183
+ extraFieldTimestamp.writeUint16(EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
7184
+ extraFieldTimestamp.writeUint16(extraFieldTimestampLength - 4);
7185
+ extraFieldTimestamp.writeUint8(extraFieldExtendedTimestampFlag);
7186
+ extraFieldTimestamp.writeUint32(lastModTimeUnix);
6961
7187
  if (lastAccessDate) {
6962
- extraFieldTimestamp.uint32(clampUnixTime(getTimeUnix(lastAccessDate)));
7188
+ extraFieldTimestamp.writeUint32(clampUnixTime(getTimeUnix(lastAccessDate)));
6963
7189
  }
6964
7190
  if (creationDate) {
6965
- extraFieldTimestamp.uint32(clampUnixTime(getTimeUnix(creationDate)));
7191
+ extraFieldTimestamp.writeUint32(clampUnixTime(getTimeUnix(creationDate)));
6966
7192
  }
6967
7193
  rawExtraFieldExtendedTimestamp = extraFieldTimestamp.array;
6968
7194
  } else {
@@ -6975,14 +7201,14 @@
6975
7201
  try {
6976
7202
  const lastModTimeNTFS = getTimeNTFS(lastModDate);
6977
7203
  const extraFieldNTFS = createRecordWriter(36);
6978
- extraFieldNTFS.uint16(EXTRAFIELD_TYPE_NTFS);
6979
- extraFieldNTFS.uint16(32);
7204
+ extraFieldNTFS.writeUint16(EXTRAFIELD_TYPE_NTFS);
7205
+ extraFieldNTFS.writeUint16(32);
6980
7206
  extraFieldNTFS.skip(4);
6981
- extraFieldNTFS.uint16(EXTRAFIELD_TYPE_NTFS_TAG1);
6982
- extraFieldNTFS.uint16(24);
6983
- extraFieldNTFS.uint64(lastModTimeNTFS);
6984
- extraFieldNTFS.uint64(lastAccessDate ? getTimeNTFS(lastAccessDate) : lastModTimeNTFS);
6985
- extraFieldNTFS.uint64(creationDate ? getTimeNTFS(creationDate) : lastModTimeNTFS);
7207
+ extraFieldNTFS.writeUint16(EXTRAFIELD_TYPE_NTFS_TAG1);
7208
+ extraFieldNTFS.writeUint16(24);
7209
+ extraFieldNTFS.writeUint64(lastModTimeNTFS);
7210
+ extraFieldNTFS.writeUint64(lastAccessDate ? getTimeNTFS(lastAccessDate) : lastModTimeNTFS);
7211
+ extraFieldNTFS.writeUint64(creationDate ? getTimeNTFS(creationDate) : lastModTimeNTFS);
6986
7212
  rawExtraFieldNTFS = extraFieldNTFS.array;
6987
7213
  } catch {
6988
7214
  rawExtraFieldNTFS = EMPTY_UINT8_ARRAY;
@@ -7001,20 +7227,20 @@
7001
7227
  const gidBytes = packUnixId(gid);
7002
7228
  const payloadLength = 3 + uidBytes.length + gidBytes.length;
7003
7229
  const extraFieldUnix = createRecordWriter(4 + payloadLength);
7004
- extraFieldUnix.uint16(EXTRAFIELD_TYPE_INFOZIP);
7005
- extraFieldUnix.uint16(payloadLength);
7006
- extraFieldUnix.uint8(1);
7007
- extraFieldUnix.uint8(uidBytes.length);
7008
- extraFieldUnix.bytes(uidBytes);
7009
- extraFieldUnix.uint8(gidBytes.length);
7010
- extraFieldUnix.bytes(gidBytes);
7230
+ extraFieldUnix.writeUint16(EXTRAFIELD_TYPE_INFOZIP);
7231
+ extraFieldUnix.writeUint16(payloadLength);
7232
+ extraFieldUnix.writeUint8(1);
7233
+ extraFieldUnix.writeUint8(uidBytes.length);
7234
+ extraFieldUnix.writeBytes(uidBytes);
7235
+ extraFieldUnix.writeUint8(gidBytes.length);
7236
+ extraFieldUnix.writeBytes(gidBytes);
7011
7237
  rawExtraFieldUnix = extraFieldUnix.array;
7012
7238
  } else if (unixExtraFieldType == UNIX_EXTRA_FIELD_TYPE && (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE)) {
7013
7239
  const extraFieldUnix = createRecordWriter(8);
7014
- extraFieldUnix.uint16(EXTRAFIELD_TYPE_UNIX);
7015
- extraFieldUnix.uint16(4);
7016
- extraFieldUnix.uint16((uid === UNDEFINED_VALUE ? 0 : uid) & MAX_16_BITS);
7017
- extraFieldUnix.uint16((gid === UNDEFINED_VALUE ? 0 : gid) & MAX_16_BITS);
7240
+ extraFieldUnix.writeUint16(EXTRAFIELD_TYPE_UNIX);
7241
+ extraFieldUnix.writeUint16(4);
7242
+ extraFieldUnix.writeUint16((uid === UNDEFINED_VALUE ? 0 : uid) & MAX_16_BITS);
7243
+ extraFieldUnix.writeUint16((gid === UNDEFINED_VALUE ? 0 : gid) & MAX_16_BITS);
7018
7244
  rawExtraFieldUnix = extraFieldUnix.array;
7019
7245
  } else {
7020
7246
  rawExtraFieldUnix = EMPTY_UINT8_ARRAY;
@@ -7064,18 +7290,18 @@
7064
7290
  const localHeader = createRecordWriter(HEADER_SIZE + getLength(rawFilename) + extraFieldLength);
7065
7291
  const localHeaderArray = localHeader.array;
7066
7292
  const localHeaderView = getDataView(localHeaderArray);
7067
- localHeader.uint32(LOCAL_FILE_HEADER_SIGNATURE);
7068
- localHeader.bytes(headerArray);
7069
- localHeader.bytes(rawFilename);
7293
+ localHeader.writeUint32(LOCAL_FILE_HEADER_SIGNATURE);
7294
+ localHeader.writeBytes(headerArray);
7295
+ localHeader.writeBytes(rawFilename);
7070
7296
  if (writeLocalExtraFieldZip64) {
7071
- localHeader.bytes(rawLocalExtraFieldZip64);
7072
- }
7073
- localHeader.bytes(rawExtraFieldAES);
7074
- localHeader.bytes(rawExtraFieldExtendedTimestamp);
7075
- localHeader.bytes(rawExtraFieldNTFS);
7076
- localHeader.bytes(rawExtraFieldUnix);
7077
- localHeader.bytes(rawExtraField);
7078
- localHeader.bytes(rawLocalExtraField);
7297
+ localHeader.writeBytes(rawLocalExtraFieldZip64);
7298
+ }
7299
+ localHeader.writeBytes(rawExtraFieldAES);
7300
+ localHeader.writeBytes(rawExtraFieldExtendedTimestamp);
7301
+ localHeader.writeBytes(rawExtraFieldNTFS);
7302
+ localHeader.writeBytes(rawExtraFieldUnix);
7303
+ localHeader.writeBytes(rawExtraField);
7304
+ localHeader.writeBytes(rawLocalExtraField);
7079
7305
  if (dataDescriptor) {
7080
7306
  if (!zip64CompressedSize) {
7081
7307
  setUint32(localHeaderView, HEADER_OFFSET_COMPRESSED_SIZE + LOCAL_HEADER_COMMON_OFFSET, 0);
@@ -7265,7 +7491,7 @@
7265
7491
 
7266
7492
 
7267
7493
  async function closeFile(zipWriter, comment, options) {
7268
- const directoryDataLength = createDirectoryRecords(zipWriter.files);
7494
+ const directoryDataLength = createDirectoryRecords(zipWriter.fileEntries);
7269
7495
  const { directoryStart, directoryArray } = await writeDirectoryRecords(zipWriter, directoryDataLength, options);
7270
7496
  const signatureLength = await writeDigitalSignatureRecord(zipWriter, directoryArray, options);
7271
7497
  await writeEndOfDirectoryRecord(zipWriter, comment, options, { directoryStart, directoryDataLength, signatureLength });
@@ -7295,19 +7521,19 @@
7295
7521
  if (zip64Offset || zip64DiskNumberStart || zip64UncompressedSize || zip64CompressedSize) {
7296
7522
  const length = 4 + (zip64UncompressedSize ? 8 : 0) + (zip64CompressedSize ? 8 : 0) + (zip64Offset ? 8 : 0) + (zip64DiskNumberStart ? 4 : 0);
7297
7523
  const extraFieldZip64 = createRecordWriter(length);
7298
- extraFieldZip64.uint16(EXTRAFIELD_TYPE_ZIP64);
7299
- extraFieldZip64.uint16(length - 4);
7524
+ extraFieldZip64.writeUint16(EXTRAFIELD_TYPE_ZIP64);
7525
+ extraFieldZip64.writeUint16(length - 4);
7300
7526
  if (zip64UncompressedSize) {
7301
- extraFieldZip64.uint64(uncompressedSize);
7527
+ extraFieldZip64.writeUint64(uncompressedSize);
7302
7528
  }
7303
7529
  if (zip64CompressedSize) {
7304
- extraFieldZip64.uint64(compressedSize);
7530
+ extraFieldZip64.writeUint64(compressedSize);
7305
7531
  }
7306
7532
  if (zip64Offset) {
7307
- extraFieldZip64.uint64(fileEntry.offset);
7533
+ extraFieldZip64.writeUint64(fileEntry.offset);
7308
7534
  }
7309
7535
  if (zip64DiskNumberStart) {
7310
- extraFieldZip64.uint32(fileEntry.diskNumberStart);
7536
+ extraFieldZip64.writeUint32(fileEntry.diskNumberStart);
7311
7537
  }
7312
7538
  rawExtraFieldZip64 = extraFieldZip64.array;
7313
7539
  } else {
@@ -7320,10 +7546,10 @@
7320
7546
  const lastModTimeUnix = getTimeUnix(lastModDate);
7321
7547
  if (extendedTimestamp && inUnixTimeRange(lastModTimeUnix)) {
7322
7548
  const extraFieldTimestamp = createRecordWriter(9);
7323
- extraFieldTimestamp.uint16(EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
7324
- extraFieldTimestamp.uint16(5);
7325
- extraFieldTimestamp.uint8(extraFieldExtendedTimestampFlag);
7326
- extraFieldTimestamp.uint32(lastModTimeUnix);
7549
+ extraFieldTimestamp.writeUint16(EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
7550
+ extraFieldTimestamp.writeUint16(5);
7551
+ extraFieldTimestamp.writeUint8(extraFieldExtendedTimestampFlag);
7552
+ extraFieldTimestamp.writeUint32(lastModTimeUnix);
7327
7553
  rawExtraFieldTimestamp = extraFieldTimestamp.array;
7328
7554
  } else {
7329
7555
  rawExtraFieldTimestamp = EMPTY_UINT8_ARRAY;
@@ -7345,14 +7571,14 @@
7345
7571
  }
7346
7572
 
7347
7573
  async function writeDirectoryRecords(zipWriter, directoryDataLength, options) {
7348
- const { files, writer } = zipWriter;
7574
+ const { fileEntries, writer } = zipWriter;
7349
7575
  const directoryArray = new Uint8Array(directoryDataLength);
7350
7576
  await initStream(writer);
7351
7577
  let offset = 0;
7352
7578
  let directoryDiskOffset = 0;
7353
7579
  let directoryStartDiskNumber = getDiskNumber(writer);
7354
7580
  let directoryStartDiskOffset = getDiskOffset(writer);
7355
- for (const [indexFileEntry, fileEntry] of Array.from(files.values()).entries()) {
7581
+ for (const [indexFileEntry, fileEntry] of Array.from(fileEntries.values()).entries()) {
7356
7582
  const {
7357
7583
  offset: fileEntryOffset,
7358
7584
  rawFilename,
@@ -7397,28 +7623,28 @@
7397
7623
  setUint16(headerView, HEADER_OFFSET_VERSION, VERSION_ZIP64);
7398
7624
  }
7399
7625
  const directoryRecord = createRecordWriter(directoryRecordLength);
7400
- directoryRecord.uint32(CENTRAL_FILE_HEADER_SIGNATURE);
7401
- directoryRecord.uint16(versionMadeBy);
7402
- directoryRecord.bytes(headerArray.subarray(0, HEADER_SIZE - 4 - 2));
7403
- directoryRecord.uint16(extraFieldLength);
7404
- directoryRecord.uint16(getLength(rawComment));
7405
- directoryRecord.uint16(zip64DiskNumberStart ? MAX_16_BITS : diskNumberStart);
7406
- directoryRecord.uint16(internalFileAttributes);
7407
- directoryRecord.uint32(externalFileAttributes);
7408
- directoryRecord.uint32(zip64Offset ? MAX_32_BITS : fileEntryOffset);
7409
- directoryRecord.bytes(rawFilename);
7410
- directoryRecord.bytes(rawExtraFieldZip64);
7411
- directoryRecord.bytes(rawExtraFieldAES);
7412
- directoryRecord.bytes(rawExtraFieldExtendedTimestamp);
7413
- directoryRecord.bytes(rawExtraFieldNTFS);
7414
- directoryRecord.bytes(rawExtraFieldUnix);
7415
- directoryRecord.bytes(rawExtraField);
7416
- directoryRecord.bytes(rawComment);
7626
+ directoryRecord.writeUint32(CENTRAL_FILE_HEADER_SIGNATURE);
7627
+ directoryRecord.writeUint16(versionMadeBy);
7628
+ directoryRecord.writeBytes(headerArray.subarray(0, HEADER_SIZE - 4 - 2));
7629
+ directoryRecord.writeUint16(extraFieldLength);
7630
+ directoryRecord.writeUint16(getLength(rawComment));
7631
+ directoryRecord.writeUint16(zip64DiskNumberStart ? MAX_16_BITS : diskNumberStart);
7632
+ directoryRecord.writeUint16(internalFileAttributes);
7633
+ directoryRecord.writeUint32(externalFileAttributes);
7634
+ directoryRecord.writeUint32(zip64Offset ? MAX_32_BITS : fileEntryOffset);
7635
+ directoryRecord.writeBytes(rawFilename);
7636
+ directoryRecord.writeBytes(rawExtraFieldZip64);
7637
+ directoryRecord.writeBytes(rawExtraFieldAES);
7638
+ directoryRecord.writeBytes(rawExtraFieldExtendedTimestamp);
7639
+ directoryRecord.writeBytes(rawExtraFieldNTFS);
7640
+ directoryRecord.writeBytes(rawExtraFieldUnix);
7641
+ directoryRecord.writeBytes(rawExtraField);
7642
+ directoryRecord.writeBytes(rawComment);
7417
7643
  arraySet(directoryArray, directoryRecord.array, offset);
7418
7644
  offset += directoryRecordLength;
7419
7645
  if (options.onprogress) {
7420
7646
  try {
7421
- await options.onprogress(indexFileEntry + 1, files.size, new Entry(fileEntry));
7647
+ await options.onprogress(indexFileEntry + 1, fileEntries.size, new Entry(fileEntry));
7422
7648
  } catch {
7423
7649
  // ignored
7424
7650
  }
@@ -7432,7 +7658,7 @@
7432
7658
  }
7433
7659
 
7434
7660
  async function writeDigitalSignatureRecord(zipWriter, directoryArray, options) {
7435
- const signCentralDirectory = getOptionValue(zipWriter, options, OPTION_SIGN_CENTRAL_DIRECTORY);
7661
+ const signCentralDirectory = getFunctionOptionValue(zipWriter, options, OPTION_SIGN_CENTRAL_DIRECTORY);
7436
7662
  if (signCentralDirectory) {
7437
7663
  const signatureData = await signCentralDirectory(directoryArray);
7438
7664
  const signatureDataLength = getLength(signatureData);
@@ -7440,9 +7666,9 @@
7440
7666
  throw new Error(ERR_INVALID_SIGNATURE_DATA);
7441
7667
  }
7442
7668
  const signatureRecord = createRecordWriter(6 + signatureDataLength);
7443
- signatureRecord.uint32(DIGITAL_SIGNATURE_RECORD_SIGNATURE);
7444
- signatureRecord.uint16(signatureDataLength);
7445
- signatureRecord.bytes(signatureData);
7669
+ signatureRecord.writeUint32(DIGITAL_SIGNATURE_RECORD_SIGNATURE);
7670
+ signatureRecord.writeUint16(signatureDataLength);
7671
+ signatureRecord.writeBytes(signatureData);
7446
7672
  await writeData(zipWriter.writer, signatureRecord.array);
7447
7673
  return 6 + signatureDataLength;
7448
7674
  }
@@ -7453,7 +7679,7 @@
7453
7679
  const { writer } = zipWriter;
7454
7680
  const { directoryStart, signatureLength } = cdInfo;
7455
7681
  let { directoryDataLength } = cdInfo;
7456
- let filesLength = zipWriter.files.size;
7682
+ let fileEntriesLength = zipWriter.fileEntries.size;
7457
7683
  let diskNumber = directoryStart.diskNumber;
7458
7684
  let directoryOffset = getSegmentOffset(zipWriter, directoryStart);
7459
7685
  let lastDiskNumber = getDiskNumber(writer);
@@ -7461,7 +7687,7 @@
7461
7687
  lastDiskNumber++;
7462
7688
  }
7463
7689
  let zip64 = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIP64);
7464
- if (directoryOffset >= MAX_32_BITS || directoryDataLength >= MAX_32_BITS || filesLength >= MAX_16_BITS || lastDiskNumber >= MAX_16_BITS) {
7690
+ if (directoryOffset >= MAX_32_BITS || directoryDataLength >= MAX_32_BITS || fileEntriesLength >= MAX_16_BITS || lastDiskNumber >= MAX_16_BITS) {
7465
7691
  if (zip64 === false) {
7466
7692
  throw new Error(ERR_UNSUPPORTED_FORMAT);
7467
7693
  } else {
@@ -7478,37 +7704,37 @@
7478
7704
  }
7479
7705
  lastDiskNumber = getDiskNumber(writer);
7480
7706
  if (zip64) {
7481
- endOfdirectoryRecord.uint32(ZIP64_END_OF_CENTRAL_DIR_SIGNATURE);
7482
- endOfdirectoryRecord.uint64(44);
7483
- endOfdirectoryRecord.uint16(45);
7484
- endOfdirectoryRecord.uint16(45);
7485
- endOfdirectoryRecord.uint32(lastDiskNumber);
7486
- endOfdirectoryRecord.uint32(diskNumber);
7487
- endOfdirectoryRecord.uint64(filesLength);
7488
- endOfdirectoryRecord.uint64(filesLength);
7489
- endOfdirectoryRecord.uint64(directoryDataLength);
7490
- endOfdirectoryRecord.uint64(directoryOffset);
7491
- endOfdirectoryRecord.uint32(ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE);
7492
- endOfdirectoryRecord.uint32(lastDiskNumber);
7493
- endOfdirectoryRecord.uint64(BigInt(getSegmentOffset(zipWriter, writer)) + BigInt(directoryDataLength) + BigInt(signatureLength));
7494
- endOfdirectoryRecord.uint32(lastDiskNumber + 1);
7707
+ endOfdirectoryRecord.writeUint32(ZIP64_END_OF_CENTRAL_DIR_SIGNATURE);
7708
+ endOfdirectoryRecord.writeUint64(44);
7709
+ endOfdirectoryRecord.writeUint16(45);
7710
+ endOfdirectoryRecord.writeUint16(45);
7711
+ endOfdirectoryRecord.writeUint32(lastDiskNumber);
7712
+ endOfdirectoryRecord.writeUint32(diskNumber);
7713
+ endOfdirectoryRecord.writeUint64(fileEntriesLength);
7714
+ endOfdirectoryRecord.writeUint64(fileEntriesLength);
7715
+ endOfdirectoryRecord.writeUint64(directoryDataLength);
7716
+ endOfdirectoryRecord.writeUint64(directoryOffset);
7717
+ endOfdirectoryRecord.writeUint32(ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE);
7718
+ endOfdirectoryRecord.writeUint32(lastDiskNumber);
7719
+ endOfdirectoryRecord.writeUint64(BigInt(getSegmentOffset(zipWriter, writer)) + BigInt(directoryDataLength) + BigInt(signatureLength));
7720
+ endOfdirectoryRecord.writeUint32(lastDiskNumber + 1);
7495
7721
  const supportZip64SplitFile = getOptionValue(zipWriter, options, OPTION_SUPPORT_ZIP64_SPLIT_FILE, true);
7496
7722
  if (supportZip64SplitFile) {
7497
7723
  lastDiskNumber = MAX_16_BITS;
7498
7724
  diskNumber = MAX_16_BITS;
7499
7725
  }
7500
- filesLength = MAX_16_BITS;
7726
+ fileEntriesLength = MAX_16_BITS;
7501
7727
  directoryOffset = MAX_32_BITS;
7502
7728
  directoryDataLength = MAX_32_BITS;
7503
7729
  }
7504
- endOfdirectoryRecord.uint32(END_OF_CENTRAL_DIR_SIGNATURE);
7505
- endOfdirectoryRecord.uint16(lastDiskNumber);
7506
- endOfdirectoryRecord.uint16(diskNumber);
7507
- endOfdirectoryRecord.uint16(filesLength);
7508
- endOfdirectoryRecord.uint16(filesLength);
7509
- endOfdirectoryRecord.uint32(directoryDataLength);
7510
- endOfdirectoryRecord.uint32(directoryOffset);
7511
- endOfdirectoryRecord.uint16(commentLength);
7730
+ endOfdirectoryRecord.writeUint32(END_OF_CENTRAL_DIR_SIGNATURE);
7731
+ endOfdirectoryRecord.writeUint16(lastDiskNumber);
7732
+ endOfdirectoryRecord.writeUint16(diskNumber);
7733
+ endOfdirectoryRecord.writeUint16(fileEntriesLength);
7734
+ endOfdirectoryRecord.writeUint16(fileEntriesLength);
7735
+ endOfdirectoryRecord.writeUint32(directoryDataLength);
7736
+ endOfdirectoryRecord.writeUint32(directoryOffset);
7737
+ endOfdirectoryRecord.writeUint16(commentLength);
7512
7738
  await writeData(writer, endOfdirectoryRecord.array);
7513
7739
  if (commentLength) {
7514
7740
  await writeData(writer, comment);
@@ -7521,11 +7747,11 @@
7521
7747
  let offset = 0;
7522
7748
  return {
7523
7749
  array,
7524
- uint8: value => { setUint8(view, offset, value); offset += 1; },
7525
- uint16: value => { setUint16(view, offset, value); offset += 2; },
7526
- uint32: value => { setUint32(view, offset, value); offset += 4; },
7527
- uint64: value => { setBigUint64(view, offset, BigInt(value)); offset += 8; },
7528
- bytes: value => { arraySet(array, value, offset); offset += getLength(value); },
7750
+ writeUint8: value => { setUint8(view, offset, value); offset += 1; },
7751
+ writeUint16: value => { setUint16(view, offset, value); offset += 2; },
7752
+ writeUint32: value => { setUint32(view, offset, value); offset += 4; },
7753
+ writeUint64: value => { setBigUint64(view, offset, BigInt(value)); offset += 8; },
7754
+ writeBytes: value => { arraySet(array, value, offset); offset += getLength(value); },
7529
7755
  skip: count => offset += count
7530
7756
  };
7531
7757
  }
@@ -7549,6 +7775,71 @@
7549
7775
  return zipWriter.offset - diskOffset - (diskNumber ? zipWriter.initialOffset : 0);
7550
7776
  }
7551
7777
 
7778
+ async function startsWithSplitZipSignature(reader) {
7779
+ const signatureArray = await readUint8Array(reader, 0, SPLIT_ZIP_FILE_SIGNATURE_LENGTH);
7780
+ return getUint32(getDataView(signatureArray), 0) == SPLIT_ZIP_FILE_SIGNATURE;
7781
+ }
7782
+
7783
+ async function copyZipData(zipWriter, reader, entries, directoryOffset, splitZipSignatureLength) {
7784
+ const { writer } = zipWriter;
7785
+ const entryPositions = new Map();
7786
+ if (writer.closeDisk) {
7787
+ const sortedEntries = Array.from(entries).sort((firstEntry, secondEntry) =>
7788
+ getSourceOffset(reader, firstEntry) - getSourceOffset(reader, secondEntry));
7789
+ let copiedLength = 0;
7790
+ for (const entry of sortedEntries) {
7791
+ const sourceOffset = getSourceOffset(reader, entry);
7792
+ await copyData(zipWriter, reader, copiedLength, sourceOffset - copiedLength);
7793
+ if (exceedsAvailableSize(writer, await getLocalHeaderLength(reader, sourceOffset))) {
7794
+ await writer.closeDisk();
7795
+ }
7796
+ entryPositions.set(entry, {
7797
+ offset: getSegmentOffset(zipWriter, writer),
7798
+ diskNumberStart: getDiskNumber(writer)
7799
+ });
7800
+ copiedLength = sourceOffset;
7801
+ }
7802
+ await copyData(zipWriter, reader, copiedLength, directoryOffset - copiedLength);
7803
+ } else {
7804
+ await copyData(zipWriter, reader, 0, directoryOffset);
7805
+ entries.forEach(entry => entryPositions.set(entry, {
7806
+ offset: splitZipSignatureLength + getSourceOffset(reader, entry),
7807
+ diskNumberStart: 0
7808
+ }));
7809
+ }
7810
+ return entryPositions;
7811
+ }
7812
+
7813
+ async function copyData(zipWriter, reader, offset, size) {
7814
+ if (size > 0) {
7815
+ const { writer } = zipWriter;
7816
+ await createReadable(reader, { offset, size }).pipeTo(writer.writable, { preventClose: true, preventAbort: true });
7817
+ writer.size += size;
7818
+ zipWriter.offset += size;
7819
+ }
7820
+ }
7821
+
7822
+ async function getLocalHeaderLength(reader, offset) {
7823
+ const headerArray = await readUint8Array(reader, offset, HEADER_SIZE);
7824
+ if (getLength(headerArray) < HEADER_SIZE) {
7825
+ return HEADER_SIZE;
7826
+ }
7827
+ const headerView = getDataView(headerArray);
7828
+ return HEADER_SIZE +
7829
+ getUint16(headerView, HEADER_OFFSET_FILENAME_LENGTH + LOCAL_HEADER_COMMON_OFFSET) +
7830
+ getUint16(headerView, HEADER_OFFSET_EXTRAFIELD_LENGTH + LOCAL_HEADER_COMMON_OFFSET);
7831
+ }
7832
+
7833
+ function getSourceOffset(reader, { offset, diskNumberStart }) {
7834
+ return offset + (reader.getDiskOffset ? reader.getDiskOffset(diskNumberStart) : 0);
7835
+ }
7836
+
7837
+ function getSplitZipSignatureArray() {
7838
+ const signatureArray = new Uint8Array(SPLIT_ZIP_FILE_SIGNATURE_LENGTH);
7839
+ setUint32(getDataView(signatureArray), 0, SPLIT_ZIP_FILE_SIGNATURE);
7840
+ return signatureArray;
7841
+ }
7842
+
7552
7843
  async function writeData(writer, array) {
7553
7844
  const { writable } = writer;
7554
7845
  const streamWriter = writable.getWriter();
@@ -7600,6 +7891,21 @@
7600
7891
  return result === UNDEFINED_VALUE ? defaultValue : result;
7601
7892
  }
7602
7893
 
7894
+ function getDateOptionValue(zipWriter, options, name, defaultValue) {
7895
+ const date = getOptionValue(zipWriter, options, name, defaultValue);
7896
+ if (date === null) {
7897
+ return defaultValue;
7898
+ }
7899
+ if (date !== UNDEFINED_VALUE && (typeof date.getTime != FUNCTION_TYPE || Number.isNaN(date.getTime()))) {
7900
+ throw new Error(ERR_INVALID_DATE);
7901
+ }
7902
+ return date;
7903
+ }
7904
+
7905
+ function getFunctionOptionValue(zipWriter, options, name) {
7906
+ return checkFunctionOption(getOptionValue(zipWriter, options, name));
7907
+ }
7908
+
7603
7909
  function getAliasedOptionValue(zipWriter, options, name, deprecatedName, defaultValue) {
7604
7910
  const value = getAliasedValue(options, name, deprecatedName);
7605
7911
  const result = value === UNDEFINED_VALUE ? getAliasedValue(zipWriter.options, name, deprecatedName) : value;
@@ -7614,9 +7920,6 @@
7614
7920
  return toNumber(getOptionValue(zipWriter, options, name, defaultValue));
7615
7921
  }
7616
7922
 
7617
- function toNumber(value) {
7618
- return typeof value == STRING_TYPE && value.trim() ? Number(value) : value;
7619
- }
7620
7923
 
7621
7924
  function getMaximumCompressedSize(uncompressedSize) {
7622
7925
  return uncompressedSize + (5 * (Math.floor(uncompressedSize / 16383) + 1));
@@ -7628,6 +7931,14 @@
7628
7931
  : compressionMethod !== COMPRESSION_METHOD_STORE;
7629
7932
  }
7630
7933
 
7934
+ function getUint16(view, offset) {
7935
+ return view.getUint16(offset, true);
7936
+ }
7937
+
7938
+ function getUint32(view, offset) {
7939
+ return view.getUint32(offset, true);
7940
+ }
7941
+
7631
7942
  function setUint8(view, offset, value) {
7632
7943
  view.setUint8(offset, value);
7633
7944
  }
@@ -7671,9 +7982,9 @@
7671
7982
  const headerRecord = createRecordWriter(HEADER_SIZE - 4);
7672
7983
  const headerArray = headerRecord.array;
7673
7984
  const headerView = getDataView(headerArray);
7674
- headerRecord.uint16(version);
7675
- headerRecord.uint16(bitFlag);
7676
- headerRecord.uint16(compressionMethod);
7985
+ headerRecord.writeUint16(version);
7986
+ headerRecord.writeUint16(bitFlag);
7987
+ headerRecord.writeUint16(compressionMethod);
7677
7988
  if (rawLastModDate === UNDEFINED_VALUE) {
7678
7989
  const dateArray = new Uint32Array(1);
7679
7990
  const dateView = getDataView(dateArray);
@@ -7681,20 +7992,20 @@
7681
7992
  setUint16(dateView, 2, ((((lastModDate.getFullYear() - 1980) << 4) | (lastModDate.getMonth() + 1)) << 5) | lastModDate.getDate());
7682
7993
  rawLastModDate = dateArray[0];
7683
7994
  }
7684
- headerRecord.uint32(rawLastModDate);
7995
+ headerRecord.writeUint32(rawLastModDate);
7685
7996
  headerRecord.skip(4);
7686
7997
  if (zip64CompressedSize || compressedSize !== UNDEFINED_VALUE) {
7687
- headerRecord.uint32(zip64CompressedSize ? MAX_32_BITS : compressedSize);
7998
+ headerRecord.writeUint32(zip64CompressedSize ? MAX_32_BITS : compressedSize);
7688
7999
  } else {
7689
8000
  headerRecord.skip(4);
7690
8001
  }
7691
8002
  if (zip64UncompressedSize || uncompressedSize !== UNDEFINED_VALUE) {
7692
- headerRecord.uint32(zip64UncompressedSize ? MAX_32_BITS : uncompressedSize);
8003
+ headerRecord.writeUint32(zip64UncompressedSize ? MAX_32_BITS : uncompressedSize);
7693
8004
  } else {
7694
8005
  headerRecord.skip(4);
7695
8006
  }
7696
- headerRecord.uint16(getLength(rawFilename));
7697
- headerRecord.uint16(extraFieldLength);
8007
+ headerRecord.writeUint16(getLength(rawFilename));
8008
+ headerRecord.writeUint16(extraFieldLength);
7698
8009
  return {
7699
8010
  headerArray,
7700
8011
  headerView,
@@ -8217,6 +8528,7 @@
8217
8528
  exports.ERR_DUPLICATED_NAME = ERR_DUPLICATED_NAME;
8218
8529
  exports.ERR_ENCRYPTED = ERR_ENCRYPTED;
8219
8530
  exports.ERR_ENCRYPTED_CENTRAL_DIRECTORY = ERR_ENCRYPTED_CENTRAL_DIRECTORY;
8531
+ exports.ERR_ENTRY_DATA_OUT_OF_BOUNDS = ERR_ENTRY_DATA_OUT_OF_BOUNDS;
8220
8532
  exports.ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND = ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND;
8221
8533
  exports.ERR_EOCDR_NOT_FOUND = ERR_EOCDR_NOT_FOUND;
8222
8534
  exports.ERR_EXTRAFIELD_ZIP64_NOT_FOUND = ERR_EXTRAFIELD_ZIP64_NOT_FOUND;
@@ -8226,21 +8538,29 @@
8226
8538
  exports.ERR_INVALID_CODEC_DEFINITION = ERR_INVALID_CODEC_DEFINITION;
8227
8539
  exports.ERR_INVALID_CODEC_MODULE = ERR_INVALID_CODEC_MODULE;
8228
8540
  exports.ERR_INVALID_COMMENT = ERR_INVALID_COMMENT;
8541
+ exports.ERR_INVALID_COMMENT_TYPE = ERR_INVALID_COMMENT_TYPE;
8229
8542
  exports.ERR_INVALID_COMPRESSED_DATA = ERR_INVALID_COMPRESSED_DATA;
8230
8543
  exports.ERR_INVALID_CRC32 = ERR_INVALID_CRC32;
8544
+ exports.ERR_INVALID_DATE = ERR_INVALID_DATE;
8231
8545
  exports.ERR_INVALID_ENCRYPTION_STRENGTH = ERR_INVALID_ENCRYPTION_STRENGTH;
8232
8546
  exports.ERR_INVALID_ENTRY_COMMENT = ERR_INVALID_ENTRY_COMMENT;
8547
+ exports.ERR_INVALID_ENTRY_COMMENT_TYPE = ERR_INVALID_ENTRY_COMMENT_TYPE;
8233
8548
  exports.ERR_INVALID_ENTRY_NAME = ERR_INVALID_ENTRY_NAME;
8549
+ exports.ERR_INVALID_EXTRAFIELD = ERR_INVALID_EXTRAFIELD;
8234
8550
  exports.ERR_INVALID_EXTRAFIELD_DATA = ERR_INVALID_EXTRAFIELD_DATA;
8551
+ exports.ERR_INVALID_EXTRAFIELD_DATA_TYPE = ERR_INVALID_EXTRAFIELD_DATA_TYPE;
8235
8552
  exports.ERR_INVALID_EXTRAFIELD_TYPE = ERR_INVALID_EXTRAFIELD_TYPE;
8236
8553
  exports.ERR_INVALID_FILENAME_VALIDATION = ERR_INVALID_FILENAME_VALIDATION;
8554
+ exports.ERR_INVALID_FUNCTION_OPTION = ERR_INVALID_FUNCTION_OPTION;
8237
8555
  exports.ERR_INVALID_GID = ERR_INVALID_GID;
8238
8556
  exports.ERR_INVALID_LEVEL = ERR_INVALID_LEVEL;
8239
8557
  exports.ERR_INVALID_MAX_APPENDED_DATA_SIZE = ERR_INVALID_MAX_APPENDED_DATA_SIZE;
8558
+ exports.ERR_INVALID_MAX_WORKERS = ERR_INVALID_MAX_WORKERS;
8240
8559
  exports.ERR_INVALID_MSDOS_ATTRIBUTES = ERR_INVALID_MSDOS_ATTRIBUTES;
8241
8560
  exports.ERR_INVALID_MSDOS_DATA = ERR_INVALID_MSDOS_DATA;
8242
8561
  exports.ERR_INVALID_PASSWORD = ERR_INVALID_PASSWORD;
8243
8562
  exports.ERR_INVALID_PASSWORD_TYPE = ERR_INVALID_PASSWORD_TYPE;
8563
+ exports.ERR_INVALID_SIGNAL = ERR_INVALID_SIGNAL;
8244
8564
  exports.ERR_INVALID_SIGNATURE = ERR_INVALID_SIGNATURE;
8245
8565
  exports.ERR_INVALID_SIGNATURE_DATA = ERR_INVALID_SIGNATURE_DATA;
8246
8566
  exports.ERR_INVALID_STRICTNESS = ERR_INVALID_STRICTNESS;