/** * @fileoverview TCBL Archive Reader. * * Reads and extracts entries from a TCBL (Tarball CBL) archive. * The reader receives an already-constructed {@link TarballConstituentBlockListBlock} * and a block store. Decryption of any `EncryptedBlock` wrapper is the * caller's responsibility. * * Usage: * ```typescript * const reader = new TcblReader(tcblBlock, blockStore); * await reader.open(); * const entries = reader.listEntries(); * const data = await reader.getEntryByName('file.txt'); * ``` * * @typeParam TID - Platform ID type for frontend/backend DTO compatibility * * @see Requirement 5 (TCBL Reading and Extraction) */ import { PlatformID } from '@digitaldefiance/ecies-lib'; import { IBlockStore } from '../../interfaces/storage/blockStore'; import { ITcblEntryDescriptor } from '../../interfaces/tcbl/tcblEntryDescriptor'; import { TarballConstituentBlockListBlock } from './tcbl'; /** * Reader for TCBL (Tarball CBL) archives. * * Provides methods to enumerate manifest entries and extract individual * entry data from the block store. The {@link open} method must be called * before any other operations. * * @typeParam TID - Platform ID type (defaults to `Uint8Array`) * * @see Requirement 5 */ export declare class TcblReader { /** The TCBL block being read. */ private readonly tcblBlock; /** Block store for retrieving entry data. */ private readonly blockStore; /** Whether {@link open} has been called successfully. */ private _isOpen; /** Cached manifest entries after open(). */ private _entries; /** * Create a new TCBL reader. * * @param tcblBlock - The TCBL block to read (must be already decrypted) * @param blockStore - Block store for retrieving entry data blocks * * @see Requirement 5.7 — decryption is the caller's responsibility */ constructor(tcblBlock: TarballConstituentBlockListBlock, blockStore: IBlockStore); /** * Open the archive for reading. * * Retrieves the payload block from the block store (last address in * the CBL's address list), handles decompression if the payload is * bzip2-compressed, sets the payload data on the TCBL block, and * validates the manifest checksum. * * Must be called before {@link listEntries}, {@link getEntryByIndex}, * or {@link getEntryByName}. * * @throws {TcblError} with {@link TcblErrorType.DecompressionFailed} * if bzip2 decompression fails * @throws {TcblError} with {@link TcblErrorType.ManifestChecksumMismatch} * if the manifest checksum does not match * @throws {TcblError} with {@link TcblErrorType.ManifestCorrupted} * if the manifest is structurally invalid * * @see Requirement 5.1, 5.2, 5.5 */ open(): Promise; /** * Ensure the archive has been opened. * * @throws {TcblError} with {@link TcblErrorType.InvalidHeader} if * {@link open} has not been called */ private ensureOpen; /** * List all entry descriptors from the manifest without extracting data. * * @returns Array of entry descriptors * @throws {TcblError} if the archive has not been opened * * @see Requirement 5.3 */ listEntries(): ITcblEntryDescriptor[]; /** * Retrieve entry data by index. * * @param index - Zero-based index into the manifest entries * @returns The entry's original data (trimmed to originalDataLength) * * @throws {TcblError} with {@link TcblErrorType.EntryNotFound} if * the index is out of range * * @see Requirement 5.4, 5.6 */ getEntryByIndex(index: number): Promise; /** * Retrieve entry data by file name. * * @param fileName - The file name to search for in the manifest * @returns The entry's original data (trimmed to originalDataLength) * * @throws {TcblError} with {@link TcblErrorType.EntryNotFound} if * no entry with the given file name exists * * @see Requirement 5.4, 5.6 */ getEntryByName(fileName: string): Promise; /** * Retrieve the raw data for a manifest entry from the block store. * * The block store returns a {@link RawDataBlock} padded to block size, * so we trim to `originalDataLength` to get the actual data. * * @param entry - The entry descriptor from the manifest * @returns The entry's original data bytes */ private retrieveEntryData; } //# sourceMappingURL=tcblReader.d.ts.map