@zip.js/zip.js 2.8.42 → 2.8.44
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 +0 -37
- package/deno.json +1 -1
- package/dist/zip-core-external.js +178 -77
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +179 -76
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +178 -77
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +177 -76
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +178 -77
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +180 -77
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +180 -77
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +180 -77
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +180 -77
- 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 +180 -77
- package/dist/zip.min.js +1 -1
- package/index-native.cjs +180 -77
- package/index-native.min.js +1 -1
- package/index.cjs +180 -77
- package/index.d.cts +80 -7
- package/index.d.ts +80 -7
- package/index.min.js +1 -1
- package/lib/core/codec-pool.js +6 -2
- package/lib/core/codec-worker.js +23 -2
- package/lib/core/options.js +4 -0
- package/lib/core/streams/aes-crypto-stream.js +4 -4
- package/lib/core/streams/codec-stream.js +8 -2
- package/lib/core/streams/common-crypto.js +2 -0
- package/lib/core/streams/zip-entry-stream.js +102 -36
- 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-wasm.js +4 -8
- package/lib/core/zip-entry.js +3 -0
- package/lib/core/zip-reader.js +35 -26
- package/lib/core/zip-writer.js +22 -10
- package/lib/zip-core-reader.js +2 -0
- package/package.json +1 -1
- package/worker-message-property-names.js +1 -1
package/index.d.cts
CHANGED
|
@@ -1164,8 +1164,8 @@ export interface ZipReaderOptions {
|
|
|
1164
1164
|
* file header of the entry disagrees with its central directory record in a way that could make other tools
|
|
1165
1165
|
* (e.g. streaming readers based on local file headers) interpret the entry differently. This detects mismatched
|
|
1166
1166
|
* filenames, general purpose bit flags (encryption, data descriptor and language encoding flags), compression
|
|
1167
|
-
* methods,
|
|
1168
|
-
* to differ.
|
|
1167
|
+
* methods, CRC-32 checksums and sizes. The extra fields are not compared because the zip specification allows
|
|
1168
|
+
* them to differ.
|
|
1169
1169
|
*
|
|
1170
1170
|
* @defaultValue false
|
|
1171
1171
|
*/
|
|
@@ -1177,7 +1177,24 @@ export interface ZipReaderOptions {
|
|
|
1177
1177
|
*/
|
|
1178
1178
|
checkPasswordOnly?: boolean;
|
|
1179
1179
|
/**
|
|
1180
|
-
* `true` to
|
|
1180
|
+
* `true` to verify the CRC-32 checksum of the entry against the value stored in the zip file. The verification
|
|
1181
|
+
* is run on the decompressed data and covers the whole read pipeline. It also applies to entries encrypted with
|
|
1182
|
+
* AES in AE-1 format. It is skipped for entries in AE-2 format because they store a zeroed CRC-32 value.
|
|
1183
|
+
*
|
|
1184
|
+
* @defaultValue false
|
|
1185
|
+
*/
|
|
1186
|
+
checkCrc32?: boolean;
|
|
1187
|
+
/**
|
|
1188
|
+
* `true` to verify the authentication code of entries encrypted with AES. The verification detects encrypted
|
|
1189
|
+
* data tampered or corrupted after the encryption.
|
|
1190
|
+
*
|
|
1191
|
+
* @defaultValue true
|
|
1192
|
+
*/
|
|
1193
|
+
checkAuthenticationCode?: boolean;
|
|
1194
|
+
/**
|
|
1195
|
+
* `true` to check the CRC-32 checksum of the entry.
|
|
1196
|
+
*
|
|
1197
|
+
* @deprecated Use {@link ZipReaderOptions#checkCrc32} instead.
|
|
1181
1198
|
*
|
|
1182
1199
|
* @defaultValue false
|
|
1183
1200
|
*/
|
|
@@ -1261,6 +1278,15 @@ export interface EntryExtraFieldAES extends EntryExtraField {
|
|
|
1261
1278
|
* The encryption strength (1, 2 or 3).
|
|
1262
1279
|
*/
|
|
1263
1280
|
strength?: number;
|
|
1281
|
+
/**
|
|
1282
|
+
* The vendor version (1 for AE-1, 2 for AE-2). Entries in AE-1 format store the CRC-32 checksum of the content,
|
|
1283
|
+
* entries in AE-2 format store a zeroed value.
|
|
1284
|
+
*/
|
|
1285
|
+
vendorVersion?: number;
|
|
1286
|
+
/**
|
|
1287
|
+
* The vendor identifier.
|
|
1288
|
+
*/
|
|
1289
|
+
vendorId?: number;
|
|
1264
1290
|
/**
|
|
1265
1291
|
* The compression method stored in the AES extra field.
|
|
1266
1292
|
*/
|
|
@@ -1319,8 +1345,14 @@ export interface LocalDirectory {
|
|
|
1319
1345
|
* The extra field.
|
|
1320
1346
|
*/
|
|
1321
1347
|
extraField?: Map<number, EntryExtraField>;
|
|
1348
|
+
/**
|
|
1349
|
+
* The CRC-32 checksum of the content.
|
|
1350
|
+
*/
|
|
1351
|
+
crc32?: number;
|
|
1322
1352
|
/**
|
|
1323
1353
|
* The signature (CRC32 checksum) of the content.
|
|
1354
|
+
*
|
|
1355
|
+
* @deprecated Use {@link LocalDirectory#crc32} instead.
|
|
1324
1356
|
*/
|
|
1325
1357
|
signature?: number;
|
|
1326
1358
|
/**
|
|
@@ -1462,9 +1494,17 @@ export interface EntryMetaData {
|
|
|
1462
1494
|
*/
|
|
1463
1495
|
commentUTF8: boolean;
|
|
1464
1496
|
/**
|
|
1465
|
-
* The
|
|
1497
|
+
* The CRC-32 checksum of the content. It is `undefined` when the zip file does not store it, e.g. for entries
|
|
1498
|
+
* encrypted with AES in AE-2 format.
|
|
1466
1499
|
*/
|
|
1467
|
-
|
|
1500
|
+
crc32?: number;
|
|
1501
|
+
/**
|
|
1502
|
+
* The signature (CRC32 checksum) of the content. It is `undefined` for entries encrypted with AES returned by
|
|
1503
|
+
* {@link ZipWriter#add}.
|
|
1504
|
+
*
|
|
1505
|
+
* @deprecated Use {@link EntryMetaData#crc32} instead.
|
|
1506
|
+
*/
|
|
1507
|
+
signature?: number;
|
|
1468
1508
|
/**
|
|
1469
1509
|
* The extra field.
|
|
1470
1510
|
*/
|
|
@@ -1935,8 +1975,14 @@ export interface ZipWriterAddDataOptions
|
|
|
1935
1975
|
* The uncompressed size of the entry. This option is ignored if the {@link ZipWriterConstructorOptions#passThrough} option is not set to `true`.
|
|
1936
1976
|
*/
|
|
1937
1977
|
uncompressedSize?: number;
|
|
1978
|
+
/**
|
|
1979
|
+
* The CRC-32 checksum of the content. This option is ignored if the {@link ZipWriterConstructorOptions#passThrough} option is not set to `true`.
|
|
1980
|
+
*/
|
|
1981
|
+
crc32?: number;
|
|
1938
1982
|
/**
|
|
1939
1983
|
* The signature (CRC32 checksum) of the content. This option is ignored if the {@link ZipWriterConstructorOptions#passThrough} option is not set to `true`.
|
|
1984
|
+
*
|
|
1985
|
+
* @deprecated Use {@link ZipWriterAddDataOptions#crc32} instead.
|
|
1940
1986
|
*/
|
|
1941
1987
|
signature?: number;
|
|
1942
1988
|
}
|
|
@@ -2013,6 +2059,13 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
2013
2059
|
keepOrder?: boolean;
|
|
2014
2060
|
/**
|
|
2015
2061
|
* The password used to encrypt the content of the entry.
|
|
2062
|
+
*
|
|
2063
|
+
* @remarks
|
|
2064
|
+
* When a password is set and the {@link ZipWriterConstructorOptions#zipCrypto} option is not set to `true`, the
|
|
2065
|
+
* entry is encrypted in AES AE-2 format: the CRC-32 checksum of the content is stored as `0` so that the zip
|
|
2066
|
+
* file reveals no information about the encrypted content. A stored checksum would allow an attacker to verify
|
|
2067
|
+
* guessed content without knowing the password. The integrity of the data is guaranteed by the authentication
|
|
2068
|
+
* code instead.
|
|
2016
2069
|
*/
|
|
2017
2070
|
password?: string;
|
|
2018
2071
|
/**
|
|
@@ -2057,7 +2110,7 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
2057
2110
|
/**
|
|
2058
2111
|
* `true` to store extended timestamp extra fields.
|
|
2059
2112
|
*
|
|
2060
|
-
* When set to `false`, the maximum last modification date cannot exceed December 31, 2107 and the maximum accuracy is 2 seconds.
|
|
2113
|
+
* When set to `false`, the maximum last modification date cannot exceed December 31, 2107 and the maximum accuracy is 2 seconds, dates being truncated to the whole second and odd seconds rounded up to the next even second.
|
|
2061
2114
|
*
|
|
2062
2115
|
* @defaultValue true
|
|
2063
2116
|
*/
|
|
@@ -2935,8 +2988,28 @@ export const ERR_RESERVED_COMPRESSION_METHOD: string;
|
|
|
2935
2988
|
* Invalid codec module error
|
|
2936
2989
|
*/
|
|
2937
2990
|
export const ERR_INVALID_CODEC_MODULE: string;
|
|
2991
|
+
/**
|
|
2992
|
+
* Invalid CRC-32 checksum error, thrown when the {@link ZipReaderOptions#checkCrc32} option is set and the CRC-32
|
|
2993
|
+
* checksum of an entry does not match the value stored in the zip file.
|
|
2994
|
+
*
|
|
2995
|
+
* @remarks
|
|
2996
|
+
* This constant and {@link ERR_INVALID_AUTHENTICATION_CODE} share the same value as {@link ERR_INVALID_SIGNATURE}
|
|
2997
|
+
* for backward compatibility. They will become distinct strings in the next minor version.
|
|
2998
|
+
*/
|
|
2999
|
+
export const ERR_INVALID_CRC32: string;
|
|
3000
|
+
/**
|
|
3001
|
+
* Invalid authentication code error, thrown when the authentication code of an entry encrypted with AES does not
|
|
3002
|
+
* match the encrypted data, e.g. when the data was tampered or corrupted after the encryption.
|
|
3003
|
+
*
|
|
3004
|
+
* @remarks
|
|
3005
|
+
* This constant and {@link ERR_INVALID_CRC32} share the same value as {@link ERR_INVALID_SIGNATURE} for backward
|
|
3006
|
+
* compatibility. They will become distinct strings in the next minor version.
|
|
3007
|
+
*/
|
|
3008
|
+
export const ERR_INVALID_AUTHENTICATION_CODE: string;
|
|
2938
3009
|
/**
|
|
2939
3010
|
* Invalid signature error
|
|
3011
|
+
*
|
|
3012
|
+
* @deprecated Use {@link ERR_INVALID_CRC32} or {@link ERR_INVALID_AUTHENTICATION_CODE} instead.
|
|
2940
3013
|
*/
|
|
2941
3014
|
export const ERR_INVALID_SIGNATURE: string;
|
|
2942
3015
|
/**
|
|
@@ -2954,7 +3027,7 @@ export const ERR_INVALID_UNCOMPRESSED_SIZE: string;
|
|
|
2954
3027
|
* native `DecompressionStream` with its own `TypeError` (on Node,
|
|
2955
3028
|
* `ERR_TRAILING_JUNK_AFTER_STREAM_END`) rather than this error. Any data that is
|
|
2956
3029
|
* returned is always validated against the entry's uncompressed size (and CRC
|
|
2957
|
-
* when `
|
|
3030
|
+
* when `checkCrc32` is set), so it is never silently truncated; the backends
|
|
2958
3031
|
* differ only in whether trailing bytes are ignored or raised as an error.
|
|
2959
3032
|
*/
|
|
2960
3033
|
export const ERR_INVALID_COMPRESSED_DATA: string;
|
package/index.d.ts
CHANGED
|
@@ -1164,8 +1164,8 @@ export interface ZipReaderOptions {
|
|
|
1164
1164
|
* file header of the entry disagrees with its central directory record in a way that could make other tools
|
|
1165
1165
|
* (e.g. streaming readers based on local file headers) interpret the entry differently. This detects mismatched
|
|
1166
1166
|
* filenames, general purpose bit flags (encryption, data descriptor and language encoding flags), compression
|
|
1167
|
-
* methods,
|
|
1168
|
-
* to differ.
|
|
1167
|
+
* methods, CRC-32 checksums and sizes. The extra fields are not compared because the zip specification allows
|
|
1168
|
+
* them to differ.
|
|
1169
1169
|
*
|
|
1170
1170
|
* @defaultValue false
|
|
1171
1171
|
*/
|
|
@@ -1177,7 +1177,24 @@ export interface ZipReaderOptions {
|
|
|
1177
1177
|
*/
|
|
1178
1178
|
checkPasswordOnly?: boolean;
|
|
1179
1179
|
/**
|
|
1180
|
-
* `true` to
|
|
1180
|
+
* `true` to verify the CRC-32 checksum of the entry against the value stored in the zip file. The verification
|
|
1181
|
+
* is run on the decompressed data and covers the whole read pipeline. It also applies to entries encrypted with
|
|
1182
|
+
* AES in AE-1 format. It is skipped for entries in AE-2 format because they store a zeroed CRC-32 value.
|
|
1183
|
+
*
|
|
1184
|
+
* @defaultValue false
|
|
1185
|
+
*/
|
|
1186
|
+
checkCrc32?: boolean;
|
|
1187
|
+
/**
|
|
1188
|
+
* `true` to verify the authentication code of entries encrypted with AES. The verification detects encrypted
|
|
1189
|
+
* data tampered or corrupted after the encryption.
|
|
1190
|
+
*
|
|
1191
|
+
* @defaultValue true
|
|
1192
|
+
*/
|
|
1193
|
+
checkAuthenticationCode?: boolean;
|
|
1194
|
+
/**
|
|
1195
|
+
* `true` to check the CRC-32 checksum of the entry.
|
|
1196
|
+
*
|
|
1197
|
+
* @deprecated Use {@link ZipReaderOptions#checkCrc32} instead.
|
|
1181
1198
|
*
|
|
1182
1199
|
* @defaultValue false
|
|
1183
1200
|
*/
|
|
@@ -1261,6 +1278,15 @@ export interface EntryExtraFieldAES extends EntryExtraField {
|
|
|
1261
1278
|
* The encryption strength (1, 2 or 3).
|
|
1262
1279
|
*/
|
|
1263
1280
|
strength?: number;
|
|
1281
|
+
/**
|
|
1282
|
+
* The vendor version (1 for AE-1, 2 for AE-2). Entries in AE-1 format store the CRC-32 checksum of the content,
|
|
1283
|
+
* entries in AE-2 format store a zeroed value.
|
|
1284
|
+
*/
|
|
1285
|
+
vendorVersion?: number;
|
|
1286
|
+
/**
|
|
1287
|
+
* The vendor identifier.
|
|
1288
|
+
*/
|
|
1289
|
+
vendorId?: number;
|
|
1264
1290
|
/**
|
|
1265
1291
|
* The compression method stored in the AES extra field.
|
|
1266
1292
|
*/
|
|
@@ -1319,8 +1345,14 @@ export interface LocalDirectory {
|
|
|
1319
1345
|
* The extra field.
|
|
1320
1346
|
*/
|
|
1321
1347
|
extraField?: Map<number, EntryExtraField>;
|
|
1348
|
+
/**
|
|
1349
|
+
* The CRC-32 checksum of the content.
|
|
1350
|
+
*/
|
|
1351
|
+
crc32?: number;
|
|
1322
1352
|
/**
|
|
1323
1353
|
* The signature (CRC32 checksum) of the content.
|
|
1354
|
+
*
|
|
1355
|
+
* @deprecated Use {@link LocalDirectory#crc32} instead.
|
|
1324
1356
|
*/
|
|
1325
1357
|
signature?: number;
|
|
1326
1358
|
/**
|
|
@@ -1462,9 +1494,17 @@ export interface EntryMetaData {
|
|
|
1462
1494
|
*/
|
|
1463
1495
|
commentUTF8: boolean;
|
|
1464
1496
|
/**
|
|
1465
|
-
* The
|
|
1497
|
+
* The CRC-32 checksum of the content. It is `undefined` when the zip file does not store it, e.g. for entries
|
|
1498
|
+
* encrypted with AES in AE-2 format.
|
|
1466
1499
|
*/
|
|
1467
|
-
|
|
1500
|
+
crc32?: number;
|
|
1501
|
+
/**
|
|
1502
|
+
* The signature (CRC32 checksum) of the content. It is `undefined` for entries encrypted with AES returned by
|
|
1503
|
+
* {@link ZipWriter#add}.
|
|
1504
|
+
*
|
|
1505
|
+
* @deprecated Use {@link EntryMetaData#crc32} instead.
|
|
1506
|
+
*/
|
|
1507
|
+
signature?: number;
|
|
1468
1508
|
/**
|
|
1469
1509
|
* The extra field.
|
|
1470
1510
|
*/
|
|
@@ -1935,8 +1975,14 @@ export interface ZipWriterAddDataOptions
|
|
|
1935
1975
|
* The uncompressed size of the entry. This option is ignored if the {@link ZipWriterConstructorOptions#passThrough} option is not set to `true`.
|
|
1936
1976
|
*/
|
|
1937
1977
|
uncompressedSize?: number;
|
|
1978
|
+
/**
|
|
1979
|
+
* The CRC-32 checksum of the content. This option is ignored if the {@link ZipWriterConstructorOptions#passThrough} option is not set to `true`.
|
|
1980
|
+
*/
|
|
1981
|
+
crc32?: number;
|
|
1938
1982
|
/**
|
|
1939
1983
|
* The signature (CRC32 checksum) of the content. This option is ignored if the {@link ZipWriterConstructorOptions#passThrough} option is not set to `true`.
|
|
1984
|
+
*
|
|
1985
|
+
* @deprecated Use {@link ZipWriterAddDataOptions#crc32} instead.
|
|
1940
1986
|
*/
|
|
1941
1987
|
signature?: number;
|
|
1942
1988
|
}
|
|
@@ -2013,6 +2059,13 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
2013
2059
|
keepOrder?: boolean;
|
|
2014
2060
|
/**
|
|
2015
2061
|
* The password used to encrypt the content of the entry.
|
|
2062
|
+
*
|
|
2063
|
+
* @remarks
|
|
2064
|
+
* When a password is set and the {@link ZipWriterConstructorOptions#zipCrypto} option is not set to `true`, the
|
|
2065
|
+
* entry is encrypted in AES AE-2 format: the CRC-32 checksum of the content is stored as `0` so that the zip
|
|
2066
|
+
* file reveals no information about the encrypted content. A stored checksum would allow an attacker to verify
|
|
2067
|
+
* guessed content without knowing the password. The integrity of the data is guaranteed by the authentication
|
|
2068
|
+
* code instead.
|
|
2016
2069
|
*/
|
|
2017
2070
|
password?: string;
|
|
2018
2071
|
/**
|
|
@@ -2057,7 +2110,7 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
2057
2110
|
/**
|
|
2058
2111
|
* `true` to store extended timestamp extra fields.
|
|
2059
2112
|
*
|
|
2060
|
-
* When set to `false`, the maximum last modification date cannot exceed December 31, 2107 and the maximum accuracy is 2 seconds.
|
|
2113
|
+
* When set to `false`, the maximum last modification date cannot exceed December 31, 2107 and the maximum accuracy is 2 seconds, dates being truncated to the whole second and odd seconds rounded up to the next even second.
|
|
2061
2114
|
*
|
|
2062
2115
|
* @defaultValue true
|
|
2063
2116
|
*/
|
|
@@ -2935,8 +2988,28 @@ export const ERR_RESERVED_COMPRESSION_METHOD: string;
|
|
|
2935
2988
|
* Invalid codec module error
|
|
2936
2989
|
*/
|
|
2937
2990
|
export const ERR_INVALID_CODEC_MODULE: string;
|
|
2991
|
+
/**
|
|
2992
|
+
* Invalid CRC-32 checksum error, thrown when the {@link ZipReaderOptions#checkCrc32} option is set and the CRC-32
|
|
2993
|
+
* checksum of an entry does not match the value stored in the zip file.
|
|
2994
|
+
*
|
|
2995
|
+
* @remarks
|
|
2996
|
+
* This constant and {@link ERR_INVALID_AUTHENTICATION_CODE} share the same value as {@link ERR_INVALID_SIGNATURE}
|
|
2997
|
+
* for backward compatibility. They will become distinct strings in the next minor version.
|
|
2998
|
+
*/
|
|
2999
|
+
export const ERR_INVALID_CRC32: string;
|
|
3000
|
+
/**
|
|
3001
|
+
* Invalid authentication code error, thrown when the authentication code of an entry encrypted with AES does not
|
|
3002
|
+
* match the encrypted data, e.g. when the data was tampered or corrupted after the encryption.
|
|
3003
|
+
*
|
|
3004
|
+
* @remarks
|
|
3005
|
+
* This constant and {@link ERR_INVALID_CRC32} share the same value as {@link ERR_INVALID_SIGNATURE} for backward
|
|
3006
|
+
* compatibility. They will become distinct strings in the next minor version.
|
|
3007
|
+
*/
|
|
3008
|
+
export const ERR_INVALID_AUTHENTICATION_CODE: string;
|
|
2938
3009
|
/**
|
|
2939
3010
|
* Invalid signature error
|
|
3011
|
+
*
|
|
3012
|
+
* @deprecated Use {@link ERR_INVALID_CRC32} or {@link ERR_INVALID_AUTHENTICATION_CODE} instead.
|
|
2940
3013
|
*/
|
|
2941
3014
|
export const ERR_INVALID_SIGNATURE: string;
|
|
2942
3015
|
/**
|
|
@@ -2954,7 +3027,7 @@ export const ERR_INVALID_UNCOMPRESSED_SIZE: string;
|
|
|
2954
3027
|
* native `DecompressionStream` with its own `TypeError` (on Node,
|
|
2955
3028
|
* `ERR_TRAILING_JUNK_AFTER_STREAM_END`) rather than this error. Any data that is
|
|
2956
3029
|
* returned is always validated against the entry's uncompressed size (and CRC
|
|
2957
|
-
* when `
|
|
3030
|
+
* when `checkCrc32` is set), so it is never silently truncated; the backends
|
|
2958
3031
|
* differ only in whether trailing bytes are ignored or raised as an error.
|
|
2959
3032
|
*/
|
|
2960
3033
|
export const ERR_INVALID_COMPRESSED_DATA: string;
|