import type { ResourceLimits } from './limits.js'; import type { JsonObject } from './json.js'; import type { SafetyProfile } from './safety.js'; import type { ZipErrorCode, ZipWarningCode } from './errors.js'; export type { ResourceLimits } from './limits.js'; export type { SafetyProfile } from './safety.js'; export type { ZipWarning, ZipWarningCode } from './errors.js'; /** Compression methods supported without registering a custom codec. */ export type BuiltInCompressionMethod = 0 | 8 | 9 | 93; /** ZIP compression method identifier, including methods supplied by registered codecs. */ export type CompressionMethod = number; /** ZIP encryption configuration for reading/writing. */ export type ZipEncryption = { type: 'none'; } | { type: 'zipcrypto'; password: string; } | { type: 'aes'; password: string; strength?: 128 | 192 | 256; vendorVersion?: 1 | 2; }; /** Progress event emitted by ZIP operations. */ export type ZipProgressEvent = { /** Pipeline stage producing the progress callback. */ kind: 'read' | 'write' | 'extract' | 'compress' | 'decrypt' | 'encrypt'; /** Entry name when progress maps to a single member. */ entryName?: string; /** Input bytes consumed by the active stage. */ bytesIn?: bigint; /** Output bytes produced by the active stage. */ bytesOut?: bigint; /** Total source bytes processed so far. */ totalIn?: bigint; /** Total output bytes produced so far. */ totalOut?: bigint; }; /** Progress callback and throttling options. */ export type ZipProgressOptions = { /** Callback invoked with bounded progress events during read/write pipelines. */ onProgress?: (event: ZipProgressEvent) => void; /** Minimum wall-clock interval between emitted progress callbacks. */ progressIntervalMs?: number; /** Minimum chunk count between emitted progress callbacks. */ progressChunkInterval?: number; }; /** Severity level for ZIP issues. */ export type ZipIssueSeverity = 'info' | 'warning' | 'error'; /** Stable machine codes emitted by ZIP audit and normalization reports. */ export type ZipIssueCode = ZipErrorCode | ZipWarningCode | 'ZIP_AUDIT_ERROR' | 'ZIP_CASE_COLLISION' | 'ZIP_DUPLICATE_ENTRY' | 'ZIP_HEADER_MISMATCH' | 'ZIP_NORMALIZED_NAME' | 'ZIP_OUT_OF_RANGE' | 'ZIP_OVERLAPPING_ENTRIES' | 'ZIP_SYMLINK_PRESENT' | 'ZIP_TRAILING_BYTES' | 'ZIP_UNICODE_COLLISION'; /** A single issue found during audit or normalize. */ export type ZipIssue = { /** Stable machine code for policy filtering. */ code: ZipIssueCode; /** Severity for machine/human reporting. */ severity: ZipIssueSeverity; /** Human-readable description of the issue. */ message: string; /** Entry name when the issue maps to one file. */ entryName?: string; /** Byte offset when parser metadata is available. */ offset?: string; /** Additional structured context for automation. */ details?: JsonObject; }; /** Audit report for a ZIP archive. */ export type ZipAuditReport = { /** Whether the archive satisfies the reader's safety profile. */ isSafe: boolean; /** Aggregate entry/error counters for dashboards and policy decisions. */ summary: { /** Number of entries found in central directory traversal. */ entryCount: number; /** Number of entries using ZIP encryption metadata. */ encryptedEntryCount: number; /** Entries requiring unsupported features/codecs. */ unsupportedEntryCount: number; /** Warning issue count. */ warningCount: number; /** Error issue count. */ errorCount: number; /** Bytes trailing the canonical ZIP payload, when present. */ trailingByteCount?: number; }; /** Full issue list with stable machine codes. */ issues: ZipIssue[]; }; /** ZIP entry metadata exposed by ZipReader. */ export type ZipEntry = { /** Normalized entry path. */ name: string; /** Decoding strategy used for `name`. */ nameSource: 'utf8-flag' | 'cp437' | 'unicode-extra'; /** Original raw filename bytes from the archive. */ rawNameBytes: Uint8Array; /** Optional entry comment. */ comment?: string | undefined; /** Compression method identifier from ZIP headers. */ method: number; /** Raw general-purpose bit flags. */ flags: number; /** CRC32 value from ZIP metadata. */ crc32: number; /** Stored compressed entry size. */ compressedSize: bigint; /** Stored uncompressed entry size. */ uncompressedSize: bigint; /** Byte offset to local header. */ offset: bigint; /** Modified timestamp converted to `Date`. */ mtime: Date; /** Access time when available. */ atime?: Date | undefined; /** Creation time when available. */ ctime?: Date | undefined; /** True when the entry is a directory marker. */ isDirectory: boolean; /** True when the entry is a symlink. */ isSymlink: boolean; /** True when encrypted metadata is present. */ encrypted: boolean; /** True when ZIP64 metadata is used. */ zip64: boolean; }; /** Limits used when reading or extracting ZIP archives. */ export type ZipLimits = ResourceLimits; /** Options for creating ZipReader instances. */ export type ZipReaderOptions = { /** Safety preset controlling validation and default resource limits. */ safetyProfile?: SafetyProfile; /** Retain parsed entries in memory for repeated access. */ shouldStoreEntries?: boolean; /** Resource ceilings for read/decompress/extract paths. */ limits?: ZipLimits; /** Default password for encrypted entries. */ password?: string; /** Abort signal for reader-level operations. */ signal?: AbortSignal; /** HTTP range-read tuning for remote ZIP inputs opened from URLs. */ http?: { /** Additional HTTP headers for remote ZIP requests. */ headers?: Record; /** In-memory block cache sizing for range reads. */ cache?: { blockSize?: number; maxBlocks?: number; }; /** Abort signal for HTTP requests. */ signal?: AbortSignal; /** Validator policy for conditional range requests. */ snapshotPolicy?: 'require-strong-etag' | 'best-effort'; }; }; /** Options for opening ZIP entries. */ export type ZipReaderOpenOptions = ZipProgressOptions & { /** Password override for this open call. */ password?: string; /** Abort signal for the open stream pipeline. */ signal?: AbortSignal; }; /** Options for extracting ZIP entries. */ export type ZipExtractOptions = ZipProgressOptions & { /** Allow materializing symlinks that remain contained under the extraction root. */ shouldAllowSymlinks?: boolean; /** Extraction resource ceilings. */ limits?: ZipLimits; /** Password override for extraction. */ password?: string; /** Abort signal for extraction operations. */ signal?: AbortSignal; }; /** Options for iterating ZIP entries. */ export type ZipReaderIterOptions = { signal?: AbortSignal; }; /** Options for auditing ZIP archives. */ export type ZipAuditOptions = { /** Audit resource ceilings. */ limits?: ZipLimits; /** Abort signal for audit operations. */ signal?: AbortSignal; }; /** Options for creating ZipWriter instances. */ export type ZipWriterOptions = ZipProgressOptions & { /** Force ZIP64 metadata regardless of payload size. */ shouldForceZip64?: boolean; /** Default compression method for added entries. */ defaultMethod?: CompressionMethod; /** Seekability policy for output sink optimization. */ sinkSeekabilityPolicy?: 'auto' | 'on' | 'off'; /** Default encryption mode for new entries. */ encryption?: ZipEncryption; /** Password used when encryption needs credentials. */ password?: string; /** Abort signal for writer lifecycle operations. */ signal?: AbortSignal; }; /** ZIP64 behavior for writing entries. */ export type Zip64Mode = 'auto' | 'force' | 'off'; /** Options for adding entries with ZipWriter. */ export type ZipWriterAddOptions = { /** Compression method override for this entry. */ method?: CompressionMethod; /** Modified timestamp for the entry metadata. */ mtime?: Date; /** Optional entry comment. */ comment?: string; /** ZIP64 mode override for this entry. */ zip64?: Zip64Mode; /** External file attribute bits. */ externalAttributes?: number; /** Encryption mode override for this entry. */ encryption?: ZipEncryption; /** Password override for this entry. */ password?: string; /** Abort signal for this add call. */ signal?: AbortSignal; }; /** Options for closing ZipWriter. */ export type ZipWriterCloseOptions = { /** Abort signal for final central-directory and footer writes. */ signal?: AbortSignal; }; /** Normalization safety level. */ export type ZipNormalizeMode = 'safe' | 'lossless'; /** Conflict resolution for duplicate or colliding entries. */ export type ZipNormalizeConflict = 'error' | 'last-wins' | 'rename'; /** Options for normalizing ZIP archives. */ export type ZipNormalizeOptions = ZipProgressOptions & { /** Safe (drop-risky) or lossless normalization strategy. */ mode?: ZipNormalizeMode; /** Enable deterministic output ordering and metadata shape. */ isDeterministic?: boolean; /** Compression method applied to rewritten entries. */ method?: CompressionMethod; /** Duplicate-entry conflict policy. */ onDuplicate?: ZipNormalizeConflict; /** Case-collision policy for entry names. */ onCaseCollision?: ZipNormalizeConflict; /** Handling policy for unsupported entry features. */ onUnsupported?: 'error' | 'drop'; /** Handling policy for symlink entries. */ onSymlink?: 'error' | 'drop'; /** Preserve entry comments in normalized output. */ shouldPreserveComments?: boolean; /** Preserve trailing bytes after canonical ZIP payload. */ shouldPreserveTrailingBytes?: boolean; /** Password used for encrypted entry reads. */ password?: string; /** Normalization resource ceilings. */ limits?: ZipLimits; /** Abort signal for normalize pipelines. */ signal?: AbortSignal; }; /** Normalize report for ZIP archives. */ export type ZipNormalizeReport = { /** True when normalize completed without error-severity issues. */ isSuccessful: boolean; /** Aggregate counters describing what normalization preserved, rewrote, or dropped. */ summary: ZipAuditReport['summary'] & { /** Number of entries emitted after normalization. */ outputEntryCount: number; /** Entries dropped by normalize policy. */ droppedEntryCount: number; /** Entries renamed to resolve conflicts. */ renamedEntryCount: number; /** Entries recompressed during rewrite. */ recompressedEntryCount: number; /** Entries preserved byte-for-byte. */ preservedEntryCount: number; }; /** Full issue list with stable machine codes. */ issues: ZipIssue[]; }; //# sourceMappingURL=types.d.ts.map