@zip.js/zip.js 2.8.58 → 2.8.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/deno.json +1 -1
- package/dist/zip-core-external.js +157 -39
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +171 -38
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +157 -40
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +156 -39
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +157 -40
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +171 -39
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +171 -39
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +171 -38
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +171 -38
- package/dist/zip-native.min.js +1 -1
- package/dist/zip.js +171 -38
- package/dist/zip.min.js +1 -1
- package/index-native.cjs +171 -39
- package/index-native.min.js +1 -1
- package/index.cjs +171 -39
- package/index.d.cts +184 -1
- package/index.d.ts +184 -1
- package/index.min.js +1 -1
- package/lib/core/constants.js +2 -0
- package/lib/core/options.js +2 -0
- package/lib/core/zip-reader.js +143 -33
- package/lib/core/zip-writer.js +13 -6
- package/lib/zip-core-reader.js +16 -1
- package/package.json +1 -1
package/index.d.cts
CHANGED
|
@@ -1341,6 +1341,31 @@ export class ZipReader<Type> {
|
|
|
1341
1341
|
* `6 + digitalSignature.length` from it when the record is stored inside the declared range.
|
|
1342
1342
|
*/
|
|
1343
1343
|
directoryLength?: number;
|
|
1344
|
+
/**
|
|
1345
|
+
* The non-fatal diagnostics deposited while reading the entries, replaced every time
|
|
1346
|
+
* {@link ZipReader#getEntries} or {@link ZipReader#getEntriesGenerator} runs.
|
|
1347
|
+
*
|
|
1348
|
+
* @remarks
|
|
1349
|
+
* A warning reports a characteristic of the zip file observed in data the parse had already read: depositing
|
|
1350
|
+
* one never costs additional I/O, and a well-formed zip file deposits none. Each
|
|
1351
|
+
* {@link ArchiveWarning#reason} value is deposited at most once per call, with
|
|
1352
|
+
* {@link ArchiveWarning#filename} naming the first entry it applies to when it applies to an entry.
|
|
1353
|
+
*
|
|
1354
|
+
* Two kinds of reasons are deposited. Observations are always non-fatal: {@link WARNING_UNSORTED_CENTRAL_DIRECTORY},
|
|
1355
|
+
* {@link WARNING_UNKNOWN_VERSION} (the low byte of the "version needed to extract" field exceeds the highest
|
|
1356
|
+
* known zip specification version; the high byte is ignored because some writers store a host identifier in it),
|
|
1357
|
+
* {@link WARNING_COMPRESSED_PATCHED_DATA} (bit 5 of the general purpose bit flag),
|
|
1358
|
+
* {@link WARNING_MALFORMED_EXTRA_FIELD}, {@link WARNING_UNKNOWN_ZIP64_EXTENSIBLE_DATA} and
|
|
1359
|
+
* {@link WARNING_WRAPPED_ENTRIES_COUNT}. The other reasons are the checks that
|
|
1360
|
+
* `strictness: "strict"` rejects with {@link ERR_AMBIGUOUS_ARCHIVE}: when the effective strictness tolerates
|
|
1361
|
+
* one of them and the evidence is already in hand, the same reason string is deposited as a warning instead —
|
|
1362
|
+
* {@link WARNING_APPENDED_DATA}, {@link WARNING_PREPENDED_DATA}, {@link WARNING_TRAILING_CENTRAL_DIRECTORY_DATA},
|
|
1363
|
+
* {@link WARNING_DUPLICATE_FILENAME} and {@link WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY}.
|
|
1364
|
+
*
|
|
1365
|
+
* The warnings related to the local file header of an entry are deposited on
|
|
1366
|
+
* {@link EntryMetaData#warnings} when its data is read, not here.
|
|
1367
|
+
*/
|
|
1368
|
+
warnings?: ArchiveWarning[];
|
|
1344
1369
|
/**
|
|
1345
1370
|
* Returns all the entries in the zip file
|
|
1346
1371
|
*
|
|
@@ -1369,6 +1394,58 @@ export class ZipReader<Type> {
|
|
|
1369
1394
|
close(): Promise<void>;
|
|
1370
1395
|
}
|
|
1371
1396
|
|
|
1397
|
+
/**
|
|
1398
|
+
* Returns `true` if the data looks like a zip file, i.e. if {@link ZipReader#getEntries} called on the same
|
|
1399
|
+
* data with the same options would locate the archive structure instead of throwing
|
|
1400
|
+
* {@link ERR_EOCDR_NOT_FOUND} or the {@link ERR_AMBIGUOUS_ARCHIVE} error caused by appended data.
|
|
1401
|
+
*
|
|
1402
|
+
* @remarks
|
|
1403
|
+
* The probe runs the same search as {@link ZipReader}: it locates the end of central directory record with
|
|
1404
|
+
* the end-anchored backward scan and verifies that a central directory record is stored where it points,
|
|
1405
|
+
* without parsing the entries. `true` therefore means the data is a plausible zip container, not that every
|
|
1406
|
+
* entry can be read: a truncated or otherwise damaged central directory is only detected by calling
|
|
1407
|
+
* {@link ZipReader#getEntries}. Formats built on zip, e.g. office documents or Java archives, return `true`.
|
|
1408
|
+
*
|
|
1409
|
+
* Like the {@link ZipReader} constructor, a `ReadableStream` or an object providing only a `readable`
|
|
1410
|
+
* property is buffered entirely in memory before probing, which defeats the purpose of a cheap probe; prefer
|
|
1411
|
+
* a seekable {@link Reader} input.
|
|
1412
|
+
*
|
|
1413
|
+
* @param reader The {@link Reader} instance used to read data.
|
|
1414
|
+
* @param options The options.
|
|
1415
|
+
* @returns A promise resolving to `true` if the data looks like a zip file.
|
|
1416
|
+
*/
|
|
1417
|
+
export function isZipFile(
|
|
1418
|
+
reader:
|
|
1419
|
+
| Reader<unknown>
|
|
1420
|
+
| ReadableReader
|
|
1421
|
+
| ReadableStream
|
|
1422
|
+
| Reader<unknown>[]
|
|
1423
|
+
| ReadableReader[]
|
|
1424
|
+
| ReadableStream[],
|
|
1425
|
+
options?: IsZipFileOptions
|
|
1426
|
+
): Promise<boolean>;
|
|
1427
|
+
|
|
1428
|
+
/**
|
|
1429
|
+
* Represents the options passed to {@link isZipFile}.
|
|
1430
|
+
*/
|
|
1431
|
+
export interface IsZipFileOptions {
|
|
1432
|
+
/**
|
|
1433
|
+
* The tolerance of the probe, with the same semantics and default as
|
|
1434
|
+
* {@link ZipReaderConstructorOptions#strictness}: it selects the default amount of tolerated appended data
|
|
1435
|
+
* (0 for `"strict"`, 65536 bytes for `"balanced"`, unlimited for `"tolerant"`) and `"strict"` also returns
|
|
1436
|
+
* `false` when multiple end of central directory records reach the end of the data.
|
|
1437
|
+
*
|
|
1438
|
+
* @defaultValue "balanced"
|
|
1439
|
+
*/
|
|
1440
|
+
strictness?: "strict" | "balanced" | "tolerant";
|
|
1441
|
+
/**
|
|
1442
|
+
* The maximum number of bytes tolerated after the end of central directory record, overriding the default
|
|
1443
|
+
* selected by {@link IsZipFileOptions#strictness}, with the same semantics as
|
|
1444
|
+
* {@link ZipReaderConstructorOptions#maxAppendedDataSize}.
|
|
1445
|
+
*/
|
|
1446
|
+
maxAppendedDataSize?: number;
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1372
1449
|
/**
|
|
1373
1450
|
* Represents the options passed to the constructor of {@link ZipReader}, and `{@link ZipDirectory}#import*`.
|
|
1374
1451
|
*/
|
|
@@ -2420,7 +2497,35 @@ export interface EntryMetaData {
|
|
|
2420
2497
|
* {@link EntryMetaData#uid} and {@link EntryMetaData#gid}, which are read from the central directory.
|
|
2421
2498
|
*/
|
|
2422
2499
|
localDirectory?: LocalDirectory;
|
|
2500
|
+
/**
|
|
2501
|
+
* The non-fatal diagnostics deposited while reading the entry data, replaced every time the data is read.
|
|
2502
|
+
*
|
|
2503
|
+
* @remarks
|
|
2504
|
+
* The reasons deposited here relate to the local file header: {@link WARNING_MALFORMED_EXTRA_FIELD} when its
|
|
2505
|
+
* extra field data cannot be fully parsed, and — only when {@link ZipReaderOptions#checkLocalDirectory} is
|
|
2506
|
+
* disabled, e.g. with `strictness: "tolerant"` — the local file header mismatches the enabled check rejects
|
|
2507
|
+
* with {@link ERR_AMBIGUOUS_ARCHIVE}: {@link WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG},
|
|
2508
|
+
* {@link WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD} and
|
|
2509
|
+
* {@link WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES}. The archive-level warnings are deposited on
|
|
2510
|
+
* {@link ZipReader#warnings} instead.
|
|
2511
|
+
*/
|
|
2512
|
+
warnings?: ArchiveWarning[];
|
|
2423
2513
|
}
|
|
2514
|
+
|
|
2515
|
+
/**
|
|
2516
|
+
* Represents a non-fatal diagnostic deposited on {@link ZipReader#warnings} or {@link EntryMetaData#warnings}.
|
|
2517
|
+
*/
|
|
2518
|
+
export interface ArchiveWarning {
|
|
2519
|
+
/**
|
|
2520
|
+
* The reason of the warning, one of the exported `WARNING_*` constants.
|
|
2521
|
+
*/
|
|
2522
|
+
reason: string;
|
|
2523
|
+
/**
|
|
2524
|
+
* The filename of the first entry the warning applies to, when it applies to an entry.
|
|
2525
|
+
*/
|
|
2526
|
+
filename?: string;
|
|
2527
|
+
}
|
|
2528
|
+
|
|
2424
2529
|
export interface DirectoryEntry extends EntryMetaData {
|
|
2425
2530
|
/**
|
|
2426
2531
|
* `true` if the entry is a directory.
|
|
@@ -2693,7 +2798,8 @@ export class ZipWriter<Type> {
|
|
|
2693
2798
|
* @param filename The filename of the entry. Paths must use forward slashes ("/") as separator,
|
|
2694
2799
|
* as required by section 4.4.17.1 of the zip specification. The value is stored as-is; in
|
|
2695
2800
|
* particular, Windows path separators ("\\") are not converted and become part of the filename,
|
|
2696
|
-
* which is interpreted inconsistently by zip tools
|
|
2801
|
+
* which is interpreted inconsistently by zip tools, and leading or trailing whitespace is
|
|
2802
|
+
* preserved, which Windows filesystems cannot represent at the end of a name.
|
|
2697
2803
|
* @param reader The {@link Reader} instance used to read the content of the entry.
|
|
2698
2804
|
* @param options The options.
|
|
2699
2805
|
* @returns A promise resolving to an {@link EntryMetaData} instance.
|
|
@@ -2779,6 +2885,10 @@ export interface ZipWriterAddDataOptions
|
|
|
2779
2885
|
* The extra field of the entry written only in the local file header.
|
|
2780
2886
|
*/
|
|
2781
2887
|
localExtraField?: Map<number, Uint8Array>;
|
|
2888
|
+
/**
|
|
2889
|
+
* The extra field of the entry written only in the central directory record.
|
|
2890
|
+
*/
|
|
2891
|
+
centralExtraField?: Map<number, Uint8Array>;
|
|
2782
2892
|
/**
|
|
2783
2893
|
* The uncompressed size of the entry. This option is ignored if the {@link ZipWriterConstructorOptions#passThrough} option is not set to `true`.
|
|
2784
2894
|
*/
|
|
@@ -4560,3 +4670,76 @@ export const ERR_UNSUPPORTED_CRYPTO_API: string;
|
|
|
4560
4670
|
* disallowing workers; set `useWebWorkers` to `false` in {@link configure} to work around it)
|
|
4561
4671
|
*/
|
|
4562
4672
|
export const ERR_WORKER_STARTUP_TIMEOUT: string;
|
|
4673
|
+
/**
|
|
4674
|
+
* Warning reason: the central directory records are not ordered by entry data position (see {@link ZipReader#warnings})
|
|
4675
|
+
*/
|
|
4676
|
+
export const WARNING_UNSORTED_CENTRAL_DIRECTORY: string;
|
|
4677
|
+
/**
|
|
4678
|
+
* Warning reason: the low byte of the "version needed to extract" field of an entry exceeds the highest known
|
|
4679
|
+
* zip specification version (see {@link ZipReader#warnings})
|
|
4680
|
+
*/
|
|
4681
|
+
export const WARNING_UNKNOWN_VERSION: string;
|
|
4682
|
+
/**
|
|
4683
|
+
* Warning reason: an entry has bit 5 of the general purpose bit flag set, i.e. declares compressed patched data
|
|
4684
|
+
* (see {@link ZipReader#warnings})
|
|
4685
|
+
*/
|
|
4686
|
+
export const WARNING_COMPRESSED_PATCHED_DATA: string;
|
|
4687
|
+
/**
|
|
4688
|
+
* Warning reason: the extra field data of a record cannot be fully parsed; the raw bytes stay available in
|
|
4689
|
+
* `rawExtraField` (see {@link ZipReader#warnings} and {@link EntryMetaData#warnings})
|
|
4690
|
+
*/
|
|
4691
|
+
export const WARNING_MALFORMED_EXTRA_FIELD: string;
|
|
4692
|
+
/**
|
|
4693
|
+
* Warning reason: the Zip64 end of central directory record carries extensible data the zip file does not use
|
|
4694
|
+
* (see {@link ZipReader#warnings})
|
|
4695
|
+
*/
|
|
4696
|
+
export const WARNING_UNKNOWN_ZIP64_EXTENSIBLE_DATA: string;
|
|
4697
|
+
/**
|
|
4698
|
+
* Warning reason: the zip file contains more than 65535 entries without Zip64, recovered from the 16-bit entry
|
|
4699
|
+
* count wrapped modulo 65536 (see {@link ZipReader#warnings})
|
|
4700
|
+
*/
|
|
4701
|
+
export const WARNING_WRAPPED_ENTRIES_COUNT: string;
|
|
4702
|
+
/**
|
|
4703
|
+
* Warning reason: data is appended after the end of the zip file (see {@link ZipReader#warnings}); the reason of
|
|
4704
|
+
* {@link ERR_AMBIGUOUS_ARCHIVE} when the appended data exceeds {@link GetEntriesOptions#maxAppendedDataSize}
|
|
4705
|
+
*/
|
|
4706
|
+
export const WARNING_APPENDED_DATA: string;
|
|
4707
|
+
/**
|
|
4708
|
+
* Warning reason: data is prepended before the zip file (see {@link ZipReader#warnings}); the reason of
|
|
4709
|
+
* {@link ERR_AMBIGUOUS_ARCHIVE} under `strictness: "strict"`
|
|
4710
|
+
*/
|
|
4711
|
+
export const WARNING_PREPENDED_DATA: string;
|
|
4712
|
+
/**
|
|
4713
|
+
* Warning reason: data lies between the end of the central directory records and the end of central directory
|
|
4714
|
+
* record, either inside the declared central directory length or beyond it (see {@link ZipReader#warnings});
|
|
4715
|
+
* the reason of {@link ERR_AMBIGUOUS_ARCHIVE} under `strictness: "strict"`
|
|
4716
|
+
*/
|
|
4717
|
+
export const WARNING_TRAILING_CENTRAL_DIRECTORY_DATA: string;
|
|
4718
|
+
/**
|
|
4719
|
+
* Warning reason: several entries share the same filename (see {@link ZipReader#warnings}); the reason of
|
|
4720
|
+
* {@link ERR_AMBIGUOUS_ARCHIVE} under `strictness: "strict"`
|
|
4721
|
+
*/
|
|
4722
|
+
export const WARNING_DUPLICATE_FILENAME: string;
|
|
4723
|
+
/**
|
|
4724
|
+
* Warning reason: the end of central directory record and its Zip64 counterpart disagree on a field stored in
|
|
4725
|
+
* both (see {@link ZipReader#warnings}); the reason of {@link ERR_AMBIGUOUS_ARCHIVE} under `strictness: "strict"`
|
|
4726
|
+
*/
|
|
4727
|
+
export const WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY: string;
|
|
4728
|
+
/**
|
|
4729
|
+
* Warning reason: the general purpose bit flag of the local file header contradicts the central directory
|
|
4730
|
+
* (see {@link EntryMetaData#warnings}); the reason of {@link ERR_AMBIGUOUS_ARCHIVE} when
|
|
4731
|
+
* {@link ZipReaderOptions#checkLocalDirectory} is enabled
|
|
4732
|
+
*/
|
|
4733
|
+
export const WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG: string;
|
|
4734
|
+
/**
|
|
4735
|
+
* Warning reason: the compression method of the local file header contradicts the central directory
|
|
4736
|
+
* (see {@link EntryMetaData#warnings}); the reason of {@link ERR_AMBIGUOUS_ARCHIVE} when
|
|
4737
|
+
* {@link ZipReaderOptions#checkLocalDirectory} is enabled
|
|
4738
|
+
*/
|
|
4739
|
+
export const WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD: string;
|
|
4740
|
+
/**
|
|
4741
|
+
* Warning reason: the crc32 or the sizes of the local file header contradict the central directory
|
|
4742
|
+
* (see {@link EntryMetaData#warnings}); the reason of {@link ERR_AMBIGUOUS_ARCHIVE} when
|
|
4743
|
+
* {@link ZipReaderOptions#checkLocalDirectory} is enabled
|
|
4744
|
+
*/
|
|
4745
|
+
export const WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES: string;
|
package/index.d.ts
CHANGED
|
@@ -1341,6 +1341,31 @@ export class ZipReader<Type> {
|
|
|
1341
1341
|
* `6 + digitalSignature.length` from it when the record is stored inside the declared range.
|
|
1342
1342
|
*/
|
|
1343
1343
|
directoryLength?: number;
|
|
1344
|
+
/**
|
|
1345
|
+
* The non-fatal diagnostics deposited while reading the entries, replaced every time
|
|
1346
|
+
* {@link ZipReader#getEntries} or {@link ZipReader#getEntriesGenerator} runs.
|
|
1347
|
+
*
|
|
1348
|
+
* @remarks
|
|
1349
|
+
* A warning reports a characteristic of the zip file observed in data the parse had already read: depositing
|
|
1350
|
+
* one never costs additional I/O, and a well-formed zip file deposits none. Each
|
|
1351
|
+
* {@link ArchiveWarning#reason} value is deposited at most once per call, with
|
|
1352
|
+
* {@link ArchiveWarning#filename} naming the first entry it applies to when it applies to an entry.
|
|
1353
|
+
*
|
|
1354
|
+
* Two kinds of reasons are deposited. Observations are always non-fatal: {@link WARNING_UNSORTED_CENTRAL_DIRECTORY},
|
|
1355
|
+
* {@link WARNING_UNKNOWN_VERSION} (the low byte of the "version needed to extract" field exceeds the highest
|
|
1356
|
+
* known zip specification version; the high byte is ignored because some writers store a host identifier in it),
|
|
1357
|
+
* {@link WARNING_COMPRESSED_PATCHED_DATA} (bit 5 of the general purpose bit flag),
|
|
1358
|
+
* {@link WARNING_MALFORMED_EXTRA_FIELD}, {@link WARNING_UNKNOWN_ZIP64_EXTENSIBLE_DATA} and
|
|
1359
|
+
* {@link WARNING_WRAPPED_ENTRIES_COUNT}. The other reasons are the checks that
|
|
1360
|
+
* `strictness: "strict"` rejects with {@link ERR_AMBIGUOUS_ARCHIVE}: when the effective strictness tolerates
|
|
1361
|
+
* one of them and the evidence is already in hand, the same reason string is deposited as a warning instead —
|
|
1362
|
+
* {@link WARNING_APPENDED_DATA}, {@link WARNING_PREPENDED_DATA}, {@link WARNING_TRAILING_CENTRAL_DIRECTORY_DATA},
|
|
1363
|
+
* {@link WARNING_DUPLICATE_FILENAME} and {@link WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY}.
|
|
1364
|
+
*
|
|
1365
|
+
* The warnings related to the local file header of an entry are deposited on
|
|
1366
|
+
* {@link EntryMetaData#warnings} when its data is read, not here.
|
|
1367
|
+
*/
|
|
1368
|
+
warnings?: ArchiveWarning[];
|
|
1344
1369
|
/**
|
|
1345
1370
|
* Returns all the entries in the zip file
|
|
1346
1371
|
*
|
|
@@ -1369,6 +1394,58 @@ export class ZipReader<Type> {
|
|
|
1369
1394
|
close(): Promise<void>;
|
|
1370
1395
|
}
|
|
1371
1396
|
|
|
1397
|
+
/**
|
|
1398
|
+
* Returns `true` if the data looks like a zip file, i.e. if {@link ZipReader#getEntries} called on the same
|
|
1399
|
+
* data with the same options would locate the archive structure instead of throwing
|
|
1400
|
+
* {@link ERR_EOCDR_NOT_FOUND} or the {@link ERR_AMBIGUOUS_ARCHIVE} error caused by appended data.
|
|
1401
|
+
*
|
|
1402
|
+
* @remarks
|
|
1403
|
+
* The probe runs the same search as {@link ZipReader}: it locates the end of central directory record with
|
|
1404
|
+
* the end-anchored backward scan and verifies that a central directory record is stored where it points,
|
|
1405
|
+
* without parsing the entries. `true` therefore means the data is a plausible zip container, not that every
|
|
1406
|
+
* entry can be read: a truncated or otherwise damaged central directory is only detected by calling
|
|
1407
|
+
* {@link ZipReader#getEntries}. Formats built on zip, e.g. office documents or Java archives, return `true`.
|
|
1408
|
+
*
|
|
1409
|
+
* Like the {@link ZipReader} constructor, a `ReadableStream` or an object providing only a `readable`
|
|
1410
|
+
* property is buffered entirely in memory before probing, which defeats the purpose of a cheap probe; prefer
|
|
1411
|
+
* a seekable {@link Reader} input.
|
|
1412
|
+
*
|
|
1413
|
+
* @param reader The {@link Reader} instance used to read data.
|
|
1414
|
+
* @param options The options.
|
|
1415
|
+
* @returns A promise resolving to `true` if the data looks like a zip file.
|
|
1416
|
+
*/
|
|
1417
|
+
export function isZipFile(
|
|
1418
|
+
reader:
|
|
1419
|
+
| Reader<unknown>
|
|
1420
|
+
| ReadableReader
|
|
1421
|
+
| ReadableStream
|
|
1422
|
+
| Reader<unknown>[]
|
|
1423
|
+
| ReadableReader[]
|
|
1424
|
+
| ReadableStream[],
|
|
1425
|
+
options?: IsZipFileOptions
|
|
1426
|
+
): Promise<boolean>;
|
|
1427
|
+
|
|
1428
|
+
/**
|
|
1429
|
+
* Represents the options passed to {@link isZipFile}.
|
|
1430
|
+
*/
|
|
1431
|
+
export interface IsZipFileOptions {
|
|
1432
|
+
/**
|
|
1433
|
+
* The tolerance of the probe, with the same semantics and default as
|
|
1434
|
+
* {@link ZipReaderConstructorOptions#strictness}: it selects the default amount of tolerated appended data
|
|
1435
|
+
* (0 for `"strict"`, 65536 bytes for `"balanced"`, unlimited for `"tolerant"`) and `"strict"` also returns
|
|
1436
|
+
* `false` when multiple end of central directory records reach the end of the data.
|
|
1437
|
+
*
|
|
1438
|
+
* @defaultValue "balanced"
|
|
1439
|
+
*/
|
|
1440
|
+
strictness?: "strict" | "balanced" | "tolerant";
|
|
1441
|
+
/**
|
|
1442
|
+
* The maximum number of bytes tolerated after the end of central directory record, overriding the default
|
|
1443
|
+
* selected by {@link IsZipFileOptions#strictness}, with the same semantics as
|
|
1444
|
+
* {@link ZipReaderConstructorOptions#maxAppendedDataSize}.
|
|
1445
|
+
*/
|
|
1446
|
+
maxAppendedDataSize?: number;
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1372
1449
|
/**
|
|
1373
1450
|
* Represents the options passed to the constructor of {@link ZipReader}, and `{@link ZipDirectory}#import*`.
|
|
1374
1451
|
*/
|
|
@@ -2420,7 +2497,35 @@ export interface EntryMetaData {
|
|
|
2420
2497
|
* {@link EntryMetaData#uid} and {@link EntryMetaData#gid}, which are read from the central directory.
|
|
2421
2498
|
*/
|
|
2422
2499
|
localDirectory?: LocalDirectory;
|
|
2500
|
+
/**
|
|
2501
|
+
* The non-fatal diagnostics deposited while reading the entry data, replaced every time the data is read.
|
|
2502
|
+
*
|
|
2503
|
+
* @remarks
|
|
2504
|
+
* The reasons deposited here relate to the local file header: {@link WARNING_MALFORMED_EXTRA_FIELD} when its
|
|
2505
|
+
* extra field data cannot be fully parsed, and — only when {@link ZipReaderOptions#checkLocalDirectory} is
|
|
2506
|
+
* disabled, e.g. with `strictness: "tolerant"` — the local file header mismatches the enabled check rejects
|
|
2507
|
+
* with {@link ERR_AMBIGUOUS_ARCHIVE}: {@link WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG},
|
|
2508
|
+
* {@link WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD} and
|
|
2509
|
+
* {@link WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES}. The archive-level warnings are deposited on
|
|
2510
|
+
* {@link ZipReader#warnings} instead.
|
|
2511
|
+
*/
|
|
2512
|
+
warnings?: ArchiveWarning[];
|
|
2423
2513
|
}
|
|
2514
|
+
|
|
2515
|
+
/**
|
|
2516
|
+
* Represents a non-fatal diagnostic deposited on {@link ZipReader#warnings} or {@link EntryMetaData#warnings}.
|
|
2517
|
+
*/
|
|
2518
|
+
export interface ArchiveWarning {
|
|
2519
|
+
/**
|
|
2520
|
+
* The reason of the warning, one of the exported `WARNING_*` constants.
|
|
2521
|
+
*/
|
|
2522
|
+
reason: string;
|
|
2523
|
+
/**
|
|
2524
|
+
* The filename of the first entry the warning applies to, when it applies to an entry.
|
|
2525
|
+
*/
|
|
2526
|
+
filename?: string;
|
|
2527
|
+
}
|
|
2528
|
+
|
|
2424
2529
|
export interface DirectoryEntry extends EntryMetaData {
|
|
2425
2530
|
/**
|
|
2426
2531
|
* `true` if the entry is a directory.
|
|
@@ -2693,7 +2798,8 @@ export class ZipWriter<Type> {
|
|
|
2693
2798
|
* @param filename The filename of the entry. Paths must use forward slashes ("/") as separator,
|
|
2694
2799
|
* as required by section 4.4.17.1 of the zip specification. The value is stored as-is; in
|
|
2695
2800
|
* particular, Windows path separators ("\\") are not converted and become part of the filename,
|
|
2696
|
-
* which is interpreted inconsistently by zip tools
|
|
2801
|
+
* which is interpreted inconsistently by zip tools, and leading or trailing whitespace is
|
|
2802
|
+
* preserved, which Windows filesystems cannot represent at the end of a name.
|
|
2697
2803
|
* @param reader The {@link Reader} instance used to read the content of the entry.
|
|
2698
2804
|
* @param options The options.
|
|
2699
2805
|
* @returns A promise resolving to an {@link EntryMetaData} instance.
|
|
@@ -2779,6 +2885,10 @@ export interface ZipWriterAddDataOptions
|
|
|
2779
2885
|
* The extra field of the entry written only in the local file header.
|
|
2780
2886
|
*/
|
|
2781
2887
|
localExtraField?: Map<number, Uint8Array>;
|
|
2888
|
+
/**
|
|
2889
|
+
* The extra field of the entry written only in the central directory record.
|
|
2890
|
+
*/
|
|
2891
|
+
centralExtraField?: Map<number, Uint8Array>;
|
|
2782
2892
|
/**
|
|
2783
2893
|
* The uncompressed size of the entry. This option is ignored if the {@link ZipWriterConstructorOptions#passThrough} option is not set to `true`.
|
|
2784
2894
|
*/
|
|
@@ -4560,3 +4670,76 @@ export const ERR_UNSUPPORTED_CRYPTO_API: string;
|
|
|
4560
4670
|
* disallowing workers; set `useWebWorkers` to `false` in {@link configure} to work around it)
|
|
4561
4671
|
*/
|
|
4562
4672
|
export const ERR_WORKER_STARTUP_TIMEOUT: string;
|
|
4673
|
+
/**
|
|
4674
|
+
* Warning reason: the central directory records are not ordered by entry data position (see {@link ZipReader#warnings})
|
|
4675
|
+
*/
|
|
4676
|
+
export const WARNING_UNSORTED_CENTRAL_DIRECTORY: string;
|
|
4677
|
+
/**
|
|
4678
|
+
* Warning reason: the low byte of the "version needed to extract" field of an entry exceeds the highest known
|
|
4679
|
+
* zip specification version (see {@link ZipReader#warnings})
|
|
4680
|
+
*/
|
|
4681
|
+
export const WARNING_UNKNOWN_VERSION: string;
|
|
4682
|
+
/**
|
|
4683
|
+
* Warning reason: an entry has bit 5 of the general purpose bit flag set, i.e. declares compressed patched data
|
|
4684
|
+
* (see {@link ZipReader#warnings})
|
|
4685
|
+
*/
|
|
4686
|
+
export const WARNING_COMPRESSED_PATCHED_DATA: string;
|
|
4687
|
+
/**
|
|
4688
|
+
* Warning reason: the extra field data of a record cannot be fully parsed; the raw bytes stay available in
|
|
4689
|
+
* `rawExtraField` (see {@link ZipReader#warnings} and {@link EntryMetaData#warnings})
|
|
4690
|
+
*/
|
|
4691
|
+
export const WARNING_MALFORMED_EXTRA_FIELD: string;
|
|
4692
|
+
/**
|
|
4693
|
+
* Warning reason: the Zip64 end of central directory record carries extensible data the zip file does not use
|
|
4694
|
+
* (see {@link ZipReader#warnings})
|
|
4695
|
+
*/
|
|
4696
|
+
export const WARNING_UNKNOWN_ZIP64_EXTENSIBLE_DATA: string;
|
|
4697
|
+
/**
|
|
4698
|
+
* Warning reason: the zip file contains more than 65535 entries without Zip64, recovered from the 16-bit entry
|
|
4699
|
+
* count wrapped modulo 65536 (see {@link ZipReader#warnings})
|
|
4700
|
+
*/
|
|
4701
|
+
export const WARNING_WRAPPED_ENTRIES_COUNT: string;
|
|
4702
|
+
/**
|
|
4703
|
+
* Warning reason: data is appended after the end of the zip file (see {@link ZipReader#warnings}); the reason of
|
|
4704
|
+
* {@link ERR_AMBIGUOUS_ARCHIVE} when the appended data exceeds {@link GetEntriesOptions#maxAppendedDataSize}
|
|
4705
|
+
*/
|
|
4706
|
+
export const WARNING_APPENDED_DATA: string;
|
|
4707
|
+
/**
|
|
4708
|
+
* Warning reason: data is prepended before the zip file (see {@link ZipReader#warnings}); the reason of
|
|
4709
|
+
* {@link ERR_AMBIGUOUS_ARCHIVE} under `strictness: "strict"`
|
|
4710
|
+
*/
|
|
4711
|
+
export const WARNING_PREPENDED_DATA: string;
|
|
4712
|
+
/**
|
|
4713
|
+
* Warning reason: data lies between the end of the central directory records and the end of central directory
|
|
4714
|
+
* record, either inside the declared central directory length or beyond it (see {@link ZipReader#warnings});
|
|
4715
|
+
* the reason of {@link ERR_AMBIGUOUS_ARCHIVE} under `strictness: "strict"`
|
|
4716
|
+
*/
|
|
4717
|
+
export const WARNING_TRAILING_CENTRAL_DIRECTORY_DATA: string;
|
|
4718
|
+
/**
|
|
4719
|
+
* Warning reason: several entries share the same filename (see {@link ZipReader#warnings}); the reason of
|
|
4720
|
+
* {@link ERR_AMBIGUOUS_ARCHIVE} under `strictness: "strict"`
|
|
4721
|
+
*/
|
|
4722
|
+
export const WARNING_DUPLICATE_FILENAME: string;
|
|
4723
|
+
/**
|
|
4724
|
+
* Warning reason: the end of central directory record and its Zip64 counterpart disagree on a field stored in
|
|
4725
|
+
* both (see {@link ZipReader#warnings}); the reason of {@link ERR_AMBIGUOUS_ARCHIVE} under `strictness: "strict"`
|
|
4726
|
+
*/
|
|
4727
|
+
export const WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY: string;
|
|
4728
|
+
/**
|
|
4729
|
+
* Warning reason: the general purpose bit flag of the local file header contradicts the central directory
|
|
4730
|
+
* (see {@link EntryMetaData#warnings}); the reason of {@link ERR_AMBIGUOUS_ARCHIVE} when
|
|
4731
|
+
* {@link ZipReaderOptions#checkLocalDirectory} is enabled
|
|
4732
|
+
*/
|
|
4733
|
+
export const WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG: string;
|
|
4734
|
+
/**
|
|
4735
|
+
* Warning reason: the compression method of the local file header contradicts the central directory
|
|
4736
|
+
* (see {@link EntryMetaData#warnings}); the reason of {@link ERR_AMBIGUOUS_ARCHIVE} when
|
|
4737
|
+
* {@link ZipReaderOptions#checkLocalDirectory} is enabled
|
|
4738
|
+
*/
|
|
4739
|
+
export const WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD: string;
|
|
4740
|
+
/**
|
|
4741
|
+
* Warning reason: the crc32 or the sizes of the local file header contradict the central directory
|
|
4742
|
+
* (see {@link EntryMetaData#warnings}); the reason of {@link ERR_AMBIGUOUS_ARCHIVE} when
|
|
4743
|
+
* {@link ZipReaderOptions#checkLocalDirectory} is enabled
|
|
4744
|
+
*/
|
|
4745
|
+
export const WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES: string;
|