Skip to content

feat: listContents + selective extract APIs #365

Description

@cursor

Motivation

Users currently leave for other libraries (e.g. react-native-zip-stream) when they need to inspect a ZIP before extracting, or extract only some entries. See e.g. SO: Read zip file content before unzipping.

Proposal

listContents(source: string, charset?: string): Promise<ZipEntry[]>

Return archive metadata without extracting:

type ZipEntry = {
  path: string;
  size: number;           // uncompressed
  compressedSize: number;
  isDirectory: boolean;
  isEncrypted: boolean;
};

unzipFiles(source, destination, entries: string[], charset?: string): Promise<string>

unzipFilesWithPassword(source, destination, entries: string[], password: string): Promise<string>

Extract only the listed entry paths (files and/or directories). Paths that escape the destination must be rejected (Zip Slip).

Acceptance criteria

  • Works on iOS and Android with matching entry shapes
  • Password-protected archives supported via the *WithPassword variant
  • Zip Slip rejected for selective extract the same as full unzip
  • Progress events emitted for selective extract
  • TypeScript types + TurboModule spec updated
  • Jest mocks updated; playground coverage for the new APIs

Priority

P0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions