@zip.js/zip.js 2.8.55 → 2.8.57

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.
@@ -235,6 +235,18 @@
235
235
  }
236
236
  }
237
237
 
238
+ function checkInteger(value, maxValue, errorMessage) {
239
+ if (!Number.isInteger(value) || value < 0 || value > maxValue) {
240
+ throw new Error(errorMessage);
241
+ }
242
+ }
243
+
244
+ function checkIntegerOption(value, maxValue, errorMessage) {
245
+ if (value !== UNDEFINED_VALUE) {
246
+ checkInteger(value, maxValue, errorMessage);
247
+ }
248
+ }
249
+
238
250
  function toNumber(value) {
239
251
  return typeof value == STRING_TYPE && value.trim() ? Number(value) : value;
240
252
  }
@@ -4717,6 +4729,7 @@
4717
4729
  const ERR_INVALID_STRICTNESS = "Invalid strictness (must be 'strict', 'balanced' or 'tolerant')";
4718
4730
  const ERR_INVALID_FILENAME_VALIDATION = "Invalid filenameValidation (must be 'strict', 'balanced' or 'tolerant')";
4719
4731
  const ERR_INVALID_MAX_APPENDED_DATA_SIZE = "Invalid maxAppendedDataSize (must be a number greater than or equal to 0)";
4732
+ const ERR_UNSUPPORTED_UINT64 = "64-bit value exceeds Number.MAX_SAFE_INTEGER";
4720
4733
  const DRIVE_LETTER_REGEXP = /^[a-zA-Z]:/;
4721
4734
  const CHARSET_UTF8 = "utf-8";
4722
4735
  const PROPERTY_NAME_UTF8_SUFFIX = "UTF8";
@@ -4739,6 +4752,7 @@
4739
4752
  bytes: 8
4740
4753
  }
4741
4754
  };
4755
+ const MAX_SAFE_UINT64 = BigInt(Number.MAX_SAFE_INTEGER);
4742
4756
  const MAX_END_OF_CENTRAL_DIR_PROBES = 64;
4743
4757
  const MAX_DEFLATE_EXPANSION_RATIO = 1032;
4744
4758
  const CENTRAL_DIRECTORY_UNREACHABLE = 0;
@@ -4834,7 +4848,7 @@
4834
4848
  zip64EndOfDirectoryVersion2 = getBigUint64(endOfDirectoryView, 4) > ZIP64_END_OF_CENTRAL_DIR_LENGTH - 12;
4835
4849
  if (zip64EndOfDirectoryVersion2) {
4836
4850
  const extensibleDataLength = Math.min(
4837
- Number(getBigUint64(endOfDirectoryView, 4)) - (ZIP64_END_OF_CENTRAL_DIR_LENGTH - 12),
4851
+ getBigUint64(endOfDirectoryView, 4) - (ZIP64_END_OF_CENTRAL_DIR_LENGTH - 12),
4838
4852
  reader.size - directoryDataOffset - ZIP64_END_OF_CENTRAL_DIR_LENGTH);
4839
4853
  if (extensibleDataLength > 0) {
4840
4854
  zip64EndOfDirectoryLength += extensibleDataLength;
@@ -5067,8 +5081,15 @@
5067
5081
  yield entry;
5068
5082
  }
5069
5083
  let offsetAfterSignature = offset;
5070
- const digitalSignature = readDigitalSignature(directoryArray.subarray(offset)) ||
5084
+ let digitalSignature = readDigitalSignature(directoryArray.subarray(offset)) ||
5071
5085
  (decryptedDirectory ? readDigitalSignature(dataAfterEncryptedDirectory) : UNDEFINED_VALUE);
5086
+ if (!digitalSignature && !decryptedDirectory) {
5087
+ const signatureRecordOffset = directoryDataOffset + offset;
5088
+ const signatureRecordLength = Math.min(centralDirectoryEndOffset - signatureRecordOffset, 6 + MAX_16_BITS);
5089
+ if (signatureRecordLength >= 6) {
5090
+ digitalSignature = readDigitalSignature(await readUint8Array(reader, signatureRecordOffset, signatureRecordLength));
5091
+ }
5092
+ }
5072
5093
  if (digitalSignature) {
5073
5094
  zipReader.digitalSignature = digitalSignature;
5074
5095
  offsetAfterSignature = offset + 6 + digitalSignature.length;
@@ -5408,8 +5429,8 @@
5408
5429
  const hashDataLength = getUint16$1(extensibleDataView, 26);
5409
5430
  Object.assign(directoryEncryptionInfo, {
5410
5431
  compressionMethod: getUint16$1(extensibleDataView, 0),
5411
- compressedSize: Number(getBigUint64(extensibleDataView, 2)),
5412
- uncompressedSize: Number(getBigUint64(extensibleDataView, 10)),
5432
+ compressedSize: getBigUint64(extensibleDataView, 2),
5433
+ uncompressedSize: getBigUint64(extensibleDataView, 10),
5413
5434
  encryptionAlgorithm: getUint16$1(extensibleDataView, 18),
5414
5435
  bitLength: getUint16$1(extensibleDataView, 20),
5415
5436
  flags: getUint16$1(extensibleDataView, 22),
@@ -6044,7 +6065,11 @@
6044
6065
  }
6045
6066
 
6046
6067
  function getBigUint64(view, offset) {
6047
- return Number(view.getBigUint64(offset, true));
6068
+ const value = view.getBigUint64(offset, true);
6069
+ if (value > MAX_SAFE_UINT64) {
6070
+ throw new Error(ERR_UNSUPPORTED_UINT64);
6071
+ }
6072
+ return Number(value);
6048
6073
  }
6049
6074
 
6050
6075
  var zipReader = /*#__PURE__*/Object.freeze({
@@ -6073,6 +6098,7 @@
6073
6098
  ERR_UNSAFE_FILENAME: ERR_UNSAFE_FILENAME,
6074
6099
  ERR_UNSUPPORTED_COMPRESSION: ERR_UNSUPPORTED_COMPRESSION$1,
6075
6100
  ERR_UNSUPPORTED_ENCRYPTION: ERR_UNSUPPORTED_ENCRYPTION,
6101
+ ERR_UNSUPPORTED_UINT64: ERR_UNSUPPORTED_UINT64,
6076
6102
  ERR_WORKER_STARTUP_TIMEOUT: ERR_WORKER_STARTUP_TIMEOUT,
6077
6103
  ZipReader: ZipReader,
6078
6104
  ZipReaderStream: ZipReaderStream
@@ -6145,6 +6171,8 @@
6145
6171
 
6146
6172
  const EXTRAFIELD_DATA_AES = new Uint8Array([0x07, 0x00, 0x02, 0x00, 0x41, 0x45, 0x03, 0x00, 0x00]);
6147
6173
  const EXTRAFIELD_OFFSET_AES_VENDOR_VERSION = 4;
6174
+ const EXTRAFIELD_OFFSET_AES_COMPRESSION_METHOD = 9;
6175
+ const EXTRAFIELD_USDZ_MAX_LENGTH = 67;
6148
6176
  const VENDOR_VERSION_AE_1 = 1;
6149
6177
  const INFOZIP_EXTRA_FIELD_TYPE$1 = "infozip";
6150
6178
  const UNIX_EXTRA_FIELD_TYPE = "unix";
@@ -6191,16 +6219,14 @@
6191
6219
  await zipReader$1.close();
6192
6220
  await initStream(this.writer);
6193
6221
  const { directoryOffset } = zipReader$1;
6194
- let splitZipSignatureLength = 0;
6195
6222
  if (this.addSplitZipSignature) {
6196
6223
  delete this.addSplitZipSignature;
6197
6224
  if (!await startsWithSplitZipSignature(reader)) {
6198
6225
  await writeData(this.writer, getSplitZipSignatureArray());
6199
- splitZipSignatureLength = SPLIT_ZIP_FILE_SIGNATURE_LENGTH;
6200
- this.offset += splitZipSignatureLength;
6226
+ this.offset += SPLIT_ZIP_FILE_SIGNATURE_LENGTH;
6201
6227
  }
6202
6228
  }
6203
- const entryPositions = await copyZipData(this, reader, entries, directoryOffset, splitZipSignatureLength);
6229
+ const entryPositions = await copyZipData(this, reader, entries, directoryOffset);
6204
6230
  this.filenames = new Set(entries.map(entry => entry.filename));
6205
6231
  this.fileEntries = new Map(entries.map(entry => {
6206
6232
  const {
@@ -6213,7 +6239,7 @@
6213
6239
  encrypted,
6214
6240
  uncompressedSize,
6215
6241
  compressedSize,
6216
- zip64
6242
+ extraFieldZip64
6217
6243
  } = entry;
6218
6244
  let {
6219
6245
  compressionMethod,
@@ -6230,13 +6256,13 @@
6230
6256
  rawExtraFieldExtendedTimestamp = rawExtraFieldExtendedTimestamp || EMPTY_UINT8_ARRAY;
6231
6257
  rawExtraFieldNTFS = rawExtraFieldNTFS || EMPTY_UINT8_ARRAY;
6232
6258
  rawExtraFieldUnix = rawExtraFieldUnix || EMPTY_UINT8_ARRAY;
6233
- rawExtraField = rawExtraField || EMPTY_UINT8_ARRAY;
6259
+ rawExtraField = removeExtraFieldZip64(rawExtraField || EMPTY_UINT8_ARRAY);
6234
6260
  if (entry.extraFieldAES) {
6235
6261
  compressionMethod = COMPRESSION_METHOD_AES;
6236
6262
  }
6237
6263
  const extraFieldLength = getLength(rawExtraFieldZip64, rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS, rawExtraFieldUnix, rawExtraField);
6238
- const zip64UncompressedSize = zip64 && uncompressedSize >= MAX_32_BITS;
6239
- const zip64CompressedSize = zip64 && compressedSize >= MAX_32_BITS;
6264
+ const zip64UncompressedSize = Boolean(extraFieldZip64) && extraFieldZip64.uncompressedSize !== UNDEFINED_VALUE;
6265
+ const zip64CompressedSize = Boolean(extraFieldZip64) && extraFieldZip64.compressedSize !== UNDEFINED_VALUE;
6240
6266
  const bitFlagValue = (getBitFlag(level, languageEncodingFlag, dataDescriptor, encrypted, compressionMethod) & ~BITFLAG_LEVEL) | (level << 1);
6241
6267
  const {
6242
6268
  headerArray,
@@ -6442,7 +6468,8 @@
6442
6468
  signature: options[PROPERTY_NAME_SIGNATURE],
6443
6469
  crc32: options.crc32 === UNDEFINED_VALUE ? options[PROPERTY_NAME_SIGNATURE] : options.crc32,
6444
6470
  offset: zipWriter.offset - diskOffset,
6445
- diskNumberStart: diskNumber
6471
+ diskNumberStart: diskNumber,
6472
+ [OPTION_USDZ]: zipWriter.options[OPTION_USDZ]
6446
6473
  });
6447
6474
  const headerInfo = getHeaderInfo(options);
6448
6475
  const dataDescriptorInfo = getDataDescriptorInfo(options);
@@ -6474,15 +6501,9 @@
6474
6501
  let setuid = getOptionValue(zipWriter, options, PROPERTY_NAME_SETUID);
6475
6502
  let setgid = getOptionValue(zipWriter, options, PROPERTY_NAME_SETGID);
6476
6503
  let sticky = getOptionValue(zipWriter, options, PROPERTY_NAME_STICKY);
6477
- if (uid !== UNDEFINED_VALUE && (!Number.isInteger(uid) || uid < 0 || uid > MAX_32_BITS)) {
6478
- throw new Error(ERR_INVALID_UID);
6479
- }
6480
- if (gid !== UNDEFINED_VALUE && (!Number.isInteger(gid) || gid < 0 || gid > MAX_32_BITS)) {
6481
- throw new Error(ERR_INVALID_GID);
6482
- }
6483
- if (unixMode !== UNDEFINED_VALUE && (!Number.isInteger(unixMode) || unixMode < 0 || unixMode > MAX_16_BITS)) {
6484
- throw new Error(ERR_INVALID_UNIX_MODE);
6485
- }
6504
+ checkIntegerOption(uid, MAX_32_BITS, ERR_INVALID_UID);
6505
+ checkIntegerOption(gid, MAX_32_BITS, ERR_INVALID_GID);
6506
+ checkIntegerOption(unixMode, MAX_16_BITS, ERR_INVALID_UNIX_MODE);
6486
6507
  if (unixExtraFieldType !== UNDEFINED_VALUE && unixExtraFieldType !== INFOZIP_EXTRA_FIELD_TYPE$1 && unixExtraFieldType !== UNIX_EXTRA_FIELD_TYPE) {
6487
6508
  throw new Error(ERR_INVALID_UNIX_EXTRA_FIELD_TYPE);
6488
6509
  }
@@ -6504,9 +6525,7 @@
6504
6525
  msDosCompatible = true;
6505
6526
  versionMadeBy = (versionMadeBy & MAX_8_BITS);
6506
6527
  }
6507
- if (msdosAttributesRaw !== UNDEFINED_VALUE && (!Number.isInteger(msdosAttributesRaw) || msdosAttributesRaw < 0 || msdosAttributesRaw > MAX_8_BITS)) {
6508
- throw new Error(ERR_INVALID_MSDOS_ATTRIBUTES);
6509
- }
6528
+ checkIntegerOption(msdosAttributesRaw, MAX_8_BITS, ERR_INVALID_MSDOS_ATTRIBUTES);
6510
6529
  if (msdosAttributes && (typeof msdosAttributes !== OBJECT_TYPE || Array.isArray(msdosAttributes))) {
6511
6530
  throw new Error(ERR_INVALID_MSDOS_DATA);
6512
6531
  }
@@ -6646,9 +6665,7 @@
6646
6665
  throw new Error(ERR_UNSUPPORTED_COMPRESSION);
6647
6666
  }
6648
6667
  let level = getNumberOptionValue(zipWriter, options, OPTION_LEVEL);
6649
- if (level !== UNDEFINED_VALUE && (!Number.isInteger(level) || level < 0 || level > MAX_LEVEL)) {
6650
- throw new Error(ERR_INVALID_LEVEL);
6651
- }
6668
+ checkIntegerOption(level, MAX_LEVEL, ERR_INVALID_LEVEL);
6652
6669
  if (zipWriter.options[OPTION_USDZ]) {
6653
6670
  if (password !== UNDEFINED_VALUE || rawPassword !== UNDEFINED_VALUE) {
6654
6671
  throw new Error(ERR_UNSUPPORTED_ENCRYPTION_USDZ);
@@ -6726,9 +6743,7 @@
6726
6743
  let extraFieldSize = 0;
6727
6744
  let offset = 0;
6728
6745
  extraField.forEach((data, type) => {
6729
- if (!Number.isInteger(type) || type < 0 || type > MAX_16_BITS) {
6730
- throw new Error(ERR_INVALID_EXTRAFIELD_TYPE);
6731
- }
6746
+ checkInteger(type, MAX_16_BITS, ERR_INVALID_EXTRAFIELD_TYPE);
6732
6747
  if (!(data instanceof Uint8Array)) {
6733
6748
  throw new Error(ERR_INVALID_EXTRAFIELD_DATA_TYPE);
6734
6749
  }
@@ -6803,6 +6818,10 @@
6803
6818
  maximumCompressedSize = contentSize === UNDEFINED_VALUE ? getMaximumCompressedSize(uncompressedSize) + encryptionOverhead : contentSize;
6804
6819
  }
6805
6820
  }
6821
+ const emptyEntry = !encryptedEntry && (!hasContent || (contentSize === 0 && !passThrough)) && !isCompressed(compressionMethod, level);
6822
+ if (emptyEntry && !zipCrypto && getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR) === UNDEFINED_VALUE) {
6823
+ dataDescriptor = false;
6824
+ }
6806
6825
  const zip64UncompressedSize = zip64Enabled || uncompressedSize >= MAX_32_BITS;
6807
6826
  const zip64CompressedSize = zip64Enabled || maximumCompressedSize >= MAX_32_BITS;
6808
6827
  if (zip64UncompressedSize || zip64CompressedSize) {
@@ -6817,6 +6836,7 @@
6817
6836
  maximumCompressedSize,
6818
6837
  resolvedOptions: {
6819
6838
  dataDescriptor,
6839
+ emptyEntry,
6820
6840
  zip64,
6821
6841
  zip64UncompressedSize,
6822
6842
  zip64CompressedSize,
@@ -6843,7 +6863,9 @@
6843
6863
  const usdz = writerOptions[OPTION_USDZ];
6844
6864
  const files = new Map();
6845
6865
  let layoutDependsOnWriteOrder = Boolean(usdz);
6846
- let offset = 0;
6866
+ const initialOffset = writerOptions[OPTION_OFFSET] === UNDEFINED_VALUE ? 0 : writerOptions[OPTION_OFFSET];
6867
+ let offset = initialOffset;
6868
+ let minimumEntrySize = INFINITY_VALUE;
6847
6869
  for (const entry of entries) {
6848
6870
  let { name } = entry;
6849
6871
  const { size } = entry;
@@ -6867,7 +6889,7 @@
6867
6889
  if (hasContent && !metadata.passThrough && isCompressed(sizes.compressionMethod, sizes.level)) {
6868
6890
  throw new Error(ERR_UNDETERMINED_SIZE);
6869
6891
  }
6870
- const entryOptions = Object.assign({}, options, attributesInfo.resolvedOptions, metadata, sizes);
6892
+ const entryOptions = Object.assign({}, options, attributesInfo.resolvedOptions, metadata, sizes, { [OPTION_USDZ]: usdz });
6871
6893
  const headerInfo = getHeaderInfo(entryOptions);
6872
6894
  const dataDescriptorInfo = getDataDescriptorInfo(entryOptions);
6873
6895
  const entryInfo = {
@@ -6878,15 +6900,17 @@
6878
6900
  appendExtraFieldUSDZ(entryInfo, offset);
6879
6901
  }
6880
6902
  const compressedSize = hasContent ? maximumCompressedSize : 0;
6881
- if (offset >= MAX_32_BITS) {
6882
- layoutDependsOnWriteOrder = true;
6883
- }
6884
6903
  files.set(name, Object.assign({}, entryOptions, headerInfo, {
6885
6904
  offset,
6886
6905
  diskNumberStart: 0,
6887
6906
  compressedSize
6888
6907
  }));
6889
- offset += entryInfo.metadataSize + compressedSize;
6908
+ const entrySize = entryInfo.metadataSize + compressedSize;
6909
+ minimumEntrySize = Math.min(minimumEntrySize, entrySize);
6910
+ offset += entrySize;
6911
+ }
6912
+ if (files.size && offset - minimumEntrySize >= MAX_32_BITS) {
6913
+ layoutDependsOnWriteOrder = true;
6890
6914
  }
6891
6915
  if (layoutDependsOnWriteOrder && !writeOrderGuaranteed) {
6892
6916
  throw new Error(ERR_UNDETERMINED_SIZE);
@@ -6900,7 +6924,7 @@
6900
6924
  zip64 = true;
6901
6925
  }
6902
6926
  }
6903
- return offset + directoryDataLength + commentLength + (zip64 ? ZIP64_END_OF_CENTRAL_DIR_TOTAL_LENGTH : END_OF_CENTRAL_DIR_LENGTH);
6927
+ return offset - initialOffset + directoryDataLength + commentLength + (zip64 ? ZIP64_END_OF_CENTRAL_DIR_TOTAL_LENGTH : END_OF_CENTRAL_DIR_LENGTH);
6904
6928
  }
6905
6929
 
6906
6930
  async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
@@ -6911,6 +6935,7 @@
6911
6935
  const {
6912
6936
  keepOrder,
6913
6937
  dataDescriptor,
6938
+ emptyEntry,
6914
6939
  signal
6915
6940
  } = options;
6916
6941
  const {
@@ -6935,7 +6960,7 @@
6935
6960
  lockPreviousFileEntry = previousFileEntry && previousFileEntry.lockFileEntry;
6936
6961
  requestLockCurrentFileEntry();
6937
6962
  }
6938
- if (options.bufferedWrite || !keepOrder || zipWriter.writerLocked || zipWriter.bufferedWrites || !dataDescriptor) {
6963
+ if (options.bufferedWrite || !keepOrder || zipWriter.writerLocked || zipWriter.bufferedWrites || (!dataDescriptor && !emptyEntry)) {
6939
6964
  bufferedWrite = true;
6940
6965
  zipWriter.bufferedWrites++;
6941
6966
  if (options.createTempStream) {
@@ -7357,8 +7382,8 @@
7357
7382
  try {
7358
7383
  const { uid, gid, unixExtraFieldType } = options;
7359
7384
  if (unixExtraFieldType == INFOZIP_EXTRA_FIELD_TYPE$1 && (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE)) {
7360
- const uidBytes = packUnixId(uid);
7361
- const gidBytes = packUnixId(gid);
7385
+ const uidBytes = packUnixId(uid === UNDEFINED_VALUE ? 0 : uid);
7386
+ const gidBytes = packUnixId(gid === UNDEFINED_VALUE ? 0 : gid);
7362
7387
  const payloadLength = 3 + uidBytes.length + gidBytes.length;
7363
7388
  const extraFieldUnix = createRecordWriter(4 + payloadLength);
7364
7389
  extraFieldUnix.writeUint16(EXTRAFIELD_TYPE_INFOZIP);
@@ -7397,12 +7422,13 @@
7397
7422
  if (passThrough && crc32 !== UNDEFINED_VALUE) {
7398
7423
  rawExtraFieldAES[EXTRAFIELD_OFFSET_AES_VENDOR_VERSION] = VENDOR_VERSION_AE_1;
7399
7424
  }
7400
- rawExtraFieldAES[9] = compressionMethod;
7425
+ setUint16(getDataView(rawExtraFieldAES), EXTRAFIELD_OFFSET_AES_COMPRESSION_METHOD, compressionMethod);
7401
7426
  compressionMethod = COMPRESSION_METHOD_AES;
7402
7427
  }
7403
7428
  const localExtraFieldZip64Length = writeLocalExtraFieldZip64 ? getLength(rawLocalExtraFieldZip64) : 0;
7404
7429
  const extraFieldLength = localExtraFieldZip64Length + getLength(rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS, rawExtraFieldUnix, rawExtraField, rawLocalExtraField);
7405
- if (extraFieldLength > MAX_16_BITS) {
7430
+ const maximumUsdzExtraFieldLength = options[OPTION_USDZ] ? EXTRAFIELD_USDZ_MAX_LENGTH : 0;
7431
+ if (extraFieldLength + maximumUsdzExtraFieldLength > MAX_16_BITS) {
7406
7432
  throw new Error(ERR_INVALID_EXTRAFIELD_DATA);
7407
7433
  }
7408
7434
  const dosLastModDate = new Date(Math.ceil(Math.floor(lastModDate.getTime() / 1000) / 2) * 2000);
@@ -7488,18 +7514,14 @@
7488
7514
  }
7489
7515
 
7490
7516
  function packUnixId(id) {
7491
- if (id === UNDEFINED_VALUE) {
7492
- return EMPTY_UINT8_ARRAY;
7493
- } else {
7494
- const dataArray = new Uint8Array(4);
7495
- const dataView = getDataView(dataArray);
7496
- dataView.setUint32(0, id, true);
7497
- let length = 4;
7498
- while (length > 1 && dataArray[length - 1] === 0) {
7499
- length--;
7500
- }
7501
- return dataArray.subarray(0, length);
7517
+ const dataArray = new Uint8Array(4);
7518
+ const dataView = getDataView(dataArray);
7519
+ dataView.setUint32(0, id, true);
7520
+ let length = 4;
7521
+ while (length > 1 && dataArray[length - 1] === 0) {
7522
+ length--;
7502
7523
  }
7524
+ return dataArray.subarray(0, length);
7503
7525
  }
7504
7526
 
7505
7527
  function normalizeMsdosAttributes(msdosAttributesRaw, msdosAttributes) {
@@ -7803,7 +7825,11 @@
7803
7825
  signatureRecord.writeUint32(DIGITAL_SIGNATURE_RECORD_SIGNATURE);
7804
7826
  signatureRecord.writeUint16(signatureDataLength);
7805
7827
  signatureRecord.writeBytes(signatureData);
7806
- await writeData(zipWriter.writer, signatureRecord.array);
7828
+ const { writer } = zipWriter;
7829
+ if (exceedsAvailableSize(writer, getLength(signatureRecord.array))) {
7830
+ await writer.closeDisk();
7831
+ }
7832
+ await writeData(writer, signatureRecord.array);
7807
7833
  return 6 + signatureDataLength;
7808
7834
  }
7809
7835
  return 0;
@@ -7914,7 +7940,22 @@
7914
7940
  return getUint32(getDataView(signatureArray), 0) == SPLIT_ZIP_FILE_SIGNATURE;
7915
7941
  }
7916
7942
 
7917
- async function copyZipData(zipWriter, reader, entries, directoryOffset, splitZipSignatureLength) {
7943
+ function removeExtraFieldZip64(rawExtraField) {
7944
+ const rawExtraFieldView = getDataView(rawExtraField);
7945
+ let offsetExtraField = 0;
7946
+ while (offsetExtraField + 4 <= getLength(rawExtraField)) {
7947
+ const size = 4 + getUint16(rawExtraFieldView, offsetExtraField + 2);
7948
+ if (getUint16(rawExtraFieldView, offsetExtraField) == EXTRAFIELD_TYPE_ZIP64) {
7949
+ return removeExtraFieldZip64(concat(
7950
+ rawExtraField.subarray(0, offsetExtraField),
7951
+ rawExtraField.subarray(Math.min(offsetExtraField + size, getLength(rawExtraField)))));
7952
+ }
7953
+ offsetExtraField += size;
7954
+ }
7955
+ return rawExtraField;
7956
+ }
7957
+
7958
+ async function copyZipData(zipWriter, reader, entries, directoryOffset) {
7918
7959
  const { writer } = zipWriter;
7919
7960
  const entryPositions = new Map();
7920
7961
  if (writer.closeDisk) {
@@ -7935,9 +7976,10 @@
7935
7976
  }
7936
7977
  await copyData(zipWriter, reader, copiedLength, directoryOffset - copiedLength);
7937
7978
  } else {
7979
+ const baseOffset = zipWriter.offset;
7938
7980
  await copyData(zipWriter, reader, 0, directoryOffset);
7939
7981
  entries.forEach(entry => entryPositions.set(entry, {
7940
- offset: splitZipSignatureLength + getSourceOffset(reader, entry),
7982
+ offset: baseOffset + getSourceOffset(reader, entry),
7941
7983
  diskNumberStart: 0
7942
7984
  }));
7943
7985
  }
@@ -9480,7 +9522,7 @@
9480
9522
  } else if (writer.constructor == BlobWriter) {
9481
9523
  return data.type == contentType;
9482
9524
  } else if (writer.constructor == Data64URIWriter) {
9483
- return data.startsWith(writer.data);
9525
+ return data.startsWith("data:" + (contentType || "") + ";base64,");
9484
9526
  } else {
9485
9527
  return true;
9486
9528
  }
@@ -10153,6 +10195,7 @@
10153
10195
  exports.ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH = ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH;
10154
10196
  exports.ERR_UNSUPPORTED_ENCRYPTION_USDZ = ERR_UNSUPPORTED_ENCRYPTION_USDZ;
10155
10197
  exports.ERR_UNSUPPORTED_FORMAT = ERR_UNSUPPORTED_FORMAT;
10198
+ exports.ERR_UNSUPPORTED_UINT64 = ERR_UNSUPPORTED_UINT64;
10156
10199
  exports.ERR_WORKER_STARTUP_TIMEOUT = ERR_WORKER_STARTUP_TIMEOUT;
10157
10200
  exports.ERR_WRITER_NOT_INITIALIZED = ERR_WRITER_NOT_INITIALIZED;
10158
10201
  exports.ERR_ZIP_NOT_EMPTY = ERR_ZIP_NOT_EMPTY;