import type { ZipAuditOptions, ZipAuditReport, ZipEntry, ZipLimits, ZipNormalizeOptions, ZipNormalizeReport, SafetyProfile, ZipReaderIterOptions, ZipReaderOpenOptions, ZipReaderOptions, ZipWarning } from '../types.js'; import { type RandomAccess } from './RandomAccess.js'; import { type EocdResult } from './eocd.js'; import { type ZipEntryRecord } from './centralDirectory.js'; /** * Read ZIP archives from bytes, streams, or URLs. * * @example * ```ts * import { ZipReader } from "../../mod.ts"; * * const reader = await ZipReader.fromUint8Array(bytes, { safetyProfile: "untrusted" }); * const report = await reader.audit(); * console.log(report.isSafe); * ``` */ export declare class ZipReader { /** * Resolved safety profile used for ZIP audit/open defaults. * @internal */ protected readonly safetyProfile: SafetyProfile; /** * Effective strict-mode flag derived from the safety profile. * @internal */ protected readonly strict: boolean; /** * Fully resolved resource ceilings applied to this reader. * @internal */ protected readonly limits: Required; /** * Accumulated non-fatal warnings surfaced during parsing/open operations. * @internal */ protected readonly warningsList: ZipWarning[]; /** * Cached central-directory entries when `shouldStoreEntries` is enabled. * @internal */ protected entriesList: ZipEntryRecord[] | null; /** * Default password reused for encrypted entry opens when provided. * @internal */ protected readonly password: string | undefined; /** * Whether entries should remain cached after initialization. * @internal */ protected readonly storeEntries: boolean; /** * Parsed EOCD metadata used to reopen entry streams lazily. * @internal */ protected eocd: EocdResult | null; /** * Reader-level abort signal merged with transport-specific signals. * @internal */ protected readonly signal: AbortSignal | undefined; /** * Random-access source used for EOCD scans and entry reads. * @internal */ protected readonly reader: RandomAccess; /** @internal */ protected constructor(reader: RandomAccess, options?: ZipReaderOptions); /** * Create a reader from a random-access source. * * Use this when you already have a custom `RandomAccess` implementation and * want the ZIP parser to reuse it instead of buffering new input first. */ static fromRandomAccess(reader: RandomAccess, options?: ZipReaderOptions): Promise; /** Create a reader from in-memory bytes. */ static fromUint8Array(data: Uint8Array, options?: ZipReaderOptions): Promise; /** Create a reader from a readable stream. */ static fromStream(stream: ReadableStream, options?: ZipReaderOptions): Promise; /** Create a reader from a URL using HTTP range requests when possible. */ static fromUrl(url: string | URL, options?: ZipReaderOptions & { http?: { headers?: Record; cache?: { blockSize?: number; maxBlocks?: number; }; signal?: AbortSignal; snapshotPolicy?: 'require-strong-etag' | 'best-effort'; }; }): Promise; /** Return stored entries (requires shouldStoreEntries=true). */ entries(): ZipEntry[]; /** Return non-fatal warnings encountered during parsing. */ warnings(): ZipWarning[]; /** Iterate entries lazily (or from cached entries). */ iterEntries(options?: ZipReaderIterOptions): AsyncGenerator; /** Iterate entries with a callback. */ forEachEntry(fn: (entry: ZipEntry) => void | Promise, options?: ZipReaderIterOptions): Promise; /** Open a decoded stream for an entry. */ open(entry: ZipEntry, options?: ZipReaderOpenOptions): Promise>; /** Open a raw (compressed) stream for an entry. */ openRaw(entry: ZipEntry, options?: ZipReaderOpenOptions): Promise>; /** * Open a decoded entry stream against the underlying random-access source. * * Subclasses reuse this hook when they need to wrap entry reads with * transport-specific behavior without changing the higher-level API. */ protected openEntryStream(entry: ZipEntry, options: ZipReaderOpenOptions & { strict: boolean; onWarning?: (warning: ZipWarning) => void; limits: Required; totals?: { totalUncompressed: bigint; }; }): Promise>; /** Normalize to a writable stream, producing a report. */ normalizeToWritable(writable: WritableStream, options?: ZipNormalizeOptions): Promise; /** Audit the archive and return a report of issues. */ audit(options?: ZipAuditOptions): Promise; /** Audit and throw if the archive fails the selected safety profile. */ assertSafe(options?: ZipAuditOptions): Promise; /** Release underlying resources held by the reader. */ close(): Promise; /** Async dispose hook for using with `using` in supported runtimes. */ [Symbol.asyncDispose](): Promise; /** * Scan the ZIP footer and preload cached entries when entry storage is enabled. * * @throws {ZipError} When EOCD discovery fails or configured ZIP limits are exceeded. */ private init; /** * Force eager entry loading when this reader is configured to cache entries. * * Readers created with `shouldStoreEntries: false` skip this step and instead * resolve entries lazily through `iterEntries()`. */ private loadEntries; /** * Enforce per-entry and cumulative uncompressed-size limits during iteration. * * @throws {ZipError} When an entry exceeds the configured limits or compression-ratio policy. */ private applyEntryLimits; /** * Resolve the effective audit settings for one audit call. * * This keeps `audit()` and `assertSafe()` aligned with the reader defaults * while allowing per-call resource ceilings. */ private resolveAuditSettings; /** * Merge the reader-level abort signal with an operation-level abort signal. */ private resolveSignal; /** * Normalize the current archive into a sink-backed ZIP writer and return the report. * * This is the shared implementation behind `normalizeToWritable()` and * runtime-specific wrappers that target custom sinks. */ private normalizeToSink; /** * Build the normalized entry plan before writing the output archive. * * The returned list records renamed or dropped entries so normalization can * report collisions and policy decisions deterministically. */ private collectNormalizedEntries; } //# sourceMappingURL=ZipReader.d.ts.map