@zip.js/zip.js 2.8.51 → 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/README.md +8 -3
- package/deno.json +1 -1
- package/dist/zip-core-external.js +241 -95
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +243 -94
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +564 -199
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +551 -194
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +564 -199
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +567 -198
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +567 -198
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +243 -94
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +243 -94
- package/dist/zip-native.min.js +1 -1
- package/dist/zip.js +243 -94
- package/dist/zip.min.js +1 -1
- package/eslint.config.mjs +1 -1
- package/index-native.cjs +567 -198
- package/index-native.min.js +1 -1
- package/index.cjs +567 -198
- package/index.d.cts +551 -45
- package/index.d.ts +551 -45
- package/index.min.js +1 -1
- package/lib/core/codec-worker-web.js +13 -4
- package/lib/core/codec-worker.js +2 -0
- package/lib/core/constants.js +9 -0
- package/lib/core/io.js +43 -4
- package/lib/core/options.js +2 -0
- package/lib/core/util/compatible-streams.js +3 -8
- package/lib/core/zip-entry.js +16 -0
- package/lib/core/zip-fs.js +236 -107
- package/lib/core/zip-reader.js +106 -40
- package/lib/core/zip-writer.js +171 -41
- package/lib/zip-core-writer.js +3 -0
- package/package.json +9 -7
|
@@ -81,6 +81,8 @@ const FILE_ATTR_MSDOS_SYSTEM_MASK = 0x04;
|
|
|
81
81
|
const FILE_ATTR_MSDOS_ARCHIVE_MASK = 0x20;
|
|
82
82
|
const FILE_ATTR_UNIX_TYPE_MASK = 0o170000;
|
|
83
83
|
const FILE_ATTR_UNIX_TYPE_DIR = 0o040000;
|
|
84
|
+
const FILE_ATTR_UNIX_TYPE_SYMLINK = 0o120000;
|
|
85
|
+
const FILE_ATTR_UNIX_TYPE_FILE = 0o100000;
|
|
84
86
|
const FILE_ATTR_UNIX_EXECUTABLE_MASK = 0o111;
|
|
85
87
|
const FILE_ATTR_UNIX_DEFAULT_MASK = 0o644;
|
|
86
88
|
const FILE_ATTR_UNIX_SETUID_MASK = 0o4000;
|
|
@@ -91,6 +93,9 @@ const VERSION_DEFLATE = 0x14;
|
|
|
91
93
|
const VERSION_ZIP64 = 0x2D;
|
|
92
94
|
const VERSION_AES = 0x33;
|
|
93
95
|
|
|
96
|
+
const VERSION_MADE_BY_MSDOS = 0x0014;
|
|
97
|
+
const VERSION_MADE_BY_UNIX = 0x0300;
|
|
98
|
+
|
|
94
99
|
const DIRECTORY_SIGNATURE = "/";
|
|
95
100
|
|
|
96
101
|
const HEADER_SIZE = 30;
|
|
@@ -1806,8 +1811,6 @@ function getInt32(number) {
|
|
|
1806
1811
|
*/
|
|
1807
1812
|
|
|
1808
1813
|
|
|
1809
|
-
const HTTP_HEADER_CONTENT_TYPE = "Content-Type";
|
|
1810
|
-
|
|
1811
1814
|
function toCompatibleReadable(readable) {
|
|
1812
1815
|
if (readable instanceof ReadableStream) {
|
|
1813
1816
|
return readable;
|
|
@@ -1830,12 +1833,9 @@ function toCompatibleReadable(readable) {
|
|
|
1830
1833
|
|
|
1831
1834
|
function streamToBlob(readable, contentType) {
|
|
1832
1835
|
readable = toCompatibleReadable(readable);
|
|
1836
|
+
const blobOptions = contentType ? { type: contentType } : {};
|
|
1833
1837
|
if (responseSupportsGlobalReadable()) {
|
|
1834
|
-
|
|
1835
|
-
if (contentType) {
|
|
1836
|
-
options.headers = [[HTTP_HEADER_CONTENT_TYPE, contentType]];
|
|
1837
|
-
}
|
|
1838
|
-
return new Response(readable, options).blob();
|
|
1838
|
+
return new Response(readable).blob().then(blob => contentType ? new Blob([blob], blobOptions) : blob);
|
|
1839
1839
|
}
|
|
1840
1840
|
const chunks = [];
|
|
1841
1841
|
return readable
|
|
@@ -1844,7 +1844,7 @@ function streamToBlob(readable, contentType) {
|
|
|
1844
1844
|
chunks.push(chunk);
|
|
1845
1845
|
}
|
|
1846
1846
|
}))
|
|
1847
|
-
.then(() => new Blob(chunks,
|
|
1847
|
+
.then(() => new Blob(chunks, blobOptions));
|
|
1848
1848
|
}
|
|
1849
1849
|
|
|
1850
1850
|
function responseSupportsGlobalReadable() {
|
|
@@ -2790,6 +2790,7 @@ function createWebWorkerInterface(workerData, config) {
|
|
|
2790
2790
|
worker,
|
|
2791
2791
|
workerAlive: false,
|
|
2792
2792
|
terminated: false,
|
|
2793
|
+
startupError: null,
|
|
2793
2794
|
interface: {
|
|
2794
2795
|
run: async () => {
|
|
2795
2796
|
try {
|
|
@@ -2817,6 +2818,13 @@ function createWebWorkerInterface(workerData, config) {
|
|
|
2817
2818
|
}
|
|
2818
2819
|
|
|
2819
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
|
+
}
|
|
2820
2828
|
let resolveResult, rejectResult;
|
|
2821
2829
|
const result = new Promise((resolve, reject) => {
|
|
2822
2830
|
resolveResult = resolve;
|
|
@@ -3030,11 +3038,12 @@ function onWorkerError(event, workerData) {
|
|
|
3030
3038
|
if (!workerAlive) {
|
|
3031
3039
|
workerData.worker = null;
|
|
3032
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
|
+
}
|
|
3033
3046
|
if (rejectResult) {
|
|
3034
|
-
let error = event.error || new Error(event.message || ERROR_EVENT_TYPE);
|
|
3035
|
-
if (!workerAlive) {
|
|
3036
|
-
error = Object.assign(new Error(error.message || ERROR_EVENT_TYPE), { workerStartupFailed: true });
|
|
3037
|
-
}
|
|
3038
3047
|
rejectResult(error);
|
|
3039
3048
|
if (writer) {
|
|
3040
3049
|
writer.releaseLock();
|
|
@@ -3379,8 +3388,10 @@ class Reader extends Stream {
|
|
|
3379
3388
|
async pull(controller) {
|
|
3380
3389
|
const dataSize = size === UNDEFINED_VALUE ? chunkSize : Math.min(chunkSize, size - chunkOffset);
|
|
3381
3390
|
const data = await readUint8Array(reader, offset + chunkOffset, dataSize);
|
|
3382
|
-
|
|
3383
|
-
|
|
3391
|
+
if (data.length) {
|
|
3392
|
+
controller.enqueue(data);
|
|
3393
|
+
}
|
|
3394
|
+
if ((chunkOffset + chunkSize >= size) || (size === UNDEFINED_VALUE && !data.length && dataSize)) {
|
|
3384
3395
|
controller.close();
|
|
3385
3396
|
} else {
|
|
3386
3397
|
chunkOffset += chunkSize;
|
|
@@ -3458,6 +3469,7 @@ class Data64URIWriter extends Writer {
|
|
|
3458
3469
|
constructor(contentType) {
|
|
3459
3470
|
super();
|
|
3460
3471
|
Object.assign(this, {
|
|
3472
|
+
contentType,
|
|
3461
3473
|
data: "data:" + (contentType || "") + ";base64,",
|
|
3462
3474
|
pending: []
|
|
3463
3475
|
});
|
|
@@ -3559,6 +3571,7 @@ class BlobWriter extends Stream {
|
|
|
3559
3571
|
return transformStream.writable;
|
|
3560
3572
|
}
|
|
3561
3573
|
});
|
|
3574
|
+
writer.contentType = contentType;
|
|
3562
3575
|
writer.blob = streamToBlob(transformStream.readable, contentType);
|
|
3563
3576
|
writer.blob.catch(() => { });
|
|
3564
3577
|
}
|
|
@@ -4059,9 +4072,8 @@ class SplitDataReader extends Reader {
|
|
|
4059
4072
|
|
|
4060
4073
|
async init() {
|
|
4061
4074
|
const reader = this;
|
|
4062
|
-
const { readers } = reader;
|
|
4063
4075
|
reader.lastDiskNumber = 0;
|
|
4064
|
-
await Promise.all(readers.map(
|
|
4076
|
+
const readers = reader.readers = await Promise.all(reader.readers.map(initDiskReader));
|
|
4065
4077
|
reader.diskOffsets = readers.map(diskReader => {
|
|
4066
4078
|
const diskOffset = reader.size;
|
|
4067
4079
|
reader.size += diskReader.size;
|
|
@@ -4238,6 +4250,10 @@ class GenericWriter {
|
|
|
4238
4250
|
}
|
|
4239
4251
|
}
|
|
4240
4252
|
|
|
4253
|
+
function ownsWritable(writer) {
|
|
4254
|
+
return Boolean(writer && writer.getData);
|
|
4255
|
+
}
|
|
4256
|
+
|
|
4241
4257
|
function isHttpFamily(url) {
|
|
4242
4258
|
const { baseURI } = getConfiguration();
|
|
4243
4259
|
const { protocol } = new URL(url, baseURI);
|
|
@@ -4252,6 +4268,16 @@ async function initStream(stream, initSize) {
|
|
|
4252
4268
|
}
|
|
4253
4269
|
}
|
|
4254
4270
|
|
|
4271
|
+
async function initDiskReader(diskReader) {
|
|
4272
|
+
diskReader = new GenericReader(diskReader);
|
|
4273
|
+
await initStream(diskReader);
|
|
4274
|
+
if (diskReader.size === UNDEFINED_VALUE || !diskReader.readUint8Array) {
|
|
4275
|
+
diskReader = new BlobReader(await streamToBlob(diskReader.readable));
|
|
4276
|
+
await initStream(diskReader);
|
|
4277
|
+
}
|
|
4278
|
+
return diskReader;
|
|
4279
|
+
}
|
|
4280
|
+
|
|
4255
4281
|
function readUint8Array(reader, offset, size) {
|
|
4256
4282
|
return reader.readUint8Array(offset, size);
|
|
4257
4283
|
}
|
|
@@ -4382,6 +4408,8 @@ const PROPERTY_NAME_CREATION_DATE = "creationDate";
|
|
|
4382
4408
|
const PROPERTY_NAME_RAW_CREATION_DATE = "rawCreationDate";
|
|
4383
4409
|
const PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES = "internalFileAttributes";
|
|
4384
4410
|
const PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES = "externalFileAttributes";
|
|
4411
|
+
const PROPERTY_NAME_DEPRECATED_INTERNAL_FILE_ATTRIBUTES = "internalFileAttribute";
|
|
4412
|
+
const PROPERTY_NAME_DEPRECATED_EXTERNAL_FILE_ATTRIBUTES = "externalFileAttribute";
|
|
4385
4413
|
const PROPERTY_NAME_MSDOS_ATTRIBUTES_RAW = "msdosAttributesRaw";
|
|
4386
4414
|
const PROPERTY_NAME_MSDOS_ATTRIBUTES = "msdosAttributes";
|
|
4387
4415
|
const PROPERTY_NAME_MS_DOS_COMPATIBLE = "msDosCompatible";
|
|
@@ -4392,6 +4420,7 @@ const PROPERTY_NAME_VERSION_MADE_BY = "versionMadeBy";
|
|
|
4392
4420
|
const PROPERTY_NAME_ZIPCRYPTO = "zipCrypto";
|
|
4393
4421
|
const PROPERTY_NAME_DIRECTORY = "directory";
|
|
4394
4422
|
const PROPERTY_NAME_EXECUTABLE = "executable";
|
|
4423
|
+
const PROPERTY_NAME_SYMLINK = "symlink";
|
|
4395
4424
|
const PROPERTY_NAME_COMPRESSION_METHOD = "compressionMethod";
|
|
4396
4425
|
const PROPERTY_NAME_SIGNATURE = "signature";
|
|
4397
4426
|
const PROPERTY_NAME_CRC32 = "crc32";
|
|
@@ -4407,6 +4436,10 @@ const PROPERTY_NAME_SETUID = "setuid";
|
|
|
4407
4436
|
const PROPERTY_NAME_SETGID = "setgid";
|
|
4408
4437
|
const PROPERTY_NAME_STICKY = "sticky";
|
|
4409
4438
|
const PROPERTY_NAME_BITFLAG = "bitFlag";
|
|
4439
|
+
const PROPERTY_NAME_RAW_BITFLAG = "rawBitFlag";
|
|
4440
|
+
const PROPERTY_NAME_FILENAME_LENGTH = "filenameLength";
|
|
4441
|
+
const PROPERTY_NAME_EXTRA_FIELD_LENGTH = "extraFieldLength";
|
|
4442
|
+
const PROPERTY_NAME_UNIX_EXTERNAL_UPPER = "unixExternalUpper";
|
|
4410
4443
|
const PROPERTY_NAME_FILENAME_UTF8 = "filenameUTF8";
|
|
4411
4444
|
const PROPERTY_NAME_COMMENT_UTF8 = "commentUTF8";
|
|
4412
4445
|
const PROPERTY_NAME_RAW_EXTRA_FIELD = "rawExtraField";
|
|
@@ -4435,6 +4468,8 @@ const PROPERTY_NAMES = [
|
|
|
4435
4468
|
PROPERTY_NAME_DISK_NUMBER_START,
|
|
4436
4469
|
PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES,
|
|
4437
4470
|
PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES,
|
|
4471
|
+
PROPERTY_NAME_DEPRECATED_INTERNAL_FILE_ATTRIBUTES,
|
|
4472
|
+
PROPERTY_NAME_DEPRECATED_EXTERNAL_FILE_ATTRIBUTES,
|
|
4438
4473
|
PROPERTY_NAME_MSDOS_ATTRIBUTES_RAW,
|
|
4439
4474
|
PROPERTY_NAME_MSDOS_ATTRIBUTES,
|
|
4440
4475
|
PROPERTY_NAME_MS_DOS_COMPATIBLE,
|
|
@@ -4445,6 +4480,7 @@ const PROPERTY_NAMES = [
|
|
|
4445
4480
|
PROPERTY_NAME_ZIPCRYPTO,
|
|
4446
4481
|
PROPERTY_NAME_DIRECTORY,
|
|
4447
4482
|
PROPERTY_NAME_EXECUTABLE,
|
|
4483
|
+
PROPERTY_NAME_SYMLINK,
|
|
4448
4484
|
PROPERTY_NAME_COMPRESSION_METHOD,
|
|
4449
4485
|
PROPERTY_NAME_SIGNATURE,
|
|
4450
4486
|
PROPERTY_NAME_CRC32,
|
|
@@ -4456,10 +4492,14 @@ const PROPERTY_NAMES = [
|
|
|
4456
4492
|
PROPERTY_NAME_UID,
|
|
4457
4493
|
PROPERTY_NAME_GID,
|
|
4458
4494
|
PROPERTY_NAME_UNIX_MODE,
|
|
4495
|
+
PROPERTY_NAME_UNIX_EXTERNAL_UPPER,
|
|
4459
4496
|
PROPERTY_NAME_SETUID,
|
|
4460
4497
|
PROPERTY_NAME_SETGID,
|
|
4461
4498
|
PROPERTY_NAME_STICKY,
|
|
4462
4499
|
PROPERTY_NAME_BITFLAG,
|
|
4500
|
+
PROPERTY_NAME_RAW_BITFLAG,
|
|
4501
|
+
PROPERTY_NAME_FILENAME_LENGTH,
|
|
4502
|
+
PROPERTY_NAME_EXTRA_FIELD_LENGTH,
|
|
4463
4503
|
PROPERTY_NAME_FILENAME_UTF8,
|
|
4464
4504
|
PROPERTY_NAME_COMMENT_UTF8,
|
|
4465
4505
|
PROPERTY_NAME_RAW_EXTRA_FIELD,
|
|
@@ -4521,6 +4561,7 @@ const OPTION_CHECK_PASSWORD_ONLY = "checkPasswordOnly";
|
|
|
4521
4561
|
const OPTION_CHECK_OVERLAPPING_ENTRY_ONLY = "checkOverlappingEntryOnly";
|
|
4522
4562
|
const OPTION_CHECK_OVERLAPPING_ENTRY = "checkOverlappingEntry";
|
|
4523
4563
|
const OPTION_CHECK_AMBIGUITY = "checkAmbiguity";
|
|
4564
|
+
const OPTION_CHECK_LOCAL_DIRECTORY = "checkLocalDirectory";
|
|
4524
4565
|
const OPTION_CHECK_SIGNATURE = "checkSignature";
|
|
4525
4566
|
const OPTION_CHECK_CRC32 = "checkCrc32";
|
|
4526
4567
|
const OPTION_CHECK_AUTHENTICATION_CODE = "checkAuthenticationCode";
|
|
@@ -4652,7 +4693,7 @@ class ZipReader {
|
|
|
4652
4693
|
if (reader.size < END_OF_CENTRAL_DIR_LENGTH) {
|
|
4653
4694
|
throw new Error(ERR_BAD_FORMAT);
|
|
4654
4695
|
}
|
|
4655
|
-
const strictness = getStrictness(
|
|
4696
|
+
const strictness = getStrictness(options, zipReader.options);
|
|
4656
4697
|
const checkAmbiguity = strictness == STRICTNESS_STRICT;
|
|
4657
4698
|
const rejectAmbiguousEndOfDirectory = strictness != STRICTNESS_TOLERANT;
|
|
4658
4699
|
const maxAppendedDataSize = getMaxAppendedDataSize(getOptionValue$1(zipReader, options, OPTION_MAX_APPENDED_DATA_SIZE), strictness);
|
|
@@ -4874,6 +4915,7 @@ class ZipReader {
|
|
|
4874
4915
|
index: indexFile,
|
|
4875
4916
|
versionMadeBy,
|
|
4876
4917
|
msDosCompatible,
|
|
4918
|
+
zip64: false,
|
|
4877
4919
|
compressedSize: 0,
|
|
4878
4920
|
uncompressedSize: 0,
|
|
4879
4921
|
commentLength,
|
|
@@ -4907,15 +4949,18 @@ class ZipReader {
|
|
|
4907
4949
|
const setuid = Boolean(fileEntry.unixMode & FILE_ATTR_UNIX_SETUID_MASK);
|
|
4908
4950
|
const setgid = Boolean(fileEntry.unixMode & FILE_ATTR_UNIX_SETGID_MASK);
|
|
4909
4951
|
const sticky = Boolean(fileEntry.unixMode & FILE_ATTR_UNIX_STICKY_MASK);
|
|
4910
|
-
const
|
|
4952
|
+
const unixType = fileEntry.unixMode === UNDEFINED_VALUE ? unixExternalUpper : fileEntry.unixMode;
|
|
4953
|
+
const symlink = (unixType & FILE_ATTR_UNIX_TYPE_MASK) == FILE_ATTR_UNIX_TYPE_SYMLINK;
|
|
4954
|
+
const executable = !symlink && ((fileEntry.unixMode !== UNDEFINED_VALUE)
|
|
4911
4955
|
? ((fileEntry.unixMode & FILE_ATTR_UNIX_EXECUTABLE_MASK) != 0)
|
|
4912
|
-
: (unixCompatible && ((unixExternalUpper & FILE_ATTR_UNIX_EXECUTABLE_MASK) != 0));
|
|
4956
|
+
: (unixCompatible && ((unixExternalUpper & FILE_ATTR_UNIX_EXECUTABLE_MASK) != 0)));
|
|
4913
4957
|
const modeIsDir = fileEntry.unixMode !== UNDEFINED_VALUE && ((fileEntry.unixMode & FILE_ATTR_UNIX_TYPE_MASK) == FILE_ATTR_UNIX_TYPE_DIR);
|
|
4914
4958
|
const upperIsDir = ((unixExternalUpper & FILE_ATTR_UNIX_TYPE_MASK) == FILE_ATTR_UNIX_TYPE_DIR);
|
|
4915
4959
|
Object.assign(fileEntry, {
|
|
4916
4960
|
setuid,
|
|
4917
4961
|
setgid,
|
|
4918
4962
|
sticky,
|
|
4963
|
+
symlink,
|
|
4919
4964
|
unixExternalUpper,
|
|
4920
4965
|
internalFileAttribute: fileEntry.internalFileAttributes,
|
|
4921
4966
|
externalFileAttribute: fileEntry.externalFileAttributes,
|
|
@@ -4981,6 +5026,10 @@ class ZipReader {
|
|
|
4981
5026
|
}
|
|
4982
5027
|
|
|
4983
5028
|
async close() {
|
|
5029
|
+
const { reader } = this;
|
|
5030
|
+
if (!reader.readUint8Array && reader.readable && !reader.readable.locked) {
|
|
5031
|
+
await reader.readable.cancel();
|
|
5032
|
+
}
|
|
4984
5033
|
}
|
|
4985
5034
|
}
|
|
4986
5035
|
|
|
@@ -5077,9 +5126,12 @@ class ZipEntry {
|
|
|
5077
5126
|
extraFieldLength,
|
|
5078
5127
|
filenameLength
|
|
5079
5128
|
} = localDirectory;
|
|
5080
|
-
const
|
|
5129
|
+
const checkLocalDirectoryOption = getOptionValue$1(zipEntry, options, OPTION_CHECK_LOCAL_DIRECTORY);
|
|
5130
|
+
const entryStrictness = getStrictness(options, zipEntry.options);
|
|
5131
|
+
const checkLocalDirectory = getCheckLocalDirectory(checkLocalDirectoryOption, entryStrictness);
|
|
5132
|
+
const checkLocalFilename = getCheckLocalFilename(checkLocalDirectoryOption, entryStrictness);
|
|
5081
5133
|
let rawLocalFilename = EMPTY_UINT8_ARRAY;
|
|
5082
|
-
if (
|
|
5134
|
+
if (checkLocalFilename && (filenameLength || extraFieldLength)) {
|
|
5083
5135
|
const trailingDataArray = await readUint8Array(reader, localHeaderOffset + HEADER_SIZE, filenameLength + extraFieldLength);
|
|
5084
5136
|
rawLocalFilename = trailingDataArray.subarray(0, filenameLength);
|
|
5085
5137
|
localDirectory.rawExtraField = trailingDataArray.subarray(filenameLength);
|
|
@@ -5088,17 +5140,26 @@ class ZipEntry {
|
|
|
5088
5140
|
await readUint8Array(reader, localHeaderOffset + HEADER_SIZE + filenameLength, extraFieldLength) :
|
|
5089
5141
|
EMPTY_UINT8_ARRAY;
|
|
5090
5142
|
}
|
|
5143
|
+
if (checkLocalFilename) {
|
|
5144
|
+
localDirectory.rawFilename = rawLocalFilename;
|
|
5145
|
+
}
|
|
5091
5146
|
readCommonFooter(zipEntry, localDirectory, dataView, 4, true);
|
|
5092
|
-
if (
|
|
5093
|
-
|
|
5147
|
+
if (checkLocalDirectory) {
|
|
5148
|
+
validateLocalDirectory(zipEntry, localDirectory, rawLocalFilename, checkLocalFilename);
|
|
5094
5149
|
}
|
|
5095
|
-
const { lastAccessDate, creationDate } = localDirectory;
|
|
5150
|
+
const { lastAccessDate, creationDate, uid, gid } = localDirectory;
|
|
5096
5151
|
if (lastAccessDate) {
|
|
5097
5152
|
fileEntry.lastAccessDate = lastAccessDate;
|
|
5098
5153
|
}
|
|
5099
5154
|
if (creationDate) {
|
|
5100
5155
|
fileEntry.creationDate = creationDate;
|
|
5101
5156
|
}
|
|
5157
|
+
if (uid !== UNDEFINED_VALUE && fileEntry.uid === UNDEFINED_VALUE) {
|
|
5158
|
+
fileEntry.uid = uid;
|
|
5159
|
+
}
|
|
5160
|
+
if (gid !== UNDEFINED_VALUE && fileEntry.gid === UNDEFINED_VALUE) {
|
|
5161
|
+
fileEntry.gid = gid;
|
|
5162
|
+
}
|
|
5102
5163
|
const encrypted = zipEntry.encrypted && localDirectory.encrypted && !passThrough;
|
|
5103
5164
|
const zipCrypto = encrypted && !extraFieldAES;
|
|
5104
5165
|
if (!passThrough) {
|
|
@@ -5205,7 +5266,7 @@ class ZipEntry {
|
|
|
5205
5266
|
throw error;
|
|
5206
5267
|
}
|
|
5207
5268
|
} finally {
|
|
5208
|
-
const preventClose = getOptionValue$1(zipEntry, options, OPTION_PREVENT_CLOSE);
|
|
5269
|
+
const preventClose = !ownsWritable(writer) && getOptionValue$1(zipEntry, options, OPTION_PREVENT_CLOSE);
|
|
5209
5270
|
if (!preventClose && writable && !writable.locked) {
|
|
5210
5271
|
const writableWriter = writable.getWriter();
|
|
5211
5272
|
if (abortError) {
|
|
@@ -5334,10 +5395,12 @@ function readCommonFooter(fileEntry, directory, dataView, offset, localDirectory
|
|
|
5334
5395
|
directory.extraFieldNTFS = extraFieldNTFS;
|
|
5335
5396
|
}
|
|
5336
5397
|
const extraFieldUnix = extraField.get(EXTRAFIELD_TYPE_UNIX);
|
|
5398
|
+
let unixIdsRead;
|
|
5337
5399
|
if (extraFieldUnix) {
|
|
5338
|
-
readExtraFieldUnix(extraFieldUnix, directory, false);
|
|
5400
|
+
unixIdsRead = readExtraFieldUnix(extraFieldUnix, directory, false);
|
|
5339
5401
|
directory.extraFieldUnix = extraFieldUnix;
|
|
5340
|
-
}
|
|
5402
|
+
}
|
|
5403
|
+
if (!unixIdsRead) {
|
|
5341
5404
|
const extraFieldInfoZip = extraField.get(EXTRAFIELD_TYPE_INFOZIP);
|
|
5342
5405
|
if (extraFieldInfoZip) {
|
|
5343
5406
|
readExtraFieldUnix(extraFieldInfoZip, directory, true);
|
|
@@ -5440,7 +5503,7 @@ function readExtraFieldNTFS(extraFieldNTFS, directory) {
|
|
|
5440
5503
|
const creationDate = getDateNTFS(rawCreationDate);
|
|
5441
5504
|
const extraFieldData = { lastModDate, lastAccessDate, creationDate };
|
|
5442
5505
|
Object.assign(extraFieldNTFS, extraFieldData);
|
|
5443
|
-
Object.assign(directory, extraFieldData);
|
|
5506
|
+
Object.assign(directory, extraFieldData, { rawLastAccessDate, rawCreationDate });
|
|
5444
5507
|
}
|
|
5445
5508
|
}
|
|
5446
5509
|
|
|
@@ -5449,8 +5512,8 @@ function readExtraFieldUnixDates(extraField, directory) {
|
|
|
5449
5512
|
return;
|
|
5450
5513
|
}
|
|
5451
5514
|
const extraFieldView = getDataView(extraField.data);
|
|
5452
|
-
const lastAccessDate = new Date(getUint32(extraFieldView, 0) * 1000);
|
|
5453
|
-
const lastModDate = new Date(getUint32(extraFieldView, 4) * 1000);
|
|
5515
|
+
const lastAccessDate = new Date((getUint32(extraFieldView, 0) | 0) * 1000);
|
|
5516
|
+
const lastModDate = new Date((getUint32(extraFieldView, 4) | 0) * 1000);
|
|
5454
5517
|
const extraFieldData = { lastAccessDate, lastModDate };
|
|
5455
5518
|
if (extraField.data.length >= 12) {
|
|
5456
5519
|
extraFieldData.uid = getUint16(extraFieldView, 8);
|
|
@@ -5484,6 +5547,7 @@ function readExtraFieldUnix(extraField, directory, isInfoZip) {
|
|
|
5484
5547
|
if (gid !== UNDEFINED_VALUE) {
|
|
5485
5548
|
directory.gid = gid;
|
|
5486
5549
|
}
|
|
5550
|
+
return uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE;
|
|
5487
5551
|
} catch {
|
|
5488
5552
|
// ignored
|
|
5489
5553
|
}
|
|
@@ -5556,26 +5620,25 @@ async function detectOverlappingEntry({
|
|
|
5556
5620
|
}
|
|
5557
5621
|
if (dataDescriptorLength) {
|
|
5558
5622
|
const dataDescriptorArray = await readUint8Array(reader, dataOffset + compressedSize, dataDescriptorLength + DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH);
|
|
5559
|
-
const
|
|
5560
|
-
|
|
5561
|
-
|
|
5562
|
-
|
|
5563
|
-
|
|
5564
|
-
|
|
5565
|
-
if (extraFieldZip64) {
|
|
5566
|
-
readCompressedSize = getBigUint64(getDataView(dataDescriptorArray), 8);
|
|
5567
|
-
readUncompressedSize = getBigUint64(getDataView(dataDescriptorArray), 16);
|
|
5568
|
-
} else {
|
|
5569
|
-
readCompressedSize = getUint32(getDataView(dataDescriptorArray), 8);
|
|
5570
|
-
readUncompressedSize = getUint32(getDataView(dataDescriptorArray), 12);
|
|
5571
|
-
}
|
|
5572
|
-
const matchCrc32 = (fileEntry.encrypted && !fileEntry.zipCrypto) || readCrc32 == crc32;
|
|
5623
|
+
const dataDescriptorView = getDataView(dataDescriptorArray);
|
|
5624
|
+
let signature = dataDescriptorArray.length == dataDescriptorLength + DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH &&
|
|
5625
|
+
getUint32(dataDescriptorView, 0) == DATA_DESCRIPTOR_RECORD_SIGNATURE;
|
|
5626
|
+
if (signature) {
|
|
5627
|
+
const signedDataDescriptor = readDataDescriptor(dataDescriptorView, DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH, extraFieldZip64);
|
|
5628
|
+
const matchCrc32 = (fileEntry.encrypted && !fileEntry.zipCrypto) || signedDataDescriptor.crc32 == crc32;
|
|
5573
5629
|
if (matchCrc32 &&
|
|
5574
|
-
|
|
5575
|
-
|
|
5630
|
+
signedDataDescriptor.compressedSize == compressedSize &&
|
|
5631
|
+
signedDataDescriptor.uncompressedSize == uncompressedSize) {
|
|
5576
5632
|
dataDescriptorLength += DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH;
|
|
5633
|
+
} else {
|
|
5634
|
+
signature = false;
|
|
5577
5635
|
}
|
|
5578
5636
|
}
|
|
5637
|
+
if (dataDescriptorArray.length >= dataDescriptorLength) {
|
|
5638
|
+
const localDataDescriptor = readDataDescriptor(dataDescriptorView, signature ? DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH : 0, extraFieldZip64);
|
|
5639
|
+
localDataDescriptor.signature = signature;
|
|
5640
|
+
fileEntry.localDirectory.dataDescriptor = localDataDescriptor;
|
|
5641
|
+
}
|
|
5579
5642
|
}
|
|
5580
5643
|
const range = {
|
|
5581
5644
|
start: offset,
|
|
@@ -5592,6 +5655,20 @@ async function detectOverlappingEntry({
|
|
|
5592
5655
|
readRanges.set(index, range);
|
|
5593
5656
|
}
|
|
5594
5657
|
|
|
5658
|
+
function readDataDescriptor(dataDescriptorView, offset, extraFieldZip64) {
|
|
5659
|
+
const crc32 = getUint32(dataDescriptorView, offset);
|
|
5660
|
+
let compressedSize;
|
|
5661
|
+
let uncompressedSize;
|
|
5662
|
+
if (extraFieldZip64) {
|
|
5663
|
+
compressedSize = getBigUint64(dataDescriptorView, offset + 4);
|
|
5664
|
+
uncompressedSize = getBigUint64(dataDescriptorView, offset + 12);
|
|
5665
|
+
} else {
|
|
5666
|
+
compressedSize = getUint32(dataDescriptorView, offset + 4);
|
|
5667
|
+
uncompressedSize = getUint32(dataDescriptorView, offset + 8);
|
|
5668
|
+
}
|
|
5669
|
+
return { crc32, compressedSize, uncompressedSize };
|
|
5670
|
+
}
|
|
5671
|
+
|
|
5595
5672
|
function getDiskOffset$1(reader, diskNumber) {
|
|
5596
5673
|
return reader.getDiskOffset ? reader.getDiskOffset(diskNumber) : 0;
|
|
5597
5674
|
}
|
|
@@ -5600,14 +5677,40 @@ function isStrictnessValue(value) {
|
|
|
5600
5677
|
return value === STRICTNESS_STRICT || value === STRICTNESS_BALANCED || value === STRICTNESS_TOLERANT;
|
|
5601
5678
|
}
|
|
5602
5679
|
|
|
5603
|
-
function getStrictness(
|
|
5604
|
-
|
|
5605
|
-
|
|
5680
|
+
function getStrictness(options, inheritedOptions) {
|
|
5681
|
+
return resolveStrictness(options, resolveStrictness(inheritedOptions, STRICTNESS_BALANCED));
|
|
5682
|
+
}
|
|
5683
|
+
|
|
5684
|
+
function resolveStrictness(options, inheritedStrictness) {
|
|
5685
|
+
const strictness = options[OPTION_STRICTNESS];
|
|
5686
|
+
if (strictness !== UNDEFINED_VALUE) {
|
|
5687
|
+
if (!isStrictnessValue(strictness)) {
|
|
5688
|
+
throw new Error(ERR_INVALID_STRICTNESS);
|
|
5689
|
+
}
|
|
5690
|
+
return strictness;
|
|
5606
5691
|
}
|
|
5607
|
-
|
|
5608
|
-
|
|
5692
|
+
const checkAmbiguity = options[OPTION_CHECK_AMBIGUITY];
|
|
5693
|
+
if (checkAmbiguity === UNDEFINED_VALUE) {
|
|
5694
|
+
return inheritedStrictness;
|
|
5695
|
+
}
|
|
5696
|
+
if (checkAmbiguity) {
|
|
5697
|
+
return STRICTNESS_STRICT;
|
|
5698
|
+
}
|
|
5699
|
+
return inheritedStrictness == STRICTNESS_TOLERANT ? STRICTNESS_TOLERANT : STRICTNESS_BALANCED;
|
|
5700
|
+
}
|
|
5701
|
+
|
|
5702
|
+
function getCheckLocalDirectory(checkLocalDirectory, strictness) {
|
|
5703
|
+
if (checkLocalDirectory === UNDEFINED_VALUE) {
|
|
5704
|
+
return strictness != STRICTNESS_TOLERANT;
|
|
5609
5705
|
}
|
|
5610
|
-
return
|
|
5706
|
+
return Boolean(checkLocalDirectory);
|
|
5707
|
+
}
|
|
5708
|
+
|
|
5709
|
+
function getCheckLocalFilename(checkLocalFilename, strictness) {
|
|
5710
|
+
if (checkLocalFilename === UNDEFINED_VALUE) {
|
|
5711
|
+
return strictness == STRICTNESS_STRICT;
|
|
5712
|
+
}
|
|
5713
|
+
return Boolean(checkLocalFilename);
|
|
5611
5714
|
}
|
|
5612
5715
|
|
|
5613
5716
|
function getFilenameValidation(filenameValidation, strictness) {
|
|
@@ -5755,10 +5858,11 @@ async function readSignature(reader, view, anchoredOffset, signatureOffset, size
|
|
|
5755
5858
|
return UNDEFINED_VALUE;
|
|
5756
5859
|
}
|
|
5757
5860
|
|
|
5758
|
-
function
|
|
5861
|
+
function validateLocalDirectory(zipEntry, localDirectory, rawLocalFilename, checkLocalFilename) {
|
|
5759
5862
|
const { rawFilename } = zipEntry;
|
|
5760
|
-
if (
|
|
5761
|
-
rawLocalFilename.
|
|
5863
|
+
if (checkLocalFilename &&
|
|
5864
|
+
(rawLocalFilename.length != rawFilename.length ||
|
|
5865
|
+
rawLocalFilename.some((byteValue, indexByte) => byteValue != rawFilename[indexByte]))) {
|
|
5762
5866
|
throwAmbiguousArchive("mismatched local file header (filename)");
|
|
5763
5867
|
}
|
|
5764
5868
|
if ((localDirectory.rawBitFlag & BITFLAG_AMBIGUITY_MASK) != (zipEntry.rawBitFlag & BITFLAG_AMBIGUITY_MASK)) {
|
|
@@ -5876,11 +5980,13 @@ var zipReader = /*#__PURE__*/Object.freeze({
|
|
|
5876
5980
|
|
|
5877
5981
|
const ERR_DUPLICATED_NAME = "File already exists";
|
|
5878
5982
|
const ERR_INVALID_COMMENT = "Zip file comment exceeds 64KB";
|
|
5983
|
+
const ERR_INVALID_COMMENT_TYPE = "Invalid zip file comment (must be a Uint8Array)";
|
|
5879
5984
|
const ERR_INVALID_ENTRY_COMMENT = "File entry comment exceeds 64KB";
|
|
5880
5985
|
const ERR_INVALID_ENTRY_NAME = "File entry name exceeds 64KB";
|
|
5881
5986
|
const ERR_INVALID_VERSION = "Version exceeds 65535";
|
|
5882
5987
|
const ERR_INVALID_ENCRYPTION_STRENGTH = "The strength must equal 1, 2, or 3";
|
|
5883
5988
|
const ERR_UNSUPPORTED_ENCRYPTION_USDZ = "Encryption is not supported in USDZ files";
|
|
5989
|
+
const ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH = "Encryption is not supported when the 'passThrough' option is set";
|
|
5884
5990
|
const ERR_INVALID_EXTRAFIELD_TYPE = "Extra field type exceeds 65535";
|
|
5885
5991
|
const ERR_INVALID_EXTRAFIELD_DATA = "Extra field data exceeds 64KB";
|
|
5886
5992
|
const ERR_UNSUPPORTED_COMPRESSION = "Compression method not supported";
|
|
@@ -5890,6 +5996,7 @@ const MIN_NTFS_TIME = BigInt(0);
|
|
|
5890
5996
|
const MAX_NTFS_TIME = BigInt("0x7fffffffffffffff");
|
|
5891
5997
|
const ERR_UNSUPPORTED_FORMAT = "Zip64 is not supported (set the 'zip64' option to 'true')";
|
|
5892
5998
|
const ERR_UNDEFINED_UNCOMPRESSED_SIZE = "Undefined uncompressed size";
|
|
5999
|
+
const ERR_UNDETERMINED_SIZE = "Undetermined size";
|
|
5893
6000
|
const ERR_UNDEFINED_READER = "Undefined reader";
|
|
5894
6001
|
const ERR_ZIP_NOT_EMPTY = "Zip file not empty";
|
|
5895
6002
|
const ERR_INVALID_UID = "Invalid uid (must be integer 0..2^32-1)";
|
|
@@ -5942,6 +6049,10 @@ class ZipWriter {
|
|
|
5942
6049
|
}
|
|
5943
6050
|
reader = new GenericReader(reader);
|
|
5944
6051
|
await initStream(reader);
|
|
6052
|
+
if (reader.size === UNDEFINED_VALUE || !reader.readUint8Array) {
|
|
6053
|
+
reader = new BlobReader(await streamToBlob(reader.readable));
|
|
6054
|
+
await initStream(reader);
|
|
6055
|
+
}
|
|
5945
6056
|
const { ZipReader } = await Promise.resolve().then(function () { return zipReader; });
|
|
5946
6057
|
const zipReader$1 = new ZipReader(reader.readable);
|
|
5947
6058
|
const entries = await zipReader$1.getEntries();
|
|
@@ -6090,6 +6201,9 @@ class ZipWriter {
|
|
|
6090
6201
|
const zipWriter = this;
|
|
6091
6202
|
const { pendingAddFileCalls, writer } = this;
|
|
6092
6203
|
const { writable } = writer;
|
|
6204
|
+
if (!(comment instanceof Uint8Array)) {
|
|
6205
|
+
throw new Error(ERR_INVALID_COMMENT_TYPE);
|
|
6206
|
+
}
|
|
6093
6207
|
if (getLength(comment) > MAX_16_BITS) {
|
|
6094
6208
|
throw new Error(ERR_INVALID_COMMENT);
|
|
6095
6209
|
}
|
|
@@ -6097,7 +6211,7 @@ class ZipWriter {
|
|
|
6097
6211
|
await Promise.allSettled(Array.from(pendingAddFileCalls));
|
|
6098
6212
|
}
|
|
6099
6213
|
await closeFile(zipWriter, comment, options);
|
|
6100
|
-
const preventClose = getOptionValue(zipWriter, options, OPTION_PREVENT_CLOSE);
|
|
6214
|
+
const preventClose = !ownsWritable(writer) && getOptionValue(zipWriter, options, OPTION_PREVENT_CLOSE);
|
|
6101
6215
|
if (!preventClose) {
|
|
6102
6216
|
await writable.getWriter().close();
|
|
6103
6217
|
}
|
|
@@ -6186,8 +6300,6 @@ async function addFile(zipWriter, name, reader, options) {
|
|
|
6186
6300
|
const diskOffset = getDiskOffset(zipWriter.writer);
|
|
6187
6301
|
const diskNumber = getDiskNumber(zipWriter.writer);
|
|
6188
6302
|
options = Object.assign({}, options, attributesInfo.resolvedOptions, metadataInfo.resolvedOptions, sizesInfo.resolvedOptions, {
|
|
6189
|
-
internalFileAttribute: metadataInfo.resolvedOptions.internalFileAttributes,
|
|
6190
|
-
externalFileAttribute: attributesInfo.resolvedOptions.externalFileAttributes,
|
|
6191
6303
|
signature: options[PROPERTY_NAME_SIGNATURE],
|
|
6192
6304
|
crc32: options.crc32 === UNDEFINED_VALUE ? options[PROPERTY_NAME_SIGNATURE] : options.crc32,
|
|
6193
6305
|
offset: zipWriter.offset - diskOffset,
|
|
@@ -6201,14 +6313,20 @@ async function addFile(zipWriter, name, reader, options) {
|
|
|
6201
6313
|
zipWriter.files.delete(name);
|
|
6202
6314
|
throw error;
|
|
6203
6315
|
}
|
|
6204
|
-
Object.assign(fileEntry, {
|
|
6316
|
+
Object.assign(fileEntry, {
|
|
6317
|
+
name,
|
|
6318
|
+
comment,
|
|
6319
|
+
extraField,
|
|
6320
|
+
[PROPERTY_NAME_DEPRECATED_INTERNAL_FILE_ATTRIBUTES]: fileEntry.internalFileAttributes,
|
|
6321
|
+
[PROPERTY_NAME_DEPRECATED_EXTERNAL_FILE_ATTRIBUTES]: fileEntry.externalFileAttributes
|
|
6322
|
+
});
|
|
6205
6323
|
return new Entry(fileEntry);
|
|
6206
6324
|
}
|
|
6207
6325
|
|
|
6208
6326
|
function resolveAttributes(zipWriter, name, options) {
|
|
6209
6327
|
name = name.trim();
|
|
6210
6328
|
let msDosCompatible = getOptionValue(zipWriter, options, PROPERTY_NAME_MS_DOS_COMPATIBLE);
|
|
6211
|
-
let versionMadeBy = getOptionValue(zipWriter, options, PROPERTY_NAME_VERSION_MADE_BY, msDosCompatible ?
|
|
6329
|
+
let versionMadeBy = getOptionValue(zipWriter, options, PROPERTY_NAME_VERSION_MADE_BY, msDosCompatible ? VERSION_MADE_BY_MSDOS : VERSION_MADE_BY_UNIX);
|
|
6212
6330
|
const executable = getOptionValue(zipWriter, options, PROPERTY_NAME_EXECUTABLE);
|
|
6213
6331
|
const uid = getNumberOptionValue(zipWriter, options, PROPERTY_NAME_UID);
|
|
6214
6332
|
const gid = getNumberOptionValue(zipWriter, options, PROPERTY_NAME_GID);
|
|
@@ -6242,7 +6360,7 @@ function resolveAttributes(zipWriter, name, options) {
|
|
|
6242
6360
|
const hasMsDosProvided = msdosAttributesRaw !== UNDEFINED_VALUE || msdosAttributes !== UNDEFINED_VALUE;
|
|
6243
6361
|
if (hasUnixMetadata) {
|
|
6244
6362
|
msDosCompatible = false;
|
|
6245
|
-
versionMadeBy = (versionMadeBy &
|
|
6363
|
+
versionMadeBy = (versionMadeBy & MAX_8_BITS) | VERSION_MADE_BY_UNIX;
|
|
6246
6364
|
} else if (hasMsDosProvided) {
|
|
6247
6365
|
msDosCompatible = true;
|
|
6248
6366
|
versionMadeBy = (versionMadeBy & MAX_8_BITS);
|
|
@@ -6256,7 +6374,7 @@ function resolveAttributes(zipWriter, name, options) {
|
|
|
6256
6374
|
if (versionMadeBy > MAX_16_BITS) {
|
|
6257
6375
|
throw new Error(ERR_INVALID_VERSION);
|
|
6258
6376
|
}
|
|
6259
|
-
let externalFileAttributes =
|
|
6377
|
+
let externalFileAttributes = getAliasedOptionValue(zipWriter, options, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES, PROPERTY_NAME_DEPRECATED_EXTERNAL_FILE_ATTRIBUTES);
|
|
6260
6378
|
const externalFileAttributesProvided = externalFileAttributes !== UNDEFINED_VALUE;
|
|
6261
6379
|
if (!externalFileAttributesProvided) {
|
|
6262
6380
|
externalFileAttributes = 0;
|
|
@@ -6282,11 +6400,10 @@ function resolveAttributes(zipWriter, name, options) {
|
|
|
6282
6400
|
externalFileAttributes = FILE_ATTR_UNIX_DEFAULT_MASK << 16;
|
|
6283
6401
|
}
|
|
6284
6402
|
}
|
|
6285
|
-
let unixExternalUpper;
|
|
6286
6403
|
if (!msDosCompatible) {
|
|
6287
6404
|
const unixModeProvided = unixMode !== UNDEFINED_VALUE || Boolean(setuid || setgid || sticky);
|
|
6288
|
-
|
|
6289
|
-
unixMode = unixMode === UNDEFINED_VALUE ?
|
|
6405
|
+
const defaultUnixMode = (externalFileAttributes >> 16) & MAX_16_BITS;
|
|
6406
|
+
unixMode = unixMode === UNDEFINED_VALUE ? defaultUnixMode : (unixMode & MAX_16_BITS);
|
|
6290
6407
|
if (setuid) {
|
|
6291
6408
|
unixMode |= FILE_ATTR_UNIX_SETUID_MASK;
|
|
6292
6409
|
} else {
|
|
@@ -6304,7 +6421,9 @@ function resolveAttributes(zipWriter, name, options) {
|
|
|
6304
6421
|
}
|
|
6305
6422
|
if (!externalFileAttributesProvided || unixModeProvided) {
|
|
6306
6423
|
if (directory) {
|
|
6307
|
-
unixMode
|
|
6424
|
+
unixMode = (unixMode & ~FILE_ATTR_UNIX_TYPE_MASK) | FILE_ATTR_UNIX_TYPE_DIR;
|
|
6425
|
+
} else if (!(unixMode & FILE_ATTR_UNIX_TYPE_MASK)) {
|
|
6426
|
+
unixMode |= FILE_ATTR_UNIX_TYPE_FILE;
|
|
6308
6427
|
}
|
|
6309
6428
|
externalFileAttributes = ((unixMode & MAX_16_BITS) << 16) | (externalFileAttributes & MAX_16_BITS);
|
|
6310
6429
|
}
|
|
@@ -6313,17 +6432,20 @@ function resolveAttributes(zipWriter, name, options) {
|
|
|
6313
6432
|
if (hasMsDosProvided) {
|
|
6314
6433
|
externalFileAttributes = (externalFileAttributes & MAX_32_BITS) | (msdosAttributesRaw & MAX_8_BITS);
|
|
6315
6434
|
}
|
|
6435
|
+
const unixExternalUpper = (externalFileAttributes >> 16) & MAX_16_BITS;
|
|
6436
|
+
const symlink = unixMode !== UNDEFINED_VALUE && ((unixMode & FILE_ATTR_UNIX_TYPE_MASK) == FILE_ATTR_UNIX_TYPE_SYMLINK);
|
|
6316
6437
|
return {
|
|
6317
6438
|
name,
|
|
6318
6439
|
resolvedOptions: {
|
|
6319
6440
|
versionMadeBy,
|
|
6320
|
-
msDosCompatible,
|
|
6441
|
+
msDosCompatible: Boolean(msDosCompatible),
|
|
6321
6442
|
externalFileAttributes,
|
|
6322
6443
|
unixExternalUpper,
|
|
6323
6444
|
uid,
|
|
6324
6445
|
gid,
|
|
6325
6446
|
unixMode,
|
|
6326
6447
|
unixExtraFieldType,
|
|
6448
|
+
symlink,
|
|
6327
6449
|
setuid,
|
|
6328
6450
|
setgid,
|
|
6329
6451
|
sticky,
|
|
@@ -6357,15 +6479,12 @@ function resolveMetadata(zipWriter, name, options) {
|
|
|
6357
6479
|
const lastModDate = getOptionValue(zipWriter, options, PROPERTY_NAME_LAST_MODIFICATION_DATE, new Date());
|
|
6358
6480
|
const lastAccessDate = getOptionValue(zipWriter, options, PROPERTY_NAME_LAST_ACCESS_DATE);
|
|
6359
6481
|
const creationDate = getOptionValue(zipWriter, options, PROPERTY_NAME_CREATION_DATE);
|
|
6360
|
-
const internalFileAttributes =
|
|
6482
|
+
const internalFileAttributes = getAliasedOptionValue(zipWriter, options, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES, PROPERTY_NAME_DEPRECATED_INTERNAL_FILE_ATTRIBUTES, 0);
|
|
6361
6483
|
const passThrough = getOptionValue(zipWriter, options, OPTION_PASS_THROUGH);
|
|
6362
|
-
|
|
6363
|
-
|
|
6364
|
-
|
|
6365
|
-
|
|
6366
|
-
if ((password && typeof password != STRING_TYPE) || (rawPassword && !(rawPassword instanceof Uint8Array))) {
|
|
6367
|
-
throw new Error(ERR_INVALID_PASSWORD_TYPE);
|
|
6368
|
-
}
|
|
6484
|
+
const password = getOptionValue(zipWriter, options, OPTION_PASSWORD);
|
|
6485
|
+
const rawPassword = getOptionValue(zipWriter, options, OPTION_RAW_PASSWORD);
|
|
6486
|
+
if ((password && typeof password != STRING_TYPE) || (rawPassword && !(rawPassword instanceof Uint8Array))) {
|
|
6487
|
+
throw new Error(ERR_INVALID_PASSWORD_TYPE);
|
|
6369
6488
|
}
|
|
6370
6489
|
const encryptionStrength = getNumberOptionValue(zipWriter, options, OPTION_ENCRYPTION_STRENGTH, 3);
|
|
6371
6490
|
const zipCrypto = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIPCRYPTO);
|
|
@@ -6478,14 +6597,24 @@ function serializeExtraField(extraField) {
|
|
|
6478
6597
|
}
|
|
6479
6598
|
|
|
6480
6599
|
async function resolveSizes(zipWriter, reader, { resolvedOptions: metadata }, options) {
|
|
6600
|
+
if (metadata.passThrough && !reader && !getOptionValue(zipWriter, options, PROPERTY_NAME_DIRECTORY)) {
|
|
6601
|
+
throw new Error(ERR_UNDEFINED_READER);
|
|
6602
|
+
}
|
|
6603
|
+
let contentSize;
|
|
6604
|
+
if (reader) {
|
|
6605
|
+
reader = new GenericReader(reader);
|
|
6606
|
+
await initStream(reader);
|
|
6607
|
+
({ size: contentSize } = reader);
|
|
6608
|
+
}
|
|
6609
|
+
return Object.assign({ reader }, resolveEntrySizes(zipWriter, Boolean(reader), contentSize, metadata, options));
|
|
6610
|
+
}
|
|
6611
|
+
|
|
6612
|
+
function resolveEntrySizes(zipWriter, hasContent, contentSize, metadata, options) {
|
|
6481
6613
|
const { passThrough, zipCrypto, password, rawPassword, encryptionStrength } = metadata;
|
|
6482
6614
|
let { dataDescriptor, zip64, level, compressionMethod } = metadata;
|
|
6483
6615
|
let maximumCompressedSize = 0;
|
|
6484
6616
|
let uncompressedSize = 0;
|
|
6485
|
-
if (passThrough) {
|
|
6486
|
-
if (!reader) {
|
|
6487
|
-
throw new Error(ERR_UNDEFINED_READER);
|
|
6488
|
-
}
|
|
6617
|
+
if (passThrough && hasContent) {
|
|
6489
6618
|
uncompressedSize = options[PROPERTY_NAME_UNCOMPRESSED_SIZE];
|
|
6490
6619
|
if (uncompressedSize === UNDEFINED_VALUE) {
|
|
6491
6620
|
throw new Error(ERR_UNDEFINED_UNCOMPRESSED_SIZE);
|
|
@@ -6493,29 +6622,30 @@ async function resolveSizes(zipWriter, reader, { resolvedOptions: metadata }, op
|
|
|
6493
6622
|
}
|
|
6494
6623
|
const zip64Enabled = zip64 === true;
|
|
6495
6624
|
const encrypted = getOptionValue(zipWriter, options, PROPERTY_NAME_ENCRYPTED);
|
|
6496
|
-
|
|
6497
|
-
|
|
6625
|
+
if (hasContent && passThrough && !encrypted && getLength(password, rawPassword)) {
|
|
6626
|
+
throw new Error(ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH);
|
|
6627
|
+
}
|
|
6628
|
+
const encryptedEntry = hasContent && (Boolean((password && getLength(password)) || (rawPassword && getLength(rawPassword))) || (passThrough && encrypted));
|
|
6629
|
+
if (!hasContent) {
|
|
6498
6630
|
level = 0;
|
|
6499
6631
|
compressionMethod = COMPRESSION_METHOD_STORE;
|
|
6500
6632
|
}
|
|
6501
6633
|
const encryptionOverhead = encryptedEntry ? (zipCrypto ? 12 : 16 + encryptionStrength * 4) : 0;
|
|
6502
|
-
if (
|
|
6503
|
-
reader = new GenericReader(reader);
|
|
6504
|
-
await initStream(reader);
|
|
6634
|
+
if (hasContent) {
|
|
6505
6635
|
if (!passThrough) {
|
|
6506
|
-
if (
|
|
6636
|
+
if (contentSize === UNDEFINED_VALUE) {
|
|
6507
6637
|
dataDescriptor = true;
|
|
6508
6638
|
if (zip64 || zip64 === UNDEFINED_VALUE) {
|
|
6509
6639
|
zip64 = true;
|
|
6510
6640
|
uncompressedSize = maximumCompressedSize = MAX_32_BITS + 1;
|
|
6511
6641
|
}
|
|
6512
6642
|
} else {
|
|
6513
|
-
options.uncompressedSize = uncompressedSize =
|
|
6514
|
-
maximumCompressedSize = getMaximumCompressedSize(uncompressedSize) + encryptionOverhead;
|
|
6643
|
+
options.uncompressedSize = uncompressedSize = contentSize;
|
|
6644
|
+
maximumCompressedSize = (isCompressed(compressionMethod, level) ? getMaximumCompressedSize(uncompressedSize) : uncompressedSize) + encryptionOverhead;
|
|
6515
6645
|
}
|
|
6516
6646
|
} else {
|
|
6517
6647
|
options.uncompressedSize = uncompressedSize;
|
|
6518
|
-
maximumCompressedSize = getMaximumCompressedSize(uncompressedSize) + encryptionOverhead;
|
|
6648
|
+
maximumCompressedSize = contentSize === UNDEFINED_VALUE ? getMaximumCompressedSize(uncompressedSize) + encryptionOverhead : contentSize;
|
|
6519
6649
|
}
|
|
6520
6650
|
}
|
|
6521
6651
|
const zip64UncompressedSize = zip64Enabled || uncompressedSize >= MAX_32_BITS;
|
|
@@ -6529,7 +6659,7 @@ async function resolveSizes(zipWriter, reader, { resolvedOptions: metadata }, op
|
|
|
6529
6659
|
}
|
|
6530
6660
|
zip64 = zip64 || false;
|
|
6531
6661
|
return {
|
|
6532
|
-
|
|
6662
|
+
maximumCompressedSize,
|
|
6533
6663
|
resolvedOptions: {
|
|
6534
6664
|
dataDescriptor,
|
|
6535
6665
|
zip64,
|
|
@@ -6757,6 +6887,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
|
|
|
6757
6887
|
uid,
|
|
6758
6888
|
gid,
|
|
6759
6889
|
unixMode,
|
|
6890
|
+
symlink,
|
|
6760
6891
|
setuid,
|
|
6761
6892
|
setgid,
|
|
6762
6893
|
sticky,
|
|
@@ -6793,6 +6924,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
|
|
|
6793
6924
|
uid,
|
|
6794
6925
|
gid,
|
|
6795
6926
|
unixMode,
|
|
6927
|
+
symlink: Boolean(symlink),
|
|
6796
6928
|
setuid,
|
|
6797
6929
|
setgid,
|
|
6798
6930
|
sticky,
|
|
@@ -6873,8 +7005,8 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
|
|
|
6873
7005
|
rawLastModDate,
|
|
6874
7006
|
creationDate,
|
|
6875
7007
|
lastAccessDate,
|
|
6876
|
-
encrypted,
|
|
6877
|
-
zipCrypto,
|
|
7008
|
+
encrypted: Boolean(encrypted),
|
|
7009
|
+
zipCrypto: Boolean(zipCrypto),
|
|
6878
7010
|
size: metadataSize + compressedSize,
|
|
6879
7011
|
compressionMethod,
|
|
6880
7012
|
version,
|
|
@@ -6914,9 +7046,7 @@ function getHeaderInfo(options) {
|
|
|
6914
7046
|
crc32
|
|
6915
7047
|
} = options;
|
|
6916
7048
|
let { version, compressionMethod } = options;
|
|
6917
|
-
const compressed = !directory && (compressionMethod
|
|
6918
|
-
? (level === UNDEFINED_VALUE || level > 0)
|
|
6919
|
-
: compressionMethod !== COMPRESSION_METHOD_STORE);
|
|
7049
|
+
const compressed = !directory && isCompressed(compressionMethod, level);
|
|
6920
7050
|
let rawLocalExtraFieldZip64;
|
|
6921
7051
|
const uncompressedFile = passThrough || !compressed;
|
|
6922
7052
|
const zip64ExtraFieldComplete = zip64 && (options.bufferedWrite || !dataDescriptor || ((!zip64UncompressedSize && !zip64CompressedSize) || uncompressedFile));
|
|
@@ -7603,6 +7733,16 @@ function getOptionValue(zipWriter, options, name, defaultValue) {
|
|
|
7603
7733
|
return result === UNDEFINED_VALUE ? defaultValue : result;
|
|
7604
7734
|
}
|
|
7605
7735
|
|
|
7736
|
+
function getAliasedOptionValue(zipWriter, options, name, deprecatedName, defaultValue) {
|
|
7737
|
+
const value = getAliasedValue(options, name, deprecatedName);
|
|
7738
|
+
const result = value === UNDEFINED_VALUE ? getAliasedValue(zipWriter.options, name, deprecatedName) : value;
|
|
7739
|
+
return result === UNDEFINED_VALUE ? defaultValue : result;
|
|
7740
|
+
}
|
|
7741
|
+
|
|
7742
|
+
function getAliasedValue(options, name, deprecatedName) {
|
|
7743
|
+
return options[name] === UNDEFINED_VALUE ? options[deprecatedName] : options[name];
|
|
7744
|
+
}
|
|
7745
|
+
|
|
7606
7746
|
function getNumberOptionValue(zipWriter, options, name, defaultValue) {
|
|
7607
7747
|
return toNumber(getOptionValue(zipWriter, options, name, defaultValue));
|
|
7608
7748
|
}
|
|
@@ -7615,6 +7755,12 @@ function getMaximumCompressedSize(uncompressedSize) {
|
|
|
7615
7755
|
return uncompressedSize + (5 * (Math.floor(uncompressedSize / 16383) + 1));
|
|
7616
7756
|
}
|
|
7617
7757
|
|
|
7758
|
+
function isCompressed(compressionMethod, level) {
|
|
7759
|
+
return compressionMethod === UNDEFINED_VALUE
|
|
7760
|
+
? (level === UNDEFINED_VALUE || level > 0)
|
|
7761
|
+
: compressionMethod !== COMPRESSION_METHOD_STORE;
|
|
7762
|
+
}
|
|
7763
|
+
|
|
7618
7764
|
function setUint8(view, offset, value) {
|
|
7619
7765
|
view.setUint8(offset, value);
|
|
7620
7766
|
}
|
|
@@ -8569,4 +8715,4 @@ function terminateWorkersAndModule() {
|
|
|
8569
8715
|
|
|
8570
8716
|
configureExternalAssets();
|
|
8571
8717
|
|
|
8572
|
-
export { BlobReader, BlobWriter, Data64URIReader, Data64URIWriter, ERR_AMBIGUOUS_ARCHIVE, ERR_BAD_FORMAT, ERR_CENTRAL_DIRECTORY_NOT_FOUND, ERR_DUPLICATED_NAME, ERR_ENCRYPTED, ERR_ENCRYPTED_CENTRAL_DIRECTORY, 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_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_RESERVED_COMPRESSION_METHOD, ERR_SPLIT_ZIP_FILE, ERR_UNDEFINED_READER, ERR_UNDEFINED_UNCOMPRESSED_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_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, getMimeType, registerCodec, resetConfiguration, terminateWorkersAndModule as terminateWorkers, unregisterCodec };
|
|
8718
|
+
export { BlobReader, BlobWriter, Data64URIReader, Data64URIWriter, ERR_AMBIGUOUS_ARCHIVE, ERR_BAD_FORMAT, ERR_CENTRAL_DIRECTORY_NOT_FOUND, ERR_DUPLICATED_NAME, ERR_ENCRYPTED, ERR_ENCRYPTED_CENTRAL_DIRECTORY, 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_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_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, getMimeType, registerCodec, resetConfiguration, terminateWorkersAndModule as terminateWorkers, unregisterCodec };
|