@zip.js/zip.js 2.8.44 → 2.8.46
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 +28 -2
- package/deno.json +32 -2
- package/dist/zip-core-external.js +199 -149
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +196 -120
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +251 -157
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +227 -126
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +272 -1751
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +273 -1726
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +273 -1726
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +198 -122
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +200 -124
- package/dist/zip-native.min.js +1 -1
- package/dist/zip-web-worker-native.js +1 -1
- package/dist/zip-web-worker.js +1 -1
- package/dist/zip.js +200 -124
- package/dist/zip.min.js +1 -1
- package/eslint.config.mjs +31 -2
- package/index-native.cjs +273 -1726
- package/index-native.min.js +1 -1
- package/index.cjs +273 -1726
- package/index.d.cts +140 -2
- package/index.d.ts +140 -2
- package/index.min.js +1 -1
- package/lib/core/codec-pool.js +3 -2
- package/lib/core/codec-worker.js +30 -14
- package/lib/core/configuration.js +20 -2
- package/lib/core/constants.js +4 -0
- package/lib/core/options.js +2 -0
- package/lib/core/streams/aes-crypto-stream.js +15 -18
- package/lib/core/streams/codec-stream.js +2 -2
- package/lib/core/streams/zip-entry-stream.js +13 -18
- package/lib/core/util/mime-type-data.js +3 -0
- package/lib/core/util/mime-type.js +23 -1596
- package/lib/core/web-worker-base.js +29 -2
- package/lib/core/web-worker-inline-native.js +1 -1
- package/lib/core/web-worker-inline-wasm.js +1 -1
- package/lib/core/web-worker-native.js +7 -9
- package/lib/core/web-worker-wasm.js +9 -12
- package/lib/core/zip-entry.js +8 -1
- package/lib/core/zip-fs.js +62 -5
- package/lib/core/zip-reader.js +45 -17
- package/lib/core/zip-writer.js +58 -44
- package/lib/{core/web-worker-inline-template.js → zip-core-custom.js} +13 -20
- package/lib/zip-core-external.js +2 -0
- package/lib/zip-fs-core-external.js +2 -0
- package/lib/zip-fs-external.js +2 -0
- package/lib/zip-mime-types.js +2 -0
- package/lib/zip-module-native.js +3 -3
- package/lib/zip-module-wasm-base.js +3 -3
- package/package.json +28 -4
- package/worker-message-property-names.js +1 -1
- package/lib/core/web-worker-inline-template-native.js +0 -48
- package/lib/core/zlib-streams-inline-template.js +0 -45
|
@@ -62,6 +62,8 @@ const EXTRAFIELD_TYPE_UNICODE_COMMENT = 0x6375;
|
|
|
62
62
|
const EXTRAFIELD_TYPE_USDZ = 0x1986;
|
|
63
63
|
const EXTRAFIELD_TYPE_INFOZIP = 0x7875;
|
|
64
64
|
const EXTRAFIELD_TYPE_UNIX = 0x7855;
|
|
65
|
+
const EXTRAFIELD_TYPE_UNIX_TYPE1 = 0x5855;
|
|
66
|
+
const EXTRAFIELD_TYPE_PKWARE_UNIX = 0x000d;
|
|
65
67
|
|
|
66
68
|
const BITFLAG_ENCRYPTED = 0b1;
|
|
67
69
|
const BITFLAG_LEVEL = 0b0110;
|
|
@@ -165,6 +167,7 @@ const CONFIGURABLE_PROPERTY_NAMES = [
|
|
|
165
167
|
"baseURI",
|
|
166
168
|
"wasmURI",
|
|
167
169
|
"workerURI",
|
|
170
|
+
"createWorker",
|
|
168
171
|
"chunkSize",
|
|
169
172
|
"maxWorkers",
|
|
170
173
|
"terminateWorkerTimeout",
|
|
@@ -175,8 +178,8 @@ const CONFIGURABLE_PROPERTY_NAMES = [
|
|
|
175
178
|
"transferStreams",
|
|
176
179
|
"CompressionStream",
|
|
177
180
|
"DecompressionStream",
|
|
178
|
-
"
|
|
179
|
-
"
|
|
181
|
+
"CompressionStreamFallback",
|
|
182
|
+
"DecompressionStreamFallback"
|
|
180
183
|
];
|
|
181
184
|
|
|
182
185
|
const config = { ...DEFAULT_CONFIGURATION };
|
|
@@ -190,6 +193,7 @@ function getChunkSize(config) {
|
|
|
190
193
|
}
|
|
191
194
|
|
|
192
195
|
function configure(configuration) {
|
|
196
|
+
configuration = normalizeConfiguration(configuration);
|
|
193
197
|
for (const propertyName of CONFIGURABLE_PROPERTY_NAMES) {
|
|
194
198
|
const propertyValue = configuration[propertyName];
|
|
195
199
|
if (propertyValue !== UNDEFINED_VALUE) {
|
|
@@ -198,7 +202,23 @@ function configure(configuration) {
|
|
|
198
202
|
}
|
|
199
203
|
}
|
|
200
204
|
|
|
205
|
+
function normalizeConfiguration(configuration) {
|
|
206
|
+
const { CompressionStreamZlib, DecompressionStreamZlib } = configuration;
|
|
207
|
+
if (CompressionStreamZlib === UNDEFINED_VALUE && DecompressionStreamZlib === UNDEFINED_VALUE) {
|
|
208
|
+
return configuration;
|
|
209
|
+
}
|
|
210
|
+
const normalizedConfiguration = Object.assign({}, configuration);
|
|
211
|
+
if (normalizedConfiguration.CompressionStreamFallback === UNDEFINED_VALUE) {
|
|
212
|
+
normalizedConfiguration.CompressionStreamFallback = CompressionStreamZlib;
|
|
213
|
+
}
|
|
214
|
+
if (normalizedConfiguration.DecompressionStreamFallback === UNDEFINED_VALUE) {
|
|
215
|
+
normalizedConfiguration.DecompressionStreamFallback = DecompressionStreamZlib;
|
|
216
|
+
}
|
|
217
|
+
return normalizedConfiguration;
|
|
218
|
+
}
|
|
219
|
+
|
|
201
220
|
function setDefaultConfiguration(configuration) {
|
|
221
|
+
configuration = normalizeConfiguration(configuration);
|
|
202
222
|
for (const propertyName of CONFIGURABLE_PROPERTY_NAMES) {
|
|
203
223
|
const propertyValue = configuration[propertyName];
|
|
204
224
|
if (propertyValue !== UNDEFINED_VALUE) {
|
|
@@ -1447,7 +1467,7 @@ const DERIVED_BITS_ALGORITHM = Object.assign({ iterations: 1000, hash: { name: H
|
|
|
1447
1467
|
const DERIVED_BITS_USAGE = ["deriveBits"];
|
|
1448
1468
|
const SALT_LENGTH = [8, 12, 16];
|
|
1449
1469
|
const KEY_LENGTH = [16, 24, 32];
|
|
1450
|
-
const
|
|
1470
|
+
const AUTHENTICATION_CODE_LENGTH = 10;
|
|
1451
1471
|
const COUNTER_DEFAULT_VALUE = [0, 0, 0, 0];
|
|
1452
1472
|
// deno-lint-ignore valid-typeof
|
|
1453
1473
|
const CRYPTO_API_SUPPORTED = typeof crypto != UNDEFINED_TYPE;
|
|
@@ -1487,8 +1507,8 @@ class AESDecryptionStream extends TransformStream {
|
|
|
1487
1507
|
} else {
|
|
1488
1508
|
await ready;
|
|
1489
1509
|
}
|
|
1490
|
-
const output = new Uint8Array(chunk.length -
|
|
1491
|
-
controller.enqueue(append(aesCrypto, chunk, output, 0,
|
|
1510
|
+
const output = new Uint8Array(chunk.length - AUTHENTICATION_CODE_LENGTH - ((chunk.length - AUTHENTICATION_CODE_LENGTH) % BLOCK_LENGTH));
|
|
1511
|
+
controller.enqueue(append(aesCrypto, chunk, output, 0, AUTHENTICATION_CODE_LENGTH, true));
|
|
1492
1512
|
},
|
|
1493
1513
|
async flush(controller) {
|
|
1494
1514
|
const {
|
|
@@ -1499,8 +1519,8 @@ class AESDecryptionStream extends TransformStream {
|
|
|
1499
1519
|
} = this;
|
|
1500
1520
|
if (hmac && ctr) {
|
|
1501
1521
|
await ready;
|
|
1502
|
-
const chunkToDecrypt = subarray(pending, 0, pending.length -
|
|
1503
|
-
const
|
|
1522
|
+
const chunkToDecrypt = subarray(pending, 0, pending.length - AUTHENTICATION_CODE_LENGTH);
|
|
1523
|
+
const originalAuthenticationCode = subarray(pending, pending.length - AUTHENTICATION_CODE_LENGTH);
|
|
1504
1524
|
let decryptedChunkArray = EMPTY_UINT8_ARRAY;
|
|
1505
1525
|
if (chunkToDecrypt.length) {
|
|
1506
1526
|
const encryptedChunk = toBits(codecBytes, chunkToDecrypt);
|
|
@@ -1508,12 +1528,12 @@ class AESDecryptionStream extends TransformStream {
|
|
|
1508
1528
|
const decryptedChunk = ctr.update(encryptedChunk);
|
|
1509
1529
|
decryptedChunkArray = fromBits(codecBytes, decryptedChunk);
|
|
1510
1530
|
}
|
|
1511
|
-
const
|
|
1512
|
-
let
|
|
1513
|
-
for (let
|
|
1514
|
-
|
|
1531
|
+
const authenticationCode = subarray(fromBits(codecBytes, hmac.digest()), 0, AUTHENTICATION_CODE_LENGTH);
|
|
1532
|
+
let invalidAuthenticationCode = pending.length < AUTHENTICATION_CODE_LENGTH ? 1 : 0;
|
|
1533
|
+
for (let indexByte = 0; indexByte < AUTHENTICATION_CODE_LENGTH; indexByte++) {
|
|
1534
|
+
invalidAuthenticationCode |= authenticationCode[indexByte] ^ originalAuthenticationCode[indexByte];
|
|
1515
1535
|
}
|
|
1516
|
-
if (
|
|
1536
|
+
if (invalidAuthenticationCode && checkAuthenticationCode) {
|
|
1517
1537
|
throw new Error(ERR_INVALID_AUTHENTICATION_CODE);
|
|
1518
1538
|
}
|
|
1519
1539
|
controller.enqueue(decryptedChunkArray);
|
|
@@ -1526,8 +1546,6 @@ class AESDecryptionStream extends TransformStream {
|
|
|
1526
1546
|
class AESEncryptionStream extends TransformStream {
|
|
1527
1547
|
|
|
1528
1548
|
constructor({ password, rawPassword, encryptionStrength }) {
|
|
1529
|
-
// deno-lint-ignore prefer-const
|
|
1530
|
-
let stream;
|
|
1531
1549
|
super({
|
|
1532
1550
|
start() {
|
|
1533
1551
|
initAesCrypto(this, password, rawPassword, encryptionStrength);
|
|
@@ -1566,12 +1584,11 @@ class AESEncryptionStream extends TransformStream {
|
|
|
1566
1584
|
hmac.update(encryptedChunk);
|
|
1567
1585
|
encryptedChunkArray = fromBits(codecBytes, encryptedChunk);
|
|
1568
1586
|
}
|
|
1569
|
-
|
|
1570
|
-
controller.enqueue(concat(encryptedChunkArray,
|
|
1587
|
+
const authenticationCode = fromBits(codecBytes, hmac.digest()).slice(0, AUTHENTICATION_CODE_LENGTH);
|
|
1588
|
+
controller.enqueue(concat(encryptedChunkArray, authenticationCode));
|
|
1571
1589
|
}
|
|
1572
1590
|
}
|
|
1573
1591
|
});
|
|
1574
|
-
stream = this;
|
|
1575
1592
|
}
|
|
1576
1593
|
}
|
|
1577
1594
|
|
|
@@ -1584,7 +1601,7 @@ function initAesCrypto(aesCrypto, password, rawPassword, encryptionStrength) {
|
|
|
1584
1601
|
});
|
|
1585
1602
|
}
|
|
1586
1603
|
|
|
1587
|
-
function append(aesCrypto, input, output, paddingStart, paddingEnd,
|
|
1604
|
+
function append(aesCrypto, input, output, paddingStart, paddingEnd, verifyAuthenticationCode) {
|
|
1588
1605
|
const {
|
|
1589
1606
|
ctr,
|
|
1590
1607
|
hmac,
|
|
@@ -1598,11 +1615,11 @@ function append(aesCrypto, input, output, paddingStart, paddingEnd, verifySignat
|
|
|
1598
1615
|
let offset;
|
|
1599
1616
|
for (offset = 0; offset <= inputLength - BLOCK_LENGTH; offset += BLOCK_LENGTH) {
|
|
1600
1617
|
const inputChunk = toBits(codecBytes, subarray(input, offset, offset + BLOCK_LENGTH));
|
|
1601
|
-
if (
|
|
1618
|
+
if (verifyAuthenticationCode) {
|
|
1602
1619
|
hmac.update(inputChunk);
|
|
1603
1620
|
}
|
|
1604
1621
|
const outputChunk = ctr.update(inputChunk);
|
|
1605
|
-
if (!
|
|
1622
|
+
if (!verifyAuthenticationCode) {
|
|
1606
1623
|
hmac.update(outputChunk);
|
|
1607
1624
|
}
|
|
1608
1625
|
output.set(fromBits(codecBytes, outputChunk), offset + paddingStart);
|
|
@@ -1964,7 +1981,7 @@ const GZIP_OUTPUT_STALL_TIMEOUT = 5000;
|
|
|
1964
1981
|
|
|
1965
1982
|
class DeflateStream extends TransformStream {
|
|
1966
1983
|
|
|
1967
|
-
constructor(options, { chunkSize,
|
|
1984
|
+
constructor(options, { chunkSize, CompressionStreamFallback, CompressionStream }) {
|
|
1968
1985
|
super({});
|
|
1969
1986
|
const { compressed, encrypted, useCompressionStream, zipCrypto, computeCrc32, level, deflate64, format, compressionMethod } = options;
|
|
1970
1987
|
const stream = this;
|
|
@@ -1986,7 +2003,7 @@ class DeflateStream extends TransformStream {
|
|
|
1986
2003
|
readable = pipeThrough(readable, gzipCrc32Stream);
|
|
1987
2004
|
} else {
|
|
1988
2005
|
try {
|
|
1989
|
-
readable = pipeThroughCompressionStream(readable, useCompressionStream, { level, chunkSize }, CompressionStream,
|
|
2006
|
+
readable = pipeThroughCompressionStream(readable, useCompressionStream, { level, chunkSize }, CompressionStream, CompressionStreamFallback);
|
|
1990
2007
|
} catch (error) {
|
|
1991
2008
|
let gzipStream;
|
|
1992
2009
|
try {
|
|
@@ -2008,14 +2025,9 @@ class DeflateStream extends TransformStream {
|
|
|
2008
2025
|
}
|
|
2009
2026
|
}
|
|
2010
2027
|
setReadable(stream, readable, () => {
|
|
2011
|
-
let signature;
|
|
2012
|
-
if (encrypted && !zipCrypto) {
|
|
2013
|
-
signature = encryptionStream.signature;
|
|
2014
|
-
}
|
|
2015
2028
|
if ((!encrypted || zipCrypto) && computeCrc32) {
|
|
2016
|
-
|
|
2029
|
+
stream.crc32 = useGzipCrc32 ? gzipCrc32Stream.crc32 : new DataView(crc32Stream.value.buffer).getUint32(0);
|
|
2017
2030
|
}
|
|
2018
|
-
stream.signature = signature;
|
|
2019
2031
|
});
|
|
2020
2032
|
}
|
|
2021
2033
|
}
|
|
@@ -2053,7 +2065,7 @@ class GzipToRawDeflateStream extends TransformStream {
|
|
|
2053
2065
|
},
|
|
2054
2066
|
flush() {
|
|
2055
2067
|
const dataView = getDataView(trailerCandidate);
|
|
2056
|
-
stream.
|
|
2068
|
+
stream.crc32 = dataView.getUint32(0, true);
|
|
2057
2069
|
stream.uncompressedSize = dataView.getUint32(4, true);
|
|
2058
2070
|
}
|
|
2059
2071
|
});
|
|
@@ -2133,9 +2145,9 @@ function pipeThroughGzipDecompressionStream(readable, gzipStream, outputSize) {
|
|
|
2133
2145
|
|
|
2134
2146
|
class InflateStream extends TransformStream {
|
|
2135
2147
|
|
|
2136
|
-
constructor(options, { chunkSize,
|
|
2148
|
+
constructor(options, { chunkSize, DecompressionStreamFallback, DecompressionStream }) {
|
|
2137
2149
|
super({});
|
|
2138
|
-
const { zipCrypto, encrypted, checkCrc32,
|
|
2150
|
+
const { zipCrypto, encrypted, checkCrc32, crc32, compressed, useCompressionStream, deflate64, format, compressionMethod, rawBitFlag, outputSize } = options;
|
|
2139
2151
|
let crc32Stream, decryptionStream;
|
|
2140
2152
|
let readable = super.readable;
|
|
2141
2153
|
if (encrypted) {
|
|
@@ -2152,7 +2164,7 @@ class InflateStream extends TransformStream {
|
|
|
2152
2164
|
readable = pipeThroughBackpressured(readable, createCodecStream(codecStreams.DecompressionStream, format, { chunkSize, compressionMethod, rawBitFlag, uncompressedSize: outputSize }));
|
|
2153
2165
|
} else {
|
|
2154
2166
|
try {
|
|
2155
|
-
readable = pipeThroughCompressionStream(readable, useCompressionStream, { chunkSize, deflate64 }, DecompressionStream,
|
|
2167
|
+
readable = pipeThroughCompressionStream(readable, useCompressionStream, { chunkSize, deflate64 }, DecompressionStream, DecompressionStreamFallback);
|
|
2156
2168
|
} catch (error) {
|
|
2157
2169
|
if (deflate64 || outputSize === UNDEFINED_VALUE) {
|
|
2158
2170
|
throw error;
|
|
@@ -2174,8 +2186,8 @@ class InflateStream extends TransformStream {
|
|
|
2174
2186
|
}
|
|
2175
2187
|
setReadable(this, readable, () => {
|
|
2176
2188
|
if (checkCrc32) {
|
|
2177
|
-
const
|
|
2178
|
-
if (
|
|
2189
|
+
const computedCrc32View = new DataView(crc32Stream.value.buffer);
|
|
2190
|
+
if (crc32 != computedCrc32View.getUint32(0, false)) {
|
|
2179
2191
|
throw new Error(ERR_INVALID_CRC32);
|
|
2180
2192
|
}
|
|
2181
2193
|
}
|
|
@@ -2231,17 +2243,17 @@ function createCodecStream(CodecStreamClass, format, options) {
|
|
|
2231
2243
|
return new CodecStreamClass(format, options);
|
|
2232
2244
|
}
|
|
2233
2245
|
|
|
2234
|
-
function pipeThroughCompressionStream(readable, useCompressionStream, options, CompressionStreamNative,
|
|
2246
|
+
function pipeThroughCompressionStream(readable, useCompressionStream, options, CompressionStreamNative, CompressionStreamFallback) {
|
|
2235
2247
|
const Stream = useCompressionStream && CompressionStreamNative ?
|
|
2236
2248
|
CompressionStreamNative :
|
|
2237
|
-
|
|
2249
|
+
CompressionStreamFallback || CompressionStreamNative;
|
|
2238
2250
|
const format = options.deflate64 ? FORMAT_DEFLATE64_RAW : FORMAT_DEFLATE_RAW;
|
|
2239
2251
|
let codecStream;
|
|
2240
2252
|
try {
|
|
2241
2253
|
codecStream = new Stream(format, options);
|
|
2242
2254
|
} catch (error) {
|
|
2243
|
-
if (useCompressionStream &&
|
|
2244
|
-
codecStream = new
|
|
2255
|
+
if (useCompressionStream && CompressionStreamFallback && Stream != CompressionStreamFallback) {
|
|
2256
|
+
codecStream = new CompressionStreamFallback(format, options);
|
|
2245
2257
|
} else {
|
|
2246
2258
|
throw error;
|
|
2247
2259
|
}
|
|
@@ -2400,9 +2412,9 @@ class CodecStream extends TransformStream {
|
|
|
2400
2412
|
}
|
|
2401
2413
|
},
|
|
2402
2414
|
flush() {
|
|
2403
|
-
const {
|
|
2415
|
+
const { crc32 } = stream;
|
|
2404
2416
|
Object.assign(codec, {
|
|
2405
|
-
|
|
2417
|
+
crc32,
|
|
2406
2418
|
inputSize
|
|
2407
2419
|
});
|
|
2408
2420
|
}
|
|
@@ -2504,7 +2516,7 @@ const ERROR_EVENT_TYPE = "error";
|
|
|
2504
2516
|
const MESSAGE_ERROR_EVENT_TYPE = "messageerror";
|
|
2505
2517
|
const ERR_WORKER_STARTUP_TIMEOUT = "Worker startup timeout";
|
|
2506
2518
|
|
|
2507
|
-
let webWorkerSupported, webWorkerSource, webWorkerURI, webWorkerOptions;
|
|
2519
|
+
let webWorkerSupported, webWorkerSource, webWorkerURI, webWorkerOptions, createWorkerFailed;
|
|
2508
2520
|
let transferStreamsSupported = true;
|
|
2509
2521
|
try {
|
|
2510
2522
|
transferStreamsSupported = typeof structuredClone == FUNCTION_TYPE && structuredClone(new DOMException("", "AbortError")).code !== UNDEFINED_VALUE;
|
|
@@ -2518,14 +2530,14 @@ function configureWorker({ initModule: initModuleFunction }) {
|
|
|
2518
2530
|
}
|
|
2519
2531
|
|
|
2520
2532
|
async function supportsDeflate(config) {
|
|
2521
|
-
const { CompressionStream: NativeStream,
|
|
2522
|
-
if (
|
|
2533
|
+
const { CompressionStream: NativeStream, CompressionStreamFallback: FallbackStream } = config;
|
|
2534
|
+
if (FallbackStream && !FallbackStream.requiresModule) {
|
|
2523
2535
|
return true;
|
|
2524
2536
|
}
|
|
2525
2537
|
if (supportsDeflateRaw(NativeStream) || supportsGzip(NativeStream)) {
|
|
2526
2538
|
return true;
|
|
2527
2539
|
}
|
|
2528
|
-
if (
|
|
2540
|
+
if (FallbackStream) {
|
|
2529
2541
|
try {
|
|
2530
2542
|
await initModule$1(config);
|
|
2531
2543
|
return true;
|
|
@@ -2538,12 +2550,16 @@ async function supportsDeflate(config) {
|
|
|
2538
2550
|
|
|
2539
2551
|
function resetWebWorkerSupport() {
|
|
2540
2552
|
webWorkerSupported = UNDEFINED_VALUE;
|
|
2553
|
+
createWorkerFailed = false;
|
|
2541
2554
|
}
|
|
2542
2555
|
|
|
2543
2556
|
class CodecWorker {
|
|
2544
2557
|
|
|
2545
|
-
constructor(workerData, { readable, writable }, { options, config, streamOptions, useWebWorkers, transferStreams, workerURI }, onTaskFinished) {
|
|
2558
|
+
constructor(workerData, { readable, writable }, { options, config, streamOptions, useWebWorkers, transferStreams, workerURI, createWorker }, onTaskFinished) {
|
|
2546
2559
|
const { signal } = streamOptions;
|
|
2560
|
+
if (createWorkerFailed) {
|
|
2561
|
+
createWorker = UNDEFINED_VALUE;
|
|
2562
|
+
}
|
|
2547
2563
|
Object.assign(workerData, {
|
|
2548
2564
|
busy: true,
|
|
2549
2565
|
generation: (workerData.generation || 0) + 1,
|
|
@@ -2553,6 +2569,7 @@ class CodecWorker {
|
|
|
2553
2569
|
writable,
|
|
2554
2570
|
options: Object.assign({}, options),
|
|
2555
2571
|
workerURI,
|
|
2572
|
+
createWorker,
|
|
2556
2573
|
transferStreams,
|
|
2557
2574
|
terminate() {
|
|
2558
2575
|
return new Promise(resolve => {
|
|
@@ -2588,7 +2605,7 @@ class CodecWorker {
|
|
|
2588
2605
|
// deno-lint-ignore valid-typeof
|
|
2589
2606
|
webWorkerSupported = typeof Worker != UNDEFINED_TYPE;
|
|
2590
2607
|
}
|
|
2591
|
-
return (useWebWorkers && webWorkerSupported ? createWebWorkerInterface : createWorkerInterface)(workerData, config);
|
|
2608
|
+
return (useWebWorkers && ((webWorkerSupported && workerURI) || createWorker) ? createWebWorkerInterface : createWorkerInterface)(workerData, config);
|
|
2592
2609
|
}
|
|
2593
2610
|
}
|
|
2594
2611
|
|
|
@@ -2645,7 +2662,11 @@ function createWebWorkerInterface(workerData, config) {
|
|
|
2645
2662
|
try {
|
|
2646
2663
|
worker = getWebWorker(workerData.workerURI, baseURI, workerData);
|
|
2647
2664
|
} catch {
|
|
2648
|
-
|
|
2665
|
+
if (workerData.createWorker) {
|
|
2666
|
+
createWorkerFailed = true;
|
|
2667
|
+
} else {
|
|
2668
|
+
webWorkerSupported = false;
|
|
2669
|
+
}
|
|
2649
2670
|
return createWorkerInterface(workerData, config);
|
|
2650
2671
|
}
|
|
2651
2672
|
Object.assign(workerData, {
|
|
@@ -2658,7 +2679,11 @@ function createWebWorkerInterface(workerData, config) {
|
|
|
2658
2679
|
return await runWebWorker(workerData, { chunkSize, wasmURI, baseURI, workerStartupTimeout });
|
|
2659
2680
|
} catch (error) {
|
|
2660
2681
|
if (error && error.workerStartupFailed) {
|
|
2661
|
-
|
|
2682
|
+
if (workerData.createWorker) {
|
|
2683
|
+
createWorkerFailed = true;
|
|
2684
|
+
} else {
|
|
2685
|
+
webWorkerSupported = false;
|
|
2686
|
+
}
|
|
2662
2687
|
const { reader } = workerData;
|
|
2663
2688
|
if (reader) {
|
|
2664
2689
|
reader.releaseLock();
|
|
@@ -2681,17 +2706,17 @@ async function runWorker$1({ options, readable, writable, onTaskFinished }, conf
|
|
|
2681
2706
|
try {
|
|
2682
2707
|
if (options.compressed && !options.format) {
|
|
2683
2708
|
const deflate = options.codecType.startsWith(CODEC_DEFLATE);
|
|
2684
|
-
const
|
|
2709
|
+
const FallbackStream = deflate ? config.CompressionStreamFallback : config.DecompressionStreamFallback;
|
|
2685
2710
|
const NativeStream = deflate ? config.CompressionStream : config.DecompressionStream;
|
|
2686
2711
|
if (!options.useCompressionStream) {
|
|
2687
2712
|
try {
|
|
2688
2713
|
await initModule$1(config);
|
|
2689
2714
|
} catch {
|
|
2690
|
-
if (!
|
|
2715
|
+
if (!FallbackStream || FallbackStream.requiresModule) {
|
|
2691
2716
|
options.useCompressionStream = true;
|
|
2692
2717
|
}
|
|
2693
2718
|
}
|
|
2694
|
-
} else if (
|
|
2719
|
+
} else if (FallbackStream && FallbackStream.requiresModule && !supportsDeflateRaw(NativeStream)) {
|
|
2695
2720
|
try {
|
|
2696
2721
|
await initModule$1(config);
|
|
2697
2722
|
} catch {
|
|
@@ -2705,12 +2730,12 @@ async function runWorker$1({ options, readable, writable, onTaskFinished }, conf
|
|
|
2705
2730
|
.pipeThrough(new ChunkStream(getChunkSize(config)))
|
|
2706
2731
|
.pipeTo(writable, { preventClose: true, preventAbort: true });
|
|
2707
2732
|
const {
|
|
2708
|
-
|
|
2733
|
+
crc32,
|
|
2709
2734
|
inputSize,
|
|
2710
2735
|
outputSize
|
|
2711
2736
|
} = codecStream;
|
|
2712
2737
|
return {
|
|
2713
|
-
|
|
2738
|
+
crc32,
|
|
2714
2739
|
inputSize,
|
|
2715
2740
|
outputSize
|
|
2716
2741
|
};
|
|
@@ -2816,8 +2841,11 @@ function terminateWorker$1(workerData) {
|
|
|
2816
2841
|
}
|
|
2817
2842
|
|
|
2818
2843
|
function getWebWorker(url, baseURI, workerData, isModuleType, useBlobURI = true) {
|
|
2844
|
+
const { createWorker } = workerData;
|
|
2819
2845
|
let worker, resolvedURI, resolvedOptions;
|
|
2820
|
-
if (
|
|
2846
|
+
if (createWorker) {
|
|
2847
|
+
worker = createWorker();
|
|
2848
|
+
} else if (webWorkerURI === UNDEFINED_VALUE || webWorkerSource !== url) {
|
|
2821
2849
|
// deno-lint-ignore valid-typeof
|
|
2822
2850
|
const isFunctionURI = typeof url == FUNCTION_TYPE;
|
|
2823
2851
|
if (isFunctionURI) {
|
|
@@ -3072,7 +3100,7 @@ let indexWorker = 0;
|
|
|
3072
3100
|
async function runWorker(stream, workerOptions) {
|
|
3073
3101
|
const { options, config } = workerOptions;
|
|
3074
3102
|
const { transferStreams, useWebWorkers, useCompressionStream, compressed, checkCrc32, computeCrc32, encrypted, format, codecURI } = options;
|
|
3075
|
-
const { workerURI, maxWorkers } = config;
|
|
3103
|
+
const { workerURI, createWorker, maxWorkers } = config;
|
|
3076
3104
|
if (format) {
|
|
3077
3105
|
if (codecURI) {
|
|
3078
3106
|
options.codecURI = resolveCodecURI(codecURI, config.baseURI);
|
|
@@ -3084,6 +3112,7 @@ async function runWorker(stream, workerOptions) {
|
|
|
3084
3112
|
const workerSupported = format === UNDEFINED_VALUE || Boolean(options.codecURI);
|
|
3085
3113
|
workerOptions.useWebWorkers = !streamCopy && workerSupported && (useWebWorkers || (useWebWorkers === UNDEFINED_VALUE && config.useWebWorkers));
|
|
3086
3114
|
workerOptions.workerURI = workerOptions.useWebWorkers && workerURI ? workerURI : UNDEFINED_VALUE;
|
|
3115
|
+
workerOptions.createWorker = workerOptions.useWebWorkers && createWorker ? createWorker : UNDEFINED_VALUE;
|
|
3087
3116
|
options.useCompressionStream = useCompressionStream || (useCompressionStream === UNDEFINED_VALUE && config.useCompressionStream);
|
|
3088
3117
|
return (await getWorker()).run();
|
|
3089
3118
|
|
|
@@ -3147,7 +3176,7 @@ function onWorkerStarvation() {
|
|
|
3147
3176
|
starvationTimeout = null;
|
|
3148
3177
|
if (pendingRequests.length) {
|
|
3149
3178
|
const [{ resolve, stream, workerOptions }] = pendingRequests.splice(0, 1);
|
|
3150
|
-
const inlineWorkerOptions = Object.assign({}, workerOptions, { useWebWorkers: false, workerURI: UNDEFINED_VALUE });
|
|
3179
|
+
const inlineWorkerOptions = Object.assign({}, workerOptions, { useWebWorkers: false, workerURI: UNDEFINED_VALUE, createWorker: UNDEFINED_VALUE });
|
|
3151
3180
|
resolve(new CodecWorker({}, stream, inlineWorkerOptions, onInlineTaskFinished));
|
|
3152
3181
|
armStarvationTimeout();
|
|
3153
3182
|
}
|
|
@@ -4308,6 +4337,8 @@ const PROPERTY_NAME_CRC32 = "crc32";
|
|
|
4308
4337
|
const PROPERTY_NAME_EXTRA_FIELD = "extraField";
|
|
4309
4338
|
const PROPERTY_NAME_EXTRA_FIELD_INFOZIP = "extraFieldInfoZip";
|
|
4310
4339
|
const PROPERTY_NAME_EXTRA_FIELD_UNIX = "extraFieldUnix";
|
|
4340
|
+
const PROPERTY_NAME_EXTRA_FIELD_UNIX_TYPE1 = "extraFieldUnixType1";
|
|
4341
|
+
const PROPERTY_NAME_EXTRA_FIELD_PKWARE_UNIX = "extraFieldPkwareUnix";
|
|
4311
4342
|
const PROPERTY_NAME_UID = "uid";
|
|
4312
4343
|
const PROPERTY_NAME_GID = "gid";
|
|
4313
4344
|
const PROPERTY_NAME_UNIX_MODE = "unixMode";
|
|
@@ -4324,6 +4355,7 @@ const PROPERTY_NAME_EXTRA_FIELD_UNICODE_COMMENT = "extraFieldUnicodeComment";
|
|
|
4324
4355
|
const PROPERTY_NAME_EXTRA_FIELD_AES = "extraFieldAES";
|
|
4325
4356
|
const PROPERTY_NAME_EXTRA_FIELD_NTFS = "extraFieldNTFS";
|
|
4326
4357
|
const PROPERTY_NAME_EXTRA_FIELD_EXTENDED_TIMESTAMP = "extraFieldExtendedTimestamp";
|
|
4358
|
+
const PROPERTY_NAME_EXTRA_FIELD_USDZ = "extraFieldUSDZ";
|
|
4327
4359
|
|
|
4328
4360
|
const PROPERTY_NAMES = [
|
|
4329
4361
|
PROPERTY_NAME_FILENAME,
|
|
@@ -4335,6 +4367,7 @@ const PROPERTY_NAMES = [
|
|
|
4335
4367
|
PROPERTY_NAME_COMMENT,
|
|
4336
4368
|
PROPERTY_NAME_RAW_COMMENT,
|
|
4337
4369
|
PROPERTY_NAME_LAST_ACCESS_DATE,
|
|
4370
|
+
PROPERTY_NAME_RAW_LAST_ACCESS_DATE,
|
|
4338
4371
|
PROPERTY_NAME_CREATION_DATE,
|
|
4339
4372
|
PROPERTY_NAME_RAW_CREATION_DATE,
|
|
4340
4373
|
PROPERTY_NAME_OFFSET,
|
|
@@ -4357,6 +4390,8 @@ const PROPERTY_NAMES = [
|
|
|
4357
4390
|
PROPERTY_NAME_EXTRA_FIELD,
|
|
4358
4391
|
PROPERTY_NAME_EXTRA_FIELD_UNIX,
|
|
4359
4392
|
PROPERTY_NAME_EXTRA_FIELD_INFOZIP,
|
|
4393
|
+
PROPERTY_NAME_EXTRA_FIELD_UNIX_TYPE1,
|
|
4394
|
+
PROPERTY_NAME_EXTRA_FIELD_PKWARE_UNIX,
|
|
4360
4395
|
PROPERTY_NAME_UID,
|
|
4361
4396
|
PROPERTY_NAME_GID,
|
|
4362
4397
|
PROPERTY_NAME_UNIX_MODE,
|
|
@@ -4372,7 +4407,8 @@ const PROPERTY_NAMES = [
|
|
|
4372
4407
|
PROPERTY_NAME_EXTRA_FIELD_UNICODE_COMMENT,
|
|
4373
4408
|
PROPERTY_NAME_EXTRA_FIELD_AES,
|
|
4374
4409
|
PROPERTY_NAME_EXTRA_FIELD_NTFS,
|
|
4375
|
-
PROPERTY_NAME_EXTRA_FIELD_EXTENDED_TIMESTAMP
|
|
4410
|
+
PROPERTY_NAME_EXTRA_FIELD_EXTENDED_TIMESTAMP,
|
|
4411
|
+
PROPERTY_NAME_EXTRA_FIELD_USDZ
|
|
4376
4412
|
];
|
|
4377
4413
|
|
|
4378
4414
|
class Entry {
|
|
@@ -4446,6 +4482,7 @@ const OPTION_ENCODE_TEXT = "encodeText";
|
|
|
4446
4482
|
const OPTION_OFFSET = "offset";
|
|
4447
4483
|
const OPTION_USDZ = "usdz";
|
|
4448
4484
|
const OPTION_UNIX_EXTRA_FIELD_TYPE = "unixExtraFieldType";
|
|
4485
|
+
const OPTION_LOCAL_EXTRA_FIELD = "localExtraField";
|
|
4449
4486
|
const OPTION_STRICTNESS = "strictness";
|
|
4450
4487
|
const OPTION_MAX_APPENDED_DATA_SIZE = "maxAppendedDataSize";
|
|
4451
4488
|
const STRICTNESS_STRICT = "strict";
|
|
@@ -4498,7 +4535,7 @@ const CHARSET_UTF8 = "utf-8";
|
|
|
4498
4535
|
const PROPERTY_NAME_UTF8_SUFFIX = "UTF8";
|
|
4499
4536
|
const CHARSET_CP437 = "cp437";
|
|
4500
4537
|
const BITFLAG_AMBIGUITY_MASK = BITFLAG_ENCRYPTED | BITFLAG_DATA_DESCRIPTOR | BITFLAG_LANG_ENCODING_FLAG;
|
|
4501
|
-
const VENDOR_VERSION_AE_1 = 1;
|
|
4538
|
+
const VENDOR_VERSION_AE_1$1 = 1;
|
|
4502
4539
|
const ZIP64_PROPERTIES = [
|
|
4503
4540
|
[PROPERTY_NAME_UNCOMPRESSED_SIZE, MAX_32_BITS],
|
|
4504
4541
|
[PROPERTY_NAME_COMPRESSED_SIZE, MAX_32_BITS],
|
|
@@ -4891,7 +4928,7 @@ let ZipEntry$1 = class ZipEntry {
|
|
|
4891
4928
|
config,
|
|
4892
4929
|
bitFlag,
|
|
4893
4930
|
rawBitFlag,
|
|
4894
|
-
|
|
4931
|
+
crc32,
|
|
4895
4932
|
rawLastModDate,
|
|
4896
4933
|
uncompressedSize,
|
|
4897
4934
|
compressedSize
|
|
@@ -4982,7 +5019,7 @@ let ZipEntry$1 = class ZipEntry {
|
|
|
4982
5019
|
const checkCrc32 = (checkCrc32Option === UNDEFINED_VALUE ?
|
|
4983
5020
|
getOptionValue$1(zipEntry, options, OPTION_CHECK_SIGNATURE) :
|
|
4984
5021
|
checkCrc32Option) && !passThrough &&
|
|
4985
|
-
(!encrypted || zipCrypto || (extraFieldAES && extraFieldAES.vendorVersion == VENDOR_VERSION_AE_1));
|
|
5022
|
+
(!encrypted || zipCrypto || (extraFieldAES && extraFieldAES.vendorVersion == VENDOR_VERSION_AE_1$1));
|
|
4986
5023
|
const workerOptions = {
|
|
4987
5024
|
options: {
|
|
4988
5025
|
codecType: CODEC_INFLATE,
|
|
@@ -4992,9 +5029,9 @@ let ZipEntry$1 = class ZipEntry {
|
|
|
4992
5029
|
encryptionStrength: extraFieldAES && extraFieldAES.strength,
|
|
4993
5030
|
checkCrc32,
|
|
4994
5031
|
checkAuthenticationCode: getOptionValue$1(zipEntry, options, OPTION_CHECK_AUTHENTICATION_CODE),
|
|
4995
|
-
passwordVerification: zipCrypto && (dataDescriptor ? ((rawLastModDate >>> 8) & MAX_8_BITS) : ((
|
|
5032
|
+
passwordVerification: zipCrypto && (dataDescriptor ? ((rawLastModDate >>> 8) & MAX_8_BITS) : ((crc32 >>> 24) & MAX_8_BITS)),
|
|
4996
5033
|
outputSize: passThrough ? compressedSize : uncompressedSize,
|
|
4997
|
-
|
|
5034
|
+
crc32,
|
|
4998
5035
|
compressed: compressionMethod != 0 && !passThrough,
|
|
4999
5036
|
encrypted,
|
|
5000
5037
|
useWebWorkers: getOptionValue$1(zipEntry, options, OPTION_USE_WEB_WORKERS),
|
|
@@ -5016,7 +5053,7 @@ let ZipEntry$1 = class ZipEntry {
|
|
|
5016
5053
|
fileEntry,
|
|
5017
5054
|
index,
|
|
5018
5055
|
offset: localHeaderOffset,
|
|
5019
|
-
|
|
5056
|
+
crc32,
|
|
5020
5057
|
compressedSize,
|
|
5021
5058
|
uncompressedSize,
|
|
5022
5059
|
dataOffset,
|
|
@@ -5133,6 +5170,16 @@ function readCommonFooter(fileEntry, directory, dataView, offset, localDirectory
|
|
|
5133
5170
|
} else {
|
|
5134
5171
|
directory.compressionMethod = compressionMethod;
|
|
5135
5172
|
}
|
|
5173
|
+
const extraFieldPkwareUnix = extraField.get(EXTRAFIELD_TYPE_PKWARE_UNIX);
|
|
5174
|
+
if (extraFieldPkwareUnix) {
|
|
5175
|
+
readExtraFieldUnixDates(extraFieldPkwareUnix, directory);
|
|
5176
|
+
directory.extraFieldPkwareUnix = extraFieldPkwareUnix;
|
|
5177
|
+
}
|
|
5178
|
+
const extraFieldUnixType1 = extraField.get(EXTRAFIELD_TYPE_UNIX_TYPE1);
|
|
5179
|
+
if (extraFieldUnixType1) {
|
|
5180
|
+
readExtraFieldUnixDates(extraFieldUnixType1, directory);
|
|
5181
|
+
directory.extraFieldUnixType1 = extraFieldUnixType1;
|
|
5182
|
+
}
|
|
5136
5183
|
const extraFieldNTFS = extraField.get(EXTRAFIELD_TYPE_NTFS);
|
|
5137
5184
|
if (extraFieldNTFS) {
|
|
5138
5185
|
readExtraFieldNTFS(extraFieldNTFS, directory);
|
|
@@ -5182,15 +5229,15 @@ function readExtraFieldUnicode(extraFieldUnicode, propertyName, rawPropertyName,
|
|
|
5182
5229
|
return;
|
|
5183
5230
|
}
|
|
5184
5231
|
const extraFieldView = getDataView(extraFieldUnicode.data);
|
|
5185
|
-
const
|
|
5186
|
-
|
|
5187
|
-
const
|
|
5188
|
-
|
|
5189
|
-
const
|
|
5232
|
+
const computedCrc32 = new Crc32();
|
|
5233
|
+
computedCrc32.append(fileEntry[rawPropertyName]);
|
|
5234
|
+
const computedCrc32View = getDataView(new Uint8Array(4));
|
|
5235
|
+
computedCrc32View.setUint32(0, computedCrc32.get(), true);
|
|
5236
|
+
const nameCrc32 = getUint32(extraFieldView, 1);
|
|
5190
5237
|
Object.assign(extraFieldUnicode, {
|
|
5191
5238
|
version: getUint8(extraFieldView, 0),
|
|
5192
5239
|
[propertyName]: decodeText(extraFieldUnicode.data.subarray(5)),
|
|
5193
|
-
valid: !fileEntry.bitFlag.languageEncodingFlag &&
|
|
5240
|
+
valid: !fileEntry.bitFlag.languageEncodingFlag && nameCrc32 == getUint32(computedCrc32View, 0)
|
|
5194
5241
|
});
|
|
5195
5242
|
if (extraFieldUnicode.valid) {
|
|
5196
5243
|
directory[propertyName] = extraFieldUnicode[propertyName];
|
|
@@ -5209,7 +5256,7 @@ function readExtraFieldAES(extraFieldAES, directory, compressionMethod) {
|
|
|
5209
5256
|
compressionMethod: getUint16(extraFieldView, 5)
|
|
5210
5257
|
});
|
|
5211
5258
|
directory.compressionMethod = extraFieldAES.compressionMethod;
|
|
5212
|
-
if (extraFieldAES.vendorVersion != VENDOR_VERSION_AE_1) {
|
|
5259
|
+
if (extraFieldAES.vendorVersion != VENDOR_VERSION_AE_1$1) {
|
|
5213
5260
|
directory.crc32 = UNDEFINED_VALUE;
|
|
5214
5261
|
}
|
|
5215
5262
|
}
|
|
@@ -5249,6 +5296,22 @@ function readExtraFieldNTFS(extraFieldNTFS, directory) {
|
|
|
5249
5296
|
}
|
|
5250
5297
|
}
|
|
5251
5298
|
|
|
5299
|
+
function readExtraFieldUnixDates(extraField, directory) {
|
|
5300
|
+
if (extraField.data.length < 8) {
|
|
5301
|
+
return;
|
|
5302
|
+
}
|
|
5303
|
+
const extraFieldView = getDataView(extraField.data);
|
|
5304
|
+
const lastAccessDate = new Date(getUint32(extraFieldView, 0) * 1000);
|
|
5305
|
+
const lastModDate = new Date(getUint32(extraFieldView, 4) * 1000);
|
|
5306
|
+
const extraFieldData = { lastAccessDate, lastModDate };
|
|
5307
|
+
if (extraField.data.length >= 12) {
|
|
5308
|
+
extraFieldData.uid = getUint16(extraFieldView, 8);
|
|
5309
|
+
extraFieldData.gid = getUint16(extraFieldView, 10);
|
|
5310
|
+
}
|
|
5311
|
+
Object.assign(extraField, extraFieldData);
|
|
5312
|
+
Object.assign(directory, extraFieldData);
|
|
5313
|
+
}
|
|
5314
|
+
|
|
5252
5315
|
function readExtraFieldUnix(extraField, directory, isInfoZip) {
|
|
5253
5316
|
try {
|
|
5254
5317
|
const view = getDataView(extraField.data);
|
|
@@ -5327,7 +5390,7 @@ async function detectOverlappingEntry({
|
|
|
5327
5390
|
fileEntry,
|
|
5328
5391
|
index,
|
|
5329
5392
|
offset,
|
|
5330
|
-
|
|
5393
|
+
crc32,
|
|
5331
5394
|
compressedSize,
|
|
5332
5395
|
uncompressedSize,
|
|
5333
5396
|
dataOffset,
|
|
@@ -5348,7 +5411,7 @@ async function detectOverlappingEntry({
|
|
|
5348
5411
|
const dataDescriptorSignature = dataDescriptorArray.length == dataDescriptorLength + DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH &&
|
|
5349
5412
|
getUint32(getDataView(dataDescriptorArray), 0) == DATA_DESCRIPTOR_RECORD_SIGNATURE;
|
|
5350
5413
|
if (dataDescriptorSignature) {
|
|
5351
|
-
const
|
|
5414
|
+
const readCrc32 = getUint32(getDataView(dataDescriptorArray), 4);
|
|
5352
5415
|
let readCompressedSize;
|
|
5353
5416
|
let readUncompressedSize;
|
|
5354
5417
|
if (extraFieldZip64) {
|
|
@@ -5358,8 +5421,8 @@ async function detectOverlappingEntry({
|
|
|
5358
5421
|
readCompressedSize = getUint32(getDataView(dataDescriptorArray), 8);
|
|
5359
5422
|
readUncompressedSize = getUint32(getDataView(dataDescriptorArray), 12);
|
|
5360
5423
|
}
|
|
5361
|
-
const
|
|
5362
|
-
if (
|
|
5424
|
+
const matchCrc32 = (fileEntry.encrypted && !fileEntry.zipCrypto) || readCrc32 == crc32;
|
|
5425
|
+
if (matchCrc32 &&
|
|
5363
5426
|
readCompressedSize == compressedSize &&
|
|
5364
5427
|
readUncompressedSize == uncompressedSize) {
|
|
5365
5428
|
dataDescriptorLength += DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH;
|
|
@@ -5528,11 +5591,11 @@ function checkLocalDirectory(zipEntry, localDirectory, rawLocalFilename) {
|
|
|
5528
5591
|
throwAmbiguousArchive("mismatched local file header (compression method)");
|
|
5529
5592
|
}
|
|
5530
5593
|
if (!localDirectory.bitFlag.dataDescriptor &&
|
|
5531
|
-
(localDirectory.
|
|
5532
|
-
(localDirectory.
|
|
5594
|
+
(localDirectory.crc32 || localDirectory.compressedSize || localDirectory.uncompressedSize) &&
|
|
5595
|
+
(localDirectory.crc32 != zipEntry.crc32 ||
|
|
5533
5596
|
localDirectory.compressedSize != zipEntry.compressedSize ||
|
|
5534
5597
|
localDirectory.uncompressedSize != zipEntry.uncompressedSize)) {
|
|
5535
|
-
throwAmbiguousArchive("mismatched local file header (
|
|
5598
|
+
throwAmbiguousArchive("mismatched local file header (crc32 or sizes)");
|
|
5536
5599
|
}
|
|
5537
5600
|
}
|
|
5538
5601
|
|
|
@@ -5652,7 +5715,9 @@ const ERR_INVALID_MSDOS_ATTRIBUTES = "Invalid msdosAttributesRaw (must be intege
|
|
|
5652
5715
|
const ERR_INVALID_MSDOS_DATA = "Invalid msdosAttributes (must be an object with boolean flags)";
|
|
5653
5716
|
|
|
5654
5717
|
const EXTRAFIELD_DATA_AES = new Uint8Array([0x07, 0x00, 0x02, 0x00, 0x41, 0x45, 0x03, 0x00, 0x00]);
|
|
5655
|
-
const
|
|
5718
|
+
const EXTRAFIELD_OFFSET_AES_VENDOR_VERSION = 4;
|
|
5719
|
+
const VENDOR_VERSION_AE_1 = 1;
|
|
5720
|
+
const INFOZIP_EXTRA_FIELD_TYPE$1 = "infozip";
|
|
5656
5721
|
const UNIX_EXTRA_FIELD_TYPE = "unix";
|
|
5657
5722
|
|
|
5658
5723
|
let workers = 0;
|
|
@@ -5746,9 +5811,9 @@ class ZipWriter {
|
|
|
5746
5811
|
zip64UncompressedSize,
|
|
5747
5812
|
extraFieldLength
|
|
5748
5813
|
});
|
|
5749
|
-
const {
|
|
5750
|
-
if (
|
|
5751
|
-
setUint32(headerView, HEADER_OFFSET_SIGNATURE,
|
|
5814
|
+
const { crc32 } = entry;
|
|
5815
|
+
if (crc32 !== UNDEFINED_VALUE) {
|
|
5816
|
+
setUint32(headerView, HEADER_OFFSET_SIGNATURE, crc32);
|
|
5752
5817
|
}
|
|
5753
5818
|
Object.assign(entry, {
|
|
5754
5819
|
zip64UncompressedSize,
|
|
@@ -5933,6 +5998,7 @@ async function addFile(zipWriter, name, reader, options) {
|
|
|
5933
5998
|
internalFileAttribute: metadataInfo.resolvedOptions.internalFileAttributes,
|
|
5934
5999
|
externalFileAttribute: attributesInfo.resolvedOptions.externalFileAttributes,
|
|
5935
6000
|
signature: options[PROPERTY_NAME_SIGNATURE],
|
|
6001
|
+
crc32: options.crc32 === UNDEFINED_VALUE ? options[PROPERTY_NAME_SIGNATURE] : options.crc32,
|
|
5936
6002
|
offset: zipWriter.offset - diskOffset,
|
|
5937
6003
|
diskNumberStart: diskNumber
|
|
5938
6004
|
});
|
|
@@ -5969,7 +6035,7 @@ function resolveAttributes(zipWriter, name, options) {
|
|
|
5969
6035
|
if (unixMode !== UNDEFINED_VALUE && (unixMode < 0 || unixMode > MAX_16_BITS)) {
|
|
5970
6036
|
throw new Error(ERR_INVALID_UNIX_MODE);
|
|
5971
6037
|
}
|
|
5972
|
-
if (unixExtraFieldType !== UNDEFINED_VALUE && unixExtraFieldType !== INFOZIP_EXTRA_FIELD_TYPE && unixExtraFieldType !== UNIX_EXTRA_FIELD_TYPE) {
|
|
6038
|
+
if (unixExtraFieldType !== UNDEFINED_VALUE && unixExtraFieldType !== INFOZIP_EXTRA_FIELD_TYPE$1 && unixExtraFieldType !== UNIX_EXTRA_FIELD_TYPE) {
|
|
5973
6039
|
throw new Error(ERR_INVALID_UNIX_EXTRA_FIELD_TYPE);
|
|
5974
6040
|
}
|
|
5975
6041
|
if (unixExtraFieldType === UNIX_EXTRA_FIELD_TYPE &&
|
|
@@ -5977,7 +6043,7 @@ function resolveAttributes(zipWriter, name, options) {
|
|
|
5977
6043
|
throw new Error(ERR_INVALID_UNIX_ID_SIZE);
|
|
5978
6044
|
}
|
|
5979
6045
|
if (unixExtraFieldType === UNDEFINED_VALUE && (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE)) {
|
|
5980
|
-
unixExtraFieldType = INFOZIP_EXTRA_FIELD_TYPE;
|
|
6046
|
+
unixExtraFieldType = INFOZIP_EXTRA_FIELD_TYPE$1;
|
|
5981
6047
|
}
|
|
5982
6048
|
let msdosAttributesRaw = getOptionValue(zipWriter, options, PROPERTY_NAME_MSDOS_ATTRIBUTES_RAW);
|
|
5983
6049
|
let msdosAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_MSDOS_ATTRIBUTES);
|
|
@@ -6149,27 +6215,8 @@ function resolveMetadata(zipWriter, name, options) {
|
|
|
6149
6215
|
if (!zipCrypto && (password !== UNDEFINED_VALUE || rawPassword !== UNDEFINED_VALUE) && !(encryptionStrength >= 1 && encryptionStrength <= 3)) {
|
|
6150
6216
|
throw new Error(ERR_INVALID_ENCRYPTION_STRENGTH);
|
|
6151
6217
|
}
|
|
6152
|
-
|
|
6153
|
-
const
|
|
6154
|
-
if (extraField) {
|
|
6155
|
-
let extraFieldSize = 0;
|
|
6156
|
-
let offset = 0;
|
|
6157
|
-
extraField.forEach(data => extraFieldSize += 4 + getLength(data));
|
|
6158
|
-
rawExtraField = new Uint8Array(extraFieldSize);
|
|
6159
|
-
const rawExtraFieldView = getDataView(rawExtraField);
|
|
6160
|
-
extraField.forEach((data, type) => {
|
|
6161
|
-
if (type > MAX_16_BITS) {
|
|
6162
|
-
throw new Error(ERR_INVALID_EXTRAFIELD_TYPE);
|
|
6163
|
-
}
|
|
6164
|
-
if (getLength(data) > MAX_16_BITS) {
|
|
6165
|
-
throw new Error(ERR_INVALID_EXTRAFIELD_DATA);
|
|
6166
|
-
}
|
|
6167
|
-
setUint16(rawExtraFieldView, offset, type);
|
|
6168
|
-
setUint16(rawExtraFieldView, offset + 2, getLength(data));
|
|
6169
|
-
arraySet(rawExtraField, data, offset + 4);
|
|
6170
|
-
offset += 4 + getLength(data);
|
|
6171
|
-
});
|
|
6172
|
-
}
|
|
6218
|
+
const rawExtraField = serializeExtraField(options[PROPERTY_NAME_EXTRA_FIELD]);
|
|
6219
|
+
const rawLocalExtraField = serializeExtraField(options[OPTION_LOCAL_EXTRA_FIELD]);
|
|
6173
6220
|
return {
|
|
6174
6221
|
comment,
|
|
6175
6222
|
resolvedOptions: {
|
|
@@ -6203,11 +6250,36 @@ function resolveMetadata(zipWriter, name, options) {
|
|
|
6203
6250
|
useCompressionStream,
|
|
6204
6251
|
dataDescriptor,
|
|
6205
6252
|
zip64,
|
|
6206
|
-
rawExtraField
|
|
6253
|
+
rawExtraField,
|
|
6254
|
+
rawLocalExtraField
|
|
6207
6255
|
}
|
|
6208
6256
|
};
|
|
6209
6257
|
}
|
|
6210
6258
|
|
|
6259
|
+
function serializeExtraField(extraField) {
|
|
6260
|
+
if (!extraField) {
|
|
6261
|
+
return EMPTY_UINT8_ARRAY;
|
|
6262
|
+
}
|
|
6263
|
+
let extraFieldSize = 0;
|
|
6264
|
+
let offset = 0;
|
|
6265
|
+
extraField.forEach(data => extraFieldSize += 4 + getLength(data));
|
|
6266
|
+
const rawExtraField = new Uint8Array(extraFieldSize);
|
|
6267
|
+
const rawExtraFieldView = getDataView(rawExtraField);
|
|
6268
|
+
extraField.forEach((data, type) => {
|
|
6269
|
+
if (type > MAX_16_BITS) {
|
|
6270
|
+
throw new Error(ERR_INVALID_EXTRAFIELD_TYPE);
|
|
6271
|
+
}
|
|
6272
|
+
if (getLength(data) > MAX_16_BITS) {
|
|
6273
|
+
throw new Error(ERR_INVALID_EXTRAFIELD_DATA);
|
|
6274
|
+
}
|
|
6275
|
+
setUint16(rawExtraFieldView, offset, type);
|
|
6276
|
+
setUint16(rawExtraFieldView, offset + 2, getLength(data));
|
|
6277
|
+
arraySet(rawExtraField, data, offset + 4);
|
|
6278
|
+
offset += 4 + getLength(data);
|
|
6279
|
+
});
|
|
6280
|
+
return rawExtraField;
|
|
6281
|
+
}
|
|
6282
|
+
|
|
6211
6283
|
async function resolveSizes(zipWriter, reader, { resolvedOptions: metadata }, options) {
|
|
6212
6284
|
const { passThrough, zipCrypto, password, rawPassword, encryptionStrength } = metadata;
|
|
6213
6285
|
let { dataDescriptor, zip64, level, compressionMethod } = metadata;
|
|
@@ -6532,12 +6604,9 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
|
|
|
6532
6604
|
msdosAttributes
|
|
6533
6605
|
};
|
|
6534
6606
|
let {
|
|
6535
|
-
crc32
|
|
6607
|
+
crc32,
|
|
6536
6608
|
uncompressedSize
|
|
6537
6609
|
} = options;
|
|
6538
|
-
if (signature === UNDEFINED_VALUE) {
|
|
6539
|
-
({ signature } = options);
|
|
6540
|
-
}
|
|
6541
6610
|
let compressedSize = 0;
|
|
6542
6611
|
if (!passThrough) {
|
|
6543
6612
|
uncompressedSize = 0;
|
|
@@ -6575,7 +6644,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
|
|
|
6575
6644
|
if (!passThrough) {
|
|
6576
6645
|
uncompressedSize = result.inputSize;
|
|
6577
6646
|
if (!encrypted || zipCrypto) {
|
|
6578
|
-
|
|
6647
|
+
crc32 = result.crc32;
|
|
6579
6648
|
}
|
|
6580
6649
|
}
|
|
6581
6650
|
if ((!zip64CompressedSize && compressedSize >= MAX_32_BITS) ||
|
|
@@ -6591,7 +6660,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
|
|
|
6591
6660
|
|
|
6592
6661
|
}
|
|
6593
6662
|
setEntryInfo({
|
|
6594
|
-
|
|
6663
|
+
crc32,
|
|
6595
6664
|
compressedSize,
|
|
6596
6665
|
uncompressedSize,
|
|
6597
6666
|
headerInfo,
|
|
@@ -6614,8 +6683,8 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
|
|
|
6614
6683
|
version,
|
|
6615
6684
|
headerArray,
|
|
6616
6685
|
headerView,
|
|
6617
|
-
signature,
|
|
6618
|
-
crc32: encrypted && !zipCrypto ? UNDEFINED_VALUE :
|
|
6686
|
+
signature: crc32,
|
|
6687
|
+
crc32: encrypted && !zipCrypto && !passThrough ? UNDEFINED_VALUE : crc32,
|
|
6619
6688
|
extraFieldExtendedTimestampFlag,
|
|
6620
6689
|
zip64UncompressedSize,
|
|
6621
6690
|
zip64CompressedSize
|
|
@@ -6636,6 +6705,7 @@ function getHeaderInfo(options) {
|
|
|
6636
6705
|
dataDescriptor,
|
|
6637
6706
|
directory,
|
|
6638
6707
|
rawExtraField,
|
|
6708
|
+
rawLocalExtraField,
|
|
6639
6709
|
encryptionStrength,
|
|
6640
6710
|
extendedTimestamp,
|
|
6641
6711
|
ntfsTimestamp,
|
|
@@ -6643,7 +6713,8 @@ function getHeaderInfo(options) {
|
|
|
6643
6713
|
encrypted,
|
|
6644
6714
|
zip64UncompressedSize,
|
|
6645
6715
|
zip64CompressedSize,
|
|
6646
|
-
uncompressedSize
|
|
6716
|
+
uncompressedSize,
|
|
6717
|
+
crc32
|
|
6647
6718
|
} = options;
|
|
6648
6719
|
let { version, compressionMethod } = options;
|
|
6649
6720
|
const compressed = !directory && (compressionMethod === UNDEFINED_VALUE
|
|
@@ -6731,7 +6802,7 @@ function getHeaderInfo(options) {
|
|
|
6731
6802
|
let rawExtraFieldUnix;
|
|
6732
6803
|
try {
|
|
6733
6804
|
const { uid, gid, unixExtraFieldType } = options;
|
|
6734
|
-
if (unixExtraFieldType == INFOZIP_EXTRA_FIELD_TYPE && (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE)) {
|
|
6805
|
+
if (unixExtraFieldType == INFOZIP_EXTRA_FIELD_TYPE$1 && (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE)) {
|
|
6735
6806
|
const uidBytes = packUnixId(uid);
|
|
6736
6807
|
const gidBytes = packUnixId(gid);
|
|
6737
6808
|
const payloadLength = 3 + uidBytes.length + gidBytes.length;
|
|
@@ -6769,11 +6840,14 @@ function getHeaderInfo(options) {
|
|
|
6769
6840
|
}
|
|
6770
6841
|
if (encrypted && !zipCrypto) {
|
|
6771
6842
|
version = version > VERSION_AES ? version : VERSION_AES;
|
|
6843
|
+
if (passThrough && crc32 !== UNDEFINED_VALUE) {
|
|
6844
|
+
rawExtraFieldAES[EXTRAFIELD_OFFSET_AES_VENDOR_VERSION] = VENDOR_VERSION_AE_1;
|
|
6845
|
+
}
|
|
6772
6846
|
rawExtraFieldAES[9] = compressionMethod;
|
|
6773
6847
|
compressionMethod = COMPRESSION_METHOD_AES;
|
|
6774
6848
|
}
|
|
6775
6849
|
const localExtraFieldZip64Length = writeLocalExtraFieldZip64 ? getLength(rawLocalExtraFieldZip64) : 0;
|
|
6776
|
-
const extraFieldLength = localExtraFieldZip64Length + getLength(rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS, rawExtraFieldUnix, rawExtraField);
|
|
6850
|
+
const extraFieldLength = localExtraFieldZip64Length + getLength(rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS, rawExtraFieldUnix, rawExtraField, rawLocalExtraField);
|
|
6777
6851
|
if (extraFieldLength > MAX_16_BITS) {
|
|
6778
6852
|
throw new Error(ERR_INVALID_EXTRAFIELD_DATA);
|
|
6779
6853
|
}
|
|
@@ -6807,6 +6881,7 @@ function getHeaderInfo(options) {
|
|
|
6807
6881
|
localHeader.bytes(rawExtraFieldNTFS);
|
|
6808
6882
|
localHeader.bytes(rawExtraFieldUnix);
|
|
6809
6883
|
localHeader.bytes(rawExtraField);
|
|
6884
|
+
localHeader.bytes(rawLocalExtraField);
|
|
6810
6885
|
if (dataDescriptor) {
|
|
6811
6886
|
if (!zip64CompressedSize) {
|
|
6812
6887
|
setUint32(localHeaderView, HEADER_OFFSET_COMPRESSED_SIZE + LOCAL_HEADER_COMMON_OFFSET, 0);
|
|
@@ -6925,7 +7000,7 @@ function getDataDescriptorInfo({
|
|
|
6925
7000
|
}
|
|
6926
7001
|
|
|
6927
7002
|
function setEntryInfo({
|
|
6928
|
-
|
|
7003
|
+
crc32,
|
|
6929
7004
|
compressedSize,
|
|
6930
7005
|
uncompressedSize,
|
|
6931
7006
|
headerInfo,
|
|
@@ -6933,6 +7008,7 @@ function setEntryInfo({
|
|
|
6933
7008
|
}, {
|
|
6934
7009
|
zip64,
|
|
6935
7010
|
zipCrypto,
|
|
7011
|
+
passThrough,
|
|
6936
7012
|
dataDescriptor
|
|
6937
7013
|
}) {
|
|
6938
7014
|
const {
|
|
@@ -6943,10 +7019,10 @@ function setEntryInfo({
|
|
|
6943
7019
|
dataDescriptorView,
|
|
6944
7020
|
dataDescriptorOffset
|
|
6945
7021
|
} = dataDescriptorInfo;
|
|
6946
|
-
if ((!encrypted || zipCrypto) &&
|
|
6947
|
-
setUint32(headerView, HEADER_OFFSET_SIGNATURE,
|
|
7022
|
+
if ((!encrypted || zipCrypto || passThrough) && crc32 !== UNDEFINED_VALUE) {
|
|
7023
|
+
setUint32(headerView, HEADER_OFFSET_SIGNATURE, crc32);
|
|
6948
7024
|
if (dataDescriptor) {
|
|
6949
|
-
setUint32(dataDescriptorView, dataDescriptorOffset,
|
|
7025
|
+
setUint32(dataDescriptorView, dataDescriptorOffset, crc32);
|
|
6950
7026
|
}
|
|
6951
7027
|
}
|
|
6952
7028
|
if (zip64) {
|
|
@@ -6969,15 +7045,15 @@ function updateLocalHeader({
|
|
|
6969
7045
|
encrypted,
|
|
6970
7046
|
zip64,
|
|
6971
7047
|
localExtraFieldZip64Length,
|
|
6972
|
-
|
|
7048
|
+
crc32,
|
|
6973
7049
|
compressedSize,
|
|
6974
7050
|
uncompressedSize,
|
|
6975
7051
|
zip64UncompressedSize,
|
|
6976
7052
|
zip64CompressedSize
|
|
6977
|
-
}, localHeaderView, { dataDescriptor }) {
|
|
7053
|
+
}, localHeaderView, { dataDescriptor, passThrough }) {
|
|
6978
7054
|
if (!dataDescriptor) {
|
|
6979
|
-
if (!encrypted) {
|
|
6980
|
-
setUint32(localHeaderView, HEADER_OFFSET_SIGNATURE + LOCAL_HEADER_COMMON_OFFSET,
|
|
7055
|
+
if (!encrypted || (passThrough && crc32 !== UNDEFINED_VALUE)) {
|
|
7056
|
+
setUint32(localHeaderView, HEADER_OFFSET_SIGNATURE + LOCAL_HEADER_COMMON_OFFSET, crc32);
|
|
6981
7057
|
}
|
|
6982
7058
|
if (!zip64CompressedSize) {
|
|
6983
7059
|
setUint32(localHeaderView, HEADER_OFFSET_COMPRESSED_SIZE + LOCAL_HEADER_COMMON_OFFSET, compressedSize);
|
|
@@ -8237,8 +8313,8 @@ configureWorker({
|
|
|
8237
8313
|
}
|
|
8238
8314
|
});
|
|
8239
8315
|
setDefaultConfiguration({
|
|
8240
|
-
CompressionStreamZlib,
|
|
8241
|
-
DecompressionStreamZlib
|
|
8316
|
+
CompressionStreamFallback: CompressionStreamZlib,
|
|
8317
|
+
DecompressionStreamFallback: DecompressionStreamZlib
|
|
8242
8318
|
});
|
|
8243
8319
|
|
|
8244
8320
|
function terminateWorkersAndModule() {
|
|
@@ -8247,33 +8323,7 @@ function terminateWorkersAndModule() {
|
|
|
8247
8323
|
resetWasmModule();
|
|
8248
8324
|
}
|
|
8249
8325
|
|
|
8250
|
-
|
|
8251
|
-
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
8252
|
-
|
|
8253
|
-
Redistribution and use in source and binary forms, with or without
|
|
8254
|
-
modification, are permitted provided that the following conditions are met:
|
|
8255
|
-
|
|
8256
|
-
1. Redistributions of source code must retain the above copyright notice,
|
|
8257
|
-
this list of conditions and the following disclaimer.
|
|
8258
|
-
|
|
8259
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
8260
|
-
notice, this list of conditions and the following disclaimer in
|
|
8261
|
-
the documentation and/or other materials provided with the distribution.
|
|
8262
|
-
|
|
8263
|
-
3. The names of the authors may not be used to endorse or promote products
|
|
8264
|
-
derived from this software without specific prior written permission.
|
|
8265
|
-
|
|
8266
|
-
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
8267
|
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
8268
|
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
8269
|
-
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
8270
|
-
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
8271
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
8272
|
-
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
8273
|
-
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
8274
|
-
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
8275
|
-
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
8276
|
-
*/
|
|
8326
|
+
/// <reference types="../index.d.ts" />
|
|
8277
8327
|
|
|
8278
8328
|
|
|
8279
8329
|
configureExternalAssets();
|
|
@@ -8309,6 +8359,20 @@ configureExternalAssets();
|
|
|
8309
8359
|
|
|
8310
8360
|
const ERR_ENTRY_EXISTS = "Entry filename already exists";
|
|
8311
8361
|
const ERR_READABLE_CONSUMED = "Readable stream already consumed";
|
|
8362
|
+
const INFOZIP_EXTRA_FIELD_TYPE = "infozip";
|
|
8363
|
+
const INTERPRETED_EXTRA_FIELD_TYPES = new Set([
|
|
8364
|
+
EXTRAFIELD_TYPE_ZIP64,
|
|
8365
|
+
EXTRAFIELD_TYPE_AES,
|
|
8366
|
+
EXTRAFIELD_TYPE_NTFS,
|
|
8367
|
+
EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP,
|
|
8368
|
+
EXTRAFIELD_TYPE_UNICODE_PATH,
|
|
8369
|
+
EXTRAFIELD_TYPE_UNICODE_COMMENT,
|
|
8370
|
+
EXTRAFIELD_TYPE_USDZ,
|
|
8371
|
+
EXTRAFIELD_TYPE_INFOZIP,
|
|
8372
|
+
EXTRAFIELD_TYPE_UNIX,
|
|
8373
|
+
EXTRAFIELD_TYPE_UNIX_TYPE1,
|
|
8374
|
+
EXTRAFIELD_TYPE_PKWARE_UNIX
|
|
8375
|
+
]);
|
|
8312
8376
|
|
|
8313
8377
|
class ZipEntry {
|
|
8314
8378
|
|
|
@@ -9046,6 +9110,20 @@ function detach(entry) {
|
|
|
9046
9110
|
}
|
|
9047
9111
|
}
|
|
9048
9112
|
|
|
9113
|
+
function getUserExtraField(extraField) {
|
|
9114
|
+
if (extraField) {
|
|
9115
|
+
const userExtraField = new Map();
|
|
9116
|
+
extraField.forEach((field, type) => {
|
|
9117
|
+
if (!INTERPRETED_EXTRA_FIELD_TYPES.has(type)) {
|
|
9118
|
+
userExtraField.set(type, field.data);
|
|
9119
|
+
}
|
|
9120
|
+
});
|
|
9121
|
+
if (userExtraField.size) {
|
|
9122
|
+
return userExtraField;
|
|
9123
|
+
}
|
|
9124
|
+
}
|
|
9125
|
+
}
|
|
9126
|
+
|
|
9049
9127
|
async function exportZip(zipWriter, entry, totalSize, options, readers) {
|
|
9050
9128
|
const selectedEntry = entry;
|
|
9051
9129
|
const entryOffsets = new Map();
|
|
@@ -9083,9 +9161,13 @@ async function exportZip(zipWriter, entry, totalSize, options, readers) {
|
|
|
9083
9161
|
uncompressedSize,
|
|
9084
9162
|
encrypted,
|
|
9085
9163
|
zipCrypto,
|
|
9086
|
-
|
|
9164
|
+
crc32,
|
|
9087
9165
|
compressionMethod,
|
|
9088
|
-
extraFieldAES
|
|
9166
|
+
extraFieldAES,
|
|
9167
|
+
internalFileAttributes,
|
|
9168
|
+
extraField,
|
|
9169
|
+
uid,
|
|
9170
|
+
gid
|
|
9089
9171
|
} = child.data;
|
|
9090
9172
|
zipEntryOptions = {
|
|
9091
9173
|
externalFileAttributes,
|
|
@@ -9093,8 +9175,20 @@ async function exportZip(zipWriter, entry, totalSize, options, readers) {
|
|
|
9093
9175
|
comment,
|
|
9094
9176
|
lastModDate,
|
|
9095
9177
|
creationDate,
|
|
9096
|
-
lastAccessDate
|
|
9178
|
+
lastAccessDate,
|
|
9179
|
+
internalFileAttributes
|
|
9097
9180
|
};
|
|
9181
|
+
const userExtraField = getUserExtraField(extraField);
|
|
9182
|
+
if (userExtraField) {
|
|
9183
|
+
zipEntryOptions.extraField = userExtraField;
|
|
9184
|
+
}
|
|
9185
|
+
if (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE) {
|
|
9186
|
+
Object.assign(zipEntryOptions, {
|
|
9187
|
+
uid,
|
|
9188
|
+
gid,
|
|
9189
|
+
unixExtraFieldType: options.unixExtraFieldType || INFOZIP_EXTRA_FIELD_TYPE
|
|
9190
|
+
});
|
|
9191
|
+
}
|
|
9098
9192
|
if (child.passThrough) {
|
|
9099
9193
|
let level, encryptionStrength;
|
|
9100
9194
|
if (compressionMethod === 0) {
|
|
@@ -9107,7 +9201,7 @@ async function exportZip(zipWriter, entry, totalSize, options, readers) {
|
|
|
9107
9201
|
passThrough: true,
|
|
9108
9202
|
encrypted,
|
|
9109
9203
|
zipCrypto,
|
|
9110
|
-
|
|
9204
|
+
crc32,
|
|
9111
9205
|
uncompressedSize,
|
|
9112
9206
|
level,
|
|
9113
9207
|
encryptionStrength,
|