@zip.js/zip.js 2.8.36 → 2.8.38

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 (42) hide show
  1. package/deno.json +4 -2
  2. package/dist/zip-core.js +356 -63
  3. package/dist/zip-core.min.js +1 -1
  4. package/dist/zip-fs-core.js +301 -63
  5. package/dist/zip-fs-core.min.js +1 -1
  6. package/dist/zip-fs-native.js +359 -66
  7. package/dist/zip-fs-native.min.js +1 -1
  8. package/dist/zip-fs.js +357 -64
  9. package/dist/zip-fs.min.js +1 -1
  10. package/dist/zip-legacy.js +358 -65
  11. package/dist/zip-legacy.min.js +1 -1
  12. package/dist/zip-native.js +359 -66
  13. package/dist/zip-native.min.js +1 -1
  14. package/dist/zip-web-worker-native.js +1 -1
  15. package/dist/zip-web-worker.js +1 -1
  16. package/dist/zip.js +357 -64
  17. package/dist/zip.min.js +1 -1
  18. package/index-native.cjs +359 -66
  19. package/index-native.min.js +1 -1
  20. package/index.cjs +357 -64
  21. package/index.d.cts +126 -4
  22. package/index.d.ts +126 -4
  23. package/index.min.js +1 -1
  24. package/lib/core/codec-pool.js +21 -4
  25. package/lib/core/codec-registry.js +116 -0
  26. package/lib/core/codec-worker.js +94 -18
  27. package/lib/core/configuration.js +2 -0
  28. package/lib/core/constants.js +5 -1
  29. package/lib/core/options.js +2 -0
  30. package/lib/core/streams/codec-stream.js +6 -2
  31. package/lib/core/streams/zip-entry-stream.js +50 -16
  32. package/lib/core/streams/zlib-js/zlib-streams.min.js +1 -1
  33. package/lib/core/web-worker-base.js +30 -8
  34. package/lib/core/web-worker-inline-native.js +1 -1
  35. package/lib/core/web-worker-inline-wasm.js +1 -1
  36. package/lib/core/zip-reader.js +29 -3
  37. package/lib/core/zip-writer.js +68 -25
  38. package/lib/zip-core-base.js +7 -0
  39. package/lib/zip-core-reader.js +2 -1
  40. package/lib/zip-core-writer.js +1 -0
  41. package/package.json +1 -1
  42. package/worker-message-property-names.js +1 -1
@@ -42,6 +42,7 @@ import {
42
42
  DATA_DESCRIPTOR_RECORD_ZIP_64_LENGTH,
43
43
  DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH,
44
44
  LOCAL_FILE_HEADER_SIGNATURE,
45
+ ARCHIVE_EXTRA_DATA_SIGNATURE,
45
46
  CENTRAL_FILE_HEADER_SIGNATURE,
46
47
  CENTRAL_FILE_HEADER_LENGTH,
47
48
  END_OF_CENTRAL_DIR_SIGNATURE,
@@ -61,6 +62,7 @@ import {
61
62
  ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH,
62
63
  ZIP64_END_OF_CENTRAL_DIR_LENGTH,
63
64
  BITFLAG_ENCRYPTED,
65
+ BITFLAG_STRONG_ENCRYPTION,
64
66
  BITFLAG_LEVEL,
65
67
  BITFLAG_DATA_DESCRIPTOR,
66
68
  BITFLAG_LANG_ENCODING_FLAG,
@@ -86,6 +88,7 @@ import {
86
88
  EMPTY_UINT8_ARRAY
87
89
  } from "./constants.js";
88
90
  import { getConfiguration } from "./configuration.js";
91
+ import { getRegisteredCodec } from "./codec-registry.js";
89
92
  import {
90
93
  runWorker,
91
94
  CODEC_INFLATE,
@@ -160,6 +163,7 @@ const ERR_UNSUPPORTED_COMPRESSION = "Compression method not supported";
160
163
  const ERR_SPLIT_ZIP_FILE = "Split zip file";
161
164
  const ERR_OVERLAPPING_ENTRY = "Overlapping entry found";
162
165
  const ERR_AMBIGUOUS_ARCHIVE = "Ambiguous archive";
166
+ const ERR_ENCRYPTED_CENTRAL_DIRECTORY = "Encrypted central directory is not supported";
163
167
  const CHARSET_UTF8 = "utf-8";
164
168
  const PROPERTY_NAME_UTF8_SUFFIX = "UTF8";
165
169
  const CHARSET_CP437 = "cp437";
@@ -237,6 +241,7 @@ class ZipReader {
237
241
  let prependedDataLength = 0;
238
242
  let startOffset;
239
243
  let zip64EndOfDirectory;
244
+ let zip64EndOfDirectoryVersion2;
240
245
  const requiresZip64 = directoryDataOffset == MAX_32_BITS || directoryDataLength == MAX_32_BITS || filesLength == MAX_16_BITS || diskNumber == MAX_16_BITS;
241
246
  if (directoryDataOffset != MAX_32_BITS && diskNumber != MAX_16_BITS) {
242
247
  directoryDataOffset += getDiskOffset(reader, diskNumber);
@@ -266,6 +271,7 @@ class ZipReader {
266
271
  throw new Error(ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND);
267
272
  }
268
273
  zip64EndOfDirectory = true;
274
+ zip64EndOfDirectoryVersion2 = getBigUint64(endOfDirectoryView, 4) > ZIP64_END_OF_CENTRAL_DIR_LENGTH - 12;
269
275
  if (lastDiskNumber == MAX_16_BITS) {
270
276
  lastDiskNumber = getUint32(endOfDirectoryView, 16);
271
277
  } else if (checkAmbiguity && lastDiskNumber != getUint32(endOfDirectoryView, 16)) {
@@ -345,6 +351,9 @@ class ZipReader {
345
351
  for (let indexFile = 0; indexFile < filesLength; indexFile++) {
346
352
  const fileEntry = new ZipEntry(reader, config, zipReader.options);
347
353
  if (offset + CENTRAL_FILE_HEADER_LENGTH > directoryArray.length || getUint32(directoryView, offset) != CENTRAL_FILE_HEADER_SIGNATURE) {
354
+ if (indexFile == 0 && (zip64EndOfDirectoryVersion2 || detectEncryptedCentralDirectory(directoryView))) {
355
+ throw new Error(ERR_ENCRYPTED_CENTRAL_DIRECTORY);
356
+ }
348
357
  throw new Error(ERR_CENTRAL_DIRECTORY_NOT_FOUND);
349
358
  }
350
359
  readCommonHeader(fileEntry, directoryView, offset + 6);
@@ -546,7 +555,8 @@ export {
546
555
  ERR_INVALID_COMPRESSED_DATA,
547
556
  ERR_SPLIT_ZIP_FILE,
548
557
  ERR_OVERLAPPING_ENTRY,
549
- ERR_AMBIGUOUS_ARCHIVE
558
+ ERR_AMBIGUOUS_ARCHIVE,
559
+ ERR_ENCRYPTED_CENTRAL_DIRECTORY
550
560
  };
551
561
 
552
562
  class ZipEntry {
@@ -593,7 +603,8 @@ class ZipEntry {
593
603
  throw new Error(ERR_UNSUPPORTED_COMPRESSION);
594
604
  }
595
605
  }
596
- if ((compressionMethod != COMPRESSION_METHOD_STORE && compressionMethod != COMPRESSION_METHOD_DEFLATE && compressionMethod != COMPRESSION_METHOD_DEFLATE_64) && !passThrough) {
606
+ const registeredCodec = passThrough ? UNDEFINED_VALUE : getRegisteredCodec(compressionMethod);
607
+ if ((compressionMethod != COMPRESSION_METHOD_STORE && compressionMethod != COMPRESSION_METHOD_DEFLATE && compressionMethod != COMPRESSION_METHOD_DEFLATE_64 && !registeredCodec) && !passThrough) {
597
608
  throw new Error(ERR_UNSUPPORTED_COMPRESSION);
598
609
  }
599
610
  if (dataArray.length < HEADER_SIZE || getUint32(dataView, 0) != LOCAL_FILE_HEADER_SIGNATURE) {
@@ -632,7 +643,10 @@ class ZipEntry {
632
643
  fileEntry.zipCrypto = zipCrypto;
633
644
  }
634
645
  if (encrypted) {
635
- if (!zipCrypto && extraFieldAES.strength === UNDEFINED_VALUE) {
646
+ if ((localDirectory.rawBitFlag & BITFLAG_STRONG_ENCRYPTION) == BITFLAG_STRONG_ENCRYPTION) {
647
+ throw new Error(ERR_UNSUPPORTED_ENCRYPTION);
648
+ }
649
+ if (!zipCrypto && (extraFieldAES.strength < 1 || extraFieldAES.strength > 3)) {
636
650
  throw new Error(ERR_UNSUPPORTED_ENCRYPTION);
637
651
  } else if (!password && !rawPassword) {
638
652
  throw new Error(ERR_ENCRYPTED);
@@ -671,6 +685,8 @@ class ZipEntry {
671
685
  useCompressionStream,
672
686
  transferStreams: getOptionValue(zipEntry, options, OPTION_TRANSFER_STREAMS),
673
687
  deflate64,
688
+ format: registeredCodec ? registeredCodec.format : UNDEFINED_VALUE,
689
+ codecURI: registeredCodec ? registeredCodec.codecURI : UNDEFINED_VALUE,
674
690
  checkPasswordOnly
675
691
  },
676
692
  config,
@@ -723,6 +739,16 @@ class ZipEntry {
723
739
  }
724
740
  }
725
741
 
742
+ function detectEncryptedCentralDirectory(directoryView) {
743
+ const maxOffset = Math.min(directoryView.byteLength, 1024) - 3;
744
+ for (let offset = 0; offset < maxOffset; offset++) {
745
+ if (getUint32(directoryView, offset) == ARCHIVE_EXTRA_DATA_SIGNATURE) {
746
+ return true;
747
+ }
748
+ }
749
+ return false;
750
+ }
751
+
726
752
  function readCommonHeader(directory, dataView, offset) {
727
753
  const rawBitFlag = directory.rawBitFlag = getUint16(dataView, offset + 2);
728
754
  const encrypted = (rawBitFlag & BITFLAG_ENCRYPTED) == BITFLAG_ENCRYPTED;
@@ -142,6 +142,7 @@ import {
142
142
  EMPTY_UINT8_ARRAY
143
143
  } from "./constants.js";
144
144
  import { getConfiguration } from "./configuration.js";
145
+ import { getRegisteredCodec } from "./codec-registry.js";
145
146
  import {
146
147
  CODEC_DEFLATE,
147
148
  runWorker
@@ -193,6 +194,7 @@ import {
193
194
  OPTION_PREVENT_CLOSE,
194
195
  OPTION_ENCRYPTION_STRENGTH,
195
196
  OPTION_EXTENDED_TIMESTAMP,
197
+ OPTION_NTFS_TIMESTAMP,
196
198
  OPTION_KEEP_ORDER,
197
199
  OPTION_LEVEL,
198
200
  OPTION_BUFFERED_WRITE,
@@ -213,6 +215,7 @@ const ERR_INVALID_ENTRY_COMMENT = "File entry comment exceeds 64KB";
213
215
  const ERR_INVALID_ENTRY_NAME = "File entry name exceeds 64KB";
214
216
  const ERR_INVALID_VERSION = "Version exceeds 65535";
215
217
  const ERR_INVALID_ENCRYPTION_STRENGTH = "The strength must equal 1, 2, or 3";
218
+ const ERR_UNSUPPORTED_ENCRYPTION_USDZ = "Encryption is not supported in USDZ files";
216
219
  const ERR_INVALID_EXTRAFIELD_TYPE = "Extra field type exceeds 65535";
217
220
  const ERR_INVALID_EXTRAFIELD_DATA = "Extra field data exceeds 64KB";
218
221
  const ERR_UNSUPPORTED_COMPRESSION = "Compression method not supported";
@@ -501,6 +504,7 @@ export {
501
504
  ERR_INVALID_EXTRAFIELD_TYPE,
502
505
  ERR_INVALID_EXTRAFIELD_DATA,
503
506
  ERR_INVALID_ENCRYPTION_STRENGTH,
507
+ ERR_UNSUPPORTED_ENCRYPTION_USDZ,
504
508
  ERR_UNSUPPORTED_FORMAT,
505
509
  ERR_UNDEFINED_UNCOMPRESSED_SIZE,
506
510
  ERR_UNDEFINED_READER,
@@ -590,7 +594,11 @@ function resolveAttributes(zipWriter, name, options) {
590
594
  if (versionMadeBy > MAX_16_BITS) {
591
595
  throw new Error(ERR_INVALID_VERSION);
592
596
  }
593
- let externalFileAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES, 0);
597
+ let externalFileAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES);
598
+ const externalFileAttributesProvided = externalFileAttributes !== UNDEFINED_VALUE;
599
+ if (!externalFileAttributesProvided) {
600
+ externalFileAttributes = 0;
601
+ }
594
602
  if (!options[PROPERTY_NAME_DIRECTORY] && name.endsWith(DIRECTORY_SIGNATURE)) {
595
603
  options[PROPERTY_NAME_DIRECTORY] = true;
596
604
  }
@@ -599,13 +607,13 @@ function resolveAttributes(zipWriter, name, options) {
599
607
  if (!name.endsWith(DIRECTORY_SIGNATURE)) {
600
608
  name += DIRECTORY_SIGNATURE;
601
609
  }
602
- if (externalFileAttributes === 0) {
610
+ if (!externalFileAttributesProvided) {
603
611
  externalFileAttributes = FILE_ATTR_MSDOS_DIR_MASK;
604
612
  if (!msDosCompatible) {
605
613
  externalFileAttributes |= (FILE_ATTR_UNIX_TYPE_DIR | FILE_ATTR_UNIX_EXECUTABLE_MASK | FILE_ATTR_UNIX_DEFAULT_MASK) << 16;
606
614
  }
607
615
  }
608
- } else if (!msDosCompatible && externalFileAttributes === 0) {
616
+ } else if (!msDosCompatible && !externalFileAttributesProvided) {
609
617
  if (executable) {
610
618
  externalFileAttributes = (FILE_ATTR_UNIX_EXECUTABLE_MASK | FILE_ATTR_UNIX_DEFAULT_MASK) << 16;
611
619
  } else {
@@ -614,6 +622,7 @@ function resolveAttributes(zipWriter, name, options) {
614
622
  }
615
623
  let unixExternalUpper;
616
624
  if (!msDosCompatible) {
625
+ const unixModeProvided = unixMode !== UNDEFINED_VALUE || Boolean(setuid || setgid || sticky);
617
626
  unixExternalUpper = (externalFileAttributes >> 16) & MAX_16_BITS;
618
627
  unixMode = unixMode === UNDEFINED_VALUE ? unixExternalUpper : (unixMode & MAX_16_BITS);
619
628
  if (setuid) {
@@ -631,10 +640,12 @@ function resolveAttributes(zipWriter, name, options) {
631
640
  } else {
632
641
  sticky = Boolean(unixMode & FILE_ATTR_UNIX_STICKY_MASK);
633
642
  }
634
- if (directory) {
635
- unixMode |= FILE_ATTR_UNIX_TYPE_DIR;
643
+ if (!externalFileAttributesProvided || unixModeProvided) {
644
+ if (directory) {
645
+ unixMode |= FILE_ATTR_UNIX_TYPE_DIR;
646
+ }
647
+ externalFileAttributes = ((unixMode & MAX_16_BITS) << 16) | (externalFileAttributes & MAX_16_BITS);
636
648
  }
637
- externalFileAttributes = ((unixMode & MAX_16_BITS) << 16) | (externalFileAttributes & MAX_8_BITS);
638
649
  }
639
650
  ({ msdosAttributesRaw, msdosAttributes } = normalizeMsdosAttributes(msdosAttributesRaw, msdosAttributes));
640
651
  if (hasMsDosProvided) {
@@ -694,6 +705,7 @@ function resolveMetadata(zipWriter, name, options) {
694
705
  const encryptionStrength = getOptionValue(zipWriter, options, OPTION_ENCRYPTION_STRENGTH, 3);
695
706
  const zipCrypto = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIPCRYPTO);
696
707
  const extendedTimestamp = getOptionValue(zipWriter, options, OPTION_EXTENDED_TIMESTAMP, true);
708
+ const ntfsTimestamp = getOptionValue(zipWriter, options, OPTION_NTFS_TIMESTAMP);
697
709
  const keepOrder = getOptionValue(zipWriter, options, OPTION_KEEP_ORDER, true);
698
710
  const useWebWorkers = getOptionValue(zipWriter, options, OPTION_USE_WEB_WORKERS);
699
711
  const transferStreams = getOptionValue(zipWriter, options, OPTION_TRANSFER_STREAMS);
@@ -703,11 +715,20 @@ function resolveMetadata(zipWriter, name, options) {
703
715
  const signal = getOptionValue(zipWriter, options, OPTION_SIGNAL);
704
716
  const useUnicodeFileNames = getOptionValue(zipWriter, options, OPTION_USE_UNICODE_FILE_NAMES, true);
705
717
  const compressionMethod = getOptionValue(zipWriter, options, PROPERTY_NAME_COMPRESSION_METHOD);
718
+ const registeredCodec = passThrough || compressionMethod === UNDEFINED_VALUE ? UNDEFINED_VALUE : getRegisteredCodec(compressionMethod);
706
719
  if (!passThrough && compressionMethod !== UNDEFINED_VALUE &&
707
- compressionMethod !== COMPRESSION_METHOD_STORE && compressionMethod !== COMPRESSION_METHOD_DEFLATE) {
720
+ compressionMethod !== COMPRESSION_METHOD_STORE && compressionMethod !== COMPRESSION_METHOD_DEFLATE && !registeredCodec) {
708
721
  throw new Error(ERR_UNSUPPORTED_COMPRESSION);
709
722
  }
710
723
  let level = getOptionValue(zipWriter, options, OPTION_LEVEL);
724
+ if (zipWriter.options[OPTION_USDZ]) {
725
+ if (password !== UNDEFINED_VALUE || rawPassword !== UNDEFINED_VALUE) {
726
+ throw new Error(ERR_UNSUPPORTED_ENCRYPTION_USDZ);
727
+ }
728
+ if (level === UNDEFINED_VALUE && compressionMethod === UNDEFINED_VALUE) {
729
+ level = 0;
730
+ }
731
+ }
711
732
  let useCompressionStream = getOptionValue(zipWriter, options, OPTION_USE_COMPRESSION_STREAM);
712
733
  let dataDescriptor = getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR);
713
734
  if (bufferedWrite && dataDescriptor === UNDEFINED_VALUE) {
@@ -719,7 +740,7 @@ function resolveMetadata(zipWriter, name, options) {
719
740
  if (level !== UNDEFINED_VALUE && level != 6) {
720
741
  useCompressionStream = false;
721
742
  }
722
- if (!useCompressionStream && (zipWriter.config.CompressionStream === UNDEFINED_VALUE && zipWriter.config.CompressionStreamZlib === UNDEFINED_VALUE)) {
743
+ if (!useCompressionStream && !registeredCodec && (zipWriter.config.CompressionStream === UNDEFINED_VALUE && zipWriter.config.CompressionStreamZlib === UNDEFINED_VALUE)) {
723
744
  level = 0;
724
745
  }
725
746
  const zip64 = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIP64);
@@ -763,6 +784,7 @@ function resolveMetadata(zipWriter, name, options) {
763
784
  encryptionStrength,
764
785
  zipCrypto,
765
786
  extendedTimestamp,
787
+ ntfsTimestamp,
766
788
  keepOrder,
767
789
  useWebWorkers,
768
790
  transferStreams,
@@ -772,6 +794,9 @@ function resolveMetadata(zipWriter, name, options) {
772
794
  signal,
773
795
  useUnicodeFileNames,
774
796
  compressionMethod,
797
+ format: registeredCodec ? registeredCodec.format : UNDEFINED_VALUE,
798
+ codecURI: registeredCodec ? registeredCodec.codecURI : UNDEFINED_VALUE,
799
+ codecVersionNeeded: registeredCodec ? registeredCodec.versionNeeded : UNDEFINED_VALUE,
775
800
  level,
776
801
  useCompressionStream,
777
802
  dataDescriptor,
@@ -1068,7 +1093,9 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
1068
1093
  msdosAttributesRaw,
1069
1094
  msdosAttributes,
1070
1095
  useCompressionStream,
1071
- passThrough
1096
+ passThrough,
1097
+ format,
1098
+ codecURI
1072
1099
  } = options;
1073
1100
  const fileEntry = {
1074
1101
  lock,
@@ -1128,7 +1155,9 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
1128
1155
  encrypted: encrypted && !passThrough,
1129
1156
  useWebWorkers,
1130
1157
  useCompressionStream,
1131
- transferStreams
1158
+ transferStreams,
1159
+ format,
1160
+ codecURI
1132
1161
  },
1133
1162
  config,
1134
1163
  streamOptions: { signal, size, onstart, onprogress, onend }
@@ -1200,6 +1229,7 @@ function getHeaderInfo(options) {
1200
1229
  rawExtraField,
1201
1230
  encryptionStrength,
1202
1231
  extendedTimestamp,
1232
+ ntfsTimestamp,
1203
1233
  passThrough,
1204
1234
  encrypted,
1205
1235
  zip64UncompressedSize,
@@ -1245,7 +1275,8 @@ function getHeaderInfo(options) {
1245
1275
  let extraFieldExtendedTimestampFlag;
1246
1276
  if (extendedTimestamp) {
1247
1277
  const lastModTimeUnix = getTimeUnix(lastModDate);
1248
- if (inUnixTimeRange(lastModTimeUnix)) {
1278
+ const lastModTimeUnixInRange = inUnixTimeRange(lastModTimeUnix);
1279
+ if (lastModTimeUnixInRange) {
1249
1280
  const extraFieldTimestampLength = 9 + (lastAccessDate ? 4 : 0) + (creationDate ? 4 : 0);
1250
1281
  const extraFieldTimestamp = createRecordWriter(extraFieldTimestampLength);
1251
1282
  extraFieldExtendedTimestampFlag = 0x1 + (lastAccessDate ? 0x2 : 0) + (creationDate ? 0x4 : 0);
@@ -1263,19 +1294,26 @@ function getHeaderInfo(options) {
1263
1294
  } else {
1264
1295
  rawExtraFieldExtendedTimestamp = EMPTY_UINT8_ARRAY;
1265
1296
  }
1266
- try {
1267
- const lastModTimeNTFS = getTimeNTFS(lastModDate);
1268
- const extraFieldNTFS = createRecordWriter(36);
1269
- extraFieldNTFS.uint16(EXTRAFIELD_TYPE_NTFS);
1270
- extraFieldNTFS.uint16(32);
1271
- extraFieldNTFS.skip(4);
1272
- extraFieldNTFS.uint16(EXTRAFIELD_TYPE_NTFS_TAG1);
1273
- extraFieldNTFS.uint16(24);
1274
- extraFieldNTFS.uint64(lastModTimeNTFS);
1275
- extraFieldNTFS.uint64(getTimeNTFS(lastAccessDate) || lastModTimeNTFS);
1276
- extraFieldNTFS.uint64(getTimeNTFS(creationDate) || lastModTimeNTFS);
1277
- rawExtraFieldNTFS = extraFieldNTFS.array;
1278
- } catch {
1297
+ const writeExtraFieldNTFS = ntfsTimestamp === UNDEFINED_VALUE ?
1298
+ !lastModTimeUnixInRange || Boolean(lastAccessDate || creationDate) :
1299
+ ntfsTimestamp;
1300
+ if (writeExtraFieldNTFS) {
1301
+ try {
1302
+ const lastModTimeNTFS = getTimeNTFS(lastModDate);
1303
+ const extraFieldNTFS = createRecordWriter(36);
1304
+ extraFieldNTFS.uint16(EXTRAFIELD_TYPE_NTFS);
1305
+ extraFieldNTFS.uint16(32);
1306
+ extraFieldNTFS.skip(4);
1307
+ extraFieldNTFS.uint16(EXTRAFIELD_TYPE_NTFS_TAG1);
1308
+ extraFieldNTFS.uint16(24);
1309
+ extraFieldNTFS.uint64(lastModTimeNTFS);
1310
+ extraFieldNTFS.uint64(getTimeNTFS(lastAccessDate) || lastModTimeNTFS);
1311
+ extraFieldNTFS.uint64(getTimeNTFS(creationDate) || lastModTimeNTFS);
1312
+ rawExtraFieldNTFS = extraFieldNTFS.array;
1313
+ } catch {
1314
+ rawExtraFieldNTFS = EMPTY_UINT8_ARRAY;
1315
+ }
1316
+ } else {
1279
1317
  rawExtraFieldNTFS = EMPTY_UINT8_ARRAY;
1280
1318
  }
1281
1319
  } else {
@@ -1313,6 +1351,10 @@ function getHeaderInfo(options) {
1313
1351
  if (compressionMethod === UNDEFINED_VALUE) {
1314
1352
  compressionMethod = compressed ? COMPRESSION_METHOD_DEFLATE : COMPRESSION_METHOD_STORE;
1315
1353
  }
1354
+ const { codecVersionNeeded } = options;
1355
+ if (compressed && codecVersionNeeded !== UNDEFINED_VALUE) {
1356
+ version = version > codecVersionNeeded ? version : codecVersionNeeded;
1357
+ }
1316
1358
  if (zip64) {
1317
1359
  version = version > VERSION_ZIP64 ? version : VERSION_ZIP64;
1318
1360
  }
@@ -1326,6 +1368,7 @@ function getHeaderInfo(options) {
1326
1368
  if (extraFieldLength > MAX_16_BITS) {
1327
1369
  throw new Error(ERR_INVALID_EXTRAFIELD_DATA);
1328
1370
  }
1371
+ const dosLastModDate = new Date(Math.ceil(lastModDate.getTime() / 2000) * 2000);
1329
1372
  const {
1330
1373
  headerArray,
1331
1374
  headerView,
@@ -1335,7 +1378,7 @@ function getHeaderInfo(options) {
1335
1378
  bitFlag: getBitFlag(level, useUnicodeFileNames, dataDescriptor, encrypted, compressionMethod),
1336
1379
  compressionMethod,
1337
1380
  uncompressedSize,
1338
- lastModDate: lastModDate < MIN_DATE ? MIN_DATE : lastModDate > MAX_DATE ? MAX_DATE : lastModDate,
1381
+ lastModDate: dosLastModDate < MIN_DATE ? MIN_DATE : dosLastModDate > MAX_DATE ? MAX_DATE : dosLastModDate,
1339
1382
  rawFilename,
1340
1383
  zip64CompressedSize,
1341
1384
  zip64UncompressedSize,
@@ -63,6 +63,13 @@ export {
63
63
  configure,
64
64
  resetConfiguration
65
65
  } from "./core/configuration.js";
66
+ export {
67
+ registerCodec,
68
+ unregisterCodec,
69
+ ERR_INVALID_CODEC_DEFINITION,
70
+ ERR_RESERVED_COMPRESSION_METHOD,
71
+ ERR_INVALID_CODEC_MODULE
72
+ } from "./core/codec-registry.js";
66
73
  export {
67
74
  createOPFSTempStream
68
75
  } from "./core/util/opfs-temp-stream.js";
@@ -44,5 +44,6 @@ export {
44
44
  ERR_INVALID_COMPRESSED_DATA,
45
45
  ERR_SPLIT_ZIP_FILE,
46
46
  ERR_OVERLAPPING_ENTRY,
47
- ERR_AMBIGUOUS_ARCHIVE
47
+ ERR_AMBIGUOUS_ARCHIVE,
48
+ ERR_ENCRYPTED_CENTRAL_DIRECTORY
48
49
  } from "./core/zip-reader.js";
@@ -37,6 +37,7 @@ export {
37
37
  ERR_INVALID_EXTRAFIELD_TYPE,
38
38
  ERR_INVALID_EXTRAFIELD_DATA,
39
39
  ERR_INVALID_ENCRYPTION_STRENGTH,
40
+ ERR_UNSUPPORTED_ENCRYPTION_USDZ,
40
41
  ERR_UNSUPPORTED_FORMAT,
41
42
  ERR_UNDEFINED_UNCOMPRESSED_SIZE,
42
43
  ERR_UNDEFINED_READER,
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "A JavaScript library to zip and unzip files in the browser, Deno and Node.js",
4
4
  "author": "Gildas Lormeau",
5
5
  "license": "BSD-3-Clause",
6
- "version": "2.8.36",
6
+ "version": "2.8.38",
7
7
  "type": "module",
8
8
  "keywords": [
9
9
  "zip",
@@ -1,3 +1,3 @@
1
- const WORKER_MESSAGE_PROPERTY_NAMES = ["baseURI", "checkPasswordOnly", "chunkSize", "code", "codecType", "compressed", "config", "deflate64", "done", "encrypted", "encryptionStrength", "error", "inputSize", "level", "message", "messageId", "name", "options", "outputSize", "password", "passwordVerification", "rawPassword", "readable", "result", "signature", "signed", "stack", "transferStreams", "type", "useCompressionStream", "useWebWorkers", "value", "wasmURI", "writable", "zipCrypto"];
1
+ const WORKER_MESSAGE_PROPERTY_NAMES = ["baseURI", "checkPasswordOnly", "chunkSize", "code", "codecType", "codecURI", "compressed", "config", "deflate64", "done", "encrypted", "encryptionStrength", "error", "format", "inputSize", "level", "message", "messageId", "name", "options", "outputSize", "password", "passwordVerification", "rawPassword", "readable", "result", "signature", "signed", "stack", "transferStreams", "type", "useCompressionStream", "useWebWorkers", "value", "wasmURI", "workerStartupTimeout", "writable", "zipCrypto"];
2
2
 
3
3
  export { WORKER_MESSAGE_PROPERTY_NAMES };