import { Member, SignatureUint8Array, type PlatformID } from '@digitaldefiance/ecies-lib'; import { BlockSize } from '../enumerations/blockSize'; import { ICBLCore } from '../interfaces/blocks/cblBase'; import { ICBLServices } from '../interfaces/services/cblServices'; import { PoolId } from '../interfaces/storage/pooledBlockStore'; import { Checksum } from '../types/checksum'; import { EphemeralBlock } from './ephemeral'; import { BlockHandleTuple } from './handleTuple'; import { RawDataBlock } from './rawData'; /** * Shared core functionality between CBL/ECBL * * This class supports dependency injection for services to break circular * dependencies. When services are not provided, it falls back to using * ServiceLocator for backward compatibility. * * @typeParam TID - The platform ID type (defaults to Uint8Array) * * @example * ```typescript * // Using dependency injection (recommended) * const services: ICBLServices = { * checksumService: checksumService, * cblService: cblService, * }; * const cbl = new ConstituentBlockListBlock(data, creator, blockSize, services); * * // Using ServiceLocator (backward compatible) * const cbl = new ConstituentBlockListBlock(data, creator, blockSize); * ``` * * @requirements 2.1, 2.2, 2.4 */ export declare abstract class CBLBase extends EphemeralBlock implements ICBLCore { /** Cache for validated headers */ private static validatedHeaderCache; /** Cache for address count to avoid circular dependency */ private _cachedAddressCount; /** * Injected services for CBL operations. * When undefined, falls back to ServiceLocator for backward compatibility. */ protected readonly _services?: ICBLServices; /** * Get the CBL service, either from injected services or global service provider. * @returns The CBL service */ protected getCblService(): any; /** * Get the checksum service, either from injected services or global service provider. * @returns The checksum service */ protected getChecksumService(): any; /** * Create a new CBL core * @param data The data of the CBL * @param creator The creator of the CBL * @param blockSize Optional block size for signature validation (if data is unpadded) * @param services Optional injected services for dependency injection (breaks circular dependencies) * * @requirements 2.1, 2.2, 2.4 */ constructor(data: Uint8Array, creator: Member, blockSize?: BlockSize, services?: ICBLServices); /** * Ensure the header has been validated. If not and a creator is available, * validate it and cache the result. Otherwise, throw an error. */ protected ensureHeaderValidated(): void; /** * Validate the signature of the CBL header */ get headerValidated(): boolean; /** * The number of addresses in the CBL * This value is cached and frozen after first computation to ensure immutability. */ get cblAddressCount(): number; /** * The length of the original data represented by the CBL */ get originalDataLength(): number; /** * The size of each address tuple in bytes */ get tupleSize(): number; /** * Whether the CBL has an extended header */ get isExtendedCbl(): boolean; /** * The signature of the creator of the CBL */ get creatorSignature(): SignatureUint8Array; /** * The ID of the creator of the CBL */ get creatorId(): TID; /** * The data that follows the header in the CBL */ get addressData(): Uint8Array; /** * The addresses in the CBL */ get addresses(): Checksum[]; /** * The address data for the CBL. */ get layerPayload(): Uint8Array; get totalOverhead(): number; /** * Validate the CBL structure and metadata */ validateSync(): void; /** * Validate the CBL structure and metadata, async */ validateAsync(): Promise; /** * Validate the signature of the creator of the CBL * @param creator */ validateSignature(): boolean; /** * Get the layer header data from the CBL */ get layerHeaderData(): Uint8Array; /** * Get Block Handle Tuples for the CBL block. * * When `poolVerification` is provided, verifies that all referenced block * addresses exist in the specified pool via `hasInPool`. This ensures * pool integrity during reconstruction — all constituent blocks must * reside in the same pool as the CBL. * * @param blockStore - Store to retrieve block data from * @param poolVerification - Optional pool verification config. When provided, * checks that every address exists in the given pool. * @throws {CblError} CblErrorType.PoolIntegrityError if any address is missing from the pool * @throws {BlockAccessError} If the block is not readable */ getHandleTuples(blockStore: { getData(key: Checksum): Promise; }, poolVerification?: { poolId: PoolId; hasInPool: (pool: PoolId, hash: string) => Promise; }): Promise>; } //# sourceMappingURL=cblBase.d.ts.map