/** * ZIP extra field parsing helpers. * * Kept standalone so both streaming parser (`stream.base.ts`) and buffer parser * (`zip-parser.ts`) can share ZIP64 + Info-ZIP timestamp + AES handling. */ import { type AesKeyStrength } from "../crypto/aes.js"; /** * Info-ZIP Unicode Path Extra Field (0x7075). * * Used to store UTF-8 encoded file names when the general purpose bit 11 * (UTF-8 flag) is not set. This allows compatibility with older tools * while still preserving Unicode file names. * * Format: [version:1][nameCrc32:4][unicodeName:variable] */ export declare const UNICODE_PATH_EXTRA_FIELD_ID = 28789; /** * Info-ZIP Unicode Comment Extra Field (0x6375). * * Similar to Unicode Path, but for file comments. * * Format: [version:1][commentCrc32:4][unicodeComment:variable] */ export declare const UNICODE_COMMENT_EXTRA_FIELD_ID = 25461; export interface ZipVars { uncompressedSize: number; compressedSize: number; offsetToLocalFileHeader?: number; /** ZIP64 exact values (when present in extra field). */ uncompressedSize64?: bigint; compressedSize64?: bigint; offsetToLocalFileHeader64?: bigint; } export interface AesExtraFieldInfo { /** AE format version (1 or 2) */ version: 1 | 2; /** Key strength (128, 192, or 256) */ keyStrength: AesKeyStrength; /** Original compression method */ compressionMethod: number; } /** * Info-ZIP Unicode Path/Comment Extra Field info. */ export interface UnicodeExtraFieldInfo { /** Version (currently always 1) */ version: number; /** CRC32 of the original raw name/comment bytes */ originalCrc32: number; /** UTF-8 encoded name/comment */ unicodeValue: string; } export interface ZipExtraFields { uncompressedSize?: number; compressedSize?: number; offsetToLocalFileHeader?: number; /** ZIP64 exact values (when present in extra field). */ uncompressedSize64?: bigint; compressedSize64?: bigint; offsetToLocalFileHeader64?: bigint; /** Info-ZIP extended timestamp (0x5455) mtime, Unix seconds (UTC). */ mtimeUnixSeconds?: number; /** Info-ZIP extended timestamp (0x5455) atime, Unix seconds (UTC), when present. */ atimeUnixSeconds?: number; /** Info-ZIP extended timestamp (0x5455) ctime, Unix seconds (UTC), when present. */ ctimeUnixSeconds?: number; /** NTFS timestamps (0x000a) as Windows FILETIME (100ns since 1601-01-01 UTC). */ ntfsTimes?: { mtime: bigint; atime: bigint; ctime: bigint; birthTime: bigint; }; /** AES encryption info (0x9901) when present */ aesInfo?: AesExtraFieldInfo; /** * Info-ZIP Unicode Path Extra Field (0x7075). * Contains UTF-8 encoded file name when present. */ unicodePath?: UnicodeExtraFieldInfo; /** * Info-ZIP Unicode Comment Extra Field (0x6375). * Contains UTF-8 encoded comment when present. */ unicodeComment?: UnicodeExtraFieldInfo; } export declare function buildUnicodePathExtraField(originalPathBytes: Uint8Array, unicodePath: string): Uint8Array; export declare function buildUnicodeCommentExtraField(originalCommentBytes: Uint8Array, unicodeComment: string): Uint8Array; export declare function parseZipExtraFields(extraField: Uint8Array, vars: ZipVars): ZipExtraFields;