@zip.js/zip.js 2.7.47 → 2.7.49
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 +100 -31
- package/dist/zip-fs-full.min.js +1 -1
- package/dist/zip-fs.js +100 -31
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-full.js +76 -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 +76 -28
- package/dist/zip.min.js +1 -1
- package/index.cjs +100 -31
- package/index.d.ts +44 -21
- 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 +68 -25
- package/package.json +3 -3
package/dist/zip-fs.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
|
|
|
@@ -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);
|
|
@@ -4227,10 +4237,11 @@
|
|
|
4227
4237
|
const bufferedWrite = getOptionValue(zipWriter, options, "bufferedWrite");
|
|
4228
4238
|
const dataDescriptorSignature = getOptionValue(zipWriter, options, "dataDescriptorSignature", false);
|
|
4229
4239
|
const signal = getOptionValue(zipWriter, options, "signal");
|
|
4240
|
+
const useUnicodeFileNames = getOptionValue(zipWriter, options, "useUnicodeFileNames", true);
|
|
4230
4241
|
const useCompressionStream = getOptionValue(zipWriter, options, "useCompressionStream");
|
|
4231
4242
|
let dataDescriptor = getOptionValue(zipWriter, options, "dataDescriptor", true);
|
|
4232
4243
|
let zip64 = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIP64);
|
|
4233
|
-
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)) {
|
|
4234
4245
|
throw new Error(ERR_INVALID_ENCRYPTION_STRENGTH);
|
|
4235
4246
|
}
|
|
4236
4247
|
let rawExtraField = new Uint8Array();
|
|
@@ -4256,18 +4267,28 @@
|
|
|
4256
4267
|
let maximumCompressedSize = 0;
|
|
4257
4268
|
let maximumEntrySize = 0;
|
|
4258
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
|
+
}
|
|
4259
4276
|
const zip64Enabled = zip64 === true;
|
|
4260
4277
|
if (reader) {
|
|
4261
4278
|
reader = initReader(reader);
|
|
4262
4279
|
await initStream(reader);
|
|
4263
|
-
if (
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
zip64
|
|
4267
|
-
|
|
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);
|
|
4268
4290
|
}
|
|
4269
4291
|
} else {
|
|
4270
|
-
uncompressedSize = reader.size;
|
|
4271
4292
|
maximumCompressedSize = getMaximumCompressedSize(uncompressedSize);
|
|
4272
4293
|
}
|
|
4273
4294
|
}
|
|
@@ -4285,6 +4306,8 @@
|
|
|
4285
4306
|
}
|
|
4286
4307
|
}
|
|
4287
4308
|
zip64 = zip64 || false;
|
|
4309
|
+
const encrypted = getOptionValue(zipWriter, options, "encrypted");
|
|
4310
|
+
const { signature } = options;
|
|
4288
4311
|
options = Object.assign({}, options, {
|
|
4289
4312
|
rawFilename,
|
|
4290
4313
|
rawComment,
|
|
@@ -4308,13 +4331,17 @@
|
|
|
4308
4331
|
zipCrypto,
|
|
4309
4332
|
bufferedWrite,
|
|
4310
4333
|
keepOrder,
|
|
4334
|
+
useUnicodeFileNames,
|
|
4311
4335
|
dataDescriptor,
|
|
4312
4336
|
dataDescriptorSignature,
|
|
4313
4337
|
signal,
|
|
4314
4338
|
msDosCompatible,
|
|
4315
4339
|
internalFileAttribute,
|
|
4316
4340
|
externalFileAttribute,
|
|
4317
|
-
useCompressionStream
|
|
4341
|
+
useCompressionStream,
|
|
4342
|
+
passThrough,
|
|
4343
|
+
encrypted: Boolean((password && getLength(password)) || (rawPassword && getLength(rawPassword))) || (passThrough && encrypted),
|
|
4344
|
+
signature
|
|
4318
4345
|
});
|
|
4319
4346
|
const headerInfo = getHeaderInfo(options);
|
|
4320
4347
|
const dataDescriptorInfo = getDataDescriptorInfo(options);
|
|
@@ -4525,7 +4552,8 @@
|
|
|
4525
4552
|
msDosCompatible,
|
|
4526
4553
|
internalFileAttribute,
|
|
4527
4554
|
externalFileAttribute,
|
|
4528
|
-
useCompressionStream
|
|
4555
|
+
useCompressionStream,
|
|
4556
|
+
passThrough
|
|
4529
4557
|
} = options;
|
|
4530
4558
|
const fileEntry = {
|
|
4531
4559
|
lock,
|
|
@@ -4546,9 +4574,14 @@
|
|
|
4546
4574
|
externalFileAttribute,
|
|
4547
4575
|
diskNumberStart
|
|
4548
4576
|
};
|
|
4577
|
+
let {
|
|
4578
|
+
signature,
|
|
4579
|
+
uncompressedSize
|
|
4580
|
+
} = options;
|
|
4549
4581
|
let compressedSize = 0;
|
|
4550
|
-
|
|
4551
|
-
|
|
4582
|
+
if (!passThrough) {
|
|
4583
|
+
uncompressedSize = 0;
|
|
4584
|
+
}
|
|
4552
4585
|
const { writable } = writer;
|
|
4553
4586
|
if (reader) {
|
|
4554
4587
|
reader.chunkSize = getChunkSize(config);
|
|
@@ -4564,9 +4597,9 @@
|
|
|
4564
4597
|
encryptionStrength,
|
|
4565
4598
|
zipCrypto: encrypted && zipCrypto,
|
|
4566
4599
|
passwordVerification: encrypted && zipCrypto && (rawLastModDate >> 8) & 0xFF,
|
|
4567
|
-
signed:
|
|
4568
|
-
compressed,
|
|
4569
|
-
encrypted,
|
|
4600
|
+
signed: !passThrough,
|
|
4601
|
+
compressed: compressed && !passThrough,
|
|
4602
|
+
encrypted: encrypted && !passThrough,
|
|
4570
4603
|
useWebWorkers,
|
|
4571
4604
|
useCompressionStream,
|
|
4572
4605
|
transferStreams: false
|
|
@@ -4575,9 +4608,11 @@
|
|
|
4575
4608
|
streamOptions: { signal, size, onstart, onprogress, onend }
|
|
4576
4609
|
};
|
|
4577
4610
|
const result = await runWorker({ readable, writable }, workerOptions);
|
|
4578
|
-
uncompressedSize = result.inputSize;
|
|
4579
4611
|
compressedSize = result.outputSize;
|
|
4580
|
-
|
|
4612
|
+
if (!passThrough) {
|
|
4613
|
+
uncompressedSize = result.inputSize;
|
|
4614
|
+
signature = result.signature;
|
|
4615
|
+
}
|
|
4581
4616
|
writable.size += uncompressedSize;
|
|
4582
4617
|
} else {
|
|
4583
4618
|
await writeData(writable, localHeaderArray);
|
|
@@ -4620,6 +4655,7 @@
|
|
|
4620
4655
|
creationDate,
|
|
4621
4656
|
lastAccessDate,
|
|
4622
4657
|
encrypted,
|
|
4658
|
+
zipCrypto,
|
|
4623
4659
|
size: metadataSize + compressedSize,
|
|
4624
4660
|
compressionMethod,
|
|
4625
4661
|
version,
|
|
@@ -4641,19 +4677,18 @@
|
|
|
4641
4677
|
lastModDate,
|
|
4642
4678
|
lastAccessDate,
|
|
4643
4679
|
creationDate,
|
|
4644
|
-
rawPassword,
|
|
4645
|
-
password,
|
|
4646
4680
|
level,
|
|
4647
4681
|
zip64,
|
|
4648
4682
|
zipCrypto,
|
|
4683
|
+
useUnicodeFileNames,
|
|
4649
4684
|
dataDescriptor,
|
|
4650
4685
|
directory,
|
|
4651
4686
|
rawExtraField,
|
|
4652
4687
|
encryptionStrength,
|
|
4653
|
-
extendedTimestamp
|
|
4688
|
+
extendedTimestamp,
|
|
4689
|
+
encrypted
|
|
4654
4690
|
} = options;
|
|
4655
4691
|
const compressed = level !== 0 && !directory;
|
|
4656
|
-
const encrypted = Boolean((password && getLength(password)) || (rawPassword && getLength(rawPassword)));
|
|
4657
4692
|
let version = options.version;
|
|
4658
4693
|
let rawExtraFieldAES;
|
|
4659
4694
|
if (encrypted && !zipCrypto) {
|
|
@@ -4702,13 +4737,25 @@
|
|
|
4702
4737
|
} else {
|
|
4703
4738
|
rawExtraFieldNTFS = rawExtraFieldExtendedTimestamp = new Uint8Array();
|
|
4704
4739
|
}
|
|
4705
|
-
let bitFlag =
|
|
4740
|
+
let bitFlag = 0;
|
|
4741
|
+
if (useUnicodeFileNames) {
|
|
4742
|
+
bitFlag = bitFlag | BITFLAG_LANG_ENCODING_FLAG;
|
|
4743
|
+
}
|
|
4706
4744
|
if (dataDescriptor) {
|
|
4707
4745
|
bitFlag = bitFlag | BITFLAG_DATA_DESCRIPTOR;
|
|
4708
4746
|
}
|
|
4709
4747
|
let compressionMethod = COMPRESSION_METHOD_STORE;
|
|
4710
4748
|
if (compressed) {
|
|
4711
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
|
+
}
|
|
4712
4759
|
}
|
|
4713
4760
|
if (zip64) {
|
|
4714
4761
|
version = version > VERSION_ZIP64 ? version : VERSION_ZIP64;
|
|
@@ -5194,7 +5241,8 @@
|
|
|
5194
5241
|
id: fs.entries.length,
|
|
5195
5242
|
parent,
|
|
5196
5243
|
children: [],
|
|
5197
|
-
uncompressedSize: params.uncompressedSize || 0
|
|
5244
|
+
uncompressedSize: params.uncompressedSize || 0,
|
|
5245
|
+
passThrough: params.passThrough
|
|
5198
5246
|
});
|
|
5199
5247
|
fs.entries.push(zipEntry);
|
|
5200
5248
|
if (parent) {
|
|
@@ -5537,7 +5585,8 @@
|
|
|
5537
5585
|
importedEntries.push(addChild(parent, name, {
|
|
5538
5586
|
data: entry,
|
|
5539
5587
|
Reader: getZipBlobReader(Object.assign({}, options)),
|
|
5540
|
-
uncompressedSize: entry.uncompressedSize
|
|
5588
|
+
uncompressedSize: entry.uncompressedSize,
|
|
5589
|
+
passThrough: options.passThrough
|
|
5541
5590
|
}));
|
|
5542
5591
|
}
|
|
5543
5592
|
} catch (error) {
|
|
@@ -5853,8 +5902,17 @@
|
|
|
5853
5902
|
comment,
|
|
5854
5903
|
lastModDate,
|
|
5855
5904
|
creationDate,
|
|
5856
|
-
lastAccessDate
|
|
5905
|
+
lastAccessDate,
|
|
5906
|
+
uncompressedSize,
|
|
5907
|
+
encrypted,
|
|
5908
|
+
zipCrypto,
|
|
5909
|
+
signature,
|
|
5910
|
+
compressionMethod
|
|
5857
5911
|
} = child.data;
|
|
5912
|
+
let level;
|
|
5913
|
+
if (compressionMethod === 0) {
|
|
5914
|
+
level = 0;
|
|
5915
|
+
}
|
|
5858
5916
|
zipEntryOptions = {
|
|
5859
5917
|
externalFileAttribute,
|
|
5860
5918
|
versionMadeBy,
|
|
@@ -5863,6 +5921,16 @@
|
|
|
5863
5921
|
creationDate,
|
|
5864
5922
|
lastAccessDate
|
|
5865
5923
|
};
|
|
5924
|
+
if (child.passThrough) {
|
|
5925
|
+
zipEntryOptions = Object.assign(zipEntryOptions, {
|
|
5926
|
+
passThrough: true,
|
|
5927
|
+
encrypted,
|
|
5928
|
+
zipCrypto,
|
|
5929
|
+
signature,
|
|
5930
|
+
uncompressedSize,
|
|
5931
|
+
level
|
|
5932
|
+
});
|
|
5933
|
+
}
|
|
5866
5934
|
}
|
|
5867
5935
|
await zipWriter.add(name, child.reader, Object.assign({
|
|
5868
5936
|
directory: child.directory
|
|
@@ -6047,6 +6115,7 @@
|
|
|
6047
6115
|
exports.ERR_ITERATOR_COMPLETED_TOO_SOON = ERR_ITERATOR_COMPLETED_TOO_SOON;
|
|
6048
6116
|
exports.ERR_LOCAL_FILE_HEADER_NOT_FOUND = ERR_LOCAL_FILE_HEADER_NOT_FOUND;
|
|
6049
6117
|
exports.ERR_SPLIT_ZIP_FILE = ERR_SPLIT_ZIP_FILE;
|
|
6118
|
+
exports.ERR_UNDEFINED_UNCOMPRESSED_SIZE = ERR_UNDEFINED_UNCOMPRESSED_SIZE;
|
|
6050
6119
|
exports.ERR_UNSUPPORTED_COMPRESSION = ERR_UNSUPPORTED_COMPRESSION;
|
|
6051
6120
|
exports.ERR_UNSUPPORTED_ENCRYPTION = ERR_UNSUPPORTED_ENCRYPTION;
|
|
6052
6121
|
exports.ERR_UNSUPPORTED_FORMAT = ERR_UNSUPPORTED_FORMAT;
|