@zip.js/zip.js 2.8.54 → 2.8.56
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 +91 -40
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +91 -39
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +103 -52
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +102 -51
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +103 -52
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +105 -53
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +105 -53
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +93 -41
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +93 -41
- 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 +93 -41
- package/dist/zip.min.js +1 -1
- package/index-native.cjs +105 -53
- package/index-native.min.js +1 -1
- package/index.cjs +105 -53
- package/index.d.cts +29 -7
- package/index.d.ts +29 -7
- package/index.min.js +1 -1
- package/lib/core/constants.js +2 -0
- package/lib/core/options.js +14 -0
- package/lib/core/web-worker-inline-native.js +1 -1
- package/lib/core/web-worker-inline-wasm.js +1 -1
- package/lib/core/zip-fs.js +1 -5
- package/lib/core/zip-reader.js +48 -11
- package/lib/core/zip-writer.js +44 -35
- package/lib/core/zlib-streams-inline.js +1 -1
- package/lib/zip-core-writer.js +1 -0
- package/package.json +1 -1
package/dist/zip-core.js
CHANGED
|
@@ -85,6 +85,7 @@
|
|
|
85
85
|
const BITFLAG_DATA_DESCRIPTOR = 0b1000;
|
|
86
86
|
const BITFLAG_STRONG_ENCRYPTION = 0b1000000;
|
|
87
87
|
const BITFLAG_LANG_ENCODING_FLAG = 0b100000000000;
|
|
88
|
+
const BITFLAG_MASKED_LOCAL_HEADERS = 0b10000000000000;
|
|
88
89
|
const FILE_ATTR_MSDOS_DIR_MASK = 0b10000;
|
|
89
90
|
const FILE_ATTR_MSDOS_READONLY_MASK = 0x01;
|
|
90
91
|
const FILE_ATTR_MSDOS_HIDDEN_MASK = 0x02;
|
|
@@ -234,6 +235,18 @@
|
|
|
234
235
|
}
|
|
235
236
|
}
|
|
236
237
|
|
|
238
|
+
function checkInteger(value, maxValue, errorMessage) {
|
|
239
|
+
if (!Number.isInteger(value) || value < 0 || value > maxValue) {
|
|
240
|
+
throw new Error(errorMessage);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function checkIntegerOption(value, maxValue, errorMessage) {
|
|
245
|
+
if (value !== UNDEFINED_VALUE) {
|
|
246
|
+
checkInteger(value, maxValue, errorMessage);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
237
250
|
function toNumber(value) {
|
|
238
251
|
return typeof value == STRING_TYPE && value.trim() ? Number(value) : value;
|
|
239
252
|
}
|
|
@@ -4777,6 +4790,7 @@
|
|
|
4777
4790
|
let startOffset;
|
|
4778
4791
|
let zip64EndOfDirectory;
|
|
4779
4792
|
let zip64EndOfDirectoryVersion2;
|
|
4793
|
+
let zip64EndOfDirectoryLength = ZIP64_END_OF_CENTRAL_DIR_LENGTH;
|
|
4780
4794
|
let directoryEncryptionInfo;
|
|
4781
4795
|
const requiresZip64 = directoryDataOffset == MAX_32_BITS || directoryDataLength == MAX_32_BITS || filesLength == MAX_16_BITS || diskNumber == MAX_16_BITS;
|
|
4782
4796
|
if (directoryDataOffset != MAX_32_BITS && diskNumber != MAX_16_BITS) {
|
|
@@ -4813,6 +4827,7 @@
|
|
|
4813
4827
|
Number(getBigUint64(endOfDirectoryView, 4)) - (ZIP64_END_OF_CENTRAL_DIR_LENGTH - 12),
|
|
4814
4828
|
reader.size - directoryDataOffset - ZIP64_END_OF_CENTRAL_DIR_LENGTH);
|
|
4815
4829
|
if (extensibleDataLength > 0) {
|
|
4830
|
+
zip64EndOfDirectoryLength += extensibleDataLength;
|
|
4816
4831
|
const rawExtensibleData = await readUint8Array(reader, directoryDataOffset + ZIP64_END_OF_CENTRAL_DIR_LENGTH, extensibleDataLength);
|
|
4817
4832
|
directoryEncryptionInfo = getDirectoryEncryptionInfo(rawExtensibleData);
|
|
4818
4833
|
}
|
|
@@ -4842,7 +4857,7 @@
|
|
|
4842
4857
|
}
|
|
4843
4858
|
let declaredDirectoryDataLength = directoryDataLength;
|
|
4844
4859
|
const centralDirectoryEndOffset = endOfDirectoryInfo.offset -
|
|
4845
|
-
(zip64EndOfDirectory ?
|
|
4860
|
+
(zip64EndOfDirectory ? zip64EndOfDirectoryLength + ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH : 0);
|
|
4846
4861
|
if (directoryDataOffset >= reader.size) {
|
|
4847
4862
|
prependedDataLength = reader.size - directoryDataOffset - directoryDataLength - END_OF_CENTRAL_DIR_LENGTH;
|
|
4848
4863
|
directoryDataOffset = reader.size - directoryDataLength - END_OF_CENTRAL_DIR_LENGTH;
|
|
@@ -4862,7 +4877,9 @@
|
|
|
4862
4877
|
}
|
|
4863
4878
|
const expectedDirectoryDataOffset = centralDirectoryEndOffset - directoryDataLength;
|
|
4864
4879
|
if (directoryDataOffset != expectedDirectoryDataOffset && diskNumber == lastDiskNumber) {
|
|
4865
|
-
const storedPointsAtDirectory = getUint32$1(directoryView, offset) == CENTRAL_FILE_HEADER_SIGNATURE
|
|
4880
|
+
const storedPointsAtDirectory = getUint32$1(directoryView, offset) == CENTRAL_FILE_HEADER_SIGNATURE ||
|
|
4881
|
+
Boolean(directoryEncryptionInfo && directoryEncryptionInfo.compressedSize) ||
|
|
4882
|
+
detectEncryptedCentralDirectory(directoryView);
|
|
4866
4883
|
let reconcile = !storedPointsAtDirectory;
|
|
4867
4884
|
if (!reconcile && expectedDirectoryDataOffset >= 0 && expectedDirectoryDataOffset + 4 <= reader.size) {
|
|
4868
4885
|
const expectedSignatureArray = await readUint8Array(reader, expectedDirectoryDataOffset, 4);
|
|
@@ -4891,11 +4908,13 @@
|
|
|
4891
4908
|
zipReader.directoryOffset = directoryDataOffset;
|
|
4892
4909
|
zipReader.directoryLength = declaredDirectoryDataLength;
|
|
4893
4910
|
const decryptCentralDirectory = getFunctionOptionValue$1(zipReader, options, OPTION_DECRYPT_CENTRAL_DIRECTORY);
|
|
4894
|
-
let decryptedDirectory;
|
|
4911
|
+
let decryptedDirectory, dataAfterEncryptedDirectory;
|
|
4895
4912
|
if (decryptCentralDirectory && filesLength && directoryArray.length >= 4 &&
|
|
4896
4913
|
getUint32$1(directoryView, 0) != CENTRAL_FILE_HEADER_SIGNATURE &&
|
|
4897
4914
|
(zip64EndOfDirectoryVersion2 || detectEncryptedCentralDirectory(directoryView))) {
|
|
4898
|
-
|
|
4915
|
+
const encryptedDirectoryDataLength = getEncryptedDirectoryDataLength(directoryEncryptionInfo, declaredDirectoryDataLength, directoryArray.length);
|
|
4916
|
+
dataAfterEncryptedDirectory = directoryArray.subarray(encryptedDirectoryDataLength);
|
|
4917
|
+
directoryArray = await decryptCentralDirectory(directoryArray.subarray(0, encryptedDirectoryDataLength), directoryEncryptionInfo);
|
|
4899
4918
|
directoryView = getDataView(directoryArray);
|
|
4900
4919
|
declaredDirectoryDataLength = directoryArray.length;
|
|
4901
4920
|
decryptedDirectory = true;
|
|
@@ -4961,6 +4980,7 @@
|
|
|
4961
4980
|
}
|
|
4962
4981
|
Object.assign(fileEntry, {
|
|
4963
4982
|
index: indexFile,
|
|
4983
|
+
decryptedDirectory,
|
|
4964
4984
|
versionMadeBy,
|
|
4965
4985
|
msDosCompatible,
|
|
4966
4986
|
zip64: false,
|
|
@@ -5037,13 +5057,19 @@
|
|
|
5037
5057
|
yield entry;
|
|
5038
5058
|
}
|
|
5039
5059
|
let offsetAfterSignature = offset;
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5060
|
+
let digitalSignature = readDigitalSignature(directoryArray.subarray(offset)) ||
|
|
5061
|
+
(decryptedDirectory ? readDigitalSignature(dataAfterEncryptedDirectory) : UNDEFINED_VALUE);
|
|
5062
|
+
if (!digitalSignature && !decryptedDirectory) {
|
|
5063
|
+
const signatureRecordOffset = directoryDataOffset + offset;
|
|
5064
|
+
const signatureRecordLength = Math.min(centralDirectoryEndOffset - signatureRecordOffset, 6 + MAX_16_BITS);
|
|
5065
|
+
if (signatureRecordLength >= 6) {
|
|
5066
|
+
digitalSignature = readDigitalSignature(await readUint8Array(reader, signatureRecordOffset, signatureRecordLength));
|
|
5045
5067
|
}
|
|
5046
5068
|
}
|
|
5069
|
+
if (digitalSignature) {
|
|
5070
|
+
zipReader.digitalSignature = digitalSignature;
|
|
5071
|
+
offsetAfterSignature = offset + 6 + digitalSignature.length;
|
|
5072
|
+
}
|
|
5047
5073
|
if (checkAmbiguity && offset != declaredDirectoryDataLength && offsetAfterSignature != declaredDirectoryDataLength) {
|
|
5048
5074
|
throwAmbiguousArchive("trailing central directory data");
|
|
5049
5075
|
}
|
|
@@ -5351,6 +5377,27 @@
|
|
|
5351
5377
|
return false;
|
|
5352
5378
|
}
|
|
5353
5379
|
|
|
5380
|
+
function readDigitalSignature(signatureRecordArray) {
|
|
5381
|
+
if (signatureRecordArray.length >= 6) {
|
|
5382
|
+
const signatureRecordView = getDataView(signatureRecordArray);
|
|
5383
|
+
if (getUint32$1(signatureRecordView, 0) == DIGITAL_SIGNATURE_RECORD_SIGNATURE) {
|
|
5384
|
+
const signatureDataLength = getUint16$1(signatureRecordView, 4);
|
|
5385
|
+
if (6 + signatureDataLength <= signatureRecordArray.length) {
|
|
5386
|
+
return signatureRecordArray.subarray(6, 6 + signatureDataLength);
|
|
5387
|
+
}
|
|
5388
|
+
}
|
|
5389
|
+
}
|
|
5390
|
+
}
|
|
5391
|
+
|
|
5392
|
+
function getEncryptedDirectoryDataLength(directoryEncryptionInfo, declaredDirectoryDataLength, directoryDataLength) {
|
|
5393
|
+
const encryptedDirectoryDataLength = directoryEncryptionInfo && directoryEncryptionInfo.compressedSize ?
|
|
5394
|
+
directoryEncryptionInfo.compressedSize :
|
|
5395
|
+
declaredDirectoryDataLength;
|
|
5396
|
+
return encryptedDirectoryDataLength > 0 && encryptedDirectoryDataLength <= directoryDataLength ?
|
|
5397
|
+
encryptedDirectoryDataLength :
|
|
5398
|
+
directoryDataLength;
|
|
5399
|
+
}
|
|
5400
|
+
|
|
5354
5401
|
function getDirectoryEncryptionInfo(rawExtensibleData) {
|
|
5355
5402
|
const directoryEncryptionInfo = { rawExtensibleData };
|
|
5356
5403
|
if (rawExtensibleData.length >= 28) {
|
|
@@ -5935,7 +5982,9 @@
|
|
|
5935
5982
|
|
|
5936
5983
|
function validateLocalDirectory(zipEntry, localDirectory, rawLocalFilename, checkLocalFilename) {
|
|
5937
5984
|
const { rawFilename } = zipEntry;
|
|
5938
|
-
|
|
5985
|
+
const maskedLocalDirectory = zipEntry.decryptedDirectory &&
|
|
5986
|
+
(localDirectory.rawBitFlag & BITFLAG_MASKED_LOCAL_HEADERS) == BITFLAG_MASKED_LOCAL_HEADERS;
|
|
5987
|
+
if (checkLocalFilename && !maskedLocalDirectory &&
|
|
5939
5988
|
(rawLocalFilename.length != rawFilename.length ||
|
|
5940
5989
|
rawLocalFilename.some((byteValue, indexByte) => byteValue != rawFilename[indexByte]))) {
|
|
5941
5990
|
throwAmbiguousArchive("mismatched local file header (filename)");
|
|
@@ -5946,7 +5995,7 @@
|
|
|
5946
5995
|
if (localDirectory.compressionMethod != zipEntry.compressionMethod) {
|
|
5947
5996
|
throwAmbiguousArchive("mismatched local file header (compression method)");
|
|
5948
5997
|
}
|
|
5949
|
-
if (!localDirectory.bitFlag.dataDescriptor &&
|
|
5998
|
+
if (!localDirectory.bitFlag.dataDescriptor && !maskedLocalDirectory &&
|
|
5950
5999
|
(localDirectory.crc32 || localDirectory.compressedSize || localDirectory.uncompressedSize) &&
|
|
5951
6000
|
(localDirectory.crc32 != zipEntry.crc32 ||
|
|
5952
6001
|
localDirectory.compressedSize != zipEntry.compressedSize ||
|
|
@@ -6077,6 +6126,7 @@
|
|
|
6077
6126
|
const MAX_NTFS_TIME = BigInt("0x7fffffffffffffff");
|
|
6078
6127
|
const ERR_UNSUPPORTED_FORMAT = "Zip64 is not supported (set the 'zip64' option to 'true')";
|
|
6079
6128
|
const ERR_UNDEFINED_UNCOMPRESSED_SIZE = "Undefined uncompressed size";
|
|
6129
|
+
const ERR_UNDEFINED_COMPRESSION_METHOD = "Undefined compression method";
|
|
6080
6130
|
const ERR_UNDETERMINED_SIZE = "Undetermined size";
|
|
6081
6131
|
const ERR_UNDEFINED_READER = "Undefined reader";
|
|
6082
6132
|
const ERR_ZIP_NOT_EMPTY = "Zip file not empty";
|
|
@@ -6092,6 +6142,8 @@
|
|
|
6092
6142
|
|
|
6093
6143
|
const EXTRAFIELD_DATA_AES = new Uint8Array([0x07, 0x00, 0x02, 0x00, 0x41, 0x45, 0x03, 0x00, 0x00]);
|
|
6094
6144
|
const EXTRAFIELD_OFFSET_AES_VENDOR_VERSION = 4;
|
|
6145
|
+
const EXTRAFIELD_OFFSET_AES_COMPRESSION_METHOD = 9;
|
|
6146
|
+
const EXTRAFIELD_USDZ_MAX_LENGTH = 67;
|
|
6095
6147
|
const VENDOR_VERSION_AE_1 = 1;
|
|
6096
6148
|
const INFOZIP_EXTRA_FIELD_TYPE = "infozip";
|
|
6097
6149
|
const UNIX_EXTRA_FIELD_TYPE = "unix";
|
|
@@ -6138,16 +6190,14 @@
|
|
|
6138
6190
|
await zipReader$1.close();
|
|
6139
6191
|
await initStream(this.writer);
|
|
6140
6192
|
const { directoryOffset } = zipReader$1;
|
|
6141
|
-
let splitZipSignatureLength = 0;
|
|
6142
6193
|
if (this.addSplitZipSignature) {
|
|
6143
6194
|
delete this.addSplitZipSignature;
|
|
6144
6195
|
if (!await startsWithSplitZipSignature(reader)) {
|
|
6145
6196
|
await writeData(this.writer, getSplitZipSignatureArray());
|
|
6146
|
-
|
|
6147
|
-
this.offset += splitZipSignatureLength;
|
|
6197
|
+
this.offset += SPLIT_ZIP_FILE_SIGNATURE_LENGTH;
|
|
6148
6198
|
}
|
|
6149
6199
|
}
|
|
6150
|
-
const entryPositions = await copyZipData(this, reader, entries, directoryOffset
|
|
6200
|
+
const entryPositions = await copyZipData(this, reader, entries, directoryOffset);
|
|
6151
6201
|
this.filenames = new Set(entries.map(entry => entry.filename));
|
|
6152
6202
|
this.fileEntries = new Map(entries.map(entry => {
|
|
6153
6203
|
const {
|
|
@@ -6389,7 +6439,8 @@
|
|
|
6389
6439
|
signature: options[PROPERTY_NAME_SIGNATURE],
|
|
6390
6440
|
crc32: options.crc32 === UNDEFINED_VALUE ? options[PROPERTY_NAME_SIGNATURE] : options.crc32,
|
|
6391
6441
|
offset: zipWriter.offset - diskOffset,
|
|
6392
|
-
diskNumberStart: diskNumber
|
|
6442
|
+
diskNumberStart: diskNumber,
|
|
6443
|
+
[OPTION_USDZ]: zipWriter.options[OPTION_USDZ]
|
|
6393
6444
|
});
|
|
6394
6445
|
const headerInfo = getHeaderInfo(options);
|
|
6395
6446
|
const dataDescriptorInfo = getDataDescriptorInfo(options);
|
|
@@ -6421,15 +6472,9 @@
|
|
|
6421
6472
|
let setuid = getOptionValue(zipWriter, options, PROPERTY_NAME_SETUID);
|
|
6422
6473
|
let setgid = getOptionValue(zipWriter, options, PROPERTY_NAME_SETGID);
|
|
6423
6474
|
let sticky = getOptionValue(zipWriter, options, PROPERTY_NAME_STICKY);
|
|
6424
|
-
|
|
6425
|
-
|
|
6426
|
-
|
|
6427
|
-
if (gid !== UNDEFINED_VALUE && (!Number.isInteger(gid) || gid < 0 || gid > MAX_32_BITS)) {
|
|
6428
|
-
throw new Error(ERR_INVALID_GID);
|
|
6429
|
-
}
|
|
6430
|
-
if (unixMode !== UNDEFINED_VALUE && (!Number.isInteger(unixMode) || unixMode < 0 || unixMode > MAX_16_BITS)) {
|
|
6431
|
-
throw new Error(ERR_INVALID_UNIX_MODE);
|
|
6432
|
-
}
|
|
6475
|
+
checkIntegerOption(uid, MAX_32_BITS, ERR_INVALID_UID);
|
|
6476
|
+
checkIntegerOption(gid, MAX_32_BITS, ERR_INVALID_GID);
|
|
6477
|
+
checkIntegerOption(unixMode, MAX_16_BITS, ERR_INVALID_UNIX_MODE);
|
|
6433
6478
|
if (unixExtraFieldType !== UNDEFINED_VALUE && unixExtraFieldType !== INFOZIP_EXTRA_FIELD_TYPE && unixExtraFieldType !== UNIX_EXTRA_FIELD_TYPE) {
|
|
6434
6479
|
throw new Error(ERR_INVALID_UNIX_EXTRA_FIELD_TYPE);
|
|
6435
6480
|
}
|
|
@@ -6451,9 +6496,7 @@
|
|
|
6451
6496
|
msDosCompatible = true;
|
|
6452
6497
|
versionMadeBy = (versionMadeBy & MAX_8_BITS);
|
|
6453
6498
|
}
|
|
6454
|
-
|
|
6455
|
-
throw new Error(ERR_INVALID_MSDOS_ATTRIBUTES);
|
|
6456
|
-
}
|
|
6499
|
+
checkIntegerOption(msdosAttributesRaw, MAX_8_BITS, ERR_INVALID_MSDOS_ATTRIBUTES);
|
|
6457
6500
|
if (msdosAttributes && (typeof msdosAttributes !== OBJECT_TYPE || Array.isArray(msdosAttributes))) {
|
|
6458
6501
|
throw new Error(ERR_INVALID_MSDOS_DATA);
|
|
6459
6502
|
}
|
|
@@ -6593,9 +6636,7 @@
|
|
|
6593
6636
|
throw new Error(ERR_UNSUPPORTED_COMPRESSION);
|
|
6594
6637
|
}
|
|
6595
6638
|
let level = getNumberOptionValue(zipWriter, options, OPTION_LEVEL);
|
|
6596
|
-
|
|
6597
|
-
throw new Error(ERR_INVALID_LEVEL);
|
|
6598
|
-
}
|
|
6639
|
+
checkIntegerOption(level, MAX_LEVEL, ERR_INVALID_LEVEL);
|
|
6599
6640
|
if (zipWriter.options[OPTION_USDZ]) {
|
|
6600
6641
|
if (password !== UNDEFINED_VALUE || rawPassword !== UNDEFINED_VALUE) {
|
|
6601
6642
|
throw new Error(ERR_UNSUPPORTED_ENCRYPTION_USDZ);
|
|
@@ -6604,6 +6645,9 @@
|
|
|
6604
6645
|
level = 0;
|
|
6605
6646
|
}
|
|
6606
6647
|
}
|
|
6648
|
+
if (passThrough) {
|
|
6649
|
+
level = UNDEFINED_VALUE;
|
|
6650
|
+
}
|
|
6607
6651
|
let useCompressionStream = getOptionValue(zipWriter, options, OPTION_USE_COMPRESSION_STREAM);
|
|
6608
6652
|
let dataDescriptor = getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR);
|
|
6609
6653
|
if (bufferedWrite && dataDescriptor === UNDEFINED_VALUE) {
|
|
@@ -6670,9 +6714,7 @@
|
|
|
6670
6714
|
let extraFieldSize = 0;
|
|
6671
6715
|
let offset = 0;
|
|
6672
6716
|
extraField.forEach((data, type) => {
|
|
6673
|
-
|
|
6674
|
-
throw new Error(ERR_INVALID_EXTRAFIELD_TYPE);
|
|
6675
|
-
}
|
|
6717
|
+
checkInteger(type, MAX_16_BITS, ERR_INVALID_EXTRAFIELD_TYPE);
|
|
6676
6718
|
if (!(data instanceof Uint8Array)) {
|
|
6677
6719
|
throw new Error(ERR_INVALID_EXTRAFIELD_DATA_TYPE);
|
|
6678
6720
|
}
|
|
@@ -6715,6 +6757,9 @@
|
|
|
6715
6757
|
if (uncompressedSize === UNDEFINED_VALUE) {
|
|
6716
6758
|
throw new Error(ERR_UNDEFINED_UNCOMPRESSED_SIZE);
|
|
6717
6759
|
}
|
|
6760
|
+
if (compressionMethod === UNDEFINED_VALUE) {
|
|
6761
|
+
throw new Error(ERR_UNDEFINED_COMPRESSION_METHOD);
|
|
6762
|
+
}
|
|
6718
6763
|
}
|
|
6719
6764
|
const zip64Enabled = zip64 === true;
|
|
6720
6765
|
const encrypted = getOptionValue(zipWriter, options, PROPERTY_NAME_ENCRYPTED);
|
|
@@ -7263,12 +7308,13 @@
|
|
|
7263
7308
|
if (passThrough && crc32 !== UNDEFINED_VALUE) {
|
|
7264
7309
|
rawExtraFieldAES[EXTRAFIELD_OFFSET_AES_VENDOR_VERSION] = VENDOR_VERSION_AE_1;
|
|
7265
7310
|
}
|
|
7266
|
-
rawExtraFieldAES
|
|
7311
|
+
setUint16(getDataView(rawExtraFieldAES), EXTRAFIELD_OFFSET_AES_COMPRESSION_METHOD, compressionMethod);
|
|
7267
7312
|
compressionMethod = COMPRESSION_METHOD_AES;
|
|
7268
7313
|
}
|
|
7269
7314
|
const localExtraFieldZip64Length = writeLocalExtraFieldZip64 ? getLength(rawLocalExtraFieldZip64) : 0;
|
|
7270
7315
|
const extraFieldLength = localExtraFieldZip64Length + getLength(rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS, rawExtraFieldUnix, rawExtraField, rawLocalExtraField);
|
|
7271
|
-
|
|
7316
|
+
const maximumUsdzExtraFieldLength = options[OPTION_USDZ] ? EXTRAFIELD_USDZ_MAX_LENGTH : 0;
|
|
7317
|
+
if (extraFieldLength + maximumUsdzExtraFieldLength > MAX_16_BITS) {
|
|
7272
7318
|
throw new Error(ERR_INVALID_EXTRAFIELD_DATA);
|
|
7273
7319
|
}
|
|
7274
7320
|
const dosLastModDate = new Date(Math.ceil(Math.floor(lastModDate.getTime() / 1000) / 2) * 2000);
|
|
@@ -7669,7 +7715,11 @@
|
|
|
7669
7715
|
signatureRecord.writeUint32(DIGITAL_SIGNATURE_RECORD_SIGNATURE);
|
|
7670
7716
|
signatureRecord.writeUint16(signatureDataLength);
|
|
7671
7717
|
signatureRecord.writeBytes(signatureData);
|
|
7672
|
-
|
|
7718
|
+
const { writer } = zipWriter;
|
|
7719
|
+
if (exceedsAvailableSize(writer, getLength(signatureRecord.array))) {
|
|
7720
|
+
await writer.closeDisk();
|
|
7721
|
+
}
|
|
7722
|
+
await writeData(writer, signatureRecord.array);
|
|
7673
7723
|
return 6 + signatureDataLength;
|
|
7674
7724
|
}
|
|
7675
7725
|
return 0;
|
|
@@ -7780,7 +7830,7 @@
|
|
|
7780
7830
|
return getUint32(getDataView(signatureArray), 0) == SPLIT_ZIP_FILE_SIGNATURE;
|
|
7781
7831
|
}
|
|
7782
7832
|
|
|
7783
|
-
async function copyZipData(zipWriter, reader, entries, directoryOffset
|
|
7833
|
+
async function copyZipData(zipWriter, reader, entries, directoryOffset) {
|
|
7784
7834
|
const { writer } = zipWriter;
|
|
7785
7835
|
const entryPositions = new Map();
|
|
7786
7836
|
if (writer.closeDisk) {
|
|
@@ -7801,9 +7851,10 @@
|
|
|
7801
7851
|
}
|
|
7802
7852
|
await copyData(zipWriter, reader, copiedLength, directoryOffset - copiedLength);
|
|
7803
7853
|
} else {
|
|
7854
|
+
const baseOffset = zipWriter.offset;
|
|
7804
7855
|
await copyData(zipWriter, reader, 0, directoryOffset);
|
|
7805
7856
|
entries.forEach(entry => entryPositions.set(entry, {
|
|
7806
|
-
offset:
|
|
7857
|
+
offset: baseOffset + getSourceOffset(reader, entry),
|
|
7807
7858
|
diskNumberStart: 0
|
|
7808
7859
|
}));
|
|
7809
7860
|
}
|
|
@@ -8575,6 +8626,7 @@
|
|
|
8575
8626
|
exports.ERR_OVERLAPPING_ENTRY = ERR_OVERLAPPING_ENTRY;
|
|
8576
8627
|
exports.ERR_RESERVED_COMPRESSION_METHOD = ERR_RESERVED_COMPRESSION_METHOD;
|
|
8577
8628
|
exports.ERR_SPLIT_ZIP_FILE = ERR_SPLIT_ZIP_FILE;
|
|
8629
|
+
exports.ERR_UNDEFINED_COMPRESSION_METHOD = ERR_UNDEFINED_COMPRESSION_METHOD;
|
|
8578
8630
|
exports.ERR_UNDEFINED_READER = ERR_UNDEFINED_READER;
|
|
8579
8631
|
exports.ERR_UNDEFINED_UNCOMPRESSED_SIZE = ERR_UNDEFINED_UNCOMPRESSED_SIZE;
|
|
8580
8632
|
exports.ERR_UNDETERMINED_SIZE = ERR_UNDETERMINED_SIZE;
|