@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/dist/zip-fs.js
CHANGED
|
@@ -235,6 +235,18 @@
|
|
|
235
235
|
}
|
|
236
236
|
}
|
|
237
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
|
+
|
|
238
250
|
function toNumber(value) {
|
|
239
251
|
return typeof value == STRING_TYPE && value.trim() ? Number(value) : value;
|
|
240
252
|
}
|
|
@@ -4721,6 +4733,7 @@
|
|
|
4721
4733
|
const ERR_INVALID_STRICTNESS = "Invalid strictness (must be 'strict', 'balanced' or 'tolerant')";
|
|
4722
4734
|
const ERR_INVALID_FILENAME_VALIDATION = "Invalid filenameValidation (must be 'strict', 'balanced' or 'tolerant')";
|
|
4723
4735
|
const ERR_INVALID_MAX_APPENDED_DATA_SIZE = "Invalid maxAppendedDataSize (must be a number greater than or equal to 0)";
|
|
4736
|
+
const ERR_UNSUPPORTED_UINT64 = "64-bit value exceeds Number.MAX_SAFE_INTEGER";
|
|
4724
4737
|
const DRIVE_LETTER_REGEXP = /^[a-zA-Z]:/;
|
|
4725
4738
|
const CHARSET_UTF8 = "utf-8";
|
|
4726
4739
|
const PROPERTY_NAME_UTF8_SUFFIX = "UTF8";
|
|
@@ -4743,6 +4756,7 @@
|
|
|
4743
4756
|
bytes: 8
|
|
4744
4757
|
}
|
|
4745
4758
|
};
|
|
4759
|
+
const MAX_SAFE_UINT64 = BigInt(Number.MAX_SAFE_INTEGER);
|
|
4746
4760
|
const MAX_END_OF_CENTRAL_DIR_PROBES = 64;
|
|
4747
4761
|
const MAX_DEFLATE_EXPANSION_RATIO = 1032;
|
|
4748
4762
|
const CENTRAL_DIRECTORY_UNREACHABLE = 0;
|
|
@@ -4838,7 +4852,7 @@
|
|
|
4838
4852
|
zip64EndOfDirectoryVersion2 = getBigUint64(endOfDirectoryView, 4) > ZIP64_END_OF_CENTRAL_DIR_LENGTH - 12;
|
|
4839
4853
|
if (zip64EndOfDirectoryVersion2) {
|
|
4840
4854
|
const extensibleDataLength = Math.min(
|
|
4841
|
-
|
|
4855
|
+
getBigUint64(endOfDirectoryView, 4) - (ZIP64_END_OF_CENTRAL_DIR_LENGTH - 12),
|
|
4842
4856
|
reader.size - directoryDataOffset - ZIP64_END_OF_CENTRAL_DIR_LENGTH);
|
|
4843
4857
|
if (extensibleDataLength > 0) {
|
|
4844
4858
|
zip64EndOfDirectoryLength += extensibleDataLength;
|
|
@@ -5071,8 +5085,15 @@
|
|
|
5071
5085
|
yield entry;
|
|
5072
5086
|
}
|
|
5073
5087
|
let offsetAfterSignature = offset;
|
|
5074
|
-
|
|
5088
|
+
let digitalSignature = readDigitalSignature(directoryArray.subarray(offset)) ||
|
|
5075
5089
|
(decryptedDirectory ? readDigitalSignature(dataAfterEncryptedDirectory) : UNDEFINED_VALUE);
|
|
5090
|
+
if (!digitalSignature && !decryptedDirectory) {
|
|
5091
|
+
const signatureRecordOffset = directoryDataOffset + offset;
|
|
5092
|
+
const signatureRecordLength = Math.min(centralDirectoryEndOffset - signatureRecordOffset, 6 + MAX_16_BITS);
|
|
5093
|
+
if (signatureRecordLength >= 6) {
|
|
5094
|
+
digitalSignature = readDigitalSignature(await readUint8Array(reader, signatureRecordOffset, signatureRecordLength));
|
|
5095
|
+
}
|
|
5096
|
+
}
|
|
5076
5097
|
if (digitalSignature) {
|
|
5077
5098
|
zipReader.digitalSignature = digitalSignature;
|
|
5078
5099
|
offsetAfterSignature = offset + 6 + digitalSignature.length;
|
|
@@ -5412,8 +5433,8 @@
|
|
|
5412
5433
|
const hashDataLength = getUint16$1(extensibleDataView, 26);
|
|
5413
5434
|
Object.assign(directoryEncryptionInfo, {
|
|
5414
5435
|
compressionMethod: getUint16$1(extensibleDataView, 0),
|
|
5415
|
-
compressedSize:
|
|
5416
|
-
uncompressedSize:
|
|
5436
|
+
compressedSize: getBigUint64(extensibleDataView, 2),
|
|
5437
|
+
uncompressedSize: getBigUint64(extensibleDataView, 10),
|
|
5417
5438
|
encryptionAlgorithm: getUint16$1(extensibleDataView, 18),
|
|
5418
5439
|
bitLength: getUint16$1(extensibleDataView, 20),
|
|
5419
5440
|
flags: getUint16$1(extensibleDataView, 22),
|
|
@@ -6048,7 +6069,11 @@
|
|
|
6048
6069
|
}
|
|
6049
6070
|
|
|
6050
6071
|
function getBigUint64(view, offset) {
|
|
6051
|
-
|
|
6072
|
+
const value = view.getBigUint64(offset, true);
|
|
6073
|
+
if (value > MAX_SAFE_UINT64) {
|
|
6074
|
+
throw new Error(ERR_UNSUPPORTED_UINT64);
|
|
6075
|
+
}
|
|
6076
|
+
return Number(value);
|
|
6052
6077
|
}
|
|
6053
6078
|
|
|
6054
6079
|
var zipReader = /*#__PURE__*/Object.freeze({
|
|
@@ -6077,6 +6102,7 @@
|
|
|
6077
6102
|
ERR_UNSAFE_FILENAME: ERR_UNSAFE_FILENAME,
|
|
6078
6103
|
ERR_UNSUPPORTED_COMPRESSION: ERR_UNSUPPORTED_COMPRESSION$1,
|
|
6079
6104
|
ERR_UNSUPPORTED_ENCRYPTION: ERR_UNSUPPORTED_ENCRYPTION,
|
|
6105
|
+
ERR_UNSUPPORTED_UINT64: ERR_UNSUPPORTED_UINT64,
|
|
6080
6106
|
ERR_WORKER_STARTUP_TIMEOUT: ERR_WORKER_STARTUP_TIMEOUT,
|
|
6081
6107
|
ZipReader: ZipReader,
|
|
6082
6108
|
ZipReaderStream: ZipReaderStream
|
|
@@ -6149,6 +6175,8 @@
|
|
|
6149
6175
|
|
|
6150
6176
|
const EXTRAFIELD_DATA_AES = new Uint8Array([0x07, 0x00, 0x02, 0x00, 0x41, 0x45, 0x03, 0x00, 0x00]);
|
|
6151
6177
|
const EXTRAFIELD_OFFSET_AES_VENDOR_VERSION = 4;
|
|
6178
|
+
const EXTRAFIELD_OFFSET_AES_COMPRESSION_METHOD = 9;
|
|
6179
|
+
const EXTRAFIELD_USDZ_MAX_LENGTH = 67;
|
|
6152
6180
|
const VENDOR_VERSION_AE_1 = 1;
|
|
6153
6181
|
const INFOZIP_EXTRA_FIELD_TYPE$1 = "infozip";
|
|
6154
6182
|
const UNIX_EXTRA_FIELD_TYPE = "unix";
|
|
@@ -6195,16 +6223,14 @@
|
|
|
6195
6223
|
await zipReader$1.close();
|
|
6196
6224
|
await initStream(this.writer);
|
|
6197
6225
|
const { directoryOffset } = zipReader$1;
|
|
6198
|
-
let splitZipSignatureLength = 0;
|
|
6199
6226
|
if (this.addSplitZipSignature) {
|
|
6200
6227
|
delete this.addSplitZipSignature;
|
|
6201
6228
|
if (!await startsWithSplitZipSignature(reader)) {
|
|
6202
6229
|
await writeData(this.writer, getSplitZipSignatureArray());
|
|
6203
|
-
|
|
6204
|
-
this.offset += splitZipSignatureLength;
|
|
6230
|
+
this.offset += SPLIT_ZIP_FILE_SIGNATURE_LENGTH;
|
|
6205
6231
|
}
|
|
6206
6232
|
}
|
|
6207
|
-
const entryPositions = await copyZipData(this, reader, entries, directoryOffset
|
|
6233
|
+
const entryPositions = await copyZipData(this, reader, entries, directoryOffset);
|
|
6208
6234
|
this.filenames = new Set(entries.map(entry => entry.filename));
|
|
6209
6235
|
this.fileEntries = new Map(entries.map(entry => {
|
|
6210
6236
|
const {
|
|
@@ -6217,7 +6243,7 @@
|
|
|
6217
6243
|
encrypted,
|
|
6218
6244
|
uncompressedSize,
|
|
6219
6245
|
compressedSize,
|
|
6220
|
-
|
|
6246
|
+
extraFieldZip64
|
|
6221
6247
|
} = entry;
|
|
6222
6248
|
let {
|
|
6223
6249
|
compressionMethod,
|
|
@@ -6234,13 +6260,13 @@
|
|
|
6234
6260
|
rawExtraFieldExtendedTimestamp = rawExtraFieldExtendedTimestamp || EMPTY_UINT8_ARRAY;
|
|
6235
6261
|
rawExtraFieldNTFS = rawExtraFieldNTFS || EMPTY_UINT8_ARRAY;
|
|
6236
6262
|
rawExtraFieldUnix = rawExtraFieldUnix || EMPTY_UINT8_ARRAY;
|
|
6237
|
-
rawExtraField = rawExtraField || EMPTY_UINT8_ARRAY;
|
|
6263
|
+
rawExtraField = removeExtraFieldZip64(rawExtraField || EMPTY_UINT8_ARRAY);
|
|
6238
6264
|
if (entry.extraFieldAES) {
|
|
6239
6265
|
compressionMethod = COMPRESSION_METHOD_AES;
|
|
6240
6266
|
}
|
|
6241
6267
|
const extraFieldLength = getLength(rawExtraFieldZip64, rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS, rawExtraFieldUnix, rawExtraField);
|
|
6242
|
-
const zip64UncompressedSize =
|
|
6243
|
-
const zip64CompressedSize =
|
|
6268
|
+
const zip64UncompressedSize = Boolean(extraFieldZip64) && extraFieldZip64.uncompressedSize !== UNDEFINED_VALUE;
|
|
6269
|
+
const zip64CompressedSize = Boolean(extraFieldZip64) && extraFieldZip64.compressedSize !== UNDEFINED_VALUE;
|
|
6244
6270
|
const bitFlagValue = (getBitFlag(level, languageEncodingFlag, dataDescriptor, encrypted, compressionMethod) & ~BITFLAG_LEVEL) | (level << 1);
|
|
6245
6271
|
const {
|
|
6246
6272
|
headerArray,
|
|
@@ -6446,7 +6472,8 @@
|
|
|
6446
6472
|
signature: options[PROPERTY_NAME_SIGNATURE],
|
|
6447
6473
|
crc32: options.crc32 === UNDEFINED_VALUE ? options[PROPERTY_NAME_SIGNATURE] : options.crc32,
|
|
6448
6474
|
offset: zipWriter.offset - diskOffset,
|
|
6449
|
-
diskNumberStart: diskNumber
|
|
6475
|
+
diskNumberStart: diskNumber,
|
|
6476
|
+
[OPTION_USDZ]: zipWriter.options[OPTION_USDZ]
|
|
6450
6477
|
});
|
|
6451
6478
|
const headerInfo = getHeaderInfo(options);
|
|
6452
6479
|
const dataDescriptorInfo = getDataDescriptorInfo(options);
|
|
@@ -6478,15 +6505,9 @@
|
|
|
6478
6505
|
let setuid = getOptionValue(zipWriter, options, PROPERTY_NAME_SETUID);
|
|
6479
6506
|
let setgid = getOptionValue(zipWriter, options, PROPERTY_NAME_SETGID);
|
|
6480
6507
|
let sticky = getOptionValue(zipWriter, options, PROPERTY_NAME_STICKY);
|
|
6481
|
-
|
|
6482
|
-
|
|
6483
|
-
|
|
6484
|
-
if (gid !== UNDEFINED_VALUE && (!Number.isInteger(gid) || gid < 0 || gid > MAX_32_BITS)) {
|
|
6485
|
-
throw new Error(ERR_INVALID_GID);
|
|
6486
|
-
}
|
|
6487
|
-
if (unixMode !== UNDEFINED_VALUE && (!Number.isInteger(unixMode) || unixMode < 0 || unixMode > MAX_16_BITS)) {
|
|
6488
|
-
throw new Error(ERR_INVALID_UNIX_MODE);
|
|
6489
|
-
}
|
|
6508
|
+
checkIntegerOption(uid, MAX_32_BITS, ERR_INVALID_UID);
|
|
6509
|
+
checkIntegerOption(gid, MAX_32_BITS, ERR_INVALID_GID);
|
|
6510
|
+
checkIntegerOption(unixMode, MAX_16_BITS, ERR_INVALID_UNIX_MODE);
|
|
6490
6511
|
if (unixExtraFieldType !== UNDEFINED_VALUE && unixExtraFieldType !== INFOZIP_EXTRA_FIELD_TYPE$1 && unixExtraFieldType !== UNIX_EXTRA_FIELD_TYPE) {
|
|
6491
6512
|
throw new Error(ERR_INVALID_UNIX_EXTRA_FIELD_TYPE);
|
|
6492
6513
|
}
|
|
@@ -6508,9 +6529,7 @@
|
|
|
6508
6529
|
msDosCompatible = true;
|
|
6509
6530
|
versionMadeBy = (versionMadeBy & MAX_8_BITS);
|
|
6510
6531
|
}
|
|
6511
|
-
|
|
6512
|
-
throw new Error(ERR_INVALID_MSDOS_ATTRIBUTES);
|
|
6513
|
-
}
|
|
6532
|
+
checkIntegerOption(msdosAttributesRaw, MAX_8_BITS, ERR_INVALID_MSDOS_ATTRIBUTES);
|
|
6514
6533
|
if (msdosAttributes && (typeof msdosAttributes !== OBJECT_TYPE || Array.isArray(msdosAttributes))) {
|
|
6515
6534
|
throw new Error(ERR_INVALID_MSDOS_DATA);
|
|
6516
6535
|
}
|
|
@@ -6650,9 +6669,7 @@
|
|
|
6650
6669
|
throw new Error(ERR_UNSUPPORTED_COMPRESSION);
|
|
6651
6670
|
}
|
|
6652
6671
|
let level = getNumberOptionValue(zipWriter, options, OPTION_LEVEL);
|
|
6653
|
-
|
|
6654
|
-
throw new Error(ERR_INVALID_LEVEL);
|
|
6655
|
-
}
|
|
6672
|
+
checkIntegerOption(level, MAX_LEVEL, ERR_INVALID_LEVEL);
|
|
6656
6673
|
if (zipWriter.options[OPTION_USDZ]) {
|
|
6657
6674
|
if (password !== UNDEFINED_VALUE || rawPassword !== UNDEFINED_VALUE) {
|
|
6658
6675
|
throw new Error(ERR_UNSUPPORTED_ENCRYPTION_USDZ);
|
|
@@ -6730,9 +6747,7 @@
|
|
|
6730
6747
|
let extraFieldSize = 0;
|
|
6731
6748
|
let offset = 0;
|
|
6732
6749
|
extraField.forEach((data, type) => {
|
|
6733
|
-
|
|
6734
|
-
throw new Error(ERR_INVALID_EXTRAFIELD_TYPE);
|
|
6735
|
-
}
|
|
6750
|
+
checkInteger(type, MAX_16_BITS, ERR_INVALID_EXTRAFIELD_TYPE);
|
|
6736
6751
|
if (!(data instanceof Uint8Array)) {
|
|
6737
6752
|
throw new Error(ERR_INVALID_EXTRAFIELD_DATA_TYPE);
|
|
6738
6753
|
}
|
|
@@ -6807,6 +6822,10 @@
|
|
|
6807
6822
|
maximumCompressedSize = contentSize === UNDEFINED_VALUE ? getMaximumCompressedSize(uncompressedSize) + encryptionOverhead : contentSize;
|
|
6808
6823
|
}
|
|
6809
6824
|
}
|
|
6825
|
+
const emptyEntry = !encryptedEntry && (!hasContent || (contentSize === 0 && !passThrough)) && !isCompressed(compressionMethod, level);
|
|
6826
|
+
if (emptyEntry && !zipCrypto && getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR) === UNDEFINED_VALUE) {
|
|
6827
|
+
dataDescriptor = false;
|
|
6828
|
+
}
|
|
6810
6829
|
const zip64UncompressedSize = zip64Enabled || uncompressedSize >= MAX_32_BITS;
|
|
6811
6830
|
const zip64CompressedSize = zip64Enabled || maximumCompressedSize >= MAX_32_BITS;
|
|
6812
6831
|
if (zip64UncompressedSize || zip64CompressedSize) {
|
|
@@ -6821,6 +6840,7 @@
|
|
|
6821
6840
|
maximumCompressedSize,
|
|
6822
6841
|
resolvedOptions: {
|
|
6823
6842
|
dataDescriptor,
|
|
6843
|
+
emptyEntry,
|
|
6824
6844
|
zip64,
|
|
6825
6845
|
zip64UncompressedSize,
|
|
6826
6846
|
zip64CompressedSize,
|
|
@@ -6847,7 +6867,9 @@
|
|
|
6847
6867
|
const usdz = writerOptions[OPTION_USDZ];
|
|
6848
6868
|
const files = new Map();
|
|
6849
6869
|
let layoutDependsOnWriteOrder = Boolean(usdz);
|
|
6850
|
-
|
|
6870
|
+
const initialOffset = writerOptions[OPTION_OFFSET] === UNDEFINED_VALUE ? 0 : writerOptions[OPTION_OFFSET];
|
|
6871
|
+
let offset = initialOffset;
|
|
6872
|
+
let minimumEntrySize = INFINITY_VALUE;
|
|
6851
6873
|
for (const entry of entries) {
|
|
6852
6874
|
let { name } = entry;
|
|
6853
6875
|
const { size } = entry;
|
|
@@ -6871,7 +6893,7 @@
|
|
|
6871
6893
|
if (hasContent && !metadata.passThrough && isCompressed(sizes.compressionMethod, sizes.level)) {
|
|
6872
6894
|
throw new Error(ERR_UNDETERMINED_SIZE);
|
|
6873
6895
|
}
|
|
6874
|
-
const entryOptions = Object.assign({}, options, attributesInfo.resolvedOptions, metadata, sizes);
|
|
6896
|
+
const entryOptions = Object.assign({}, options, attributesInfo.resolvedOptions, metadata, sizes, { [OPTION_USDZ]: usdz });
|
|
6875
6897
|
const headerInfo = getHeaderInfo(entryOptions);
|
|
6876
6898
|
const dataDescriptorInfo = getDataDescriptorInfo(entryOptions);
|
|
6877
6899
|
const entryInfo = {
|
|
@@ -6882,15 +6904,17 @@
|
|
|
6882
6904
|
appendExtraFieldUSDZ(entryInfo, offset);
|
|
6883
6905
|
}
|
|
6884
6906
|
const compressedSize = hasContent ? maximumCompressedSize : 0;
|
|
6885
|
-
if (offset >= MAX_32_BITS) {
|
|
6886
|
-
layoutDependsOnWriteOrder = true;
|
|
6887
|
-
}
|
|
6888
6907
|
files.set(name, Object.assign({}, entryOptions, headerInfo, {
|
|
6889
6908
|
offset,
|
|
6890
6909
|
diskNumberStart: 0,
|
|
6891
6910
|
compressedSize
|
|
6892
6911
|
}));
|
|
6893
|
-
|
|
6912
|
+
const entrySize = entryInfo.metadataSize + compressedSize;
|
|
6913
|
+
minimumEntrySize = Math.min(minimumEntrySize, entrySize);
|
|
6914
|
+
offset += entrySize;
|
|
6915
|
+
}
|
|
6916
|
+
if (files.size && offset - minimumEntrySize >= MAX_32_BITS) {
|
|
6917
|
+
layoutDependsOnWriteOrder = true;
|
|
6894
6918
|
}
|
|
6895
6919
|
if (layoutDependsOnWriteOrder && !writeOrderGuaranteed) {
|
|
6896
6920
|
throw new Error(ERR_UNDETERMINED_SIZE);
|
|
@@ -6904,7 +6928,7 @@
|
|
|
6904
6928
|
zip64 = true;
|
|
6905
6929
|
}
|
|
6906
6930
|
}
|
|
6907
|
-
return offset + directoryDataLength + commentLength + (zip64 ? ZIP64_END_OF_CENTRAL_DIR_TOTAL_LENGTH : END_OF_CENTRAL_DIR_LENGTH);
|
|
6931
|
+
return offset - initialOffset + directoryDataLength + commentLength + (zip64 ? ZIP64_END_OF_CENTRAL_DIR_TOTAL_LENGTH : END_OF_CENTRAL_DIR_LENGTH);
|
|
6908
6932
|
}
|
|
6909
6933
|
|
|
6910
6934
|
async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
|
|
@@ -6915,6 +6939,7 @@
|
|
|
6915
6939
|
const {
|
|
6916
6940
|
keepOrder,
|
|
6917
6941
|
dataDescriptor,
|
|
6942
|
+
emptyEntry,
|
|
6918
6943
|
signal
|
|
6919
6944
|
} = options;
|
|
6920
6945
|
const {
|
|
@@ -6939,7 +6964,7 @@
|
|
|
6939
6964
|
lockPreviousFileEntry = previousFileEntry && previousFileEntry.lockFileEntry;
|
|
6940
6965
|
requestLockCurrentFileEntry();
|
|
6941
6966
|
}
|
|
6942
|
-
if (options.bufferedWrite || !keepOrder || zipWriter.writerLocked || zipWriter.bufferedWrites || !dataDescriptor) {
|
|
6967
|
+
if (options.bufferedWrite || !keepOrder || zipWriter.writerLocked || zipWriter.bufferedWrites || (!dataDescriptor && !emptyEntry)) {
|
|
6943
6968
|
bufferedWrite = true;
|
|
6944
6969
|
zipWriter.bufferedWrites++;
|
|
6945
6970
|
if (options.createTempStream) {
|
|
@@ -7361,8 +7386,8 @@
|
|
|
7361
7386
|
try {
|
|
7362
7387
|
const { uid, gid, unixExtraFieldType } = options;
|
|
7363
7388
|
if (unixExtraFieldType == INFOZIP_EXTRA_FIELD_TYPE$1 && (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE)) {
|
|
7364
|
-
const uidBytes = packUnixId(uid);
|
|
7365
|
-
const gidBytes = packUnixId(gid);
|
|
7389
|
+
const uidBytes = packUnixId(uid === UNDEFINED_VALUE ? 0 : uid);
|
|
7390
|
+
const gidBytes = packUnixId(gid === UNDEFINED_VALUE ? 0 : gid);
|
|
7366
7391
|
const payloadLength = 3 + uidBytes.length + gidBytes.length;
|
|
7367
7392
|
const extraFieldUnix = createRecordWriter(4 + payloadLength);
|
|
7368
7393
|
extraFieldUnix.writeUint16(EXTRAFIELD_TYPE_INFOZIP);
|
|
@@ -7401,12 +7426,13 @@
|
|
|
7401
7426
|
if (passThrough && crc32 !== UNDEFINED_VALUE) {
|
|
7402
7427
|
rawExtraFieldAES[EXTRAFIELD_OFFSET_AES_VENDOR_VERSION] = VENDOR_VERSION_AE_1;
|
|
7403
7428
|
}
|
|
7404
|
-
rawExtraFieldAES
|
|
7429
|
+
setUint16(getDataView(rawExtraFieldAES), EXTRAFIELD_OFFSET_AES_COMPRESSION_METHOD, compressionMethod);
|
|
7405
7430
|
compressionMethod = COMPRESSION_METHOD_AES;
|
|
7406
7431
|
}
|
|
7407
7432
|
const localExtraFieldZip64Length = writeLocalExtraFieldZip64 ? getLength(rawLocalExtraFieldZip64) : 0;
|
|
7408
7433
|
const extraFieldLength = localExtraFieldZip64Length + getLength(rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS, rawExtraFieldUnix, rawExtraField, rawLocalExtraField);
|
|
7409
|
-
|
|
7434
|
+
const maximumUsdzExtraFieldLength = options[OPTION_USDZ] ? EXTRAFIELD_USDZ_MAX_LENGTH : 0;
|
|
7435
|
+
if (extraFieldLength + maximumUsdzExtraFieldLength > MAX_16_BITS) {
|
|
7410
7436
|
throw new Error(ERR_INVALID_EXTRAFIELD_DATA);
|
|
7411
7437
|
}
|
|
7412
7438
|
const dosLastModDate = new Date(Math.ceil(Math.floor(lastModDate.getTime() / 1000) / 2) * 2000);
|
|
@@ -7492,18 +7518,14 @@
|
|
|
7492
7518
|
}
|
|
7493
7519
|
|
|
7494
7520
|
function packUnixId(id) {
|
|
7495
|
-
|
|
7496
|
-
|
|
7497
|
-
|
|
7498
|
-
|
|
7499
|
-
|
|
7500
|
-
|
|
7501
|
-
let length = 4;
|
|
7502
|
-
while (length > 1 && dataArray[length - 1] === 0) {
|
|
7503
|
-
length--;
|
|
7504
|
-
}
|
|
7505
|
-
return dataArray.subarray(0, length);
|
|
7521
|
+
const dataArray = new Uint8Array(4);
|
|
7522
|
+
const dataView = getDataView(dataArray);
|
|
7523
|
+
dataView.setUint32(0, id, true);
|
|
7524
|
+
let length = 4;
|
|
7525
|
+
while (length > 1 && dataArray[length - 1] === 0) {
|
|
7526
|
+
length--;
|
|
7506
7527
|
}
|
|
7528
|
+
return dataArray.subarray(0, length);
|
|
7507
7529
|
}
|
|
7508
7530
|
|
|
7509
7531
|
function normalizeMsdosAttributes(msdosAttributesRaw, msdosAttributes) {
|
|
@@ -7807,7 +7829,11 @@
|
|
|
7807
7829
|
signatureRecord.writeUint32(DIGITAL_SIGNATURE_RECORD_SIGNATURE);
|
|
7808
7830
|
signatureRecord.writeUint16(signatureDataLength);
|
|
7809
7831
|
signatureRecord.writeBytes(signatureData);
|
|
7810
|
-
|
|
7832
|
+
const { writer } = zipWriter;
|
|
7833
|
+
if (exceedsAvailableSize(writer, getLength(signatureRecord.array))) {
|
|
7834
|
+
await writer.closeDisk();
|
|
7835
|
+
}
|
|
7836
|
+
await writeData(writer, signatureRecord.array);
|
|
7811
7837
|
return 6 + signatureDataLength;
|
|
7812
7838
|
}
|
|
7813
7839
|
return 0;
|
|
@@ -7918,7 +7944,22 @@
|
|
|
7918
7944
|
return getUint32(getDataView(signatureArray), 0) == SPLIT_ZIP_FILE_SIGNATURE;
|
|
7919
7945
|
}
|
|
7920
7946
|
|
|
7921
|
-
|
|
7947
|
+
function removeExtraFieldZip64(rawExtraField) {
|
|
7948
|
+
const rawExtraFieldView = getDataView(rawExtraField);
|
|
7949
|
+
let offsetExtraField = 0;
|
|
7950
|
+
while (offsetExtraField + 4 <= getLength(rawExtraField)) {
|
|
7951
|
+
const size = 4 + getUint16(rawExtraFieldView, offsetExtraField + 2);
|
|
7952
|
+
if (getUint16(rawExtraFieldView, offsetExtraField) == EXTRAFIELD_TYPE_ZIP64) {
|
|
7953
|
+
return removeExtraFieldZip64(concat(
|
|
7954
|
+
rawExtraField.subarray(0, offsetExtraField),
|
|
7955
|
+
rawExtraField.subarray(Math.min(offsetExtraField + size, getLength(rawExtraField)))));
|
|
7956
|
+
}
|
|
7957
|
+
offsetExtraField += size;
|
|
7958
|
+
}
|
|
7959
|
+
return rawExtraField;
|
|
7960
|
+
}
|
|
7961
|
+
|
|
7962
|
+
async function copyZipData(zipWriter, reader, entries, directoryOffset) {
|
|
7922
7963
|
const { writer } = zipWriter;
|
|
7923
7964
|
const entryPositions = new Map();
|
|
7924
7965
|
if (writer.closeDisk) {
|
|
@@ -7939,9 +7980,10 @@
|
|
|
7939
7980
|
}
|
|
7940
7981
|
await copyData(zipWriter, reader, copiedLength, directoryOffset - copiedLength);
|
|
7941
7982
|
} else {
|
|
7983
|
+
const baseOffset = zipWriter.offset;
|
|
7942
7984
|
await copyData(zipWriter, reader, 0, directoryOffset);
|
|
7943
7985
|
entries.forEach(entry => entryPositions.set(entry, {
|
|
7944
|
-
offset:
|
|
7986
|
+
offset: baseOffset + getSourceOffset(reader, entry),
|
|
7945
7987
|
diskNumberStart: 0
|
|
7946
7988
|
}));
|
|
7947
7989
|
}
|
|
@@ -9849,7 +9891,7 @@
|
|
|
9849
9891
|
} else if (writer.constructor == BlobWriter) {
|
|
9850
9892
|
return data.type == contentType;
|
|
9851
9893
|
} else if (writer.constructor == Data64URIWriter) {
|
|
9852
|
-
return data.startsWith(
|
|
9894
|
+
return data.startsWith("data:" + (contentType || "") + ";base64,");
|
|
9853
9895
|
} else {
|
|
9854
9896
|
return true;
|
|
9855
9897
|
}
|
|
@@ -10522,6 +10564,7 @@
|
|
|
10522
10564
|
exports.ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH = ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH;
|
|
10523
10565
|
exports.ERR_UNSUPPORTED_ENCRYPTION_USDZ = ERR_UNSUPPORTED_ENCRYPTION_USDZ;
|
|
10524
10566
|
exports.ERR_UNSUPPORTED_FORMAT = ERR_UNSUPPORTED_FORMAT;
|
|
10567
|
+
exports.ERR_UNSUPPORTED_UINT64 = ERR_UNSUPPORTED_UINT64;
|
|
10525
10568
|
exports.ERR_WORKER_STARTUP_TIMEOUT = ERR_WORKER_STARTUP_TIMEOUT;
|
|
10526
10569
|
exports.ERR_WRITER_NOT_INITIALIZED = ERR_WRITER_NOT_INITIALIZED;
|
|
10527
10570
|
exports.ERR_ZIP_NOT_EMPTY = ERR_ZIP_NOT_EMPTY;
|