@zip.js/zip.js 2.8.52 → 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.
package/dist/zip-core.js CHANGED
@@ -102,6 +102,9 @@
102
102
  const VERSION_ZIP64 = 0x2D;
103
103
  const VERSION_AES = 0x33;
104
104
 
105
+ const VERSION_MADE_BY_MSDOS = 0x0014;
106
+ const VERSION_MADE_BY_UNIX = 0x0300;
107
+
105
108
  const DIRECTORY_SIGNATURE = "/";
106
109
 
107
110
  const HEADER_SIZE = 30;
@@ -2756,6 +2759,7 @@
2756
2759
  worker,
2757
2760
  workerAlive: false,
2758
2761
  terminated: false,
2762
+ startupError: null,
2759
2763
  interface: {
2760
2764
  run: async () => {
2761
2765
  try {
@@ -2783,6 +2787,13 @@
2783
2787
  }
2784
2788
 
2785
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
+ }
2786
2797
  let resolveResult, rejectResult;
2787
2798
  const result = new Promise((resolve, reject) => {
2788
2799
  resolveResult = resolve;
@@ -2996,11 +3007,12 @@
2996
3007
  if (!workerAlive) {
2997
3008
  workerData.worker = null;
2998
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
+ }
2999
3015
  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
3016
  rejectResult(error);
3005
3017
  if (writer) {
3006
3018
  writer.releaseLock();
@@ -4029,9 +4041,8 @@
4029
4041
 
4030
4042
  async init() {
4031
4043
  const reader = this;
4032
- const { readers } = reader;
4033
4044
  reader.lastDiskNumber = 0;
4034
- await Promise.all(readers.map(diskReader => initStream(diskReader)));
4045
+ const readers = reader.readers = await Promise.all(reader.readers.map(initDiskReader));
4035
4046
  reader.diskOffsets = readers.map(diskReader => {
4036
4047
  const diskOffset = reader.size;
4037
4048
  reader.size += diskReader.size;
@@ -4226,6 +4237,16 @@
4226
4237
  }
4227
4238
  }
4228
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
+
4229
4250
  function readUint8Array(reader, offset, size) {
4230
4251
  return reader.readUint8Array(offset, size);
4231
4252
  }
@@ -4384,6 +4405,10 @@
4384
4405
  const PROPERTY_NAME_SETGID = "setgid";
4385
4406
  const PROPERTY_NAME_STICKY = "sticky";
4386
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";
4387
4412
  const PROPERTY_NAME_FILENAME_UTF8 = "filenameUTF8";
4388
4413
  const PROPERTY_NAME_COMMENT_UTF8 = "commentUTF8";
4389
4414
  const PROPERTY_NAME_RAW_EXTRA_FIELD = "rawExtraField";
@@ -4436,10 +4461,14 @@
4436
4461
  PROPERTY_NAME_UID,
4437
4462
  PROPERTY_NAME_GID,
4438
4463
  PROPERTY_NAME_UNIX_MODE,
4464
+ PROPERTY_NAME_UNIX_EXTERNAL_UPPER,
4439
4465
  PROPERTY_NAME_SETUID,
4440
4466
  PROPERTY_NAME_SETGID,
4441
4467
  PROPERTY_NAME_STICKY,
4442
4468
  PROPERTY_NAME_BITFLAG,
4469
+ PROPERTY_NAME_RAW_BITFLAG,
4470
+ PROPERTY_NAME_FILENAME_LENGTH,
4471
+ PROPERTY_NAME_EXTRA_FIELD_LENGTH,
4443
4472
  PROPERTY_NAME_FILENAME_UTF8,
4444
4473
  PROPERTY_NAME_COMMENT_UTF8,
4445
4474
  PROPERTY_NAME_RAW_EXTRA_FIELD,
@@ -4501,6 +4530,7 @@
4501
4530
  const OPTION_CHECK_OVERLAPPING_ENTRY_ONLY = "checkOverlappingEntryOnly";
4502
4531
  const OPTION_CHECK_OVERLAPPING_ENTRY = "checkOverlappingEntry";
4503
4532
  const OPTION_CHECK_AMBIGUITY = "checkAmbiguity";
4533
+ const OPTION_CHECK_LOCAL_DIRECTORY = "checkLocalDirectory";
4504
4534
  const OPTION_CHECK_SIGNATURE = "checkSignature";
4505
4535
  const OPTION_CHECK_CRC32 = "checkCrc32";
4506
4536
  const OPTION_CHECK_AUTHENTICATION_CODE = "checkAuthenticationCode";
@@ -4632,7 +4662,7 @@
4632
4662
  if (reader.size < END_OF_CENTRAL_DIR_LENGTH) {
4633
4663
  throw new Error(ERR_BAD_FORMAT);
4634
4664
  }
4635
- const strictness = getStrictness(getOptionValue$1(zipReader, options, OPTION_STRICTNESS), getOptionValue$1(zipReader, options, OPTION_CHECK_AMBIGUITY));
4665
+ const strictness = getStrictness(options, zipReader.options);
4636
4666
  const checkAmbiguity = strictness == STRICTNESS_STRICT;
4637
4667
  const rejectAmbiguousEndOfDirectory = strictness != STRICTNESS_TOLERANT;
4638
4668
  const maxAppendedDataSize = getMaxAppendedDataSize(getOptionValue$1(zipReader, options, OPTION_MAX_APPENDED_DATA_SIZE), strictness);
@@ -4854,6 +4884,7 @@
4854
4884
  index: indexFile,
4855
4885
  versionMadeBy,
4856
4886
  msDosCompatible,
4887
+ zip64: false,
4857
4888
  compressedSize: 0,
4858
4889
  uncompressedSize: 0,
4859
4890
  commentLength,
@@ -5064,9 +5095,12 @@
5064
5095
  extraFieldLength,
5065
5096
  filenameLength
5066
5097
  } = localDirectory;
5067
- 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);
5068
5102
  let rawLocalFilename = EMPTY_UINT8_ARRAY;
5069
- if (checkAmbiguity && (filenameLength || extraFieldLength)) {
5103
+ if (checkLocalFilename && (filenameLength || extraFieldLength)) {
5070
5104
  const trailingDataArray = await readUint8Array(reader, localHeaderOffset + HEADER_SIZE, filenameLength + extraFieldLength);
5071
5105
  rawLocalFilename = trailingDataArray.subarray(0, filenameLength);
5072
5106
  localDirectory.rawExtraField = trailingDataArray.subarray(filenameLength);
@@ -5075,17 +5109,26 @@
5075
5109
  await readUint8Array(reader, localHeaderOffset + HEADER_SIZE + filenameLength, extraFieldLength) :
5076
5110
  EMPTY_UINT8_ARRAY;
5077
5111
  }
5112
+ if (checkLocalFilename) {
5113
+ localDirectory.rawFilename = rawLocalFilename;
5114
+ }
5078
5115
  readCommonFooter(zipEntry, localDirectory, dataView, 4, true);
5079
- if (checkAmbiguity) {
5080
- checkLocalDirectory(zipEntry, localDirectory, rawLocalFilename);
5116
+ if (checkLocalDirectory) {
5117
+ validateLocalDirectory(zipEntry, localDirectory, rawLocalFilename, checkLocalFilename);
5081
5118
  }
5082
- const { lastAccessDate, creationDate } = localDirectory;
5119
+ const { lastAccessDate, creationDate, uid, gid } = localDirectory;
5083
5120
  if (lastAccessDate) {
5084
5121
  fileEntry.lastAccessDate = lastAccessDate;
5085
5122
  }
5086
5123
  if (creationDate) {
5087
5124
  fileEntry.creationDate = creationDate;
5088
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
+ }
5089
5132
  const encrypted = zipEntry.encrypted && localDirectory.encrypted && !passThrough;
5090
5133
  const zipCrypto = encrypted && !extraFieldAES;
5091
5134
  if (!passThrough) {
@@ -5321,10 +5364,12 @@
5321
5364
  directory.extraFieldNTFS = extraFieldNTFS;
5322
5365
  }
5323
5366
  const extraFieldUnix = extraField.get(EXTRAFIELD_TYPE_UNIX);
5367
+ let unixIdsRead;
5324
5368
  if (extraFieldUnix) {
5325
- readExtraFieldUnix(extraFieldUnix, directory, false);
5369
+ unixIdsRead = readExtraFieldUnix(extraFieldUnix, directory, false);
5326
5370
  directory.extraFieldUnix = extraFieldUnix;
5327
- } else {
5371
+ }
5372
+ if (!unixIdsRead) {
5328
5373
  const extraFieldInfoZip = extraField.get(EXTRAFIELD_TYPE_INFOZIP);
5329
5374
  if (extraFieldInfoZip) {
5330
5375
  readExtraFieldUnix(extraFieldInfoZip, directory, true);
@@ -5427,7 +5472,7 @@
5427
5472
  const creationDate = getDateNTFS(rawCreationDate);
5428
5473
  const extraFieldData = { lastModDate, lastAccessDate, creationDate };
5429
5474
  Object.assign(extraFieldNTFS, extraFieldData);
5430
- Object.assign(directory, extraFieldData);
5475
+ Object.assign(directory, extraFieldData, { rawLastAccessDate, rawCreationDate });
5431
5476
  }
5432
5477
  }
5433
5478
 
@@ -5471,6 +5516,7 @@
5471
5516
  if (gid !== UNDEFINED_VALUE) {
5472
5517
  directory.gid = gid;
5473
5518
  }
5519
+ return uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE;
5474
5520
  } catch {
5475
5521
  // ignored
5476
5522
  }
@@ -5543,26 +5589,25 @@
5543
5589
  }
5544
5590
  if (dataDescriptorLength) {
5545
5591
  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;
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;
5560
5598
  if (matchCrc32 &&
5561
- readCompressedSize == compressedSize &&
5562
- readUncompressedSize == uncompressedSize) {
5599
+ signedDataDescriptor.compressedSize == compressedSize &&
5600
+ signedDataDescriptor.uncompressedSize == uncompressedSize) {
5563
5601
  dataDescriptorLength += DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH;
5602
+ } else {
5603
+ signature = false;
5564
5604
  }
5565
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
+ }
5566
5611
  }
5567
5612
  const range = {
5568
5613
  start: offset,
@@ -5579,6 +5624,20 @@
5579
5624
  readRanges.set(index, range);
5580
5625
  }
5581
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
+
5582
5641
  function getDiskOffset$1(reader, diskNumber) {
5583
5642
  return reader.getDiskOffset ? reader.getDiskOffset(diskNumber) : 0;
5584
5643
  }
@@ -5587,14 +5646,40 @@
5587
5646
  return value === STRICTNESS_STRICT || value === STRICTNESS_BALANCED || value === STRICTNESS_TOLERANT;
5588
5647
  }
5589
5648
 
5590
- function getStrictness(strictness, checkAmbiguity) {
5591
- if (strictness === UNDEFINED_VALUE) {
5592
- 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;
5660
+ }
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;
5593
5674
  }
5594
- if (!isStrictnessValue(strictness)) {
5595
- throw new Error(ERR_INVALID_STRICTNESS);
5675
+ return Boolean(checkLocalDirectory);
5676
+ }
5677
+
5678
+ function getCheckLocalFilename(checkLocalFilename, strictness) {
5679
+ if (checkLocalFilename === UNDEFINED_VALUE) {
5680
+ return strictness == STRICTNESS_STRICT;
5596
5681
  }
5597
- return strictness;
5682
+ return Boolean(checkLocalFilename);
5598
5683
  }
5599
5684
 
5600
5685
  function getFilenameValidation(filenameValidation, strictness) {
@@ -5742,10 +5827,11 @@
5742
5827
  return UNDEFINED_VALUE;
5743
5828
  }
5744
5829
 
5745
- function checkLocalDirectory(zipEntry, localDirectory, rawLocalFilename) {
5830
+ function validateLocalDirectory(zipEntry, localDirectory, rawLocalFilename, checkLocalFilename) {
5746
5831
  const { rawFilename } = zipEntry;
5747
- if (rawLocalFilename.length != rawFilename.length ||
5748
- rawLocalFilename.some((byteValue, indexByte) => byteValue != rawFilename[indexByte])) {
5832
+ if (checkLocalFilename &&
5833
+ (rawLocalFilename.length != rawFilename.length ||
5834
+ rawLocalFilename.some((byteValue, indexByte) => byteValue != rawFilename[indexByte]))) {
5749
5835
  throwAmbiguousArchive("mismatched local file header (filename)");
5750
5836
  }
5751
5837
  if ((localDirectory.rawBitFlag & BITFLAG_AMBIGUITY_MASK) != (zipEntry.rawBitFlag & BITFLAG_AMBIGUITY_MASK)) {
@@ -5863,6 +5949,7 @@
5863
5949
 
5864
5950
  const ERR_DUPLICATED_NAME = "File already exists";
5865
5951
  const ERR_INVALID_COMMENT = "Zip file comment exceeds 64KB";
5952
+ const ERR_INVALID_COMMENT_TYPE = "Invalid zip file comment (must be a Uint8Array)";
5866
5953
  const ERR_INVALID_ENTRY_COMMENT = "File entry comment exceeds 64KB";
5867
5954
  const ERR_INVALID_ENTRY_NAME = "File entry name exceeds 64KB";
5868
5955
  const ERR_INVALID_VERSION = "Version exceeds 65535";
@@ -5931,6 +6018,10 @@
5931
6018
  }
5932
6019
  reader = new GenericReader(reader);
5933
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
+ }
5934
6025
  const { ZipReader } = await Promise.resolve().then(function () { return zipReader; });
5935
6026
  const zipReader$1 = new ZipReader(reader.readable);
5936
6027
  const entries = await zipReader$1.getEntries();
@@ -6079,6 +6170,9 @@
6079
6170
  const zipWriter = this;
6080
6171
  const { pendingAddFileCalls, writer } = this;
6081
6172
  const { writable } = writer;
6173
+ if (!(comment instanceof Uint8Array)) {
6174
+ throw new Error(ERR_INVALID_COMMENT_TYPE);
6175
+ }
6082
6176
  if (getLength(comment) > MAX_16_BITS) {
6083
6177
  throw new Error(ERR_INVALID_COMMENT);
6084
6178
  }
@@ -6175,8 +6269,6 @@
6175
6269
  const diskOffset = getDiskOffset(zipWriter.writer);
6176
6270
  const diskNumber = getDiskNumber(zipWriter.writer);
6177
6271
  options = Object.assign({}, options, attributesInfo.resolvedOptions, metadataInfo.resolvedOptions, sizesInfo.resolvedOptions, {
6178
- internalFileAttribute: metadataInfo.resolvedOptions.internalFileAttributes,
6179
- externalFileAttribute: attributesInfo.resolvedOptions.externalFileAttributes,
6180
6272
  signature: options[PROPERTY_NAME_SIGNATURE],
6181
6273
  crc32: options.crc32 === UNDEFINED_VALUE ? options[PROPERTY_NAME_SIGNATURE] : options.crc32,
6182
6274
  offset: zipWriter.offset - diskOffset,
@@ -6190,14 +6282,20 @@
6190
6282
  zipWriter.files.delete(name);
6191
6283
  throw error;
6192
6284
  }
6193
- 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
+ });
6194
6292
  return new Entry(fileEntry);
6195
6293
  }
6196
6294
 
6197
6295
  function resolveAttributes(zipWriter, name, options) {
6198
6296
  name = name.trim();
6199
6297
  let msDosCompatible = getOptionValue(zipWriter, options, PROPERTY_NAME_MS_DOS_COMPATIBLE);
6200
- 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);
6201
6299
  const executable = getOptionValue(zipWriter, options, PROPERTY_NAME_EXECUTABLE);
6202
6300
  const uid = getNumberOptionValue(zipWriter, options, PROPERTY_NAME_UID);
6203
6301
  const gid = getNumberOptionValue(zipWriter, options, PROPERTY_NAME_GID);
@@ -6231,7 +6329,7 @@
6231
6329
  const hasMsDosProvided = msdosAttributesRaw !== UNDEFINED_VALUE || msdosAttributes !== UNDEFINED_VALUE;
6232
6330
  if (hasUnixMetadata) {
6233
6331
  msDosCompatible = false;
6234
- versionMadeBy = (versionMadeBy & MAX_16_BITS) | (3 << 8);
6332
+ versionMadeBy = (versionMadeBy & MAX_8_BITS) | VERSION_MADE_BY_UNIX;
6235
6333
  } else if (hasMsDosProvided) {
6236
6334
  msDosCompatible = true;
6237
6335
  versionMadeBy = (versionMadeBy & MAX_8_BITS);
@@ -6271,11 +6369,10 @@
6271
6369
  externalFileAttributes = FILE_ATTR_UNIX_DEFAULT_MASK << 16;
6272
6370
  }
6273
6371
  }
6274
- let unixExternalUpper;
6275
6372
  if (!msDosCompatible) {
6276
6373
  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);
6374
+ const defaultUnixMode = (externalFileAttributes >> 16) & MAX_16_BITS;
6375
+ unixMode = unixMode === UNDEFINED_VALUE ? defaultUnixMode : (unixMode & MAX_16_BITS);
6279
6376
  if (setuid) {
6280
6377
  unixMode |= FILE_ATTR_UNIX_SETUID_MASK;
6281
6378
  } else {
@@ -6304,17 +6401,20 @@
6304
6401
  if (hasMsDosProvided) {
6305
6402
  externalFileAttributes = (externalFileAttributes & MAX_32_BITS) | (msdosAttributesRaw & MAX_8_BITS);
6306
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);
6307
6406
  return {
6308
6407
  name,
6309
6408
  resolvedOptions: {
6310
6409
  versionMadeBy,
6311
- msDosCompatible,
6410
+ msDosCompatible: Boolean(msDosCompatible),
6312
6411
  externalFileAttributes,
6313
6412
  unixExternalUpper,
6314
6413
  uid,
6315
6414
  gid,
6316
6415
  unixMode,
6317
6416
  unixExtraFieldType,
6417
+ symlink,
6318
6418
  setuid,
6319
6419
  setgid,
6320
6420
  sticky,
@@ -6756,6 +6856,7 @@
6756
6856
  uid,
6757
6857
  gid,
6758
6858
  unixMode,
6859
+ symlink,
6759
6860
  setuid,
6760
6861
  setgid,
6761
6862
  sticky,
@@ -6792,6 +6893,7 @@
6792
6893
  uid,
6793
6894
  gid,
6794
6895
  unixMode,
6896
+ symlink: Boolean(symlink),
6795
6897
  setuid,
6796
6898
  setgid,
6797
6899
  sticky,
@@ -6872,8 +6974,8 @@
6872
6974
  rawLastModDate,
6873
6975
  creationDate,
6874
6976
  lastAccessDate,
6875
- encrypted,
6876
- zipCrypto,
6977
+ encrypted: Boolean(encrypted),
6978
+ zipCrypto: Boolean(zipCrypto),
6877
6979
  size: metadataSize + compressedSize,
6878
6980
  compressionMethod,
6879
6981
  version,
@@ -8226,6 +8328,7 @@
8226
8328
  exports.ERR_INVALID_CODEC_DEFINITION = ERR_INVALID_CODEC_DEFINITION;
8227
8329
  exports.ERR_INVALID_CODEC_MODULE = ERR_INVALID_CODEC_MODULE;
8228
8330
  exports.ERR_INVALID_COMMENT = ERR_INVALID_COMMENT;
8331
+ exports.ERR_INVALID_COMMENT_TYPE = ERR_INVALID_COMMENT_TYPE;
8229
8332
  exports.ERR_INVALID_COMPRESSED_DATA = ERR_INVALID_COMPRESSED_DATA;
8230
8333
  exports.ERR_INVALID_CRC32 = ERR_INVALID_CRC32;
8231
8334
  exports.ERR_INVALID_ENCRYPTION_STRENGTH = ERR_INVALID_ENCRYPTION_STRENGTH;