@zip.js/zip.js 2.8.46 → 2.8.48
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 +130 -35
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +140 -34
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +131 -36
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +115 -32
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +131 -36
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +145 -37
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +144 -36
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +142 -36
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +142 -36
- 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 +141 -35
- package/dist/zip.min.js +1 -1
- package/index-native.cjs +145 -37
- package/index-native.min.js +1 -1
- package/index.cjs +144 -36
- package/index.d.cts +141 -0
- package/index.d.ts +141 -0
- package/index.min.js +1 -1
- package/lib/core/codec-pool.js +6 -3
- package/lib/core/codec-worker.js +2 -1
- package/lib/core/constants.js +2 -0
- package/lib/core/io.js +3 -23
- package/lib/core/options.js +4 -0
- package/lib/core/streams/codec-stream.js +2 -0
- package/lib/core/streams/common-crypto.js +2 -1
- package/lib/core/streams/zip-entry-stream.js +4 -2
- package/lib/core/util/blob-temp-stream.js +4 -2
- package/lib/core/util/compatible-streams.js +30 -2
- package/lib/core/util/opfs-temp-stream.js +8 -1
- package/lib/core/util/sync-access-handle-temp-stream.js +10 -2
- package/lib/core/web-worker-inline-native.js +1 -1
- package/lib/core/web-worker-inline-wasm.js +1 -1
- package/lib/core/zip-fs.js +3 -2
- package/lib/core/zip-reader.js +62 -9
- package/lib/core/zip-writer.js +43 -8
- package/lib/zip-core-base.js +2 -1
- package/lib/zip-core-reader.js +2 -1
- package/lib/zip-core-writer.js +10 -1
- package/package.json +2 -1
package/index.d.cts
CHANGED
|
@@ -1119,6 +1119,21 @@ export class ZipReader<Type> {
|
|
|
1119
1119
|
* The data appended after the zip file.
|
|
1120
1120
|
*/
|
|
1121
1121
|
appendedData?: Uint8Array;
|
|
1122
|
+
/**
|
|
1123
|
+
* The data of the digital signature record of the central directory (see
|
|
1124
|
+
* {@link ZipWriterCloseOptions#signCentralDirectory}), if the zip file contains one. zip.js does not verify
|
|
1125
|
+
* signatures; use {@link ZipReader#directoryOffset} and {@link ZipReader#directoryLength} to read the signed
|
|
1126
|
+
* central directory data and verify it.
|
|
1127
|
+
*/
|
|
1128
|
+
digitalSignature?: Uint8Array;
|
|
1129
|
+
/**
|
|
1130
|
+
* The offset of the central directory in the zip file.
|
|
1131
|
+
*/
|
|
1132
|
+
directoryOffset?: number;
|
|
1133
|
+
/**
|
|
1134
|
+
* The length in bytes of the central directory as declared in the end of central directory record.
|
|
1135
|
+
*/
|
|
1136
|
+
directoryLength?: number;
|
|
1122
1137
|
/**
|
|
1123
1138
|
* Returns all the entries in the zip file
|
|
1124
1139
|
*
|
|
@@ -1234,6 +1249,66 @@ export interface GetEntriesOptions {
|
|
|
1234
1249
|
* {@link ERR_AMBIGUOUS_ARCHIVE} error otherwise.
|
|
1235
1250
|
*/
|
|
1236
1251
|
maxAppendedDataSize?: number;
|
|
1252
|
+
/**
|
|
1253
|
+
* The function called for decrypting the central directory when it is encrypted (see the Strong Encryption
|
|
1254
|
+
* Specification in the ZIP format specification). Without this function, reading such an archive throws an
|
|
1255
|
+
* {@link ERR_ENCRYPTED_CENTRAL_DIRECTORY} error. zip.js provides the encrypted data and the related metadata
|
|
1256
|
+
* but does not implement the decryption itself.
|
|
1257
|
+
*
|
|
1258
|
+
* @param data The raw data stored in place of the central directory, i.e. the decryption header followed by
|
|
1259
|
+
* the encrypted (and possibly compressed) central directory, as stored in the zip file.
|
|
1260
|
+
* @param encryptionInfo The encryption metadata read from the Zip64 end of central directory record, or
|
|
1261
|
+
* `undefined` if the zip file does not contain a version 2 record.
|
|
1262
|
+
* @returns The decrypted and decompressed central directory records.
|
|
1263
|
+
*/
|
|
1264
|
+
decryptCentralDirectory?(
|
|
1265
|
+
data: Uint8Array,
|
|
1266
|
+
encryptionInfo?: DirectoryEncryptionInfo
|
|
1267
|
+
): Uint8Array | PromiseLike<Uint8Array>;
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
/**
|
|
1271
|
+
* Represents the encryption metadata of an encrypted central directory (see
|
|
1272
|
+
* {@link GetEntriesOptions#decryptCentralDirectory}), read from the version 2 Zip64 end of central directory
|
|
1273
|
+
* record.
|
|
1274
|
+
*/
|
|
1275
|
+
export interface DirectoryEncryptionInfo {
|
|
1276
|
+
/**
|
|
1277
|
+
* The raw data of the extensible data sector of the record.
|
|
1278
|
+
*/
|
|
1279
|
+
rawExtensibleData: Uint8Array;
|
|
1280
|
+
/**
|
|
1281
|
+
* The compression method applied to the central directory before encryption.
|
|
1282
|
+
*/
|
|
1283
|
+
compressionMethod?: number;
|
|
1284
|
+
/**
|
|
1285
|
+
* The size of the compressed and encrypted central directory.
|
|
1286
|
+
*/
|
|
1287
|
+
compressedSize?: number;
|
|
1288
|
+
/**
|
|
1289
|
+
* The size of the central directory once decrypted and decompressed.
|
|
1290
|
+
*/
|
|
1291
|
+
uncompressedSize?: number;
|
|
1292
|
+
/**
|
|
1293
|
+
* The identifier of the encryption algorithm (e.g. `0x6610` for AES-256).
|
|
1294
|
+
*/
|
|
1295
|
+
encryptionAlgorithm?: number;
|
|
1296
|
+
/**
|
|
1297
|
+
* The key size in bits.
|
|
1298
|
+
*/
|
|
1299
|
+
bitLength?: number;
|
|
1300
|
+
/**
|
|
1301
|
+
* The processing flags (e.g. `0x0001` for password-based encryption).
|
|
1302
|
+
*/
|
|
1303
|
+
flags?: number;
|
|
1304
|
+
/**
|
|
1305
|
+
* The identifier of the hash algorithm used for the password validation data.
|
|
1306
|
+
*/
|
|
1307
|
+
hashAlgorithm?: number;
|
|
1308
|
+
/**
|
|
1309
|
+
* The password validation data.
|
|
1310
|
+
*/
|
|
1311
|
+
hashData?: Uint8Array;
|
|
1237
1312
|
}
|
|
1238
1313
|
|
|
1239
1314
|
/**
|
|
@@ -2141,6 +2216,19 @@ export interface ZipWriterCloseOptions extends EntryOnprogressOptions {
|
|
|
2141
2216
|
* @defaultValue false
|
|
2142
2217
|
*/
|
|
2143
2218
|
preventClose?: boolean;
|
|
2219
|
+
/**
|
|
2220
|
+
* The function called for signing the central directory. The returned data (e.g. a PKCS#7 signature computed
|
|
2221
|
+
* over the central directory records) is stored in a digital signature record written between the central
|
|
2222
|
+
* directory and the end of central directory record, and exposed by {@link ZipReader#digitalSignature} when
|
|
2223
|
+
* reading the zip file. It must not exceed 64KB, otherwise an {@link ERR_INVALID_SIGNATURE_DATA} error is
|
|
2224
|
+
* thrown. zip.js stores the data as-is and does not implement the signature computation itself.
|
|
2225
|
+
*
|
|
2226
|
+
* @param directory The raw data of the central directory records.
|
|
2227
|
+
* @returns The data of the digital signature record.
|
|
2228
|
+
*/
|
|
2229
|
+
signCentralDirectory?(
|
|
2230
|
+
directory: Uint8Array
|
|
2231
|
+
): Uint8Array | PromiseLike<Uint8Array>;
|
|
2144
2232
|
}
|
|
2145
2233
|
|
|
2146
2234
|
/**
|
|
@@ -3254,3 +3342,56 @@ export const ERR_WRITER_NOT_INITIALIZED: string;
|
|
|
3254
3342
|
* Zip file not empty error
|
|
3255
3343
|
*/
|
|
3256
3344
|
export const ERR_ZIP_NOT_EMPTY: string;
|
|
3345
|
+
/**
|
|
3346
|
+
* Signature data exceeding 64KB error (see {@link ZipWriterCloseOptions#signCentralDirectory})
|
|
3347
|
+
*/
|
|
3348
|
+
export const ERR_INVALID_SIGNATURE_DATA: string;
|
|
3349
|
+
/**
|
|
3350
|
+
* Invalid uid error (thrown when the `uid` option is not an integer in the range 0..2^32-1)
|
|
3351
|
+
*/
|
|
3352
|
+
export const ERR_INVALID_UID: string;
|
|
3353
|
+
/**
|
|
3354
|
+
* Invalid gid error (thrown when the `gid` option is not an integer in the range 0..2^32-1)
|
|
3355
|
+
*/
|
|
3356
|
+
export const ERR_INVALID_GID: string;
|
|
3357
|
+
/**
|
|
3358
|
+
* Invalid UNIX mode error (thrown when the `unixMode` option is not an integer in the range 0..65535)
|
|
3359
|
+
*/
|
|
3360
|
+
export const ERR_INVALID_UNIX_MODE: string;
|
|
3361
|
+
/**
|
|
3362
|
+
* Invalid unixExtraFieldType error (thrown when the `unixExtraFieldType` option is not `"infozip"` or `"unix"`)
|
|
3363
|
+
*/
|
|
3364
|
+
export const ERR_INVALID_UNIX_EXTRA_FIELD_TYPE: string;
|
|
3365
|
+
/**
|
|
3366
|
+
* Invalid UNIX uid/gid size error (thrown when `uid`/`gid` exceeds 65535 with `unixExtraFieldType` set to `"unix"`; use `"infozip"` for larger ids)
|
|
3367
|
+
*/
|
|
3368
|
+
export const ERR_INVALID_UNIX_ID_SIZE: string;
|
|
3369
|
+
/**
|
|
3370
|
+
* Invalid msdosAttributesRaw error (thrown when the `msdosAttributesRaw` option is not an integer in the range 0..255)
|
|
3371
|
+
*/
|
|
3372
|
+
export const ERR_INVALID_MSDOS_ATTRIBUTES: string;
|
|
3373
|
+
/**
|
|
3374
|
+
* Invalid msdosAttributes error (thrown when the `msdosAttributes` option is not an object with boolean flags)
|
|
3375
|
+
*/
|
|
3376
|
+
export const ERR_INVALID_MSDOS_DATA: string;
|
|
3377
|
+
/**
|
|
3378
|
+
* Entry already exists error (thrown by the filesystem API when adding an entry whose filename already exists)
|
|
3379
|
+
*/
|
|
3380
|
+
export const ERR_ENTRY_EXISTS: string;
|
|
3381
|
+
/**
|
|
3382
|
+
* Readable stream already consumed error (thrown by the filesystem API when a readable stream is read more than once)
|
|
3383
|
+
*/
|
|
3384
|
+
export const ERR_READABLE_CONSUMED: string;
|
|
3385
|
+
/**
|
|
3386
|
+
* Unsupported context error (thrown when {@link createSyncAccessHandleTempStream} is used outside a dedicated worker)
|
|
3387
|
+
*/
|
|
3388
|
+
export const ERR_UNSUPPORTED_CONTEXT: string;
|
|
3389
|
+
/**
|
|
3390
|
+
* Unsupported Crypto API error (thrown when writing encrypted entries while `crypto.getRandomValues` is unavailable)
|
|
3391
|
+
*/
|
|
3392
|
+
export const ERR_UNSUPPORTED_CRYPTO_API: string;
|
|
3393
|
+
/**
|
|
3394
|
+
* Web worker startup timeout error (thrown when a web worker does not start in time, e.g. in browser extensions
|
|
3395
|
+
* disallowing workers; set `useWebWorkers` to `false` in {@link configure} to work around it)
|
|
3396
|
+
*/
|
|
3397
|
+
export const ERR_WORKER_STARTUP_TIMEOUT: string;
|
package/index.d.ts
CHANGED
|
@@ -1119,6 +1119,21 @@ export class ZipReader<Type> {
|
|
|
1119
1119
|
* The data appended after the zip file.
|
|
1120
1120
|
*/
|
|
1121
1121
|
appendedData?: Uint8Array;
|
|
1122
|
+
/**
|
|
1123
|
+
* The data of the digital signature record of the central directory (see
|
|
1124
|
+
* {@link ZipWriterCloseOptions#signCentralDirectory}), if the zip file contains one. zip.js does not verify
|
|
1125
|
+
* signatures; use {@link ZipReader#directoryOffset} and {@link ZipReader#directoryLength} to read the signed
|
|
1126
|
+
* central directory data and verify it.
|
|
1127
|
+
*/
|
|
1128
|
+
digitalSignature?: Uint8Array;
|
|
1129
|
+
/**
|
|
1130
|
+
* The offset of the central directory in the zip file.
|
|
1131
|
+
*/
|
|
1132
|
+
directoryOffset?: number;
|
|
1133
|
+
/**
|
|
1134
|
+
* The length in bytes of the central directory as declared in the end of central directory record.
|
|
1135
|
+
*/
|
|
1136
|
+
directoryLength?: number;
|
|
1122
1137
|
/**
|
|
1123
1138
|
* Returns all the entries in the zip file
|
|
1124
1139
|
*
|
|
@@ -1234,6 +1249,66 @@ export interface GetEntriesOptions {
|
|
|
1234
1249
|
* {@link ERR_AMBIGUOUS_ARCHIVE} error otherwise.
|
|
1235
1250
|
*/
|
|
1236
1251
|
maxAppendedDataSize?: number;
|
|
1252
|
+
/**
|
|
1253
|
+
* The function called for decrypting the central directory when it is encrypted (see the Strong Encryption
|
|
1254
|
+
* Specification in the ZIP format specification). Without this function, reading such an archive throws an
|
|
1255
|
+
* {@link ERR_ENCRYPTED_CENTRAL_DIRECTORY} error. zip.js provides the encrypted data and the related metadata
|
|
1256
|
+
* but does not implement the decryption itself.
|
|
1257
|
+
*
|
|
1258
|
+
* @param data The raw data stored in place of the central directory, i.e. the decryption header followed by
|
|
1259
|
+
* the encrypted (and possibly compressed) central directory, as stored in the zip file.
|
|
1260
|
+
* @param encryptionInfo The encryption metadata read from the Zip64 end of central directory record, or
|
|
1261
|
+
* `undefined` if the zip file does not contain a version 2 record.
|
|
1262
|
+
* @returns The decrypted and decompressed central directory records.
|
|
1263
|
+
*/
|
|
1264
|
+
decryptCentralDirectory?(
|
|
1265
|
+
data: Uint8Array,
|
|
1266
|
+
encryptionInfo?: DirectoryEncryptionInfo
|
|
1267
|
+
): Uint8Array | PromiseLike<Uint8Array>;
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
/**
|
|
1271
|
+
* Represents the encryption metadata of an encrypted central directory (see
|
|
1272
|
+
* {@link GetEntriesOptions#decryptCentralDirectory}), read from the version 2 Zip64 end of central directory
|
|
1273
|
+
* record.
|
|
1274
|
+
*/
|
|
1275
|
+
export interface DirectoryEncryptionInfo {
|
|
1276
|
+
/**
|
|
1277
|
+
* The raw data of the extensible data sector of the record.
|
|
1278
|
+
*/
|
|
1279
|
+
rawExtensibleData: Uint8Array;
|
|
1280
|
+
/**
|
|
1281
|
+
* The compression method applied to the central directory before encryption.
|
|
1282
|
+
*/
|
|
1283
|
+
compressionMethod?: number;
|
|
1284
|
+
/**
|
|
1285
|
+
* The size of the compressed and encrypted central directory.
|
|
1286
|
+
*/
|
|
1287
|
+
compressedSize?: number;
|
|
1288
|
+
/**
|
|
1289
|
+
* The size of the central directory once decrypted and decompressed.
|
|
1290
|
+
*/
|
|
1291
|
+
uncompressedSize?: number;
|
|
1292
|
+
/**
|
|
1293
|
+
* The identifier of the encryption algorithm (e.g. `0x6610` for AES-256).
|
|
1294
|
+
*/
|
|
1295
|
+
encryptionAlgorithm?: number;
|
|
1296
|
+
/**
|
|
1297
|
+
* The key size in bits.
|
|
1298
|
+
*/
|
|
1299
|
+
bitLength?: number;
|
|
1300
|
+
/**
|
|
1301
|
+
* The processing flags (e.g. `0x0001` for password-based encryption).
|
|
1302
|
+
*/
|
|
1303
|
+
flags?: number;
|
|
1304
|
+
/**
|
|
1305
|
+
* The identifier of the hash algorithm used for the password validation data.
|
|
1306
|
+
*/
|
|
1307
|
+
hashAlgorithm?: number;
|
|
1308
|
+
/**
|
|
1309
|
+
* The password validation data.
|
|
1310
|
+
*/
|
|
1311
|
+
hashData?: Uint8Array;
|
|
1237
1312
|
}
|
|
1238
1313
|
|
|
1239
1314
|
/**
|
|
@@ -2141,6 +2216,19 @@ export interface ZipWriterCloseOptions extends EntryOnprogressOptions {
|
|
|
2141
2216
|
* @defaultValue false
|
|
2142
2217
|
*/
|
|
2143
2218
|
preventClose?: boolean;
|
|
2219
|
+
/**
|
|
2220
|
+
* The function called for signing the central directory. The returned data (e.g. a PKCS#7 signature computed
|
|
2221
|
+
* over the central directory records) is stored in a digital signature record written between the central
|
|
2222
|
+
* directory and the end of central directory record, and exposed by {@link ZipReader#digitalSignature} when
|
|
2223
|
+
* reading the zip file. It must not exceed 64KB, otherwise an {@link ERR_INVALID_SIGNATURE_DATA} error is
|
|
2224
|
+
* thrown. zip.js stores the data as-is and does not implement the signature computation itself.
|
|
2225
|
+
*
|
|
2226
|
+
* @param directory The raw data of the central directory records.
|
|
2227
|
+
* @returns The data of the digital signature record.
|
|
2228
|
+
*/
|
|
2229
|
+
signCentralDirectory?(
|
|
2230
|
+
directory: Uint8Array
|
|
2231
|
+
): Uint8Array | PromiseLike<Uint8Array>;
|
|
2144
2232
|
}
|
|
2145
2233
|
|
|
2146
2234
|
/**
|
|
@@ -3254,3 +3342,56 @@ export const ERR_WRITER_NOT_INITIALIZED: string;
|
|
|
3254
3342
|
* Zip file not empty error
|
|
3255
3343
|
*/
|
|
3256
3344
|
export const ERR_ZIP_NOT_EMPTY: string;
|
|
3345
|
+
/**
|
|
3346
|
+
* Signature data exceeding 64KB error (see {@link ZipWriterCloseOptions#signCentralDirectory})
|
|
3347
|
+
*/
|
|
3348
|
+
export const ERR_INVALID_SIGNATURE_DATA: string;
|
|
3349
|
+
/**
|
|
3350
|
+
* Invalid uid error (thrown when the `uid` option is not an integer in the range 0..2^32-1)
|
|
3351
|
+
*/
|
|
3352
|
+
export const ERR_INVALID_UID: string;
|
|
3353
|
+
/**
|
|
3354
|
+
* Invalid gid error (thrown when the `gid` option is not an integer in the range 0..2^32-1)
|
|
3355
|
+
*/
|
|
3356
|
+
export const ERR_INVALID_GID: string;
|
|
3357
|
+
/**
|
|
3358
|
+
* Invalid UNIX mode error (thrown when the `unixMode` option is not an integer in the range 0..65535)
|
|
3359
|
+
*/
|
|
3360
|
+
export const ERR_INVALID_UNIX_MODE: string;
|
|
3361
|
+
/**
|
|
3362
|
+
* Invalid unixExtraFieldType error (thrown when the `unixExtraFieldType` option is not `"infozip"` or `"unix"`)
|
|
3363
|
+
*/
|
|
3364
|
+
export const ERR_INVALID_UNIX_EXTRA_FIELD_TYPE: string;
|
|
3365
|
+
/**
|
|
3366
|
+
* Invalid UNIX uid/gid size error (thrown when `uid`/`gid` exceeds 65535 with `unixExtraFieldType` set to `"unix"`; use `"infozip"` for larger ids)
|
|
3367
|
+
*/
|
|
3368
|
+
export const ERR_INVALID_UNIX_ID_SIZE: string;
|
|
3369
|
+
/**
|
|
3370
|
+
* Invalid msdosAttributesRaw error (thrown when the `msdosAttributesRaw` option is not an integer in the range 0..255)
|
|
3371
|
+
*/
|
|
3372
|
+
export const ERR_INVALID_MSDOS_ATTRIBUTES: string;
|
|
3373
|
+
/**
|
|
3374
|
+
* Invalid msdosAttributes error (thrown when the `msdosAttributes` option is not an object with boolean flags)
|
|
3375
|
+
*/
|
|
3376
|
+
export const ERR_INVALID_MSDOS_DATA: string;
|
|
3377
|
+
/**
|
|
3378
|
+
* Entry already exists error (thrown by the filesystem API when adding an entry whose filename already exists)
|
|
3379
|
+
*/
|
|
3380
|
+
export const ERR_ENTRY_EXISTS: string;
|
|
3381
|
+
/**
|
|
3382
|
+
* Readable stream already consumed error (thrown by the filesystem API when a readable stream is read more than once)
|
|
3383
|
+
*/
|
|
3384
|
+
export const ERR_READABLE_CONSUMED: string;
|
|
3385
|
+
/**
|
|
3386
|
+
* Unsupported context error (thrown when {@link createSyncAccessHandleTempStream} is used outside a dedicated worker)
|
|
3387
|
+
*/
|
|
3388
|
+
export const ERR_UNSUPPORTED_CONTEXT: string;
|
|
3389
|
+
/**
|
|
3390
|
+
* Unsupported Crypto API error (thrown when writing encrypted entries while `crypto.getRandomValues` is unavailable)
|
|
3391
|
+
*/
|
|
3392
|
+
export const ERR_UNSUPPORTED_CRYPTO_API: string;
|
|
3393
|
+
/**
|
|
3394
|
+
* Web worker startup timeout error (thrown when a web worker does not start in time, e.g. in browser extensions
|
|
3395
|
+
* disallowing workers; set `useWebWorkers` to `false` in {@link configure} to work around it)
|
|
3396
|
+
*/
|
|
3397
|
+
export const ERR_WORKER_STARTUP_TIMEOUT: string;
|