@zip.js/zip.js 2.7.48 → 2.7.50
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 +94 -31
- package/dist/zip-fs-full.min.js +1 -1
- package/dist/zip-fs.js +94 -31
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-full.js +70 -28
- 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 +70 -28
- package/dist/zip.min.js +1 -1
- package/index.cjs +94 -31
- 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/dist/zip-full.js
CHANGED
|
@@ -7579,7 +7579,7 @@
|
|
|
7579
7579
|
PROPERTY_NAME_MS_DOS_COMPATIBLE, PROPERTY_NAME_ZIP64,
|
|
7580
7580
|
"directory", "bitFlag", "encrypted", "signature", "filenameUTF8", "commentUTF8", "compressionMethod", "version", "versionMadeBy",
|
|
7581
7581
|
"extraField", "rawExtraField", "extraFieldZip64", "extraFieldUnicodePath", "extraFieldUnicodeComment", "extraFieldAES", "extraFieldNTFS",
|
|
7582
|
-
"extraFieldExtendedTimestamp"];
|
|
7582
|
+
"extraFieldExtendedTimestamp", "zipCrypto"];
|
|
7583
7583
|
|
|
7584
7584
|
class Entry {
|
|
7585
7585
|
|
|
@@ -7814,6 +7814,7 @@
|
|
|
7814
7814
|
});
|
|
7815
7815
|
startOffset = Math.max(offsetFileEntry, startOffset);
|
|
7816
7816
|
await readCommonFooter(fileEntry, fileEntry, directoryView, offset + 6);
|
|
7817
|
+
fileEntry.zipCrypto = fileEntry.encrypted && !fileEntry.extraFieldAES;
|
|
7817
7818
|
const entry = new Entry(fileEntry);
|
|
7818
7819
|
entry.getData = (writer, options) => fileEntry.getData(writer, entry, options);
|
|
7819
7820
|
offset = endOffset;
|
|
@@ -7931,8 +7932,12 @@
|
|
|
7931
7932
|
lastAccessDate: localDirectory.lastAccessDate,
|
|
7932
7933
|
creationDate: localDirectory.creationDate
|
|
7933
7934
|
});
|
|
7934
|
-
const
|
|
7935
|
+
const passThrough = getOptionValue$1(zipEntry, options, "passThrough");
|
|
7936
|
+
const encrypted = zipEntry.encrypted && localDirectory.encrypted && !passThrough;
|
|
7935
7937
|
const zipCrypto = encrypted && !extraFieldAES;
|
|
7938
|
+
if (!passThrough) {
|
|
7939
|
+
fileEntry.zipCrypto = zipCrypto;
|
|
7940
|
+
}
|
|
7936
7941
|
if (encrypted) {
|
|
7937
7942
|
if (!zipCrypto && extraFieldAES.strength === UNDEFINED_VALUE) {
|
|
7938
7943
|
throw new Error(ERR_UNSUPPORTED_ENCRYPTION);
|
|
@@ -7964,11 +7969,11 @@
|
|
|
7964
7969
|
rawPassword,
|
|
7965
7970
|
zipCrypto,
|
|
7966
7971
|
encryptionStrength: extraFieldAES && extraFieldAES.strength,
|
|
7967
|
-
signed: getOptionValue$1(zipEntry, options, "checkSignature"),
|
|
7972
|
+
signed: getOptionValue$1(zipEntry, options, "checkSignature") && !passThrough,
|
|
7968
7973
|
passwordVerification: zipCrypto && (bitFlag.dataDescriptor ? ((rawLastModDate >>> 8) & 0xFF) : ((signature >>> 24) & 0xFF)),
|
|
7969
7974
|
signature,
|
|
7970
|
-
compressed: compressionMethod != 0,
|
|
7971
|
-
encrypted,
|
|
7975
|
+
compressed: compressionMethod != 0 && !passThrough,
|
|
7976
|
+
encrypted: zipEntry.encrypted && !passThrough,
|
|
7972
7977
|
useWebWorkers: getOptionValue$1(zipEntry, options, "useWebWorkers"),
|
|
7973
7978
|
useCompressionStream: getOptionValue$1(zipEntry, options, "useCompressionStream"),
|
|
7974
7979
|
transferStreams: getOptionValue$1(zipEntry, options, "transferStreams"),
|
|
@@ -8297,6 +8302,7 @@
|
|
|
8297
8302
|
const ERR_INVALID_EXTRAFIELD_TYPE = "Extra field type exceeds 65535";
|
|
8298
8303
|
const ERR_INVALID_EXTRAFIELD_DATA = "Extra field data exceeds 64KB";
|
|
8299
8304
|
const ERR_UNSUPPORTED_FORMAT = "Zip64 is not supported (make sure 'keepOrder' is set to 'true')";
|
|
8305
|
+
const ERR_UNDEFINED_UNCOMPRESSED_SIZE = "Undefined uncompressed size";
|
|
8300
8306
|
|
|
8301
8307
|
const EXTRAFIELD_DATA_AES = new Uint8Array([0x07, 0x00, 0x02, 0x00, 0x41, 0x45, 0x03, 0x00, 0x00]);
|
|
8302
8308
|
|
|
@@ -8317,7 +8323,7 @@
|
|
|
8317
8323
|
config: getConfiguration(),
|
|
8318
8324
|
files: new Map(),
|
|
8319
8325
|
filenames: new Set(),
|
|
8320
|
-
offset: writer.writable.size,
|
|
8326
|
+
offset: options.offset === UNDEFINED_VALUE ? writer.writable.size : options.offset,
|
|
8321
8327
|
pendingEntriesSize: 0,
|
|
8322
8328
|
pendingAddFileCalls: new Set(),
|
|
8323
8329
|
bufferedWrites: 0
|
|
@@ -8439,8 +8445,12 @@
|
|
|
8439
8445
|
const msDosCompatible = getOptionValue(zipWriter, options, PROPERTY_NAME_MS_DOS_COMPATIBLE, true);
|
|
8440
8446
|
const internalFileAttribute = getOptionValue(zipWriter, options, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTE, 0);
|
|
8441
8447
|
const externalFileAttribute = getOptionValue(zipWriter, options, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTE, 0);
|
|
8442
|
-
const
|
|
8443
|
-
|
|
8448
|
+
const passThrough = getOptionValue(zipWriter, options, "passThrough");
|
|
8449
|
+
let password, rawPassword;
|
|
8450
|
+
if (!passThrough) {
|
|
8451
|
+
password = getOptionValue(zipWriter, options, "password");
|
|
8452
|
+
rawPassword = getOptionValue(zipWriter, options, "rawPassword");
|
|
8453
|
+
}
|
|
8444
8454
|
const encryptionStrength = getOptionValue(zipWriter, options, "encryptionStrength", 3);
|
|
8445
8455
|
const zipCrypto = getOptionValue(zipWriter, options, "zipCrypto");
|
|
8446
8456
|
const extendedTimestamp = getOptionValue(zipWriter, options, "extendedTimestamp", true);
|
|
@@ -8454,7 +8464,7 @@
|
|
|
8454
8464
|
const useCompressionStream = getOptionValue(zipWriter, options, "useCompressionStream");
|
|
8455
8465
|
let dataDescriptor = getOptionValue(zipWriter, options, "dataDescriptor", true);
|
|
8456
8466
|
let zip64 = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIP64);
|
|
8457
|
-
if (password !== UNDEFINED_VALUE && encryptionStrength !== UNDEFINED_VALUE && (encryptionStrength < 1 || encryptionStrength > 3)) {
|
|
8467
|
+
if ((password !== UNDEFINED_VALUE || rawPassword !== UNDEFINED_VALUE) && encryptionStrength !== UNDEFINED_VALUE && (encryptionStrength < 1 || encryptionStrength > 3)) {
|
|
8458
8468
|
throw new Error(ERR_INVALID_ENCRYPTION_STRENGTH);
|
|
8459
8469
|
}
|
|
8460
8470
|
let rawExtraField = new Uint8Array();
|
|
@@ -8480,18 +8490,28 @@
|
|
|
8480
8490
|
let maximumCompressedSize = 0;
|
|
8481
8491
|
let maximumEntrySize = 0;
|
|
8482
8492
|
let uncompressedSize = 0;
|
|
8493
|
+
if (passThrough) {
|
|
8494
|
+
({ uncompressedSize } = options);
|
|
8495
|
+
if (uncompressedSize === UNDEFINED_VALUE) {
|
|
8496
|
+
throw new Error(ERR_UNDEFINED_UNCOMPRESSED_SIZE);
|
|
8497
|
+
}
|
|
8498
|
+
}
|
|
8483
8499
|
const zip64Enabled = zip64 === true;
|
|
8484
8500
|
if (reader) {
|
|
8485
8501
|
reader = initReader(reader);
|
|
8486
8502
|
await initStream(reader);
|
|
8487
|
-
if (
|
|
8488
|
-
|
|
8489
|
-
|
|
8490
|
-
zip64
|
|
8491
|
-
|
|
8503
|
+
if (!passThrough) {
|
|
8504
|
+
if (reader.size === UNDEFINED_VALUE) {
|
|
8505
|
+
dataDescriptor = true;
|
|
8506
|
+
if (zip64 || zip64 === UNDEFINED_VALUE) {
|
|
8507
|
+
zip64 = true;
|
|
8508
|
+
uncompressedSize = maximumCompressedSize = MAX_32_BITS + 1;
|
|
8509
|
+
}
|
|
8510
|
+
} else {
|
|
8511
|
+
uncompressedSize = reader.size;
|
|
8512
|
+
maximumCompressedSize = getMaximumCompressedSize(uncompressedSize);
|
|
8492
8513
|
}
|
|
8493
8514
|
} else {
|
|
8494
|
-
uncompressedSize = reader.size;
|
|
8495
8515
|
maximumCompressedSize = getMaximumCompressedSize(uncompressedSize);
|
|
8496
8516
|
}
|
|
8497
8517
|
}
|
|
@@ -8509,6 +8529,8 @@
|
|
|
8509
8529
|
}
|
|
8510
8530
|
}
|
|
8511
8531
|
zip64 = zip64 || false;
|
|
8532
|
+
const encrypted = getOptionValue(zipWriter, options, "encrypted");
|
|
8533
|
+
const { signature } = options;
|
|
8512
8534
|
options = Object.assign({}, options, {
|
|
8513
8535
|
rawFilename,
|
|
8514
8536
|
rawComment,
|
|
@@ -8539,7 +8561,10 @@
|
|
|
8539
8561
|
msDosCompatible,
|
|
8540
8562
|
internalFileAttribute,
|
|
8541
8563
|
externalFileAttribute,
|
|
8542
|
-
useCompressionStream
|
|
8564
|
+
useCompressionStream,
|
|
8565
|
+
passThrough,
|
|
8566
|
+
encrypted: Boolean((password && getLength(password)) || (rawPassword && getLength(rawPassword))) || (passThrough && encrypted),
|
|
8567
|
+
signature
|
|
8543
8568
|
});
|
|
8544
8569
|
const headerInfo = getHeaderInfo(options);
|
|
8545
8570
|
const dataDescriptorInfo = getDataDescriptorInfo(options);
|
|
@@ -8750,7 +8775,8 @@
|
|
|
8750
8775
|
msDosCompatible,
|
|
8751
8776
|
internalFileAttribute,
|
|
8752
8777
|
externalFileAttribute,
|
|
8753
|
-
useCompressionStream
|
|
8778
|
+
useCompressionStream,
|
|
8779
|
+
passThrough
|
|
8754
8780
|
} = options;
|
|
8755
8781
|
const fileEntry = {
|
|
8756
8782
|
lock,
|
|
@@ -8771,9 +8797,14 @@
|
|
|
8771
8797
|
externalFileAttribute,
|
|
8772
8798
|
diskNumberStart
|
|
8773
8799
|
};
|
|
8800
|
+
let {
|
|
8801
|
+
signature,
|
|
8802
|
+
uncompressedSize
|
|
8803
|
+
} = options;
|
|
8774
8804
|
let compressedSize = 0;
|
|
8775
|
-
|
|
8776
|
-
|
|
8805
|
+
if (!passThrough) {
|
|
8806
|
+
uncompressedSize = 0;
|
|
8807
|
+
}
|
|
8777
8808
|
const { writable } = writer;
|
|
8778
8809
|
if (reader) {
|
|
8779
8810
|
reader.chunkSize = getChunkSize(config);
|
|
@@ -8789,9 +8820,9 @@
|
|
|
8789
8820
|
encryptionStrength,
|
|
8790
8821
|
zipCrypto: encrypted && zipCrypto,
|
|
8791
8822
|
passwordVerification: encrypted && zipCrypto && (rawLastModDate >> 8) & 0xFF,
|
|
8792
|
-
signed:
|
|
8793
|
-
compressed,
|
|
8794
|
-
encrypted,
|
|
8823
|
+
signed: !passThrough,
|
|
8824
|
+
compressed: compressed && !passThrough,
|
|
8825
|
+
encrypted: encrypted && !passThrough,
|
|
8795
8826
|
useWebWorkers,
|
|
8796
8827
|
useCompressionStream,
|
|
8797
8828
|
transferStreams: false
|
|
@@ -8800,9 +8831,11 @@
|
|
|
8800
8831
|
streamOptions: { signal, size, onstart, onprogress, onend }
|
|
8801
8832
|
};
|
|
8802
8833
|
const result = await runWorker({ readable, writable }, workerOptions);
|
|
8803
|
-
uncompressedSize = result.inputSize;
|
|
8804
8834
|
compressedSize = result.outputSize;
|
|
8805
|
-
|
|
8835
|
+
if (!passThrough) {
|
|
8836
|
+
uncompressedSize = result.inputSize;
|
|
8837
|
+
signature = result.signature;
|
|
8838
|
+
}
|
|
8806
8839
|
writable.size += uncompressedSize;
|
|
8807
8840
|
} else {
|
|
8808
8841
|
await writeData(writable, localHeaderArray);
|
|
@@ -8845,6 +8878,7 @@
|
|
|
8845
8878
|
creationDate,
|
|
8846
8879
|
lastAccessDate,
|
|
8847
8880
|
encrypted,
|
|
8881
|
+
zipCrypto,
|
|
8848
8882
|
size: metadataSize + compressedSize,
|
|
8849
8883
|
compressionMethod,
|
|
8850
8884
|
version,
|
|
@@ -8866,8 +8900,6 @@
|
|
|
8866
8900
|
lastModDate,
|
|
8867
8901
|
lastAccessDate,
|
|
8868
8902
|
creationDate,
|
|
8869
|
-
rawPassword,
|
|
8870
|
-
password,
|
|
8871
8903
|
level,
|
|
8872
8904
|
zip64,
|
|
8873
8905
|
zipCrypto,
|
|
@@ -8876,10 +8908,10 @@
|
|
|
8876
8908
|
directory,
|
|
8877
8909
|
rawExtraField,
|
|
8878
8910
|
encryptionStrength,
|
|
8879
|
-
extendedTimestamp
|
|
8911
|
+
extendedTimestamp,
|
|
8912
|
+
encrypted
|
|
8880
8913
|
} = options;
|
|
8881
8914
|
const compressed = level !== 0 && !directory;
|
|
8882
|
-
const encrypted = Boolean((password && getLength(password)) || (rawPassword && getLength(rawPassword)));
|
|
8883
8915
|
let version = options.version;
|
|
8884
8916
|
let rawExtraFieldAES;
|
|
8885
8917
|
if (encrypted && !zipCrypto) {
|
|
@@ -8938,6 +8970,15 @@
|
|
|
8938
8970
|
let compressionMethod = COMPRESSION_METHOD_STORE;
|
|
8939
8971
|
if (compressed) {
|
|
8940
8972
|
compressionMethod = COMPRESSION_METHOD_DEFLATE;
|
|
8973
|
+
if (level >= 1 && level < 3) {
|
|
8974
|
+
bitFlag = bitFlag | 0b110;
|
|
8975
|
+
}
|
|
8976
|
+
if (level >= 3 && level < 5) {
|
|
8977
|
+
bitFlag = bitFlag | 0b01;
|
|
8978
|
+
}
|
|
8979
|
+
if (level === 9) {
|
|
8980
|
+
bitFlag = bitFlag | 0b10;
|
|
8981
|
+
}
|
|
8941
8982
|
}
|
|
8942
8983
|
if (zip64) {
|
|
8943
8984
|
version = version > VERSION_ZIP64 ? version : VERSION_ZIP64;
|
|
@@ -9438,6 +9479,7 @@
|
|
|
9438
9479
|
exports.ERR_ITERATOR_COMPLETED_TOO_SOON = ERR_ITERATOR_COMPLETED_TOO_SOON;
|
|
9439
9480
|
exports.ERR_LOCAL_FILE_HEADER_NOT_FOUND = ERR_LOCAL_FILE_HEADER_NOT_FOUND;
|
|
9440
9481
|
exports.ERR_SPLIT_ZIP_FILE = ERR_SPLIT_ZIP_FILE;
|
|
9482
|
+
exports.ERR_UNDEFINED_UNCOMPRESSED_SIZE = ERR_UNDEFINED_UNCOMPRESSED_SIZE;
|
|
9441
9483
|
exports.ERR_UNSUPPORTED_COMPRESSION = ERR_UNSUPPORTED_COMPRESSION;
|
|
9442
9484
|
exports.ERR_UNSUPPORTED_ENCRYPTION = ERR_UNSUPPORTED_ENCRYPTION;
|
|
9443
9485
|
exports.ERR_UNSUPPORTED_FORMAT = ERR_UNSUPPORTED_FORMAT;
|