@zip.js/zip.js 2.7.48 → 2.7.49
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 +93 -30
- package/dist/zip-fs-full.min.js +1 -1
- package/dist/zip-fs.js +93 -30
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-full.js +69 -27
- 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 +69 -27
- package/dist/zip.min.js +1 -1
- package/index.cjs +93 -30
- package/index.d.ts +35 -20
- package/index.js +1 -0
- package/index.min.js +1 -1
- package/lib/core/zip-entry.js +1 -1
- package/lib/core/zip-fs-core.js +24 -3
- package/lib/core/zip-reader.js +9 -4
- package/lib/core/zip-writer.js +61 -24
- package/package.json +3 -3
package/deno.json
CHANGED
package/dist/zip-fs-full.js
CHANGED
|
@@ -9211,7 +9211,7 @@
|
|
|
9211
9211
|
PROPERTY_NAME_MS_DOS_COMPATIBLE, PROPERTY_NAME_ZIP64,
|
|
9212
9212
|
"directory", "bitFlag", "encrypted", "signature", "filenameUTF8", "commentUTF8", "compressionMethod", "version", "versionMadeBy",
|
|
9213
9213
|
"extraField", "rawExtraField", "extraFieldZip64", "extraFieldUnicodePath", "extraFieldUnicodeComment", "extraFieldAES", "extraFieldNTFS",
|
|
9214
|
-
"extraFieldExtendedTimestamp"];
|
|
9214
|
+
"extraFieldExtendedTimestamp", "zipCrypto"];
|
|
9215
9215
|
|
|
9216
9216
|
class Entry {
|
|
9217
9217
|
|
|
@@ -9446,6 +9446,7 @@
|
|
|
9446
9446
|
});
|
|
9447
9447
|
startOffset = Math.max(offsetFileEntry, startOffset);
|
|
9448
9448
|
await readCommonFooter(fileEntry, fileEntry, directoryView, offset + 6);
|
|
9449
|
+
fileEntry.zipCrypto = fileEntry.encrypted && !fileEntry.extraFieldAES;
|
|
9449
9450
|
const entry = new Entry(fileEntry);
|
|
9450
9451
|
entry.getData = (writer, options) => fileEntry.getData(writer, entry, options);
|
|
9451
9452
|
offset = endOffset;
|
|
@@ -9563,8 +9564,12 @@
|
|
|
9563
9564
|
lastAccessDate: localDirectory.lastAccessDate,
|
|
9564
9565
|
creationDate: localDirectory.creationDate
|
|
9565
9566
|
});
|
|
9566
|
-
const
|
|
9567
|
+
const passThrough = getOptionValue$1(zipEntry, options, "passThrough");
|
|
9568
|
+
const encrypted = zipEntry.encrypted && localDirectory.encrypted && !passThrough;
|
|
9567
9569
|
const zipCrypto = encrypted && !extraFieldAES;
|
|
9570
|
+
if (!passThrough) {
|
|
9571
|
+
fileEntry.zipCrypto = zipCrypto;
|
|
9572
|
+
}
|
|
9568
9573
|
if (encrypted) {
|
|
9569
9574
|
if (!zipCrypto && extraFieldAES.strength === UNDEFINED_VALUE) {
|
|
9570
9575
|
throw new Error(ERR_UNSUPPORTED_ENCRYPTION);
|
|
@@ -9596,11 +9601,11 @@
|
|
|
9596
9601
|
rawPassword,
|
|
9597
9602
|
zipCrypto,
|
|
9598
9603
|
encryptionStrength: extraFieldAES && extraFieldAES.strength,
|
|
9599
|
-
signed: getOptionValue$1(zipEntry, options, "checkSignature"),
|
|
9604
|
+
signed: getOptionValue$1(zipEntry, options, "checkSignature") && !passThrough,
|
|
9600
9605
|
passwordVerification: zipCrypto && (bitFlag.dataDescriptor ? ((rawLastModDate >>> 8) & 0xFF) : ((signature >>> 24) & 0xFF)),
|
|
9601
9606
|
signature,
|
|
9602
|
-
compressed: compressionMethod != 0,
|
|
9603
|
-
encrypted,
|
|
9607
|
+
compressed: compressionMethod != 0 && !passThrough,
|
|
9608
|
+
encrypted: zipEntry.encrypted && !passThrough,
|
|
9604
9609
|
useWebWorkers: getOptionValue$1(zipEntry, options, "useWebWorkers"),
|
|
9605
9610
|
useCompressionStream: getOptionValue$1(zipEntry, options, "useCompressionStream"),
|
|
9606
9611
|
transferStreams: getOptionValue$1(zipEntry, options, "transferStreams"),
|
|
@@ -9929,6 +9934,7 @@
|
|
|
9929
9934
|
const ERR_INVALID_EXTRAFIELD_TYPE = "Extra field type exceeds 65535";
|
|
9930
9935
|
const ERR_INVALID_EXTRAFIELD_DATA = "Extra field data exceeds 64KB";
|
|
9931
9936
|
const ERR_UNSUPPORTED_FORMAT = "Zip64 is not supported (make sure 'keepOrder' is set to 'true')";
|
|
9937
|
+
const ERR_UNDEFINED_UNCOMPRESSED_SIZE = "Undefined uncompressed size";
|
|
9932
9938
|
|
|
9933
9939
|
const EXTRAFIELD_DATA_AES = new Uint8Array([0x07, 0x00, 0x02, 0x00, 0x41, 0x45, 0x03, 0x00, 0x00]);
|
|
9934
9940
|
|
|
@@ -10071,8 +10077,12 @@
|
|
|
10071
10077
|
const msDosCompatible = getOptionValue(zipWriter, options, PROPERTY_NAME_MS_DOS_COMPATIBLE, true);
|
|
10072
10078
|
const internalFileAttribute = getOptionValue(zipWriter, options, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTE, 0);
|
|
10073
10079
|
const externalFileAttribute = getOptionValue(zipWriter, options, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTE, 0);
|
|
10074
|
-
const
|
|
10075
|
-
|
|
10080
|
+
const passThrough = getOptionValue(zipWriter, options, "passThrough");
|
|
10081
|
+
let password, rawPassword;
|
|
10082
|
+
if (!passThrough) {
|
|
10083
|
+
password = getOptionValue(zipWriter, options, "password");
|
|
10084
|
+
rawPassword = getOptionValue(zipWriter, options, "rawPassword");
|
|
10085
|
+
}
|
|
10076
10086
|
const encryptionStrength = getOptionValue(zipWriter, options, "encryptionStrength", 3);
|
|
10077
10087
|
const zipCrypto = getOptionValue(zipWriter, options, "zipCrypto");
|
|
10078
10088
|
const extendedTimestamp = getOptionValue(zipWriter, options, "extendedTimestamp", true);
|
|
@@ -10086,7 +10096,7 @@
|
|
|
10086
10096
|
const useCompressionStream = getOptionValue(zipWriter, options, "useCompressionStream");
|
|
10087
10097
|
let dataDescriptor = getOptionValue(zipWriter, options, "dataDescriptor", true);
|
|
10088
10098
|
let zip64 = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIP64);
|
|
10089
|
-
if (password !== UNDEFINED_VALUE && encryptionStrength !== UNDEFINED_VALUE && (encryptionStrength < 1 || encryptionStrength > 3)) {
|
|
10099
|
+
if ((password !== UNDEFINED_VALUE || rawPassword !== UNDEFINED_VALUE) && encryptionStrength !== UNDEFINED_VALUE && (encryptionStrength < 1 || encryptionStrength > 3)) {
|
|
10090
10100
|
throw new Error(ERR_INVALID_ENCRYPTION_STRENGTH);
|
|
10091
10101
|
}
|
|
10092
10102
|
let rawExtraField = new Uint8Array();
|
|
@@ -10112,18 +10122,28 @@
|
|
|
10112
10122
|
let maximumCompressedSize = 0;
|
|
10113
10123
|
let maximumEntrySize = 0;
|
|
10114
10124
|
let uncompressedSize = 0;
|
|
10125
|
+
if (passThrough) {
|
|
10126
|
+
({ uncompressedSize } = options);
|
|
10127
|
+
if (uncompressedSize === UNDEFINED_VALUE) {
|
|
10128
|
+
throw new Error(ERR_UNDEFINED_UNCOMPRESSED_SIZE);
|
|
10129
|
+
}
|
|
10130
|
+
}
|
|
10115
10131
|
const zip64Enabled = zip64 === true;
|
|
10116
10132
|
if (reader) {
|
|
10117
10133
|
reader = initReader(reader);
|
|
10118
10134
|
await initStream(reader);
|
|
10119
|
-
if (
|
|
10120
|
-
|
|
10121
|
-
|
|
10122
|
-
zip64
|
|
10123
|
-
|
|
10135
|
+
if (!passThrough) {
|
|
10136
|
+
if (reader.size === UNDEFINED_VALUE) {
|
|
10137
|
+
dataDescriptor = true;
|
|
10138
|
+
if (zip64 || zip64 === UNDEFINED_VALUE) {
|
|
10139
|
+
zip64 = true;
|
|
10140
|
+
uncompressedSize = maximumCompressedSize = MAX_32_BITS + 1;
|
|
10141
|
+
}
|
|
10142
|
+
} else {
|
|
10143
|
+
uncompressedSize = reader.size;
|
|
10144
|
+
maximumCompressedSize = getMaximumCompressedSize(uncompressedSize);
|
|
10124
10145
|
}
|
|
10125
10146
|
} else {
|
|
10126
|
-
uncompressedSize = reader.size;
|
|
10127
10147
|
maximumCompressedSize = getMaximumCompressedSize(uncompressedSize);
|
|
10128
10148
|
}
|
|
10129
10149
|
}
|
|
@@ -10141,6 +10161,8 @@
|
|
|
10141
10161
|
}
|
|
10142
10162
|
}
|
|
10143
10163
|
zip64 = zip64 || false;
|
|
10164
|
+
const encrypted = getOptionValue(zipWriter, options, "encrypted");
|
|
10165
|
+
const { signature } = options;
|
|
10144
10166
|
options = Object.assign({}, options, {
|
|
10145
10167
|
rawFilename,
|
|
10146
10168
|
rawComment,
|
|
@@ -10171,7 +10193,10 @@
|
|
|
10171
10193
|
msDosCompatible,
|
|
10172
10194
|
internalFileAttribute,
|
|
10173
10195
|
externalFileAttribute,
|
|
10174
|
-
useCompressionStream
|
|
10196
|
+
useCompressionStream,
|
|
10197
|
+
passThrough,
|
|
10198
|
+
encrypted: Boolean((password && getLength(password)) || (rawPassword && getLength(rawPassword))) || (passThrough && encrypted),
|
|
10199
|
+
signature
|
|
10175
10200
|
});
|
|
10176
10201
|
const headerInfo = getHeaderInfo(options);
|
|
10177
10202
|
const dataDescriptorInfo = getDataDescriptorInfo(options);
|
|
@@ -10382,7 +10407,8 @@
|
|
|
10382
10407
|
msDosCompatible,
|
|
10383
10408
|
internalFileAttribute,
|
|
10384
10409
|
externalFileAttribute,
|
|
10385
|
-
useCompressionStream
|
|
10410
|
+
useCompressionStream,
|
|
10411
|
+
passThrough
|
|
10386
10412
|
} = options;
|
|
10387
10413
|
const fileEntry = {
|
|
10388
10414
|
lock,
|
|
@@ -10403,9 +10429,14 @@
|
|
|
10403
10429
|
externalFileAttribute,
|
|
10404
10430
|
diskNumberStart
|
|
10405
10431
|
};
|
|
10432
|
+
let {
|
|
10433
|
+
signature,
|
|
10434
|
+
uncompressedSize
|
|
10435
|
+
} = options;
|
|
10406
10436
|
let compressedSize = 0;
|
|
10407
|
-
|
|
10408
|
-
|
|
10437
|
+
if (!passThrough) {
|
|
10438
|
+
uncompressedSize = 0;
|
|
10439
|
+
}
|
|
10409
10440
|
const { writable } = writer;
|
|
10410
10441
|
if (reader) {
|
|
10411
10442
|
reader.chunkSize = getChunkSize(config);
|
|
@@ -10421,9 +10452,9 @@
|
|
|
10421
10452
|
encryptionStrength,
|
|
10422
10453
|
zipCrypto: encrypted && zipCrypto,
|
|
10423
10454
|
passwordVerification: encrypted && zipCrypto && (rawLastModDate >> 8) & 0xFF,
|
|
10424
|
-
signed:
|
|
10425
|
-
compressed,
|
|
10426
|
-
encrypted,
|
|
10455
|
+
signed: !passThrough,
|
|
10456
|
+
compressed: compressed && !passThrough,
|
|
10457
|
+
encrypted: encrypted && !passThrough,
|
|
10427
10458
|
useWebWorkers,
|
|
10428
10459
|
useCompressionStream,
|
|
10429
10460
|
transferStreams: false
|
|
@@ -10432,9 +10463,11 @@
|
|
|
10432
10463
|
streamOptions: { signal, size, onstart, onprogress, onend }
|
|
10433
10464
|
};
|
|
10434
10465
|
const result = await runWorker({ readable, writable }, workerOptions);
|
|
10435
|
-
uncompressedSize = result.inputSize;
|
|
10436
10466
|
compressedSize = result.outputSize;
|
|
10437
|
-
|
|
10467
|
+
if (!passThrough) {
|
|
10468
|
+
uncompressedSize = result.inputSize;
|
|
10469
|
+
signature = result.signature;
|
|
10470
|
+
}
|
|
10438
10471
|
writable.size += uncompressedSize;
|
|
10439
10472
|
} else {
|
|
10440
10473
|
await writeData(writable, localHeaderArray);
|
|
@@ -10477,6 +10510,7 @@
|
|
|
10477
10510
|
creationDate,
|
|
10478
10511
|
lastAccessDate,
|
|
10479
10512
|
encrypted,
|
|
10513
|
+
zipCrypto,
|
|
10480
10514
|
size: metadataSize + compressedSize,
|
|
10481
10515
|
compressionMethod,
|
|
10482
10516
|
version,
|
|
@@ -10498,8 +10532,6 @@
|
|
|
10498
10532
|
lastModDate,
|
|
10499
10533
|
lastAccessDate,
|
|
10500
10534
|
creationDate,
|
|
10501
|
-
rawPassword,
|
|
10502
|
-
password,
|
|
10503
10535
|
level,
|
|
10504
10536
|
zip64,
|
|
10505
10537
|
zipCrypto,
|
|
@@ -10508,10 +10540,10 @@
|
|
|
10508
10540
|
directory,
|
|
10509
10541
|
rawExtraField,
|
|
10510
10542
|
encryptionStrength,
|
|
10511
|
-
extendedTimestamp
|
|
10543
|
+
extendedTimestamp,
|
|
10544
|
+
encrypted
|
|
10512
10545
|
} = options;
|
|
10513
10546
|
const compressed = level !== 0 && !directory;
|
|
10514
|
-
const encrypted = Boolean((password && getLength(password)) || (rawPassword && getLength(rawPassword)));
|
|
10515
10547
|
let version = options.version;
|
|
10516
10548
|
let rawExtraFieldAES;
|
|
10517
10549
|
if (encrypted && !zipCrypto) {
|
|
@@ -10570,6 +10602,15 @@
|
|
|
10570
10602
|
let compressionMethod = COMPRESSION_METHOD_STORE;
|
|
10571
10603
|
if (compressed) {
|
|
10572
10604
|
compressionMethod = COMPRESSION_METHOD_DEFLATE;
|
|
10605
|
+
if (level >= 1 && level < 3) {
|
|
10606
|
+
bitFlag = bitFlag | 0b110;
|
|
10607
|
+
}
|
|
10608
|
+
if (level >= 3 && level < 5) {
|
|
10609
|
+
bitFlag = bitFlag | 0b01;
|
|
10610
|
+
}
|
|
10611
|
+
if (level === 9) {
|
|
10612
|
+
bitFlag = bitFlag | 0b10;
|
|
10613
|
+
}
|
|
10573
10614
|
}
|
|
10574
10615
|
if (zip64) {
|
|
10575
10616
|
version = version > VERSION_ZIP64 ? version : VERSION_ZIP64;
|
|
@@ -11055,7 +11096,8 @@
|
|
|
11055
11096
|
id: fs.entries.length,
|
|
11056
11097
|
parent,
|
|
11057
11098
|
children: [],
|
|
11058
|
-
uncompressedSize: params.uncompressedSize || 0
|
|
11099
|
+
uncompressedSize: params.uncompressedSize || 0,
|
|
11100
|
+
passThrough: params.passThrough
|
|
11059
11101
|
});
|
|
11060
11102
|
fs.entries.push(zipEntry);
|
|
11061
11103
|
if (parent) {
|
|
@@ -11398,7 +11440,8 @@
|
|
|
11398
11440
|
importedEntries.push(addChild(parent, name, {
|
|
11399
11441
|
data: entry,
|
|
11400
11442
|
Reader: getZipBlobReader(Object.assign({}, options)),
|
|
11401
|
-
uncompressedSize: entry.uncompressedSize
|
|
11443
|
+
uncompressedSize: entry.uncompressedSize,
|
|
11444
|
+
passThrough: options.passThrough
|
|
11402
11445
|
}));
|
|
11403
11446
|
}
|
|
11404
11447
|
} catch (error) {
|
|
@@ -11714,8 +11757,17 @@
|
|
|
11714
11757
|
comment,
|
|
11715
11758
|
lastModDate,
|
|
11716
11759
|
creationDate,
|
|
11717
|
-
lastAccessDate
|
|
11760
|
+
lastAccessDate,
|
|
11761
|
+
uncompressedSize,
|
|
11762
|
+
encrypted,
|
|
11763
|
+
zipCrypto,
|
|
11764
|
+
signature,
|
|
11765
|
+
compressionMethod
|
|
11718
11766
|
} = child.data;
|
|
11767
|
+
let level;
|
|
11768
|
+
if (compressionMethod === 0) {
|
|
11769
|
+
level = 0;
|
|
11770
|
+
}
|
|
11719
11771
|
zipEntryOptions = {
|
|
11720
11772
|
externalFileAttribute,
|
|
11721
11773
|
versionMadeBy,
|
|
@@ -11724,6 +11776,16 @@
|
|
|
11724
11776
|
creationDate,
|
|
11725
11777
|
lastAccessDate
|
|
11726
11778
|
};
|
|
11779
|
+
if (child.passThrough) {
|
|
11780
|
+
zipEntryOptions = Object.assign(zipEntryOptions, {
|
|
11781
|
+
passThrough: true,
|
|
11782
|
+
encrypted,
|
|
11783
|
+
zipCrypto,
|
|
11784
|
+
signature,
|
|
11785
|
+
uncompressedSize,
|
|
11786
|
+
level
|
|
11787
|
+
});
|
|
11788
|
+
}
|
|
11727
11789
|
}
|
|
11728
11790
|
await zipWriter.add(name, child.reader, Object.assign({
|
|
11729
11791
|
directory: child.directory
|
|
@@ -11913,6 +11975,7 @@
|
|
|
11913
11975
|
exports.ERR_ITERATOR_COMPLETED_TOO_SOON = ERR_ITERATOR_COMPLETED_TOO_SOON;
|
|
11914
11976
|
exports.ERR_LOCAL_FILE_HEADER_NOT_FOUND = ERR_LOCAL_FILE_HEADER_NOT_FOUND;
|
|
11915
11977
|
exports.ERR_SPLIT_ZIP_FILE = ERR_SPLIT_ZIP_FILE;
|
|
11978
|
+
exports.ERR_UNDEFINED_UNCOMPRESSED_SIZE = ERR_UNDEFINED_UNCOMPRESSED_SIZE;
|
|
11916
11979
|
exports.ERR_UNSUPPORTED_COMPRESSION = ERR_UNSUPPORTED_COMPRESSION;
|
|
11917
11980
|
exports.ERR_UNSUPPORTED_ENCRYPTION = ERR_UNSUPPORTED_ENCRYPTION;
|
|
11918
11981
|
exports.ERR_UNSUPPORTED_FORMAT = ERR_UNSUPPORTED_FORMAT;
|