@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/deno.json
CHANGED
|
@@ -76,6 +76,7 @@ const BITFLAG_LEVEL_SUPER_FAST_MASK = 0b110;
|
|
|
76
76
|
const BITFLAG_DATA_DESCRIPTOR = 0b1000;
|
|
77
77
|
const BITFLAG_STRONG_ENCRYPTION = 0b1000000;
|
|
78
78
|
const BITFLAG_LANG_ENCODING_FLAG = 0b100000000000;
|
|
79
|
+
const BITFLAG_MASKED_LOCAL_HEADERS = 0b10000000000000;
|
|
79
80
|
const FILE_ATTR_MSDOS_DIR_MASK = 0b10000;
|
|
80
81
|
const FILE_ATTR_MSDOS_READONLY_MASK = 0x01;
|
|
81
82
|
const FILE_ATTR_MSDOS_HIDDEN_MASK = 0x02;
|
|
@@ -225,6 +226,18 @@ function checkPasswordOption(password, rawPassword) {
|
|
|
225
226
|
}
|
|
226
227
|
}
|
|
227
228
|
|
|
229
|
+
function checkInteger(value, maxValue, errorMessage) {
|
|
230
|
+
if (!Number.isInteger(value) || value < 0 || value > maxValue) {
|
|
231
|
+
throw new Error(errorMessage);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function checkIntegerOption(value, maxValue, errorMessage) {
|
|
236
|
+
if (value !== UNDEFINED_VALUE) {
|
|
237
|
+
checkInteger(value, maxValue, errorMessage);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
228
241
|
function toNumber(value) {
|
|
229
242
|
return typeof value == STRING_TYPE && value.trim() ? Number(value) : value;
|
|
230
243
|
}
|
|
@@ -4808,6 +4821,7 @@ class ZipReader {
|
|
|
4808
4821
|
let startOffset;
|
|
4809
4822
|
let zip64EndOfDirectory;
|
|
4810
4823
|
let zip64EndOfDirectoryVersion2;
|
|
4824
|
+
let zip64EndOfDirectoryLength = ZIP64_END_OF_CENTRAL_DIR_LENGTH;
|
|
4811
4825
|
let directoryEncryptionInfo;
|
|
4812
4826
|
const requiresZip64 = directoryDataOffset == MAX_32_BITS || directoryDataLength == MAX_32_BITS || filesLength == MAX_16_BITS || diskNumber == MAX_16_BITS;
|
|
4813
4827
|
if (directoryDataOffset != MAX_32_BITS && diskNumber != MAX_16_BITS) {
|
|
@@ -4844,6 +4858,7 @@ class ZipReader {
|
|
|
4844
4858
|
Number(getBigUint64(endOfDirectoryView, 4)) - (ZIP64_END_OF_CENTRAL_DIR_LENGTH - 12),
|
|
4845
4859
|
reader.size - directoryDataOffset - ZIP64_END_OF_CENTRAL_DIR_LENGTH);
|
|
4846
4860
|
if (extensibleDataLength > 0) {
|
|
4861
|
+
zip64EndOfDirectoryLength += extensibleDataLength;
|
|
4847
4862
|
const rawExtensibleData = await readUint8Array(reader, directoryDataOffset + ZIP64_END_OF_CENTRAL_DIR_LENGTH, extensibleDataLength);
|
|
4848
4863
|
directoryEncryptionInfo = getDirectoryEncryptionInfo(rawExtensibleData);
|
|
4849
4864
|
}
|
|
@@ -4873,7 +4888,7 @@ class ZipReader {
|
|
|
4873
4888
|
}
|
|
4874
4889
|
let declaredDirectoryDataLength = directoryDataLength;
|
|
4875
4890
|
const centralDirectoryEndOffset = endOfDirectoryInfo.offset -
|
|
4876
|
-
(zip64EndOfDirectory ?
|
|
4891
|
+
(zip64EndOfDirectory ? zip64EndOfDirectoryLength + ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH : 0);
|
|
4877
4892
|
if (directoryDataOffset >= reader.size) {
|
|
4878
4893
|
prependedDataLength = reader.size - directoryDataOffset - directoryDataLength - END_OF_CENTRAL_DIR_LENGTH;
|
|
4879
4894
|
directoryDataOffset = reader.size - directoryDataLength - END_OF_CENTRAL_DIR_LENGTH;
|
|
@@ -4893,7 +4908,9 @@ class ZipReader {
|
|
|
4893
4908
|
}
|
|
4894
4909
|
const expectedDirectoryDataOffset = centralDirectoryEndOffset - directoryDataLength;
|
|
4895
4910
|
if (directoryDataOffset != expectedDirectoryDataOffset && diskNumber == lastDiskNumber) {
|
|
4896
|
-
const storedPointsAtDirectory = getUint32$1(directoryView, offset) == CENTRAL_FILE_HEADER_SIGNATURE
|
|
4911
|
+
const storedPointsAtDirectory = getUint32$1(directoryView, offset) == CENTRAL_FILE_HEADER_SIGNATURE ||
|
|
4912
|
+
Boolean(directoryEncryptionInfo && directoryEncryptionInfo.compressedSize) ||
|
|
4913
|
+
detectEncryptedCentralDirectory(directoryView);
|
|
4897
4914
|
let reconcile = !storedPointsAtDirectory;
|
|
4898
4915
|
if (!reconcile && expectedDirectoryDataOffset >= 0 && expectedDirectoryDataOffset + 4 <= reader.size) {
|
|
4899
4916
|
const expectedSignatureArray = await readUint8Array(reader, expectedDirectoryDataOffset, 4);
|
|
@@ -4922,11 +4939,13 @@ class ZipReader {
|
|
|
4922
4939
|
zipReader.directoryOffset = directoryDataOffset;
|
|
4923
4940
|
zipReader.directoryLength = declaredDirectoryDataLength;
|
|
4924
4941
|
const decryptCentralDirectory = getFunctionOptionValue$1(zipReader, options, OPTION_DECRYPT_CENTRAL_DIRECTORY);
|
|
4925
|
-
let decryptedDirectory;
|
|
4942
|
+
let decryptedDirectory, dataAfterEncryptedDirectory;
|
|
4926
4943
|
if (decryptCentralDirectory && filesLength && directoryArray.length >= 4 &&
|
|
4927
4944
|
getUint32$1(directoryView, 0) != CENTRAL_FILE_HEADER_SIGNATURE &&
|
|
4928
4945
|
(zip64EndOfDirectoryVersion2 || detectEncryptedCentralDirectory(directoryView))) {
|
|
4929
|
-
|
|
4946
|
+
const encryptedDirectoryDataLength = getEncryptedDirectoryDataLength(directoryEncryptionInfo, declaredDirectoryDataLength, directoryArray.length);
|
|
4947
|
+
dataAfterEncryptedDirectory = directoryArray.subarray(encryptedDirectoryDataLength);
|
|
4948
|
+
directoryArray = await decryptCentralDirectory(directoryArray.subarray(0, encryptedDirectoryDataLength), directoryEncryptionInfo);
|
|
4930
4949
|
directoryView = getDataView(directoryArray);
|
|
4931
4950
|
declaredDirectoryDataLength = directoryArray.length;
|
|
4932
4951
|
decryptedDirectory = true;
|
|
@@ -4992,6 +5011,7 @@ class ZipReader {
|
|
|
4992
5011
|
}
|
|
4993
5012
|
Object.assign(fileEntry, {
|
|
4994
5013
|
index: indexFile,
|
|
5014
|
+
decryptedDirectory,
|
|
4995
5015
|
versionMadeBy,
|
|
4996
5016
|
msDosCompatible,
|
|
4997
5017
|
zip64: false,
|
|
@@ -5068,13 +5088,19 @@ class ZipReader {
|
|
|
5068
5088
|
yield entry;
|
|
5069
5089
|
}
|
|
5070
5090
|
let offsetAfterSignature = offset;
|
|
5071
|
-
|
|
5072
|
-
|
|
5073
|
-
|
|
5074
|
-
|
|
5075
|
-
|
|
5091
|
+
let digitalSignature = readDigitalSignature(directoryArray.subarray(offset)) ||
|
|
5092
|
+
(decryptedDirectory ? readDigitalSignature(dataAfterEncryptedDirectory) : UNDEFINED_VALUE);
|
|
5093
|
+
if (!digitalSignature && !decryptedDirectory) {
|
|
5094
|
+
const signatureRecordOffset = directoryDataOffset + offset;
|
|
5095
|
+
const signatureRecordLength = Math.min(centralDirectoryEndOffset - signatureRecordOffset, 6 + MAX_16_BITS);
|
|
5096
|
+
if (signatureRecordLength >= 6) {
|
|
5097
|
+
digitalSignature = readDigitalSignature(await readUint8Array(reader, signatureRecordOffset, signatureRecordLength));
|
|
5076
5098
|
}
|
|
5077
5099
|
}
|
|
5100
|
+
if (digitalSignature) {
|
|
5101
|
+
zipReader.digitalSignature = digitalSignature;
|
|
5102
|
+
offsetAfterSignature = offset + 6 + digitalSignature.length;
|
|
5103
|
+
}
|
|
5078
5104
|
if (checkAmbiguity && offset != declaredDirectoryDataLength && offsetAfterSignature != declaredDirectoryDataLength) {
|
|
5079
5105
|
throwAmbiguousArchive("trailing central directory data");
|
|
5080
5106
|
}
|
|
@@ -5382,6 +5408,27 @@ function detectEncryptedCentralDirectory(directoryView) {
|
|
|
5382
5408
|
return false;
|
|
5383
5409
|
}
|
|
5384
5410
|
|
|
5411
|
+
function readDigitalSignature(signatureRecordArray) {
|
|
5412
|
+
if (signatureRecordArray.length >= 6) {
|
|
5413
|
+
const signatureRecordView = getDataView(signatureRecordArray);
|
|
5414
|
+
if (getUint32$1(signatureRecordView, 0) == DIGITAL_SIGNATURE_RECORD_SIGNATURE) {
|
|
5415
|
+
const signatureDataLength = getUint16$1(signatureRecordView, 4);
|
|
5416
|
+
if (6 + signatureDataLength <= signatureRecordArray.length) {
|
|
5417
|
+
return signatureRecordArray.subarray(6, 6 + signatureDataLength);
|
|
5418
|
+
}
|
|
5419
|
+
}
|
|
5420
|
+
}
|
|
5421
|
+
}
|
|
5422
|
+
|
|
5423
|
+
function getEncryptedDirectoryDataLength(directoryEncryptionInfo, declaredDirectoryDataLength, directoryDataLength) {
|
|
5424
|
+
const encryptedDirectoryDataLength = directoryEncryptionInfo && directoryEncryptionInfo.compressedSize ?
|
|
5425
|
+
directoryEncryptionInfo.compressedSize :
|
|
5426
|
+
declaredDirectoryDataLength;
|
|
5427
|
+
return encryptedDirectoryDataLength > 0 && encryptedDirectoryDataLength <= directoryDataLength ?
|
|
5428
|
+
encryptedDirectoryDataLength :
|
|
5429
|
+
directoryDataLength;
|
|
5430
|
+
}
|
|
5431
|
+
|
|
5385
5432
|
function getDirectoryEncryptionInfo(rawExtensibleData) {
|
|
5386
5433
|
const directoryEncryptionInfo = { rawExtensibleData };
|
|
5387
5434
|
if (rawExtensibleData.length >= 28) {
|
|
@@ -5966,7 +6013,9 @@ async function readSignature(reader, view, anchoredOffset, signatureOffset, size
|
|
|
5966
6013
|
|
|
5967
6014
|
function validateLocalDirectory(zipEntry, localDirectory, rawLocalFilename, checkLocalFilename) {
|
|
5968
6015
|
const { rawFilename } = zipEntry;
|
|
5969
|
-
|
|
6016
|
+
const maskedLocalDirectory = zipEntry.decryptedDirectory &&
|
|
6017
|
+
(localDirectory.rawBitFlag & BITFLAG_MASKED_LOCAL_HEADERS) == BITFLAG_MASKED_LOCAL_HEADERS;
|
|
6018
|
+
if (checkLocalFilename && !maskedLocalDirectory &&
|
|
5970
6019
|
(rawLocalFilename.length != rawFilename.length ||
|
|
5971
6020
|
rawLocalFilename.some((byteValue, indexByte) => byteValue != rawFilename[indexByte]))) {
|
|
5972
6021
|
throwAmbiguousArchive("mismatched local file header (filename)");
|
|
@@ -5977,7 +6026,7 @@ function validateLocalDirectory(zipEntry, localDirectory, rawLocalFilename, chec
|
|
|
5977
6026
|
if (localDirectory.compressionMethod != zipEntry.compressionMethod) {
|
|
5978
6027
|
throwAmbiguousArchive("mismatched local file header (compression method)");
|
|
5979
6028
|
}
|
|
5980
|
-
if (!localDirectory.bitFlag.dataDescriptor &&
|
|
6029
|
+
if (!localDirectory.bitFlag.dataDescriptor && !maskedLocalDirectory &&
|
|
5981
6030
|
(localDirectory.crc32 || localDirectory.compressedSize || localDirectory.uncompressedSize) &&
|
|
5982
6031
|
(localDirectory.crc32 != zipEntry.crc32 ||
|
|
5983
6032
|
localDirectory.compressedSize != zipEntry.compressedSize ||
|
|
@@ -6108,6 +6157,7 @@ const MIN_NTFS_TIME = BigInt(0);
|
|
|
6108
6157
|
const MAX_NTFS_TIME = BigInt("0x7fffffffffffffff");
|
|
6109
6158
|
const ERR_UNSUPPORTED_FORMAT = "Zip64 is not supported (set the 'zip64' option to 'true')";
|
|
6110
6159
|
const ERR_UNDEFINED_UNCOMPRESSED_SIZE = "Undefined uncompressed size";
|
|
6160
|
+
const ERR_UNDEFINED_COMPRESSION_METHOD = "Undefined compression method";
|
|
6111
6161
|
const ERR_UNDETERMINED_SIZE = "Undetermined size";
|
|
6112
6162
|
const ERR_UNDEFINED_READER = "Undefined reader";
|
|
6113
6163
|
const ERR_ZIP_NOT_EMPTY = "Zip file not empty";
|
|
@@ -6123,6 +6173,8 @@ const ERR_INVALID_SIGNATURE_DATA = "Signature data exceeds 64KB";
|
|
|
6123
6173
|
|
|
6124
6174
|
const EXTRAFIELD_DATA_AES = new Uint8Array([0x07, 0x00, 0x02, 0x00, 0x41, 0x45, 0x03, 0x00, 0x00]);
|
|
6125
6175
|
const EXTRAFIELD_OFFSET_AES_VENDOR_VERSION = 4;
|
|
6176
|
+
const EXTRAFIELD_OFFSET_AES_COMPRESSION_METHOD = 9;
|
|
6177
|
+
const EXTRAFIELD_USDZ_MAX_LENGTH = 67;
|
|
6126
6178
|
const VENDOR_VERSION_AE_1 = 1;
|
|
6127
6179
|
const INFOZIP_EXTRA_FIELD_TYPE = "infozip";
|
|
6128
6180
|
const UNIX_EXTRA_FIELD_TYPE = "unix";
|
|
@@ -6169,16 +6221,14 @@ class ZipWriter {
|
|
|
6169
6221
|
await zipReader$1.close();
|
|
6170
6222
|
await initStream(this.writer);
|
|
6171
6223
|
const { directoryOffset } = zipReader$1;
|
|
6172
|
-
let splitZipSignatureLength = 0;
|
|
6173
6224
|
if (this.addSplitZipSignature) {
|
|
6174
6225
|
delete this.addSplitZipSignature;
|
|
6175
6226
|
if (!await startsWithSplitZipSignature(reader)) {
|
|
6176
6227
|
await writeData(this.writer, getSplitZipSignatureArray());
|
|
6177
|
-
|
|
6178
|
-
this.offset += splitZipSignatureLength;
|
|
6228
|
+
this.offset += SPLIT_ZIP_FILE_SIGNATURE_LENGTH;
|
|
6179
6229
|
}
|
|
6180
6230
|
}
|
|
6181
|
-
const entryPositions = await copyZipData(this, reader, entries, directoryOffset
|
|
6231
|
+
const entryPositions = await copyZipData(this, reader, entries, directoryOffset);
|
|
6182
6232
|
this.filenames = new Set(entries.map(entry => entry.filename));
|
|
6183
6233
|
this.fileEntries = new Map(entries.map(entry => {
|
|
6184
6234
|
const {
|
|
@@ -6420,7 +6470,8 @@ async function addFile(zipWriter, name, reader, options) {
|
|
|
6420
6470
|
signature: options[PROPERTY_NAME_SIGNATURE],
|
|
6421
6471
|
crc32: options.crc32 === UNDEFINED_VALUE ? options[PROPERTY_NAME_SIGNATURE] : options.crc32,
|
|
6422
6472
|
offset: zipWriter.offset - diskOffset,
|
|
6423
|
-
diskNumberStart: diskNumber
|
|
6473
|
+
diskNumberStart: diskNumber,
|
|
6474
|
+
[OPTION_USDZ]: zipWriter.options[OPTION_USDZ]
|
|
6424
6475
|
});
|
|
6425
6476
|
const headerInfo = getHeaderInfo(options);
|
|
6426
6477
|
const dataDescriptorInfo = getDataDescriptorInfo(options);
|
|
@@ -6452,15 +6503,9 @@ function resolveAttributes(zipWriter, name, options) {
|
|
|
6452
6503
|
let setuid = getOptionValue(zipWriter, options, PROPERTY_NAME_SETUID);
|
|
6453
6504
|
let setgid = getOptionValue(zipWriter, options, PROPERTY_NAME_SETGID);
|
|
6454
6505
|
let sticky = getOptionValue(zipWriter, options, PROPERTY_NAME_STICKY);
|
|
6455
|
-
|
|
6456
|
-
|
|
6457
|
-
|
|
6458
|
-
if (gid !== UNDEFINED_VALUE && (!Number.isInteger(gid) || gid < 0 || gid > MAX_32_BITS)) {
|
|
6459
|
-
throw new Error(ERR_INVALID_GID);
|
|
6460
|
-
}
|
|
6461
|
-
if (unixMode !== UNDEFINED_VALUE && (!Number.isInteger(unixMode) || unixMode < 0 || unixMode > MAX_16_BITS)) {
|
|
6462
|
-
throw new Error(ERR_INVALID_UNIX_MODE);
|
|
6463
|
-
}
|
|
6506
|
+
checkIntegerOption(uid, MAX_32_BITS, ERR_INVALID_UID);
|
|
6507
|
+
checkIntegerOption(gid, MAX_32_BITS, ERR_INVALID_GID);
|
|
6508
|
+
checkIntegerOption(unixMode, MAX_16_BITS, ERR_INVALID_UNIX_MODE);
|
|
6464
6509
|
if (unixExtraFieldType !== UNDEFINED_VALUE && unixExtraFieldType !== INFOZIP_EXTRA_FIELD_TYPE && unixExtraFieldType !== UNIX_EXTRA_FIELD_TYPE) {
|
|
6465
6510
|
throw new Error(ERR_INVALID_UNIX_EXTRA_FIELD_TYPE);
|
|
6466
6511
|
}
|
|
@@ -6482,9 +6527,7 @@ function resolveAttributes(zipWriter, name, options) {
|
|
|
6482
6527
|
msDosCompatible = true;
|
|
6483
6528
|
versionMadeBy = (versionMadeBy & MAX_8_BITS);
|
|
6484
6529
|
}
|
|
6485
|
-
|
|
6486
|
-
throw new Error(ERR_INVALID_MSDOS_ATTRIBUTES);
|
|
6487
|
-
}
|
|
6530
|
+
checkIntegerOption(msdosAttributesRaw, MAX_8_BITS, ERR_INVALID_MSDOS_ATTRIBUTES);
|
|
6488
6531
|
if (msdosAttributes && (typeof msdosAttributes !== OBJECT_TYPE || Array.isArray(msdosAttributes))) {
|
|
6489
6532
|
throw new Error(ERR_INVALID_MSDOS_DATA);
|
|
6490
6533
|
}
|
|
@@ -6624,9 +6667,7 @@ function resolveMetadata(zipWriter, name, options) {
|
|
|
6624
6667
|
throw new Error(ERR_UNSUPPORTED_COMPRESSION);
|
|
6625
6668
|
}
|
|
6626
6669
|
let level = getNumberOptionValue(zipWriter, options, OPTION_LEVEL);
|
|
6627
|
-
|
|
6628
|
-
throw new Error(ERR_INVALID_LEVEL);
|
|
6629
|
-
}
|
|
6670
|
+
checkIntegerOption(level, MAX_LEVEL, ERR_INVALID_LEVEL);
|
|
6630
6671
|
if (zipWriter.options[OPTION_USDZ]) {
|
|
6631
6672
|
if (password !== UNDEFINED_VALUE || rawPassword !== UNDEFINED_VALUE) {
|
|
6632
6673
|
throw new Error(ERR_UNSUPPORTED_ENCRYPTION_USDZ);
|
|
@@ -6635,6 +6676,9 @@ function resolveMetadata(zipWriter, name, options) {
|
|
|
6635
6676
|
level = 0;
|
|
6636
6677
|
}
|
|
6637
6678
|
}
|
|
6679
|
+
if (passThrough) {
|
|
6680
|
+
level = UNDEFINED_VALUE;
|
|
6681
|
+
}
|
|
6638
6682
|
let useCompressionStream = getOptionValue(zipWriter, options, OPTION_USE_COMPRESSION_STREAM);
|
|
6639
6683
|
let dataDescriptor = getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR);
|
|
6640
6684
|
if (bufferedWrite && dataDescriptor === UNDEFINED_VALUE) {
|
|
@@ -6701,9 +6745,7 @@ function serializeExtraField(extraField) {
|
|
|
6701
6745
|
let extraFieldSize = 0;
|
|
6702
6746
|
let offset = 0;
|
|
6703
6747
|
extraField.forEach((data, type) => {
|
|
6704
|
-
|
|
6705
|
-
throw new Error(ERR_INVALID_EXTRAFIELD_TYPE);
|
|
6706
|
-
}
|
|
6748
|
+
checkInteger(type, MAX_16_BITS, ERR_INVALID_EXTRAFIELD_TYPE);
|
|
6707
6749
|
if (!(data instanceof Uint8Array)) {
|
|
6708
6750
|
throw new Error(ERR_INVALID_EXTRAFIELD_DATA_TYPE);
|
|
6709
6751
|
}
|
|
@@ -6746,6 +6788,9 @@ function resolveEntrySizes(zipWriter, hasContent, contentSize, metadata, options
|
|
|
6746
6788
|
if (uncompressedSize === UNDEFINED_VALUE) {
|
|
6747
6789
|
throw new Error(ERR_UNDEFINED_UNCOMPRESSED_SIZE);
|
|
6748
6790
|
}
|
|
6791
|
+
if (compressionMethod === UNDEFINED_VALUE) {
|
|
6792
|
+
throw new Error(ERR_UNDEFINED_COMPRESSION_METHOD);
|
|
6793
|
+
}
|
|
6749
6794
|
}
|
|
6750
6795
|
const zip64Enabled = zip64 === true;
|
|
6751
6796
|
const encrypted = getOptionValue(zipWriter, options, PROPERTY_NAME_ENCRYPTED);
|
|
@@ -7294,12 +7339,13 @@ function getHeaderInfo(options) {
|
|
|
7294
7339
|
if (passThrough && crc32 !== UNDEFINED_VALUE) {
|
|
7295
7340
|
rawExtraFieldAES[EXTRAFIELD_OFFSET_AES_VENDOR_VERSION] = VENDOR_VERSION_AE_1;
|
|
7296
7341
|
}
|
|
7297
|
-
rawExtraFieldAES
|
|
7342
|
+
setUint16(getDataView(rawExtraFieldAES), EXTRAFIELD_OFFSET_AES_COMPRESSION_METHOD, compressionMethod);
|
|
7298
7343
|
compressionMethod = COMPRESSION_METHOD_AES;
|
|
7299
7344
|
}
|
|
7300
7345
|
const localExtraFieldZip64Length = writeLocalExtraFieldZip64 ? getLength(rawLocalExtraFieldZip64) : 0;
|
|
7301
7346
|
const extraFieldLength = localExtraFieldZip64Length + getLength(rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS, rawExtraFieldUnix, rawExtraField, rawLocalExtraField);
|
|
7302
|
-
|
|
7347
|
+
const maximumUsdzExtraFieldLength = options[OPTION_USDZ] ? EXTRAFIELD_USDZ_MAX_LENGTH : 0;
|
|
7348
|
+
if (extraFieldLength + maximumUsdzExtraFieldLength > MAX_16_BITS) {
|
|
7303
7349
|
throw new Error(ERR_INVALID_EXTRAFIELD_DATA);
|
|
7304
7350
|
}
|
|
7305
7351
|
const dosLastModDate = new Date(Math.ceil(Math.floor(lastModDate.getTime() / 1000) / 2) * 2000);
|
|
@@ -7700,7 +7746,11 @@ async function writeDigitalSignatureRecord(zipWriter, directoryArray, options) {
|
|
|
7700
7746
|
signatureRecord.writeUint32(DIGITAL_SIGNATURE_RECORD_SIGNATURE);
|
|
7701
7747
|
signatureRecord.writeUint16(signatureDataLength);
|
|
7702
7748
|
signatureRecord.writeBytes(signatureData);
|
|
7703
|
-
|
|
7749
|
+
const { writer } = zipWriter;
|
|
7750
|
+
if (exceedsAvailableSize(writer, getLength(signatureRecord.array))) {
|
|
7751
|
+
await writer.closeDisk();
|
|
7752
|
+
}
|
|
7753
|
+
await writeData(writer, signatureRecord.array);
|
|
7704
7754
|
return 6 + signatureDataLength;
|
|
7705
7755
|
}
|
|
7706
7756
|
return 0;
|
|
@@ -7811,7 +7861,7 @@ async function startsWithSplitZipSignature(reader) {
|
|
|
7811
7861
|
return getUint32(getDataView(signatureArray), 0) == SPLIT_ZIP_FILE_SIGNATURE;
|
|
7812
7862
|
}
|
|
7813
7863
|
|
|
7814
|
-
async function copyZipData(zipWriter, reader, entries, directoryOffset
|
|
7864
|
+
async function copyZipData(zipWriter, reader, entries, directoryOffset) {
|
|
7815
7865
|
const { writer } = zipWriter;
|
|
7816
7866
|
const entryPositions = new Map();
|
|
7817
7867
|
if (writer.closeDisk) {
|
|
@@ -7832,9 +7882,10 @@ async function copyZipData(zipWriter, reader, entries, directoryOffset, splitZip
|
|
|
7832
7882
|
}
|
|
7833
7883
|
await copyData(zipWriter, reader, copiedLength, directoryOffset - copiedLength);
|
|
7834
7884
|
} else {
|
|
7885
|
+
const baseOffset = zipWriter.offset;
|
|
7835
7886
|
await copyData(zipWriter, reader, 0, directoryOffset);
|
|
7836
7887
|
entries.forEach(entry => entryPositions.set(entry, {
|
|
7837
|
-
offset:
|
|
7888
|
+
offset: baseOffset + getSourceOffset(reader, entry),
|
|
7838
7889
|
diskNumberStart: 0
|
|
7839
7890
|
}));
|
|
7840
7891
|
}
|
|
@@ -8924,4 +8975,4 @@ function terminateWorkersAndModule() {
|
|
|
8924
8975
|
|
|
8925
8976
|
configureExternalAssets();
|
|
8926
8977
|
|
|
8927
|
-
export { BlobReader, BlobWriter, Data64URIReader, Data64URIWriter, ERR_AMBIGUOUS_ARCHIVE, ERR_BAD_FORMAT, ERR_CENTRAL_DIRECTORY_NOT_FOUND, ERR_DUPLICATED_NAME, ERR_ENCRYPTED, ERR_ENCRYPTED_CENTRAL_DIRECTORY, ERR_ENTRY_DATA_OUT_OF_BOUNDS, ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND, ERR_EOCDR_NOT_FOUND, ERR_EXTRAFIELD_ZIP64_NOT_FOUND, ERR_HTTP_RANGE, ERR_HTTP_RESOURCE_CHANGED, ERR_INVALID_AUTHENTICATION_CODE, ERR_INVALID_CODEC_DEFINITION, ERR_INVALID_CODEC_MODULE, ERR_INVALID_COMMENT, ERR_INVALID_COMMENT_TYPE, ERR_INVALID_COMPRESSED_DATA, ERR_INVALID_CRC32, ERR_INVALID_DATE, ERR_INVALID_ENCRYPTION_STRENGTH, ERR_INVALID_ENTRY_COMMENT, ERR_INVALID_ENTRY_COMMENT_TYPE, ERR_INVALID_ENTRY_NAME, ERR_INVALID_EXTRAFIELD, ERR_INVALID_EXTRAFIELD_DATA, ERR_INVALID_EXTRAFIELD_DATA_TYPE, ERR_INVALID_EXTRAFIELD_TYPE, ERR_INVALID_FILENAME_VALIDATION, ERR_INVALID_FUNCTION_OPTION, ERR_INVALID_GID, ERR_INVALID_LEVEL, ERR_INVALID_MAX_APPENDED_DATA_SIZE, ERR_INVALID_MAX_WORKERS, ERR_INVALID_MSDOS_ATTRIBUTES, ERR_INVALID_MSDOS_DATA, ERR_INVALID_PASSWORD, ERR_INVALID_PASSWORD_TYPE, ERR_INVALID_SIGNAL, ERR_INVALID_SIGNATURE, ERR_INVALID_SIGNATURE_DATA, ERR_INVALID_STRICTNESS, ERR_INVALID_UID, ERR_INVALID_UNCOMPRESSED_SIZE, ERR_INVALID_UNIX_EXTRA_FIELD_TYPE, ERR_INVALID_UNIX_ID_SIZE, ERR_INVALID_UNIX_MODE, ERR_INVALID_VERSION, ERR_ITERATOR_COMPLETED_TOO_SOON, ERR_LOCAL_FILE_HEADER_NOT_FOUND, ERR_OVERLAPPING_ENTRY, ERR_RESERVED_COMPRESSION_METHOD, ERR_SPLIT_ZIP_FILE, ERR_UNDEFINED_READER, ERR_UNDEFINED_UNCOMPRESSED_SIZE, ERR_UNDETERMINED_SIZE, ERR_UNSAFE_FILENAME, ERR_UNSUPPORTED_COMPRESSION$1 as ERR_UNSUPPORTED_COMPRESSION, ERR_UNSUPPORTED_CONTEXT, ERR_UNSUPPORTED_CRYPTO_API, ERR_UNSUPPORTED_ENCRYPTION, ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH, ERR_UNSUPPORTED_ENCRYPTION_USDZ, ERR_UNSUPPORTED_FORMAT, ERR_WORKER_STARTUP_TIMEOUT, ERR_WRITER_NOT_INITIALIZED, ERR_ZIP_NOT_EMPTY, HttpRangeReader, HttpReader, Reader, SplitDataReader, SplitDataWriter, TextReader, TextWriter, Uint8ArrayReader, Uint8ArrayWriter, Writer, ZipReader, ZipReaderStream, ZipWriter, ZipWriterStream, configure, createBlobTempStream, createOPFSTempStream, createSyncAccessHandleTempStream, getMimeType, registerCodec, resetConfiguration, terminateWorkersAndModule as terminateWorkers, unregisterCodec };
|
|
8978
|
+
export { BlobReader, BlobWriter, Data64URIReader, Data64URIWriter, ERR_AMBIGUOUS_ARCHIVE, ERR_BAD_FORMAT, ERR_CENTRAL_DIRECTORY_NOT_FOUND, ERR_DUPLICATED_NAME, ERR_ENCRYPTED, ERR_ENCRYPTED_CENTRAL_DIRECTORY, ERR_ENTRY_DATA_OUT_OF_BOUNDS, ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND, ERR_EOCDR_NOT_FOUND, ERR_EXTRAFIELD_ZIP64_NOT_FOUND, ERR_HTTP_RANGE, ERR_HTTP_RESOURCE_CHANGED, ERR_INVALID_AUTHENTICATION_CODE, ERR_INVALID_CODEC_DEFINITION, ERR_INVALID_CODEC_MODULE, ERR_INVALID_COMMENT, ERR_INVALID_COMMENT_TYPE, ERR_INVALID_COMPRESSED_DATA, ERR_INVALID_CRC32, ERR_INVALID_DATE, ERR_INVALID_ENCRYPTION_STRENGTH, ERR_INVALID_ENTRY_COMMENT, ERR_INVALID_ENTRY_COMMENT_TYPE, ERR_INVALID_ENTRY_NAME, ERR_INVALID_EXTRAFIELD, ERR_INVALID_EXTRAFIELD_DATA, ERR_INVALID_EXTRAFIELD_DATA_TYPE, ERR_INVALID_EXTRAFIELD_TYPE, ERR_INVALID_FILENAME_VALIDATION, ERR_INVALID_FUNCTION_OPTION, ERR_INVALID_GID, ERR_INVALID_LEVEL, ERR_INVALID_MAX_APPENDED_DATA_SIZE, ERR_INVALID_MAX_WORKERS, ERR_INVALID_MSDOS_ATTRIBUTES, ERR_INVALID_MSDOS_DATA, ERR_INVALID_PASSWORD, ERR_INVALID_PASSWORD_TYPE, ERR_INVALID_SIGNAL, ERR_INVALID_SIGNATURE, ERR_INVALID_SIGNATURE_DATA, ERR_INVALID_STRICTNESS, ERR_INVALID_UID, ERR_INVALID_UNCOMPRESSED_SIZE, ERR_INVALID_UNIX_EXTRA_FIELD_TYPE, ERR_INVALID_UNIX_ID_SIZE, ERR_INVALID_UNIX_MODE, ERR_INVALID_VERSION, ERR_ITERATOR_COMPLETED_TOO_SOON, ERR_LOCAL_FILE_HEADER_NOT_FOUND, ERR_OVERLAPPING_ENTRY, ERR_RESERVED_COMPRESSION_METHOD, ERR_SPLIT_ZIP_FILE, ERR_UNDEFINED_COMPRESSION_METHOD, ERR_UNDEFINED_READER, ERR_UNDEFINED_UNCOMPRESSED_SIZE, ERR_UNDETERMINED_SIZE, ERR_UNSAFE_FILENAME, ERR_UNSUPPORTED_COMPRESSION$1 as ERR_UNSUPPORTED_COMPRESSION, ERR_UNSUPPORTED_CONTEXT, ERR_UNSUPPORTED_CRYPTO_API, ERR_UNSUPPORTED_ENCRYPTION, ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH, ERR_UNSUPPORTED_ENCRYPTION_USDZ, ERR_UNSUPPORTED_FORMAT, ERR_WORKER_STARTUP_TIMEOUT, ERR_WRITER_NOT_INITIALIZED, ERR_ZIP_NOT_EMPTY, HttpRangeReader, HttpReader, Reader, SplitDataReader, SplitDataWriter, TextReader, TextWriter, Uint8ArrayReader, Uint8ArrayWriter, Writer, ZipReader, ZipReaderStream, ZipWriter, ZipWriterStream, configure, createBlobTempStream, createOPFSTempStream, createSyncAccessHandleTempStream, getMimeType, registerCodec, resetConfiguration, terminateWorkersAndModule as terminateWorkers, unregisterCodec };
|