@zip.js/zip.js 2.8.55 → 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 +43 -29
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +43 -29
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +54 -36
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +54 -36
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +54 -36
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +54 -36
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +54 -36
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +43 -29
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +43 -29
- package/dist/zip-native.min.js +1 -1
- package/dist/zip.js +43 -29
- package/dist/zip.min.js +1 -1
- package/index-native.cjs +54 -36
- package/index-native.min.js +1 -1
- package/index.cjs +54 -36
- package/index.d.cts +5 -0
- package/index.d.ts +5 -0
- package/index.min.js +1 -1
- package/lib/core/options.js +14 -0
- package/lib/core/zip-reader.js +8 -1
- package/lib/core/zip-writer.js +36 -35
- package/package.json +1 -1
package/dist/zip-native.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
|
}
|
|
@@ -5047,8 +5059,15 @@
|
|
|
5047
5059
|
yield entry;
|
|
5048
5060
|
}
|
|
5049
5061
|
let offsetAfterSignature = offset;
|
|
5050
|
-
|
|
5062
|
+
let digitalSignature = readDigitalSignature(directoryArray.subarray(offset)) ||
|
|
5051
5063
|
(decryptedDirectory ? readDigitalSignature(dataAfterEncryptedDirectory) : UNDEFINED_VALUE);
|
|
5064
|
+
if (!digitalSignature && !decryptedDirectory) {
|
|
5065
|
+
const signatureRecordOffset = directoryDataOffset + offset;
|
|
5066
|
+
const signatureRecordLength = Math.min(centralDirectoryEndOffset - signatureRecordOffset, 6 + MAX_16_BITS);
|
|
5067
|
+
if (signatureRecordLength >= 6) {
|
|
5068
|
+
digitalSignature = readDigitalSignature(await readUint8Array(reader, signatureRecordOffset, signatureRecordLength));
|
|
5069
|
+
}
|
|
5070
|
+
}
|
|
5052
5071
|
if (digitalSignature) {
|
|
5053
5072
|
zipReader.digitalSignature = digitalSignature;
|
|
5054
5073
|
offsetAfterSignature = offset + 6 + digitalSignature.length;
|
|
@@ -6125,6 +6144,8 @@
|
|
|
6125
6144
|
|
|
6126
6145
|
const EXTRAFIELD_DATA_AES = new Uint8Array([0x07, 0x00, 0x02, 0x00, 0x41, 0x45, 0x03, 0x00, 0x00]);
|
|
6127
6146
|
const EXTRAFIELD_OFFSET_AES_VENDOR_VERSION = 4;
|
|
6147
|
+
const EXTRAFIELD_OFFSET_AES_COMPRESSION_METHOD = 9;
|
|
6148
|
+
const EXTRAFIELD_USDZ_MAX_LENGTH = 67;
|
|
6128
6149
|
const VENDOR_VERSION_AE_1 = 1;
|
|
6129
6150
|
const INFOZIP_EXTRA_FIELD_TYPE = "infozip";
|
|
6130
6151
|
const UNIX_EXTRA_FIELD_TYPE = "unix";
|
|
@@ -6171,16 +6192,14 @@
|
|
|
6171
6192
|
await zipReader$1.close();
|
|
6172
6193
|
await initStream(this.writer);
|
|
6173
6194
|
const { directoryOffset } = zipReader$1;
|
|
6174
|
-
let splitZipSignatureLength = 0;
|
|
6175
6195
|
if (this.addSplitZipSignature) {
|
|
6176
6196
|
delete this.addSplitZipSignature;
|
|
6177
6197
|
if (!await startsWithSplitZipSignature(reader)) {
|
|
6178
6198
|
await writeData(this.writer, getSplitZipSignatureArray());
|
|
6179
|
-
|
|
6180
|
-
this.offset += splitZipSignatureLength;
|
|
6199
|
+
this.offset += SPLIT_ZIP_FILE_SIGNATURE_LENGTH;
|
|
6181
6200
|
}
|
|
6182
6201
|
}
|
|
6183
|
-
const entryPositions = await copyZipData(this, reader, entries, directoryOffset
|
|
6202
|
+
const entryPositions = await copyZipData(this, reader, entries, directoryOffset);
|
|
6184
6203
|
this.filenames = new Set(entries.map(entry => entry.filename));
|
|
6185
6204
|
this.fileEntries = new Map(entries.map(entry => {
|
|
6186
6205
|
const {
|
|
@@ -6422,7 +6441,8 @@
|
|
|
6422
6441
|
signature: options[PROPERTY_NAME_SIGNATURE],
|
|
6423
6442
|
crc32: options.crc32 === UNDEFINED_VALUE ? options[PROPERTY_NAME_SIGNATURE] : options.crc32,
|
|
6424
6443
|
offset: zipWriter.offset - diskOffset,
|
|
6425
|
-
diskNumberStart: diskNumber
|
|
6444
|
+
diskNumberStart: diskNumber,
|
|
6445
|
+
[OPTION_USDZ]: zipWriter.options[OPTION_USDZ]
|
|
6426
6446
|
});
|
|
6427
6447
|
const headerInfo = getHeaderInfo(options);
|
|
6428
6448
|
const dataDescriptorInfo = getDataDescriptorInfo(options);
|
|
@@ -6454,15 +6474,9 @@
|
|
|
6454
6474
|
let setuid = getOptionValue(zipWriter, options, PROPERTY_NAME_SETUID);
|
|
6455
6475
|
let setgid = getOptionValue(zipWriter, options, PROPERTY_NAME_SETGID);
|
|
6456
6476
|
let sticky = getOptionValue(zipWriter, options, PROPERTY_NAME_STICKY);
|
|
6457
|
-
|
|
6458
|
-
|
|
6459
|
-
|
|
6460
|
-
if (gid !== UNDEFINED_VALUE && (!Number.isInteger(gid) || gid < 0 || gid > MAX_32_BITS)) {
|
|
6461
|
-
throw new Error(ERR_INVALID_GID);
|
|
6462
|
-
}
|
|
6463
|
-
if (unixMode !== UNDEFINED_VALUE && (!Number.isInteger(unixMode) || unixMode < 0 || unixMode > MAX_16_BITS)) {
|
|
6464
|
-
throw new Error(ERR_INVALID_UNIX_MODE);
|
|
6465
|
-
}
|
|
6477
|
+
checkIntegerOption(uid, MAX_32_BITS, ERR_INVALID_UID);
|
|
6478
|
+
checkIntegerOption(gid, MAX_32_BITS, ERR_INVALID_GID);
|
|
6479
|
+
checkIntegerOption(unixMode, MAX_16_BITS, ERR_INVALID_UNIX_MODE);
|
|
6466
6480
|
if (unixExtraFieldType !== UNDEFINED_VALUE && unixExtraFieldType !== INFOZIP_EXTRA_FIELD_TYPE && unixExtraFieldType !== UNIX_EXTRA_FIELD_TYPE) {
|
|
6467
6481
|
throw new Error(ERR_INVALID_UNIX_EXTRA_FIELD_TYPE);
|
|
6468
6482
|
}
|
|
@@ -6484,9 +6498,7 @@
|
|
|
6484
6498
|
msDosCompatible = true;
|
|
6485
6499
|
versionMadeBy = (versionMadeBy & MAX_8_BITS);
|
|
6486
6500
|
}
|
|
6487
|
-
|
|
6488
|
-
throw new Error(ERR_INVALID_MSDOS_ATTRIBUTES);
|
|
6489
|
-
}
|
|
6501
|
+
checkIntegerOption(msdosAttributesRaw, MAX_8_BITS, ERR_INVALID_MSDOS_ATTRIBUTES);
|
|
6490
6502
|
if (msdosAttributes && (typeof msdosAttributes !== OBJECT_TYPE || Array.isArray(msdosAttributes))) {
|
|
6491
6503
|
throw new Error(ERR_INVALID_MSDOS_DATA);
|
|
6492
6504
|
}
|
|
@@ -6626,9 +6638,7 @@
|
|
|
6626
6638
|
throw new Error(ERR_UNSUPPORTED_COMPRESSION);
|
|
6627
6639
|
}
|
|
6628
6640
|
let level = getNumberOptionValue(zipWriter, options, OPTION_LEVEL);
|
|
6629
|
-
|
|
6630
|
-
throw new Error(ERR_INVALID_LEVEL);
|
|
6631
|
-
}
|
|
6641
|
+
checkIntegerOption(level, MAX_LEVEL, ERR_INVALID_LEVEL);
|
|
6632
6642
|
if (zipWriter.options[OPTION_USDZ]) {
|
|
6633
6643
|
if (password !== UNDEFINED_VALUE || rawPassword !== UNDEFINED_VALUE) {
|
|
6634
6644
|
throw new Error(ERR_UNSUPPORTED_ENCRYPTION_USDZ);
|
|
@@ -6706,9 +6716,7 @@
|
|
|
6706
6716
|
let extraFieldSize = 0;
|
|
6707
6717
|
let offset = 0;
|
|
6708
6718
|
extraField.forEach((data, type) => {
|
|
6709
|
-
|
|
6710
|
-
throw new Error(ERR_INVALID_EXTRAFIELD_TYPE);
|
|
6711
|
-
}
|
|
6719
|
+
checkInteger(type, MAX_16_BITS, ERR_INVALID_EXTRAFIELD_TYPE);
|
|
6712
6720
|
if (!(data instanceof Uint8Array)) {
|
|
6713
6721
|
throw new Error(ERR_INVALID_EXTRAFIELD_DATA_TYPE);
|
|
6714
6722
|
}
|
|
@@ -7302,12 +7310,13 @@
|
|
|
7302
7310
|
if (passThrough && crc32 !== UNDEFINED_VALUE) {
|
|
7303
7311
|
rawExtraFieldAES[EXTRAFIELD_OFFSET_AES_VENDOR_VERSION] = VENDOR_VERSION_AE_1;
|
|
7304
7312
|
}
|
|
7305
|
-
rawExtraFieldAES
|
|
7313
|
+
setUint16(getDataView(rawExtraFieldAES), EXTRAFIELD_OFFSET_AES_COMPRESSION_METHOD, compressionMethod);
|
|
7306
7314
|
compressionMethod = COMPRESSION_METHOD_AES;
|
|
7307
7315
|
}
|
|
7308
7316
|
const localExtraFieldZip64Length = writeLocalExtraFieldZip64 ? getLength(rawLocalExtraFieldZip64) : 0;
|
|
7309
7317
|
const extraFieldLength = localExtraFieldZip64Length + getLength(rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS, rawExtraFieldUnix, rawExtraField, rawLocalExtraField);
|
|
7310
|
-
|
|
7318
|
+
const maximumUsdzExtraFieldLength = options[OPTION_USDZ] ? EXTRAFIELD_USDZ_MAX_LENGTH : 0;
|
|
7319
|
+
if (extraFieldLength + maximumUsdzExtraFieldLength > MAX_16_BITS) {
|
|
7311
7320
|
throw new Error(ERR_INVALID_EXTRAFIELD_DATA);
|
|
7312
7321
|
}
|
|
7313
7322
|
const dosLastModDate = new Date(Math.ceil(Math.floor(lastModDate.getTime() / 1000) / 2) * 2000);
|
|
@@ -7708,7 +7717,11 @@
|
|
|
7708
7717
|
signatureRecord.writeUint32(DIGITAL_SIGNATURE_RECORD_SIGNATURE);
|
|
7709
7718
|
signatureRecord.writeUint16(signatureDataLength);
|
|
7710
7719
|
signatureRecord.writeBytes(signatureData);
|
|
7711
|
-
|
|
7720
|
+
const { writer } = zipWriter;
|
|
7721
|
+
if (exceedsAvailableSize(writer, getLength(signatureRecord.array))) {
|
|
7722
|
+
await writer.closeDisk();
|
|
7723
|
+
}
|
|
7724
|
+
await writeData(writer, signatureRecord.array);
|
|
7712
7725
|
return 6 + signatureDataLength;
|
|
7713
7726
|
}
|
|
7714
7727
|
return 0;
|
|
@@ -7819,7 +7832,7 @@
|
|
|
7819
7832
|
return getUint32(getDataView(signatureArray), 0) == SPLIT_ZIP_FILE_SIGNATURE;
|
|
7820
7833
|
}
|
|
7821
7834
|
|
|
7822
|
-
async function copyZipData(zipWriter, reader, entries, directoryOffset
|
|
7835
|
+
async function copyZipData(zipWriter, reader, entries, directoryOffset) {
|
|
7823
7836
|
const { writer } = zipWriter;
|
|
7824
7837
|
const entryPositions = new Map();
|
|
7825
7838
|
if (writer.closeDisk) {
|
|
@@ -7840,9 +7853,10 @@
|
|
|
7840
7853
|
}
|
|
7841
7854
|
await copyData(zipWriter, reader, copiedLength, directoryOffset - copiedLength);
|
|
7842
7855
|
} else {
|
|
7856
|
+
const baseOffset = zipWriter.offset;
|
|
7843
7857
|
await copyData(zipWriter, reader, 0, directoryOffset);
|
|
7844
7858
|
entries.forEach(entry => entryPositions.set(entry, {
|
|
7845
|
-
offset:
|
|
7859
|
+
offset: baseOffset + getSourceOffset(reader, entry),
|
|
7846
7860
|
diskNumberStart: 0
|
|
7847
7861
|
}));
|
|
7848
7862
|
}
|