import { Member, PlatformID } from '@digitaldefiance/ecies-lib'; import { ConstituentBlockListBlock } from '../blocks/cbl'; import { EncryptedBlock } from '../blocks/encrypted'; import { EphemeralBlock } from '../blocks/ephemeral'; import { ExtendedCBL } from '../blocks/extendedCbl'; import { RandomBlock } from '../blocks/random'; import { RawDataBlock } from '../blocks/rawData'; import { BlockEncryptionType } from '../enumerations/blockEncryptionType'; import { BlockSize } from '../enumerations/blockSize'; import { BlockType } from '../enumerations/blockType'; import { IEncryptedBlock } from '../interfaces/blocks/encrypted'; import { IEphemeralBlock } from '../interfaces/blocks/ephemeral'; import { LogLevel } from '../logging/blockLogger'; import { IUniversalBlockStore } from '../interfaces/storage/universalBlockStore'; /** * Browser-compatible BlockService with core functionality */ export declare class BlockService { private static blockStore; /** * Configure the block logger level. * @param level - The minimum log level to emit */ static setLogLevel(level: LogLevel): void; static initialize(blockStore: IUniversalBlockStore): void; /** * Determine the block type from the first byte of the block data */ determineBlockEncryptionType(data: Uint8Array): BlockEncryptionType; /** * Check if a block is encrypted for a single recipient */ isSingleRecipientEncrypted(data: Uint8Array): boolean; /** * Check if a block is encrypted for multiple recipients */ isMultiRecipientEncrypted(data: Uint8Array): boolean; /** * Get the appropriate block size for a given data length. * * @param dataLength - The number of bytes that must fit in the block. * @param supportedSizes - Optional list of block sizes to choose from * (e.g. from a block store's `supportedBlockSizes`). When provided, * only sizes in this list are considered. When omitted, all standard * sizes are eligible (original behaviour). * @returns The smallest qualifying BlockSize, or BlockSize.Unknown if * no size is large enough. */ getBlockSizeForData(dataLength: number, supportedSizes?: readonly BlockSize[]): BlockSize; /** * Generate random data using browser crypto. * Chunks calls to comply with the 65 536-byte getRandomValues() limit. */ private generateRandomData; /** * Encrypt a block using ECIES * * @param newBlockType - The block type for the encrypted block * @param block - The ephemeral block to encrypt * @param recipient - Optional recipient member (defaults to block creator) * @returns The encrypted block * @throws {EnhancedValidationError} If block type is invalid * @throws {BlockError} If block cannot be encrypted or creator is missing * @throws {EciesError} If ECIES encryption fails * * @see Requirements 5.1, 5.2, 5.3, 7.2, 7.3 */ encrypt(newBlockType: BlockType, block: IEphemeralBlock, recipient?: Member): Promise>; /** * Decrypt a block using ECIES * * @param creator - The member with private key to decrypt * @param block - The encrypted block to decrypt * @param newBlockType - The block type for the decrypted block * @returns The decrypted ephemeral block * @throws {EnhancedValidationError} If block type is invalid * @throws {BlockError} If creator private key is missing * @throws {EciesError} If ECIES decryption fails * * @see Requirements 5.1, 5.2, 5.3, 7.2, 7.3 */ decrypt(creator: Member, block: EncryptedBlock, newBlockType: BlockType): Promise>; /** * Decrypt multiple and encrypt multiple methods */ decryptMultiple(recipient: Member, block: IEncryptedBlock): Promise>; /** * Encrypt a block for multiple recipients using ECIES * * @param newBlockType - The block type for the encrypted block * @param block - The ephemeral block to encrypt * @param recipients - Array of recipient members * @returns The encrypted block * @throws {EnhancedValidationError} If block type or recipient count is invalid * @throws {BlockError} If block cannot be encrypted or creator is missing * @throws {EciesError} If ECIES encryption fails * * @see Requirements 5.1, 5.2, 5.3, 7.2, 7.3 */ encryptMultiple(newBlockType: BlockType, block: EphemeralBlock, recipients: Member[]): Promise>; /** * XOR a single block with all whiteners using XorService. * All arrays must be equal length for proper whitening. */ xorBlockWithWhiteners(block: Uint8Array, whiteners: (Uint8Array | RandomBlock | RawDataBlock)[]): Uint8Array; /** * Generate whiteners for browser use */ generateWhiteners(blockSize: BlockSize, count: number, dateCreated?: Date): RandomBlock[]; /** * Store a block to the store */ static storeBlockToDisk(block: RawDataBlock): Promise; /** * Process file data for browser ingestion (simplified version) */ ingestFile(fileData: Uint8Array, createECBL: boolean, encrypt: boolean, creator: Member, recipient?: Member, fileName?: string, dateCreated?: Date): Promise | ExtendedCBL>; /** * Create a CBL from blocks */ createCBL(blocks: any[], creator: Member, originalDataLength: number): Promise>; /** * Process file data in chunks (browser-compatible version) */ processFileInChunks(fileData: Uint8Array, encrypt: boolean, chunkCount: number, processChunk: (chunkBlocks: Uint8Array[]) => Promise, recipient?: Member): Promise; } //# sourceMappingURL=blockService.d.ts.map