@zip.js/zip.js 2.8.55 → 2.8.57
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 +90 -52
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +90 -51
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +102 -60
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +101 -59
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +102 -60
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +102 -59
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +102 -59
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +90 -51
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +90 -51
- package/dist/zip-native.min.js +1 -1
- package/dist/zip.js +90 -51
- package/dist/zip.min.js +1 -1
- package/index-native.cjs +102 -59
- package/index-native.min.js +1 -1
- package/index.cjs +102 -59
- package/index.d.cts +18 -1
- package/index.d.ts +18 -1
- package/index.min.js +1 -1
- package/lib/core/options.js +14 -0
- package/lib/core/zip-fs.js +1 -1
- package/lib/core/zip-reader.js +19 -5
- package/lib/core/zip-writer.js +73 -55
- package/lib/zip-core-reader.js +1 -0
- package/package.json +1 -1
package/index-native.cjs
CHANGED
|
@@ -229,6 +229,18 @@ function checkPasswordOption(password, rawPassword) {
|
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
+
function checkInteger(value, maxValue, errorMessage) {
|
|
233
|
+
if (!Number.isInteger(value) || value < 0 || value > maxValue) {
|
|
234
|
+
throw new Error(errorMessage);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function checkIntegerOption(value, maxValue, errorMessage) {
|
|
239
|
+
if (value !== UNDEFINED_VALUE) {
|
|
240
|
+
checkInteger(value, maxValue, errorMessage);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
232
244
|
function toNumber(value) {
|
|
233
245
|
return typeof value == STRING_TYPE && value.trim() ? Number(value) : value;
|
|
234
246
|
}
|
|
@@ -4711,6 +4723,7 @@ const ERR_UNSAFE_FILENAME = "Unsafe filename";
|
|
|
4711
4723
|
const ERR_INVALID_STRICTNESS = "Invalid strictness (must be 'strict', 'balanced' or 'tolerant')";
|
|
4712
4724
|
const ERR_INVALID_FILENAME_VALIDATION = "Invalid filenameValidation (must be 'strict', 'balanced' or 'tolerant')";
|
|
4713
4725
|
const ERR_INVALID_MAX_APPENDED_DATA_SIZE = "Invalid maxAppendedDataSize (must be a number greater than or equal to 0)";
|
|
4726
|
+
const ERR_UNSUPPORTED_UINT64 = "64-bit value exceeds Number.MAX_SAFE_INTEGER";
|
|
4714
4727
|
const DRIVE_LETTER_REGEXP = /^[a-zA-Z]:/;
|
|
4715
4728
|
const CHARSET_UTF8 = "utf-8";
|
|
4716
4729
|
const PROPERTY_NAME_UTF8_SUFFIX = "UTF8";
|
|
@@ -4733,6 +4746,7 @@ const ZIP64_EXTRACTION = {
|
|
|
4733
4746
|
bytes: 8
|
|
4734
4747
|
}
|
|
4735
4748
|
};
|
|
4749
|
+
const MAX_SAFE_UINT64 = BigInt(Number.MAX_SAFE_INTEGER);
|
|
4736
4750
|
const MAX_END_OF_CENTRAL_DIR_PROBES = 64;
|
|
4737
4751
|
const MAX_DEFLATE_EXPANSION_RATIO = 1032;
|
|
4738
4752
|
const CENTRAL_DIRECTORY_UNREACHABLE = 0;
|
|
@@ -4828,7 +4842,7 @@ class ZipReader {
|
|
|
4828
4842
|
zip64EndOfDirectoryVersion2 = getBigUint64(endOfDirectoryView, 4) > ZIP64_END_OF_CENTRAL_DIR_LENGTH - 12;
|
|
4829
4843
|
if (zip64EndOfDirectoryVersion2) {
|
|
4830
4844
|
const extensibleDataLength = Math.min(
|
|
4831
|
-
|
|
4845
|
+
getBigUint64(endOfDirectoryView, 4) - (ZIP64_END_OF_CENTRAL_DIR_LENGTH - 12),
|
|
4832
4846
|
reader.size - directoryDataOffset - ZIP64_END_OF_CENTRAL_DIR_LENGTH);
|
|
4833
4847
|
if (extensibleDataLength > 0) {
|
|
4834
4848
|
zip64EndOfDirectoryLength += extensibleDataLength;
|
|
@@ -5061,8 +5075,15 @@ class ZipReader {
|
|
|
5061
5075
|
yield entry;
|
|
5062
5076
|
}
|
|
5063
5077
|
let offsetAfterSignature = offset;
|
|
5064
|
-
|
|
5078
|
+
let digitalSignature = readDigitalSignature(directoryArray.subarray(offset)) ||
|
|
5065
5079
|
(decryptedDirectory ? readDigitalSignature(dataAfterEncryptedDirectory) : UNDEFINED_VALUE);
|
|
5080
|
+
if (!digitalSignature && !decryptedDirectory) {
|
|
5081
|
+
const signatureRecordOffset = directoryDataOffset + offset;
|
|
5082
|
+
const signatureRecordLength = Math.min(centralDirectoryEndOffset - signatureRecordOffset, 6 + MAX_16_BITS);
|
|
5083
|
+
if (signatureRecordLength >= 6) {
|
|
5084
|
+
digitalSignature = readDigitalSignature(await readUint8Array(reader, signatureRecordOffset, signatureRecordLength));
|
|
5085
|
+
}
|
|
5086
|
+
}
|
|
5066
5087
|
if (digitalSignature) {
|
|
5067
5088
|
zipReader.digitalSignature = digitalSignature;
|
|
5068
5089
|
offsetAfterSignature = offset + 6 + digitalSignature.length;
|
|
@@ -5402,8 +5423,8 @@ function getDirectoryEncryptionInfo(rawExtensibleData) {
|
|
|
5402
5423
|
const hashDataLength = getUint16$1(extensibleDataView, 26);
|
|
5403
5424
|
Object.assign(directoryEncryptionInfo, {
|
|
5404
5425
|
compressionMethod: getUint16$1(extensibleDataView, 0),
|
|
5405
|
-
compressedSize:
|
|
5406
|
-
uncompressedSize:
|
|
5426
|
+
compressedSize: getBigUint64(extensibleDataView, 2),
|
|
5427
|
+
uncompressedSize: getBigUint64(extensibleDataView, 10),
|
|
5407
5428
|
encryptionAlgorithm: getUint16$1(extensibleDataView, 18),
|
|
5408
5429
|
bitLength: getUint16$1(extensibleDataView, 20),
|
|
5409
5430
|
flags: getUint16$1(extensibleDataView, 22),
|
|
@@ -6038,7 +6059,11 @@ function getUint32$1(view, offset) {
|
|
|
6038
6059
|
}
|
|
6039
6060
|
|
|
6040
6061
|
function getBigUint64(view, offset) {
|
|
6041
|
-
|
|
6062
|
+
const value = view.getBigUint64(offset, true);
|
|
6063
|
+
if (value > MAX_SAFE_UINT64) {
|
|
6064
|
+
throw new Error(ERR_UNSUPPORTED_UINT64);
|
|
6065
|
+
}
|
|
6066
|
+
return Number(value);
|
|
6042
6067
|
}
|
|
6043
6068
|
|
|
6044
6069
|
var zipReader = /*#__PURE__*/Object.freeze({
|
|
@@ -6067,6 +6092,7 @@ var zipReader = /*#__PURE__*/Object.freeze({
|
|
|
6067
6092
|
ERR_UNSAFE_FILENAME: ERR_UNSAFE_FILENAME,
|
|
6068
6093
|
ERR_UNSUPPORTED_COMPRESSION: ERR_UNSUPPORTED_COMPRESSION$1,
|
|
6069
6094
|
ERR_UNSUPPORTED_ENCRYPTION: ERR_UNSUPPORTED_ENCRYPTION,
|
|
6095
|
+
ERR_UNSUPPORTED_UINT64: ERR_UNSUPPORTED_UINT64,
|
|
6070
6096
|
ERR_WORKER_STARTUP_TIMEOUT: ERR_WORKER_STARTUP_TIMEOUT,
|
|
6071
6097
|
ZipReader: ZipReader,
|
|
6072
6098
|
ZipReaderStream: ZipReaderStream
|
|
@@ -6139,6 +6165,8 @@ const ERR_INVALID_SIGNATURE_DATA = "Signature data exceeds 64KB";
|
|
|
6139
6165
|
|
|
6140
6166
|
const EXTRAFIELD_DATA_AES = new Uint8Array([0x07, 0x00, 0x02, 0x00, 0x41, 0x45, 0x03, 0x00, 0x00]);
|
|
6141
6167
|
const EXTRAFIELD_OFFSET_AES_VENDOR_VERSION = 4;
|
|
6168
|
+
const EXTRAFIELD_OFFSET_AES_COMPRESSION_METHOD = 9;
|
|
6169
|
+
const EXTRAFIELD_USDZ_MAX_LENGTH = 67;
|
|
6142
6170
|
const VENDOR_VERSION_AE_1 = 1;
|
|
6143
6171
|
const INFOZIP_EXTRA_FIELD_TYPE$1 = "infozip";
|
|
6144
6172
|
const UNIX_EXTRA_FIELD_TYPE = "unix";
|
|
@@ -6185,16 +6213,14 @@ class ZipWriter {
|
|
|
6185
6213
|
await zipReader$1.close();
|
|
6186
6214
|
await initStream(this.writer);
|
|
6187
6215
|
const { directoryOffset } = zipReader$1;
|
|
6188
|
-
let splitZipSignatureLength = 0;
|
|
6189
6216
|
if (this.addSplitZipSignature) {
|
|
6190
6217
|
delete this.addSplitZipSignature;
|
|
6191
6218
|
if (!await startsWithSplitZipSignature(reader)) {
|
|
6192
6219
|
await writeData(this.writer, getSplitZipSignatureArray());
|
|
6193
|
-
|
|
6194
|
-
this.offset += splitZipSignatureLength;
|
|
6220
|
+
this.offset += SPLIT_ZIP_FILE_SIGNATURE_LENGTH;
|
|
6195
6221
|
}
|
|
6196
6222
|
}
|
|
6197
|
-
const entryPositions = await copyZipData(this, reader, entries, directoryOffset
|
|
6223
|
+
const entryPositions = await copyZipData(this, reader, entries, directoryOffset);
|
|
6198
6224
|
this.filenames = new Set(entries.map(entry => entry.filename));
|
|
6199
6225
|
this.fileEntries = new Map(entries.map(entry => {
|
|
6200
6226
|
const {
|
|
@@ -6207,7 +6233,7 @@ class ZipWriter {
|
|
|
6207
6233
|
encrypted,
|
|
6208
6234
|
uncompressedSize,
|
|
6209
6235
|
compressedSize,
|
|
6210
|
-
|
|
6236
|
+
extraFieldZip64
|
|
6211
6237
|
} = entry;
|
|
6212
6238
|
let {
|
|
6213
6239
|
compressionMethod,
|
|
@@ -6224,13 +6250,13 @@ class ZipWriter {
|
|
|
6224
6250
|
rawExtraFieldExtendedTimestamp = rawExtraFieldExtendedTimestamp || EMPTY_UINT8_ARRAY;
|
|
6225
6251
|
rawExtraFieldNTFS = rawExtraFieldNTFS || EMPTY_UINT8_ARRAY;
|
|
6226
6252
|
rawExtraFieldUnix = rawExtraFieldUnix || EMPTY_UINT8_ARRAY;
|
|
6227
|
-
rawExtraField = rawExtraField || EMPTY_UINT8_ARRAY;
|
|
6253
|
+
rawExtraField = removeExtraFieldZip64(rawExtraField || EMPTY_UINT8_ARRAY);
|
|
6228
6254
|
if (entry.extraFieldAES) {
|
|
6229
6255
|
compressionMethod = COMPRESSION_METHOD_AES;
|
|
6230
6256
|
}
|
|
6231
6257
|
const extraFieldLength = getLength(rawExtraFieldZip64, rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS, rawExtraFieldUnix, rawExtraField);
|
|
6232
|
-
const zip64UncompressedSize =
|
|
6233
|
-
const zip64CompressedSize =
|
|
6258
|
+
const zip64UncompressedSize = Boolean(extraFieldZip64) && extraFieldZip64.uncompressedSize !== UNDEFINED_VALUE;
|
|
6259
|
+
const zip64CompressedSize = Boolean(extraFieldZip64) && extraFieldZip64.compressedSize !== UNDEFINED_VALUE;
|
|
6234
6260
|
const bitFlagValue = (getBitFlag(level, languageEncodingFlag, dataDescriptor, encrypted, compressionMethod) & ~BITFLAG_LEVEL) | (level << 1);
|
|
6235
6261
|
const {
|
|
6236
6262
|
headerArray,
|
|
@@ -6436,7 +6462,8 @@ async function addFile(zipWriter, name, reader, options) {
|
|
|
6436
6462
|
signature: options[PROPERTY_NAME_SIGNATURE],
|
|
6437
6463
|
crc32: options.crc32 === UNDEFINED_VALUE ? options[PROPERTY_NAME_SIGNATURE] : options.crc32,
|
|
6438
6464
|
offset: zipWriter.offset - diskOffset,
|
|
6439
|
-
diskNumberStart: diskNumber
|
|
6465
|
+
diskNumberStart: diskNumber,
|
|
6466
|
+
[OPTION_USDZ]: zipWriter.options[OPTION_USDZ]
|
|
6440
6467
|
});
|
|
6441
6468
|
const headerInfo = getHeaderInfo(options);
|
|
6442
6469
|
const dataDescriptorInfo = getDataDescriptorInfo(options);
|
|
@@ -6468,15 +6495,9 @@ function resolveAttributes(zipWriter, name, options) {
|
|
|
6468
6495
|
let setuid = getOptionValue(zipWriter, options, PROPERTY_NAME_SETUID);
|
|
6469
6496
|
let setgid = getOptionValue(zipWriter, options, PROPERTY_NAME_SETGID);
|
|
6470
6497
|
let sticky = getOptionValue(zipWriter, options, PROPERTY_NAME_STICKY);
|
|
6471
|
-
|
|
6472
|
-
|
|
6473
|
-
|
|
6474
|
-
if (gid !== UNDEFINED_VALUE && (!Number.isInteger(gid) || gid < 0 || gid > MAX_32_BITS)) {
|
|
6475
|
-
throw new Error(ERR_INVALID_GID);
|
|
6476
|
-
}
|
|
6477
|
-
if (unixMode !== UNDEFINED_VALUE && (!Number.isInteger(unixMode) || unixMode < 0 || unixMode > MAX_16_BITS)) {
|
|
6478
|
-
throw new Error(ERR_INVALID_UNIX_MODE);
|
|
6479
|
-
}
|
|
6498
|
+
checkIntegerOption(uid, MAX_32_BITS, ERR_INVALID_UID);
|
|
6499
|
+
checkIntegerOption(gid, MAX_32_BITS, ERR_INVALID_GID);
|
|
6500
|
+
checkIntegerOption(unixMode, MAX_16_BITS, ERR_INVALID_UNIX_MODE);
|
|
6480
6501
|
if (unixExtraFieldType !== UNDEFINED_VALUE && unixExtraFieldType !== INFOZIP_EXTRA_FIELD_TYPE$1 && unixExtraFieldType !== UNIX_EXTRA_FIELD_TYPE) {
|
|
6481
6502
|
throw new Error(ERR_INVALID_UNIX_EXTRA_FIELD_TYPE);
|
|
6482
6503
|
}
|
|
@@ -6498,9 +6519,7 @@ function resolveAttributes(zipWriter, name, options) {
|
|
|
6498
6519
|
msDosCompatible = true;
|
|
6499
6520
|
versionMadeBy = (versionMadeBy & MAX_8_BITS);
|
|
6500
6521
|
}
|
|
6501
|
-
|
|
6502
|
-
throw new Error(ERR_INVALID_MSDOS_ATTRIBUTES);
|
|
6503
|
-
}
|
|
6522
|
+
checkIntegerOption(msdosAttributesRaw, MAX_8_BITS, ERR_INVALID_MSDOS_ATTRIBUTES);
|
|
6504
6523
|
if (msdosAttributes && (typeof msdosAttributes !== OBJECT_TYPE || Array.isArray(msdosAttributes))) {
|
|
6505
6524
|
throw new Error(ERR_INVALID_MSDOS_DATA);
|
|
6506
6525
|
}
|
|
@@ -6640,9 +6659,7 @@ function resolveMetadata(zipWriter, name, options) {
|
|
|
6640
6659
|
throw new Error(ERR_UNSUPPORTED_COMPRESSION);
|
|
6641
6660
|
}
|
|
6642
6661
|
let level = getNumberOptionValue(zipWriter, options, OPTION_LEVEL);
|
|
6643
|
-
|
|
6644
|
-
throw new Error(ERR_INVALID_LEVEL);
|
|
6645
|
-
}
|
|
6662
|
+
checkIntegerOption(level, MAX_LEVEL, ERR_INVALID_LEVEL);
|
|
6646
6663
|
if (zipWriter.options[OPTION_USDZ]) {
|
|
6647
6664
|
if (password !== UNDEFINED_VALUE || rawPassword !== UNDEFINED_VALUE) {
|
|
6648
6665
|
throw new Error(ERR_UNSUPPORTED_ENCRYPTION_USDZ);
|
|
@@ -6720,9 +6737,7 @@ function serializeExtraField(extraField) {
|
|
|
6720
6737
|
let extraFieldSize = 0;
|
|
6721
6738
|
let offset = 0;
|
|
6722
6739
|
extraField.forEach((data, type) => {
|
|
6723
|
-
|
|
6724
|
-
throw new Error(ERR_INVALID_EXTRAFIELD_TYPE);
|
|
6725
|
-
}
|
|
6740
|
+
checkInteger(type, MAX_16_BITS, ERR_INVALID_EXTRAFIELD_TYPE);
|
|
6726
6741
|
if (!(data instanceof Uint8Array)) {
|
|
6727
6742
|
throw new Error(ERR_INVALID_EXTRAFIELD_DATA_TYPE);
|
|
6728
6743
|
}
|
|
@@ -6797,6 +6812,10 @@ function resolveEntrySizes(zipWriter, hasContent, contentSize, metadata, options
|
|
|
6797
6812
|
maximumCompressedSize = contentSize === UNDEFINED_VALUE ? getMaximumCompressedSize(uncompressedSize) + encryptionOverhead : contentSize;
|
|
6798
6813
|
}
|
|
6799
6814
|
}
|
|
6815
|
+
const emptyEntry = !encryptedEntry && (!hasContent || (contentSize === 0 && !passThrough)) && !isCompressed(compressionMethod, level);
|
|
6816
|
+
if (emptyEntry && !zipCrypto && getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR) === UNDEFINED_VALUE) {
|
|
6817
|
+
dataDescriptor = false;
|
|
6818
|
+
}
|
|
6800
6819
|
const zip64UncompressedSize = zip64Enabled || uncompressedSize >= MAX_32_BITS;
|
|
6801
6820
|
const zip64CompressedSize = zip64Enabled || maximumCompressedSize >= MAX_32_BITS;
|
|
6802
6821
|
if (zip64UncompressedSize || zip64CompressedSize) {
|
|
@@ -6811,6 +6830,7 @@ function resolveEntrySizes(zipWriter, hasContent, contentSize, metadata, options
|
|
|
6811
6830
|
maximumCompressedSize,
|
|
6812
6831
|
resolvedOptions: {
|
|
6813
6832
|
dataDescriptor,
|
|
6833
|
+
emptyEntry,
|
|
6814
6834
|
zip64,
|
|
6815
6835
|
zip64UncompressedSize,
|
|
6816
6836
|
zip64CompressedSize,
|
|
@@ -6837,7 +6857,9 @@ async function getEntriesSize(writerOptions, entries, writeOrderGuaranteed, comm
|
|
|
6837
6857
|
const usdz = writerOptions[OPTION_USDZ];
|
|
6838
6858
|
const files = new Map();
|
|
6839
6859
|
let layoutDependsOnWriteOrder = Boolean(usdz);
|
|
6840
|
-
|
|
6860
|
+
const initialOffset = writerOptions[OPTION_OFFSET] === UNDEFINED_VALUE ? 0 : writerOptions[OPTION_OFFSET];
|
|
6861
|
+
let offset = initialOffset;
|
|
6862
|
+
let minimumEntrySize = INFINITY_VALUE;
|
|
6841
6863
|
for (const entry of entries) {
|
|
6842
6864
|
let { name } = entry;
|
|
6843
6865
|
const { size } = entry;
|
|
@@ -6861,7 +6883,7 @@ async function getEntriesSize(writerOptions, entries, writeOrderGuaranteed, comm
|
|
|
6861
6883
|
if (hasContent && !metadata.passThrough && isCompressed(sizes.compressionMethod, sizes.level)) {
|
|
6862
6884
|
throw new Error(ERR_UNDETERMINED_SIZE);
|
|
6863
6885
|
}
|
|
6864
|
-
const entryOptions = Object.assign({}, options, attributesInfo.resolvedOptions, metadata, sizes);
|
|
6886
|
+
const entryOptions = Object.assign({}, options, attributesInfo.resolvedOptions, metadata, sizes, { [OPTION_USDZ]: usdz });
|
|
6865
6887
|
const headerInfo = getHeaderInfo(entryOptions);
|
|
6866
6888
|
const dataDescriptorInfo = getDataDescriptorInfo(entryOptions);
|
|
6867
6889
|
const entryInfo = {
|
|
@@ -6872,15 +6894,17 @@ async function getEntriesSize(writerOptions, entries, writeOrderGuaranteed, comm
|
|
|
6872
6894
|
appendExtraFieldUSDZ(entryInfo, offset);
|
|
6873
6895
|
}
|
|
6874
6896
|
const compressedSize = hasContent ? maximumCompressedSize : 0;
|
|
6875
|
-
if (offset >= MAX_32_BITS) {
|
|
6876
|
-
layoutDependsOnWriteOrder = true;
|
|
6877
|
-
}
|
|
6878
6897
|
files.set(name, Object.assign({}, entryOptions, headerInfo, {
|
|
6879
6898
|
offset,
|
|
6880
6899
|
diskNumberStart: 0,
|
|
6881
6900
|
compressedSize
|
|
6882
6901
|
}));
|
|
6883
|
-
|
|
6902
|
+
const entrySize = entryInfo.metadataSize + compressedSize;
|
|
6903
|
+
minimumEntrySize = Math.min(minimumEntrySize, entrySize);
|
|
6904
|
+
offset += entrySize;
|
|
6905
|
+
}
|
|
6906
|
+
if (files.size && offset - minimumEntrySize >= MAX_32_BITS) {
|
|
6907
|
+
layoutDependsOnWriteOrder = true;
|
|
6884
6908
|
}
|
|
6885
6909
|
if (layoutDependsOnWriteOrder && !writeOrderGuaranteed) {
|
|
6886
6910
|
throw new Error(ERR_UNDETERMINED_SIZE);
|
|
@@ -6894,7 +6918,7 @@ async function getEntriesSize(writerOptions, entries, writeOrderGuaranteed, comm
|
|
|
6894
6918
|
zip64 = true;
|
|
6895
6919
|
}
|
|
6896
6920
|
}
|
|
6897
|
-
return offset + directoryDataLength + commentLength + (zip64 ? ZIP64_END_OF_CENTRAL_DIR_TOTAL_LENGTH : END_OF_CENTRAL_DIR_LENGTH);
|
|
6921
|
+
return offset - initialOffset + directoryDataLength + commentLength + (zip64 ? ZIP64_END_OF_CENTRAL_DIR_TOTAL_LENGTH : END_OF_CENTRAL_DIR_LENGTH);
|
|
6898
6922
|
}
|
|
6899
6923
|
|
|
6900
6924
|
async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
|
|
@@ -6905,6 +6929,7 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
|
|
|
6905
6929
|
const {
|
|
6906
6930
|
keepOrder,
|
|
6907
6931
|
dataDescriptor,
|
|
6932
|
+
emptyEntry,
|
|
6908
6933
|
signal
|
|
6909
6934
|
} = options;
|
|
6910
6935
|
const {
|
|
@@ -6929,7 +6954,7 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
|
|
|
6929
6954
|
lockPreviousFileEntry = previousFileEntry && previousFileEntry.lockFileEntry;
|
|
6930
6955
|
requestLockCurrentFileEntry();
|
|
6931
6956
|
}
|
|
6932
|
-
if (options.bufferedWrite || !keepOrder || zipWriter.writerLocked || zipWriter.bufferedWrites || !dataDescriptor) {
|
|
6957
|
+
if (options.bufferedWrite || !keepOrder || zipWriter.writerLocked || zipWriter.bufferedWrites || (!dataDescriptor && !emptyEntry)) {
|
|
6933
6958
|
bufferedWrite = true;
|
|
6934
6959
|
zipWriter.bufferedWrites++;
|
|
6935
6960
|
if (options.createTempStream) {
|
|
@@ -7351,8 +7376,8 @@ function getHeaderInfo(options) {
|
|
|
7351
7376
|
try {
|
|
7352
7377
|
const { uid, gid, unixExtraFieldType } = options;
|
|
7353
7378
|
if (unixExtraFieldType == INFOZIP_EXTRA_FIELD_TYPE$1 && (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE)) {
|
|
7354
|
-
const uidBytes = packUnixId(uid);
|
|
7355
|
-
const gidBytes = packUnixId(gid);
|
|
7379
|
+
const uidBytes = packUnixId(uid === UNDEFINED_VALUE ? 0 : uid);
|
|
7380
|
+
const gidBytes = packUnixId(gid === UNDEFINED_VALUE ? 0 : gid);
|
|
7356
7381
|
const payloadLength = 3 + uidBytes.length + gidBytes.length;
|
|
7357
7382
|
const extraFieldUnix = createRecordWriter(4 + payloadLength);
|
|
7358
7383
|
extraFieldUnix.writeUint16(EXTRAFIELD_TYPE_INFOZIP);
|
|
@@ -7391,12 +7416,13 @@ function getHeaderInfo(options) {
|
|
|
7391
7416
|
if (passThrough && crc32 !== UNDEFINED_VALUE) {
|
|
7392
7417
|
rawExtraFieldAES[EXTRAFIELD_OFFSET_AES_VENDOR_VERSION] = VENDOR_VERSION_AE_1;
|
|
7393
7418
|
}
|
|
7394
|
-
rawExtraFieldAES
|
|
7419
|
+
setUint16(getDataView(rawExtraFieldAES), EXTRAFIELD_OFFSET_AES_COMPRESSION_METHOD, compressionMethod);
|
|
7395
7420
|
compressionMethod = COMPRESSION_METHOD_AES;
|
|
7396
7421
|
}
|
|
7397
7422
|
const localExtraFieldZip64Length = writeLocalExtraFieldZip64 ? getLength(rawLocalExtraFieldZip64) : 0;
|
|
7398
7423
|
const extraFieldLength = localExtraFieldZip64Length + getLength(rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS, rawExtraFieldUnix, rawExtraField, rawLocalExtraField);
|
|
7399
|
-
|
|
7424
|
+
const maximumUsdzExtraFieldLength = options[OPTION_USDZ] ? EXTRAFIELD_USDZ_MAX_LENGTH : 0;
|
|
7425
|
+
if (extraFieldLength + maximumUsdzExtraFieldLength > MAX_16_BITS) {
|
|
7400
7426
|
throw new Error(ERR_INVALID_EXTRAFIELD_DATA);
|
|
7401
7427
|
}
|
|
7402
7428
|
const dosLastModDate = new Date(Math.ceil(Math.floor(lastModDate.getTime() / 1000) / 2) * 2000);
|
|
@@ -7482,18 +7508,14 @@ function appendExtraFieldUSDZ(entryInfo, zipWriterOffset) {
|
|
|
7482
7508
|
}
|
|
7483
7509
|
|
|
7484
7510
|
function packUnixId(id) {
|
|
7485
|
-
|
|
7486
|
-
|
|
7487
|
-
|
|
7488
|
-
|
|
7489
|
-
|
|
7490
|
-
|
|
7491
|
-
let length = 4;
|
|
7492
|
-
while (length > 1 && dataArray[length - 1] === 0) {
|
|
7493
|
-
length--;
|
|
7494
|
-
}
|
|
7495
|
-
return dataArray.subarray(0, length);
|
|
7511
|
+
const dataArray = new Uint8Array(4);
|
|
7512
|
+
const dataView = getDataView(dataArray);
|
|
7513
|
+
dataView.setUint32(0, id, true);
|
|
7514
|
+
let length = 4;
|
|
7515
|
+
while (length > 1 && dataArray[length - 1] === 0) {
|
|
7516
|
+
length--;
|
|
7496
7517
|
}
|
|
7518
|
+
return dataArray.subarray(0, length);
|
|
7497
7519
|
}
|
|
7498
7520
|
|
|
7499
7521
|
function normalizeMsdosAttributes(msdosAttributesRaw, msdosAttributes) {
|
|
@@ -7797,7 +7819,11 @@ async function writeDigitalSignatureRecord(zipWriter, directoryArray, options) {
|
|
|
7797
7819
|
signatureRecord.writeUint32(DIGITAL_SIGNATURE_RECORD_SIGNATURE);
|
|
7798
7820
|
signatureRecord.writeUint16(signatureDataLength);
|
|
7799
7821
|
signatureRecord.writeBytes(signatureData);
|
|
7800
|
-
|
|
7822
|
+
const { writer } = zipWriter;
|
|
7823
|
+
if (exceedsAvailableSize(writer, getLength(signatureRecord.array))) {
|
|
7824
|
+
await writer.closeDisk();
|
|
7825
|
+
}
|
|
7826
|
+
await writeData(writer, signatureRecord.array);
|
|
7801
7827
|
return 6 + signatureDataLength;
|
|
7802
7828
|
}
|
|
7803
7829
|
return 0;
|
|
@@ -7908,7 +7934,22 @@ async function startsWithSplitZipSignature(reader) {
|
|
|
7908
7934
|
return getUint32(getDataView(signatureArray), 0) == SPLIT_ZIP_FILE_SIGNATURE;
|
|
7909
7935
|
}
|
|
7910
7936
|
|
|
7911
|
-
|
|
7937
|
+
function removeExtraFieldZip64(rawExtraField) {
|
|
7938
|
+
const rawExtraFieldView = getDataView(rawExtraField);
|
|
7939
|
+
let offsetExtraField = 0;
|
|
7940
|
+
while (offsetExtraField + 4 <= getLength(rawExtraField)) {
|
|
7941
|
+
const size = 4 + getUint16(rawExtraFieldView, offsetExtraField + 2);
|
|
7942
|
+
if (getUint16(rawExtraFieldView, offsetExtraField) == EXTRAFIELD_TYPE_ZIP64) {
|
|
7943
|
+
return removeExtraFieldZip64(concat(
|
|
7944
|
+
rawExtraField.subarray(0, offsetExtraField),
|
|
7945
|
+
rawExtraField.subarray(Math.min(offsetExtraField + size, getLength(rawExtraField)))));
|
|
7946
|
+
}
|
|
7947
|
+
offsetExtraField += size;
|
|
7948
|
+
}
|
|
7949
|
+
return rawExtraField;
|
|
7950
|
+
}
|
|
7951
|
+
|
|
7952
|
+
async function copyZipData(zipWriter, reader, entries, directoryOffset) {
|
|
7912
7953
|
const { writer } = zipWriter;
|
|
7913
7954
|
const entryPositions = new Map();
|
|
7914
7955
|
if (writer.closeDisk) {
|
|
@@ -7929,9 +7970,10 @@ async function copyZipData(zipWriter, reader, entries, directoryOffset, splitZip
|
|
|
7929
7970
|
}
|
|
7930
7971
|
await copyData(zipWriter, reader, copiedLength, directoryOffset - copiedLength);
|
|
7931
7972
|
} else {
|
|
7973
|
+
const baseOffset = zipWriter.offset;
|
|
7932
7974
|
await copyData(zipWriter, reader, 0, directoryOffset);
|
|
7933
7975
|
entries.forEach(entry => entryPositions.set(entry, {
|
|
7934
|
-
offset:
|
|
7976
|
+
offset: baseOffset + getSourceOffset(reader, entry),
|
|
7935
7977
|
diskNumberStart: 0
|
|
7936
7978
|
}));
|
|
7937
7979
|
}
|
|
@@ -9474,7 +9516,7 @@ function keepsContentType(writer, data) {
|
|
|
9474
9516
|
} else if (writer.constructor == BlobWriter) {
|
|
9475
9517
|
return data.type == contentType;
|
|
9476
9518
|
} else if (writer.constructor == Data64URIWriter) {
|
|
9477
|
-
return data.startsWith(
|
|
9519
|
+
return data.startsWith("data:" + (contentType || "") + ";base64,");
|
|
9478
9520
|
} else {
|
|
9479
9521
|
return true;
|
|
9480
9522
|
}
|
|
@@ -10147,6 +10189,7 @@ exports.ERR_UNSUPPORTED_ENCRYPTION = ERR_UNSUPPORTED_ENCRYPTION;
|
|
|
10147
10189
|
exports.ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH = ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH;
|
|
10148
10190
|
exports.ERR_UNSUPPORTED_ENCRYPTION_USDZ = ERR_UNSUPPORTED_ENCRYPTION_USDZ;
|
|
10149
10191
|
exports.ERR_UNSUPPORTED_FORMAT = ERR_UNSUPPORTED_FORMAT;
|
|
10192
|
+
exports.ERR_UNSUPPORTED_UINT64 = ERR_UNSUPPORTED_UINT64;
|
|
10150
10193
|
exports.ERR_WORKER_STARTUP_TIMEOUT = ERR_WORKER_STARTUP_TIMEOUT;
|
|
10151
10194
|
exports.ERR_WRITER_NOT_INITIALIZED = ERR_WRITER_NOT_INITIALIZED;
|
|
10152
10195
|
exports.ERR_ZIP_NOT_EMPTY = ERR_ZIP_NOT_EMPTY;
|