@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
@@ -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;
@@ -1781,8 +1786,6 @@
1781
1786
  */
1782
1787
 
1783
1788
 
1784
- const HTTP_HEADER_CONTENT_TYPE = "Content-Type";
1785
-
1786
1789
  function toCompatibleReadable(readable) {
1787
1790
  if (readable instanceof ReadableStream) {
1788
1791
  return readable;
@@ -1805,12 +1808,9 @@
1805
1808
 
1806
1809
  function streamToBlob(readable, contentType) {
1807
1810
  readable = toCompatibleReadable(readable);
1811
+ const blobOptions = contentType ? { type: contentType } : {};
1808
1812
  if (responseSupportsGlobalReadable()) {
1809
- const options = {};
1810
- if (contentType) {
1811
- options.headers = [[HTTP_HEADER_CONTENT_TYPE, contentType]];
1812
- }
1813
- return new Response(readable, options).blob();
1813
+ return new Response(readable).blob().then(blob => contentType ? new Blob([blob], blobOptions) : blob);
1814
1814
  }
1815
1815
  const chunks = [];
1816
1816
  return readable
@@ -1819,7 +1819,7 @@
1819
1819
  chunks.push(chunk);
1820
1820
  }
1821
1821
  }))
1822
- .then(() => new Blob(chunks, contentType ? { type: contentType } : {}));
1822
+ .then(() => new Blob(chunks, blobOptions));
1823
1823
  }
1824
1824
 
1825
1825
  function responseSupportsGlobalReadable() {
@@ -2761,6 +2761,7 @@
2761
2761
  worker,
2762
2762
  workerAlive: false,
2763
2763
  terminated: false,
2764
+ startupError: null,
2764
2765
  interface: {
2765
2766
  run: async () => {
2766
2767
  try {
@@ -2788,6 +2789,13 @@
2788
2789
  }
2789
2790
 
2790
2791
  async function runWebWorker(workerData, config) {
2792
+ if (!workerData.worker) {
2793
+ const { startupError } = workerData;
2794
+ workerData.startupError = null;
2795
+ const error = startupError || new Error(ERR_WORKER_STARTUP_TIMEOUT);
2796
+ error.workerStartupFailed = true;
2797
+ throw error;
2798
+ }
2791
2799
  let resolveResult, rejectResult;
2792
2800
  const result = new Promise((resolve, reject) => {
2793
2801
  resolveResult = resolve;
@@ -3001,11 +3009,12 @@
3001
3009
  if (!workerAlive) {
3002
3010
  workerData.worker = null;
3003
3011
  }
3012
+ let error = event.error || new Error(event.message || ERROR_EVENT_TYPE);
3013
+ if (!workerAlive) {
3014
+ error = Object.assign(new Error(error.message || ERROR_EVENT_TYPE), { workerStartupFailed: true });
3015
+ workerData.startupError = error;
3016
+ }
3004
3017
  if (rejectResult) {
3005
- let error = event.error || new Error(event.message || ERROR_EVENT_TYPE);
3006
- if (!workerAlive) {
3007
- error = Object.assign(new Error(error.message || ERROR_EVENT_TYPE), { workerStartupFailed: true });
3008
- }
3009
3018
  rejectResult(error);
3010
3019
  if (writer) {
3011
3020
  writer.releaseLock();
@@ -3350,8 +3359,10 @@
3350
3359
  async pull(controller) {
3351
3360
  const dataSize = size === UNDEFINED_VALUE ? chunkSize : Math.min(chunkSize, size - chunkOffset);
3352
3361
  const data = await readUint8Array(reader, offset + chunkOffset, dataSize);
3353
- controller.enqueue(data);
3354
- if ((chunkOffset + chunkSize > size) || (size === UNDEFINED_VALUE && !data.length && dataSize)) {
3362
+ if (data.length) {
3363
+ controller.enqueue(data);
3364
+ }
3365
+ if ((chunkOffset + chunkSize >= size) || (size === UNDEFINED_VALUE && !data.length && dataSize)) {
3355
3366
  controller.close();
3356
3367
  } else {
3357
3368
  chunkOffset += chunkSize;
@@ -3429,6 +3440,7 @@
3429
3440
  constructor(contentType) {
3430
3441
  super();
3431
3442
  Object.assign(this, {
3443
+ contentType,
3432
3444
  data: "data:" + (contentType || "") + ";base64,",
3433
3445
  pending: []
3434
3446
  });
@@ -3530,6 +3542,7 @@
3530
3542
  return transformStream.writable;
3531
3543
  }
3532
3544
  });
3545
+ writer.contentType = contentType;
3533
3546
  writer.blob = streamToBlob(transformStream.readable, contentType);
3534
3547
  writer.blob.catch(() => { });
3535
3548
  }
@@ -4030,9 +4043,8 @@
4030
4043
 
4031
4044
  async init() {
4032
4045
  const reader = this;
4033
- const { readers } = reader;
4034
4046
  reader.lastDiskNumber = 0;
4035
- await Promise.all(readers.map(diskReader => initStream(diskReader)));
4047
+ const readers = reader.readers = await Promise.all(reader.readers.map(initDiskReader));
4036
4048
  reader.diskOffsets = readers.map(diskReader => {
4037
4049
  const diskOffset = reader.size;
4038
4050
  reader.size += diskReader.size;
@@ -4209,6 +4221,10 @@
4209
4221
  }
4210
4222
  }
4211
4223
 
4224
+ function ownsWritable(writer) {
4225
+ return Boolean(writer && writer.getData);
4226
+ }
4227
+
4212
4228
  function isHttpFamily(url) {
4213
4229
  const { baseURI } = getConfiguration();
4214
4230
  const { protocol } = new URL(url, baseURI);
@@ -4223,6 +4239,16 @@
4223
4239
  }
4224
4240
  }
4225
4241
 
4242
+ async function initDiskReader(diskReader) {
4243
+ diskReader = new GenericReader(diskReader);
4244
+ await initStream(diskReader);
4245
+ if (diskReader.size === UNDEFINED_VALUE || !diskReader.readUint8Array) {
4246
+ diskReader = new BlobReader(await streamToBlob(diskReader.readable));
4247
+ await initStream(diskReader);
4248
+ }
4249
+ return diskReader;
4250
+ }
4251
+
4226
4252
  function readUint8Array(reader, offset, size) {
4227
4253
  return reader.readUint8Array(offset, size);
4228
4254
  }
@@ -4353,6 +4379,8 @@
4353
4379
  const PROPERTY_NAME_RAW_CREATION_DATE = "rawCreationDate";
4354
4380
  const PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES = "internalFileAttributes";
4355
4381
  const PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES = "externalFileAttributes";
4382
+ const PROPERTY_NAME_DEPRECATED_INTERNAL_FILE_ATTRIBUTES = "internalFileAttribute";
4383
+ const PROPERTY_NAME_DEPRECATED_EXTERNAL_FILE_ATTRIBUTES = "externalFileAttribute";
4356
4384
  const PROPERTY_NAME_MSDOS_ATTRIBUTES_RAW = "msdosAttributesRaw";
4357
4385
  const PROPERTY_NAME_MSDOS_ATTRIBUTES = "msdosAttributes";
4358
4386
  const PROPERTY_NAME_MS_DOS_COMPATIBLE = "msDosCompatible";
@@ -4363,6 +4391,7 @@
4363
4391
  const PROPERTY_NAME_ZIPCRYPTO = "zipCrypto";
4364
4392
  const PROPERTY_NAME_DIRECTORY = "directory";
4365
4393
  const PROPERTY_NAME_EXECUTABLE = "executable";
4394
+ const PROPERTY_NAME_SYMLINK = "symlink";
4366
4395
  const PROPERTY_NAME_COMPRESSION_METHOD = "compressionMethod";
4367
4396
  const PROPERTY_NAME_SIGNATURE = "signature";
4368
4397
  const PROPERTY_NAME_CRC32 = "crc32";
@@ -4378,6 +4407,10 @@
4378
4407
  const PROPERTY_NAME_SETGID = "setgid";
4379
4408
  const PROPERTY_NAME_STICKY = "sticky";
4380
4409
  const PROPERTY_NAME_BITFLAG = "bitFlag";
4410
+ const PROPERTY_NAME_RAW_BITFLAG = "rawBitFlag";
4411
+ const PROPERTY_NAME_FILENAME_LENGTH = "filenameLength";
4412
+ const PROPERTY_NAME_EXTRA_FIELD_LENGTH = "extraFieldLength";
4413
+ const PROPERTY_NAME_UNIX_EXTERNAL_UPPER = "unixExternalUpper";
4381
4414
  const PROPERTY_NAME_FILENAME_UTF8 = "filenameUTF8";
4382
4415
  const PROPERTY_NAME_COMMENT_UTF8 = "commentUTF8";
4383
4416
  const PROPERTY_NAME_RAW_EXTRA_FIELD = "rawExtraField";
@@ -4406,6 +4439,8 @@
4406
4439
  PROPERTY_NAME_DISK_NUMBER_START,
4407
4440
  PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES,
4408
4441
  PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES,
4442
+ PROPERTY_NAME_DEPRECATED_INTERNAL_FILE_ATTRIBUTES,
4443
+ PROPERTY_NAME_DEPRECATED_EXTERNAL_FILE_ATTRIBUTES,
4409
4444
  PROPERTY_NAME_MSDOS_ATTRIBUTES_RAW,
4410
4445
  PROPERTY_NAME_MSDOS_ATTRIBUTES,
4411
4446
  PROPERTY_NAME_MS_DOS_COMPATIBLE,
@@ -4416,6 +4451,7 @@
4416
4451
  PROPERTY_NAME_ZIPCRYPTO,
4417
4452
  PROPERTY_NAME_DIRECTORY,
4418
4453
  PROPERTY_NAME_EXECUTABLE,
4454
+ PROPERTY_NAME_SYMLINK,
4419
4455
  PROPERTY_NAME_COMPRESSION_METHOD,
4420
4456
  PROPERTY_NAME_SIGNATURE,
4421
4457
  PROPERTY_NAME_CRC32,
@@ -4427,10 +4463,14 @@
4427
4463
  PROPERTY_NAME_UID,
4428
4464
  PROPERTY_NAME_GID,
4429
4465
  PROPERTY_NAME_UNIX_MODE,
4466
+ PROPERTY_NAME_UNIX_EXTERNAL_UPPER,
4430
4467
  PROPERTY_NAME_SETUID,
4431
4468
  PROPERTY_NAME_SETGID,
4432
4469
  PROPERTY_NAME_STICKY,
4433
4470
  PROPERTY_NAME_BITFLAG,
4471
+ PROPERTY_NAME_RAW_BITFLAG,
4472
+ PROPERTY_NAME_FILENAME_LENGTH,
4473
+ PROPERTY_NAME_EXTRA_FIELD_LENGTH,
4434
4474
  PROPERTY_NAME_FILENAME_UTF8,
4435
4475
  PROPERTY_NAME_COMMENT_UTF8,
4436
4476
  PROPERTY_NAME_RAW_EXTRA_FIELD,
@@ -4492,6 +4532,7 @@
4492
4532
  const OPTION_CHECK_OVERLAPPING_ENTRY_ONLY = "checkOverlappingEntryOnly";
4493
4533
  const OPTION_CHECK_OVERLAPPING_ENTRY = "checkOverlappingEntry";
4494
4534
  const OPTION_CHECK_AMBIGUITY = "checkAmbiguity";
4535
+ const OPTION_CHECK_LOCAL_DIRECTORY = "checkLocalDirectory";
4495
4536
  const OPTION_CHECK_SIGNATURE = "checkSignature";
4496
4537
  const OPTION_CHECK_CRC32 = "checkCrc32";
4497
4538
  const OPTION_CHECK_AUTHENTICATION_CODE = "checkAuthenticationCode";
@@ -4623,7 +4664,7 @@
4623
4664
  if (reader.size < END_OF_CENTRAL_DIR_LENGTH) {
4624
4665
  throw new Error(ERR_BAD_FORMAT);
4625
4666
  }
4626
- const strictness = getStrictness(getOptionValue$1(zipReader, options, OPTION_STRICTNESS), getOptionValue$1(zipReader, options, OPTION_CHECK_AMBIGUITY));
4667
+ const strictness = getStrictness(options, zipReader.options);
4627
4668
  const checkAmbiguity = strictness == STRICTNESS_STRICT;
4628
4669
  const rejectAmbiguousEndOfDirectory = strictness != STRICTNESS_TOLERANT;
4629
4670
  const maxAppendedDataSize = getMaxAppendedDataSize(getOptionValue$1(zipReader, options, OPTION_MAX_APPENDED_DATA_SIZE), strictness);
@@ -4845,6 +4886,7 @@
4845
4886
  index: indexFile,
4846
4887
  versionMadeBy,
4847
4888
  msDosCompatible,
4889
+ zip64: false,
4848
4890
  compressedSize: 0,
4849
4891
  uncompressedSize: 0,
4850
4892
  commentLength,
@@ -4878,15 +4920,18 @@
4878
4920
  const setuid = Boolean(fileEntry.unixMode & FILE_ATTR_UNIX_SETUID_MASK);
4879
4921
  const setgid = Boolean(fileEntry.unixMode & FILE_ATTR_UNIX_SETGID_MASK);
4880
4922
  const sticky = Boolean(fileEntry.unixMode & FILE_ATTR_UNIX_STICKY_MASK);
4881
- const executable = (fileEntry.unixMode !== UNDEFINED_VALUE)
4923
+ const unixType = fileEntry.unixMode === UNDEFINED_VALUE ? unixExternalUpper : fileEntry.unixMode;
4924
+ const symlink = (unixType & FILE_ATTR_UNIX_TYPE_MASK) == FILE_ATTR_UNIX_TYPE_SYMLINK;
4925
+ const executable = !symlink && ((fileEntry.unixMode !== UNDEFINED_VALUE)
4882
4926
  ? ((fileEntry.unixMode & FILE_ATTR_UNIX_EXECUTABLE_MASK) != 0)
4883
- : (unixCompatible && ((unixExternalUpper & FILE_ATTR_UNIX_EXECUTABLE_MASK) != 0));
4927
+ : (unixCompatible && ((unixExternalUpper & FILE_ATTR_UNIX_EXECUTABLE_MASK) != 0)));
4884
4928
  const modeIsDir = fileEntry.unixMode !== UNDEFINED_VALUE && ((fileEntry.unixMode & FILE_ATTR_UNIX_TYPE_MASK) == FILE_ATTR_UNIX_TYPE_DIR);
4885
4929
  const upperIsDir = ((unixExternalUpper & FILE_ATTR_UNIX_TYPE_MASK) == FILE_ATTR_UNIX_TYPE_DIR);
4886
4930
  Object.assign(fileEntry, {
4887
4931
  setuid,
4888
4932
  setgid,
4889
4933
  sticky,
4934
+ symlink,
4890
4935
  unixExternalUpper,
4891
4936
  internalFileAttribute: fileEntry.internalFileAttributes,
4892
4937
  externalFileAttribute: fileEntry.externalFileAttributes,
@@ -4952,6 +4997,10 @@
4952
4997
  }
4953
4998
 
4954
4999
  async close() {
5000
+ const { reader } = this;
5001
+ if (!reader.readUint8Array && reader.readable && !reader.readable.locked) {
5002
+ await reader.readable.cancel();
5003
+ }
4955
5004
  }
4956
5005
  }
4957
5006
 
@@ -5048,9 +5097,12 @@
5048
5097
  extraFieldLength,
5049
5098
  filenameLength
5050
5099
  } = localDirectory;
5051
- const checkAmbiguity = getStrictness(getOptionValue$1(zipEntry, options, OPTION_STRICTNESS), getOptionValue$1(zipEntry, options, OPTION_CHECK_AMBIGUITY)) == STRICTNESS_STRICT;
5100
+ const checkLocalDirectoryOption = getOptionValue$1(zipEntry, options, OPTION_CHECK_LOCAL_DIRECTORY);
5101
+ const entryStrictness = getStrictness(options, zipEntry.options);
5102
+ const checkLocalDirectory = getCheckLocalDirectory(checkLocalDirectoryOption, entryStrictness);
5103
+ const checkLocalFilename = getCheckLocalFilename(checkLocalDirectoryOption, entryStrictness);
5052
5104
  let rawLocalFilename = EMPTY_UINT8_ARRAY;
5053
- if (checkAmbiguity && (filenameLength || extraFieldLength)) {
5105
+ if (checkLocalFilename && (filenameLength || extraFieldLength)) {
5054
5106
  const trailingDataArray = await readUint8Array(reader, localHeaderOffset + HEADER_SIZE, filenameLength + extraFieldLength);
5055
5107
  rawLocalFilename = trailingDataArray.subarray(0, filenameLength);
5056
5108
  localDirectory.rawExtraField = trailingDataArray.subarray(filenameLength);
@@ -5059,17 +5111,26 @@
5059
5111
  await readUint8Array(reader, localHeaderOffset + HEADER_SIZE + filenameLength, extraFieldLength) :
5060
5112
  EMPTY_UINT8_ARRAY;
5061
5113
  }
5114
+ if (checkLocalFilename) {
5115
+ localDirectory.rawFilename = rawLocalFilename;
5116
+ }
5062
5117
  readCommonFooter(zipEntry, localDirectory, dataView, 4, true);
5063
- if (checkAmbiguity) {
5064
- checkLocalDirectory(zipEntry, localDirectory, rawLocalFilename);
5118
+ if (checkLocalDirectory) {
5119
+ validateLocalDirectory(zipEntry, localDirectory, rawLocalFilename, checkLocalFilename);
5065
5120
  }
5066
- const { lastAccessDate, creationDate } = localDirectory;
5121
+ const { lastAccessDate, creationDate, uid, gid } = localDirectory;
5067
5122
  if (lastAccessDate) {
5068
5123
  fileEntry.lastAccessDate = lastAccessDate;
5069
5124
  }
5070
5125
  if (creationDate) {
5071
5126
  fileEntry.creationDate = creationDate;
5072
5127
  }
5128
+ if (uid !== UNDEFINED_VALUE && fileEntry.uid === UNDEFINED_VALUE) {
5129
+ fileEntry.uid = uid;
5130
+ }
5131
+ if (gid !== UNDEFINED_VALUE && fileEntry.gid === UNDEFINED_VALUE) {
5132
+ fileEntry.gid = gid;
5133
+ }
5073
5134
  const encrypted = zipEntry.encrypted && localDirectory.encrypted && !passThrough;
5074
5135
  const zipCrypto = encrypted && !extraFieldAES;
5075
5136
  if (!passThrough) {
@@ -5176,7 +5237,7 @@
5176
5237
  throw error;
5177
5238
  }
5178
5239
  } finally {
5179
- const preventClose = getOptionValue$1(zipEntry, options, OPTION_PREVENT_CLOSE);
5240
+ const preventClose = !ownsWritable(writer) && getOptionValue$1(zipEntry, options, OPTION_PREVENT_CLOSE);
5180
5241
  if (!preventClose && writable && !writable.locked) {
5181
5242
  const writableWriter = writable.getWriter();
5182
5243
  if (abortError) {
@@ -5305,10 +5366,12 @@
5305
5366
  directory.extraFieldNTFS = extraFieldNTFS;
5306
5367
  }
5307
5368
  const extraFieldUnix = extraField.get(EXTRAFIELD_TYPE_UNIX);
5369
+ let unixIdsRead;
5308
5370
  if (extraFieldUnix) {
5309
- readExtraFieldUnix(extraFieldUnix, directory, false);
5371
+ unixIdsRead = readExtraFieldUnix(extraFieldUnix, directory, false);
5310
5372
  directory.extraFieldUnix = extraFieldUnix;
5311
- } else {
5373
+ }
5374
+ if (!unixIdsRead) {
5312
5375
  const extraFieldInfoZip = extraField.get(EXTRAFIELD_TYPE_INFOZIP);
5313
5376
  if (extraFieldInfoZip) {
5314
5377
  readExtraFieldUnix(extraFieldInfoZip, directory, true);
@@ -5411,7 +5474,7 @@
5411
5474
  const creationDate = getDateNTFS(rawCreationDate);
5412
5475
  const extraFieldData = { lastModDate, lastAccessDate, creationDate };
5413
5476
  Object.assign(extraFieldNTFS, extraFieldData);
5414
- Object.assign(directory, extraFieldData);
5477
+ Object.assign(directory, extraFieldData, { rawLastAccessDate, rawCreationDate });
5415
5478
  }
5416
5479
  }
5417
5480
 
@@ -5420,8 +5483,8 @@
5420
5483
  return;
5421
5484
  }
5422
5485
  const extraFieldView = getDataView(extraField.data);
5423
- const lastAccessDate = new Date(getUint32(extraFieldView, 0) * 1000);
5424
- const lastModDate = new Date(getUint32(extraFieldView, 4) * 1000);
5486
+ const lastAccessDate = new Date((getUint32(extraFieldView, 0) | 0) * 1000);
5487
+ const lastModDate = new Date((getUint32(extraFieldView, 4) | 0) * 1000);
5425
5488
  const extraFieldData = { lastAccessDate, lastModDate };
5426
5489
  if (extraField.data.length >= 12) {
5427
5490
  extraFieldData.uid = getUint16(extraFieldView, 8);
@@ -5455,6 +5518,7 @@
5455
5518
  if (gid !== UNDEFINED_VALUE) {
5456
5519
  directory.gid = gid;
5457
5520
  }
5521
+ return uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE;
5458
5522
  } catch {
5459
5523
  // ignored
5460
5524
  }
@@ -5527,26 +5591,25 @@
5527
5591
  }
5528
5592
  if (dataDescriptorLength) {
5529
5593
  const dataDescriptorArray = await readUint8Array(reader, dataOffset + compressedSize, dataDescriptorLength + DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH);
5530
- const dataDescriptorSignature = dataDescriptorArray.length == dataDescriptorLength + DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH &&
5531
- getUint32(getDataView(dataDescriptorArray), 0) == DATA_DESCRIPTOR_RECORD_SIGNATURE;
5532
- if (dataDescriptorSignature) {
5533
- const readCrc32 = getUint32(getDataView(dataDescriptorArray), 4);
5534
- let readCompressedSize;
5535
- let readUncompressedSize;
5536
- if (extraFieldZip64) {
5537
- readCompressedSize = getBigUint64(getDataView(dataDescriptorArray), 8);
5538
- readUncompressedSize = getBigUint64(getDataView(dataDescriptorArray), 16);
5539
- } else {
5540
- readCompressedSize = getUint32(getDataView(dataDescriptorArray), 8);
5541
- readUncompressedSize = getUint32(getDataView(dataDescriptorArray), 12);
5542
- }
5543
- const matchCrc32 = (fileEntry.encrypted && !fileEntry.zipCrypto) || readCrc32 == crc32;
5594
+ const dataDescriptorView = getDataView(dataDescriptorArray);
5595
+ let signature = dataDescriptorArray.length == dataDescriptorLength + DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH &&
5596
+ getUint32(dataDescriptorView, 0) == DATA_DESCRIPTOR_RECORD_SIGNATURE;
5597
+ if (signature) {
5598
+ const signedDataDescriptor = readDataDescriptor(dataDescriptorView, DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH, extraFieldZip64);
5599
+ const matchCrc32 = (fileEntry.encrypted && !fileEntry.zipCrypto) || signedDataDescriptor.crc32 == crc32;
5544
5600
  if (matchCrc32 &&
5545
- readCompressedSize == compressedSize &&
5546
- readUncompressedSize == uncompressedSize) {
5601
+ signedDataDescriptor.compressedSize == compressedSize &&
5602
+ signedDataDescriptor.uncompressedSize == uncompressedSize) {
5547
5603
  dataDescriptorLength += DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH;
5604
+ } else {
5605
+ signature = false;
5548
5606
  }
5549
5607
  }
5608
+ if (dataDescriptorArray.length >= dataDescriptorLength) {
5609
+ const localDataDescriptor = readDataDescriptor(dataDescriptorView, signature ? DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH : 0, extraFieldZip64);
5610
+ localDataDescriptor.signature = signature;
5611
+ fileEntry.localDirectory.dataDescriptor = localDataDescriptor;
5612
+ }
5550
5613
  }
5551
5614
  const range = {
5552
5615
  start: offset,
@@ -5563,6 +5626,20 @@
5563
5626
  readRanges.set(index, range);
5564
5627
  }
5565
5628
 
5629
+ function readDataDescriptor(dataDescriptorView, offset, extraFieldZip64) {
5630
+ const crc32 = getUint32(dataDescriptorView, offset);
5631
+ let compressedSize;
5632
+ let uncompressedSize;
5633
+ if (extraFieldZip64) {
5634
+ compressedSize = getBigUint64(dataDescriptorView, offset + 4);
5635
+ uncompressedSize = getBigUint64(dataDescriptorView, offset + 12);
5636
+ } else {
5637
+ compressedSize = getUint32(dataDescriptorView, offset + 4);
5638
+ uncompressedSize = getUint32(dataDescriptorView, offset + 8);
5639
+ }
5640
+ return { crc32, compressedSize, uncompressedSize };
5641
+ }
5642
+
5566
5643
  function getDiskOffset$1(reader, diskNumber) {
5567
5644
  return reader.getDiskOffset ? reader.getDiskOffset(diskNumber) : 0;
5568
5645
  }
@@ -5571,14 +5648,40 @@
5571
5648
  return value === STRICTNESS_STRICT || value === STRICTNESS_BALANCED || value === STRICTNESS_TOLERANT;
5572
5649
  }
5573
5650
 
5574
- function getStrictness(strictness, checkAmbiguity) {
5575
- if (strictness === UNDEFINED_VALUE) {
5576
- return checkAmbiguity ? STRICTNESS_STRICT : STRICTNESS_BALANCED;
5651
+ function getStrictness(options, inheritedOptions) {
5652
+ return resolveStrictness(options, resolveStrictness(inheritedOptions, STRICTNESS_BALANCED));
5653
+ }
5654
+
5655
+ function resolveStrictness(options, inheritedStrictness) {
5656
+ const strictness = options[OPTION_STRICTNESS];
5657
+ if (strictness !== UNDEFINED_VALUE) {
5658
+ if (!isStrictnessValue(strictness)) {
5659
+ throw new Error(ERR_INVALID_STRICTNESS);
5660
+ }
5661
+ return strictness;
5577
5662
  }
5578
- if (!isStrictnessValue(strictness)) {
5579
- throw new Error(ERR_INVALID_STRICTNESS);
5663
+ const checkAmbiguity = options[OPTION_CHECK_AMBIGUITY];
5664
+ if (checkAmbiguity === UNDEFINED_VALUE) {
5665
+ return inheritedStrictness;
5666
+ }
5667
+ if (checkAmbiguity) {
5668
+ return STRICTNESS_STRICT;
5669
+ }
5670
+ return inheritedStrictness == STRICTNESS_TOLERANT ? STRICTNESS_TOLERANT : STRICTNESS_BALANCED;
5671
+ }
5672
+
5673
+ function getCheckLocalDirectory(checkLocalDirectory, strictness) {
5674
+ if (checkLocalDirectory === UNDEFINED_VALUE) {
5675
+ return strictness != STRICTNESS_TOLERANT;
5580
5676
  }
5581
- return strictness;
5677
+ return Boolean(checkLocalDirectory);
5678
+ }
5679
+
5680
+ function getCheckLocalFilename(checkLocalFilename, strictness) {
5681
+ if (checkLocalFilename === UNDEFINED_VALUE) {
5682
+ return strictness == STRICTNESS_STRICT;
5683
+ }
5684
+ return Boolean(checkLocalFilename);
5582
5685
  }
5583
5686
 
5584
5687
  function getFilenameValidation(filenameValidation, strictness) {
@@ -5726,10 +5829,11 @@
5726
5829
  return UNDEFINED_VALUE;
5727
5830
  }
5728
5831
 
5729
- function checkLocalDirectory(zipEntry, localDirectory, rawLocalFilename) {
5832
+ function validateLocalDirectory(zipEntry, localDirectory, rawLocalFilename, checkLocalFilename) {
5730
5833
  const { rawFilename } = zipEntry;
5731
- if (rawLocalFilename.length != rawFilename.length ||
5732
- rawLocalFilename.some((byteValue, indexByte) => byteValue != rawFilename[indexByte])) {
5834
+ if (checkLocalFilename &&
5835
+ (rawLocalFilename.length != rawFilename.length ||
5836
+ rawLocalFilename.some((byteValue, indexByte) => byteValue != rawFilename[indexByte]))) {
5733
5837
  throwAmbiguousArchive("mismatched local file header (filename)");
5734
5838
  }
5735
5839
  if ((localDirectory.rawBitFlag & BITFLAG_AMBIGUITY_MASK) != (zipEntry.rawBitFlag & BITFLAG_AMBIGUITY_MASK)) {
@@ -5847,11 +5951,13 @@
5847
5951
 
5848
5952
  const ERR_DUPLICATED_NAME = "File already exists";
5849
5953
  const ERR_INVALID_COMMENT = "Zip file comment exceeds 64KB";
5954
+ const ERR_INVALID_COMMENT_TYPE = "Invalid zip file comment (must be a Uint8Array)";
5850
5955
  const ERR_INVALID_ENTRY_COMMENT = "File entry comment exceeds 64KB";
5851
5956
  const ERR_INVALID_ENTRY_NAME = "File entry name exceeds 64KB";
5852
5957
  const ERR_INVALID_VERSION = "Version exceeds 65535";
5853
5958
  const ERR_INVALID_ENCRYPTION_STRENGTH = "The strength must equal 1, 2, or 3";
5854
5959
  const ERR_UNSUPPORTED_ENCRYPTION_USDZ = "Encryption is not supported in USDZ files";
5960
+ const ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH = "Encryption is not supported when the 'passThrough' option is set";
5855
5961
  const ERR_INVALID_EXTRAFIELD_TYPE = "Extra field type exceeds 65535";
5856
5962
  const ERR_INVALID_EXTRAFIELD_DATA = "Extra field data exceeds 64KB";
5857
5963
  const ERR_UNSUPPORTED_COMPRESSION = "Compression method not supported";
@@ -5861,6 +5967,7 @@
5861
5967
  const MAX_NTFS_TIME = BigInt("0x7fffffffffffffff");
5862
5968
  const ERR_UNSUPPORTED_FORMAT = "Zip64 is not supported (set the 'zip64' option to 'true')";
5863
5969
  const ERR_UNDEFINED_UNCOMPRESSED_SIZE = "Undefined uncompressed size";
5970
+ const ERR_UNDETERMINED_SIZE = "Undetermined size";
5864
5971
  const ERR_UNDEFINED_READER = "Undefined reader";
5865
5972
  const ERR_ZIP_NOT_EMPTY = "Zip file not empty";
5866
5973
  const ERR_INVALID_UID = "Invalid uid (must be integer 0..2^32-1)";
@@ -5913,6 +6020,10 @@
5913
6020
  }
5914
6021
  reader = new GenericReader(reader);
5915
6022
  await initStream(reader);
6023
+ if (reader.size === UNDEFINED_VALUE || !reader.readUint8Array) {
6024
+ reader = new BlobReader(await streamToBlob(reader.readable));
6025
+ await initStream(reader);
6026
+ }
5916
6027
  const { ZipReader } = await Promise.resolve().then(function () { return zipReader; });
5917
6028
  const zipReader$1 = new ZipReader(reader.readable);
5918
6029
  const entries = await zipReader$1.getEntries();
@@ -6061,6 +6172,9 @@
6061
6172
  const zipWriter = this;
6062
6173
  const { pendingAddFileCalls, writer } = this;
6063
6174
  const { writable } = writer;
6175
+ if (!(comment instanceof Uint8Array)) {
6176
+ throw new Error(ERR_INVALID_COMMENT_TYPE);
6177
+ }
6064
6178
  if (getLength(comment) > MAX_16_BITS) {
6065
6179
  throw new Error(ERR_INVALID_COMMENT);
6066
6180
  }
@@ -6068,7 +6182,7 @@
6068
6182
  await Promise.allSettled(Array.from(pendingAddFileCalls));
6069
6183
  }
6070
6184
  await closeFile(zipWriter, comment, options);
6071
- const preventClose = getOptionValue(zipWriter, options, OPTION_PREVENT_CLOSE);
6185
+ const preventClose = !ownsWritable(writer) && getOptionValue(zipWriter, options, OPTION_PREVENT_CLOSE);
6072
6186
  if (!preventClose) {
6073
6187
  await writable.getWriter().close();
6074
6188
  }
@@ -6157,8 +6271,6 @@
6157
6271
  const diskOffset = getDiskOffset(zipWriter.writer);
6158
6272
  const diskNumber = getDiskNumber(zipWriter.writer);
6159
6273
  options = Object.assign({}, options, attributesInfo.resolvedOptions, metadataInfo.resolvedOptions, sizesInfo.resolvedOptions, {
6160
- internalFileAttribute: metadataInfo.resolvedOptions.internalFileAttributes,
6161
- externalFileAttribute: attributesInfo.resolvedOptions.externalFileAttributes,
6162
6274
  signature: options[PROPERTY_NAME_SIGNATURE],
6163
6275
  crc32: options.crc32 === UNDEFINED_VALUE ? options[PROPERTY_NAME_SIGNATURE] : options.crc32,
6164
6276
  offset: zipWriter.offset - diskOffset,
@@ -6172,14 +6284,20 @@
6172
6284
  zipWriter.files.delete(name);
6173
6285
  throw error;
6174
6286
  }
6175
- Object.assign(fileEntry, { name, comment, extraField });
6287
+ Object.assign(fileEntry, {
6288
+ name,
6289
+ comment,
6290
+ extraField,
6291
+ [PROPERTY_NAME_DEPRECATED_INTERNAL_FILE_ATTRIBUTES]: fileEntry.internalFileAttributes,
6292
+ [PROPERTY_NAME_DEPRECATED_EXTERNAL_FILE_ATTRIBUTES]: fileEntry.externalFileAttributes
6293
+ });
6176
6294
  return new Entry(fileEntry);
6177
6295
  }
6178
6296
 
6179
6297
  function resolveAttributes(zipWriter, name, options) {
6180
6298
  name = name.trim();
6181
6299
  let msDosCompatible = getOptionValue(zipWriter, options, PROPERTY_NAME_MS_DOS_COMPATIBLE);
6182
- let versionMadeBy = getOptionValue(zipWriter, options, PROPERTY_NAME_VERSION_MADE_BY, msDosCompatible ? 20 : 768);
6300
+ let versionMadeBy = getOptionValue(zipWriter, options, PROPERTY_NAME_VERSION_MADE_BY, msDosCompatible ? VERSION_MADE_BY_MSDOS : VERSION_MADE_BY_UNIX);
6183
6301
  const executable = getOptionValue(zipWriter, options, PROPERTY_NAME_EXECUTABLE);
6184
6302
  const uid = getNumberOptionValue(zipWriter, options, PROPERTY_NAME_UID);
6185
6303
  const gid = getNumberOptionValue(zipWriter, options, PROPERTY_NAME_GID);
@@ -6213,7 +6331,7 @@
6213
6331
  const hasMsDosProvided = msdosAttributesRaw !== UNDEFINED_VALUE || msdosAttributes !== UNDEFINED_VALUE;
6214
6332
  if (hasUnixMetadata) {
6215
6333
  msDosCompatible = false;
6216
- versionMadeBy = (versionMadeBy & MAX_16_BITS) | (3 << 8);
6334
+ versionMadeBy = (versionMadeBy & MAX_8_BITS) | VERSION_MADE_BY_UNIX;
6217
6335
  } else if (hasMsDosProvided) {
6218
6336
  msDosCompatible = true;
6219
6337
  versionMadeBy = (versionMadeBy & MAX_8_BITS);
@@ -6227,7 +6345,7 @@
6227
6345
  if (versionMadeBy > MAX_16_BITS) {
6228
6346
  throw new Error(ERR_INVALID_VERSION);
6229
6347
  }
6230
- let externalFileAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES);
6348
+ let externalFileAttributes = getAliasedOptionValue(zipWriter, options, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES, PROPERTY_NAME_DEPRECATED_EXTERNAL_FILE_ATTRIBUTES);
6231
6349
  const externalFileAttributesProvided = externalFileAttributes !== UNDEFINED_VALUE;
6232
6350
  if (!externalFileAttributesProvided) {
6233
6351
  externalFileAttributes = 0;
@@ -6253,11 +6371,10 @@
6253
6371
  externalFileAttributes = FILE_ATTR_UNIX_DEFAULT_MASK << 16;
6254
6372
  }
6255
6373
  }
6256
- let unixExternalUpper;
6257
6374
  if (!msDosCompatible) {
6258
6375
  const unixModeProvided = unixMode !== UNDEFINED_VALUE || Boolean(setuid || setgid || sticky);
6259
- unixExternalUpper = (externalFileAttributes >> 16) & MAX_16_BITS;
6260
- unixMode = unixMode === UNDEFINED_VALUE ? unixExternalUpper : (unixMode & MAX_16_BITS);
6376
+ const defaultUnixMode = (externalFileAttributes >> 16) & MAX_16_BITS;
6377
+ unixMode = unixMode === UNDEFINED_VALUE ? defaultUnixMode : (unixMode & MAX_16_BITS);
6261
6378
  if (setuid) {
6262
6379
  unixMode |= FILE_ATTR_UNIX_SETUID_MASK;
6263
6380
  } else {
@@ -6275,7 +6392,9 @@
6275
6392
  }
6276
6393
  if (!externalFileAttributesProvided || unixModeProvided) {
6277
6394
  if (directory) {
6278
- unixMode |= FILE_ATTR_UNIX_TYPE_DIR;
6395
+ unixMode = (unixMode & ~FILE_ATTR_UNIX_TYPE_MASK) | FILE_ATTR_UNIX_TYPE_DIR;
6396
+ } else if (!(unixMode & FILE_ATTR_UNIX_TYPE_MASK)) {
6397
+ unixMode |= FILE_ATTR_UNIX_TYPE_FILE;
6279
6398
  }
6280
6399
  externalFileAttributes = ((unixMode & MAX_16_BITS) << 16) | (externalFileAttributes & MAX_16_BITS);
6281
6400
  }
@@ -6284,17 +6403,20 @@
6284
6403
  if (hasMsDosProvided) {
6285
6404
  externalFileAttributes = (externalFileAttributes & MAX_32_BITS) | (msdosAttributesRaw & MAX_8_BITS);
6286
6405
  }
6406
+ const unixExternalUpper = (externalFileAttributes >> 16) & MAX_16_BITS;
6407
+ const symlink = unixMode !== UNDEFINED_VALUE && ((unixMode & FILE_ATTR_UNIX_TYPE_MASK) == FILE_ATTR_UNIX_TYPE_SYMLINK);
6287
6408
  return {
6288
6409
  name,
6289
6410
  resolvedOptions: {
6290
6411
  versionMadeBy,
6291
- msDosCompatible,
6412
+ msDosCompatible: Boolean(msDosCompatible),
6292
6413
  externalFileAttributes,
6293
6414
  unixExternalUpper,
6294
6415
  uid,
6295
6416
  gid,
6296
6417
  unixMode,
6297
6418
  unixExtraFieldType,
6419
+ symlink,
6298
6420
  setuid,
6299
6421
  setgid,
6300
6422
  sticky,
@@ -6328,15 +6450,12 @@
6328
6450
  const lastModDate = getOptionValue(zipWriter, options, PROPERTY_NAME_LAST_MODIFICATION_DATE, new Date());
6329
6451
  const lastAccessDate = getOptionValue(zipWriter, options, PROPERTY_NAME_LAST_ACCESS_DATE);
6330
6452
  const creationDate = getOptionValue(zipWriter, options, PROPERTY_NAME_CREATION_DATE);
6331
- const internalFileAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES, 0);
6453
+ const internalFileAttributes = getAliasedOptionValue(zipWriter, options, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES, PROPERTY_NAME_DEPRECATED_INTERNAL_FILE_ATTRIBUTES, 0);
6332
6454
  const passThrough = getOptionValue(zipWriter, options, OPTION_PASS_THROUGH);
6333
- let password, rawPassword;
6334
- if (!passThrough) {
6335
- password = getOptionValue(zipWriter, options, OPTION_PASSWORD);
6336
- rawPassword = getOptionValue(zipWriter, options, OPTION_RAW_PASSWORD);
6337
- if ((password && typeof password != STRING_TYPE) || (rawPassword && !(rawPassword instanceof Uint8Array))) {
6338
- throw new Error(ERR_INVALID_PASSWORD_TYPE);
6339
- }
6455
+ const password = getOptionValue(zipWriter, options, OPTION_PASSWORD);
6456
+ const rawPassword = getOptionValue(zipWriter, options, OPTION_RAW_PASSWORD);
6457
+ if ((password && typeof password != STRING_TYPE) || (rawPassword && !(rawPassword instanceof Uint8Array))) {
6458
+ throw new Error(ERR_INVALID_PASSWORD_TYPE);
6340
6459
  }
6341
6460
  const encryptionStrength = getNumberOptionValue(zipWriter, options, OPTION_ENCRYPTION_STRENGTH, 3);
6342
6461
  const zipCrypto = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIPCRYPTO);
@@ -6449,14 +6568,24 @@
6449
6568
  }
6450
6569
 
6451
6570
  async function resolveSizes(zipWriter, reader, { resolvedOptions: metadata }, options) {
6571
+ if (metadata.passThrough && !reader && !getOptionValue(zipWriter, options, PROPERTY_NAME_DIRECTORY)) {
6572
+ throw new Error(ERR_UNDEFINED_READER);
6573
+ }
6574
+ let contentSize;
6575
+ if (reader) {
6576
+ reader = new GenericReader(reader);
6577
+ await initStream(reader);
6578
+ ({ size: contentSize } = reader);
6579
+ }
6580
+ return Object.assign({ reader }, resolveEntrySizes(zipWriter, Boolean(reader), contentSize, metadata, options));
6581
+ }
6582
+
6583
+ function resolveEntrySizes(zipWriter, hasContent, contentSize, metadata, options) {
6452
6584
  const { passThrough, zipCrypto, password, rawPassword, encryptionStrength } = metadata;
6453
6585
  let { dataDescriptor, zip64, level, compressionMethod } = metadata;
6454
6586
  let maximumCompressedSize = 0;
6455
6587
  let uncompressedSize = 0;
6456
- if (passThrough) {
6457
- if (!reader) {
6458
- throw new Error(ERR_UNDEFINED_READER);
6459
- }
6588
+ if (passThrough && hasContent) {
6460
6589
  uncompressedSize = options[PROPERTY_NAME_UNCOMPRESSED_SIZE];
6461
6590
  if (uncompressedSize === UNDEFINED_VALUE) {
6462
6591
  throw new Error(ERR_UNDEFINED_UNCOMPRESSED_SIZE);
@@ -6464,29 +6593,30 @@
6464
6593
  }
6465
6594
  const zip64Enabled = zip64 === true;
6466
6595
  const encrypted = getOptionValue(zipWriter, options, PROPERTY_NAME_ENCRYPTED);
6467
- const encryptedEntry = Boolean(reader) && (Boolean((password && getLength(password)) || (rawPassword && getLength(rawPassword))) || (passThrough && encrypted));
6468
- if (!reader) {
6596
+ if (hasContent && passThrough && !encrypted && getLength(password, rawPassword)) {
6597
+ throw new Error(ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH);
6598
+ }
6599
+ const encryptedEntry = hasContent && (Boolean((password && getLength(password)) || (rawPassword && getLength(rawPassword))) || (passThrough && encrypted));
6600
+ if (!hasContent) {
6469
6601
  level = 0;
6470
6602
  compressionMethod = COMPRESSION_METHOD_STORE;
6471
6603
  }
6472
6604
  const encryptionOverhead = encryptedEntry ? (zipCrypto ? 12 : 16 + encryptionStrength * 4) : 0;
6473
- if (reader) {
6474
- reader = new GenericReader(reader);
6475
- await initStream(reader);
6605
+ if (hasContent) {
6476
6606
  if (!passThrough) {
6477
- if (reader.size === UNDEFINED_VALUE) {
6607
+ if (contentSize === UNDEFINED_VALUE) {
6478
6608
  dataDescriptor = true;
6479
6609
  if (zip64 || zip64 === UNDEFINED_VALUE) {
6480
6610
  zip64 = true;
6481
6611
  uncompressedSize = maximumCompressedSize = MAX_32_BITS + 1;
6482
6612
  }
6483
6613
  } else {
6484
- options.uncompressedSize = uncompressedSize = reader.size;
6485
- maximumCompressedSize = getMaximumCompressedSize(uncompressedSize) + encryptionOverhead;
6614
+ options.uncompressedSize = uncompressedSize = contentSize;
6615
+ maximumCompressedSize = (isCompressed(compressionMethod, level) ? getMaximumCompressedSize(uncompressedSize) : uncompressedSize) + encryptionOverhead;
6486
6616
  }
6487
6617
  } else {
6488
6618
  options.uncompressedSize = uncompressedSize;
6489
- maximumCompressedSize = getMaximumCompressedSize(uncompressedSize) + encryptionOverhead;
6619
+ maximumCompressedSize = contentSize === UNDEFINED_VALUE ? getMaximumCompressedSize(uncompressedSize) + encryptionOverhead : contentSize;
6490
6620
  }
6491
6621
  }
6492
6622
  const zip64UncompressedSize = zip64Enabled || uncompressedSize >= MAX_32_BITS;
@@ -6500,7 +6630,7 @@
6500
6630
  }
6501
6631
  zip64 = zip64 || false;
6502
6632
  return {
6503
- reader,
6633
+ maximumCompressedSize,
6504
6634
  resolvedOptions: {
6505
6635
  dataDescriptor,
6506
6636
  zip64,
@@ -6728,6 +6858,7 @@
6728
6858
  uid,
6729
6859
  gid,
6730
6860
  unixMode,
6861
+ symlink,
6731
6862
  setuid,
6732
6863
  setgid,
6733
6864
  sticky,
@@ -6764,6 +6895,7 @@
6764
6895
  uid,
6765
6896
  gid,
6766
6897
  unixMode,
6898
+ symlink: Boolean(symlink),
6767
6899
  setuid,
6768
6900
  setgid,
6769
6901
  sticky,
@@ -6844,8 +6976,8 @@
6844
6976
  rawLastModDate,
6845
6977
  creationDate,
6846
6978
  lastAccessDate,
6847
- encrypted,
6848
- zipCrypto,
6979
+ encrypted: Boolean(encrypted),
6980
+ zipCrypto: Boolean(zipCrypto),
6849
6981
  size: metadataSize + compressedSize,
6850
6982
  compressionMethod,
6851
6983
  version,
@@ -6885,9 +7017,7 @@
6885
7017
  crc32
6886
7018
  } = options;
6887
7019
  let { version, compressionMethod } = options;
6888
- const compressed = !directory && (compressionMethod === UNDEFINED_VALUE
6889
- ? (level === UNDEFINED_VALUE || level > 0)
6890
- : compressionMethod !== COMPRESSION_METHOD_STORE);
7020
+ const compressed = !directory && isCompressed(compressionMethod, level);
6891
7021
  let rawLocalExtraFieldZip64;
6892
7022
  const uncompressedFile = passThrough || !compressed;
6893
7023
  const zip64ExtraFieldComplete = zip64 && (options.bufferedWrite || !dataDescriptor || ((!zip64UncompressedSize && !zip64CompressedSize) || uncompressedFile));
@@ -7574,6 +7704,16 @@
7574
7704
  return result === UNDEFINED_VALUE ? defaultValue : result;
7575
7705
  }
7576
7706
 
7707
+ function getAliasedOptionValue(zipWriter, options, name, deprecatedName, defaultValue) {
7708
+ const value = getAliasedValue(options, name, deprecatedName);
7709
+ const result = value === UNDEFINED_VALUE ? getAliasedValue(zipWriter.options, name, deprecatedName) : value;
7710
+ return result === UNDEFINED_VALUE ? defaultValue : result;
7711
+ }
7712
+
7713
+ function getAliasedValue(options, name, deprecatedName) {
7714
+ return options[name] === UNDEFINED_VALUE ? options[deprecatedName] : options[name];
7715
+ }
7716
+
7577
7717
  function getNumberOptionValue(zipWriter, options, name, defaultValue) {
7578
7718
  return toNumber(getOptionValue(zipWriter, options, name, defaultValue));
7579
7719
  }
@@ -7586,6 +7726,12 @@
7586
7726
  return uncompressedSize + (5 * (Math.floor(uncompressedSize / 16383) + 1));
7587
7727
  }
7588
7728
 
7729
+ function isCompressed(compressionMethod, level) {
7730
+ return compressionMethod === UNDEFINED_VALUE
7731
+ ? (level === UNDEFINED_VALUE || level > 0)
7732
+ : compressionMethod !== COMPRESSION_METHOD_STORE;
7733
+ }
7734
+
7589
7735
  function setUint8(view, offset, value) {
7590
7736
  view.setUint8(offset, value);
7591
7737
  }
@@ -8215,6 +8361,7 @@
8215
8361
  exports.ERR_INVALID_CODEC_DEFINITION = ERR_INVALID_CODEC_DEFINITION;
8216
8362
  exports.ERR_INVALID_CODEC_MODULE = ERR_INVALID_CODEC_MODULE;
8217
8363
  exports.ERR_INVALID_COMMENT = ERR_INVALID_COMMENT;
8364
+ exports.ERR_INVALID_COMMENT_TYPE = ERR_INVALID_COMMENT_TYPE;
8218
8365
  exports.ERR_INVALID_COMPRESSED_DATA = ERR_INVALID_COMPRESSED_DATA;
8219
8366
  exports.ERR_INVALID_CRC32 = ERR_INVALID_CRC32;
8220
8367
  exports.ERR_INVALID_ENCRYPTION_STRENGTH = ERR_INVALID_ENCRYPTION_STRENGTH;
@@ -8246,11 +8393,13 @@
8246
8393
  exports.ERR_SPLIT_ZIP_FILE = ERR_SPLIT_ZIP_FILE;
8247
8394
  exports.ERR_UNDEFINED_READER = ERR_UNDEFINED_READER;
8248
8395
  exports.ERR_UNDEFINED_UNCOMPRESSED_SIZE = ERR_UNDEFINED_UNCOMPRESSED_SIZE;
8396
+ exports.ERR_UNDETERMINED_SIZE = ERR_UNDETERMINED_SIZE;
8249
8397
  exports.ERR_UNSAFE_FILENAME = ERR_UNSAFE_FILENAME;
8250
8398
  exports.ERR_UNSUPPORTED_COMPRESSION = ERR_UNSUPPORTED_COMPRESSION$1;
8251
8399
  exports.ERR_UNSUPPORTED_CONTEXT = ERR_UNSUPPORTED_CONTEXT;
8252
8400
  exports.ERR_UNSUPPORTED_CRYPTO_API = ERR_UNSUPPORTED_CRYPTO_API;
8253
8401
  exports.ERR_UNSUPPORTED_ENCRYPTION = ERR_UNSUPPORTED_ENCRYPTION;
8402
+ exports.ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH = ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH;
8254
8403
  exports.ERR_UNSUPPORTED_ENCRYPTION_USDZ = ERR_UNSUPPORTED_ENCRYPTION_USDZ;
8255
8404
  exports.ERR_UNSUPPORTED_FORMAT = ERR_UNSUPPORTED_FORMAT;
8256
8405
  exports.ERR_WORKER_STARTUP_TIMEOUT = ERR_WORKER_STARTUP_TIMEOUT;