@zip.js/zip.js 2.7.50 → 2.7.52
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-fs-full.js +36 -26
- package/dist/zip-fs-full.min.js +1 -1
- package/dist/zip-fs.js +36 -26
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-full.js +24 -20
- package/dist/zip-full.min.js +1 -1
- package/dist/zip-no-worker-deflate.min.js +1 -1
- package/dist/zip-no-worker-inflate.min.js +1 -1
- package/dist/zip-no-worker.min.js +1 -1
- package/dist/zip.js +24 -20
- package/dist/zip.min.js +1 -1
- package/index.cjs +36 -26
- package/index.d.ts +11 -3
- package/index.min.js +1 -1
- package/lib/core/zip-entry.js +11 -4
- package/lib/core/zip-fs-core.js +12 -6
- package/lib/core/zip-reader.js +3 -3
- package/lib/core/zip-writer.js +18 -13
- package/package.json +1 -1
package/deno.json
CHANGED
package/dist/zip-fs-full.js
CHANGED
|
@@ -9202,16 +9202,19 @@
|
|
|
9202
9202
|
const PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTE = "externalFileAttribute";
|
|
9203
9203
|
const PROPERTY_NAME_MS_DOS_COMPATIBLE = "msDosCompatible";
|
|
9204
9204
|
const PROPERTY_NAME_ZIP64 = "zip64";
|
|
9205
|
+
const PROPERTY_NAME_ENCRYPTED = "encrypted";
|
|
9206
|
+
const PROPERTY_NAME_VERSION = "version";
|
|
9207
|
+
const PROPERTY_NAME_VERSION_MADE_BY = "versionMadeBy";
|
|
9208
|
+
const PROPERTY_NAME_ZIPCRYPTO = "zipCrypto";
|
|
9205
9209
|
|
|
9206
9210
|
const PROPERTY_NAMES = [
|
|
9207
9211
|
PROPERTY_NAME_FILENAME, PROPERTY_NAME_RAW_FILENAME, PROPERTY_NAME_COMPPRESSED_SIZE, PROPERTY_NAME_UNCOMPPRESSED_SIZE,
|
|
9208
9212
|
PROPERTY_NAME_LAST_MODIFICATION_DATE, PROPERTY_NAME_RAW_LAST_MODIFICATION_DATE, PROPERTY_NAME_COMMENT, PROPERTY_NAME_RAW_COMMENT,
|
|
9209
9213
|
PROPERTY_NAME_LAST_ACCESS_DATE, PROPERTY_NAME_CREATION_DATE, PROPERTY_NAME_OFFSET, PROPERTY_NAME_DISK_NUMBER_START,
|
|
9210
9214
|
PROPERTY_NAME_DISK_NUMBER_START, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTE, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTE,
|
|
9211
|
-
PROPERTY_NAME_MS_DOS_COMPATIBLE, PROPERTY_NAME_ZIP64,
|
|
9212
|
-
"directory", "bitFlag", "
|
|
9213
|
-
"
|
|
9214
|
-
"extraFieldExtendedTimestamp", "zipCrypto"];
|
|
9215
|
+
PROPERTY_NAME_MS_DOS_COMPATIBLE, PROPERTY_NAME_ZIP64, PROPERTY_NAME_ENCRYPTED, PROPERTY_NAME_VERSION, PROPERTY_NAME_VERSION_MADE_BY,
|
|
9216
|
+
PROPERTY_NAME_ZIPCRYPTO, "directory", "bitFlag", "signature", "filenameUTF8", "commentUTF8", "compressionMethod", "extraField", "rawExtraField",
|
|
9217
|
+
"extraFieldZip64", "extraFieldUnicodePath", "extraFieldUnicodeComment", "extraFieldAES", "extraFieldNTFS", "extraFieldExtendedTimestamp"];
|
|
9215
9218
|
|
|
9216
9219
|
class Entry {
|
|
9217
9220
|
|
|
@@ -9542,6 +9545,7 @@
|
|
|
9542
9545
|
const dataView = getDataView$1(dataArray);
|
|
9543
9546
|
let password = getOptionValue$1(zipEntry, options, "password");
|
|
9544
9547
|
let rawPassword = getOptionValue$1(zipEntry, options, "rawPassword");
|
|
9548
|
+
const passThrough = getOptionValue$1(zipEntry, options, "passThrough");
|
|
9545
9549
|
password = password && password.length && password;
|
|
9546
9550
|
rawPassword = rawPassword && rawPassword.length && rawPassword;
|
|
9547
9551
|
if (extraFieldAES) {
|
|
@@ -9549,7 +9553,7 @@
|
|
|
9549
9553
|
throw new Error(ERR_UNSUPPORTED_COMPRESSION);
|
|
9550
9554
|
}
|
|
9551
9555
|
}
|
|
9552
|
-
if (compressionMethod != COMPRESSION_METHOD_STORE && compressionMethod != COMPRESSION_METHOD_DEFLATE) {
|
|
9556
|
+
if ((compressionMethod != COMPRESSION_METHOD_STORE && compressionMethod != COMPRESSION_METHOD_DEFLATE) && !passThrough) {
|
|
9553
9557
|
throw new Error(ERR_UNSUPPORTED_COMPRESSION);
|
|
9554
9558
|
}
|
|
9555
9559
|
if (getUint32(dataView, 0) != LOCAL_FILE_HEADER_SIGNATURE) {
|
|
@@ -9564,7 +9568,6 @@
|
|
|
9564
9568
|
lastAccessDate: localDirectory.lastAccessDate,
|
|
9565
9569
|
creationDate: localDirectory.creationDate
|
|
9566
9570
|
});
|
|
9567
|
-
const passThrough = getOptionValue$1(zipEntry, options, "passThrough");
|
|
9568
9571
|
const encrypted = zipEntry.encrypted && localDirectory.encrypted && !passThrough;
|
|
9569
9572
|
const zipCrypto = encrypted && !extraFieldAES;
|
|
9570
9573
|
if (!passThrough) {
|
|
@@ -9591,7 +9594,7 @@
|
|
|
9591
9594
|
writer = new WritableStream();
|
|
9592
9595
|
}
|
|
9593
9596
|
writer = initWriter(writer);
|
|
9594
|
-
await initStream(writer, uncompressedSize);
|
|
9597
|
+
await initStream(writer, passThrough ? compressedSize : uncompressedSize);
|
|
9595
9598
|
const { writable } = writer;
|
|
9596
9599
|
const { onstart, onprogress, onend } = options;
|
|
9597
9600
|
const workerOptions = {
|
|
@@ -10063,11 +10066,11 @@
|
|
|
10063
10066
|
if (getLength(rawComment) > MAX_16_BITS) {
|
|
10064
10067
|
throw new Error(ERR_INVALID_ENTRY_COMMENT);
|
|
10065
10068
|
}
|
|
10066
|
-
const version = getOptionValue(zipWriter, options,
|
|
10069
|
+
const version = getOptionValue(zipWriter, options, PROPERTY_NAME_VERSION, VERSION_DEFLATE);
|
|
10067
10070
|
if (version > MAX_16_BITS) {
|
|
10068
10071
|
throw new Error(ERR_INVALID_VERSION);
|
|
10069
10072
|
}
|
|
10070
|
-
const versionMadeBy = getOptionValue(zipWriter, options,
|
|
10073
|
+
const versionMadeBy = getOptionValue(zipWriter, options, PROPERTY_NAME_VERSION_MADE_BY, 20);
|
|
10071
10074
|
if (versionMadeBy > MAX_16_BITS) {
|
|
10072
10075
|
throw new Error(ERR_INVALID_VERSION);
|
|
10073
10076
|
}
|
|
@@ -10084,7 +10087,7 @@
|
|
|
10084
10087
|
rawPassword = getOptionValue(zipWriter, options, "rawPassword");
|
|
10085
10088
|
}
|
|
10086
10089
|
const encryptionStrength = getOptionValue(zipWriter, options, "encryptionStrength", 3);
|
|
10087
|
-
const zipCrypto = getOptionValue(zipWriter, options,
|
|
10090
|
+
const zipCrypto = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIPCRYPTO);
|
|
10088
10091
|
const extendedTimestamp = getOptionValue(zipWriter, options, "extendedTimestamp", true);
|
|
10089
10092
|
const keepOrder = getOptionValue(zipWriter, options, "keepOrder", true);
|
|
10090
10093
|
const level = getOptionValue(zipWriter, options, "level");
|
|
@@ -10094,9 +10097,10 @@
|
|
|
10094
10097
|
const signal = getOptionValue(zipWriter, options, "signal");
|
|
10095
10098
|
const useUnicodeFileNames = getOptionValue(zipWriter, options, "useUnicodeFileNames", true);
|
|
10096
10099
|
const useCompressionStream = getOptionValue(zipWriter, options, "useCompressionStream");
|
|
10100
|
+
const compressionMethod = getOptionValue(zipWriter, options, "compressionMethod");
|
|
10097
10101
|
let dataDescriptor = getOptionValue(zipWriter, options, "dataDescriptor", true);
|
|
10098
10102
|
let zip64 = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIP64);
|
|
10099
|
-
if ((password !== UNDEFINED_VALUE || rawPassword !== UNDEFINED_VALUE) &&
|
|
10103
|
+
if (!zipCrypto && (password !== UNDEFINED_VALUE || rawPassword !== UNDEFINED_VALUE) && !(encryptionStrength >= 1 && encryptionStrength <= 3)) {
|
|
10100
10104
|
throw new Error(ERR_INVALID_ENCRYPTION_STRENGTH);
|
|
10101
10105
|
}
|
|
10102
10106
|
let rawExtraField = new Uint8Array();
|
|
@@ -10161,7 +10165,7 @@
|
|
|
10161
10165
|
}
|
|
10162
10166
|
}
|
|
10163
10167
|
zip64 = zip64 || false;
|
|
10164
|
-
const encrypted = getOptionValue(zipWriter, options,
|
|
10168
|
+
const encrypted = getOptionValue(zipWriter, options, PROPERTY_NAME_ENCRYPTED);
|
|
10165
10169
|
const { signature } = options;
|
|
10166
10170
|
options = Object.assign({}, options, {
|
|
10167
10171
|
rawFilename,
|
|
@@ -10196,7 +10200,8 @@
|
|
|
10196
10200
|
useCompressionStream,
|
|
10197
10201
|
passThrough,
|
|
10198
10202
|
encrypted: Boolean((password && getLength(password)) || (rawPassword && getLength(rawPassword))) || (passThrough && encrypted),
|
|
10199
|
-
signature
|
|
10203
|
+
signature,
|
|
10204
|
+
compressionMethod
|
|
10200
10205
|
});
|
|
10201
10206
|
const headerInfo = getHeaderInfo(options);
|
|
10202
10207
|
const dataDescriptorInfo = getDataDescriptorInfo(options);
|
|
@@ -10544,7 +10549,7 @@
|
|
|
10544
10549
|
encrypted
|
|
10545
10550
|
} = options;
|
|
10546
10551
|
const compressed = level !== 0 && !directory;
|
|
10547
|
-
let version = options
|
|
10552
|
+
let { version, compressionMethod } = options;
|
|
10548
10553
|
let rawExtraFieldAES;
|
|
10549
10554
|
if (encrypted && !zipCrypto) {
|
|
10550
10555
|
rawExtraFieldAES = new Uint8Array(getLength(EXTRAFIELD_DATA_AES) + 2);
|
|
@@ -10599,9 +10604,10 @@
|
|
|
10599
10604
|
if (dataDescriptor) {
|
|
10600
10605
|
bitFlag = bitFlag | BITFLAG_DATA_DESCRIPTOR;
|
|
10601
10606
|
}
|
|
10602
|
-
|
|
10607
|
+
if (compressionMethod === UNDEFINED_VALUE) {
|
|
10608
|
+
compressionMethod = compressed ? COMPRESSION_METHOD_DEFLATE : COMPRESSION_METHOD_STORE;
|
|
10609
|
+
}
|
|
10603
10610
|
if (compressed) {
|
|
10604
|
-
compressionMethod = COMPRESSION_METHOD_DEFLATE;
|
|
10605
10611
|
if (level >= 1 && level < 3) {
|
|
10606
10612
|
bitFlag = bitFlag | 0b110;
|
|
10607
10613
|
}
|
|
@@ -10619,10 +10625,8 @@
|
|
|
10619
10625
|
bitFlag = bitFlag | BITFLAG_ENCRYPTED;
|
|
10620
10626
|
if (!zipCrypto) {
|
|
10621
10627
|
version = version > VERSION_AES ? version : VERSION_AES;
|
|
10628
|
+
rawExtraFieldAES[9] = compressionMethod;
|
|
10622
10629
|
compressionMethod = COMPRESSION_METHOD_AES;
|
|
10623
|
-
if (compressed) {
|
|
10624
|
-
rawExtraFieldAES[9] = COMPRESSION_METHOD_DEFLATE;
|
|
10625
|
-
}
|
|
10626
10630
|
}
|
|
10627
10631
|
}
|
|
10628
10632
|
const headerArray = new Uint8Array(26);
|
|
@@ -10937,7 +10941,7 @@
|
|
|
10937
10941
|
if (availableSize < END_OF_CENTRAL_DIR_LENGTH) {
|
|
10938
10942
|
lastDiskNumber++;
|
|
10939
10943
|
}
|
|
10940
|
-
let zip64 = getOptionValue(zipWriter, options,
|
|
10944
|
+
let zip64 = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIP64);
|
|
10941
10945
|
if (directoryOffset > MAX_32_BITS || directoryDataLength > MAX_32_BITS || filesLength > MAX_16_BITS || lastDiskNumber > MAX_16_BITS) {
|
|
10942
10946
|
if (zip64 === false) {
|
|
10943
10947
|
throw new Error(ERR_UNSUPPORTED_FORMAT);
|
|
@@ -11762,12 +11766,9 @@
|
|
|
11762
11766
|
encrypted,
|
|
11763
11767
|
zipCrypto,
|
|
11764
11768
|
signature,
|
|
11765
|
-
compressionMethod
|
|
11769
|
+
compressionMethod,
|
|
11770
|
+
extraFieldAES
|
|
11766
11771
|
} = child.data;
|
|
11767
|
-
let level;
|
|
11768
|
-
if (compressionMethod === 0) {
|
|
11769
|
-
level = 0;
|
|
11770
|
-
}
|
|
11771
11772
|
zipEntryOptions = {
|
|
11772
11773
|
externalFileAttribute,
|
|
11773
11774
|
versionMadeBy,
|
|
@@ -11777,13 +11778,22 @@
|
|
|
11777
11778
|
lastAccessDate
|
|
11778
11779
|
};
|
|
11779
11780
|
if (child.passThrough) {
|
|
11781
|
+
let level, encryptionStrength;
|
|
11782
|
+
if (compressionMethod === 0) {
|
|
11783
|
+
level = 0;
|
|
11784
|
+
}
|
|
11785
|
+
if (extraFieldAES) {
|
|
11786
|
+
encryptionStrength = extraFieldAES.strength;
|
|
11787
|
+
}
|
|
11780
11788
|
zipEntryOptions = Object.assign(zipEntryOptions, {
|
|
11781
11789
|
passThrough: true,
|
|
11782
11790
|
encrypted,
|
|
11783
11791
|
zipCrypto,
|
|
11784
11792
|
signature,
|
|
11785
11793
|
uncompressedSize,
|
|
11786
|
-
level
|
|
11794
|
+
level,
|
|
11795
|
+
encryptionStrength,
|
|
11796
|
+
compressionMethod
|
|
11787
11797
|
});
|
|
11788
11798
|
}
|
|
11789
11799
|
}
|