@zip.js/zip.js
    Preparing search index...

    Interface ZipDirectoryEntryExportFileSystemHandleOptions

    The ZipReaderOptions#preventClose option is ignored: the export owns the writable of each file it creates and must close it for the data to be written.

    interface ZipDirectoryEntryExportFileSystemHandleOptions {
        checkAmbiguity?: boolean;
        checkAuthenticationCode?: boolean;
        checkCrc32?: boolean;
        checkLocalDirectory?: boolean;
        checkLocalFilename?: boolean;
        checkOverlappingEntry?: boolean;
        checkOverlappingEntryOnly?: boolean;
        checkPasswordOnly?: boolean;
        checkSignature?: boolean;
        concurrent?: boolean;
        passThrough?: boolean | "compressed";
        password?: string;
        passwords?: string[];
        preventClose?: boolean;
        rawPassword?: Uint8Array<ArrayBufferLike>;
        readerOptions?: Omit<ZipReaderConstructorOptions, "passThrough"> & {
            passThrough?: boolean;
        } & PasswordCandidatesOptions;
        signal?: AbortSignal;
        strictness?: "balanced"
        | "strict"
        | "tolerant";
        transferStreams?: boolean;
        useCompressionStream?: boolean;
        useWebWorkers?: boolean;
        onend?(computedSize: number): void | Promise<void>;
        onprogress?(progress: number, total: number): void | Promise<void>;
        onstart?(total: number): void | Promise<void>;
        requestPassword?(
            entry: FileEntry,
            error?: Error,
        ): string | Promise<string | null | undefined> | null | undefined;
    }

    Hierarchy (View Summary)

    Index
    checkAmbiguity?: boolean

    true to throw an ERR_AMBIGUOUS_ARCHIVE error when calling FileEntry#getData if the local file header of the entry disagrees with its central directory record in a way that could make other tools (e.g. streaming readers based on local file headers) interpret the entry differently. This detects mismatched filenames, general purpose bit flags (encryption, data descriptor and language encoding flags), compression methods, CRC-32 checksums and sizes. The extra fields are not compared because the zip specification allows them to differ.

    This is the boolean form of ZipReaderOptions#strictness: true means "strict" and false means any value but "strict". When both options are set, the value passed to FileEntry#getData takes precedence over the value passed to the constructor of ZipReader, and strictness takes precedence over checkAmbiguity when both are set at the same level. false downgrades an inherited "strict" value to "balanced" and leaves an inherited "tolerant" value unchanged.

    false
    
    checkAuthenticationCode?: boolean

    true to verify the authentication code of entries encrypted with AES. The verification detects encrypted data tampered or corrupted after the encryption.

    true
    
    checkCrc32?: boolean

    true to verify the CRC-32 checksum of the entry against the value stored in the zip file. The verification is run on the decompressed data and covers the whole read pipeline. It also applies to entries encrypted with AES in AE-1 format. It is skipped for entries in AE-2 format because they store a zeroed CRC-32 value.

    false
    
    checkLocalDirectory?: boolean

    true to reject the entry with an ERR_AMBIGUOUS_ARCHIVE error when its local file header disagrees with its central directory record while calling FileEntry#getData, false to deposit the differences on EntryMetaData#warnings instead. This is the entry-level half of ZipReaderOptions#checkAmbiguity, exposed on its own so it can be enabled without the archive-level checks and disabled without giving up the rest of ZipReaderOptions#strictness. It is the only way to validate the local file headers of a self-extracting archive, since GetEntriesOptions#checkAmbiguity rejects prepended data outright.

    true compares the filename as well, like ZipReaderOptions#strictness set to "strict"; false compares everything except the filename, like "tolerant". Set ZipReaderOptions#checkLocalFilename to control the filename comparison on its own. An explicit value takes precedence over the strictness default at every level.

    true when ZipReaderOptions#strictness is "strict" or "balanced", false when it is "tolerant".

    checkLocalFilename?: boolean

    true to compare the filename of the local file header with the one of the central directory record when calling FileEntry#getData, false to leave the filename out of that comparison.

    Comparing the filename costs one extra read per entry whenever the local file header carries no extra field, which is why it is left out below ZipReaderOptions#strictness set to "strict". This option selects what is compared without changing whether a difference throws or warns, which ZipReaderOptions#checkLocalDirectory decides. It is therefore the only way to obtain WARNING_MISMATCHED_LOCAL_FILE_HEADER_FILENAME as a warning, with { checkLocalFilename: true, checkLocalDirectory: false }, and the only way to keep every other check of "strict" without paying the extra read, with { checkLocalFilename: false, strictness: "strict" }.

    the value of ZipReaderOptions#checkLocalDirectory when it is set, otherwise true when ZipReaderOptions#strictness is "strict" and false when it is "balanced" or "tolerant".

    checkOverlappingEntry?: boolean

    true to throw an ERR_OVERLAPPING_ENTRY error when calling FileEntry#getData if the entry overlaps with another entry on which FileEntry#getData has already been called (with the option checkOverlappingEntry or checkOverlappingEntryOnly set to true).

    false
    
    checkOverlappingEntryOnly?: boolean

    true to throw an ERR_OVERLAPPING_ENTRY error when calling FileEntry#getData if the entry overlaps with another entry on which FileEntry#getData has already been called (with the option checkOverlappingEntry or checkOverlappingEntryOnly set to true) without trying to read the content of the entry.

    false
    
    checkPasswordOnly?: boolean

    true to check only if the password is valid.

    false
    
    checkSignature?: boolean

    true to check the CRC-32 checksum of the entry.

    Use ZipReaderOptions#checkCrc32 instead.

    false
    
    concurrent?: boolean

    true to write independent files concurrently instead of one after another.

    When an entry fails, the entries still in flight are cancelled and the ones not started yet are skipped, so a failed export stops as early as it does when writing one file after another. An entry whose write has already been requested may still be created, because the File System Access API cannot cancel a pending getFileHandle or getDirectoryHandle call.

    false
    
    passThrough?: boolean | "compressed"

    true to read the data as-is without decompressing it and without decrypting it, "compressed" to decrypt it without decompressing it.

    The codecs run in a fixed order, the data is decrypted and then decompressed, so this option selects how many of these two stages are skipped rather than which one. "compressed" therefore returns the data of the entry still compressed but no longer encrypted, and it is the only way to obtain it: the value true returns the stored bytes, which are still encrypted, and an unset value returns the content itself. Reading an entry which is not encrypted gives the same result with true and with "compressed".

    Since the encryption is undone, "compressed" needs the ZipReaderOptions#password option and throws an ERR_INVALID_PASSWORD error when it is wrong, whereas true never looks at the password. The ZipReaderOptions#checkAuthenticationCode option applies as well. The ZipReaderOptions#checkCrc32 option does not, since the CRC32 of the entry describes its content and the content is not decompressed.

    Two entries holding the same content encrypted with two different passwords have no bytes in common when they are read with true, because the salt is drawn per entry. Read with "compressed" they are identical, which is what makes it possible to compare the content of encrypted entries without decompressing them.

    A value which is neither a boolean, "compressed" nor unset throws an ERR_INVALID_PASS_THROUGH_VALUE error. The filesystem API copies entries verbatim and only accepts a boolean, see ERR_UNSUPPORTED_PASS_THROUGH_VALUE.

    password?: string

    The password used to decrypt the content of the entry.

    passwords?: string[]

    The passwords tried in order, after the ZipReaderOptions#password option and the passwords already accepted by another entry of the same imported zip file. An empty string is ignored.

    When every candidate fails, the entry raises an ERR_INVALID_PASSWORD error whose cause is the error raised by the last candidate, unless the PasswordCandidatesOptions#requestPassword option is set.

    A value which is neither an array of strings nor unset throws an ERR_INVALID_PASSWORDS error.

    preventClose?: boolean

    true to prevent closing of WritableWriter#writable when calling FileEntry#getData.

    It only applies to the writable owned by the caller. It is ignored by the Writer instances returning the written data, such as BlobWriter or TextWriter, whose writable is created internally and must be closed for Writer#getData to resolve.

    false
    
    rawPassword?: Uint8Array<ArrayBufferLike>

    The password used to encrypt the content of the entry (raw).

    readerOptions?: Omit<ZipReaderConstructorOptions, "passThrough"> & {
        passThrough?: boolean;
    } & PasswordCandidatesOptions

    The options passed to the Reader instances.

    These options override the ones passed at the top level. The ZipReaderOptions#password option can be set here or at the top level, unlike ZipDirectoryEntryExportOptions where the top-level password encrypts the exported zip file instead.

    A value which is neither an object nor unset throws an ERR_INVALID_READER_OPTIONS error.

    signal?: AbortSignal

    The AbortSignal instance used to cancel the decompression.

    A signal already aborted when the operation starts rejects it with ERR_ABORTED as the reason of the AbortError, or with signal.reason when it is set, without relying on the signal option of pipeTo that the oldest supported engines ignore. A signal aborted while the entry is being read rejects the operation as well, whether its compressed data is still being consumed or its content still being written; on those engines, the content is written to the end before the operation is rejected.

    strictness?: "balanced" | "strict" | "tolerant"

    How tolerant the reader should be when the local file header of an entry disagrees with its central directory record.

    • "strict": compare the filename, the general purpose bit flag, the compression method, the CRC-32 checksum and the sizes, and throw an ERR_AMBIGUOUS_ARCHIVE error on any difference.
    • "balanced": compare everything except the filename, and throw on any difference.
    • "tolerant": compare everything except the filename, and deposit the differences on EntryMetaData#warnings instead of throwing.

    Every field except the filename is read from the local file header anyway, to locate the entry data, so the comparison "balanced" performs reads no additional bytes. Comparing the filename reads the filename bytes as well, which costs one extra read per entry whenever the local file header carries no extra field — the common case in practice, and the reason the filename is left out below "strict". Use ZipReaderOptions#checkLocalDirectory to request or suppress the whole comparison explicitly, and ZipReaderOptions#checkLocalFilename to include or exclude the filename on its own.

    "balanced"
    
    transferStreams?: boolean

    true to transfer stream ownership to web workers.

    true
    
    useCompressionStream?: boolean

    true to use the native API CompressionStream/DecompressionStream to compress/decompress data.

    When compressing, the native API is only used when level is undefined or equal to 6, see ZipWriterConstructorOptions#level.

    true
    
    useWebWorkers?: boolean

    true to use web workers to compress/decompress data in non-blocking background processes.

    true
    
    • The function called when ending compression/decompression.

      Parameters

      • computedSize: number

        The total number of bytes (computed).

      Returns void | Promise<void>

      An empty promise or undefined.

    • The function called during compression/decompression.

      Parameters

      • progress: number

        The current progress in bytes.

      • total: number

        The total number of bytes.

      Returns void | Promise<void>

      An empty promise or undefined.

    • The function called when starting compression/decompression.

      Parameters

      • total: number

        The total number of bytes.

      Returns void | Promise<void>

      An empty promise or undefined.

    • The function asked for a password when every candidate has failed, or when there is none. It is called with the entry being read and with the error raised by the last candidate, which is undefined when no candidate was tried, and it can return a promise, e.g. when it prompts the user.

      A string is tried on the entry, and the function is called again when it fails, with the ERR_INVALID_PASSWORD error. undefined or null gives up: the entry raises an ERR_INVALID_PASSWORD error whose cause is the error raised by the last candidate, or an ERR_ENCRYPTED error when no candidate was tried. A value of another type throws an ERR_INVALID_REQUEST_PASSWORD error. The function is not called for the entries whose password is already known.

      When several entries are read concurrently, e.g. by {@link ZipDirectoryEntry}#export*() with the ZipWriterConstructorOptions#bufferedWrite option, only one call is pending at a time: the other entries wait for its answer and try it before asking themselves. Cancelling the whole operation from the function is done with the ZipReaderOptions#signal option, since giving up fails the entry being read only.

      A value which is neither a function nor unset throws an ERR_INVALID_REQUEST_PASSWORD error.

      Parameters

      • entry: FileEntry

        The entry being read.

      • Optionalerror: Error

        The error raised by the last candidate, undefined when no candidate was tried.

      Returns string | Promise<string | null | undefined> | null | undefined

      The password to try, or undefined to give up.