@zip.js/zip.js 2.16.1 → 2.18.0

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.
Files changed (45) hide show
  1. package/deno.json +1 -1
  2. package/dist/zip-core-external.js +211 -130
  3. package/dist/zip-core-external.min.js +1 -1
  4. package/dist/zip-core.js +180 -117
  5. package/dist/zip-core.min.js +1 -1
  6. package/dist/zip-fs-core-external.js +223 -132
  7. package/dist/zip-fs-core-external.min.js +1 -1
  8. package/dist/zip-fs-core.js +192 -119
  9. package/dist/zip-fs-core.min.js +1 -1
  10. package/dist/zip-fs-external.js +223 -132
  11. package/dist/zip-fs-external.min.js +1 -1
  12. package/dist/zip-fs-native.js +194 -121
  13. package/dist/zip-fs-native.min.js +1 -1
  14. package/dist/zip-fs.js +224 -132
  15. package/dist/zip-fs.min.js +1 -1
  16. package/dist/zip-legacy.js +181 -118
  17. package/dist/zip-legacy.min.js +1 -1
  18. package/dist/zip-native.js +182 -119
  19. package/dist/zip-native.min.js +1 -1
  20. package/dist/zip-web-worker-native.js +1 -1
  21. package/dist/zip-web-worker.js +1 -1
  22. package/dist/zip.js +212 -130
  23. package/dist/zip.min.js +1 -1
  24. package/index-native.cjs +194 -121
  25. package/index-native.min.js +1 -1
  26. package/index.cjs +224 -132
  27. package/index.d.cts +87 -24
  28. package/index.d.ts +87 -24
  29. package/index.min.js +1 -1
  30. package/lib/core/codec-pool.js +2 -0
  31. package/lib/core/codec-worker-web.js +16 -3
  32. package/lib/core/codec-worker.js +2 -1
  33. package/lib/core/streams/codec-stream.js +2 -0
  34. package/lib/core/streams/zip-entry-stream.js +123 -102
  35. package/lib/core/streams/zlib-js/zlib-streams.min.js +1 -1
  36. package/lib/core/streams/zlib-wasm/zlib-streams.js +31 -12
  37. package/lib/core/version.js +1 -1
  38. package/lib/core/web-worker-base.js +2 -2
  39. package/lib/core/web-worker-inline-native.js +1 -1
  40. package/lib/core/web-worker-inline-wasm.js +1 -1
  41. package/lib/core/zip-fs.js +16 -3
  42. package/lib/core/zip-reader.js +40 -11
  43. package/lib/core/zip-writer.js +1 -0
  44. package/lib/zip-core-reader.js +1 -0
  45. package/package.json +1 -1
package/index.d.cts CHANGED
@@ -2009,7 +2009,10 @@ export interface ZipReaderOptions {
2009
2009
  *
2010
2010
  * A signal already aborted when the operation starts rejects it with {@link ERR_ABORTED} as the
2011
2011
  * reason of the `AbortError`, or with `signal.reason` when it is set, without relying on the
2012
- * `signal` option of `pipeTo` that the oldest supported engines ignore.
2012
+ * `signal` option of `pipeTo` that the oldest supported engines ignore. A signal aborted while the
2013
+ * entry is being read rejects the operation as well, whether its compressed data is still being
2014
+ * consumed or its content still being written; on those engines, the content is written to the end
2015
+ * before the operation is rejected.
2013
2016
  */
2014
2017
  signal?: AbortSignal;
2015
2018
  /**
@@ -3423,7 +3426,10 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
3423
3426
  *
3424
3427
  * A signal already aborted when the operation starts rejects it with {@link ERR_ABORTED} as the
3425
3428
  * reason of the `AbortError`, or with `signal.reason` when it is set, without relying on the
3426
- * `signal` option of `pipeTo` that the oldest supported engines ignore.
3429
+ * `signal` option of `pipeTo` that the oldest supported engines ignore. A signal aborted while the
3430
+ * entry is being added rejects the operation as well, whether its content is still being read or
3431
+ * its compressed data still being written; on those engines, the data is written to the end before
3432
+ * the operation is rejected.
3427
3433
  */
3428
3434
  signal?: AbortSignal;
3429
3435
  /**
@@ -4544,9 +4550,13 @@ export class ZipDirectoryEntry extends ZipEntry {
4544
4550
  * encrypted with ZipCrypto verifies the password on a single byte, so one wrong password in 256 passes
4545
4551
  * that check and fails while reading the content instead: for such entries the password is first
4546
4552
  * verified alone, the CRC32 of the content is then checked whatever the {@link ZipReaderOptions#checkCrc32}
4547
- * option says, and any failure of the read is treated as a wrong password and the next candidate is
4548
- * tried. An entry encrypted with AES verifies it on two bytes, so a failure of the read that follows is
4549
- * reported as-is, e.g. as an {@link ERR_INVALID_AUTHENTICATION_CODE} error.
4553
+ * option says, and a read failing with an {@link ERR_INVALID_CRC32}, {@link ERR_INVALID_COMPRESSED_DATA}
4554
+ * or {@link ERR_INVALID_UNCOMPRESSED_SIZE} error is treated as a wrong password and the next candidate is
4555
+ * tried. Any other failure, e.g. a failure of the reader or an {@link ERR_CODEC_OUT_OF_MEMORY} error, is
4556
+ * reported as-is. A corrupted entry read with the right password is reported as a wrong password too,
4557
+ * since nothing tells it from a wrong password passing the check. An entry encrypted with AES verifies
4558
+ * the password on two bytes, so a failure of the read that follows is reported as-is, e.g. as an
4559
+ * {@link ERR_INVALID_AUTHENTICATION_CODE} error.
4550
4560
  *
4551
4561
  * The options are set when importing the zip file, in the {@link ZipDirectoryEntryExportOptions#readerOptions}
4552
4562
  * option of an export, and when reading one entry with `{@link ZipFileEntry}#get*()`. They apply to the
@@ -4559,8 +4569,9 @@ export interface PasswordCandidatesOptions {
4559
4569
  * passwords already accepted by another entry of the same imported zip file. An empty string is
4560
4570
  * ignored.
4561
4571
  *
4562
- * When every candidate fails, the entry raises an {@link ERR_INVALID_PASSWORD} error, unless the
4563
- * {@link PasswordCandidatesOptions#requestPassword} option is set.
4572
+ * When every candidate fails, the entry raises an {@link ERR_INVALID_PASSWORD} error whose `cause` is
4573
+ * the error raised by the last candidate, unless the {@link PasswordCandidatesOptions#requestPassword}
4574
+ * option is set.
4564
4575
  *
4565
4576
  * A value which is neither an array of strings nor unset throws an {@link ERR_INVALID_PASSWORDS}
4566
4577
  * error.
@@ -4573,8 +4584,9 @@ export interface PasswordCandidatesOptions {
4573
4584
  *
4574
4585
  * A string is tried on the entry, and the function is called again when it fails, with the
4575
4586
  * {@link ERR_INVALID_PASSWORD} error. `undefined` or `null` gives up: the entry raises an
4576
- * {@link ERR_INVALID_PASSWORD} error, or an {@link ERR_ENCRYPTED} error when no candidate was
4577
- * tried. A value of another type throws an {@link ERR_INVALID_REQUEST_PASSWORD} error. The
4587
+ * {@link ERR_INVALID_PASSWORD} error whose `cause` is the error raised by the last candidate, or an
4588
+ * {@link ERR_ENCRYPTED} error when no candidate was tried. A value of another type throws an
4589
+ * {@link ERR_INVALID_REQUEST_PASSWORD} error. The
4578
4590
  * function is not called for the entries whose password is already known.
4579
4591
  *
4580
4592
  * When several entries are read concurrently, e.g. by `{@link ZipDirectoryEntry}#export*()` with the
@@ -4977,6 +4989,16 @@ export const ERR_CENTRAL_DIRECTORY_NOT_FOUND: string;
4977
4989
  export const ERR_LOCAL_FILE_HEADER_NOT_FOUND: string;
4978
4990
  /**
4979
4991
  * Extra field Zip64 not found error
4992
+ *
4993
+ * @remarks
4994
+ * Raised by {@link ZipReader#getEntries} when the Zip64 extra field of a central directory record is missing or
4995
+ * too short to hold the values that the `0xFFFFFFFF` and `0xFFFF` sentinels of the record defer to it, since the
4996
+ * sizes and the offset of the entry have no other source. The same defect in a local file header is not fatal, because
4997
+ * the sizes of an entry are read from the central directory: {@link FileEntry#getData} reports it as
4998
+ * {@link WARNING_MALFORMED_EXTRA_FIELD} on {@link EntryMetaData#warnings}, and an entry without a data descriptor
4999
+ * keeps the sentinels as its local sizes, which the local file header check reports as
5000
+ * {@link WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES}, an error or a warning depending on
5001
+ * {@link ZipReaderOptions#strictness}.
4980
5002
  */
4981
5003
  export const ERR_EXTRAFIELD_ZIP64_NOT_FOUND: string;
4982
5004
  /**
@@ -5006,6 +5028,15 @@ export const ERR_INVALID_CODEC_MODULE: string;
5006
5028
  /**
5007
5029
  * Invalid CRC-32 checksum error, thrown when the {@link ZipReaderOptions#checkCrc32} option is set and the CRC-32
5008
5030
  * checksum of an entry does not match the value stored in the zip file.
5031
+ *
5032
+ * @remarks
5033
+ * When the inflater verifies the checksum itself, through a gzip trailer that zip.js builds from the stored
5034
+ * CRC-32 and uncompressed size, it rejects the trailer as a whole and its error is kept as the `cause`. A
5035
+ * stored uncompressed size larger than the data therefore raises this error too on that route, whereas a
5036
+ * stored size smaller than the data raises {@link ERR_INVALID_UNCOMPRESSED_SIZE} on every route. Bytes
5037
+ * trailing the DEFLATE stream, e.g. a wrong `compressedSize`, displace that trailer, and an inflater that
5038
+ * reports them only once the real trailer has been written, as the one of Node.js does, raises this error
5039
+ * in place of {@link ERR_INVALID_COMPRESSED_DATA}.
5009
5040
  */
5010
5041
  export const ERR_INVALID_CRC32: string;
5011
5042
  /**
@@ -5014,24 +5045,50 @@ export const ERR_INVALID_CRC32: string;
5014
5045
  */
5015
5046
  export const ERR_INVALID_AUTHENTICATION_CODE: string;
5016
5047
  /**
5017
- * Invalid uncompressed size error
5048
+ * Invalid uncompressed size error, thrown when an entry inflates to more bytes than its stored uncompressed size.
5049
+ *
5050
+ * @remarks
5051
+ * An entry encrypted with AES that stores no CRC-32 (AE-2) raises this error when it inflates to fewer bytes
5052
+ * as well, since the end of its data is told by the stored size alone, when it is inflated through a gzip
5053
+ * container: on a host whose native inflater lacks `"deflate-raw"`, when the bundled codec cannot take over
5054
+ * either, e.g. because its WASM module failed to load.
5018
5055
  */
5019
5056
  export const ERR_INVALID_UNCOMPRESSED_SIZE: string;
5020
5057
  /**
5021
- * Invalid compressed data error
5058
+ * Invalid compressed data error, thrown when the codec rejects the compressed data of an entry.
5022
5059
  *
5023
5060
  * @remarks
5024
- * The way malformed compressed data is reported is not uniform across codec
5025
- * backends. Bytes trailing a complete DEFLATE stream (e.g. a wrong
5026
- * `compressedSize`) are tolerated by the bundled WASM and pure-JS codecs, which
5027
- * decompress the valid data and ignore the extra bytes, but are rejected by the
5028
- * native `DecompressionStream` with its own `TypeError` (on Node,
5029
- * `ERR_TRAILING_JUNK_AFTER_STREAM_END`) rather than this error. Any data that is
5030
- * returned is always validated against the entry's uncompressed size (and CRC
5031
- * when `checkCrc32` is set), so it is never silently truncated; the backends
5032
- * differ only in whether trailing bytes are ignored or raised as an error.
5061
+ * The error is the same whatever inflates the data, and the error the codec raised is kept as its
5062
+ * `cause`: the `TypeError` of a native `DecompressionStream`, whose message depends on the engine,
5063
+ * or the error of the bundled WASM or pure-JS codec. An error raised while reading the data, e.g.
5064
+ * by the reader of the zip file or by the decryption of the entry, is not a codec failure and
5065
+ * reaches the caller unchanged.
5066
+ *
5067
+ * Bytes trailing a complete DEFLATE stream (e.g. a wrong `compressedSize`) are rejected by every
5068
+ * codec, the native `DecompressionStream` (on Node.js, with `ERR_TRAILING_JUNK_AFTER_STREAM_END`
5069
+ * as the `code` of the cause) and the bundled WASM and pure-JS codecs alike, except that with
5070
+ * {@link ZipReaderOptions#checkCrc32} set the native inflater of Node.js reports them as
5071
+ * {@link ERR_INVALID_CRC32}, see that error. Any data that is returned is always validated against
5072
+ * the entry's uncompressed size (and CRC when {@link ZipReaderOptions#checkCrc32} is set), so it is
5073
+ * never silently truncated.
5033
5074
  */
5034
5075
  export const ERR_INVALID_COMPRESSED_DATA: string;
5076
+ /**
5077
+ * Codec out of memory error, thrown when the codec of an entry cannot allocate the memory it needs, e.g. when
5078
+ * the fixed heap of the bundled WASM module is exhausted by too many entries processed concurrently in the same
5079
+ * scope.
5080
+ *
5081
+ * @remarks
5082
+ * The error the codec raised is kept as the `cause`. The failure is recognized by the `code` property of that
5083
+ * error, `"Z_MEM_ERROR"`, which the bundled WASM codec sets and the native `DecompressionStream` of Node.js
5084
+ * would set; a codec reporting the failure without it is reported as {@link ERR_INVALID_COMPRESSED_DATA} when
5085
+ * reading, or with its own error when writing. When writing, only a codec that fails to allocate its state is
5086
+ * reported with this error: a failure while compressing keeps the error of the codec. On a host whose native
5087
+ * codec lacks `"deflate-raw"`, a bundled codec that cannot allocate its state when the entry starts is not
5088
+ * reported either: the native codec takes over through a gzip container, unless `useCompressionStream` is
5089
+ * `false`.
5090
+ */
5091
+ export const ERR_CODEC_OUT_OF_MEMORY: string;
5035
5092
  /**
5036
5093
  * Invalid password error
5037
5094
  */
@@ -5216,7 +5273,9 @@ export const ERR_INVALID_MAX_APPENDED_DATA_SIZE: string;
5216
5273
  * Unsupported 64-bit value error
5217
5274
  *
5218
5275
  * @remarks Thrown when a 64-bit size, offset, or entry count read from a zip file exceeds `Number.MAX_SAFE_INTEGER`,
5219
- * instead of processing the value with a loss of precision.
5276
+ * instead of processing the value with a loss of precision. A local file header whose Zip64 extra field holds such a
5277
+ * value is not rejected, since the sizes of an entry are read from the central directory: the field is reported as
5278
+ * {@link WARNING_MALFORMED_EXTRA_FIELD} instead, see {@link ERR_EXTRAFIELD_ZIP64_NOT_FOUND}.
5220
5279
  */
5221
5280
  export const ERR_UNSUPPORTED_UINT64: string;
5222
5281
  /**
@@ -5470,8 +5529,11 @@ export const WARNING_UNKNOWN_VERSION: string;
5470
5529
  */
5471
5530
  export const WARNING_COMPRESSED_PATCHED_DATA: string;
5472
5531
  /**
5473
- * Warning reason: the extra field data of a record cannot be fully parsed; the raw bytes stay available in
5474
- * `rawExtraField` (see {@link ZipReader#warnings} and {@link EntryMetaData#warnings})
5532
+ * Warning reason: the extra field data of a record cannot be fully parsed, or one of its fields is ignored: an AES
5533
+ * extra field shorter than 7 bytes, or on a record that is not encrypted and whose compression method is not 99, and
5534
+ * the Zip64 extra field of a local file header that is missing behind the sentinels of the header, too short for
5535
+ * them, or holds a value above `Number.MAX_SAFE_INTEGER`.
5536
+ * The raw bytes stay available in `rawExtraField` (see {@link ZipReader#warnings} and {@link EntryMetaData#warnings})
5475
5537
  */
5476
5538
  export const WARNING_MALFORMED_EXTRA_FIELD: string;
5477
5539
  /**
@@ -5539,7 +5601,8 @@ export const WARNING_MISMATCHED_LOCAL_FILE_HEADER_FILENAME: string;
5539
5601
  /**
5540
5602
  * Warning reason: the general purpose bit flag of the local file header contradicts the central directory
5541
5603
  * (see {@link EntryMetaData#warnings}); the reason of {@link ERR_AMBIGUOUS_ARCHIVE} when
5542
- * {@link ZipReaderOptions#checkLocalDirectory} is enabled
5604
+ * {@link ZipReaderOptions#checkLocalDirectory} is enabled. The entry is read as the central directory declares,
5605
+ * its encrypted flag included.
5543
5606
  */
5544
5607
  export const WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG: string;
5545
5608
  /**
package/index.d.ts CHANGED
@@ -2009,7 +2009,10 @@ export interface ZipReaderOptions {
2009
2009
  *
2010
2010
  * A signal already aborted when the operation starts rejects it with {@link ERR_ABORTED} as the
2011
2011
  * reason of the `AbortError`, or with `signal.reason` when it is set, without relying on the
2012
- * `signal` option of `pipeTo` that the oldest supported engines ignore.
2012
+ * `signal` option of `pipeTo` that the oldest supported engines ignore. A signal aborted while the
2013
+ * entry is being read rejects the operation as well, whether its compressed data is still being
2014
+ * consumed or its content still being written; on those engines, the content is written to the end
2015
+ * before the operation is rejected.
2013
2016
  */
2014
2017
  signal?: AbortSignal;
2015
2018
  /**
@@ -3423,7 +3426,10 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
3423
3426
  *
3424
3427
  * A signal already aborted when the operation starts rejects it with {@link ERR_ABORTED} as the
3425
3428
  * reason of the `AbortError`, or with `signal.reason` when it is set, without relying on the
3426
- * `signal` option of `pipeTo` that the oldest supported engines ignore.
3429
+ * `signal` option of `pipeTo` that the oldest supported engines ignore. A signal aborted while the
3430
+ * entry is being added rejects the operation as well, whether its content is still being read or
3431
+ * its compressed data still being written; on those engines, the data is written to the end before
3432
+ * the operation is rejected.
3427
3433
  */
3428
3434
  signal?: AbortSignal;
3429
3435
  /**
@@ -4544,9 +4550,13 @@ export class ZipDirectoryEntry extends ZipEntry {
4544
4550
  * encrypted with ZipCrypto verifies the password on a single byte, so one wrong password in 256 passes
4545
4551
  * that check and fails while reading the content instead: for such entries the password is first
4546
4552
  * verified alone, the CRC32 of the content is then checked whatever the {@link ZipReaderOptions#checkCrc32}
4547
- * option says, and any failure of the read is treated as a wrong password and the next candidate is
4548
- * tried. An entry encrypted with AES verifies it on two bytes, so a failure of the read that follows is
4549
- * reported as-is, e.g. as an {@link ERR_INVALID_AUTHENTICATION_CODE} error.
4553
+ * option says, and a read failing with an {@link ERR_INVALID_CRC32}, {@link ERR_INVALID_COMPRESSED_DATA}
4554
+ * or {@link ERR_INVALID_UNCOMPRESSED_SIZE} error is treated as a wrong password and the next candidate is
4555
+ * tried. Any other failure, e.g. a failure of the reader or an {@link ERR_CODEC_OUT_OF_MEMORY} error, is
4556
+ * reported as-is. A corrupted entry read with the right password is reported as a wrong password too,
4557
+ * since nothing tells it from a wrong password passing the check. An entry encrypted with AES verifies
4558
+ * the password on two bytes, so a failure of the read that follows is reported as-is, e.g. as an
4559
+ * {@link ERR_INVALID_AUTHENTICATION_CODE} error.
4550
4560
  *
4551
4561
  * The options are set when importing the zip file, in the {@link ZipDirectoryEntryExportOptions#readerOptions}
4552
4562
  * option of an export, and when reading one entry with `{@link ZipFileEntry}#get*()`. They apply to the
@@ -4559,8 +4569,9 @@ export interface PasswordCandidatesOptions {
4559
4569
  * passwords already accepted by another entry of the same imported zip file. An empty string is
4560
4570
  * ignored.
4561
4571
  *
4562
- * When every candidate fails, the entry raises an {@link ERR_INVALID_PASSWORD} error, unless the
4563
- * {@link PasswordCandidatesOptions#requestPassword} option is set.
4572
+ * When every candidate fails, the entry raises an {@link ERR_INVALID_PASSWORD} error whose `cause` is
4573
+ * the error raised by the last candidate, unless the {@link PasswordCandidatesOptions#requestPassword}
4574
+ * option is set.
4564
4575
  *
4565
4576
  * A value which is neither an array of strings nor unset throws an {@link ERR_INVALID_PASSWORDS}
4566
4577
  * error.
@@ -4573,8 +4584,9 @@ export interface PasswordCandidatesOptions {
4573
4584
  *
4574
4585
  * A string is tried on the entry, and the function is called again when it fails, with the
4575
4586
  * {@link ERR_INVALID_PASSWORD} error. `undefined` or `null` gives up: the entry raises an
4576
- * {@link ERR_INVALID_PASSWORD} error, or an {@link ERR_ENCRYPTED} error when no candidate was
4577
- * tried. A value of another type throws an {@link ERR_INVALID_REQUEST_PASSWORD} error. The
4587
+ * {@link ERR_INVALID_PASSWORD} error whose `cause` is the error raised by the last candidate, or an
4588
+ * {@link ERR_ENCRYPTED} error when no candidate was tried. A value of another type throws an
4589
+ * {@link ERR_INVALID_REQUEST_PASSWORD} error. The
4578
4590
  * function is not called for the entries whose password is already known.
4579
4591
  *
4580
4592
  * When several entries are read concurrently, e.g. by `{@link ZipDirectoryEntry}#export*()` with the
@@ -4977,6 +4989,16 @@ export const ERR_CENTRAL_DIRECTORY_NOT_FOUND: string;
4977
4989
  export const ERR_LOCAL_FILE_HEADER_NOT_FOUND: string;
4978
4990
  /**
4979
4991
  * Extra field Zip64 not found error
4992
+ *
4993
+ * @remarks
4994
+ * Raised by {@link ZipReader#getEntries} when the Zip64 extra field of a central directory record is missing or
4995
+ * too short to hold the values that the `0xFFFFFFFF` and `0xFFFF` sentinels of the record defer to it, since the
4996
+ * sizes and the offset of the entry have no other source. The same defect in a local file header is not fatal, because
4997
+ * the sizes of an entry are read from the central directory: {@link FileEntry#getData} reports it as
4998
+ * {@link WARNING_MALFORMED_EXTRA_FIELD} on {@link EntryMetaData#warnings}, and an entry without a data descriptor
4999
+ * keeps the sentinels as its local sizes, which the local file header check reports as
5000
+ * {@link WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES}, an error or a warning depending on
5001
+ * {@link ZipReaderOptions#strictness}.
4980
5002
  */
4981
5003
  export const ERR_EXTRAFIELD_ZIP64_NOT_FOUND: string;
4982
5004
  /**
@@ -5006,6 +5028,15 @@ export const ERR_INVALID_CODEC_MODULE: string;
5006
5028
  /**
5007
5029
  * Invalid CRC-32 checksum error, thrown when the {@link ZipReaderOptions#checkCrc32} option is set and the CRC-32
5008
5030
  * checksum of an entry does not match the value stored in the zip file.
5031
+ *
5032
+ * @remarks
5033
+ * When the inflater verifies the checksum itself, through a gzip trailer that zip.js builds from the stored
5034
+ * CRC-32 and uncompressed size, it rejects the trailer as a whole and its error is kept as the `cause`. A
5035
+ * stored uncompressed size larger than the data therefore raises this error too on that route, whereas a
5036
+ * stored size smaller than the data raises {@link ERR_INVALID_UNCOMPRESSED_SIZE} on every route. Bytes
5037
+ * trailing the DEFLATE stream, e.g. a wrong `compressedSize`, displace that trailer, and an inflater that
5038
+ * reports them only once the real trailer has been written, as the one of Node.js does, raises this error
5039
+ * in place of {@link ERR_INVALID_COMPRESSED_DATA}.
5009
5040
  */
5010
5041
  export const ERR_INVALID_CRC32: string;
5011
5042
  /**
@@ -5014,24 +5045,50 @@ export const ERR_INVALID_CRC32: string;
5014
5045
  */
5015
5046
  export const ERR_INVALID_AUTHENTICATION_CODE: string;
5016
5047
  /**
5017
- * Invalid uncompressed size error
5048
+ * Invalid uncompressed size error, thrown when an entry inflates to more bytes than its stored uncompressed size.
5049
+ *
5050
+ * @remarks
5051
+ * An entry encrypted with AES that stores no CRC-32 (AE-2) raises this error when it inflates to fewer bytes
5052
+ * as well, since the end of its data is told by the stored size alone, when it is inflated through a gzip
5053
+ * container: on a host whose native inflater lacks `"deflate-raw"`, when the bundled codec cannot take over
5054
+ * either, e.g. because its WASM module failed to load.
5018
5055
  */
5019
5056
  export const ERR_INVALID_UNCOMPRESSED_SIZE: string;
5020
5057
  /**
5021
- * Invalid compressed data error
5058
+ * Invalid compressed data error, thrown when the codec rejects the compressed data of an entry.
5022
5059
  *
5023
5060
  * @remarks
5024
- * The way malformed compressed data is reported is not uniform across codec
5025
- * backends. Bytes trailing a complete DEFLATE stream (e.g. a wrong
5026
- * `compressedSize`) are tolerated by the bundled WASM and pure-JS codecs, which
5027
- * decompress the valid data and ignore the extra bytes, but are rejected by the
5028
- * native `DecompressionStream` with its own `TypeError` (on Node,
5029
- * `ERR_TRAILING_JUNK_AFTER_STREAM_END`) rather than this error. Any data that is
5030
- * returned is always validated against the entry's uncompressed size (and CRC
5031
- * when `checkCrc32` is set), so it is never silently truncated; the backends
5032
- * differ only in whether trailing bytes are ignored or raised as an error.
5061
+ * The error is the same whatever inflates the data, and the error the codec raised is kept as its
5062
+ * `cause`: the `TypeError` of a native `DecompressionStream`, whose message depends on the engine,
5063
+ * or the error of the bundled WASM or pure-JS codec. An error raised while reading the data, e.g.
5064
+ * by the reader of the zip file or by the decryption of the entry, is not a codec failure and
5065
+ * reaches the caller unchanged.
5066
+ *
5067
+ * Bytes trailing a complete DEFLATE stream (e.g. a wrong `compressedSize`) are rejected by every
5068
+ * codec, the native `DecompressionStream` (on Node.js, with `ERR_TRAILING_JUNK_AFTER_STREAM_END`
5069
+ * as the `code` of the cause) and the bundled WASM and pure-JS codecs alike, except that with
5070
+ * {@link ZipReaderOptions#checkCrc32} set the native inflater of Node.js reports them as
5071
+ * {@link ERR_INVALID_CRC32}, see that error. Any data that is returned is always validated against
5072
+ * the entry's uncompressed size (and CRC when {@link ZipReaderOptions#checkCrc32} is set), so it is
5073
+ * never silently truncated.
5033
5074
  */
5034
5075
  export const ERR_INVALID_COMPRESSED_DATA: string;
5076
+ /**
5077
+ * Codec out of memory error, thrown when the codec of an entry cannot allocate the memory it needs, e.g. when
5078
+ * the fixed heap of the bundled WASM module is exhausted by too many entries processed concurrently in the same
5079
+ * scope.
5080
+ *
5081
+ * @remarks
5082
+ * The error the codec raised is kept as the `cause`. The failure is recognized by the `code` property of that
5083
+ * error, `"Z_MEM_ERROR"`, which the bundled WASM codec sets and the native `DecompressionStream` of Node.js
5084
+ * would set; a codec reporting the failure without it is reported as {@link ERR_INVALID_COMPRESSED_DATA} when
5085
+ * reading, or with its own error when writing. When writing, only a codec that fails to allocate its state is
5086
+ * reported with this error: a failure while compressing keeps the error of the codec. On a host whose native
5087
+ * codec lacks `"deflate-raw"`, a bundled codec that cannot allocate its state when the entry starts is not
5088
+ * reported either: the native codec takes over through a gzip container, unless `useCompressionStream` is
5089
+ * `false`.
5090
+ */
5091
+ export const ERR_CODEC_OUT_OF_MEMORY: string;
5035
5092
  /**
5036
5093
  * Invalid password error
5037
5094
  */
@@ -5216,7 +5273,9 @@ export const ERR_INVALID_MAX_APPENDED_DATA_SIZE: string;
5216
5273
  * Unsupported 64-bit value error
5217
5274
  *
5218
5275
  * @remarks Thrown when a 64-bit size, offset, or entry count read from a zip file exceeds `Number.MAX_SAFE_INTEGER`,
5219
- * instead of processing the value with a loss of precision.
5276
+ * instead of processing the value with a loss of precision. A local file header whose Zip64 extra field holds such a
5277
+ * value is not rejected, since the sizes of an entry are read from the central directory: the field is reported as
5278
+ * {@link WARNING_MALFORMED_EXTRA_FIELD} instead, see {@link ERR_EXTRAFIELD_ZIP64_NOT_FOUND}.
5220
5279
  */
5221
5280
  export const ERR_UNSUPPORTED_UINT64: string;
5222
5281
  /**
@@ -5470,8 +5529,11 @@ export const WARNING_UNKNOWN_VERSION: string;
5470
5529
  */
5471
5530
  export const WARNING_COMPRESSED_PATCHED_DATA: string;
5472
5531
  /**
5473
- * Warning reason: the extra field data of a record cannot be fully parsed; the raw bytes stay available in
5474
- * `rawExtraField` (see {@link ZipReader#warnings} and {@link EntryMetaData#warnings})
5532
+ * Warning reason: the extra field data of a record cannot be fully parsed, or one of its fields is ignored: an AES
5533
+ * extra field shorter than 7 bytes, or on a record that is not encrypted and whose compression method is not 99, and
5534
+ * the Zip64 extra field of a local file header that is missing behind the sentinels of the header, too short for
5535
+ * them, or holds a value above `Number.MAX_SAFE_INTEGER`.
5536
+ * The raw bytes stay available in `rawExtraField` (see {@link ZipReader#warnings} and {@link EntryMetaData#warnings})
5475
5537
  */
5476
5538
  export const WARNING_MALFORMED_EXTRA_FIELD: string;
5477
5539
  /**
@@ -5539,7 +5601,8 @@ export const WARNING_MISMATCHED_LOCAL_FILE_HEADER_FILENAME: string;
5539
5601
  /**
5540
5602
  * Warning reason: the general purpose bit flag of the local file header contradicts the central directory
5541
5603
  * (see {@link EntryMetaData#warnings}); the reason of {@link ERR_AMBIGUOUS_ARCHIVE} when
5542
- * {@link ZipReaderOptions#checkLocalDirectory} is enabled
5604
+ * {@link ZipReaderOptions#checkLocalDirectory} is enabled. The entry is read as the central directory declares,
5605
+ * its encrypted flag included.
5543
5606
  */
5544
5607
  export const WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG: string;
5545
5608
  /**