@zip.js/zip.js 2.8.36 → 2.8.37

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/deno.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zip-js/zip-js",
3
- "version": "2.8.36",
3
+ "version": "2.8.37",
4
4
  "exports": {
5
5
  ".": "./index.js"
6
6
  },
@@ -23,6 +23,7 @@
23
23
  ".eslintrc.json",
24
24
  "benchmarks",
25
25
  "docs",
26
- ".github"
26
+ ".github",
27
+ "tests/corpus"
27
28
  ]
28
29
  }
package/dist/zip-core.js CHANGED
@@ -104,7 +104,7 @@
104
104
  const HEADER_OFFSET_UNCOMPRESSED_SIZE = 18;
105
105
  const LOCAL_HEADER_COMMON_OFFSET = 4;
106
106
 
107
- const MAX_DATE = new Date(2107, 11, 31);
107
+ const MAX_DATE = new Date(2107, 11, 31, 23, 59, 58);
108
108
  const MIN_DATE = new Date(1980, 0, 1);
109
109
 
110
110
  const UNDEFINED_VALUE = undefined;
@@ -220,6 +220,103 @@
220
220
  Object.assign(config, DEFAULT_CONFIGURATION);
221
221
  }
222
222
 
223
+ /*
224
+ Copyright (c) 2025 Gildas Lormeau. All rights reserved.
225
+
226
+ Redistribution and use in source and binary forms, with or without
227
+ modification, are permitted provided that the following conditions are met:
228
+
229
+ 1. Redistributions of source code must retain the above copyright notice,
230
+ this list of conditions and the following disclaimer.
231
+
232
+ 2. Redistributions in binary form must reproduce the above copyright
233
+ notice, this list of conditions and the following disclaimer in
234
+ the documentation and/or other materials provided with the distribution.
235
+
236
+ 3. The names of the authors may not be used to endorse or promote products
237
+ derived from this software without specific prior written permission.
238
+
239
+ THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
240
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
241
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
242
+ INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
243
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
244
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
245
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
246
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
247
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
248
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
249
+ */
250
+
251
+
252
+ const ERR_INVALID_CODEC_DEFINITION = "Invalid codec definition";
253
+ const ERR_RESERVED_COMPRESSION_METHOD = "Reserved compression method";
254
+ const ERR_INVALID_CODEC_MODULE = "Invalid codec module";
255
+
256
+ const STRING_TYPE = "string";
257
+ const RESERVED_COMPRESSION_METHODS = [
258
+ COMPRESSION_METHOD_STORE,
259
+ COMPRESSION_METHOD_DEFLATE,
260
+ COMPRESSION_METHOD_DEFLATE_64,
261
+ COMPRESSION_METHOD_AES
262
+ ];
263
+
264
+ const registeredCodecs = new Map();
265
+ const codecStreams = new Map();
266
+
267
+ function registerCodec(codec = {}) {
268
+ const { compressionMethod, format, codecURI, CompressionStream, DecompressionStream, versionNeeded } = codec;
269
+ if (!Number.isInteger(compressionMethod) || compressionMethod < 0 || compressionMethod > MAX_16_BITS ||
270
+ typeof format != STRING_TYPE || !format.length) {
271
+ throw new Error(ERR_INVALID_CODEC_DEFINITION);
272
+ }
273
+ if (RESERVED_COMPRESSION_METHODS.includes(compressionMethod)) {
274
+ throw new Error(ERR_RESERVED_COMPRESSION_METHOD);
275
+ }
276
+ const hasStreams = typeof CompressionStream == FUNCTION_TYPE || typeof DecompressionStream == FUNCTION_TYPE;
277
+ if (!hasStreams && (typeof codecURI != STRING_TYPE || !codecURI.length)) {
278
+ throw new Error(ERR_INVALID_CODEC_DEFINITION);
279
+ }
280
+ registeredCodecs.set(compressionMethod, { compressionMethod, format, codecURI, versionNeeded });
281
+ if (hasStreams) {
282
+ setCodecStreams(format, { CompressionStream, DecompressionStream });
283
+ }
284
+ }
285
+
286
+ function unregisterCodec(compressionMethod) {
287
+ const codec = registeredCodecs.get(compressionMethod);
288
+ if (codec) {
289
+ registeredCodecs.delete(compressionMethod);
290
+ let formatUsed;
291
+ registeredCodecs.forEach(otherCodec => formatUsed = formatUsed || otherCodec.format == codec.format);
292
+ if (!formatUsed) {
293
+ codecStreams.delete(codec.format);
294
+ }
295
+ }
296
+ }
297
+
298
+ function getRegisteredCodec(compressionMethod) {
299
+ return registeredCodecs.get(compressionMethod);
300
+ }
301
+
302
+ function getCodecStreams(format) {
303
+ return codecStreams.get(format);
304
+ }
305
+
306
+ function setCodecStreams(format, streams) {
307
+ const { CompressionStream, DecompressionStream } = streams;
308
+ if (typeof CompressionStream != FUNCTION_TYPE && typeof DecompressionStream != FUNCTION_TYPE) {
309
+ throw new Error(ERR_INVALID_CODEC_MODULE);
310
+ }
311
+ codecStreams.set(format, { CompressionStream, DecompressionStream });
312
+ }
313
+
314
+ async function ensureCodecStreams(format, codecURI) {
315
+ if (!codecStreams.has(format) && codecURI) {
316
+ setCodecStreams(format, await import(codecURI));
317
+ }
318
+ }
319
+
223
320
  /*
224
321
  Copyright (c) 2022 Gildas Lormeau. All rights reserved.
225
322
 
@@ -1756,6 +1853,7 @@
1756
1853
 
1757
1854
  const ERR_INVALID_UNCOMPRESSED_SIZE = "Invalid uncompressed size";
1758
1855
  const ERR_INVALID_COMPRESSED_DATA = "Invalid compressed data";
1856
+ const ERR_UNSUPPORTED_COMPRESSION$2 = "Compression method not supported";
1759
1857
  const FORMAT_DEFLATE_RAW = "deflate-raw";
1760
1858
  const FORMAT_DEFLATE64_RAW = "deflate64-raw";
1761
1859
  const FORMAT_GZIP = "gzip";
@@ -1766,18 +1864,21 @@
1766
1864
 
1767
1865
  constructor(options, { chunkSize, CompressionStreamZlib, CompressionStream }) {
1768
1866
  super({});
1769
- const { compressed, encrypted, useCompressionStream, zipCrypto, signed, level, deflate64 } = options;
1867
+ const { compressed, encrypted, useCompressionStream, zipCrypto, signed, level, deflate64, format } = options;
1770
1868
  const stream = this;
1771
1869
  let crc32Stream, encryptionStream, gzipCrc32Stream;
1772
1870
  let readable = super.readable;
1773
- const useGzipCrc32 = signed && compressed && !deflate64 && (!encrypted || zipCrypto) &&
1871
+ const codecStreams = format && getCodecStreams(format);
1872
+ const useGzipCrc32 = signed && compressed && !deflate64 && !codecStreams && (!encrypted || zipCrypto) &&
1774
1873
  Boolean(useCompressionStream && CompressionStream);
1775
1874
  if ((!encrypted || zipCrypto) && signed && !useGzipCrc32) {
1776
1875
  crc32Stream = new Crc32Stream();
1777
1876
  readable = pipeThrough(readable, crc32Stream);
1778
1877
  }
1779
1878
  if (compressed) {
1780
- if (useGzipCrc32) {
1879
+ if (codecStreams) {
1880
+ readable = pipeThroughBackpressured(readable, createCodecStream(codecStreams.CompressionStream, format, { level, chunkSize }));
1881
+ } else if (useGzipCrc32) {
1781
1882
  gzipCrc32Stream = new GzipToRawDeflateStream();
1782
1883
  readable = pipeThroughBackpressured(readable, new CompressionStream(FORMAT_GZIP));
1783
1884
  readable = pipeThrough(readable, gzipCrc32Stream);
@@ -1851,7 +1952,7 @@
1851
1952
 
1852
1953
  constructor(options, { chunkSize, DecompressionStreamZlib, DecompressionStream }) {
1853
1954
  super({});
1854
- const { zipCrypto, encrypted, signed, signature, compressed, useCompressionStream, deflate64 } = options;
1955
+ const { zipCrypto, encrypted, signed, signature, compressed, useCompressionStream, deflate64, format } = options;
1855
1956
  let crc32Stream, decryptionStream;
1856
1957
  let readable = super.readable;
1857
1958
  if (encrypted) {
@@ -1863,7 +1964,12 @@
1863
1964
  }
1864
1965
  }
1865
1966
  if (compressed) {
1866
- readable = pipeThroughCommpressionStream(readable, useCompressionStream, { chunkSize, deflate64 }, DecompressionStream, DecompressionStreamZlib, DecompressionStream);
1967
+ const codecStreams = format && getCodecStreams(format);
1968
+ if (codecStreams) {
1969
+ readable = pipeThroughBackpressured(readable, createCodecStream(codecStreams.DecompressionStream, format, { chunkSize }));
1970
+ } else {
1971
+ readable = pipeThroughCommpressionStream(readable, useCompressionStream, { chunkSize, deflate64 }, DecompressionStream, DecompressionStreamZlib, DecompressionStream);
1972
+ }
1867
1973
  readable = mapInflateStreamError(readable);
1868
1974
  }
1869
1975
  if ((!encrypted || zipCrypto) && signed) {
@@ -1890,6 +1996,13 @@
1890
1996
  });
1891
1997
  }
1892
1998
 
1999
+ function createCodecStream(CodecStreamClass, format, options) {
2000
+ if (!CodecStreamClass) {
2001
+ throw new Error(ERR_UNSUPPORTED_COMPRESSION$2);
2002
+ }
2003
+ return new CodecStreamClass(format, options);
2004
+ }
2005
+
1893
2006
  function pipeThroughCommpressionStream(readable, useCompressionStream, options, CompressionStreamNative, CompressionStreamZlib, CompressionStream) {
1894
2007
  const Stream = useCompressionStream && CompressionStreamNative ? CompressionStreamNative : CompressionStreamZlib || CompressionStream;
1895
2008
  const format = options.deflate64 ? FORMAT_DEFLATE64_RAW : FORMAT_DEFLATE_RAW;
@@ -2634,11 +2747,18 @@
2634
2747
 
2635
2748
  async function runWorker(stream, workerOptions) {
2636
2749
  const { options, config } = workerOptions;
2637
- const { transferStreams, useWebWorkers, useCompressionStream, compressed, signed, encrypted } = options;
2750
+ const { transferStreams, useWebWorkers, useCompressionStream, compressed, signed, encrypted, format, codecURI } = options;
2638
2751
  const { workerURI, maxWorkers } = config;
2752
+ if (format) {
2753
+ if (codecURI) {
2754
+ options.codecURI = resolveCodecURI(codecURI, config.baseURI);
2755
+ }
2756
+ await ensureCodecStreams(format, options.codecURI);
2757
+ }
2639
2758
  workerOptions.transferStreams = transferStreams || (transferStreams === UNDEFINED_VALUE && config.transferStreams);
2640
2759
  const streamCopy = !compressed && !signed && !encrypted;
2641
- workerOptions.useWebWorkers = !streamCopy && (useWebWorkers || (useWebWorkers === UNDEFINED_VALUE && config.useWebWorkers));
2760
+ const workerSupported = format === UNDEFINED_VALUE || Boolean(options.codecURI);
2761
+ workerOptions.useWebWorkers = !streamCopy && workerSupported && (useWebWorkers || (useWebWorkers === UNDEFINED_VALUE && config.useWebWorkers));
2642
2762
  workerOptions.workerURI = workerOptions.useWebWorkers && workerURI ? workerURI : UNDEFINED_VALUE;
2643
2763
  options.useCompressionStream = useCompressionStream || (useCompressionStream === UNDEFINED_VALUE && config.useCompressionStream);
2644
2764
  return (await getWorker()).run();
@@ -2678,6 +2798,14 @@
2678
2798
  }
2679
2799
  }
2680
2800
 
2801
+ function resolveCodecURI(codecURI, baseURI) {
2802
+ try {
2803
+ return new URL(codecURI, baseURI).toString();
2804
+ } catch {
2805
+ return codecURI;
2806
+ }
2807
+ }
2808
+
2681
2809
  function armStarvationTimeout() {
2682
2810
  if (!starvationTimeout && pendingRequests.length && Number.isFinite(starvationDelay) && starvationDelay >= 0) {
2683
2811
  starvationTimeout = setTimeout(onWorkerStarvation, starvationDelay);
@@ -3961,6 +4089,7 @@
3961
4089
  const OPTION_PREVENT_CLOSE = "preventClose";
3962
4090
  const OPTION_ENCRYPTION_STRENGTH = "encryptionStrength";
3963
4091
  const OPTION_EXTENDED_TIMESTAMP = "extendedTimestamp";
4092
+ const OPTION_NTFS_TIMESTAMP = "ntfsTimestamp";
3964
4093
  const OPTION_KEEP_ORDER = "keepOrder";
3965
4094
  const OPTION_LEVEL = "level";
3966
4095
  const OPTION_BUFFERED_WRITE = "bufferedWrite";
@@ -4432,7 +4561,8 @@
4432
4561
  throw new Error(ERR_UNSUPPORTED_COMPRESSION$1);
4433
4562
  }
4434
4563
  }
4435
- if ((compressionMethod != COMPRESSION_METHOD_STORE && compressionMethod != COMPRESSION_METHOD_DEFLATE && compressionMethod != COMPRESSION_METHOD_DEFLATE_64) && !passThrough) {
4564
+ const registeredCodec = passThrough ? UNDEFINED_VALUE : getRegisteredCodec(compressionMethod);
4565
+ if ((compressionMethod != COMPRESSION_METHOD_STORE && compressionMethod != COMPRESSION_METHOD_DEFLATE && compressionMethod != COMPRESSION_METHOD_DEFLATE_64 && !registeredCodec) && !passThrough) {
4436
4566
  throw new Error(ERR_UNSUPPORTED_COMPRESSION$1);
4437
4567
  }
4438
4568
  if (dataArray.length < HEADER_SIZE || getUint32(dataView, 0) != LOCAL_FILE_HEADER_SIGNATURE) {
@@ -4471,7 +4601,7 @@
4471
4601
  fileEntry.zipCrypto = zipCrypto;
4472
4602
  }
4473
4603
  if (encrypted) {
4474
- if (!zipCrypto && extraFieldAES.strength === UNDEFINED_VALUE) {
4604
+ if (!zipCrypto && (extraFieldAES.strength < 1 || extraFieldAES.strength > 3)) {
4475
4605
  throw new Error(ERR_UNSUPPORTED_ENCRYPTION);
4476
4606
  } else if (!password && !rawPassword) {
4477
4607
  throw new Error(ERR_ENCRYPTED);
@@ -4510,6 +4640,8 @@
4510
4640
  useCompressionStream,
4511
4641
  transferStreams: getOptionValue$1(zipEntry, options, OPTION_TRANSFER_STREAMS),
4512
4642
  deflate64,
4643
+ format: registeredCodec ? registeredCodec.format : UNDEFINED_VALUE,
4644
+ codecURI: registeredCodec ? registeredCodec.codecURI : UNDEFINED_VALUE,
4513
4645
  checkPasswordOnly
4514
4646
  },
4515
4647
  config,
@@ -5127,6 +5259,7 @@
5127
5259
  const ERR_INVALID_ENTRY_NAME = "File entry name exceeds 64KB";
5128
5260
  const ERR_INVALID_VERSION = "Version exceeds 65535";
5129
5261
  const ERR_INVALID_ENCRYPTION_STRENGTH = "The strength must equal 1, 2, or 3";
5262
+ const ERR_UNSUPPORTED_ENCRYPTION_USDZ = "Encryption is not supported in USDZ files";
5130
5263
  const ERR_INVALID_EXTRAFIELD_TYPE = "Extra field type exceeds 65535";
5131
5264
  const ERR_INVALID_EXTRAFIELD_DATA = "Extra field data exceeds 64KB";
5132
5265
  const ERR_UNSUPPORTED_COMPRESSION = "Compression method not supported";
@@ -5591,6 +5724,7 @@
5591
5724
  const encryptionStrength = getOptionValue(zipWriter, options, OPTION_ENCRYPTION_STRENGTH, 3);
5592
5725
  const zipCrypto = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIPCRYPTO);
5593
5726
  const extendedTimestamp = getOptionValue(zipWriter, options, OPTION_EXTENDED_TIMESTAMP, true);
5727
+ const ntfsTimestamp = getOptionValue(zipWriter, options, OPTION_NTFS_TIMESTAMP);
5594
5728
  const keepOrder = getOptionValue(zipWriter, options, OPTION_KEEP_ORDER, true);
5595
5729
  const useWebWorkers = getOptionValue(zipWriter, options, OPTION_USE_WEB_WORKERS);
5596
5730
  const transferStreams = getOptionValue(zipWriter, options, OPTION_TRANSFER_STREAMS);
@@ -5600,11 +5734,20 @@
5600
5734
  const signal = getOptionValue(zipWriter, options, OPTION_SIGNAL);
5601
5735
  const useUnicodeFileNames = getOptionValue(zipWriter, options, OPTION_USE_UNICODE_FILE_NAMES, true);
5602
5736
  const compressionMethod = getOptionValue(zipWriter, options, PROPERTY_NAME_COMPRESSION_METHOD);
5737
+ const registeredCodec = passThrough || compressionMethod === UNDEFINED_VALUE ? UNDEFINED_VALUE : getRegisteredCodec(compressionMethod);
5603
5738
  if (!passThrough && compressionMethod !== UNDEFINED_VALUE &&
5604
- compressionMethod !== COMPRESSION_METHOD_STORE && compressionMethod !== COMPRESSION_METHOD_DEFLATE) {
5739
+ compressionMethod !== COMPRESSION_METHOD_STORE && compressionMethod !== COMPRESSION_METHOD_DEFLATE && !registeredCodec) {
5605
5740
  throw new Error(ERR_UNSUPPORTED_COMPRESSION);
5606
5741
  }
5607
5742
  let level = getOptionValue(zipWriter, options, OPTION_LEVEL);
5743
+ if (zipWriter.options[OPTION_USDZ]) {
5744
+ if (password !== UNDEFINED_VALUE || rawPassword !== UNDEFINED_VALUE) {
5745
+ throw new Error(ERR_UNSUPPORTED_ENCRYPTION_USDZ);
5746
+ }
5747
+ if (level === UNDEFINED_VALUE && compressionMethod === UNDEFINED_VALUE) {
5748
+ level = 0;
5749
+ }
5750
+ }
5608
5751
  let useCompressionStream = getOptionValue(zipWriter, options, OPTION_USE_COMPRESSION_STREAM);
5609
5752
  let dataDescriptor = getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR);
5610
5753
  if (bufferedWrite && dataDescriptor === UNDEFINED_VALUE) {
@@ -5616,7 +5759,7 @@
5616
5759
  if (level !== UNDEFINED_VALUE && level != 6) {
5617
5760
  useCompressionStream = false;
5618
5761
  }
5619
- if (!useCompressionStream && (zipWriter.config.CompressionStream === UNDEFINED_VALUE && zipWriter.config.CompressionStreamZlib === UNDEFINED_VALUE)) {
5762
+ if (!useCompressionStream && !registeredCodec && (zipWriter.config.CompressionStream === UNDEFINED_VALUE && zipWriter.config.CompressionStreamZlib === UNDEFINED_VALUE)) {
5620
5763
  level = 0;
5621
5764
  }
5622
5765
  const zip64 = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIP64);
@@ -5660,6 +5803,7 @@
5660
5803
  encryptionStrength,
5661
5804
  zipCrypto,
5662
5805
  extendedTimestamp,
5806
+ ntfsTimestamp,
5663
5807
  keepOrder,
5664
5808
  useWebWorkers,
5665
5809
  transferStreams,
@@ -5669,6 +5813,9 @@
5669
5813
  signal,
5670
5814
  useUnicodeFileNames,
5671
5815
  compressionMethod,
5816
+ format: registeredCodec ? registeredCodec.format : UNDEFINED_VALUE,
5817
+ codecURI: registeredCodec ? registeredCodec.codecURI : UNDEFINED_VALUE,
5818
+ codecVersionNeeded: registeredCodec ? registeredCodec.versionNeeded : UNDEFINED_VALUE,
5672
5819
  level,
5673
5820
  useCompressionStream,
5674
5821
  dataDescriptor,
@@ -5965,7 +6112,9 @@
5965
6112
  msdosAttributesRaw,
5966
6113
  msdosAttributes,
5967
6114
  useCompressionStream,
5968
- passThrough
6115
+ passThrough,
6116
+ format,
6117
+ codecURI
5969
6118
  } = options;
5970
6119
  const fileEntry = {
5971
6120
  lock,
@@ -6025,7 +6174,9 @@
6025
6174
  encrypted: encrypted && !passThrough,
6026
6175
  useWebWorkers,
6027
6176
  useCompressionStream,
6028
- transferStreams
6177
+ transferStreams,
6178
+ format,
6179
+ codecURI
6029
6180
  },
6030
6181
  config,
6031
6182
  streamOptions: { signal, size, onstart, onprogress, onend }
@@ -6097,6 +6248,7 @@
6097
6248
  rawExtraField,
6098
6249
  encryptionStrength,
6099
6250
  extendedTimestamp,
6251
+ ntfsTimestamp,
6100
6252
  passThrough,
6101
6253
  encrypted,
6102
6254
  zip64UncompressedSize,
@@ -6142,7 +6294,8 @@
6142
6294
  let extraFieldExtendedTimestampFlag;
6143
6295
  if (extendedTimestamp) {
6144
6296
  const lastModTimeUnix = getTimeUnix(lastModDate);
6145
- if (inUnixTimeRange(lastModTimeUnix)) {
6297
+ const lastModTimeUnixInRange = inUnixTimeRange(lastModTimeUnix);
6298
+ if (lastModTimeUnixInRange) {
6146
6299
  const extraFieldTimestampLength = 9 + (lastAccessDate ? 4 : 0) + (creationDate ? 4 : 0);
6147
6300
  const extraFieldTimestamp = createRecordWriter(extraFieldTimestampLength);
6148
6301
  extraFieldExtendedTimestampFlag = 0x1 + (lastAccessDate ? 0x2 : 0) + (creationDate ? 0x4 : 0);
@@ -6160,19 +6313,26 @@
6160
6313
  } else {
6161
6314
  rawExtraFieldExtendedTimestamp = EMPTY_UINT8_ARRAY;
6162
6315
  }
6163
- try {
6164
- const lastModTimeNTFS = getTimeNTFS(lastModDate);
6165
- const extraFieldNTFS = createRecordWriter(36);
6166
- extraFieldNTFS.uint16(EXTRAFIELD_TYPE_NTFS);
6167
- extraFieldNTFS.uint16(32);
6168
- extraFieldNTFS.skip(4);
6169
- extraFieldNTFS.uint16(EXTRAFIELD_TYPE_NTFS_TAG1);
6170
- extraFieldNTFS.uint16(24);
6171
- extraFieldNTFS.uint64(lastModTimeNTFS);
6172
- extraFieldNTFS.uint64(getTimeNTFS(lastAccessDate) || lastModTimeNTFS);
6173
- extraFieldNTFS.uint64(getTimeNTFS(creationDate) || lastModTimeNTFS);
6174
- rawExtraFieldNTFS = extraFieldNTFS.array;
6175
- } catch {
6316
+ const writeExtraFieldNTFS = ntfsTimestamp === UNDEFINED_VALUE ?
6317
+ !lastModTimeUnixInRange || Boolean(lastAccessDate || creationDate) :
6318
+ ntfsTimestamp;
6319
+ if (writeExtraFieldNTFS) {
6320
+ try {
6321
+ const lastModTimeNTFS = getTimeNTFS(lastModDate);
6322
+ const extraFieldNTFS = createRecordWriter(36);
6323
+ extraFieldNTFS.uint16(EXTRAFIELD_TYPE_NTFS);
6324
+ extraFieldNTFS.uint16(32);
6325
+ extraFieldNTFS.skip(4);
6326
+ extraFieldNTFS.uint16(EXTRAFIELD_TYPE_NTFS_TAG1);
6327
+ extraFieldNTFS.uint16(24);
6328
+ extraFieldNTFS.uint64(lastModTimeNTFS);
6329
+ extraFieldNTFS.uint64(getTimeNTFS(lastAccessDate) || lastModTimeNTFS);
6330
+ extraFieldNTFS.uint64(getTimeNTFS(creationDate) || lastModTimeNTFS);
6331
+ rawExtraFieldNTFS = extraFieldNTFS.array;
6332
+ } catch {
6333
+ rawExtraFieldNTFS = EMPTY_UINT8_ARRAY;
6334
+ }
6335
+ } else {
6176
6336
  rawExtraFieldNTFS = EMPTY_UINT8_ARRAY;
6177
6337
  }
6178
6338
  } else {
@@ -6210,6 +6370,10 @@
6210
6370
  if (compressionMethod === UNDEFINED_VALUE) {
6211
6371
  compressionMethod = compressed ? COMPRESSION_METHOD_DEFLATE : COMPRESSION_METHOD_STORE;
6212
6372
  }
6373
+ const { codecVersionNeeded } = options;
6374
+ if (compressed && codecVersionNeeded !== UNDEFINED_VALUE) {
6375
+ version = version > codecVersionNeeded ? version : codecVersionNeeded;
6376
+ }
6213
6377
  if (zip64) {
6214
6378
  version = version > VERSION_ZIP64 ? version : VERSION_ZIP64;
6215
6379
  }
@@ -7335,6 +7499,8 @@
7335
7499
  exports.ERR_EXTRAFIELD_ZIP64_NOT_FOUND = ERR_EXTRAFIELD_ZIP64_NOT_FOUND;
7336
7500
  exports.ERR_HTTP_RANGE = ERR_HTTP_RANGE;
7337
7501
  exports.ERR_HTTP_RESOURCE_CHANGED = ERR_HTTP_RESOURCE_CHANGED;
7502
+ exports.ERR_INVALID_CODEC_DEFINITION = ERR_INVALID_CODEC_DEFINITION;
7503
+ exports.ERR_INVALID_CODEC_MODULE = ERR_INVALID_CODEC_MODULE;
7338
7504
  exports.ERR_INVALID_COMMENT = ERR_INVALID_COMMENT;
7339
7505
  exports.ERR_INVALID_COMPRESSED_DATA = ERR_INVALID_COMPRESSED_DATA;
7340
7506
  exports.ERR_INVALID_ENCRYPTION_STRENGTH = ERR_INVALID_ENCRYPTION_STRENGTH;
@@ -7349,11 +7515,13 @@
7349
7515
  exports.ERR_ITERATOR_COMPLETED_TOO_SOON = ERR_ITERATOR_COMPLETED_TOO_SOON;
7350
7516
  exports.ERR_LOCAL_FILE_HEADER_NOT_FOUND = ERR_LOCAL_FILE_HEADER_NOT_FOUND;
7351
7517
  exports.ERR_OVERLAPPING_ENTRY = ERR_OVERLAPPING_ENTRY;
7518
+ exports.ERR_RESERVED_COMPRESSION_METHOD = ERR_RESERVED_COMPRESSION_METHOD;
7352
7519
  exports.ERR_SPLIT_ZIP_FILE = ERR_SPLIT_ZIP_FILE;
7353
7520
  exports.ERR_UNDEFINED_READER = ERR_UNDEFINED_READER;
7354
7521
  exports.ERR_UNDEFINED_UNCOMPRESSED_SIZE = ERR_UNDEFINED_UNCOMPRESSED_SIZE;
7355
7522
  exports.ERR_UNSUPPORTED_COMPRESSION = ERR_UNSUPPORTED_COMPRESSION$1;
7356
7523
  exports.ERR_UNSUPPORTED_ENCRYPTION = ERR_UNSUPPORTED_ENCRYPTION;
7524
+ exports.ERR_UNSUPPORTED_ENCRYPTION_USDZ = ERR_UNSUPPORTED_ENCRYPTION_USDZ;
7357
7525
  exports.ERR_UNSUPPORTED_FORMAT = ERR_UNSUPPORTED_FORMAT;
7358
7526
  exports.ERR_WRITER_NOT_INITIALIZED = ERR_WRITER_NOT_INITIALIZED;
7359
7527
  exports.ERR_ZIP_NOT_EMPTY = ERR_ZIP_NOT_EMPTY;
@@ -7376,7 +7544,9 @@
7376
7544
  exports.createOPFSTempStream = createOPFSTempStream;
7377
7545
  exports.createSyncAccessHandleTempStream = createSyncAccessHandleTempStream;
7378
7546
  exports.getMimeType = getMimeType;
7547
+ exports.registerCodec = registerCodec;
7379
7548
  exports.resetConfiguration = resetConfiguration;
7380
7549
  exports.terminateWorkers = terminateWorkers;
7550
+ exports.unregisterCodec = unregisterCodec;
7381
7551
 
7382
7552
  }));