@zip.js/zip.js 2.17.0 → 2.18.1
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 +1 -1
- package/dist/zip-core-external.js +83 -44
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +83 -44
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +83 -44
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +83 -44
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +83 -44
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +85 -46
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +84 -45
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +85 -46
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +85 -46
- package/dist/zip-native.min.js +1 -1
- package/dist/zip-web-worker-native.js +1 -1
- package/dist/zip-web-worker.js +1 -1
- package/dist/zip.js +84 -45
- package/dist/zip.min.js +1 -1
- package/index-native.cjs +85 -46
- package/index-native.min.js +1 -1
- package/index.cjs +84 -45
- package/index.d.cts +49 -12
- package/index.d.ts +49 -12
- package/index.min.js +1 -1
- package/lib/core/codec-worker-web.js +7 -2
- package/lib/core/version.js +1 -1
- package/lib/core/web-worker-base.js +1 -1
- package/lib/core/web-worker-inline-native.js +1 -1
- package/lib/core/web-worker-inline-wasm.js +1 -1
- package/lib/core/zip-reader.js +75 -41
- package/package.json +1 -1
package/dist/zip-core.js
CHANGED
|
@@ -3245,8 +3245,13 @@
|
|
|
3245
3245
|
if (codecImportFailed) {
|
|
3246
3246
|
responseError.codecImportFailed = true;
|
|
3247
3247
|
}
|
|
3248
|
-
if (cause
|
|
3249
|
-
|
|
3248
|
+
if (cause) {
|
|
3249
|
+
if (!isErrorObject(responseError.cause)) {
|
|
3250
|
+
responseError.cause = Object.assign(new Error(cause.message), { name: cause.name });
|
|
3251
|
+
}
|
|
3252
|
+
if (cause.code !== UNDEFINED_VALUE && responseError.cause.code !== cause.code) {
|
|
3253
|
+
responseError.cause.code = cause.code;
|
|
3254
|
+
}
|
|
3250
3255
|
}
|
|
3251
3256
|
if (errorValue) {
|
|
3252
3257
|
if (responseError.name !== name) {
|
|
@@ -4818,7 +4823,7 @@
|
|
|
4818
4823
|
const CHARSET_UTF8 = "utf-8";
|
|
4819
4824
|
const PROPERTY_NAME_UTF8_SUFFIX = "UTF8";
|
|
4820
4825
|
const CHARSET_CP437 = "cp437";
|
|
4821
|
-
const BITFLAG_AMBIGUITY_MASK = BITFLAG_ENCRYPTED | BITFLAG_DATA_DESCRIPTOR | BITFLAG_LANG_ENCODING_FLAG;
|
|
4826
|
+
const BITFLAG_AMBIGUITY_MASK = BITFLAG_ENCRYPTED | BITFLAG_DATA_DESCRIPTOR | BITFLAG_STRONG_ENCRYPTION | BITFLAG_LANG_ENCODING_FLAG;
|
|
4822
4827
|
const VENDOR_VERSION_AE_1$1 = 1;
|
|
4823
4828
|
const ZIP64_PROPERTIES = [
|
|
4824
4829
|
[PROPERTY_NAME_UNCOMPRESSED_SIZE, MAX_32_BITS],
|
|
@@ -5472,12 +5477,12 @@
|
|
|
5472
5477
|
fileEntry.gid = gid;
|
|
5473
5478
|
}
|
|
5474
5479
|
const checkPasswordOnly = getOptionValue$1(zipEntry, options, OPTION_CHECK_PASSWORD_ONLY);
|
|
5475
|
-
const encrypted = zipEntry.encrypted &&
|
|
5480
|
+
const encrypted = zipEntry.encrypted && (!passThroughEncryption || checkPasswordOnly);
|
|
5476
5481
|
const zipCrypto = encrypted && !extraFieldAES;
|
|
5477
5482
|
if (!passThroughEncryption) {
|
|
5478
5483
|
fileEntry.zipCrypto = zipCrypto;
|
|
5479
5484
|
}
|
|
5480
|
-
if (encrypted && (
|
|
5485
|
+
if (encrypted && (zipEntry.rawBitFlag & BITFLAG_STRONG_ENCRYPTION) == BITFLAG_STRONG_ENCRYPTION) {
|
|
5481
5486
|
throw new Error(ERR_UNSUPPORTED_ENCRYPTION);
|
|
5482
5487
|
}
|
|
5483
5488
|
const registeredCodec = passThroughCompression ? UNDEFINED_VALUE : getRegisteredCodec(compressionMethod);
|
|
@@ -5717,8 +5722,16 @@
|
|
|
5717
5722
|
});
|
|
5718
5723
|
const extraFieldZip64 = extraField.get(EXTRAFIELD_TYPE_ZIP64);
|
|
5719
5724
|
if (extraFieldZip64) {
|
|
5720
|
-
readExtraFieldZip64(extraFieldZip64, directory)
|
|
5725
|
+
if (!readExtraFieldZip64(extraFieldZip64, directory, localDirectory)) {
|
|
5726
|
+
malformedExtraField = true;
|
|
5727
|
+
}
|
|
5721
5728
|
directory.extraFieldZip64 = extraFieldZip64;
|
|
5729
|
+
} else if (ZIP64_PROPERTIES.some(([propertyName, max]) => directory[propertyName] == max)) {
|
|
5730
|
+
if (localDirectory) {
|
|
5731
|
+
malformedExtraField = true;
|
|
5732
|
+
} else {
|
|
5733
|
+
throw new Error(ERR_EXTRAFIELD_ZIP64_NOT_FOUND);
|
|
5734
|
+
}
|
|
5722
5735
|
}
|
|
5723
5736
|
const extraFieldUnicodePath = extraField.get(EXTRAFIELD_TYPE_UNICODE_PATH);
|
|
5724
5737
|
if (extraFieldUnicodePath) {
|
|
@@ -5731,10 +5744,13 @@
|
|
|
5731
5744
|
directory.extraFieldUnicodeComment = extraFieldUnicodeComment;
|
|
5732
5745
|
}
|
|
5733
5746
|
const extraFieldAES = extraField.get(EXTRAFIELD_TYPE_AES);
|
|
5734
|
-
if (extraFieldAES && extraFieldAES.data.length >= 7) {
|
|
5747
|
+
if (extraFieldAES && (compressionMethod == COMPRESSION_METHOD_AES || directory.encrypted) && extraFieldAES.data.length >= 7) {
|
|
5735
5748
|
readExtraFieldAES(extraFieldAES, directory, compressionMethod);
|
|
5736
5749
|
directory.extraFieldAES = extraFieldAES;
|
|
5737
5750
|
} else {
|
|
5751
|
+
if (extraFieldAES) {
|
|
5752
|
+
malformedExtraField = true;
|
|
5753
|
+
}
|
|
5738
5754
|
directory.compressionMethod = compressionMethod;
|
|
5739
5755
|
}
|
|
5740
5756
|
const extraFieldPkwareUnix = extraField.get(EXTRAFIELD_TYPE_PKWARE_UNIX);
|
|
@@ -5777,20 +5793,35 @@
|
|
|
5777
5793
|
return malformedExtraField;
|
|
5778
5794
|
}
|
|
5779
5795
|
|
|
5780
|
-
function readExtraFieldZip64(extraFieldZip64, directory) {
|
|
5796
|
+
function readExtraFieldZip64(extraFieldZip64, directory, localDirectory) {
|
|
5781
5797
|
directory.zip64 = true;
|
|
5782
5798
|
const extraFieldView = getDataView(extraFieldZip64.data);
|
|
5783
5799
|
const missingProperties = ZIP64_PROPERTIES.filter(([propertyName, max]) => directory[propertyName] == max);
|
|
5784
5800
|
const requiredLength = missingProperties.reduce((length, [, max]) => length + ZIP64_EXTRACTION[max].bytes, 0);
|
|
5785
5801
|
if (extraFieldZip64.data.length < requiredLength) {
|
|
5802
|
+
if (localDirectory) {
|
|
5803
|
+
return false;
|
|
5804
|
+
}
|
|
5786
5805
|
throw new Error(ERR_EXTRAFIELD_ZIP64_NOT_FOUND);
|
|
5787
5806
|
}
|
|
5788
|
-
|
|
5789
|
-
|
|
5790
|
-
|
|
5791
|
-
|
|
5792
|
-
|
|
5807
|
+
const values = [];
|
|
5808
|
+
try {
|
|
5809
|
+
for (let indexMissingProperty = 0, offset = 0; indexMissingProperty < missingProperties.length; indexMissingProperty++) {
|
|
5810
|
+
const [, max] = missingProperties[indexMissingProperty];
|
|
5811
|
+
const extraction = ZIP64_EXTRACTION[max];
|
|
5812
|
+
values.push(extraction.getValue(extraFieldView, offset));
|
|
5813
|
+
offset += extraction.bytes;
|
|
5814
|
+
}
|
|
5815
|
+
} catch (error) {
|
|
5816
|
+
if (localDirectory) {
|
|
5817
|
+
return false;
|
|
5818
|
+
}
|
|
5819
|
+
throw error;
|
|
5793
5820
|
}
|
|
5821
|
+
missingProperties.forEach(([propertyName], indexMissingProperty) => {
|
|
5822
|
+
directory[propertyName] = extraFieldZip64[propertyName] = values[indexMissingProperty];
|
|
5823
|
+
});
|
|
5824
|
+
return true;
|
|
5794
5825
|
}
|
|
5795
5826
|
|
|
5796
5827
|
function readExtraFieldUnicode(extraFieldUnicode, propertyName, rawPropertyName, directory, fileEntry) {
|
|
@@ -5972,32 +6003,27 @@
|
|
|
5972
6003
|
}) {
|
|
5973
6004
|
let dataDescriptorLength = 0;
|
|
5974
6005
|
if (dataDescriptor) {
|
|
5975
|
-
|
|
5976
|
-
|
|
5977
|
-
} else {
|
|
5978
|
-
dataDescriptorLength = DATA_DESCRIPTOR_RECORD_LENGTH;
|
|
5979
|
-
}
|
|
5980
|
-
}
|
|
5981
|
-
if (dataDescriptorLength) {
|
|
5982
|
-
const dataDescriptorArray = await readUint8Array(reader, dataOffset + compressedSize, dataDescriptorLength + DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH);
|
|
6006
|
+
const zip64 = Boolean(extraFieldZip64);
|
|
6007
|
+
const dataDescriptorArray = await readUint8Array(reader, dataOffset + compressedSize, DATA_DESCRIPTOR_RECORD_ZIP_64_LENGTH + DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH);
|
|
5983
6008
|
const dataDescriptorView = getDataView(dataDescriptorArray);
|
|
5984
|
-
|
|
5985
|
-
|
|
5986
|
-
|
|
5987
|
-
const
|
|
5988
|
-
|
|
5989
|
-
|
|
5990
|
-
|
|
5991
|
-
|
|
5992
|
-
dataDescriptorLength += DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH;
|
|
5993
|
-
} else {
|
|
5994
|
-
signature = false;
|
|
6009
|
+
const ignoreCrc32 = fileEntry.encrypted && !fileEntry.zipCrypto;
|
|
6010
|
+
let localDataDescriptor;
|
|
6011
|
+
for (const [zip64Layout, signature] of [[zip64, true], [zip64, false], [!zip64, true], [!zip64, false]]) {
|
|
6012
|
+
const candidate = readDataDescriptor(dataDescriptorView, zip64Layout, signature);
|
|
6013
|
+
if (candidate && (ignoreCrc32 || candidate.crc32 == crc32) &&
|
|
6014
|
+
candidate.compressedSize == compressedSize && candidate.uncompressedSize == uncompressedSize) {
|
|
6015
|
+
localDataDescriptor = candidate;
|
|
6016
|
+
break;
|
|
5995
6017
|
}
|
|
5996
6018
|
}
|
|
5997
|
-
if (
|
|
5998
|
-
|
|
5999
|
-
|
|
6019
|
+
if (!localDataDescriptor) {
|
|
6020
|
+
localDataDescriptor = readDataDescriptor(dataDescriptorView, zip64, false);
|
|
6021
|
+
}
|
|
6022
|
+
if (localDataDescriptor) {
|
|
6000
6023
|
fileEntry.localDirectory.dataDescriptor = localDataDescriptor;
|
|
6024
|
+
dataDescriptorLength = getDataDescriptorLength(localDataDescriptor.zip64, localDataDescriptor.signature);
|
|
6025
|
+
} else {
|
|
6026
|
+
dataDescriptorLength = getDataDescriptorLength(zip64, false);
|
|
6001
6027
|
}
|
|
6002
6028
|
}
|
|
6003
6029
|
const range = {
|
|
@@ -6062,18 +6088,31 @@
|
|
|
6062
6088
|
return mergedRanges;
|
|
6063
6089
|
}
|
|
6064
6090
|
|
|
6065
|
-
function readDataDescriptor(dataDescriptorView,
|
|
6091
|
+
function readDataDescriptor(dataDescriptorView, zip64, signature) {
|
|
6092
|
+
const offset = signature ? DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH : 0;
|
|
6093
|
+
if (dataDescriptorView.byteLength < getDataDescriptorLength(zip64, signature) ||
|
|
6094
|
+
(signature && getUint32$1(dataDescriptorView, 0) != DATA_DESCRIPTOR_RECORD_SIGNATURE)) {
|
|
6095
|
+
return UNDEFINED_VALUE;
|
|
6096
|
+
}
|
|
6066
6097
|
const crc32 = getUint32$1(dataDescriptorView, offset);
|
|
6067
6098
|
let compressedSize;
|
|
6068
6099
|
let uncompressedSize;
|
|
6069
|
-
|
|
6070
|
-
|
|
6071
|
-
|
|
6072
|
-
|
|
6073
|
-
|
|
6074
|
-
|
|
6100
|
+
try {
|
|
6101
|
+
if (zip64) {
|
|
6102
|
+
compressedSize = getBigUint64(dataDescriptorView, offset + 4);
|
|
6103
|
+
uncompressedSize = getBigUint64(dataDescriptorView, offset + 12);
|
|
6104
|
+
} else {
|
|
6105
|
+
compressedSize = getUint32$1(dataDescriptorView, offset + 4);
|
|
6106
|
+
uncompressedSize = getUint32$1(dataDescriptorView, offset + 8);
|
|
6107
|
+
}
|
|
6108
|
+
} catch {
|
|
6109
|
+
return UNDEFINED_VALUE;
|
|
6075
6110
|
}
|
|
6076
|
-
return { crc32, compressedSize, uncompressedSize };
|
|
6111
|
+
return { signature, zip64, crc32, compressedSize, uncompressedSize };
|
|
6112
|
+
}
|
|
6113
|
+
|
|
6114
|
+
function getDataDescriptorLength(zip64, signature) {
|
|
6115
|
+
return (zip64 ? DATA_DESCRIPTOR_RECORD_ZIP_64_LENGTH : DATA_DESCRIPTOR_RECORD_LENGTH) + (signature ? DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH : 0);
|
|
6077
6116
|
}
|
|
6078
6117
|
|
|
6079
6118
|
function getDiskOffset$1(reader, diskNumber) {
|
|
@@ -8896,7 +8935,7 @@
|
|
|
8896
8935
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
8897
8936
|
*/
|
|
8898
8937
|
|
|
8899
|
-
const VERSION = "2.
|
|
8938
|
+
const VERSION = "2.18.1";
|
|
8900
8939
|
|
|
8901
8940
|
/*
|
|
8902
8941
|
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|