@zip.js/zip.js 2.8.56 → 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 +47 -23
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +47 -22
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +48 -24
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +47 -23
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +48 -24
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +48 -23
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +48 -23
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +47 -22
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +47 -22
- package/dist/zip-native.min.js +1 -1
- package/dist/zip.js +47 -22
- package/dist/zip.min.js +1 -1
- package/index-native.cjs +48 -23
- package/index-native.min.js +1 -1
- package/index.cjs +48 -23
- package/index.d.cts +13 -1
- package/index.d.ts +13 -1
- package/index.min.js +1 -1
- package/lib/core/zip-fs.js +1 -1
- package/lib/core/zip-reader.js +11 -4
- package/lib/core/zip-writer.js +37 -20
- package/lib/zip-core-reader.js +1 -0
- package/package.json +1 -1
package/dist/zip-fs-core.js
CHANGED
|
@@ -4122,6 +4122,7 @@
|
|
|
4122
4122
|
const ERR_INVALID_STRICTNESS = "Invalid strictness (must be 'strict', 'balanced' or 'tolerant')";
|
|
4123
4123
|
const ERR_INVALID_FILENAME_VALIDATION = "Invalid filenameValidation (must be 'strict', 'balanced' or 'tolerant')";
|
|
4124
4124
|
const ERR_INVALID_MAX_APPENDED_DATA_SIZE = "Invalid maxAppendedDataSize (must be a number greater than or equal to 0)";
|
|
4125
|
+
const ERR_UNSUPPORTED_UINT64 = "64-bit value exceeds Number.MAX_SAFE_INTEGER";
|
|
4125
4126
|
const DRIVE_LETTER_REGEXP = /^[a-zA-Z]:/;
|
|
4126
4127
|
const CHARSET_UTF8 = "utf-8";
|
|
4127
4128
|
const PROPERTY_NAME_UTF8_SUFFIX = "UTF8";
|
|
@@ -4144,6 +4145,7 @@
|
|
|
4144
4145
|
bytes: 8
|
|
4145
4146
|
}
|
|
4146
4147
|
};
|
|
4148
|
+
const MAX_SAFE_UINT64 = BigInt(Number.MAX_SAFE_INTEGER);
|
|
4147
4149
|
const MAX_END_OF_CENTRAL_DIR_PROBES = 64;
|
|
4148
4150
|
const MAX_DEFLATE_EXPANSION_RATIO = 1032;
|
|
4149
4151
|
const CENTRAL_DIRECTORY_UNREACHABLE = 0;
|
|
@@ -4239,7 +4241,7 @@
|
|
|
4239
4241
|
zip64EndOfDirectoryVersion2 = getBigUint64(endOfDirectoryView, 4) > ZIP64_END_OF_CENTRAL_DIR_LENGTH - 12;
|
|
4240
4242
|
if (zip64EndOfDirectoryVersion2) {
|
|
4241
4243
|
const extensibleDataLength = Math.min(
|
|
4242
|
-
|
|
4244
|
+
getBigUint64(endOfDirectoryView, 4) - (ZIP64_END_OF_CENTRAL_DIR_LENGTH - 12),
|
|
4243
4245
|
reader.size - directoryDataOffset - ZIP64_END_OF_CENTRAL_DIR_LENGTH);
|
|
4244
4246
|
if (extensibleDataLength > 0) {
|
|
4245
4247
|
zip64EndOfDirectoryLength += extensibleDataLength;
|
|
@@ -4780,8 +4782,8 @@
|
|
|
4780
4782
|
const hashDataLength = getUint16$1(extensibleDataView, 26);
|
|
4781
4783
|
Object.assign(directoryEncryptionInfo, {
|
|
4782
4784
|
compressionMethod: getUint16$1(extensibleDataView, 0),
|
|
4783
|
-
compressedSize:
|
|
4784
|
-
uncompressedSize:
|
|
4785
|
+
compressedSize: getBigUint64(extensibleDataView, 2),
|
|
4786
|
+
uncompressedSize: getBigUint64(extensibleDataView, 10),
|
|
4785
4787
|
encryptionAlgorithm: getUint16$1(extensibleDataView, 18),
|
|
4786
4788
|
bitLength: getUint16$1(extensibleDataView, 20),
|
|
4787
4789
|
flags: getUint16$1(extensibleDataView, 22),
|
|
@@ -5416,7 +5418,11 @@
|
|
|
5416
5418
|
}
|
|
5417
5419
|
|
|
5418
5420
|
function getBigUint64(view, offset) {
|
|
5419
|
-
|
|
5421
|
+
const value = view.getBigUint64(offset, true);
|
|
5422
|
+
if (value > MAX_SAFE_UINT64) {
|
|
5423
|
+
throw new Error(ERR_UNSUPPORTED_UINT64);
|
|
5424
|
+
}
|
|
5425
|
+
return Number(value);
|
|
5420
5426
|
}
|
|
5421
5427
|
|
|
5422
5428
|
var zipReader = /*#__PURE__*/Object.freeze({
|
|
@@ -5445,6 +5451,7 @@
|
|
|
5445
5451
|
ERR_UNSAFE_FILENAME: ERR_UNSAFE_FILENAME,
|
|
5446
5452
|
ERR_UNSUPPORTED_COMPRESSION: ERR_UNSUPPORTED_COMPRESSION$1,
|
|
5447
5453
|
ERR_UNSUPPORTED_ENCRYPTION: ERR_UNSUPPORTED_ENCRYPTION,
|
|
5454
|
+
ERR_UNSUPPORTED_UINT64: ERR_UNSUPPORTED_UINT64,
|
|
5448
5455
|
ZipReader: ZipReader
|
|
5449
5456
|
});
|
|
5450
5457
|
|
|
@@ -5583,7 +5590,7 @@
|
|
|
5583
5590
|
encrypted,
|
|
5584
5591
|
uncompressedSize,
|
|
5585
5592
|
compressedSize,
|
|
5586
|
-
|
|
5593
|
+
extraFieldZip64
|
|
5587
5594
|
} = entry;
|
|
5588
5595
|
let {
|
|
5589
5596
|
compressionMethod,
|
|
@@ -5600,13 +5607,13 @@
|
|
|
5600
5607
|
rawExtraFieldExtendedTimestamp = rawExtraFieldExtendedTimestamp || EMPTY_UINT8_ARRAY;
|
|
5601
5608
|
rawExtraFieldNTFS = rawExtraFieldNTFS || EMPTY_UINT8_ARRAY;
|
|
5602
5609
|
rawExtraFieldUnix = rawExtraFieldUnix || EMPTY_UINT8_ARRAY;
|
|
5603
|
-
rawExtraField = rawExtraField || EMPTY_UINT8_ARRAY;
|
|
5610
|
+
rawExtraField = removeExtraFieldZip64(rawExtraField || EMPTY_UINT8_ARRAY);
|
|
5604
5611
|
if (entry.extraFieldAES) {
|
|
5605
5612
|
compressionMethod = COMPRESSION_METHOD_AES;
|
|
5606
5613
|
}
|
|
5607
5614
|
const extraFieldLength = getLength(rawExtraFieldZip64, rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS, rawExtraFieldUnix, rawExtraField);
|
|
5608
|
-
const zip64UncompressedSize =
|
|
5609
|
-
const zip64CompressedSize =
|
|
5615
|
+
const zip64UncompressedSize = Boolean(extraFieldZip64) && extraFieldZip64.uncompressedSize !== UNDEFINED_VALUE;
|
|
5616
|
+
const zip64CompressedSize = Boolean(extraFieldZip64) && extraFieldZip64.compressedSize !== UNDEFINED_VALUE;
|
|
5610
5617
|
const bitFlagValue = (getBitFlag(level, languageEncodingFlag, dataDescriptor, encrypted, compressionMethod) & ~BITFLAG_LEVEL) | (level << 1);
|
|
5611
5618
|
const {
|
|
5612
5619
|
headerArray,
|
|
@@ -6100,6 +6107,10 @@
|
|
|
6100
6107
|
maximumCompressedSize = contentSize === UNDEFINED_VALUE ? getMaximumCompressedSize(uncompressedSize) + encryptionOverhead : contentSize;
|
|
6101
6108
|
}
|
|
6102
6109
|
}
|
|
6110
|
+
const emptyEntry = !encryptedEntry && (!hasContent || (contentSize === 0 && !passThrough)) && !isCompressed(compressionMethod, level);
|
|
6111
|
+
if (emptyEntry && !zipCrypto && getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR) === UNDEFINED_VALUE) {
|
|
6112
|
+
dataDescriptor = false;
|
|
6113
|
+
}
|
|
6103
6114
|
const zip64UncompressedSize = zip64Enabled || uncompressedSize >= MAX_32_BITS;
|
|
6104
6115
|
const zip64CompressedSize = zip64Enabled || maximumCompressedSize >= MAX_32_BITS;
|
|
6105
6116
|
if (zip64UncompressedSize || zip64CompressedSize) {
|
|
@@ -6114,6 +6125,7 @@
|
|
|
6114
6125
|
maximumCompressedSize,
|
|
6115
6126
|
resolvedOptions: {
|
|
6116
6127
|
dataDescriptor,
|
|
6128
|
+
emptyEntry,
|
|
6117
6129
|
zip64,
|
|
6118
6130
|
zip64UncompressedSize,
|
|
6119
6131
|
zip64CompressedSize,
|
|
@@ -6212,6 +6224,7 @@
|
|
|
6212
6224
|
const {
|
|
6213
6225
|
keepOrder,
|
|
6214
6226
|
dataDescriptor,
|
|
6227
|
+
emptyEntry,
|
|
6215
6228
|
signal
|
|
6216
6229
|
} = options;
|
|
6217
6230
|
const {
|
|
@@ -6236,7 +6249,7 @@
|
|
|
6236
6249
|
lockPreviousFileEntry = previousFileEntry && previousFileEntry.lockFileEntry;
|
|
6237
6250
|
requestLockCurrentFileEntry();
|
|
6238
6251
|
}
|
|
6239
|
-
if (options.bufferedWrite || !keepOrder || zipWriter.writerLocked || zipWriter.bufferedWrites || !dataDescriptor) {
|
|
6252
|
+
if (options.bufferedWrite || !keepOrder || zipWriter.writerLocked || zipWriter.bufferedWrites || (!dataDescriptor && !emptyEntry)) {
|
|
6240
6253
|
bufferedWrite = true;
|
|
6241
6254
|
zipWriter.bufferedWrites++;
|
|
6242
6255
|
if (options.createTempStream) {
|
|
@@ -6658,8 +6671,8 @@
|
|
|
6658
6671
|
try {
|
|
6659
6672
|
const { uid, gid, unixExtraFieldType } = options;
|
|
6660
6673
|
if (unixExtraFieldType == INFOZIP_EXTRA_FIELD_TYPE$1 && (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE)) {
|
|
6661
|
-
const uidBytes = packUnixId(uid);
|
|
6662
|
-
const gidBytes = packUnixId(gid);
|
|
6674
|
+
const uidBytes = packUnixId(uid === UNDEFINED_VALUE ? 0 : uid);
|
|
6675
|
+
const gidBytes = packUnixId(gid === UNDEFINED_VALUE ? 0 : gid);
|
|
6663
6676
|
const payloadLength = 3 + uidBytes.length + gidBytes.length;
|
|
6664
6677
|
const extraFieldUnix = createRecordWriter(4 + payloadLength);
|
|
6665
6678
|
extraFieldUnix.writeUint16(EXTRAFIELD_TYPE_INFOZIP);
|
|
@@ -6790,18 +6803,14 @@
|
|
|
6790
6803
|
}
|
|
6791
6804
|
|
|
6792
6805
|
function packUnixId(id) {
|
|
6793
|
-
|
|
6794
|
-
|
|
6795
|
-
|
|
6796
|
-
|
|
6797
|
-
|
|
6798
|
-
|
|
6799
|
-
let length = 4;
|
|
6800
|
-
while (length > 1 && dataArray[length - 1] === 0) {
|
|
6801
|
-
length--;
|
|
6802
|
-
}
|
|
6803
|
-
return dataArray.subarray(0, length);
|
|
6806
|
+
const dataArray = new Uint8Array(4);
|
|
6807
|
+
const dataView = getDataView(dataArray);
|
|
6808
|
+
dataView.setUint32(0, id, true);
|
|
6809
|
+
let length = 4;
|
|
6810
|
+
while (length > 1 && dataArray[length - 1] === 0) {
|
|
6811
|
+
length--;
|
|
6804
6812
|
}
|
|
6813
|
+
return dataArray.subarray(0, length);
|
|
6805
6814
|
}
|
|
6806
6815
|
|
|
6807
6816
|
function normalizeMsdosAttributes(msdosAttributesRaw, msdosAttributes) {
|
|
@@ -7220,6 +7229,21 @@
|
|
|
7220
7229
|
return getUint32(getDataView(signatureArray), 0) == SPLIT_ZIP_FILE_SIGNATURE;
|
|
7221
7230
|
}
|
|
7222
7231
|
|
|
7232
|
+
function removeExtraFieldZip64(rawExtraField) {
|
|
7233
|
+
const rawExtraFieldView = getDataView(rawExtraField);
|
|
7234
|
+
let offsetExtraField = 0;
|
|
7235
|
+
while (offsetExtraField + 4 <= getLength(rawExtraField)) {
|
|
7236
|
+
const size = 4 + getUint16(rawExtraFieldView, offsetExtraField + 2);
|
|
7237
|
+
if (getUint16(rawExtraFieldView, offsetExtraField) == EXTRAFIELD_TYPE_ZIP64) {
|
|
7238
|
+
return removeExtraFieldZip64(concat(
|
|
7239
|
+
rawExtraField.subarray(0, offsetExtraField),
|
|
7240
|
+
rawExtraField.subarray(Math.min(offsetExtraField + size, getLength(rawExtraField)))));
|
|
7241
|
+
}
|
|
7242
|
+
offsetExtraField += size;
|
|
7243
|
+
}
|
|
7244
|
+
return rawExtraField;
|
|
7245
|
+
}
|
|
7246
|
+
|
|
7223
7247
|
async function copyZipData(zipWriter, reader, entries, directoryOffset) {
|
|
7224
7248
|
const { writer } = zipWriter;
|
|
7225
7249
|
const entryPositions = new Map();
|
|
@@ -8269,7 +8293,7 @@
|
|
|
8269
8293
|
} else if (writer.constructor == BlobWriter) {
|
|
8270
8294
|
return data.type == contentType;
|
|
8271
8295
|
} else if (writer.constructor == Data64URIWriter) {
|
|
8272
|
-
return data.startsWith(
|
|
8296
|
+
return data.startsWith("data:" + (contentType || "") + ";base64,");
|
|
8273
8297
|
} else {
|
|
8274
8298
|
return true;
|
|
8275
8299
|
}
|