@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-fs-external.js
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
|
}
|
|
@@ -4828,6 +4841,7 @@ class ZipReader {
|
|
|
4828
4841
|
let startOffset;
|
|
4829
4842
|
let zip64EndOfDirectory;
|
|
4830
4843
|
let zip64EndOfDirectoryVersion2;
|
|
4844
|
+
let zip64EndOfDirectoryLength = ZIP64_END_OF_CENTRAL_DIR_LENGTH;
|
|
4831
4845
|
let directoryEncryptionInfo;
|
|
4832
4846
|
const requiresZip64 = directoryDataOffset == MAX_32_BITS || directoryDataLength == MAX_32_BITS || filesLength == MAX_16_BITS || diskNumber == MAX_16_BITS;
|
|
4833
4847
|
if (directoryDataOffset != MAX_32_BITS && diskNumber != MAX_16_BITS) {
|
|
@@ -4864,6 +4878,7 @@ class ZipReader {
|
|
|
4864
4878
|
Number(getBigUint64(endOfDirectoryView, 4)) - (ZIP64_END_OF_CENTRAL_DIR_LENGTH - 12),
|
|
4865
4879
|
reader.size - directoryDataOffset - ZIP64_END_OF_CENTRAL_DIR_LENGTH);
|
|
4866
4880
|
if (extensibleDataLength > 0) {
|
|
4881
|
+
zip64EndOfDirectoryLength += extensibleDataLength;
|
|
4867
4882
|
const rawExtensibleData = await readUint8Array(reader, directoryDataOffset + ZIP64_END_OF_CENTRAL_DIR_LENGTH, extensibleDataLength);
|
|
4868
4883
|
directoryEncryptionInfo = getDirectoryEncryptionInfo(rawExtensibleData);
|
|
4869
4884
|
}
|
|
@@ -4893,7 +4908,7 @@ class ZipReader {
|
|
|
4893
4908
|
}
|
|
4894
4909
|
let declaredDirectoryDataLength = directoryDataLength;
|
|
4895
4910
|
const centralDirectoryEndOffset = endOfDirectoryInfo.offset -
|
|
4896
|
-
(zip64EndOfDirectory ?
|
|
4911
|
+
(zip64EndOfDirectory ? zip64EndOfDirectoryLength + ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH : 0);
|
|
4897
4912
|
if (directoryDataOffset >= reader.size) {
|
|
4898
4913
|
prependedDataLength = reader.size - directoryDataOffset - directoryDataLength - END_OF_CENTRAL_DIR_LENGTH;
|
|
4899
4914
|
directoryDataOffset = reader.size - directoryDataLength - END_OF_CENTRAL_DIR_LENGTH;
|
|
@@ -4913,7 +4928,9 @@ class ZipReader {
|
|
|
4913
4928
|
}
|
|
4914
4929
|
const expectedDirectoryDataOffset = centralDirectoryEndOffset - directoryDataLength;
|
|
4915
4930
|
if (directoryDataOffset != expectedDirectoryDataOffset && diskNumber == lastDiskNumber) {
|
|
4916
|
-
const storedPointsAtDirectory = getUint32$1(directoryView, offset) == CENTRAL_FILE_HEADER_SIGNATURE
|
|
4931
|
+
const storedPointsAtDirectory = getUint32$1(directoryView, offset) == CENTRAL_FILE_HEADER_SIGNATURE ||
|
|
4932
|
+
Boolean(directoryEncryptionInfo && directoryEncryptionInfo.compressedSize) ||
|
|
4933
|
+
detectEncryptedCentralDirectory(directoryView);
|
|
4917
4934
|
let reconcile = !storedPointsAtDirectory;
|
|
4918
4935
|
if (!reconcile && expectedDirectoryDataOffset >= 0 && expectedDirectoryDataOffset + 4 <= reader.size) {
|
|
4919
4936
|
const expectedSignatureArray = await readUint8Array(reader, expectedDirectoryDataOffset, 4);
|
|
@@ -4942,11 +4959,13 @@ class ZipReader {
|
|
|
4942
4959
|
zipReader.directoryOffset = directoryDataOffset;
|
|
4943
4960
|
zipReader.directoryLength = declaredDirectoryDataLength;
|
|
4944
4961
|
const decryptCentralDirectory = getFunctionOptionValue$1(zipReader, options, OPTION_DECRYPT_CENTRAL_DIRECTORY);
|
|
4945
|
-
let decryptedDirectory;
|
|
4962
|
+
let decryptedDirectory, dataAfterEncryptedDirectory;
|
|
4946
4963
|
if (decryptCentralDirectory && filesLength && directoryArray.length >= 4 &&
|
|
4947
4964
|
getUint32$1(directoryView, 0) != CENTRAL_FILE_HEADER_SIGNATURE &&
|
|
4948
4965
|
(zip64EndOfDirectoryVersion2 || detectEncryptedCentralDirectory(directoryView))) {
|
|
4949
|
-
|
|
4966
|
+
const encryptedDirectoryDataLength = getEncryptedDirectoryDataLength(directoryEncryptionInfo, declaredDirectoryDataLength, directoryArray.length);
|
|
4967
|
+
dataAfterEncryptedDirectory = directoryArray.subarray(encryptedDirectoryDataLength);
|
|
4968
|
+
directoryArray = await decryptCentralDirectory(directoryArray.subarray(0, encryptedDirectoryDataLength), directoryEncryptionInfo);
|
|
4950
4969
|
directoryView = getDataView(directoryArray);
|
|
4951
4970
|
declaredDirectoryDataLength = directoryArray.length;
|
|
4952
4971
|
decryptedDirectory = true;
|
|
@@ -5012,6 +5031,7 @@ class ZipReader {
|
|
|
5012
5031
|
}
|
|
5013
5032
|
Object.assign(fileEntry, {
|
|
5014
5033
|
index: indexFile,
|
|
5034
|
+
decryptedDirectory,
|
|
5015
5035
|
versionMadeBy,
|
|
5016
5036
|
msDosCompatible,
|
|
5017
5037
|
zip64: false,
|
|
@@ -5088,13 +5108,19 @@ class ZipReader {
|
|
|
5088
5108
|
yield entry;
|
|
5089
5109
|
}
|
|
5090
5110
|
let offsetAfterSignature = offset;
|
|
5091
|
-
|
|
5092
|
-
|
|
5093
|
-
|
|
5094
|
-
|
|
5095
|
-
|
|
5111
|
+
let digitalSignature = readDigitalSignature(directoryArray.subarray(offset)) ||
|
|
5112
|
+
(decryptedDirectory ? readDigitalSignature(dataAfterEncryptedDirectory) : UNDEFINED_VALUE);
|
|
5113
|
+
if (!digitalSignature && !decryptedDirectory) {
|
|
5114
|
+
const signatureRecordOffset = directoryDataOffset + offset;
|
|
5115
|
+
const signatureRecordLength = Math.min(centralDirectoryEndOffset - signatureRecordOffset, 6 + MAX_16_BITS);
|
|
5116
|
+
if (signatureRecordLength >= 6) {
|
|
5117
|
+
digitalSignature = readDigitalSignature(await readUint8Array(reader, signatureRecordOffset, signatureRecordLength));
|
|
5096
5118
|
}
|
|
5097
5119
|
}
|
|
5120
|
+
if (digitalSignature) {
|
|
5121
|
+
zipReader.digitalSignature = digitalSignature;
|
|
5122
|
+
offsetAfterSignature = offset + 6 + digitalSignature.length;
|
|
5123
|
+
}
|
|
5098
5124
|
if (checkAmbiguity && offset != declaredDirectoryDataLength && offsetAfterSignature != declaredDirectoryDataLength) {
|
|
5099
5125
|
throwAmbiguousArchive("trailing central directory data");
|
|
5100
5126
|
}
|
|
@@ -5402,6 +5428,27 @@ function detectEncryptedCentralDirectory(directoryView) {
|
|
|
5402
5428
|
return false;
|
|
5403
5429
|
}
|
|
5404
5430
|
|
|
5431
|
+
function readDigitalSignature(signatureRecordArray) {
|
|
5432
|
+
if (signatureRecordArray.length >= 6) {
|
|
5433
|
+
const signatureRecordView = getDataView(signatureRecordArray);
|
|
5434
|
+
if (getUint32$1(signatureRecordView, 0) == DIGITAL_SIGNATURE_RECORD_SIGNATURE) {
|
|
5435
|
+
const signatureDataLength = getUint16$1(signatureRecordView, 4);
|
|
5436
|
+
if (6 + signatureDataLength <= signatureRecordArray.length) {
|
|
5437
|
+
return signatureRecordArray.subarray(6, 6 + signatureDataLength);
|
|
5438
|
+
}
|
|
5439
|
+
}
|
|
5440
|
+
}
|
|
5441
|
+
}
|
|
5442
|
+
|
|
5443
|
+
function getEncryptedDirectoryDataLength(directoryEncryptionInfo, declaredDirectoryDataLength, directoryDataLength) {
|
|
5444
|
+
const encryptedDirectoryDataLength = directoryEncryptionInfo && directoryEncryptionInfo.compressedSize ?
|
|
5445
|
+
directoryEncryptionInfo.compressedSize :
|
|
5446
|
+
declaredDirectoryDataLength;
|
|
5447
|
+
return encryptedDirectoryDataLength > 0 && encryptedDirectoryDataLength <= directoryDataLength ?
|
|
5448
|
+
encryptedDirectoryDataLength :
|
|
5449
|
+
directoryDataLength;
|
|
5450
|
+
}
|
|
5451
|
+
|
|
5405
5452
|
function getDirectoryEncryptionInfo(rawExtensibleData) {
|
|
5406
5453
|
const directoryEncryptionInfo = { rawExtensibleData };
|
|
5407
5454
|
if (rawExtensibleData.length >= 28) {
|
|
@@ -5986,7 +6033,9 @@ async function readSignature(reader, view, anchoredOffset, signatureOffset, size
|
|
|
5986
6033
|
|
|
5987
6034
|
function validateLocalDirectory(zipEntry, localDirectory, rawLocalFilename, checkLocalFilename) {
|
|
5988
6035
|
const { rawFilename } = zipEntry;
|
|
5989
|
-
|
|
6036
|
+
const maskedLocalDirectory = zipEntry.decryptedDirectory &&
|
|
6037
|
+
(localDirectory.rawBitFlag & BITFLAG_MASKED_LOCAL_HEADERS) == BITFLAG_MASKED_LOCAL_HEADERS;
|
|
6038
|
+
if (checkLocalFilename && !maskedLocalDirectory &&
|
|
5990
6039
|
(rawLocalFilename.length != rawFilename.length ||
|
|
5991
6040
|
rawLocalFilename.some((byteValue, indexByte) => byteValue != rawFilename[indexByte]))) {
|
|
5992
6041
|
throwAmbiguousArchive("mismatched local file header (filename)");
|
|
@@ -5997,7 +6046,7 @@ function validateLocalDirectory(zipEntry, localDirectory, rawLocalFilename, chec
|
|
|
5997
6046
|
if (localDirectory.compressionMethod != zipEntry.compressionMethod) {
|
|
5998
6047
|
throwAmbiguousArchive("mismatched local file header (compression method)");
|
|
5999
6048
|
}
|
|
6000
|
-
if (!localDirectory.bitFlag.dataDescriptor &&
|
|
6049
|
+
if (!localDirectory.bitFlag.dataDescriptor && !maskedLocalDirectory &&
|
|
6001
6050
|
(localDirectory.crc32 || localDirectory.compressedSize || localDirectory.uncompressedSize) &&
|
|
6002
6051
|
(localDirectory.crc32 != zipEntry.crc32 ||
|
|
6003
6052
|
localDirectory.compressedSize != zipEntry.compressedSize ||
|
|
@@ -6128,6 +6177,7 @@ const MIN_NTFS_TIME = BigInt(0);
|
|
|
6128
6177
|
const MAX_NTFS_TIME = BigInt("0x7fffffffffffffff");
|
|
6129
6178
|
const ERR_UNSUPPORTED_FORMAT = "Zip64 is not supported (set the 'zip64' option to 'true')";
|
|
6130
6179
|
const ERR_UNDEFINED_UNCOMPRESSED_SIZE = "Undefined uncompressed size";
|
|
6180
|
+
const ERR_UNDEFINED_COMPRESSION_METHOD = "Undefined compression method";
|
|
6131
6181
|
const ERR_UNDETERMINED_SIZE = "Undetermined size";
|
|
6132
6182
|
const ERR_UNDEFINED_READER = "Undefined reader";
|
|
6133
6183
|
const ERR_ZIP_NOT_EMPTY = "Zip file not empty";
|
|
@@ -6143,6 +6193,8 @@ const ERR_INVALID_SIGNATURE_DATA = "Signature data exceeds 64KB";
|
|
|
6143
6193
|
|
|
6144
6194
|
const EXTRAFIELD_DATA_AES = new Uint8Array([0x07, 0x00, 0x02, 0x00, 0x41, 0x45, 0x03, 0x00, 0x00]);
|
|
6145
6195
|
const EXTRAFIELD_OFFSET_AES_VENDOR_VERSION = 4;
|
|
6196
|
+
const EXTRAFIELD_OFFSET_AES_COMPRESSION_METHOD = 9;
|
|
6197
|
+
const EXTRAFIELD_USDZ_MAX_LENGTH = 67;
|
|
6146
6198
|
const VENDOR_VERSION_AE_1 = 1;
|
|
6147
6199
|
const INFOZIP_EXTRA_FIELD_TYPE$1 = "infozip";
|
|
6148
6200
|
const UNIX_EXTRA_FIELD_TYPE = "unix";
|
|
@@ -6189,16 +6241,14 @@ class ZipWriter {
|
|
|
6189
6241
|
await zipReader$1.close();
|
|
6190
6242
|
await initStream(this.writer);
|
|
6191
6243
|
const { directoryOffset } = zipReader$1;
|
|
6192
|
-
let splitZipSignatureLength = 0;
|
|
6193
6244
|
if (this.addSplitZipSignature) {
|
|
6194
6245
|
delete this.addSplitZipSignature;
|
|
6195
6246
|
if (!await startsWithSplitZipSignature(reader)) {
|
|
6196
6247
|
await writeData(this.writer, getSplitZipSignatureArray());
|
|
6197
|
-
|
|
6198
|
-
this.offset += splitZipSignatureLength;
|
|
6248
|
+
this.offset += SPLIT_ZIP_FILE_SIGNATURE_LENGTH;
|
|
6199
6249
|
}
|
|
6200
6250
|
}
|
|
6201
|
-
const entryPositions = await copyZipData(this, reader, entries, directoryOffset
|
|
6251
|
+
const entryPositions = await copyZipData(this, reader, entries, directoryOffset);
|
|
6202
6252
|
this.filenames = new Set(entries.map(entry => entry.filename));
|
|
6203
6253
|
this.fileEntries = new Map(entries.map(entry => {
|
|
6204
6254
|
const {
|
|
@@ -6440,7 +6490,8 @@ async function addFile(zipWriter, name, reader, options) {
|
|
|
6440
6490
|
signature: options[PROPERTY_NAME_SIGNATURE],
|
|
6441
6491
|
crc32: options.crc32 === UNDEFINED_VALUE ? options[PROPERTY_NAME_SIGNATURE] : options.crc32,
|
|
6442
6492
|
offset: zipWriter.offset - diskOffset,
|
|
6443
|
-
diskNumberStart: diskNumber
|
|
6493
|
+
diskNumberStart: diskNumber,
|
|
6494
|
+
[OPTION_USDZ]: zipWriter.options[OPTION_USDZ]
|
|
6444
6495
|
});
|
|
6445
6496
|
const headerInfo = getHeaderInfo(options);
|
|
6446
6497
|
const dataDescriptorInfo = getDataDescriptorInfo(options);
|
|
@@ -6472,15 +6523,9 @@ function resolveAttributes(zipWriter, name, options) {
|
|
|
6472
6523
|
let setuid = getOptionValue(zipWriter, options, PROPERTY_NAME_SETUID);
|
|
6473
6524
|
let setgid = getOptionValue(zipWriter, options, PROPERTY_NAME_SETGID);
|
|
6474
6525
|
let sticky = getOptionValue(zipWriter, options, PROPERTY_NAME_STICKY);
|
|
6475
|
-
|
|
6476
|
-
|
|
6477
|
-
|
|
6478
|
-
if (gid !== UNDEFINED_VALUE && (!Number.isInteger(gid) || gid < 0 || gid > MAX_32_BITS)) {
|
|
6479
|
-
throw new Error(ERR_INVALID_GID);
|
|
6480
|
-
}
|
|
6481
|
-
if (unixMode !== UNDEFINED_VALUE && (!Number.isInteger(unixMode) || unixMode < 0 || unixMode > MAX_16_BITS)) {
|
|
6482
|
-
throw new Error(ERR_INVALID_UNIX_MODE);
|
|
6483
|
-
}
|
|
6526
|
+
checkIntegerOption(uid, MAX_32_BITS, ERR_INVALID_UID);
|
|
6527
|
+
checkIntegerOption(gid, MAX_32_BITS, ERR_INVALID_GID);
|
|
6528
|
+
checkIntegerOption(unixMode, MAX_16_BITS, ERR_INVALID_UNIX_MODE);
|
|
6484
6529
|
if (unixExtraFieldType !== UNDEFINED_VALUE && unixExtraFieldType !== INFOZIP_EXTRA_FIELD_TYPE$1 && unixExtraFieldType !== UNIX_EXTRA_FIELD_TYPE) {
|
|
6485
6530
|
throw new Error(ERR_INVALID_UNIX_EXTRA_FIELD_TYPE);
|
|
6486
6531
|
}
|
|
@@ -6502,9 +6547,7 @@ function resolveAttributes(zipWriter, name, options) {
|
|
|
6502
6547
|
msDosCompatible = true;
|
|
6503
6548
|
versionMadeBy = (versionMadeBy & MAX_8_BITS);
|
|
6504
6549
|
}
|
|
6505
|
-
|
|
6506
|
-
throw new Error(ERR_INVALID_MSDOS_ATTRIBUTES);
|
|
6507
|
-
}
|
|
6550
|
+
checkIntegerOption(msdosAttributesRaw, MAX_8_BITS, ERR_INVALID_MSDOS_ATTRIBUTES);
|
|
6508
6551
|
if (msdosAttributes && (typeof msdosAttributes !== OBJECT_TYPE || Array.isArray(msdosAttributes))) {
|
|
6509
6552
|
throw new Error(ERR_INVALID_MSDOS_DATA);
|
|
6510
6553
|
}
|
|
@@ -6644,9 +6687,7 @@ function resolveMetadata(zipWriter, name, options) {
|
|
|
6644
6687
|
throw new Error(ERR_UNSUPPORTED_COMPRESSION);
|
|
6645
6688
|
}
|
|
6646
6689
|
let level = getNumberOptionValue(zipWriter, options, OPTION_LEVEL);
|
|
6647
|
-
|
|
6648
|
-
throw new Error(ERR_INVALID_LEVEL);
|
|
6649
|
-
}
|
|
6690
|
+
checkIntegerOption(level, MAX_LEVEL, ERR_INVALID_LEVEL);
|
|
6650
6691
|
if (zipWriter.options[OPTION_USDZ]) {
|
|
6651
6692
|
if (password !== UNDEFINED_VALUE || rawPassword !== UNDEFINED_VALUE) {
|
|
6652
6693
|
throw new Error(ERR_UNSUPPORTED_ENCRYPTION_USDZ);
|
|
@@ -6655,6 +6696,9 @@ function resolveMetadata(zipWriter, name, options) {
|
|
|
6655
6696
|
level = 0;
|
|
6656
6697
|
}
|
|
6657
6698
|
}
|
|
6699
|
+
if (passThrough) {
|
|
6700
|
+
level = UNDEFINED_VALUE;
|
|
6701
|
+
}
|
|
6658
6702
|
let useCompressionStream = getOptionValue(zipWriter, options, OPTION_USE_COMPRESSION_STREAM);
|
|
6659
6703
|
let dataDescriptor = getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR);
|
|
6660
6704
|
if (bufferedWrite && dataDescriptor === UNDEFINED_VALUE) {
|
|
@@ -6721,9 +6765,7 @@ function serializeExtraField(extraField) {
|
|
|
6721
6765
|
let extraFieldSize = 0;
|
|
6722
6766
|
let offset = 0;
|
|
6723
6767
|
extraField.forEach((data, type) => {
|
|
6724
|
-
|
|
6725
|
-
throw new Error(ERR_INVALID_EXTRAFIELD_TYPE);
|
|
6726
|
-
}
|
|
6768
|
+
checkInteger(type, MAX_16_BITS, ERR_INVALID_EXTRAFIELD_TYPE);
|
|
6727
6769
|
if (!(data instanceof Uint8Array)) {
|
|
6728
6770
|
throw new Error(ERR_INVALID_EXTRAFIELD_DATA_TYPE);
|
|
6729
6771
|
}
|
|
@@ -6766,6 +6808,9 @@ function resolveEntrySizes(zipWriter, hasContent, contentSize, metadata, options
|
|
|
6766
6808
|
if (uncompressedSize === UNDEFINED_VALUE) {
|
|
6767
6809
|
throw new Error(ERR_UNDEFINED_UNCOMPRESSED_SIZE);
|
|
6768
6810
|
}
|
|
6811
|
+
if (compressionMethod === UNDEFINED_VALUE) {
|
|
6812
|
+
throw new Error(ERR_UNDEFINED_COMPRESSION_METHOD);
|
|
6813
|
+
}
|
|
6769
6814
|
}
|
|
6770
6815
|
const zip64Enabled = zip64 === true;
|
|
6771
6816
|
const encrypted = getOptionValue(zipWriter, options, PROPERTY_NAME_ENCRYPTED);
|
|
@@ -6835,7 +6880,9 @@ async function getEntriesSize(writerOptions, entries, writeOrderGuaranteed, comm
|
|
|
6835
6880
|
const usdz = writerOptions[OPTION_USDZ];
|
|
6836
6881
|
const files = new Map();
|
|
6837
6882
|
let layoutDependsOnWriteOrder = Boolean(usdz);
|
|
6838
|
-
|
|
6883
|
+
const initialOffset = writerOptions[OPTION_OFFSET] === UNDEFINED_VALUE ? 0 : writerOptions[OPTION_OFFSET];
|
|
6884
|
+
let offset = initialOffset;
|
|
6885
|
+
let minimumEntrySize = INFINITY_VALUE;
|
|
6839
6886
|
for (const entry of entries) {
|
|
6840
6887
|
let { name } = entry;
|
|
6841
6888
|
const { size } = entry;
|
|
@@ -6859,7 +6906,7 @@ async function getEntriesSize(writerOptions, entries, writeOrderGuaranteed, comm
|
|
|
6859
6906
|
if (hasContent && !metadata.passThrough && isCompressed(sizes.compressionMethod, sizes.level)) {
|
|
6860
6907
|
throw new Error(ERR_UNDETERMINED_SIZE);
|
|
6861
6908
|
}
|
|
6862
|
-
const entryOptions = Object.assign({}, options, attributesInfo.resolvedOptions, metadata, sizes);
|
|
6909
|
+
const entryOptions = Object.assign({}, options, attributesInfo.resolvedOptions, metadata, sizes, { [OPTION_USDZ]: usdz });
|
|
6863
6910
|
const headerInfo = getHeaderInfo(entryOptions);
|
|
6864
6911
|
const dataDescriptorInfo = getDataDescriptorInfo(entryOptions);
|
|
6865
6912
|
const entryInfo = {
|
|
@@ -6870,15 +6917,17 @@ async function getEntriesSize(writerOptions, entries, writeOrderGuaranteed, comm
|
|
|
6870
6917
|
appendExtraFieldUSDZ(entryInfo, offset);
|
|
6871
6918
|
}
|
|
6872
6919
|
const compressedSize = hasContent ? maximumCompressedSize : 0;
|
|
6873
|
-
if (offset >= MAX_32_BITS) {
|
|
6874
|
-
layoutDependsOnWriteOrder = true;
|
|
6875
|
-
}
|
|
6876
6920
|
files.set(name, Object.assign({}, entryOptions, headerInfo, {
|
|
6877
6921
|
offset,
|
|
6878
6922
|
diskNumberStart: 0,
|
|
6879
6923
|
compressedSize
|
|
6880
6924
|
}));
|
|
6881
|
-
|
|
6925
|
+
const entrySize = entryInfo.metadataSize + compressedSize;
|
|
6926
|
+
minimumEntrySize = Math.min(minimumEntrySize, entrySize);
|
|
6927
|
+
offset += entrySize;
|
|
6928
|
+
}
|
|
6929
|
+
if (files.size && offset - minimumEntrySize >= MAX_32_BITS) {
|
|
6930
|
+
layoutDependsOnWriteOrder = true;
|
|
6882
6931
|
}
|
|
6883
6932
|
if (layoutDependsOnWriteOrder && !writeOrderGuaranteed) {
|
|
6884
6933
|
throw new Error(ERR_UNDETERMINED_SIZE);
|
|
@@ -6892,7 +6941,7 @@ async function getEntriesSize(writerOptions, entries, writeOrderGuaranteed, comm
|
|
|
6892
6941
|
zip64 = true;
|
|
6893
6942
|
}
|
|
6894
6943
|
}
|
|
6895
|
-
return offset + directoryDataLength + commentLength + (zip64 ? ZIP64_END_OF_CENTRAL_DIR_TOTAL_LENGTH : END_OF_CENTRAL_DIR_LENGTH);
|
|
6944
|
+
return offset - initialOffset + directoryDataLength + commentLength + (zip64 ? ZIP64_END_OF_CENTRAL_DIR_TOTAL_LENGTH : END_OF_CENTRAL_DIR_LENGTH);
|
|
6896
6945
|
}
|
|
6897
6946
|
|
|
6898
6947
|
async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
|
|
@@ -7389,12 +7438,13 @@ function getHeaderInfo(options) {
|
|
|
7389
7438
|
if (passThrough && crc32 !== UNDEFINED_VALUE) {
|
|
7390
7439
|
rawExtraFieldAES[EXTRAFIELD_OFFSET_AES_VENDOR_VERSION] = VENDOR_VERSION_AE_1;
|
|
7391
7440
|
}
|
|
7392
|
-
rawExtraFieldAES
|
|
7441
|
+
setUint16(getDataView(rawExtraFieldAES), EXTRAFIELD_OFFSET_AES_COMPRESSION_METHOD, compressionMethod);
|
|
7393
7442
|
compressionMethod = COMPRESSION_METHOD_AES;
|
|
7394
7443
|
}
|
|
7395
7444
|
const localExtraFieldZip64Length = writeLocalExtraFieldZip64 ? getLength(rawLocalExtraFieldZip64) : 0;
|
|
7396
7445
|
const extraFieldLength = localExtraFieldZip64Length + getLength(rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS, rawExtraFieldUnix, rawExtraField, rawLocalExtraField);
|
|
7397
|
-
|
|
7446
|
+
const maximumUsdzExtraFieldLength = options[OPTION_USDZ] ? EXTRAFIELD_USDZ_MAX_LENGTH : 0;
|
|
7447
|
+
if (extraFieldLength + maximumUsdzExtraFieldLength > MAX_16_BITS) {
|
|
7398
7448
|
throw new Error(ERR_INVALID_EXTRAFIELD_DATA);
|
|
7399
7449
|
}
|
|
7400
7450
|
const dosLastModDate = new Date(Math.ceil(Math.floor(lastModDate.getTime() / 1000) / 2) * 2000);
|
|
@@ -7795,7 +7845,11 @@ async function writeDigitalSignatureRecord(zipWriter, directoryArray, options) {
|
|
|
7795
7845
|
signatureRecord.writeUint32(DIGITAL_SIGNATURE_RECORD_SIGNATURE);
|
|
7796
7846
|
signatureRecord.writeUint16(signatureDataLength);
|
|
7797
7847
|
signatureRecord.writeBytes(signatureData);
|
|
7798
|
-
|
|
7848
|
+
const { writer } = zipWriter;
|
|
7849
|
+
if (exceedsAvailableSize(writer, getLength(signatureRecord.array))) {
|
|
7850
|
+
await writer.closeDisk();
|
|
7851
|
+
}
|
|
7852
|
+
await writeData(writer, signatureRecord.array);
|
|
7799
7853
|
return 6 + signatureDataLength;
|
|
7800
7854
|
}
|
|
7801
7855
|
return 0;
|
|
@@ -7906,7 +7960,7 @@ async function startsWithSplitZipSignature(reader) {
|
|
|
7906
7960
|
return getUint32(getDataView(signatureArray), 0) == SPLIT_ZIP_FILE_SIGNATURE;
|
|
7907
7961
|
}
|
|
7908
7962
|
|
|
7909
|
-
async function copyZipData(zipWriter, reader, entries, directoryOffset
|
|
7963
|
+
async function copyZipData(zipWriter, reader, entries, directoryOffset) {
|
|
7910
7964
|
const { writer } = zipWriter;
|
|
7911
7965
|
const entryPositions = new Map();
|
|
7912
7966
|
if (writer.closeDisk) {
|
|
@@ -7927,9 +7981,10 @@ async function copyZipData(zipWriter, reader, entries, directoryOffset, splitZip
|
|
|
7927
7981
|
}
|
|
7928
7982
|
await copyData(zipWriter, reader, copiedLength, directoryOffset - copiedLength);
|
|
7929
7983
|
} else {
|
|
7984
|
+
const baseOffset = zipWriter.offset;
|
|
7930
7985
|
await copyData(zipWriter, reader, 0, directoryOffset);
|
|
7931
7986
|
entries.forEach(entry => entryPositions.set(entry, {
|
|
7932
|
-
offset:
|
|
7987
|
+
offset: baseOffset + getSourceOffset(reader, entry),
|
|
7933
7988
|
diskNumberStart: 0
|
|
7934
7989
|
}));
|
|
7935
7990
|
}
|
|
@@ -9953,10 +10008,7 @@ function getChildEntryOptions(child, selectedEntry, options) {
|
|
|
9953
10008
|
});
|
|
9954
10009
|
}
|
|
9955
10010
|
if (isPassThrough(child, options)) {
|
|
9956
|
-
let
|
|
9957
|
-
if (compressionMethod === 0) {
|
|
9958
|
-
level = 0;
|
|
9959
|
-
}
|
|
10011
|
+
let encryptionStrength;
|
|
9960
10012
|
if (extraFieldAES) {
|
|
9961
10013
|
encryptionStrength = extraFieldAES.strength;
|
|
9962
10014
|
}
|
|
@@ -9966,7 +10018,6 @@ function getChildEntryOptions(child, selectedEntry, options) {
|
|
|
9966
10018
|
zipCrypto,
|
|
9967
10019
|
crc32,
|
|
9968
10020
|
uncompressedSize,
|
|
9969
|
-
level,
|
|
9970
10021
|
encryptionStrength,
|
|
9971
10022
|
compressionMethod
|
|
9972
10023
|
};
|
|
@@ -10381,4 +10432,4 @@ function decodeMimeTypes(data) {
|
|
|
10381
10432
|
return mimeTypes;
|
|
10382
10433
|
}
|
|
10383
10434
|
|
|
10384
|
-
export { BlobReader, BlobWriter, Data64URIReader, Data64URIWriter, ERR_ABORTED, 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_ENTRY_EXISTS, 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_PASS_THROUGH, ERR_INVALID_READER_OPTIONS, 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_READABLE_CONSUMED, 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, ZipDirectoryEntry, ZipEntry, ZipFS, ZipFileEntry, ZipReader, ZipReaderStream, ZipWriter, ZipWriterStream, configure, createBlobTempStream, createOPFSTempStream, createSyncAccessHandleTempStream, fs, getMimeType, registerCodec, resetConfiguration, terminateWorkersAndModule as terminateWorkers, unregisterCodec };
|
|
10435
|
+
export { BlobReader, BlobWriter, Data64URIReader, Data64URIWriter, ERR_ABORTED, 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_ENTRY_EXISTS, 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_PASS_THROUGH, ERR_INVALID_READER_OPTIONS, 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_READABLE_CONSUMED, 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, ZipDirectoryEntry, ZipEntry, ZipFS, ZipFileEntry, ZipReader, ZipReaderStream, ZipWriter, ZipWriterStream, configure, createBlobTempStream, createOPFSTempStream, createSyncAccessHandleTempStream, fs, getMimeType, registerCodec, resetConfiguration, terminateWorkersAndModule as terminateWorkers, unregisterCodec };
|