@zip.js/zip.js 2.7.47 → 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 +100 -31
- package/dist/zip-fs-full.min.js +1 -1
- package/dist/zip-fs.js +100 -31
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-full.js +76 -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 +76 -28
- package/dist/zip.min.js +1 -1
- package/index.cjs +100 -31
- package/index.d.ts +44 -21
- 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 +68 -25
- 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
|
|
|
@@ -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);
|
|
@@ -8450,10 +8460,11 @@
|
|
|
8450
8460
|
const bufferedWrite = getOptionValue(zipWriter, options, "bufferedWrite");
|
|
8451
8461
|
const dataDescriptorSignature = getOptionValue(zipWriter, options, "dataDescriptorSignature", false);
|
|
8452
8462
|
const signal = getOptionValue(zipWriter, options, "signal");
|
|
8463
|
+
const useUnicodeFileNames = getOptionValue(zipWriter, options, "useUnicodeFileNames", true);
|
|
8453
8464
|
const useCompressionStream = getOptionValue(zipWriter, options, "useCompressionStream");
|
|
8454
8465
|
let dataDescriptor = getOptionValue(zipWriter, options, "dataDescriptor", true);
|
|
8455
8466
|
let zip64 = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIP64);
|
|
8456
|
-
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)) {
|
|
8457
8468
|
throw new Error(ERR_INVALID_ENCRYPTION_STRENGTH);
|
|
8458
8469
|
}
|
|
8459
8470
|
let rawExtraField = new Uint8Array();
|
|
@@ -8479,18 +8490,28 @@
|
|
|
8479
8490
|
let maximumCompressedSize = 0;
|
|
8480
8491
|
let maximumEntrySize = 0;
|
|
8481
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
|
+
}
|
|
8482
8499
|
const zip64Enabled = zip64 === true;
|
|
8483
8500
|
if (reader) {
|
|
8484
8501
|
reader = initReader(reader);
|
|
8485
8502
|
await initStream(reader);
|
|
8486
|
-
if (
|
|
8487
|
-
|
|
8488
|
-
|
|
8489
|
-
zip64
|
|
8490
|
-
|
|
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);
|
|
8491
8513
|
}
|
|
8492
8514
|
} else {
|
|
8493
|
-
uncompressedSize = reader.size;
|
|
8494
8515
|
maximumCompressedSize = getMaximumCompressedSize(uncompressedSize);
|
|
8495
8516
|
}
|
|
8496
8517
|
}
|
|
@@ -8508,6 +8529,8 @@
|
|
|
8508
8529
|
}
|
|
8509
8530
|
}
|
|
8510
8531
|
zip64 = zip64 || false;
|
|
8532
|
+
const encrypted = getOptionValue(zipWriter, options, "encrypted");
|
|
8533
|
+
const { signature } = options;
|
|
8511
8534
|
options = Object.assign({}, options, {
|
|
8512
8535
|
rawFilename,
|
|
8513
8536
|
rawComment,
|
|
@@ -8531,13 +8554,17 @@
|
|
|
8531
8554
|
zipCrypto,
|
|
8532
8555
|
bufferedWrite,
|
|
8533
8556
|
keepOrder,
|
|
8557
|
+
useUnicodeFileNames,
|
|
8534
8558
|
dataDescriptor,
|
|
8535
8559
|
dataDescriptorSignature,
|
|
8536
8560
|
signal,
|
|
8537
8561
|
msDosCompatible,
|
|
8538
8562
|
internalFileAttribute,
|
|
8539
8563
|
externalFileAttribute,
|
|
8540
|
-
useCompressionStream
|
|
8564
|
+
useCompressionStream,
|
|
8565
|
+
passThrough,
|
|
8566
|
+
encrypted: Boolean((password && getLength(password)) || (rawPassword && getLength(rawPassword))) || (passThrough && encrypted),
|
|
8567
|
+
signature
|
|
8541
8568
|
});
|
|
8542
8569
|
const headerInfo = getHeaderInfo(options);
|
|
8543
8570
|
const dataDescriptorInfo = getDataDescriptorInfo(options);
|
|
@@ -8748,7 +8775,8 @@
|
|
|
8748
8775
|
msDosCompatible,
|
|
8749
8776
|
internalFileAttribute,
|
|
8750
8777
|
externalFileAttribute,
|
|
8751
|
-
useCompressionStream
|
|
8778
|
+
useCompressionStream,
|
|
8779
|
+
passThrough
|
|
8752
8780
|
} = options;
|
|
8753
8781
|
const fileEntry = {
|
|
8754
8782
|
lock,
|
|
@@ -8769,9 +8797,14 @@
|
|
|
8769
8797
|
externalFileAttribute,
|
|
8770
8798
|
diskNumberStart
|
|
8771
8799
|
};
|
|
8800
|
+
let {
|
|
8801
|
+
signature,
|
|
8802
|
+
uncompressedSize
|
|
8803
|
+
} = options;
|
|
8772
8804
|
let compressedSize = 0;
|
|
8773
|
-
|
|
8774
|
-
|
|
8805
|
+
if (!passThrough) {
|
|
8806
|
+
uncompressedSize = 0;
|
|
8807
|
+
}
|
|
8775
8808
|
const { writable } = writer;
|
|
8776
8809
|
if (reader) {
|
|
8777
8810
|
reader.chunkSize = getChunkSize(config);
|
|
@@ -8787,9 +8820,9 @@
|
|
|
8787
8820
|
encryptionStrength,
|
|
8788
8821
|
zipCrypto: encrypted && zipCrypto,
|
|
8789
8822
|
passwordVerification: encrypted && zipCrypto && (rawLastModDate >> 8) & 0xFF,
|
|
8790
|
-
signed:
|
|
8791
|
-
compressed,
|
|
8792
|
-
encrypted,
|
|
8823
|
+
signed: !passThrough,
|
|
8824
|
+
compressed: compressed && !passThrough,
|
|
8825
|
+
encrypted: encrypted && !passThrough,
|
|
8793
8826
|
useWebWorkers,
|
|
8794
8827
|
useCompressionStream,
|
|
8795
8828
|
transferStreams: false
|
|
@@ -8798,9 +8831,11 @@
|
|
|
8798
8831
|
streamOptions: { signal, size, onstart, onprogress, onend }
|
|
8799
8832
|
};
|
|
8800
8833
|
const result = await runWorker({ readable, writable }, workerOptions);
|
|
8801
|
-
uncompressedSize = result.inputSize;
|
|
8802
8834
|
compressedSize = result.outputSize;
|
|
8803
|
-
|
|
8835
|
+
if (!passThrough) {
|
|
8836
|
+
uncompressedSize = result.inputSize;
|
|
8837
|
+
signature = result.signature;
|
|
8838
|
+
}
|
|
8804
8839
|
writable.size += uncompressedSize;
|
|
8805
8840
|
} else {
|
|
8806
8841
|
await writeData(writable, localHeaderArray);
|
|
@@ -8843,6 +8878,7 @@
|
|
|
8843
8878
|
creationDate,
|
|
8844
8879
|
lastAccessDate,
|
|
8845
8880
|
encrypted,
|
|
8881
|
+
zipCrypto,
|
|
8846
8882
|
size: metadataSize + compressedSize,
|
|
8847
8883
|
compressionMethod,
|
|
8848
8884
|
version,
|
|
@@ -8864,19 +8900,18 @@
|
|
|
8864
8900
|
lastModDate,
|
|
8865
8901
|
lastAccessDate,
|
|
8866
8902
|
creationDate,
|
|
8867
|
-
rawPassword,
|
|
8868
|
-
password,
|
|
8869
8903
|
level,
|
|
8870
8904
|
zip64,
|
|
8871
8905
|
zipCrypto,
|
|
8906
|
+
useUnicodeFileNames,
|
|
8872
8907
|
dataDescriptor,
|
|
8873
8908
|
directory,
|
|
8874
8909
|
rawExtraField,
|
|
8875
8910
|
encryptionStrength,
|
|
8876
|
-
extendedTimestamp
|
|
8911
|
+
extendedTimestamp,
|
|
8912
|
+
encrypted
|
|
8877
8913
|
} = options;
|
|
8878
8914
|
const compressed = level !== 0 && !directory;
|
|
8879
|
-
const encrypted = Boolean((password && getLength(password)) || (rawPassword && getLength(rawPassword)));
|
|
8880
8915
|
let version = options.version;
|
|
8881
8916
|
let rawExtraFieldAES;
|
|
8882
8917
|
if (encrypted && !zipCrypto) {
|
|
@@ -8925,13 +8960,25 @@
|
|
|
8925
8960
|
} else {
|
|
8926
8961
|
rawExtraFieldNTFS = rawExtraFieldExtendedTimestamp = new Uint8Array();
|
|
8927
8962
|
}
|
|
8928
|
-
let bitFlag =
|
|
8963
|
+
let bitFlag = 0;
|
|
8964
|
+
if (useUnicodeFileNames) {
|
|
8965
|
+
bitFlag = bitFlag | BITFLAG_LANG_ENCODING_FLAG;
|
|
8966
|
+
}
|
|
8929
8967
|
if (dataDescriptor) {
|
|
8930
8968
|
bitFlag = bitFlag | BITFLAG_DATA_DESCRIPTOR;
|
|
8931
8969
|
}
|
|
8932
8970
|
let compressionMethod = COMPRESSION_METHOD_STORE;
|
|
8933
8971
|
if (compressed) {
|
|
8934
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
|
+
}
|
|
8935
8982
|
}
|
|
8936
8983
|
if (zip64) {
|
|
8937
8984
|
version = version > VERSION_ZIP64 ? version : VERSION_ZIP64;
|
|
@@ -9432,6 +9479,7 @@
|
|
|
9432
9479
|
exports.ERR_ITERATOR_COMPLETED_TOO_SOON = ERR_ITERATOR_COMPLETED_TOO_SOON;
|
|
9433
9480
|
exports.ERR_LOCAL_FILE_HEADER_NOT_FOUND = ERR_LOCAL_FILE_HEADER_NOT_FOUND;
|
|
9434
9481
|
exports.ERR_SPLIT_ZIP_FILE = ERR_SPLIT_ZIP_FILE;
|
|
9482
|
+
exports.ERR_UNDEFINED_UNCOMPRESSED_SIZE = ERR_UNDEFINED_UNCOMPRESSED_SIZE;
|
|
9435
9483
|
exports.ERR_UNSUPPORTED_COMPRESSION = ERR_UNSUPPORTED_COMPRESSION;
|
|
9436
9484
|
exports.ERR_UNSUPPORTED_ENCRYPTION = ERR_UNSUPPORTED_ENCRYPTION;
|
|
9437
9485
|
exports.ERR_UNSUPPORTED_FORMAT = ERR_UNSUPPORTED_FORMAT;
|