@zip.js/zip.js 2.8.52 → 2.8.53
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 +154 -52
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +154 -51
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +157 -52
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +143 -47
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +157 -52
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +157 -51
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +157 -51
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +154 -51
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +154 -51
- package/dist/zip-native.min.js +1 -1
- package/dist/zip.js +154 -51
- package/dist/zip.min.js +1 -1
- package/eslint.config.mjs +1 -1
- package/index-native.cjs +157 -51
- package/index-native.min.js +1 -1
- package/index.cjs +157 -51
- package/index.d.cts +278 -40
- package/index.d.ts +278 -40
- package/index.min.js +1 -1
- package/lib/core/codec-worker-web.js +13 -4
- package/lib/core/constants.js +5 -0
- package/lib/core/io.js +11 -2
- package/lib/core/options.js +2 -0
- package/lib/core/zip-entry.js +8 -0
- package/lib/core/zip-reader.js +91 -34
- package/lib/core/zip-writer.js +36 -12
- package/lib/zip-core-writer.js +1 -0
- package/package.json +5 -3
package/dist/zip-fs-external.js
CHANGED
|
@@ -93,6 +93,9 @@ const VERSION_DEFLATE = 0x14;
|
|
|
93
93
|
const VERSION_ZIP64 = 0x2D;
|
|
94
94
|
const VERSION_AES = 0x33;
|
|
95
95
|
|
|
96
|
+
const VERSION_MADE_BY_MSDOS = 0x0014;
|
|
97
|
+
const VERSION_MADE_BY_UNIX = 0x0300;
|
|
98
|
+
|
|
96
99
|
const DIRECTORY_SIGNATURE = "/";
|
|
97
100
|
|
|
98
101
|
const HEADER_SIZE = 30;
|
|
@@ -2787,6 +2790,7 @@ function createWebWorkerInterface(workerData, config) {
|
|
|
2787
2790
|
worker,
|
|
2788
2791
|
workerAlive: false,
|
|
2789
2792
|
terminated: false,
|
|
2793
|
+
startupError: null,
|
|
2790
2794
|
interface: {
|
|
2791
2795
|
run: async () => {
|
|
2792
2796
|
try {
|
|
@@ -2814,6 +2818,13 @@ function createWebWorkerInterface(workerData, config) {
|
|
|
2814
2818
|
}
|
|
2815
2819
|
|
|
2816
2820
|
async function runWebWorker(workerData, config) {
|
|
2821
|
+
if (!workerData.worker) {
|
|
2822
|
+
const { startupError } = workerData;
|
|
2823
|
+
workerData.startupError = null;
|
|
2824
|
+
const error = startupError || new Error(ERR_WORKER_STARTUP_TIMEOUT);
|
|
2825
|
+
error.workerStartupFailed = true;
|
|
2826
|
+
throw error;
|
|
2827
|
+
}
|
|
2817
2828
|
let resolveResult, rejectResult;
|
|
2818
2829
|
const result = new Promise((resolve, reject) => {
|
|
2819
2830
|
resolveResult = resolve;
|
|
@@ -3027,11 +3038,12 @@ function onWorkerError(event, workerData) {
|
|
|
3027
3038
|
if (!workerAlive) {
|
|
3028
3039
|
workerData.worker = null;
|
|
3029
3040
|
}
|
|
3041
|
+
let error = event.error || new Error(event.message || ERROR_EVENT_TYPE);
|
|
3042
|
+
if (!workerAlive) {
|
|
3043
|
+
error = Object.assign(new Error(error.message || ERROR_EVENT_TYPE), { workerStartupFailed: true });
|
|
3044
|
+
workerData.startupError = error;
|
|
3045
|
+
}
|
|
3030
3046
|
if (rejectResult) {
|
|
3031
|
-
let error = event.error || new Error(event.message || ERROR_EVENT_TYPE);
|
|
3032
|
-
if (!workerAlive) {
|
|
3033
|
-
error = Object.assign(new Error(error.message || ERROR_EVENT_TYPE), { workerStartupFailed: true });
|
|
3034
|
-
}
|
|
3035
3047
|
rejectResult(error);
|
|
3036
3048
|
if (writer) {
|
|
3037
3049
|
writer.releaseLock();
|
|
@@ -4080,9 +4092,8 @@ class SplitDataReader extends Reader {
|
|
|
4080
4092
|
|
|
4081
4093
|
async init() {
|
|
4082
4094
|
const reader = this;
|
|
4083
|
-
const { readers } = reader;
|
|
4084
4095
|
reader.lastDiskNumber = 0;
|
|
4085
|
-
await Promise.all(readers.map(
|
|
4096
|
+
const readers = reader.readers = await Promise.all(reader.readers.map(initDiskReader));
|
|
4086
4097
|
reader.diskOffsets = readers.map(diskReader => {
|
|
4087
4098
|
const diskOffset = reader.size;
|
|
4088
4099
|
reader.size += diskReader.size;
|
|
@@ -4277,6 +4288,16 @@ async function initStream(stream, initSize) {
|
|
|
4277
4288
|
}
|
|
4278
4289
|
}
|
|
4279
4290
|
|
|
4291
|
+
async function initDiskReader(diskReader) {
|
|
4292
|
+
diskReader = new GenericReader(diskReader);
|
|
4293
|
+
await initStream(diskReader);
|
|
4294
|
+
if (diskReader.size === UNDEFINED_VALUE || !diskReader.readUint8Array) {
|
|
4295
|
+
diskReader = new BlobReader(await streamToBlob(diskReader.readable));
|
|
4296
|
+
await initStream(diskReader);
|
|
4297
|
+
}
|
|
4298
|
+
return diskReader;
|
|
4299
|
+
}
|
|
4300
|
+
|
|
4280
4301
|
function readUint8Array(reader, offset, size) {
|
|
4281
4302
|
return reader.readUint8Array(offset, size);
|
|
4282
4303
|
}
|
|
@@ -4435,6 +4456,10 @@ const PROPERTY_NAME_SETUID = "setuid";
|
|
|
4435
4456
|
const PROPERTY_NAME_SETGID = "setgid";
|
|
4436
4457
|
const PROPERTY_NAME_STICKY = "sticky";
|
|
4437
4458
|
const PROPERTY_NAME_BITFLAG = "bitFlag";
|
|
4459
|
+
const PROPERTY_NAME_RAW_BITFLAG = "rawBitFlag";
|
|
4460
|
+
const PROPERTY_NAME_FILENAME_LENGTH = "filenameLength";
|
|
4461
|
+
const PROPERTY_NAME_EXTRA_FIELD_LENGTH = "extraFieldLength";
|
|
4462
|
+
const PROPERTY_NAME_UNIX_EXTERNAL_UPPER = "unixExternalUpper";
|
|
4438
4463
|
const PROPERTY_NAME_FILENAME_UTF8 = "filenameUTF8";
|
|
4439
4464
|
const PROPERTY_NAME_COMMENT_UTF8 = "commentUTF8";
|
|
4440
4465
|
const PROPERTY_NAME_RAW_EXTRA_FIELD = "rawExtraField";
|
|
@@ -4487,10 +4512,14 @@ const PROPERTY_NAMES = [
|
|
|
4487
4512
|
PROPERTY_NAME_UID,
|
|
4488
4513
|
PROPERTY_NAME_GID,
|
|
4489
4514
|
PROPERTY_NAME_UNIX_MODE,
|
|
4515
|
+
PROPERTY_NAME_UNIX_EXTERNAL_UPPER,
|
|
4490
4516
|
PROPERTY_NAME_SETUID,
|
|
4491
4517
|
PROPERTY_NAME_SETGID,
|
|
4492
4518
|
PROPERTY_NAME_STICKY,
|
|
4493
4519
|
PROPERTY_NAME_BITFLAG,
|
|
4520
|
+
PROPERTY_NAME_RAW_BITFLAG,
|
|
4521
|
+
PROPERTY_NAME_FILENAME_LENGTH,
|
|
4522
|
+
PROPERTY_NAME_EXTRA_FIELD_LENGTH,
|
|
4494
4523
|
PROPERTY_NAME_FILENAME_UTF8,
|
|
4495
4524
|
PROPERTY_NAME_COMMENT_UTF8,
|
|
4496
4525
|
PROPERTY_NAME_RAW_EXTRA_FIELD,
|
|
@@ -4552,6 +4581,7 @@ const OPTION_CHECK_PASSWORD_ONLY = "checkPasswordOnly";
|
|
|
4552
4581
|
const OPTION_CHECK_OVERLAPPING_ENTRY_ONLY = "checkOverlappingEntryOnly";
|
|
4553
4582
|
const OPTION_CHECK_OVERLAPPING_ENTRY = "checkOverlappingEntry";
|
|
4554
4583
|
const OPTION_CHECK_AMBIGUITY = "checkAmbiguity";
|
|
4584
|
+
const OPTION_CHECK_LOCAL_DIRECTORY = "checkLocalDirectory";
|
|
4555
4585
|
const OPTION_CHECK_SIGNATURE = "checkSignature";
|
|
4556
4586
|
const OPTION_CHECK_CRC32 = "checkCrc32";
|
|
4557
4587
|
const OPTION_CHECK_AUTHENTICATION_CODE = "checkAuthenticationCode";
|
|
@@ -4683,7 +4713,7 @@ class ZipReader {
|
|
|
4683
4713
|
if (reader.size < END_OF_CENTRAL_DIR_LENGTH) {
|
|
4684
4714
|
throw new Error(ERR_BAD_FORMAT);
|
|
4685
4715
|
}
|
|
4686
|
-
const strictness = getStrictness(
|
|
4716
|
+
const strictness = getStrictness(options, zipReader.options);
|
|
4687
4717
|
const checkAmbiguity = strictness == STRICTNESS_STRICT;
|
|
4688
4718
|
const rejectAmbiguousEndOfDirectory = strictness != STRICTNESS_TOLERANT;
|
|
4689
4719
|
const maxAppendedDataSize = getMaxAppendedDataSize(getOptionValue$1(zipReader, options, OPTION_MAX_APPENDED_DATA_SIZE), strictness);
|
|
@@ -4905,6 +4935,7 @@ class ZipReader {
|
|
|
4905
4935
|
index: indexFile,
|
|
4906
4936
|
versionMadeBy,
|
|
4907
4937
|
msDosCompatible,
|
|
4938
|
+
zip64: false,
|
|
4908
4939
|
compressedSize: 0,
|
|
4909
4940
|
uncompressedSize: 0,
|
|
4910
4941
|
commentLength,
|
|
@@ -5115,9 +5146,12 @@ let ZipEntry$1 = class ZipEntry {
|
|
|
5115
5146
|
extraFieldLength,
|
|
5116
5147
|
filenameLength
|
|
5117
5148
|
} = localDirectory;
|
|
5118
|
-
const
|
|
5149
|
+
const checkLocalDirectoryOption = getOptionValue$1(zipEntry, options, OPTION_CHECK_LOCAL_DIRECTORY);
|
|
5150
|
+
const entryStrictness = getStrictness(options, zipEntry.options);
|
|
5151
|
+
const checkLocalDirectory = getCheckLocalDirectory(checkLocalDirectoryOption, entryStrictness);
|
|
5152
|
+
const checkLocalFilename = getCheckLocalFilename(checkLocalDirectoryOption, entryStrictness);
|
|
5119
5153
|
let rawLocalFilename = EMPTY_UINT8_ARRAY;
|
|
5120
|
-
if (
|
|
5154
|
+
if (checkLocalFilename && (filenameLength || extraFieldLength)) {
|
|
5121
5155
|
const trailingDataArray = await readUint8Array(reader, localHeaderOffset + HEADER_SIZE, filenameLength + extraFieldLength);
|
|
5122
5156
|
rawLocalFilename = trailingDataArray.subarray(0, filenameLength);
|
|
5123
5157
|
localDirectory.rawExtraField = trailingDataArray.subarray(filenameLength);
|
|
@@ -5126,17 +5160,26 @@ let ZipEntry$1 = class ZipEntry {
|
|
|
5126
5160
|
await readUint8Array(reader, localHeaderOffset + HEADER_SIZE + filenameLength, extraFieldLength) :
|
|
5127
5161
|
EMPTY_UINT8_ARRAY;
|
|
5128
5162
|
}
|
|
5163
|
+
if (checkLocalFilename) {
|
|
5164
|
+
localDirectory.rawFilename = rawLocalFilename;
|
|
5165
|
+
}
|
|
5129
5166
|
readCommonFooter(zipEntry, localDirectory, dataView, 4, true);
|
|
5130
|
-
if (
|
|
5131
|
-
|
|
5167
|
+
if (checkLocalDirectory) {
|
|
5168
|
+
validateLocalDirectory(zipEntry, localDirectory, rawLocalFilename, checkLocalFilename);
|
|
5132
5169
|
}
|
|
5133
|
-
const { lastAccessDate, creationDate } = localDirectory;
|
|
5170
|
+
const { lastAccessDate, creationDate, uid, gid } = localDirectory;
|
|
5134
5171
|
if (lastAccessDate) {
|
|
5135
5172
|
fileEntry.lastAccessDate = lastAccessDate;
|
|
5136
5173
|
}
|
|
5137
5174
|
if (creationDate) {
|
|
5138
5175
|
fileEntry.creationDate = creationDate;
|
|
5139
5176
|
}
|
|
5177
|
+
if (uid !== UNDEFINED_VALUE && fileEntry.uid === UNDEFINED_VALUE) {
|
|
5178
|
+
fileEntry.uid = uid;
|
|
5179
|
+
}
|
|
5180
|
+
if (gid !== UNDEFINED_VALUE && fileEntry.gid === UNDEFINED_VALUE) {
|
|
5181
|
+
fileEntry.gid = gid;
|
|
5182
|
+
}
|
|
5140
5183
|
const encrypted = zipEntry.encrypted && localDirectory.encrypted && !passThrough;
|
|
5141
5184
|
const zipCrypto = encrypted && !extraFieldAES;
|
|
5142
5185
|
if (!passThrough) {
|
|
@@ -5372,10 +5415,12 @@ function readCommonFooter(fileEntry, directory, dataView, offset, localDirectory
|
|
|
5372
5415
|
directory.extraFieldNTFS = extraFieldNTFS;
|
|
5373
5416
|
}
|
|
5374
5417
|
const extraFieldUnix = extraField.get(EXTRAFIELD_TYPE_UNIX);
|
|
5418
|
+
let unixIdsRead;
|
|
5375
5419
|
if (extraFieldUnix) {
|
|
5376
|
-
readExtraFieldUnix(extraFieldUnix, directory, false);
|
|
5420
|
+
unixIdsRead = readExtraFieldUnix(extraFieldUnix, directory, false);
|
|
5377
5421
|
directory.extraFieldUnix = extraFieldUnix;
|
|
5378
|
-
}
|
|
5422
|
+
}
|
|
5423
|
+
if (!unixIdsRead) {
|
|
5379
5424
|
const extraFieldInfoZip = extraField.get(EXTRAFIELD_TYPE_INFOZIP);
|
|
5380
5425
|
if (extraFieldInfoZip) {
|
|
5381
5426
|
readExtraFieldUnix(extraFieldInfoZip, directory, true);
|
|
@@ -5478,7 +5523,7 @@ function readExtraFieldNTFS(extraFieldNTFS, directory) {
|
|
|
5478
5523
|
const creationDate = getDateNTFS(rawCreationDate);
|
|
5479
5524
|
const extraFieldData = { lastModDate, lastAccessDate, creationDate };
|
|
5480
5525
|
Object.assign(extraFieldNTFS, extraFieldData);
|
|
5481
|
-
Object.assign(directory, extraFieldData);
|
|
5526
|
+
Object.assign(directory, extraFieldData, { rawLastAccessDate, rawCreationDate });
|
|
5482
5527
|
}
|
|
5483
5528
|
}
|
|
5484
5529
|
|
|
@@ -5522,6 +5567,7 @@ function readExtraFieldUnix(extraField, directory, isInfoZip) {
|
|
|
5522
5567
|
if (gid !== UNDEFINED_VALUE) {
|
|
5523
5568
|
directory.gid = gid;
|
|
5524
5569
|
}
|
|
5570
|
+
return uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE;
|
|
5525
5571
|
} catch {
|
|
5526
5572
|
// ignored
|
|
5527
5573
|
}
|
|
@@ -5594,26 +5640,25 @@ async function detectOverlappingEntry({
|
|
|
5594
5640
|
}
|
|
5595
5641
|
if (dataDescriptorLength) {
|
|
5596
5642
|
const dataDescriptorArray = await readUint8Array(reader, dataOffset + compressedSize, dataDescriptorLength + DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH);
|
|
5597
|
-
const
|
|
5598
|
-
|
|
5599
|
-
|
|
5600
|
-
|
|
5601
|
-
|
|
5602
|
-
|
|
5603
|
-
if (extraFieldZip64) {
|
|
5604
|
-
readCompressedSize = getBigUint64(getDataView(dataDescriptorArray), 8);
|
|
5605
|
-
readUncompressedSize = getBigUint64(getDataView(dataDescriptorArray), 16);
|
|
5606
|
-
} else {
|
|
5607
|
-
readCompressedSize = getUint32(getDataView(dataDescriptorArray), 8);
|
|
5608
|
-
readUncompressedSize = getUint32(getDataView(dataDescriptorArray), 12);
|
|
5609
|
-
}
|
|
5610
|
-
const matchCrc32 = (fileEntry.encrypted && !fileEntry.zipCrypto) || readCrc32 == crc32;
|
|
5643
|
+
const dataDescriptorView = getDataView(dataDescriptorArray);
|
|
5644
|
+
let signature = dataDescriptorArray.length == dataDescriptorLength + DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH &&
|
|
5645
|
+
getUint32(dataDescriptorView, 0) == DATA_DESCRIPTOR_RECORD_SIGNATURE;
|
|
5646
|
+
if (signature) {
|
|
5647
|
+
const signedDataDescriptor = readDataDescriptor(dataDescriptorView, DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH, extraFieldZip64);
|
|
5648
|
+
const matchCrc32 = (fileEntry.encrypted && !fileEntry.zipCrypto) || signedDataDescriptor.crc32 == crc32;
|
|
5611
5649
|
if (matchCrc32 &&
|
|
5612
|
-
|
|
5613
|
-
|
|
5650
|
+
signedDataDescriptor.compressedSize == compressedSize &&
|
|
5651
|
+
signedDataDescriptor.uncompressedSize == uncompressedSize) {
|
|
5614
5652
|
dataDescriptorLength += DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH;
|
|
5653
|
+
} else {
|
|
5654
|
+
signature = false;
|
|
5615
5655
|
}
|
|
5616
5656
|
}
|
|
5657
|
+
if (dataDescriptorArray.length >= dataDescriptorLength) {
|
|
5658
|
+
const localDataDescriptor = readDataDescriptor(dataDescriptorView, signature ? DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH : 0, extraFieldZip64);
|
|
5659
|
+
localDataDescriptor.signature = signature;
|
|
5660
|
+
fileEntry.localDirectory.dataDescriptor = localDataDescriptor;
|
|
5661
|
+
}
|
|
5617
5662
|
}
|
|
5618
5663
|
const range = {
|
|
5619
5664
|
start: offset,
|
|
@@ -5630,6 +5675,20 @@ async function detectOverlappingEntry({
|
|
|
5630
5675
|
readRanges.set(index, range);
|
|
5631
5676
|
}
|
|
5632
5677
|
|
|
5678
|
+
function readDataDescriptor(dataDescriptorView, offset, extraFieldZip64) {
|
|
5679
|
+
const crc32 = getUint32(dataDescriptorView, offset);
|
|
5680
|
+
let compressedSize;
|
|
5681
|
+
let uncompressedSize;
|
|
5682
|
+
if (extraFieldZip64) {
|
|
5683
|
+
compressedSize = getBigUint64(dataDescriptorView, offset + 4);
|
|
5684
|
+
uncompressedSize = getBigUint64(dataDescriptorView, offset + 12);
|
|
5685
|
+
} else {
|
|
5686
|
+
compressedSize = getUint32(dataDescriptorView, offset + 4);
|
|
5687
|
+
uncompressedSize = getUint32(dataDescriptorView, offset + 8);
|
|
5688
|
+
}
|
|
5689
|
+
return { crc32, compressedSize, uncompressedSize };
|
|
5690
|
+
}
|
|
5691
|
+
|
|
5633
5692
|
function getDiskOffset$1(reader, diskNumber) {
|
|
5634
5693
|
return reader.getDiskOffset ? reader.getDiskOffset(diskNumber) : 0;
|
|
5635
5694
|
}
|
|
@@ -5638,14 +5697,40 @@ function isStrictnessValue(value) {
|
|
|
5638
5697
|
return value === STRICTNESS_STRICT || value === STRICTNESS_BALANCED || value === STRICTNESS_TOLERANT;
|
|
5639
5698
|
}
|
|
5640
5699
|
|
|
5641
|
-
function getStrictness(
|
|
5642
|
-
|
|
5643
|
-
|
|
5700
|
+
function getStrictness(options, inheritedOptions) {
|
|
5701
|
+
return resolveStrictness(options, resolveStrictness(inheritedOptions, STRICTNESS_BALANCED));
|
|
5702
|
+
}
|
|
5703
|
+
|
|
5704
|
+
function resolveStrictness(options, inheritedStrictness) {
|
|
5705
|
+
const strictness = options[OPTION_STRICTNESS];
|
|
5706
|
+
if (strictness !== UNDEFINED_VALUE) {
|
|
5707
|
+
if (!isStrictnessValue(strictness)) {
|
|
5708
|
+
throw new Error(ERR_INVALID_STRICTNESS);
|
|
5709
|
+
}
|
|
5710
|
+
return strictness;
|
|
5711
|
+
}
|
|
5712
|
+
const checkAmbiguity = options[OPTION_CHECK_AMBIGUITY];
|
|
5713
|
+
if (checkAmbiguity === UNDEFINED_VALUE) {
|
|
5714
|
+
return inheritedStrictness;
|
|
5715
|
+
}
|
|
5716
|
+
if (checkAmbiguity) {
|
|
5717
|
+
return STRICTNESS_STRICT;
|
|
5718
|
+
}
|
|
5719
|
+
return inheritedStrictness == STRICTNESS_TOLERANT ? STRICTNESS_TOLERANT : STRICTNESS_BALANCED;
|
|
5720
|
+
}
|
|
5721
|
+
|
|
5722
|
+
function getCheckLocalDirectory(checkLocalDirectory, strictness) {
|
|
5723
|
+
if (checkLocalDirectory === UNDEFINED_VALUE) {
|
|
5724
|
+
return strictness != STRICTNESS_TOLERANT;
|
|
5644
5725
|
}
|
|
5645
|
-
|
|
5646
|
-
|
|
5726
|
+
return Boolean(checkLocalDirectory);
|
|
5727
|
+
}
|
|
5728
|
+
|
|
5729
|
+
function getCheckLocalFilename(checkLocalFilename, strictness) {
|
|
5730
|
+
if (checkLocalFilename === UNDEFINED_VALUE) {
|
|
5731
|
+
return strictness == STRICTNESS_STRICT;
|
|
5647
5732
|
}
|
|
5648
|
-
return
|
|
5733
|
+
return Boolean(checkLocalFilename);
|
|
5649
5734
|
}
|
|
5650
5735
|
|
|
5651
5736
|
function getFilenameValidation(filenameValidation, strictness) {
|
|
@@ -5793,10 +5878,11 @@ async function readSignature(reader, view, anchoredOffset, signatureOffset, size
|
|
|
5793
5878
|
return UNDEFINED_VALUE;
|
|
5794
5879
|
}
|
|
5795
5880
|
|
|
5796
|
-
function
|
|
5881
|
+
function validateLocalDirectory(zipEntry, localDirectory, rawLocalFilename, checkLocalFilename) {
|
|
5797
5882
|
const { rawFilename } = zipEntry;
|
|
5798
|
-
if (
|
|
5799
|
-
rawLocalFilename.
|
|
5883
|
+
if (checkLocalFilename &&
|
|
5884
|
+
(rawLocalFilename.length != rawFilename.length ||
|
|
5885
|
+
rawLocalFilename.some((byteValue, indexByte) => byteValue != rawFilename[indexByte]))) {
|
|
5800
5886
|
throwAmbiguousArchive("mismatched local file header (filename)");
|
|
5801
5887
|
}
|
|
5802
5888
|
if ((localDirectory.rawBitFlag & BITFLAG_AMBIGUITY_MASK) != (zipEntry.rawBitFlag & BITFLAG_AMBIGUITY_MASK)) {
|
|
@@ -5914,6 +6000,7 @@ var zipReader = /*#__PURE__*/Object.freeze({
|
|
|
5914
6000
|
|
|
5915
6001
|
const ERR_DUPLICATED_NAME = "File already exists";
|
|
5916
6002
|
const ERR_INVALID_COMMENT = "Zip file comment exceeds 64KB";
|
|
6003
|
+
const ERR_INVALID_COMMENT_TYPE = "Invalid zip file comment (must be a Uint8Array)";
|
|
5917
6004
|
const ERR_INVALID_ENTRY_COMMENT = "File entry comment exceeds 64KB";
|
|
5918
6005
|
const ERR_INVALID_ENTRY_NAME = "File entry name exceeds 64KB";
|
|
5919
6006
|
const ERR_INVALID_VERSION = "Version exceeds 65535";
|
|
@@ -5982,6 +6069,10 @@ class ZipWriter {
|
|
|
5982
6069
|
}
|
|
5983
6070
|
reader = new GenericReader(reader);
|
|
5984
6071
|
await initStream(reader);
|
|
6072
|
+
if (reader.size === UNDEFINED_VALUE || !reader.readUint8Array) {
|
|
6073
|
+
reader = new BlobReader(await streamToBlob(reader.readable));
|
|
6074
|
+
await initStream(reader);
|
|
6075
|
+
}
|
|
5985
6076
|
const { ZipReader } = await Promise.resolve().then(function () { return zipReader; });
|
|
5986
6077
|
const zipReader$1 = new ZipReader(reader.readable);
|
|
5987
6078
|
const entries = await zipReader$1.getEntries();
|
|
@@ -6130,6 +6221,9 @@ class ZipWriter {
|
|
|
6130
6221
|
const zipWriter = this;
|
|
6131
6222
|
const { pendingAddFileCalls, writer } = this;
|
|
6132
6223
|
const { writable } = writer;
|
|
6224
|
+
if (!(comment instanceof Uint8Array)) {
|
|
6225
|
+
throw new Error(ERR_INVALID_COMMENT_TYPE);
|
|
6226
|
+
}
|
|
6133
6227
|
if (getLength(comment) > MAX_16_BITS) {
|
|
6134
6228
|
throw new Error(ERR_INVALID_COMMENT);
|
|
6135
6229
|
}
|
|
@@ -6226,8 +6320,6 @@ async function addFile(zipWriter, name, reader, options) {
|
|
|
6226
6320
|
const diskOffset = getDiskOffset(zipWriter.writer);
|
|
6227
6321
|
const diskNumber = getDiskNumber(zipWriter.writer);
|
|
6228
6322
|
options = Object.assign({}, options, attributesInfo.resolvedOptions, metadataInfo.resolvedOptions, sizesInfo.resolvedOptions, {
|
|
6229
|
-
internalFileAttribute: metadataInfo.resolvedOptions.internalFileAttributes,
|
|
6230
|
-
externalFileAttribute: attributesInfo.resolvedOptions.externalFileAttributes,
|
|
6231
6323
|
signature: options[PROPERTY_NAME_SIGNATURE],
|
|
6232
6324
|
crc32: options.crc32 === UNDEFINED_VALUE ? options[PROPERTY_NAME_SIGNATURE] : options.crc32,
|
|
6233
6325
|
offset: zipWriter.offset - diskOffset,
|
|
@@ -6241,14 +6333,20 @@ async function addFile(zipWriter, name, reader, options) {
|
|
|
6241
6333
|
zipWriter.files.delete(name);
|
|
6242
6334
|
throw error;
|
|
6243
6335
|
}
|
|
6244
|
-
Object.assign(fileEntry, {
|
|
6336
|
+
Object.assign(fileEntry, {
|
|
6337
|
+
name,
|
|
6338
|
+
comment,
|
|
6339
|
+
extraField,
|
|
6340
|
+
[PROPERTY_NAME_DEPRECATED_INTERNAL_FILE_ATTRIBUTES]: fileEntry.internalFileAttributes,
|
|
6341
|
+
[PROPERTY_NAME_DEPRECATED_EXTERNAL_FILE_ATTRIBUTES]: fileEntry.externalFileAttributes
|
|
6342
|
+
});
|
|
6245
6343
|
return new Entry(fileEntry);
|
|
6246
6344
|
}
|
|
6247
6345
|
|
|
6248
6346
|
function resolveAttributes(zipWriter, name, options) {
|
|
6249
6347
|
name = name.trim();
|
|
6250
6348
|
let msDosCompatible = getOptionValue(zipWriter, options, PROPERTY_NAME_MS_DOS_COMPATIBLE);
|
|
6251
|
-
let versionMadeBy = getOptionValue(zipWriter, options, PROPERTY_NAME_VERSION_MADE_BY, msDosCompatible ?
|
|
6349
|
+
let versionMadeBy = getOptionValue(zipWriter, options, PROPERTY_NAME_VERSION_MADE_BY, msDosCompatible ? VERSION_MADE_BY_MSDOS : VERSION_MADE_BY_UNIX);
|
|
6252
6350
|
const executable = getOptionValue(zipWriter, options, PROPERTY_NAME_EXECUTABLE);
|
|
6253
6351
|
const uid = getNumberOptionValue(zipWriter, options, PROPERTY_NAME_UID);
|
|
6254
6352
|
const gid = getNumberOptionValue(zipWriter, options, PROPERTY_NAME_GID);
|
|
@@ -6282,7 +6380,7 @@ function resolveAttributes(zipWriter, name, options) {
|
|
|
6282
6380
|
const hasMsDosProvided = msdosAttributesRaw !== UNDEFINED_VALUE || msdosAttributes !== UNDEFINED_VALUE;
|
|
6283
6381
|
if (hasUnixMetadata) {
|
|
6284
6382
|
msDosCompatible = false;
|
|
6285
|
-
versionMadeBy = (versionMadeBy &
|
|
6383
|
+
versionMadeBy = (versionMadeBy & MAX_8_BITS) | VERSION_MADE_BY_UNIX;
|
|
6286
6384
|
} else if (hasMsDosProvided) {
|
|
6287
6385
|
msDosCompatible = true;
|
|
6288
6386
|
versionMadeBy = (versionMadeBy & MAX_8_BITS);
|
|
@@ -6322,11 +6420,10 @@ function resolveAttributes(zipWriter, name, options) {
|
|
|
6322
6420
|
externalFileAttributes = FILE_ATTR_UNIX_DEFAULT_MASK << 16;
|
|
6323
6421
|
}
|
|
6324
6422
|
}
|
|
6325
|
-
let unixExternalUpper;
|
|
6326
6423
|
if (!msDosCompatible) {
|
|
6327
6424
|
const unixModeProvided = unixMode !== UNDEFINED_VALUE || Boolean(setuid || setgid || sticky);
|
|
6328
|
-
|
|
6329
|
-
unixMode = unixMode === UNDEFINED_VALUE ?
|
|
6425
|
+
const defaultUnixMode = (externalFileAttributes >> 16) & MAX_16_BITS;
|
|
6426
|
+
unixMode = unixMode === UNDEFINED_VALUE ? defaultUnixMode : (unixMode & MAX_16_BITS);
|
|
6330
6427
|
if (setuid) {
|
|
6331
6428
|
unixMode |= FILE_ATTR_UNIX_SETUID_MASK;
|
|
6332
6429
|
} else {
|
|
@@ -6355,17 +6452,20 @@ function resolveAttributes(zipWriter, name, options) {
|
|
|
6355
6452
|
if (hasMsDosProvided) {
|
|
6356
6453
|
externalFileAttributes = (externalFileAttributes & MAX_32_BITS) | (msdosAttributesRaw & MAX_8_BITS);
|
|
6357
6454
|
}
|
|
6455
|
+
const unixExternalUpper = (externalFileAttributes >> 16) & MAX_16_BITS;
|
|
6456
|
+
const symlink = unixMode !== UNDEFINED_VALUE && ((unixMode & FILE_ATTR_UNIX_TYPE_MASK) == FILE_ATTR_UNIX_TYPE_SYMLINK);
|
|
6358
6457
|
return {
|
|
6359
6458
|
name,
|
|
6360
6459
|
resolvedOptions: {
|
|
6361
6460
|
versionMadeBy,
|
|
6362
|
-
msDosCompatible,
|
|
6461
|
+
msDosCompatible: Boolean(msDosCompatible),
|
|
6363
6462
|
externalFileAttributes,
|
|
6364
6463
|
unixExternalUpper,
|
|
6365
6464
|
uid,
|
|
6366
6465
|
gid,
|
|
6367
6466
|
unixMode,
|
|
6368
6467
|
unixExtraFieldType,
|
|
6468
|
+
symlink,
|
|
6369
6469
|
setuid,
|
|
6370
6470
|
setgid,
|
|
6371
6471
|
sticky,
|
|
@@ -6598,6 +6698,9 @@ async function getEntriesSize(writerOptions, entries, writeOrderGuaranteed, comm
|
|
|
6598
6698
|
if (writerOptions[OPTION_SIGN_CENTRAL_DIRECTORY]) {
|
|
6599
6699
|
throw new Error(ERR_UNDETERMINED_SIZE);
|
|
6600
6700
|
}
|
|
6701
|
+
if (comment !== UNDEFINED_VALUE && !(comment instanceof Uint8Array)) {
|
|
6702
|
+
throw new Error(ERR_INVALID_COMMENT_TYPE);
|
|
6703
|
+
}
|
|
6601
6704
|
const commentLength = getLength(comment);
|
|
6602
6705
|
if (commentLength > MAX_16_BITS) {
|
|
6603
6706
|
throw new Error(ERR_INVALID_COMMENT);
|
|
@@ -6879,6 +6982,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
|
|
|
6879
6982
|
uid,
|
|
6880
6983
|
gid,
|
|
6881
6984
|
unixMode,
|
|
6985
|
+
symlink,
|
|
6882
6986
|
setuid,
|
|
6883
6987
|
setgid,
|
|
6884
6988
|
sticky,
|
|
@@ -6915,6 +7019,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
|
|
|
6915
7019
|
uid,
|
|
6916
7020
|
gid,
|
|
6917
7021
|
unixMode,
|
|
7022
|
+
symlink: Boolean(symlink),
|
|
6918
7023
|
setuid,
|
|
6919
7024
|
setgid,
|
|
6920
7025
|
sticky,
|
|
@@ -6995,8 +7100,8 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
|
|
|
6995
7100
|
rawLastModDate,
|
|
6996
7101
|
creationDate,
|
|
6997
7102
|
lastAccessDate,
|
|
6998
|
-
encrypted,
|
|
6999
|
-
zipCrypto,
|
|
7103
|
+
encrypted: Boolean(encrypted),
|
|
7104
|
+
zipCrypto: Boolean(zipCrypto),
|
|
7000
7105
|
size: metadataSize + compressedSize,
|
|
7001
7106
|
compressionMethod,
|
|
7002
7107
|
version,
|
|
@@ -10058,4 +10163,4 @@ function decodeMimeTypes(data) {
|
|
|
10058
10163
|
return mimeTypes;
|
|
10059
10164
|
}
|
|
10060
10165
|
|
|
10061
|
-
export { BlobReader, BlobWriter, Data64URIReader, Data64URIWriter, ERR_ABORTED, ERR_AMBIGUOUS_ARCHIVE, ERR_BAD_FORMAT, ERR_CENTRAL_DIRECTORY_NOT_FOUND, ERR_DUPLICATED_NAME, ERR_ENCRYPTED, ERR_ENCRYPTED_CENTRAL_DIRECTORY, ERR_ENTRY_EXISTS, ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND, ERR_EOCDR_NOT_FOUND, ERR_EXTRAFIELD_ZIP64_NOT_FOUND, ERR_HTTP_RANGE, ERR_HTTP_RESOURCE_CHANGED, ERR_INVALID_AUTHENTICATION_CODE, ERR_INVALID_CODEC_DEFINITION, ERR_INVALID_CODEC_MODULE, ERR_INVALID_COMMENT, ERR_INVALID_COMPRESSED_DATA, ERR_INVALID_CRC32, ERR_INVALID_ENCRYPTION_STRENGTH, ERR_INVALID_ENTRY_COMMENT, ERR_INVALID_ENTRY_NAME, ERR_INVALID_EXTRAFIELD_DATA, ERR_INVALID_EXTRAFIELD_TYPE, ERR_INVALID_FILENAME_VALIDATION, ERR_INVALID_GID, ERR_INVALID_LEVEL, ERR_INVALID_MAX_APPENDED_DATA_SIZE, ERR_INVALID_MSDOS_ATTRIBUTES, ERR_INVALID_MSDOS_DATA, ERR_INVALID_PASSWORD, ERR_INVALID_PASSWORD_TYPE, ERR_INVALID_PASS_THROUGH, ERR_INVALID_SIGNATURE, ERR_INVALID_SIGNATURE_DATA, ERR_INVALID_STRICTNESS, ERR_INVALID_UID, ERR_INVALID_UNCOMPRESSED_SIZE, ERR_INVALID_UNIX_EXTRA_FIELD_TYPE, ERR_INVALID_UNIX_ID_SIZE, ERR_INVALID_UNIX_MODE, ERR_INVALID_VERSION, ERR_ITERATOR_COMPLETED_TOO_SOON, ERR_LOCAL_FILE_HEADER_NOT_FOUND, ERR_OVERLAPPING_ENTRY, ERR_READABLE_CONSUMED, ERR_RESERVED_COMPRESSION_METHOD, ERR_SPLIT_ZIP_FILE, ERR_UNDEFINED_READER, ERR_UNDEFINED_UNCOMPRESSED_SIZE, ERR_UNDETERMINED_SIZE, ERR_UNSAFE_FILENAME, ERR_UNSUPPORTED_COMPRESSION$1 as ERR_UNSUPPORTED_COMPRESSION, ERR_UNSUPPORTED_CONTEXT, ERR_UNSUPPORTED_CRYPTO_API, ERR_UNSUPPORTED_ENCRYPTION, ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH, ERR_UNSUPPORTED_ENCRYPTION_USDZ, ERR_UNSUPPORTED_FORMAT, ERR_WORKER_STARTUP_TIMEOUT, ERR_WRITER_NOT_INITIALIZED, ERR_ZIP_NOT_EMPTY, HttpRangeReader, HttpReader, Reader, SplitDataReader, SplitDataWriter, TextReader, TextWriter, Uint8ArrayReader, Uint8ArrayWriter, Writer, ZipReader, ZipReaderStream, ZipWriter, ZipWriterStream, configure, createBlobTempStream, createOPFSTempStream, createSyncAccessHandleTempStream, fs, getMimeType, registerCodec, resetConfiguration, terminateWorkersAndModule as terminateWorkers, unregisterCodec };
|
|
10166
|
+
export { BlobReader, BlobWriter, Data64URIReader, Data64URIWriter, ERR_ABORTED, ERR_AMBIGUOUS_ARCHIVE, ERR_BAD_FORMAT, ERR_CENTRAL_DIRECTORY_NOT_FOUND, ERR_DUPLICATED_NAME, ERR_ENCRYPTED, ERR_ENCRYPTED_CENTRAL_DIRECTORY, ERR_ENTRY_EXISTS, ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND, ERR_EOCDR_NOT_FOUND, ERR_EXTRAFIELD_ZIP64_NOT_FOUND, ERR_HTTP_RANGE, ERR_HTTP_RESOURCE_CHANGED, ERR_INVALID_AUTHENTICATION_CODE, ERR_INVALID_CODEC_DEFINITION, ERR_INVALID_CODEC_MODULE, ERR_INVALID_COMMENT, ERR_INVALID_COMMENT_TYPE, ERR_INVALID_COMPRESSED_DATA, ERR_INVALID_CRC32, ERR_INVALID_ENCRYPTION_STRENGTH, ERR_INVALID_ENTRY_COMMENT, ERR_INVALID_ENTRY_NAME, ERR_INVALID_EXTRAFIELD_DATA, ERR_INVALID_EXTRAFIELD_TYPE, ERR_INVALID_FILENAME_VALIDATION, ERR_INVALID_GID, ERR_INVALID_LEVEL, ERR_INVALID_MAX_APPENDED_DATA_SIZE, ERR_INVALID_MSDOS_ATTRIBUTES, ERR_INVALID_MSDOS_DATA, ERR_INVALID_PASSWORD, ERR_INVALID_PASSWORD_TYPE, ERR_INVALID_PASS_THROUGH, ERR_INVALID_SIGNATURE, ERR_INVALID_SIGNATURE_DATA, ERR_INVALID_STRICTNESS, ERR_INVALID_UID, ERR_INVALID_UNCOMPRESSED_SIZE, ERR_INVALID_UNIX_EXTRA_FIELD_TYPE, ERR_INVALID_UNIX_ID_SIZE, ERR_INVALID_UNIX_MODE, ERR_INVALID_VERSION, ERR_ITERATOR_COMPLETED_TOO_SOON, ERR_LOCAL_FILE_HEADER_NOT_FOUND, ERR_OVERLAPPING_ENTRY, ERR_READABLE_CONSUMED, ERR_RESERVED_COMPRESSION_METHOD, ERR_SPLIT_ZIP_FILE, ERR_UNDEFINED_READER, ERR_UNDEFINED_UNCOMPRESSED_SIZE, ERR_UNDETERMINED_SIZE, ERR_UNSAFE_FILENAME, ERR_UNSUPPORTED_COMPRESSION$1 as ERR_UNSUPPORTED_COMPRESSION, ERR_UNSUPPORTED_CONTEXT, ERR_UNSUPPORTED_CRYPTO_API, ERR_UNSUPPORTED_ENCRYPTION, ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH, ERR_UNSUPPORTED_ENCRYPTION_USDZ, ERR_UNSUPPORTED_FORMAT, ERR_WORKER_STARTUP_TIMEOUT, ERR_WRITER_NOT_INITIALIZED, ERR_ZIP_NOT_EMPTY, HttpRangeReader, HttpReader, Reader, SplitDataReader, SplitDataWriter, TextReader, TextWriter, Uint8ArrayReader, Uint8ArrayWriter, Writer, ZipReader, ZipReaderStream, ZipWriter, ZipWriterStream, configure, createBlobTempStream, createOPFSTempStream, createSyncAccessHandleTempStream, fs, getMimeType, registerCodec, resetConfiguration, terminateWorkersAndModule as terminateWorkers, unregisterCodec };
|