@zip.js/zip.js 2.8.51 → 2.8.53

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 (41) hide show
  1. package/README.md +8 -3
  2. package/deno.json +1 -1
  3. package/dist/zip-core-external.js +241 -95
  4. package/dist/zip-core-external.min.js +1 -1
  5. package/dist/zip-core.js +243 -94
  6. package/dist/zip-core.min.js +1 -1
  7. package/dist/zip-fs-core-external.js +564 -199
  8. package/dist/zip-fs-core-external.min.js +1 -1
  9. package/dist/zip-fs-core.js +551 -194
  10. package/dist/zip-fs-core.min.js +1 -1
  11. package/dist/zip-fs-external.js +564 -199
  12. package/dist/zip-fs-external.min.js +1 -1
  13. package/dist/zip-fs-native.js +567 -198
  14. package/dist/zip-fs-native.min.js +1 -1
  15. package/dist/zip-fs.js +567 -198
  16. package/dist/zip-fs.min.js +1 -1
  17. package/dist/zip-legacy.js +243 -94
  18. package/dist/zip-legacy.min.js +1 -1
  19. package/dist/zip-native.js +243 -94
  20. package/dist/zip-native.min.js +1 -1
  21. package/dist/zip.js +243 -94
  22. package/dist/zip.min.js +1 -1
  23. package/eslint.config.mjs +1 -1
  24. package/index-native.cjs +567 -198
  25. package/index-native.min.js +1 -1
  26. package/index.cjs +567 -198
  27. package/index.d.cts +551 -45
  28. package/index.d.ts +551 -45
  29. package/index.min.js +1 -1
  30. package/lib/core/codec-worker-web.js +13 -4
  31. package/lib/core/codec-worker.js +2 -0
  32. package/lib/core/constants.js +9 -0
  33. package/lib/core/io.js +43 -4
  34. package/lib/core/options.js +2 -0
  35. package/lib/core/util/compatible-streams.js +3 -8
  36. package/lib/core/zip-entry.js +16 -0
  37. package/lib/core/zip-fs.js +236 -107
  38. package/lib/core/zip-reader.js +106 -40
  39. package/lib/core/zip-writer.js +171 -41
  40. package/lib/zip-core-writer.js +3 -0
  41. package/package.json +9 -7
package/dist/zip-core.js CHANGED
@@ -90,6 +90,8 @@
90
90
  const FILE_ATTR_MSDOS_ARCHIVE_MASK = 0x20;
91
91
  const FILE_ATTR_UNIX_TYPE_MASK = 0o170000;
92
92
  const FILE_ATTR_UNIX_TYPE_DIR = 0o040000;
93
+ const FILE_ATTR_UNIX_TYPE_SYMLINK = 0o120000;
94
+ const FILE_ATTR_UNIX_TYPE_FILE = 0o100000;
93
95
  const FILE_ATTR_UNIX_EXECUTABLE_MASK = 0o111;
94
96
  const FILE_ATTR_UNIX_DEFAULT_MASK = 0o644;
95
97
  const FILE_ATTR_UNIX_SETUID_MASK = 0o4000;
@@ -100,6 +102,9 @@
100
102
  const VERSION_ZIP64 = 0x2D;
101
103
  const VERSION_AES = 0x33;
102
104
 
105
+ const VERSION_MADE_BY_MSDOS = 0x0014;
106
+ const VERSION_MADE_BY_UNIX = 0x0300;
107
+
103
108
  const DIRECTORY_SIGNATURE = "/";
104
109
 
105
110
  const HEADER_SIZE = 30;
@@ -1779,8 +1784,6 @@
1779
1784
  */
1780
1785
 
1781
1786
 
1782
- const HTTP_HEADER_CONTENT_TYPE = "Content-Type";
1783
-
1784
1787
  function toCompatibleReadable(readable) {
1785
1788
  if (readable instanceof ReadableStream) {
1786
1789
  return readable;
@@ -1803,12 +1806,9 @@
1803
1806
 
1804
1807
  function streamToBlob(readable, contentType) {
1805
1808
  readable = toCompatibleReadable(readable);
1809
+ const blobOptions = contentType ? { type: contentType } : {};
1806
1810
  if (responseSupportsGlobalReadable()) {
1807
- const options = {};
1808
- if (contentType) {
1809
- options.headers = [[HTTP_HEADER_CONTENT_TYPE, contentType]];
1810
- }
1811
- return new Response(readable, options).blob();
1811
+ return new Response(readable).blob().then(blob => contentType ? new Blob([blob], blobOptions) : blob);
1812
1812
  }
1813
1813
  const chunks = [];
1814
1814
  return readable
@@ -1817,7 +1817,7 @@
1817
1817
  chunks.push(chunk);
1818
1818
  }
1819
1819
  }))
1820
- .then(() => new Blob(chunks, contentType ? { type: contentType } : {}));
1820
+ .then(() => new Blob(chunks, blobOptions));
1821
1821
  }
1822
1822
 
1823
1823
  function responseSupportsGlobalReadable() {
@@ -2759,6 +2759,7 @@
2759
2759
  worker,
2760
2760
  workerAlive: false,
2761
2761
  terminated: false,
2762
+ startupError: null,
2762
2763
  interface: {
2763
2764
  run: async () => {
2764
2765
  try {
@@ -2786,6 +2787,13 @@
2786
2787
  }
2787
2788
 
2788
2789
  async function runWebWorker(workerData, config) {
2790
+ if (!workerData.worker) {
2791
+ const { startupError } = workerData;
2792
+ workerData.startupError = null;
2793
+ const error = startupError || new Error(ERR_WORKER_STARTUP_TIMEOUT);
2794
+ error.workerStartupFailed = true;
2795
+ throw error;
2796
+ }
2789
2797
  let resolveResult, rejectResult;
2790
2798
  const result = new Promise((resolve, reject) => {
2791
2799
  resolveResult = resolve;
@@ -2999,11 +3007,12 @@
2999
3007
  if (!workerAlive) {
3000
3008
  workerData.worker = null;
3001
3009
  }
3010
+ let error = event.error || new Error(event.message || ERROR_EVENT_TYPE);
3011
+ if (!workerAlive) {
3012
+ error = Object.assign(new Error(error.message || ERROR_EVENT_TYPE), { workerStartupFailed: true });
3013
+ workerData.startupError = error;
3014
+ }
3002
3015
  if (rejectResult) {
3003
- let error = event.error || new Error(event.message || ERROR_EVENT_TYPE);
3004
- if (!workerAlive) {
3005
- error = Object.assign(new Error(error.message || ERROR_EVENT_TYPE), { workerStartupFailed: true });
3006
- }
3007
3016
  rejectResult(error);
3008
3017
  if (writer) {
3009
3018
  writer.releaseLock();
@@ -3348,8 +3357,10 @@
3348
3357
  async pull(controller) {
3349
3358
  const dataSize = size === UNDEFINED_VALUE ? chunkSize : Math.min(chunkSize, size - chunkOffset);
3350
3359
  const data = await readUint8Array(reader, offset + chunkOffset, dataSize);
3351
- controller.enqueue(data);
3352
- if ((chunkOffset + chunkSize > size) || (size === UNDEFINED_VALUE && !data.length && dataSize)) {
3360
+ if (data.length) {
3361
+ controller.enqueue(data);
3362
+ }
3363
+ if ((chunkOffset + chunkSize >= size) || (size === UNDEFINED_VALUE && !data.length && dataSize)) {
3353
3364
  controller.close();
3354
3365
  } else {
3355
3366
  chunkOffset += chunkSize;
@@ -3427,6 +3438,7 @@
3427
3438
  constructor(contentType) {
3428
3439
  super();
3429
3440
  Object.assign(this, {
3441
+ contentType,
3430
3442
  data: "data:" + (contentType || "") + ";base64,",
3431
3443
  pending: []
3432
3444
  });
@@ -3528,6 +3540,7 @@
3528
3540
  return transformStream.writable;
3529
3541
  }
3530
3542
  });
3543
+ writer.contentType = contentType;
3531
3544
  writer.blob = streamToBlob(transformStream.readable, contentType);
3532
3545
  writer.blob.catch(() => { });
3533
3546
  }
@@ -4028,9 +4041,8 @@
4028
4041
 
4029
4042
  async init() {
4030
4043
  const reader = this;
4031
- const { readers } = reader;
4032
4044
  reader.lastDiskNumber = 0;
4033
- await Promise.all(readers.map(diskReader => initStream(diskReader)));
4045
+ const readers = reader.readers = await Promise.all(reader.readers.map(initDiskReader));
4034
4046
  reader.diskOffsets = readers.map(diskReader => {
4035
4047
  const diskOffset = reader.size;
4036
4048
  reader.size += diskReader.size;
@@ -4207,6 +4219,10 @@
4207
4219
  }
4208
4220
  }
4209
4221
 
4222
+ function ownsWritable(writer) {
4223
+ return Boolean(writer && writer.getData);
4224
+ }
4225
+
4210
4226
  function isHttpFamily(url) {
4211
4227
  const { baseURI } = getConfiguration();
4212
4228
  const { protocol } = new URL(url, baseURI);
@@ -4221,6 +4237,16 @@
4221
4237
  }
4222
4238
  }
4223
4239
 
4240
+ async function initDiskReader(diskReader) {
4241
+ diskReader = new GenericReader(diskReader);
4242
+ await initStream(diskReader);
4243
+ if (diskReader.size === UNDEFINED_VALUE || !diskReader.readUint8Array) {
4244
+ diskReader = new BlobReader(await streamToBlob(diskReader.readable));
4245
+ await initStream(diskReader);
4246
+ }
4247
+ return diskReader;
4248
+ }
4249
+
4224
4250
  function readUint8Array(reader, offset, size) {
4225
4251
  return reader.readUint8Array(offset, size);
4226
4252
  }
@@ -4351,6 +4377,8 @@
4351
4377
  const PROPERTY_NAME_RAW_CREATION_DATE = "rawCreationDate";
4352
4378
  const PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES = "internalFileAttributes";
4353
4379
  const PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES = "externalFileAttributes";
4380
+ const PROPERTY_NAME_DEPRECATED_INTERNAL_FILE_ATTRIBUTES = "internalFileAttribute";
4381
+ const PROPERTY_NAME_DEPRECATED_EXTERNAL_FILE_ATTRIBUTES = "externalFileAttribute";
4354
4382
  const PROPERTY_NAME_MSDOS_ATTRIBUTES_RAW = "msdosAttributesRaw";
4355
4383
  const PROPERTY_NAME_MSDOS_ATTRIBUTES = "msdosAttributes";
4356
4384
  const PROPERTY_NAME_MS_DOS_COMPATIBLE = "msDosCompatible";
@@ -4361,6 +4389,7 @@
4361
4389
  const PROPERTY_NAME_ZIPCRYPTO = "zipCrypto";
4362
4390
  const PROPERTY_NAME_DIRECTORY = "directory";
4363
4391
  const PROPERTY_NAME_EXECUTABLE = "executable";
4392
+ const PROPERTY_NAME_SYMLINK = "symlink";
4364
4393
  const PROPERTY_NAME_COMPRESSION_METHOD = "compressionMethod";
4365
4394
  const PROPERTY_NAME_SIGNATURE = "signature";
4366
4395
  const PROPERTY_NAME_CRC32 = "crc32";
@@ -4376,6 +4405,10 @@
4376
4405
  const PROPERTY_NAME_SETGID = "setgid";
4377
4406
  const PROPERTY_NAME_STICKY = "sticky";
4378
4407
  const PROPERTY_NAME_BITFLAG = "bitFlag";
4408
+ const PROPERTY_NAME_RAW_BITFLAG = "rawBitFlag";
4409
+ const PROPERTY_NAME_FILENAME_LENGTH = "filenameLength";
4410
+ const PROPERTY_NAME_EXTRA_FIELD_LENGTH = "extraFieldLength";
4411
+ const PROPERTY_NAME_UNIX_EXTERNAL_UPPER = "unixExternalUpper";
4379
4412
  const PROPERTY_NAME_FILENAME_UTF8 = "filenameUTF8";
4380
4413
  const PROPERTY_NAME_COMMENT_UTF8 = "commentUTF8";
4381
4414
  const PROPERTY_NAME_RAW_EXTRA_FIELD = "rawExtraField";
@@ -4404,6 +4437,8 @@
4404
4437
  PROPERTY_NAME_DISK_NUMBER_START,
4405
4438
  PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES,
4406
4439
  PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES,
4440
+ PROPERTY_NAME_DEPRECATED_INTERNAL_FILE_ATTRIBUTES,
4441
+ PROPERTY_NAME_DEPRECATED_EXTERNAL_FILE_ATTRIBUTES,
4407
4442
  PROPERTY_NAME_MSDOS_ATTRIBUTES_RAW,
4408
4443
  PROPERTY_NAME_MSDOS_ATTRIBUTES,
4409
4444
  PROPERTY_NAME_MS_DOS_COMPATIBLE,
@@ -4414,6 +4449,7 @@
4414
4449
  PROPERTY_NAME_ZIPCRYPTO,
4415
4450
  PROPERTY_NAME_DIRECTORY,
4416
4451
  PROPERTY_NAME_EXECUTABLE,
4452
+ PROPERTY_NAME_SYMLINK,
4417
4453
  PROPERTY_NAME_COMPRESSION_METHOD,
4418
4454
  PROPERTY_NAME_SIGNATURE,
4419
4455
  PROPERTY_NAME_CRC32,
@@ -4425,10 +4461,14 @@
4425
4461
  PROPERTY_NAME_UID,
4426
4462
  PROPERTY_NAME_GID,
4427
4463
  PROPERTY_NAME_UNIX_MODE,
4464
+ PROPERTY_NAME_UNIX_EXTERNAL_UPPER,
4428
4465
  PROPERTY_NAME_SETUID,
4429
4466
  PROPERTY_NAME_SETGID,
4430
4467
  PROPERTY_NAME_STICKY,
4431
4468
  PROPERTY_NAME_BITFLAG,
4469
+ PROPERTY_NAME_RAW_BITFLAG,
4470
+ PROPERTY_NAME_FILENAME_LENGTH,
4471
+ PROPERTY_NAME_EXTRA_FIELD_LENGTH,
4432
4472
  PROPERTY_NAME_FILENAME_UTF8,
4433
4473
  PROPERTY_NAME_COMMENT_UTF8,
4434
4474
  PROPERTY_NAME_RAW_EXTRA_FIELD,
@@ -4490,6 +4530,7 @@
4490
4530
  const OPTION_CHECK_OVERLAPPING_ENTRY_ONLY = "checkOverlappingEntryOnly";
4491
4531
  const OPTION_CHECK_OVERLAPPING_ENTRY = "checkOverlappingEntry";
4492
4532
  const OPTION_CHECK_AMBIGUITY = "checkAmbiguity";
4533
+ const OPTION_CHECK_LOCAL_DIRECTORY = "checkLocalDirectory";
4493
4534
  const OPTION_CHECK_SIGNATURE = "checkSignature";
4494
4535
  const OPTION_CHECK_CRC32 = "checkCrc32";
4495
4536
  const OPTION_CHECK_AUTHENTICATION_CODE = "checkAuthenticationCode";
@@ -4621,7 +4662,7 @@
4621
4662
  if (reader.size < END_OF_CENTRAL_DIR_LENGTH) {
4622
4663
  throw new Error(ERR_BAD_FORMAT);
4623
4664
  }
4624
- const strictness = getStrictness(getOptionValue$1(zipReader, options, OPTION_STRICTNESS), getOptionValue$1(zipReader, options, OPTION_CHECK_AMBIGUITY));
4665
+ const strictness = getStrictness(options, zipReader.options);
4625
4666
  const checkAmbiguity = strictness == STRICTNESS_STRICT;
4626
4667
  const rejectAmbiguousEndOfDirectory = strictness != STRICTNESS_TOLERANT;
4627
4668
  const maxAppendedDataSize = getMaxAppendedDataSize(getOptionValue$1(zipReader, options, OPTION_MAX_APPENDED_DATA_SIZE), strictness);
@@ -4843,6 +4884,7 @@
4843
4884
  index: indexFile,
4844
4885
  versionMadeBy,
4845
4886
  msDosCompatible,
4887
+ zip64: false,
4846
4888
  compressedSize: 0,
4847
4889
  uncompressedSize: 0,
4848
4890
  commentLength,
@@ -4876,15 +4918,18 @@
4876
4918
  const setuid = Boolean(fileEntry.unixMode & FILE_ATTR_UNIX_SETUID_MASK);
4877
4919
  const setgid = Boolean(fileEntry.unixMode & FILE_ATTR_UNIX_SETGID_MASK);
4878
4920
  const sticky = Boolean(fileEntry.unixMode & FILE_ATTR_UNIX_STICKY_MASK);
4879
- const executable = (fileEntry.unixMode !== UNDEFINED_VALUE)
4921
+ const unixType = fileEntry.unixMode === UNDEFINED_VALUE ? unixExternalUpper : fileEntry.unixMode;
4922
+ const symlink = (unixType & FILE_ATTR_UNIX_TYPE_MASK) == FILE_ATTR_UNIX_TYPE_SYMLINK;
4923
+ const executable = !symlink && ((fileEntry.unixMode !== UNDEFINED_VALUE)
4880
4924
  ? ((fileEntry.unixMode & FILE_ATTR_UNIX_EXECUTABLE_MASK) != 0)
4881
- : (unixCompatible && ((unixExternalUpper & FILE_ATTR_UNIX_EXECUTABLE_MASK) != 0));
4925
+ : (unixCompatible && ((unixExternalUpper & FILE_ATTR_UNIX_EXECUTABLE_MASK) != 0)));
4882
4926
  const modeIsDir = fileEntry.unixMode !== UNDEFINED_VALUE && ((fileEntry.unixMode & FILE_ATTR_UNIX_TYPE_MASK) == FILE_ATTR_UNIX_TYPE_DIR);
4883
4927
  const upperIsDir = ((unixExternalUpper & FILE_ATTR_UNIX_TYPE_MASK) == FILE_ATTR_UNIX_TYPE_DIR);
4884
4928
  Object.assign(fileEntry, {
4885
4929
  setuid,
4886
4930
  setgid,
4887
4931
  sticky,
4932
+ symlink,
4888
4933
  unixExternalUpper,
4889
4934
  internalFileAttribute: fileEntry.internalFileAttributes,
4890
4935
  externalFileAttribute: fileEntry.externalFileAttributes,
@@ -4950,6 +4995,10 @@
4950
4995
  }
4951
4996
 
4952
4997
  async close() {
4998
+ const { reader } = this;
4999
+ if (!reader.readUint8Array && reader.readable && !reader.readable.locked) {
5000
+ await reader.readable.cancel();
5001
+ }
4953
5002
  }
4954
5003
  }
4955
5004
 
@@ -5046,9 +5095,12 @@
5046
5095
  extraFieldLength,
5047
5096
  filenameLength
5048
5097
  } = localDirectory;
5049
- const checkAmbiguity = getStrictness(getOptionValue$1(zipEntry, options, OPTION_STRICTNESS), getOptionValue$1(zipEntry, options, OPTION_CHECK_AMBIGUITY)) == STRICTNESS_STRICT;
5098
+ const checkLocalDirectoryOption = getOptionValue$1(zipEntry, options, OPTION_CHECK_LOCAL_DIRECTORY);
5099
+ const entryStrictness = getStrictness(options, zipEntry.options);
5100
+ const checkLocalDirectory = getCheckLocalDirectory(checkLocalDirectoryOption, entryStrictness);
5101
+ const checkLocalFilename = getCheckLocalFilename(checkLocalDirectoryOption, entryStrictness);
5050
5102
  let rawLocalFilename = EMPTY_UINT8_ARRAY;
5051
- if (checkAmbiguity && (filenameLength || extraFieldLength)) {
5103
+ if (checkLocalFilename && (filenameLength || extraFieldLength)) {
5052
5104
  const trailingDataArray = await readUint8Array(reader, localHeaderOffset + HEADER_SIZE, filenameLength + extraFieldLength);
5053
5105
  rawLocalFilename = trailingDataArray.subarray(0, filenameLength);
5054
5106
  localDirectory.rawExtraField = trailingDataArray.subarray(filenameLength);
@@ -5057,17 +5109,26 @@
5057
5109
  await readUint8Array(reader, localHeaderOffset + HEADER_SIZE + filenameLength, extraFieldLength) :
5058
5110
  EMPTY_UINT8_ARRAY;
5059
5111
  }
5112
+ if (checkLocalFilename) {
5113
+ localDirectory.rawFilename = rawLocalFilename;
5114
+ }
5060
5115
  readCommonFooter(zipEntry, localDirectory, dataView, 4, true);
5061
- if (checkAmbiguity) {
5062
- checkLocalDirectory(zipEntry, localDirectory, rawLocalFilename);
5116
+ if (checkLocalDirectory) {
5117
+ validateLocalDirectory(zipEntry, localDirectory, rawLocalFilename, checkLocalFilename);
5063
5118
  }
5064
- const { lastAccessDate, creationDate } = localDirectory;
5119
+ const { lastAccessDate, creationDate, uid, gid } = localDirectory;
5065
5120
  if (lastAccessDate) {
5066
5121
  fileEntry.lastAccessDate = lastAccessDate;
5067
5122
  }
5068
5123
  if (creationDate) {
5069
5124
  fileEntry.creationDate = creationDate;
5070
5125
  }
5126
+ if (uid !== UNDEFINED_VALUE && fileEntry.uid === UNDEFINED_VALUE) {
5127
+ fileEntry.uid = uid;
5128
+ }
5129
+ if (gid !== UNDEFINED_VALUE && fileEntry.gid === UNDEFINED_VALUE) {
5130
+ fileEntry.gid = gid;
5131
+ }
5071
5132
  const encrypted = zipEntry.encrypted && localDirectory.encrypted && !passThrough;
5072
5133
  const zipCrypto = encrypted && !extraFieldAES;
5073
5134
  if (!passThrough) {
@@ -5174,7 +5235,7 @@
5174
5235
  throw error;
5175
5236
  }
5176
5237
  } finally {
5177
- const preventClose = getOptionValue$1(zipEntry, options, OPTION_PREVENT_CLOSE);
5238
+ const preventClose = !ownsWritable(writer) && getOptionValue$1(zipEntry, options, OPTION_PREVENT_CLOSE);
5178
5239
  if (!preventClose && writable && !writable.locked) {
5179
5240
  const writableWriter = writable.getWriter();
5180
5241
  if (abortError) {
@@ -5303,10 +5364,12 @@
5303
5364
  directory.extraFieldNTFS = extraFieldNTFS;
5304
5365
  }
5305
5366
  const extraFieldUnix = extraField.get(EXTRAFIELD_TYPE_UNIX);
5367
+ let unixIdsRead;
5306
5368
  if (extraFieldUnix) {
5307
- readExtraFieldUnix(extraFieldUnix, directory, false);
5369
+ unixIdsRead = readExtraFieldUnix(extraFieldUnix, directory, false);
5308
5370
  directory.extraFieldUnix = extraFieldUnix;
5309
- } else {
5371
+ }
5372
+ if (!unixIdsRead) {
5310
5373
  const extraFieldInfoZip = extraField.get(EXTRAFIELD_TYPE_INFOZIP);
5311
5374
  if (extraFieldInfoZip) {
5312
5375
  readExtraFieldUnix(extraFieldInfoZip, directory, true);
@@ -5409,7 +5472,7 @@
5409
5472
  const creationDate = getDateNTFS(rawCreationDate);
5410
5473
  const extraFieldData = { lastModDate, lastAccessDate, creationDate };
5411
5474
  Object.assign(extraFieldNTFS, extraFieldData);
5412
- Object.assign(directory, extraFieldData);
5475
+ Object.assign(directory, extraFieldData, { rawLastAccessDate, rawCreationDate });
5413
5476
  }
5414
5477
  }
5415
5478
 
@@ -5418,8 +5481,8 @@
5418
5481
  return;
5419
5482
  }
5420
5483
  const extraFieldView = getDataView(extraField.data);
5421
- const lastAccessDate = new Date(getUint32(extraFieldView, 0) * 1000);
5422
- const lastModDate = new Date(getUint32(extraFieldView, 4) * 1000);
5484
+ const lastAccessDate = new Date((getUint32(extraFieldView, 0) | 0) * 1000);
5485
+ const lastModDate = new Date((getUint32(extraFieldView, 4) | 0) * 1000);
5423
5486
  const extraFieldData = { lastAccessDate, lastModDate };
5424
5487
  if (extraField.data.length >= 12) {
5425
5488
  extraFieldData.uid = getUint16(extraFieldView, 8);
@@ -5453,6 +5516,7 @@
5453
5516
  if (gid !== UNDEFINED_VALUE) {
5454
5517
  directory.gid = gid;
5455
5518
  }
5519
+ return uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE;
5456
5520
  } catch {
5457
5521
  // ignored
5458
5522
  }
@@ -5525,26 +5589,25 @@
5525
5589
  }
5526
5590
  if (dataDescriptorLength) {
5527
5591
  const dataDescriptorArray = await readUint8Array(reader, dataOffset + compressedSize, dataDescriptorLength + DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH);
5528
- const dataDescriptorSignature = dataDescriptorArray.length == dataDescriptorLength + DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH &&
5529
- getUint32(getDataView(dataDescriptorArray), 0) == DATA_DESCRIPTOR_RECORD_SIGNATURE;
5530
- if (dataDescriptorSignature) {
5531
- const readCrc32 = getUint32(getDataView(dataDescriptorArray), 4);
5532
- let readCompressedSize;
5533
- let readUncompressedSize;
5534
- if (extraFieldZip64) {
5535
- readCompressedSize = getBigUint64(getDataView(dataDescriptorArray), 8);
5536
- readUncompressedSize = getBigUint64(getDataView(dataDescriptorArray), 16);
5537
- } else {
5538
- readCompressedSize = getUint32(getDataView(dataDescriptorArray), 8);
5539
- readUncompressedSize = getUint32(getDataView(dataDescriptorArray), 12);
5540
- }
5541
- const matchCrc32 = (fileEntry.encrypted && !fileEntry.zipCrypto) || readCrc32 == crc32;
5592
+ const dataDescriptorView = getDataView(dataDescriptorArray);
5593
+ let signature = dataDescriptorArray.length == dataDescriptorLength + DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH &&
5594
+ getUint32(dataDescriptorView, 0) == DATA_DESCRIPTOR_RECORD_SIGNATURE;
5595
+ if (signature) {
5596
+ const signedDataDescriptor = readDataDescriptor(dataDescriptorView, DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH, extraFieldZip64);
5597
+ const matchCrc32 = (fileEntry.encrypted && !fileEntry.zipCrypto) || signedDataDescriptor.crc32 == crc32;
5542
5598
  if (matchCrc32 &&
5543
- readCompressedSize == compressedSize &&
5544
- readUncompressedSize == uncompressedSize) {
5599
+ signedDataDescriptor.compressedSize == compressedSize &&
5600
+ signedDataDescriptor.uncompressedSize == uncompressedSize) {
5545
5601
  dataDescriptorLength += DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH;
5602
+ } else {
5603
+ signature = false;
5546
5604
  }
5547
5605
  }
5606
+ if (dataDescriptorArray.length >= dataDescriptorLength) {
5607
+ const localDataDescriptor = readDataDescriptor(dataDescriptorView, signature ? DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH : 0, extraFieldZip64);
5608
+ localDataDescriptor.signature = signature;
5609
+ fileEntry.localDirectory.dataDescriptor = localDataDescriptor;
5610
+ }
5548
5611
  }
5549
5612
  const range = {
5550
5613
  start: offset,
@@ -5561,6 +5624,20 @@
5561
5624
  readRanges.set(index, range);
5562
5625
  }
5563
5626
 
5627
+ function readDataDescriptor(dataDescriptorView, offset, extraFieldZip64) {
5628
+ const crc32 = getUint32(dataDescriptorView, offset);
5629
+ let compressedSize;
5630
+ let uncompressedSize;
5631
+ if (extraFieldZip64) {
5632
+ compressedSize = getBigUint64(dataDescriptorView, offset + 4);
5633
+ uncompressedSize = getBigUint64(dataDescriptorView, offset + 12);
5634
+ } else {
5635
+ compressedSize = getUint32(dataDescriptorView, offset + 4);
5636
+ uncompressedSize = getUint32(dataDescriptorView, offset + 8);
5637
+ }
5638
+ return { crc32, compressedSize, uncompressedSize };
5639
+ }
5640
+
5564
5641
  function getDiskOffset$1(reader, diskNumber) {
5565
5642
  return reader.getDiskOffset ? reader.getDiskOffset(diskNumber) : 0;
5566
5643
  }
@@ -5569,14 +5646,40 @@
5569
5646
  return value === STRICTNESS_STRICT || value === STRICTNESS_BALANCED || value === STRICTNESS_TOLERANT;
5570
5647
  }
5571
5648
 
5572
- function getStrictness(strictness, checkAmbiguity) {
5573
- if (strictness === UNDEFINED_VALUE) {
5574
- return checkAmbiguity ? STRICTNESS_STRICT : STRICTNESS_BALANCED;
5649
+ function getStrictness(options, inheritedOptions) {
5650
+ return resolveStrictness(options, resolveStrictness(inheritedOptions, STRICTNESS_BALANCED));
5651
+ }
5652
+
5653
+ function resolveStrictness(options, inheritedStrictness) {
5654
+ const strictness = options[OPTION_STRICTNESS];
5655
+ if (strictness !== UNDEFINED_VALUE) {
5656
+ if (!isStrictnessValue(strictness)) {
5657
+ throw new Error(ERR_INVALID_STRICTNESS);
5658
+ }
5659
+ return strictness;
5575
5660
  }
5576
- if (!isStrictnessValue(strictness)) {
5577
- throw new Error(ERR_INVALID_STRICTNESS);
5661
+ const checkAmbiguity = options[OPTION_CHECK_AMBIGUITY];
5662
+ if (checkAmbiguity === UNDEFINED_VALUE) {
5663
+ return inheritedStrictness;
5664
+ }
5665
+ if (checkAmbiguity) {
5666
+ return STRICTNESS_STRICT;
5667
+ }
5668
+ return inheritedStrictness == STRICTNESS_TOLERANT ? STRICTNESS_TOLERANT : STRICTNESS_BALANCED;
5669
+ }
5670
+
5671
+ function getCheckLocalDirectory(checkLocalDirectory, strictness) {
5672
+ if (checkLocalDirectory === UNDEFINED_VALUE) {
5673
+ return strictness != STRICTNESS_TOLERANT;
5578
5674
  }
5579
- return strictness;
5675
+ return Boolean(checkLocalDirectory);
5676
+ }
5677
+
5678
+ function getCheckLocalFilename(checkLocalFilename, strictness) {
5679
+ if (checkLocalFilename === UNDEFINED_VALUE) {
5680
+ return strictness == STRICTNESS_STRICT;
5681
+ }
5682
+ return Boolean(checkLocalFilename);
5580
5683
  }
5581
5684
 
5582
5685
  function getFilenameValidation(filenameValidation, strictness) {
@@ -5724,10 +5827,11 @@
5724
5827
  return UNDEFINED_VALUE;
5725
5828
  }
5726
5829
 
5727
- function checkLocalDirectory(zipEntry, localDirectory, rawLocalFilename) {
5830
+ function validateLocalDirectory(zipEntry, localDirectory, rawLocalFilename, checkLocalFilename) {
5728
5831
  const { rawFilename } = zipEntry;
5729
- if (rawLocalFilename.length != rawFilename.length ||
5730
- rawLocalFilename.some((byteValue, indexByte) => byteValue != rawFilename[indexByte])) {
5832
+ if (checkLocalFilename &&
5833
+ (rawLocalFilename.length != rawFilename.length ||
5834
+ rawLocalFilename.some((byteValue, indexByte) => byteValue != rawFilename[indexByte]))) {
5731
5835
  throwAmbiguousArchive("mismatched local file header (filename)");
5732
5836
  }
5733
5837
  if ((localDirectory.rawBitFlag & BITFLAG_AMBIGUITY_MASK) != (zipEntry.rawBitFlag & BITFLAG_AMBIGUITY_MASK)) {
@@ -5845,11 +5949,13 @@
5845
5949
 
5846
5950
  const ERR_DUPLICATED_NAME = "File already exists";
5847
5951
  const ERR_INVALID_COMMENT = "Zip file comment exceeds 64KB";
5952
+ const ERR_INVALID_COMMENT_TYPE = "Invalid zip file comment (must be a Uint8Array)";
5848
5953
  const ERR_INVALID_ENTRY_COMMENT = "File entry comment exceeds 64KB";
5849
5954
  const ERR_INVALID_ENTRY_NAME = "File entry name exceeds 64KB";
5850
5955
  const ERR_INVALID_VERSION = "Version exceeds 65535";
5851
5956
  const ERR_INVALID_ENCRYPTION_STRENGTH = "The strength must equal 1, 2, or 3";
5852
5957
  const ERR_UNSUPPORTED_ENCRYPTION_USDZ = "Encryption is not supported in USDZ files";
5958
+ const ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH = "Encryption is not supported when the 'passThrough' option is set";
5853
5959
  const ERR_INVALID_EXTRAFIELD_TYPE = "Extra field type exceeds 65535";
5854
5960
  const ERR_INVALID_EXTRAFIELD_DATA = "Extra field data exceeds 64KB";
5855
5961
  const ERR_UNSUPPORTED_COMPRESSION = "Compression method not supported";
@@ -5859,6 +5965,7 @@
5859
5965
  const MAX_NTFS_TIME = BigInt("0x7fffffffffffffff");
5860
5966
  const ERR_UNSUPPORTED_FORMAT = "Zip64 is not supported (set the 'zip64' option to 'true')";
5861
5967
  const ERR_UNDEFINED_UNCOMPRESSED_SIZE = "Undefined uncompressed size";
5968
+ const ERR_UNDETERMINED_SIZE = "Undetermined size";
5862
5969
  const ERR_UNDEFINED_READER = "Undefined reader";
5863
5970
  const ERR_ZIP_NOT_EMPTY = "Zip file not empty";
5864
5971
  const ERR_INVALID_UID = "Invalid uid (must be integer 0..2^32-1)";
@@ -5911,6 +6018,10 @@
5911
6018
  }
5912
6019
  reader = new GenericReader(reader);
5913
6020
  await initStream(reader);
6021
+ if (reader.size === UNDEFINED_VALUE || !reader.readUint8Array) {
6022
+ reader = new BlobReader(await streamToBlob(reader.readable));
6023
+ await initStream(reader);
6024
+ }
5914
6025
  const { ZipReader } = await Promise.resolve().then(function () { return zipReader; });
5915
6026
  const zipReader$1 = new ZipReader(reader.readable);
5916
6027
  const entries = await zipReader$1.getEntries();
@@ -6059,6 +6170,9 @@
6059
6170
  const zipWriter = this;
6060
6171
  const { pendingAddFileCalls, writer } = this;
6061
6172
  const { writable } = writer;
6173
+ if (!(comment instanceof Uint8Array)) {
6174
+ throw new Error(ERR_INVALID_COMMENT_TYPE);
6175
+ }
6062
6176
  if (getLength(comment) > MAX_16_BITS) {
6063
6177
  throw new Error(ERR_INVALID_COMMENT);
6064
6178
  }
@@ -6066,7 +6180,7 @@
6066
6180
  await Promise.allSettled(Array.from(pendingAddFileCalls));
6067
6181
  }
6068
6182
  await closeFile(zipWriter, comment, options);
6069
- const preventClose = getOptionValue(zipWriter, options, OPTION_PREVENT_CLOSE);
6183
+ const preventClose = !ownsWritable(writer) && getOptionValue(zipWriter, options, OPTION_PREVENT_CLOSE);
6070
6184
  if (!preventClose) {
6071
6185
  await writable.getWriter().close();
6072
6186
  }
@@ -6155,8 +6269,6 @@
6155
6269
  const diskOffset = getDiskOffset(zipWriter.writer);
6156
6270
  const diskNumber = getDiskNumber(zipWriter.writer);
6157
6271
  options = Object.assign({}, options, attributesInfo.resolvedOptions, metadataInfo.resolvedOptions, sizesInfo.resolvedOptions, {
6158
- internalFileAttribute: metadataInfo.resolvedOptions.internalFileAttributes,
6159
- externalFileAttribute: attributesInfo.resolvedOptions.externalFileAttributes,
6160
6272
  signature: options[PROPERTY_NAME_SIGNATURE],
6161
6273
  crc32: options.crc32 === UNDEFINED_VALUE ? options[PROPERTY_NAME_SIGNATURE] : options.crc32,
6162
6274
  offset: zipWriter.offset - diskOffset,
@@ -6170,14 +6282,20 @@
6170
6282
  zipWriter.files.delete(name);
6171
6283
  throw error;
6172
6284
  }
6173
- Object.assign(fileEntry, { name, comment, extraField });
6285
+ Object.assign(fileEntry, {
6286
+ name,
6287
+ comment,
6288
+ extraField,
6289
+ [PROPERTY_NAME_DEPRECATED_INTERNAL_FILE_ATTRIBUTES]: fileEntry.internalFileAttributes,
6290
+ [PROPERTY_NAME_DEPRECATED_EXTERNAL_FILE_ATTRIBUTES]: fileEntry.externalFileAttributes
6291
+ });
6174
6292
  return new Entry(fileEntry);
6175
6293
  }
6176
6294
 
6177
6295
  function resolveAttributes(zipWriter, name, options) {
6178
6296
  name = name.trim();
6179
6297
  let msDosCompatible = getOptionValue(zipWriter, options, PROPERTY_NAME_MS_DOS_COMPATIBLE);
6180
- let versionMadeBy = getOptionValue(zipWriter, options, PROPERTY_NAME_VERSION_MADE_BY, msDosCompatible ? 20 : 768);
6298
+ let versionMadeBy = getOptionValue(zipWriter, options, PROPERTY_NAME_VERSION_MADE_BY, msDosCompatible ? VERSION_MADE_BY_MSDOS : VERSION_MADE_BY_UNIX);
6181
6299
  const executable = getOptionValue(zipWriter, options, PROPERTY_NAME_EXECUTABLE);
6182
6300
  const uid = getNumberOptionValue(zipWriter, options, PROPERTY_NAME_UID);
6183
6301
  const gid = getNumberOptionValue(zipWriter, options, PROPERTY_NAME_GID);
@@ -6211,7 +6329,7 @@
6211
6329
  const hasMsDosProvided = msdosAttributesRaw !== UNDEFINED_VALUE || msdosAttributes !== UNDEFINED_VALUE;
6212
6330
  if (hasUnixMetadata) {
6213
6331
  msDosCompatible = false;
6214
- versionMadeBy = (versionMadeBy & MAX_16_BITS) | (3 << 8);
6332
+ versionMadeBy = (versionMadeBy & MAX_8_BITS) | VERSION_MADE_BY_UNIX;
6215
6333
  } else if (hasMsDosProvided) {
6216
6334
  msDosCompatible = true;
6217
6335
  versionMadeBy = (versionMadeBy & MAX_8_BITS);
@@ -6225,7 +6343,7 @@
6225
6343
  if (versionMadeBy > MAX_16_BITS) {
6226
6344
  throw new Error(ERR_INVALID_VERSION);
6227
6345
  }
6228
- let externalFileAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES);
6346
+ let externalFileAttributes = getAliasedOptionValue(zipWriter, options, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES, PROPERTY_NAME_DEPRECATED_EXTERNAL_FILE_ATTRIBUTES);
6229
6347
  const externalFileAttributesProvided = externalFileAttributes !== UNDEFINED_VALUE;
6230
6348
  if (!externalFileAttributesProvided) {
6231
6349
  externalFileAttributes = 0;
@@ -6251,11 +6369,10 @@
6251
6369
  externalFileAttributes = FILE_ATTR_UNIX_DEFAULT_MASK << 16;
6252
6370
  }
6253
6371
  }
6254
- let unixExternalUpper;
6255
6372
  if (!msDosCompatible) {
6256
6373
  const unixModeProvided = unixMode !== UNDEFINED_VALUE || Boolean(setuid || setgid || sticky);
6257
- unixExternalUpper = (externalFileAttributes >> 16) & MAX_16_BITS;
6258
- unixMode = unixMode === UNDEFINED_VALUE ? unixExternalUpper : (unixMode & MAX_16_BITS);
6374
+ const defaultUnixMode = (externalFileAttributes >> 16) & MAX_16_BITS;
6375
+ unixMode = unixMode === UNDEFINED_VALUE ? defaultUnixMode : (unixMode & MAX_16_BITS);
6259
6376
  if (setuid) {
6260
6377
  unixMode |= FILE_ATTR_UNIX_SETUID_MASK;
6261
6378
  } else {
@@ -6273,7 +6390,9 @@
6273
6390
  }
6274
6391
  if (!externalFileAttributesProvided || unixModeProvided) {
6275
6392
  if (directory) {
6276
- unixMode |= FILE_ATTR_UNIX_TYPE_DIR;
6393
+ unixMode = (unixMode & ~FILE_ATTR_UNIX_TYPE_MASK) | FILE_ATTR_UNIX_TYPE_DIR;
6394
+ } else if (!(unixMode & FILE_ATTR_UNIX_TYPE_MASK)) {
6395
+ unixMode |= FILE_ATTR_UNIX_TYPE_FILE;
6277
6396
  }
6278
6397
  externalFileAttributes = ((unixMode & MAX_16_BITS) << 16) | (externalFileAttributes & MAX_16_BITS);
6279
6398
  }
@@ -6282,17 +6401,20 @@
6282
6401
  if (hasMsDosProvided) {
6283
6402
  externalFileAttributes = (externalFileAttributes & MAX_32_BITS) | (msdosAttributesRaw & MAX_8_BITS);
6284
6403
  }
6404
+ const unixExternalUpper = (externalFileAttributes >> 16) & MAX_16_BITS;
6405
+ const symlink = unixMode !== UNDEFINED_VALUE && ((unixMode & FILE_ATTR_UNIX_TYPE_MASK) == FILE_ATTR_UNIX_TYPE_SYMLINK);
6285
6406
  return {
6286
6407
  name,
6287
6408
  resolvedOptions: {
6288
6409
  versionMadeBy,
6289
- msDosCompatible,
6410
+ msDosCompatible: Boolean(msDosCompatible),
6290
6411
  externalFileAttributes,
6291
6412
  unixExternalUpper,
6292
6413
  uid,
6293
6414
  gid,
6294
6415
  unixMode,
6295
6416
  unixExtraFieldType,
6417
+ symlink,
6296
6418
  setuid,
6297
6419
  setgid,
6298
6420
  sticky,
@@ -6326,15 +6448,12 @@
6326
6448
  const lastModDate = getOptionValue(zipWriter, options, PROPERTY_NAME_LAST_MODIFICATION_DATE, new Date());
6327
6449
  const lastAccessDate = getOptionValue(zipWriter, options, PROPERTY_NAME_LAST_ACCESS_DATE);
6328
6450
  const creationDate = getOptionValue(zipWriter, options, PROPERTY_NAME_CREATION_DATE);
6329
- const internalFileAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES, 0);
6451
+ const internalFileAttributes = getAliasedOptionValue(zipWriter, options, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES, PROPERTY_NAME_DEPRECATED_INTERNAL_FILE_ATTRIBUTES, 0);
6330
6452
  const passThrough = getOptionValue(zipWriter, options, OPTION_PASS_THROUGH);
6331
- let password, rawPassword;
6332
- if (!passThrough) {
6333
- password = getOptionValue(zipWriter, options, OPTION_PASSWORD);
6334
- rawPassword = getOptionValue(zipWriter, options, OPTION_RAW_PASSWORD);
6335
- if ((password && typeof password != STRING_TYPE) || (rawPassword && !(rawPassword instanceof Uint8Array))) {
6336
- throw new Error(ERR_INVALID_PASSWORD_TYPE);
6337
- }
6453
+ const password = getOptionValue(zipWriter, options, OPTION_PASSWORD);
6454
+ const rawPassword = getOptionValue(zipWriter, options, OPTION_RAW_PASSWORD);
6455
+ if ((password && typeof password != STRING_TYPE) || (rawPassword && !(rawPassword instanceof Uint8Array))) {
6456
+ throw new Error(ERR_INVALID_PASSWORD_TYPE);
6338
6457
  }
6339
6458
  const encryptionStrength = getNumberOptionValue(zipWriter, options, OPTION_ENCRYPTION_STRENGTH, 3);
6340
6459
  const zipCrypto = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIPCRYPTO);
@@ -6447,14 +6566,24 @@
6447
6566
  }
6448
6567
 
6449
6568
  async function resolveSizes(zipWriter, reader, { resolvedOptions: metadata }, options) {
6569
+ if (metadata.passThrough && !reader && !getOptionValue(zipWriter, options, PROPERTY_NAME_DIRECTORY)) {
6570
+ throw new Error(ERR_UNDEFINED_READER);
6571
+ }
6572
+ let contentSize;
6573
+ if (reader) {
6574
+ reader = new GenericReader(reader);
6575
+ await initStream(reader);
6576
+ ({ size: contentSize } = reader);
6577
+ }
6578
+ return Object.assign({ reader }, resolveEntrySizes(zipWriter, Boolean(reader), contentSize, metadata, options));
6579
+ }
6580
+
6581
+ function resolveEntrySizes(zipWriter, hasContent, contentSize, metadata, options) {
6450
6582
  const { passThrough, zipCrypto, password, rawPassword, encryptionStrength } = metadata;
6451
6583
  let { dataDescriptor, zip64, level, compressionMethod } = metadata;
6452
6584
  let maximumCompressedSize = 0;
6453
6585
  let uncompressedSize = 0;
6454
- if (passThrough) {
6455
- if (!reader) {
6456
- throw new Error(ERR_UNDEFINED_READER);
6457
- }
6586
+ if (passThrough && hasContent) {
6458
6587
  uncompressedSize = options[PROPERTY_NAME_UNCOMPRESSED_SIZE];
6459
6588
  if (uncompressedSize === UNDEFINED_VALUE) {
6460
6589
  throw new Error(ERR_UNDEFINED_UNCOMPRESSED_SIZE);
@@ -6462,29 +6591,30 @@
6462
6591
  }
6463
6592
  const zip64Enabled = zip64 === true;
6464
6593
  const encrypted = getOptionValue(zipWriter, options, PROPERTY_NAME_ENCRYPTED);
6465
- const encryptedEntry = Boolean(reader) && (Boolean((password && getLength(password)) || (rawPassword && getLength(rawPassword))) || (passThrough && encrypted));
6466
- if (!reader) {
6594
+ if (hasContent && passThrough && !encrypted && getLength(password, rawPassword)) {
6595
+ throw new Error(ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH);
6596
+ }
6597
+ const encryptedEntry = hasContent && (Boolean((password && getLength(password)) || (rawPassword && getLength(rawPassword))) || (passThrough && encrypted));
6598
+ if (!hasContent) {
6467
6599
  level = 0;
6468
6600
  compressionMethod = COMPRESSION_METHOD_STORE;
6469
6601
  }
6470
6602
  const encryptionOverhead = encryptedEntry ? (zipCrypto ? 12 : 16 + encryptionStrength * 4) : 0;
6471
- if (reader) {
6472
- reader = new GenericReader(reader);
6473
- await initStream(reader);
6603
+ if (hasContent) {
6474
6604
  if (!passThrough) {
6475
- if (reader.size === UNDEFINED_VALUE) {
6605
+ if (contentSize === UNDEFINED_VALUE) {
6476
6606
  dataDescriptor = true;
6477
6607
  if (zip64 || zip64 === UNDEFINED_VALUE) {
6478
6608
  zip64 = true;
6479
6609
  uncompressedSize = maximumCompressedSize = MAX_32_BITS + 1;
6480
6610
  }
6481
6611
  } else {
6482
- options.uncompressedSize = uncompressedSize = reader.size;
6483
- maximumCompressedSize = getMaximumCompressedSize(uncompressedSize) + encryptionOverhead;
6612
+ options.uncompressedSize = uncompressedSize = contentSize;
6613
+ maximumCompressedSize = (isCompressed(compressionMethod, level) ? getMaximumCompressedSize(uncompressedSize) : uncompressedSize) + encryptionOverhead;
6484
6614
  }
6485
6615
  } else {
6486
6616
  options.uncompressedSize = uncompressedSize;
6487
- maximumCompressedSize = getMaximumCompressedSize(uncompressedSize) + encryptionOverhead;
6617
+ maximumCompressedSize = contentSize === UNDEFINED_VALUE ? getMaximumCompressedSize(uncompressedSize) + encryptionOverhead : contentSize;
6488
6618
  }
6489
6619
  }
6490
6620
  const zip64UncompressedSize = zip64Enabled || uncompressedSize >= MAX_32_BITS;
@@ -6498,7 +6628,7 @@
6498
6628
  }
6499
6629
  zip64 = zip64 || false;
6500
6630
  return {
6501
- reader,
6631
+ maximumCompressedSize,
6502
6632
  resolvedOptions: {
6503
6633
  dataDescriptor,
6504
6634
  zip64,
@@ -6726,6 +6856,7 @@
6726
6856
  uid,
6727
6857
  gid,
6728
6858
  unixMode,
6859
+ symlink,
6729
6860
  setuid,
6730
6861
  setgid,
6731
6862
  sticky,
@@ -6762,6 +6893,7 @@
6762
6893
  uid,
6763
6894
  gid,
6764
6895
  unixMode,
6896
+ symlink: Boolean(symlink),
6765
6897
  setuid,
6766
6898
  setgid,
6767
6899
  sticky,
@@ -6842,8 +6974,8 @@
6842
6974
  rawLastModDate,
6843
6975
  creationDate,
6844
6976
  lastAccessDate,
6845
- encrypted,
6846
- zipCrypto,
6977
+ encrypted: Boolean(encrypted),
6978
+ zipCrypto: Boolean(zipCrypto),
6847
6979
  size: metadataSize + compressedSize,
6848
6980
  compressionMethod,
6849
6981
  version,
@@ -6883,9 +7015,7 @@
6883
7015
  crc32
6884
7016
  } = options;
6885
7017
  let { version, compressionMethod } = options;
6886
- const compressed = !directory && (compressionMethod === UNDEFINED_VALUE
6887
- ? (level === UNDEFINED_VALUE || level > 0)
6888
- : compressionMethod !== COMPRESSION_METHOD_STORE);
7018
+ const compressed = !directory && isCompressed(compressionMethod, level);
6889
7019
  let rawLocalExtraFieldZip64;
6890
7020
  const uncompressedFile = passThrough || !compressed;
6891
7021
  const zip64ExtraFieldComplete = zip64 && (options.bufferedWrite || !dataDescriptor || ((!zip64UncompressedSize && !zip64CompressedSize) || uncompressedFile));
@@ -7572,6 +7702,16 @@
7572
7702
  return result === UNDEFINED_VALUE ? defaultValue : result;
7573
7703
  }
7574
7704
 
7705
+ function getAliasedOptionValue(zipWriter, options, name, deprecatedName, defaultValue) {
7706
+ const value = getAliasedValue(options, name, deprecatedName);
7707
+ const result = value === UNDEFINED_VALUE ? getAliasedValue(zipWriter.options, name, deprecatedName) : value;
7708
+ return result === UNDEFINED_VALUE ? defaultValue : result;
7709
+ }
7710
+
7711
+ function getAliasedValue(options, name, deprecatedName) {
7712
+ return options[name] === UNDEFINED_VALUE ? options[deprecatedName] : options[name];
7713
+ }
7714
+
7575
7715
  function getNumberOptionValue(zipWriter, options, name, defaultValue) {
7576
7716
  return toNumber(getOptionValue(zipWriter, options, name, defaultValue));
7577
7717
  }
@@ -7584,6 +7724,12 @@
7584
7724
  return uncompressedSize + (5 * (Math.floor(uncompressedSize / 16383) + 1));
7585
7725
  }
7586
7726
 
7727
+ function isCompressed(compressionMethod, level) {
7728
+ return compressionMethod === UNDEFINED_VALUE
7729
+ ? (level === UNDEFINED_VALUE || level > 0)
7730
+ : compressionMethod !== COMPRESSION_METHOD_STORE;
7731
+ }
7732
+
7587
7733
  function setUint8(view, offset, value) {
7588
7734
  view.setUint8(offset, value);
7589
7735
  }
@@ -8182,6 +8328,7 @@
8182
8328
  exports.ERR_INVALID_CODEC_DEFINITION = ERR_INVALID_CODEC_DEFINITION;
8183
8329
  exports.ERR_INVALID_CODEC_MODULE = ERR_INVALID_CODEC_MODULE;
8184
8330
  exports.ERR_INVALID_COMMENT = ERR_INVALID_COMMENT;
8331
+ exports.ERR_INVALID_COMMENT_TYPE = ERR_INVALID_COMMENT_TYPE;
8185
8332
  exports.ERR_INVALID_COMPRESSED_DATA = ERR_INVALID_COMPRESSED_DATA;
8186
8333
  exports.ERR_INVALID_CRC32 = ERR_INVALID_CRC32;
8187
8334
  exports.ERR_INVALID_ENCRYPTION_STRENGTH = ERR_INVALID_ENCRYPTION_STRENGTH;
@@ -8213,11 +8360,13 @@
8213
8360
  exports.ERR_SPLIT_ZIP_FILE = ERR_SPLIT_ZIP_FILE;
8214
8361
  exports.ERR_UNDEFINED_READER = ERR_UNDEFINED_READER;
8215
8362
  exports.ERR_UNDEFINED_UNCOMPRESSED_SIZE = ERR_UNDEFINED_UNCOMPRESSED_SIZE;
8363
+ exports.ERR_UNDETERMINED_SIZE = ERR_UNDETERMINED_SIZE;
8216
8364
  exports.ERR_UNSAFE_FILENAME = ERR_UNSAFE_FILENAME;
8217
8365
  exports.ERR_UNSUPPORTED_COMPRESSION = ERR_UNSUPPORTED_COMPRESSION$1;
8218
8366
  exports.ERR_UNSUPPORTED_CONTEXT = ERR_UNSUPPORTED_CONTEXT;
8219
8367
  exports.ERR_UNSUPPORTED_CRYPTO_API = ERR_UNSUPPORTED_CRYPTO_API;
8220
8368
  exports.ERR_UNSUPPORTED_ENCRYPTION = ERR_UNSUPPORTED_ENCRYPTION;
8369
+ exports.ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH = ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH;
8221
8370
  exports.ERR_UNSUPPORTED_ENCRYPTION_USDZ = ERR_UNSUPPORTED_ENCRYPTION_USDZ;
8222
8371
  exports.ERR_UNSUPPORTED_FORMAT = ERR_UNSUPPORTED_FORMAT;
8223
8372
  exports.ERR_WORKER_STARTUP_TIMEOUT = ERR_WORKER_STARTUP_TIMEOUT;