@zip.js/zip.js 2.7.43 → 2.7.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/deno.json +1 -1
- package/dist/zip-fs-full.js +52 -21
- package/dist/zip-fs-full.min.js +1 -1
- package/dist/zip-fs.js +48 -19
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-full.js +47 -19
- package/dist/zip-full.min.js +1 -1
- package/dist/zip-no-worker-deflate.min.js +1 -1
- package/dist/zip-no-worker-inflate.min.js +1 -1
- package/dist/zip-no-worker.min.js +1 -1
- package/dist/zip.js +45 -17
- package/dist/zip.min.js +1 -1
- package/index.cjs +52 -21
- package/index.d.ts +18 -12
- package/index.min.js +1 -1
- package/lib/core/zip-reader.js +10 -4
- package/lib/core/zip-writer.js +16 -10
- package/package.json +4 -7
package/dist/zip-full.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
const { Array, Object, String, Number, BigInt, Math, Date, Map, Set, Response, URL, Error, Uint8Array, Uint16Array, Uint32Array, DataView, Blob, Promise, TextEncoder, TextDecoder, document, crypto, btoa, TransformStream, ReadableStream, WritableStream, CompressionStream, DecompressionStream, navigator, Worker } = typeof globalThis !== 'undefined' ? globalThis : this || self;
|
|
8
8
|
|
|
9
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
9
10
|
/*
|
|
10
11
|
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
11
12
|
|
|
@@ -1046,7 +1047,7 @@
|
|
|
1046
1047
|
bi_windup(); // align on byte boundary
|
|
1047
1048
|
last_eob_len = 8; // enough lookahead for inflate
|
|
1048
1049
|
|
|
1049
|
-
|
|
1050
|
+
{
|
|
1050
1051
|
put_short(len);
|
|
1051
1052
|
put_short(~len);
|
|
1052
1053
|
}
|
|
@@ -1061,7 +1062,7 @@
|
|
|
1061
1062
|
eof // true if this is the last block for a file
|
|
1062
1063
|
) {
|
|
1063
1064
|
send_bits((STORED_BLOCK << 1) + (eof ? 1 : 0), 3); // send block type
|
|
1064
|
-
copy_block(buf, stored_len
|
|
1065
|
+
copy_block(buf, stored_len); // with header
|
|
1065
1066
|
}
|
|
1066
1067
|
|
|
1067
1068
|
// Determine the best encoding for the current block: dynamic trees, static
|
|
@@ -4331,6 +4332,7 @@
|
|
|
4331
4332
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
4332
4333
|
*/
|
|
4333
4334
|
|
|
4335
|
+
|
|
4334
4336
|
class StreamAdapter {
|
|
4335
4337
|
|
|
4336
4338
|
constructor(Codec) {
|
|
@@ -4381,6 +4383,7 @@
|
|
|
4381
4383
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
4382
4384
|
*/
|
|
4383
4385
|
|
|
4386
|
+
|
|
4384
4387
|
const MINIMUM_CHUNK_SIZE = 64;
|
|
4385
4388
|
let maxWorkers = 2;
|
|
4386
4389
|
try {
|
|
@@ -4497,6 +4500,7 @@
|
|
|
4497
4500
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
4498
4501
|
*/
|
|
4499
4502
|
|
|
4503
|
+
|
|
4500
4504
|
function getMimeType() {
|
|
4501
4505
|
return "application/octet-stream";
|
|
4502
4506
|
}
|
|
@@ -4644,6 +4648,7 @@
|
|
|
4644
4648
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
4645
4649
|
*/
|
|
4646
4650
|
|
|
4651
|
+
|
|
4647
4652
|
class Crc32Stream extends TransformStream {
|
|
4648
4653
|
|
|
4649
4654
|
constructor() {
|
|
@@ -4693,6 +4698,7 @@
|
|
|
4693
4698
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
4694
4699
|
*/
|
|
4695
4700
|
|
|
4701
|
+
|
|
4696
4702
|
function encodeText(value) {
|
|
4697
4703
|
if (typeof TextEncoder == UNDEFINED_TYPE) {
|
|
4698
4704
|
value = unescape(encodeURIComponent(value));
|
|
@@ -5554,6 +5560,7 @@
|
|
|
5554
5560
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
5555
5561
|
*/
|
|
5556
5562
|
|
|
5563
|
+
|
|
5557
5564
|
const GET_RANDOM_VALUES_SUPPORTED = typeof crypto != UNDEFINED_TYPE && typeof crypto.getRandomValues == FUNCTION_TYPE;
|
|
5558
5565
|
|
|
5559
5566
|
const ERR_INVALID_PASSWORD = "Invalid password";
|
|
@@ -5596,6 +5603,7 @@
|
|
|
5596
5603
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
5597
5604
|
*/
|
|
5598
5605
|
|
|
5606
|
+
|
|
5599
5607
|
const BLOCK_LENGTH = 16;
|
|
5600
5608
|
const RAW_FORMAT = "raw";
|
|
5601
5609
|
const PBKDF2_ALGORITHM = { name: "PBKDF2" };
|
|
@@ -5899,6 +5907,7 @@
|
|
|
5899
5907
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
5900
5908
|
*/
|
|
5901
5909
|
|
|
5910
|
+
|
|
5902
5911
|
const HEADER_LENGTH = 12;
|
|
5903
5912
|
|
|
5904
5913
|
class ZipCryptoDecryptionStream extends TransformStream {
|
|
@@ -6046,6 +6055,7 @@
|
|
|
6046
6055
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
6047
6056
|
*/
|
|
6048
6057
|
|
|
6058
|
+
|
|
6049
6059
|
const COMPRESSION_FORMAT = "deflate-raw";
|
|
6050
6060
|
|
|
6051
6061
|
class DeflateStream extends TransformStream {
|
|
@@ -6186,6 +6196,7 @@
|
|
|
6186
6196
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
6187
6197
|
*/
|
|
6188
6198
|
|
|
6199
|
+
|
|
6189
6200
|
const MESSAGE_EVENT_TYPE = "message";
|
|
6190
6201
|
const MESSAGE_START = "start";
|
|
6191
6202
|
const MESSAGE_PULL = "pull";
|
|
@@ -6307,6 +6318,7 @@
|
|
|
6307
6318
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
6308
6319
|
*/
|
|
6309
6320
|
|
|
6321
|
+
|
|
6310
6322
|
// deno-lint-ignore valid-typeof
|
|
6311
6323
|
let WEB_WORKERS_SUPPORTED = typeof Worker != UNDEFINED_TYPE;
|
|
6312
6324
|
|
|
@@ -6635,6 +6647,7 @@
|
|
|
6635
6647
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
6636
6648
|
*/
|
|
6637
6649
|
|
|
6650
|
+
|
|
6638
6651
|
let pool = [];
|
|
6639
6652
|
const pendingRequests = [];
|
|
6640
6653
|
|
|
@@ -6741,6 +6754,7 @@
|
|
|
6741
6754
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
6742
6755
|
*/
|
|
6743
6756
|
|
|
6757
|
+
|
|
6744
6758
|
const ERR_HTTP_STATUS = "HTTP error ";
|
|
6745
6759
|
const ERR_HTTP_RANGE = "HTTP Range not supported";
|
|
6746
6760
|
const ERR_ITERATOR_COMPLETED_TOO_SOON = "Writer iterator completed too soon";
|
|
@@ -7501,6 +7515,7 @@
|
|
|
7501
7515
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
7502
7516
|
*/
|
|
7503
7517
|
|
|
7518
|
+
|
|
7504
7519
|
function decodeText(value, encoding) {
|
|
7505
7520
|
if (encoding && encoding.trim().toLowerCase() == "cp437") {
|
|
7506
7521
|
return decodeCP437(value);
|
|
@@ -7602,6 +7617,7 @@
|
|
|
7602
7617
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
7603
7618
|
*/
|
|
7604
7619
|
|
|
7620
|
+
|
|
7605
7621
|
const ERR_BAD_FORMAT = "File format is not recognized";
|
|
7606
7622
|
const ERR_EOCDR_NOT_FOUND = "End of central directory not found";
|
|
7607
7623
|
const ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND = "End of Zip64 central directory locator not found";
|
|
@@ -7780,10 +7796,16 @@
|
|
|
7780
7796
|
rawExtraField: directoryArray.subarray(extraFieldOffset, commentOffset)
|
|
7781
7797
|
});
|
|
7782
7798
|
const decode = getOptionValue$1(zipReader, options, "decodeText") || decodeText;
|
|
7783
|
-
const
|
|
7784
|
-
|
|
7785
|
-
|
|
7786
|
-
|
|
7799
|
+
const rawFilenameEncoding = filenameUTF8 ? CHARSET_UTF8 : filenameEncoding || CHARSET_CP437;
|
|
7800
|
+
const rawCommentEncoding = commentUTF8 ? CHARSET_UTF8 : commentEncoding || CHARSET_CP437;
|
|
7801
|
+
let filename = decode(rawFilename, rawFilenameEncoding);
|
|
7802
|
+
if (filename === UNDEFINED_VALUE) {
|
|
7803
|
+
filename = decodeText(rawFilename, rawFilenameEncoding);
|
|
7804
|
+
}
|
|
7805
|
+
let comment = decode(rawComment, rawCommentEncoding);
|
|
7806
|
+
if (comment === UNDEFINED_VALUE) {
|
|
7807
|
+
comment = decodeText(rawComment, rawCommentEncoding);
|
|
7808
|
+
}
|
|
7787
7809
|
Object.assign(fileEntry, {
|
|
7788
7810
|
rawComment,
|
|
7789
7811
|
filename,
|
|
@@ -8265,6 +8287,7 @@
|
|
|
8265
8287
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
8266
8288
|
*/
|
|
8267
8289
|
|
|
8290
|
+
|
|
8268
8291
|
const ERR_DUPLICATED_NAME = "File already exists";
|
|
8269
8292
|
const ERR_INVALID_COMMENT = "Zip file comment exceeds 64KB";
|
|
8270
8293
|
const ERR_INVALID_ENTRY_COMMENT = "File entry comment exceeds 64KB";
|
|
@@ -8387,12 +8410,18 @@
|
|
|
8387
8410
|
options.directory = name.endsWith(DIRECTORY_SIGNATURE);
|
|
8388
8411
|
}
|
|
8389
8412
|
const encode = getOptionValue(zipWriter, options, "encodeText", encodeText);
|
|
8390
|
-
|
|
8413
|
+
let rawFilename = encode(name);
|
|
8414
|
+
if (rawFilename === UNDEFINED_VALUE) {
|
|
8415
|
+
rawFilename = encodeText(name);
|
|
8416
|
+
}
|
|
8391
8417
|
if (getLength(rawFilename) > MAX_16_BITS) {
|
|
8392
8418
|
throw new Error(ERR_INVALID_ENTRY_NAME);
|
|
8393
8419
|
}
|
|
8394
8420
|
const comment = options.comment || "";
|
|
8395
|
-
|
|
8421
|
+
let rawComment = encode(comment);
|
|
8422
|
+
if (rawComment === UNDEFINED_VALUE) {
|
|
8423
|
+
rawComment = encodeText(comment);
|
|
8424
|
+
}
|
|
8396
8425
|
if (getLength(rawComment) > MAX_16_BITS) {
|
|
8397
8426
|
throw new Error(ERR_INVALID_ENTRY_COMMENT);
|
|
8398
8427
|
}
|
|
@@ -8458,7 +8487,7 @@
|
|
|
8458
8487
|
dataDescriptor = true;
|
|
8459
8488
|
if (zip64 || zip64 === UNDEFINED_VALUE) {
|
|
8460
8489
|
zip64 = true;
|
|
8461
|
-
uncompressedSize = maximumCompressedSize = MAX_32_BITS;
|
|
8490
|
+
uncompressedSize = maximumCompressedSize = MAX_32_BITS + 1;
|
|
8462
8491
|
}
|
|
8463
8492
|
} else {
|
|
8464
8493
|
uncompressedSize = reader.size;
|
|
@@ -8466,11 +8495,11 @@
|
|
|
8466
8495
|
}
|
|
8467
8496
|
}
|
|
8468
8497
|
const { diskOffset, diskNumber, maxSize } = zipWriter.writer;
|
|
8469
|
-
const zip64UncompressedSize = zip64Enabled || uncompressedSize
|
|
8470
|
-
const zip64CompressedSize = zip64Enabled || maximumCompressedSize
|
|
8471
|
-
const zip64Offset = zip64Enabled || zipWriter.offset + zipWriter.pendingEntriesSize - diskOffset
|
|
8498
|
+
const zip64UncompressedSize = zip64Enabled || uncompressedSize > MAX_32_BITS;
|
|
8499
|
+
const zip64CompressedSize = zip64Enabled || maximumCompressedSize > MAX_32_BITS;
|
|
8500
|
+
const zip64Offset = zip64Enabled || zipWriter.offset + zipWriter.pendingEntriesSize - diskOffset > MAX_32_BITS;
|
|
8472
8501
|
const supportZip64SplitFile = getOptionValue(zipWriter, options, "supportZip64SplitFile", true);
|
|
8473
|
-
const zip64DiskNumberStart = (supportZip64SplitFile && zip64Enabled) || diskNumber + Math.ceil(zipWriter.pendingEntriesSize / maxSize)
|
|
8502
|
+
const zip64DiskNumberStart = (supportZip64SplitFile && zip64Enabled) || diskNumber + Math.ceil(zipWriter.pendingEntriesSize / maxSize) > MAX_16_BITS;
|
|
8474
8503
|
if (zip64Offset || zip64UncompressedSize || zip64CompressedSize || zip64DiskNumberStart) {
|
|
8475
8504
|
if (zip64 === false || !keepOrder) {
|
|
8476
8505
|
throw new Error(ERR_UNSUPPORTED_FORMAT);
|
|
@@ -8495,7 +8524,7 @@
|
|
|
8495
8524
|
zip64DiskNumberStart,
|
|
8496
8525
|
password,
|
|
8497
8526
|
rawPassword,
|
|
8498
|
-
level: !useCompressionStream && zipWriter.config.CompressionStream === UNDEFINED_VALUE ? 0 : level,
|
|
8527
|
+
level: !useCompressionStream && (zipWriter.config.CompressionStream === UNDEFINED_VALUE && zipWriter.config.CompressionStreamNative === UNDEFINED_VALUE) ? 0 : level,
|
|
8499
8528
|
useWebWorkers,
|
|
8500
8529
|
encryptionStrength,
|
|
8501
8530
|
extendedTimestamp,
|
|
@@ -8613,7 +8642,7 @@
|
|
|
8613
8642
|
fileEntry.offset = zipWriter.offset - diskOffset;
|
|
8614
8643
|
if (fileEntry.zip64) {
|
|
8615
8644
|
setZip64ExtraInfo(fileEntry, options);
|
|
8616
|
-
} else if (fileEntry.offset
|
|
8645
|
+
} else if (fileEntry.offset > MAX_32_BITS) {
|
|
8617
8646
|
throw new Error(ERR_UNSUPPORTED_FORMAT);
|
|
8618
8647
|
}
|
|
8619
8648
|
zipWriter.offset += fileEntry.size;
|
|
@@ -9230,7 +9259,7 @@
|
|
|
9230
9259
|
lastDiskNumber++;
|
|
9231
9260
|
}
|
|
9232
9261
|
let zip64 = getOptionValue(zipWriter, options, "zip64");
|
|
9233
|
-
if (directoryOffset
|
|
9262
|
+
if (directoryOffset > MAX_32_BITS || directoryDataLength > MAX_32_BITS || filesLength > MAX_16_BITS || lastDiskNumber > MAX_16_BITS) {
|
|
9234
9263
|
if (zip64 === false) {
|
|
9235
9264
|
throw new Error(ERR_UNSUPPORTED_FORMAT);
|
|
9236
9265
|
} else {
|
|
@@ -9369,9 +9398,10 @@
|
|
|
9369
9398
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
9370
9399
|
*/
|
|
9371
9400
|
|
|
9401
|
+
|
|
9372
9402
|
let baseURL;
|
|
9373
9403
|
try {
|
|
9374
|
-
baseURL = (typeof document === 'undefined' && typeof location === 'undefined' ?
|
|
9404
|
+
baseURL = (typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.src || new URL('zip-full.js', document.baseURI).href));
|
|
9375
9405
|
} catch (_error) {
|
|
9376
9406
|
// ignored
|
|
9377
9407
|
}
|
|
@@ -9430,6 +9460,4 @@
|
|
|
9430
9460
|
exports.readUint8Array = readUint8Array;
|
|
9431
9461
|
exports.terminateWorkers = terminateWorkers;
|
|
9432
9462
|
|
|
9433
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
9434
|
-
|
|
9435
9463
|
}));
|