@zip.js/zip.js 2.8.54 → 2.8.55
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 +50 -13
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +50 -12
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +51 -18
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +50 -17
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +51 -18
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +53 -19
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +53 -19
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +52 -14
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +52 -14
- 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 +52 -14
- package/dist/zip.min.js +1 -1
- package/index-native.cjs +53 -19
- package/index-native.min.js +1 -1
- package/index.cjs +53 -19
- package/index.d.cts +24 -7
- package/index.d.ts +24 -7
- package/index.min.js +1 -1
- package/lib/core/constants.js +2 -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 +42 -12
- package/lib/core/zip-writer.js +8 -0
- 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-core.js
CHANGED
|
@@ -84,6 +84,7 @@
|
|
|
84
84
|
const BITFLAG_DATA_DESCRIPTOR = 0b1000;
|
|
85
85
|
const BITFLAG_STRONG_ENCRYPTION = 0b1000000;
|
|
86
86
|
const BITFLAG_LANG_ENCODING_FLAG = 0b100000000000;
|
|
87
|
+
const BITFLAG_MASKED_LOCAL_HEADERS = 0b10000000000000;
|
|
87
88
|
const FILE_ATTR_MSDOS_DIR_MASK = 0b10000;
|
|
88
89
|
const FILE_ATTR_MSDOS_READONLY_MASK = 0x01;
|
|
89
90
|
const FILE_ATTR_MSDOS_HIDDEN_MASK = 0x02;
|
|
@@ -4192,6 +4193,7 @@
|
|
|
4192
4193
|
let startOffset;
|
|
4193
4194
|
let zip64EndOfDirectory;
|
|
4194
4195
|
let zip64EndOfDirectoryVersion2;
|
|
4196
|
+
let zip64EndOfDirectoryLength = ZIP64_END_OF_CENTRAL_DIR_LENGTH;
|
|
4195
4197
|
let directoryEncryptionInfo;
|
|
4196
4198
|
const requiresZip64 = directoryDataOffset == MAX_32_BITS || directoryDataLength == MAX_32_BITS || filesLength == MAX_16_BITS || diskNumber == MAX_16_BITS;
|
|
4197
4199
|
if (directoryDataOffset != MAX_32_BITS && diskNumber != MAX_16_BITS) {
|
|
@@ -4228,6 +4230,7 @@
|
|
|
4228
4230
|
Number(getBigUint64(endOfDirectoryView, 4)) - (ZIP64_END_OF_CENTRAL_DIR_LENGTH - 12),
|
|
4229
4231
|
reader.size - directoryDataOffset - ZIP64_END_OF_CENTRAL_DIR_LENGTH);
|
|
4230
4232
|
if (extensibleDataLength > 0) {
|
|
4233
|
+
zip64EndOfDirectoryLength += extensibleDataLength;
|
|
4231
4234
|
const rawExtensibleData = await readUint8Array(reader, directoryDataOffset + ZIP64_END_OF_CENTRAL_DIR_LENGTH, extensibleDataLength);
|
|
4232
4235
|
directoryEncryptionInfo = getDirectoryEncryptionInfo(rawExtensibleData);
|
|
4233
4236
|
}
|
|
@@ -4257,7 +4260,7 @@
|
|
|
4257
4260
|
}
|
|
4258
4261
|
let declaredDirectoryDataLength = directoryDataLength;
|
|
4259
4262
|
const centralDirectoryEndOffset = endOfDirectoryInfo.offset -
|
|
4260
|
-
(zip64EndOfDirectory ?
|
|
4263
|
+
(zip64EndOfDirectory ? zip64EndOfDirectoryLength + ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH : 0);
|
|
4261
4264
|
if (directoryDataOffset >= reader.size) {
|
|
4262
4265
|
prependedDataLength = reader.size - directoryDataOffset - directoryDataLength - END_OF_CENTRAL_DIR_LENGTH;
|
|
4263
4266
|
directoryDataOffset = reader.size - directoryDataLength - END_OF_CENTRAL_DIR_LENGTH;
|
|
@@ -4277,7 +4280,9 @@
|
|
|
4277
4280
|
}
|
|
4278
4281
|
const expectedDirectoryDataOffset = centralDirectoryEndOffset - directoryDataLength;
|
|
4279
4282
|
if (directoryDataOffset != expectedDirectoryDataOffset && diskNumber == lastDiskNumber) {
|
|
4280
|
-
const storedPointsAtDirectory = getUint32$1(directoryView, offset) == CENTRAL_FILE_HEADER_SIGNATURE
|
|
4283
|
+
const storedPointsAtDirectory = getUint32$1(directoryView, offset) == CENTRAL_FILE_HEADER_SIGNATURE ||
|
|
4284
|
+
Boolean(directoryEncryptionInfo && directoryEncryptionInfo.compressedSize) ||
|
|
4285
|
+
detectEncryptedCentralDirectory(directoryView);
|
|
4281
4286
|
let reconcile = !storedPointsAtDirectory;
|
|
4282
4287
|
if (!reconcile && expectedDirectoryDataOffset >= 0 && expectedDirectoryDataOffset + 4 <= reader.size) {
|
|
4283
4288
|
const expectedSignatureArray = await readUint8Array(reader, expectedDirectoryDataOffset, 4);
|
|
@@ -4306,11 +4311,13 @@
|
|
|
4306
4311
|
zipReader.directoryOffset = directoryDataOffset;
|
|
4307
4312
|
zipReader.directoryLength = declaredDirectoryDataLength;
|
|
4308
4313
|
const decryptCentralDirectory = getFunctionOptionValue$1(zipReader, options, OPTION_DECRYPT_CENTRAL_DIRECTORY);
|
|
4309
|
-
let decryptedDirectory;
|
|
4314
|
+
let decryptedDirectory, dataAfterEncryptedDirectory;
|
|
4310
4315
|
if (decryptCentralDirectory && filesLength && directoryArray.length >= 4 &&
|
|
4311
4316
|
getUint32$1(directoryView, 0) != CENTRAL_FILE_HEADER_SIGNATURE &&
|
|
4312
4317
|
(zip64EndOfDirectoryVersion2 || detectEncryptedCentralDirectory(directoryView))) {
|
|
4313
|
-
|
|
4318
|
+
const encryptedDirectoryDataLength = getEncryptedDirectoryDataLength(directoryEncryptionInfo, declaredDirectoryDataLength, directoryArray.length);
|
|
4319
|
+
dataAfterEncryptedDirectory = directoryArray.subarray(encryptedDirectoryDataLength);
|
|
4320
|
+
directoryArray = await decryptCentralDirectory(directoryArray.subarray(0, encryptedDirectoryDataLength), directoryEncryptionInfo);
|
|
4314
4321
|
directoryView = getDataView(directoryArray);
|
|
4315
4322
|
declaredDirectoryDataLength = directoryArray.length;
|
|
4316
4323
|
decryptedDirectory = true;
|
|
@@ -4376,6 +4383,7 @@
|
|
|
4376
4383
|
}
|
|
4377
4384
|
Object.assign(fileEntry, {
|
|
4378
4385
|
index: indexFile,
|
|
4386
|
+
decryptedDirectory,
|
|
4379
4387
|
versionMadeBy,
|
|
4380
4388
|
msDosCompatible,
|
|
4381
4389
|
zip64: false,
|
|
@@ -4452,12 +4460,11 @@
|
|
|
4452
4460
|
yield entry;
|
|
4453
4461
|
}
|
|
4454
4462
|
let offsetAfterSignature = offset;
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
}
|
|
4463
|
+
const digitalSignature = readDigitalSignature(directoryArray.subarray(offset)) ||
|
|
4464
|
+
(decryptedDirectory ? readDigitalSignature(dataAfterEncryptedDirectory) : UNDEFINED_VALUE);
|
|
4465
|
+
if (digitalSignature) {
|
|
4466
|
+
zipReader.digitalSignature = digitalSignature;
|
|
4467
|
+
offsetAfterSignature = offset + 6 + digitalSignature.length;
|
|
4461
4468
|
}
|
|
4462
4469
|
if (checkAmbiguity && offset != declaredDirectoryDataLength && offsetAfterSignature != declaredDirectoryDataLength) {
|
|
4463
4470
|
throwAmbiguousArchive("trailing central directory data");
|
|
@@ -4726,6 +4733,27 @@
|
|
|
4726
4733
|
return false;
|
|
4727
4734
|
}
|
|
4728
4735
|
|
|
4736
|
+
function readDigitalSignature(signatureRecordArray) {
|
|
4737
|
+
if (signatureRecordArray.length >= 6) {
|
|
4738
|
+
const signatureRecordView = getDataView(signatureRecordArray);
|
|
4739
|
+
if (getUint32$1(signatureRecordView, 0) == DIGITAL_SIGNATURE_RECORD_SIGNATURE) {
|
|
4740
|
+
const signatureDataLength = getUint16$1(signatureRecordView, 4);
|
|
4741
|
+
if (6 + signatureDataLength <= signatureRecordArray.length) {
|
|
4742
|
+
return signatureRecordArray.subarray(6, 6 + signatureDataLength);
|
|
4743
|
+
}
|
|
4744
|
+
}
|
|
4745
|
+
}
|
|
4746
|
+
}
|
|
4747
|
+
|
|
4748
|
+
function getEncryptedDirectoryDataLength(directoryEncryptionInfo, declaredDirectoryDataLength, directoryDataLength) {
|
|
4749
|
+
const encryptedDirectoryDataLength = directoryEncryptionInfo && directoryEncryptionInfo.compressedSize ?
|
|
4750
|
+
directoryEncryptionInfo.compressedSize :
|
|
4751
|
+
declaredDirectoryDataLength;
|
|
4752
|
+
return encryptedDirectoryDataLength > 0 && encryptedDirectoryDataLength <= directoryDataLength ?
|
|
4753
|
+
encryptedDirectoryDataLength :
|
|
4754
|
+
directoryDataLength;
|
|
4755
|
+
}
|
|
4756
|
+
|
|
4729
4757
|
function getDirectoryEncryptionInfo(rawExtensibleData) {
|
|
4730
4758
|
const directoryEncryptionInfo = { rawExtensibleData };
|
|
4731
4759
|
if (rawExtensibleData.length >= 28) {
|
|
@@ -5310,7 +5338,9 @@
|
|
|
5310
5338
|
|
|
5311
5339
|
function validateLocalDirectory(zipEntry, localDirectory, rawLocalFilename, checkLocalFilename) {
|
|
5312
5340
|
const { rawFilename } = zipEntry;
|
|
5313
|
-
|
|
5341
|
+
const maskedLocalDirectory = zipEntry.decryptedDirectory &&
|
|
5342
|
+
(localDirectory.rawBitFlag & BITFLAG_MASKED_LOCAL_HEADERS) == BITFLAG_MASKED_LOCAL_HEADERS;
|
|
5343
|
+
if (checkLocalFilename && !maskedLocalDirectory &&
|
|
5314
5344
|
(rawLocalFilename.length != rawFilename.length ||
|
|
5315
5345
|
rawLocalFilename.some((byteValue, indexByte) => byteValue != rawFilename[indexByte]))) {
|
|
5316
5346
|
throwAmbiguousArchive("mismatched local file header (filename)");
|
|
@@ -5321,7 +5351,7 @@
|
|
|
5321
5351
|
if (localDirectory.compressionMethod != zipEntry.compressionMethod) {
|
|
5322
5352
|
throwAmbiguousArchive("mismatched local file header (compression method)");
|
|
5323
5353
|
}
|
|
5324
|
-
if (!localDirectory.bitFlag.dataDescriptor &&
|
|
5354
|
+
if (!localDirectory.bitFlag.dataDescriptor && !maskedLocalDirectory &&
|
|
5325
5355
|
(localDirectory.crc32 || localDirectory.compressedSize || localDirectory.uncompressedSize) &&
|
|
5326
5356
|
(localDirectory.crc32 != zipEntry.crc32 ||
|
|
5327
5357
|
localDirectory.compressedSize != zipEntry.compressedSize ||
|
|
@@ -5450,6 +5480,7 @@
|
|
|
5450
5480
|
const MAX_NTFS_TIME = BigInt("0x7fffffffffffffff");
|
|
5451
5481
|
const ERR_UNSUPPORTED_FORMAT = "Zip64 is not supported (set the 'zip64' option to 'true')";
|
|
5452
5482
|
const ERR_UNDEFINED_UNCOMPRESSED_SIZE = "Undefined uncompressed size";
|
|
5483
|
+
const ERR_UNDEFINED_COMPRESSION_METHOD = "Undefined compression method";
|
|
5453
5484
|
const ERR_UNDETERMINED_SIZE = "Undetermined size";
|
|
5454
5485
|
const ERR_UNDEFINED_READER = "Undefined reader";
|
|
5455
5486
|
const ERR_ZIP_NOT_EMPTY = "Zip file not empty";
|
|
@@ -5915,6 +5946,9 @@
|
|
|
5915
5946
|
level = 0;
|
|
5916
5947
|
}
|
|
5917
5948
|
}
|
|
5949
|
+
if (passThrough) {
|
|
5950
|
+
level = UNDEFINED_VALUE;
|
|
5951
|
+
}
|
|
5918
5952
|
let useCompressionStream = getOptionValue(zipWriter, options, OPTION_USE_COMPRESSION_STREAM);
|
|
5919
5953
|
let dataDescriptor = getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR);
|
|
5920
5954
|
if (bufferedWrite && dataDescriptor === UNDEFINED_VALUE) {
|
|
@@ -6026,6 +6060,9 @@
|
|
|
6026
6060
|
if (uncompressedSize === UNDEFINED_VALUE) {
|
|
6027
6061
|
throw new Error(ERR_UNDEFINED_UNCOMPRESSED_SIZE);
|
|
6028
6062
|
}
|
|
6063
|
+
if (compressionMethod === UNDEFINED_VALUE) {
|
|
6064
|
+
throw new Error(ERR_UNDEFINED_COMPRESSION_METHOD);
|
|
6065
|
+
}
|
|
6029
6066
|
}
|
|
6030
6067
|
const zip64Enabled = zip64 === true;
|
|
6031
6068
|
const encrypted = getOptionValue(zipWriter, options, PROPERTY_NAME_ENCRYPTED);
|
|
@@ -8358,10 +8395,7 @@
|
|
|
8358
8395
|
});
|
|
8359
8396
|
}
|
|
8360
8397
|
if (isPassThrough(child, options)) {
|
|
8361
|
-
let
|
|
8362
|
-
if (compressionMethod === 0) {
|
|
8363
|
-
level = 0;
|
|
8364
|
-
}
|
|
8398
|
+
let encryptionStrength;
|
|
8365
8399
|
if (extraFieldAES) {
|
|
8366
8400
|
encryptionStrength = extraFieldAES.strength;
|
|
8367
8401
|
}
|
|
@@ -8371,7 +8405,6 @@
|
|
|
8371
8405
|
zipCrypto,
|
|
8372
8406
|
crc32,
|
|
8373
8407
|
uncompressedSize,
|
|
8374
|
-
level,
|
|
8375
8408
|
encryptionStrength,
|
|
8376
8409
|
compressionMethod
|
|
8377
8410
|
};
|