@zip.js/zip.js 2.7.48 → 2.7.50
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-fs-full.js +94 -31
- package/dist/zip-fs-full.min.js +1 -1
- package/dist/zip-fs.js +94 -31
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-full.js +70 -28
- package/dist/zip-full.min.js +1 -1
- package/dist/zip-no-worker-deflate.min.js +1 -1
- package/dist/zip-no-worker-inflate.min.js +1 -1
- package/dist/zip-no-worker.min.js +1 -1
- package/dist/zip.js +70 -28
- package/dist/zip.min.js +1 -1
- package/index.cjs +94 -31
- package/index.d.ts +35 -20
- package/index.js +1 -0
- package/index.min.js +1 -1
- package/lib/core/zip-entry.js +1 -1
- package/lib/core/zip-fs-core.js +24 -3
- package/lib/core/zip-reader.js +9 -4
- package/lib/core/zip-writer.js +61 -24
- package/package.json +3 -3
package/dist/zip.js
CHANGED
|
@@ -3356,7 +3356,7 @@
|
|
|
3356
3356
|
PROPERTY_NAME_MS_DOS_COMPATIBLE, PROPERTY_NAME_ZIP64,
|
|
3357
3357
|
"directory", "bitFlag", "encrypted", "signature", "filenameUTF8", "commentUTF8", "compressionMethod", "version", "versionMadeBy",
|
|
3358
3358
|
"extraField", "rawExtraField", "extraFieldZip64", "extraFieldUnicodePath", "extraFieldUnicodeComment", "extraFieldAES", "extraFieldNTFS",
|
|
3359
|
-
"extraFieldExtendedTimestamp"];
|
|
3359
|
+
"extraFieldExtendedTimestamp", "zipCrypto"];
|
|
3360
3360
|
|
|
3361
3361
|
class Entry {
|
|
3362
3362
|
|
|
@@ -3591,6 +3591,7 @@
|
|
|
3591
3591
|
});
|
|
3592
3592
|
startOffset = Math.max(offsetFileEntry, startOffset);
|
|
3593
3593
|
await readCommonFooter(fileEntry, fileEntry, directoryView, offset + 6);
|
|
3594
|
+
fileEntry.zipCrypto = fileEntry.encrypted && !fileEntry.extraFieldAES;
|
|
3594
3595
|
const entry = new Entry(fileEntry);
|
|
3595
3596
|
entry.getData = (writer, options) => fileEntry.getData(writer, entry, options);
|
|
3596
3597
|
offset = endOffset;
|
|
@@ -3708,8 +3709,12 @@
|
|
|
3708
3709
|
lastAccessDate: localDirectory.lastAccessDate,
|
|
3709
3710
|
creationDate: localDirectory.creationDate
|
|
3710
3711
|
});
|
|
3711
|
-
const
|
|
3712
|
+
const passThrough = getOptionValue$1(zipEntry, options, "passThrough");
|
|
3713
|
+
const encrypted = zipEntry.encrypted && localDirectory.encrypted && !passThrough;
|
|
3712
3714
|
const zipCrypto = encrypted && !extraFieldAES;
|
|
3715
|
+
if (!passThrough) {
|
|
3716
|
+
fileEntry.zipCrypto = zipCrypto;
|
|
3717
|
+
}
|
|
3713
3718
|
if (encrypted) {
|
|
3714
3719
|
if (!zipCrypto && extraFieldAES.strength === UNDEFINED_VALUE) {
|
|
3715
3720
|
throw new Error(ERR_UNSUPPORTED_ENCRYPTION);
|
|
@@ -3741,11 +3746,11 @@
|
|
|
3741
3746
|
rawPassword,
|
|
3742
3747
|
zipCrypto,
|
|
3743
3748
|
encryptionStrength: extraFieldAES && extraFieldAES.strength,
|
|
3744
|
-
signed: getOptionValue$1(zipEntry, options, "checkSignature"),
|
|
3749
|
+
signed: getOptionValue$1(zipEntry, options, "checkSignature") && !passThrough,
|
|
3745
3750
|
passwordVerification: zipCrypto && (bitFlag.dataDescriptor ? ((rawLastModDate >>> 8) & 0xFF) : ((signature >>> 24) & 0xFF)),
|
|
3746
3751
|
signature,
|
|
3747
|
-
compressed: compressionMethod != 0,
|
|
3748
|
-
encrypted,
|
|
3752
|
+
compressed: compressionMethod != 0 && !passThrough,
|
|
3753
|
+
encrypted: zipEntry.encrypted && !passThrough,
|
|
3749
3754
|
useWebWorkers: getOptionValue$1(zipEntry, options, "useWebWorkers"),
|
|
3750
3755
|
useCompressionStream: getOptionValue$1(zipEntry, options, "useCompressionStream"),
|
|
3751
3756
|
transferStreams: getOptionValue$1(zipEntry, options, "transferStreams"),
|
|
@@ -4074,6 +4079,7 @@
|
|
|
4074
4079
|
const ERR_INVALID_EXTRAFIELD_TYPE = "Extra field type exceeds 65535";
|
|
4075
4080
|
const ERR_INVALID_EXTRAFIELD_DATA = "Extra field data exceeds 64KB";
|
|
4076
4081
|
const ERR_UNSUPPORTED_FORMAT = "Zip64 is not supported (make sure 'keepOrder' is set to 'true')";
|
|
4082
|
+
const ERR_UNDEFINED_UNCOMPRESSED_SIZE = "Undefined uncompressed size";
|
|
4077
4083
|
|
|
4078
4084
|
const EXTRAFIELD_DATA_AES = new Uint8Array([0x07, 0x00, 0x02, 0x00, 0x41, 0x45, 0x03, 0x00, 0x00]);
|
|
4079
4085
|
|
|
@@ -4094,7 +4100,7 @@
|
|
|
4094
4100
|
config: getConfiguration(),
|
|
4095
4101
|
files: new Map(),
|
|
4096
4102
|
filenames: new Set(),
|
|
4097
|
-
offset: writer.writable.size,
|
|
4103
|
+
offset: options.offset === UNDEFINED_VALUE ? writer.writable.size : options.offset,
|
|
4098
4104
|
pendingEntriesSize: 0,
|
|
4099
4105
|
pendingAddFileCalls: new Set(),
|
|
4100
4106
|
bufferedWrites: 0
|
|
@@ -4216,8 +4222,12 @@
|
|
|
4216
4222
|
const msDosCompatible = getOptionValue(zipWriter, options, PROPERTY_NAME_MS_DOS_COMPATIBLE, true);
|
|
4217
4223
|
const internalFileAttribute = getOptionValue(zipWriter, options, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTE, 0);
|
|
4218
4224
|
const externalFileAttribute = getOptionValue(zipWriter, options, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTE, 0);
|
|
4219
|
-
const
|
|
4220
|
-
|
|
4225
|
+
const passThrough = getOptionValue(zipWriter, options, "passThrough");
|
|
4226
|
+
let password, rawPassword;
|
|
4227
|
+
if (!passThrough) {
|
|
4228
|
+
password = getOptionValue(zipWriter, options, "password");
|
|
4229
|
+
rawPassword = getOptionValue(zipWriter, options, "rawPassword");
|
|
4230
|
+
}
|
|
4221
4231
|
const encryptionStrength = getOptionValue(zipWriter, options, "encryptionStrength", 3);
|
|
4222
4232
|
const zipCrypto = getOptionValue(zipWriter, options, "zipCrypto");
|
|
4223
4233
|
const extendedTimestamp = getOptionValue(zipWriter, options, "extendedTimestamp", true);
|
|
@@ -4231,7 +4241,7 @@
|
|
|
4231
4241
|
const useCompressionStream = getOptionValue(zipWriter, options, "useCompressionStream");
|
|
4232
4242
|
let dataDescriptor = getOptionValue(zipWriter, options, "dataDescriptor", true);
|
|
4233
4243
|
let zip64 = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIP64);
|
|
4234
|
-
if (password !== UNDEFINED_VALUE && encryptionStrength !== UNDEFINED_VALUE && (encryptionStrength < 1 || encryptionStrength > 3)) {
|
|
4244
|
+
if ((password !== UNDEFINED_VALUE || rawPassword !== UNDEFINED_VALUE) && encryptionStrength !== UNDEFINED_VALUE && (encryptionStrength < 1 || encryptionStrength > 3)) {
|
|
4235
4245
|
throw new Error(ERR_INVALID_ENCRYPTION_STRENGTH);
|
|
4236
4246
|
}
|
|
4237
4247
|
let rawExtraField = new Uint8Array();
|
|
@@ -4257,18 +4267,28 @@
|
|
|
4257
4267
|
let maximumCompressedSize = 0;
|
|
4258
4268
|
let maximumEntrySize = 0;
|
|
4259
4269
|
let uncompressedSize = 0;
|
|
4270
|
+
if (passThrough) {
|
|
4271
|
+
({ uncompressedSize } = options);
|
|
4272
|
+
if (uncompressedSize === UNDEFINED_VALUE) {
|
|
4273
|
+
throw new Error(ERR_UNDEFINED_UNCOMPRESSED_SIZE);
|
|
4274
|
+
}
|
|
4275
|
+
}
|
|
4260
4276
|
const zip64Enabled = zip64 === true;
|
|
4261
4277
|
if (reader) {
|
|
4262
4278
|
reader = initReader(reader);
|
|
4263
4279
|
await initStream(reader);
|
|
4264
|
-
if (
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
zip64
|
|
4268
|
-
|
|
4280
|
+
if (!passThrough) {
|
|
4281
|
+
if (reader.size === UNDEFINED_VALUE) {
|
|
4282
|
+
dataDescriptor = true;
|
|
4283
|
+
if (zip64 || zip64 === UNDEFINED_VALUE) {
|
|
4284
|
+
zip64 = true;
|
|
4285
|
+
uncompressedSize = maximumCompressedSize = MAX_32_BITS + 1;
|
|
4286
|
+
}
|
|
4287
|
+
} else {
|
|
4288
|
+
uncompressedSize = reader.size;
|
|
4289
|
+
maximumCompressedSize = getMaximumCompressedSize(uncompressedSize);
|
|
4269
4290
|
}
|
|
4270
4291
|
} else {
|
|
4271
|
-
uncompressedSize = reader.size;
|
|
4272
4292
|
maximumCompressedSize = getMaximumCompressedSize(uncompressedSize);
|
|
4273
4293
|
}
|
|
4274
4294
|
}
|
|
@@ -4286,6 +4306,8 @@
|
|
|
4286
4306
|
}
|
|
4287
4307
|
}
|
|
4288
4308
|
zip64 = zip64 || false;
|
|
4309
|
+
const encrypted = getOptionValue(zipWriter, options, "encrypted");
|
|
4310
|
+
const { signature } = options;
|
|
4289
4311
|
options = Object.assign({}, options, {
|
|
4290
4312
|
rawFilename,
|
|
4291
4313
|
rawComment,
|
|
@@ -4316,7 +4338,10 @@
|
|
|
4316
4338
|
msDosCompatible,
|
|
4317
4339
|
internalFileAttribute,
|
|
4318
4340
|
externalFileAttribute,
|
|
4319
|
-
useCompressionStream
|
|
4341
|
+
useCompressionStream,
|
|
4342
|
+
passThrough,
|
|
4343
|
+
encrypted: Boolean((password && getLength(password)) || (rawPassword && getLength(rawPassword))) || (passThrough && encrypted),
|
|
4344
|
+
signature
|
|
4320
4345
|
});
|
|
4321
4346
|
const headerInfo = getHeaderInfo(options);
|
|
4322
4347
|
const dataDescriptorInfo = getDataDescriptorInfo(options);
|
|
@@ -4527,7 +4552,8 @@
|
|
|
4527
4552
|
msDosCompatible,
|
|
4528
4553
|
internalFileAttribute,
|
|
4529
4554
|
externalFileAttribute,
|
|
4530
|
-
useCompressionStream
|
|
4555
|
+
useCompressionStream,
|
|
4556
|
+
passThrough
|
|
4531
4557
|
} = options;
|
|
4532
4558
|
const fileEntry = {
|
|
4533
4559
|
lock,
|
|
@@ -4548,9 +4574,14 @@
|
|
|
4548
4574
|
externalFileAttribute,
|
|
4549
4575
|
diskNumberStart
|
|
4550
4576
|
};
|
|
4577
|
+
let {
|
|
4578
|
+
signature,
|
|
4579
|
+
uncompressedSize
|
|
4580
|
+
} = options;
|
|
4551
4581
|
let compressedSize = 0;
|
|
4552
|
-
|
|
4553
|
-
|
|
4582
|
+
if (!passThrough) {
|
|
4583
|
+
uncompressedSize = 0;
|
|
4584
|
+
}
|
|
4554
4585
|
const { writable } = writer;
|
|
4555
4586
|
if (reader) {
|
|
4556
4587
|
reader.chunkSize = getChunkSize(config);
|
|
@@ -4566,9 +4597,9 @@
|
|
|
4566
4597
|
encryptionStrength,
|
|
4567
4598
|
zipCrypto: encrypted && zipCrypto,
|
|
4568
4599
|
passwordVerification: encrypted && zipCrypto && (rawLastModDate >> 8) & 0xFF,
|
|
4569
|
-
signed:
|
|
4570
|
-
compressed,
|
|
4571
|
-
encrypted,
|
|
4600
|
+
signed: !passThrough,
|
|
4601
|
+
compressed: compressed && !passThrough,
|
|
4602
|
+
encrypted: encrypted && !passThrough,
|
|
4572
4603
|
useWebWorkers,
|
|
4573
4604
|
useCompressionStream,
|
|
4574
4605
|
transferStreams: false
|
|
@@ -4577,9 +4608,11 @@
|
|
|
4577
4608
|
streamOptions: { signal, size, onstart, onprogress, onend }
|
|
4578
4609
|
};
|
|
4579
4610
|
const result = await runWorker({ readable, writable }, workerOptions);
|
|
4580
|
-
uncompressedSize = result.inputSize;
|
|
4581
4611
|
compressedSize = result.outputSize;
|
|
4582
|
-
|
|
4612
|
+
if (!passThrough) {
|
|
4613
|
+
uncompressedSize = result.inputSize;
|
|
4614
|
+
signature = result.signature;
|
|
4615
|
+
}
|
|
4583
4616
|
writable.size += uncompressedSize;
|
|
4584
4617
|
} else {
|
|
4585
4618
|
await writeData(writable, localHeaderArray);
|
|
@@ -4622,6 +4655,7 @@
|
|
|
4622
4655
|
creationDate,
|
|
4623
4656
|
lastAccessDate,
|
|
4624
4657
|
encrypted,
|
|
4658
|
+
zipCrypto,
|
|
4625
4659
|
size: metadataSize + compressedSize,
|
|
4626
4660
|
compressionMethod,
|
|
4627
4661
|
version,
|
|
@@ -4643,8 +4677,6 @@
|
|
|
4643
4677
|
lastModDate,
|
|
4644
4678
|
lastAccessDate,
|
|
4645
4679
|
creationDate,
|
|
4646
|
-
rawPassword,
|
|
4647
|
-
password,
|
|
4648
4680
|
level,
|
|
4649
4681
|
zip64,
|
|
4650
4682
|
zipCrypto,
|
|
@@ -4653,10 +4685,10 @@
|
|
|
4653
4685
|
directory,
|
|
4654
4686
|
rawExtraField,
|
|
4655
4687
|
encryptionStrength,
|
|
4656
|
-
extendedTimestamp
|
|
4688
|
+
extendedTimestamp,
|
|
4689
|
+
encrypted
|
|
4657
4690
|
} = options;
|
|
4658
4691
|
const compressed = level !== 0 && !directory;
|
|
4659
|
-
const encrypted = Boolean((password && getLength(password)) || (rawPassword && getLength(rawPassword)));
|
|
4660
4692
|
let version = options.version;
|
|
4661
4693
|
let rawExtraFieldAES;
|
|
4662
4694
|
if (encrypted && !zipCrypto) {
|
|
@@ -4715,6 +4747,15 @@
|
|
|
4715
4747
|
let compressionMethod = COMPRESSION_METHOD_STORE;
|
|
4716
4748
|
if (compressed) {
|
|
4717
4749
|
compressionMethod = COMPRESSION_METHOD_DEFLATE;
|
|
4750
|
+
if (level >= 1 && level < 3) {
|
|
4751
|
+
bitFlag = bitFlag | 0b110;
|
|
4752
|
+
}
|
|
4753
|
+
if (level >= 3 && level < 5) {
|
|
4754
|
+
bitFlag = bitFlag | 0b01;
|
|
4755
|
+
}
|
|
4756
|
+
if (level === 9) {
|
|
4757
|
+
bitFlag = bitFlag | 0b10;
|
|
4758
|
+
}
|
|
4718
4759
|
}
|
|
4719
4760
|
if (zip64) {
|
|
4720
4761
|
version = version > VERSION_ZIP64 ? version : VERSION_ZIP64;
|
|
@@ -5215,6 +5256,7 @@
|
|
|
5215
5256
|
exports.ERR_ITERATOR_COMPLETED_TOO_SOON = ERR_ITERATOR_COMPLETED_TOO_SOON;
|
|
5216
5257
|
exports.ERR_LOCAL_FILE_HEADER_NOT_FOUND = ERR_LOCAL_FILE_HEADER_NOT_FOUND;
|
|
5217
5258
|
exports.ERR_SPLIT_ZIP_FILE = ERR_SPLIT_ZIP_FILE;
|
|
5259
|
+
exports.ERR_UNDEFINED_UNCOMPRESSED_SIZE = ERR_UNDEFINED_UNCOMPRESSED_SIZE;
|
|
5218
5260
|
exports.ERR_UNSUPPORTED_COMPRESSION = ERR_UNSUPPORTED_COMPRESSION;
|
|
5219
5261
|
exports.ERR_UNSUPPORTED_ENCRYPTION = ERR_UNSUPPORTED_ENCRYPTION;
|
|
5220
5262
|
exports.ERR_UNSUPPORTED_FORMAT = ERR_UNSUPPORTED_FORMAT;
|