/** * Hash Utilities Module * * Provides SHA256 hashing utilities for: * - String content hashing (fingerprinting) * - File content hashing (delta detection) * - Project path hashing (index directory names) */ /** * Compute SHA256 hash of a string * * @param input - The string to hash * @returns Full SHA256 hex digest (64 characters) * * @example * ```typescript * hashString('hello world') * // => 'b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9' * ``` */ export declare function hashString(input: string): string; /** * Compute SHA256 hash of a file's content using streaming * * Uses streaming to handle large files without loading entire content into memory. * Falls back to synchronous read for small files for better performance. * * @param filePath - Absolute path to the file * @returns Promise resolving to SHA256 hex digest (64 characters) * @throws MCPError with FILE_NOT_FOUND if file doesn't exist * @throws MCPError with PERMISSION_DENIED if file can't be read * * @example * ```typescript * const hash = await hashFile('/path/to/file.ts'); * // => 'a94a8fe5ccb19ba61c4c0873d391e987982fbbd3...' * ``` */ export declare function hashFile(filePath: string): Promise; /** * Hash length constants for project path hashing * * SMCP-057: Increased from 16 to 32 characters for better collision resistance * - OLD_HASH_LENGTH (16 chars) = 64 bits of entropy * - NEW_HASH_LENGTH (32 chars) = 128 bits of entropy (recommended minimum for security) */ export declare const OLD_HASH_LENGTH = 16; export declare const NEW_HASH_LENGTH = 32; /** * Compute SHA256 hash of a project path for index directory naming * * SMCP-057: Returns a truncated hash (first 32 characters) suitable for directory names. * This provides 128 bits of entropy, which is the recommended minimum for security-sensitive * applications. Previously used 16 characters (64 bits). * * The path is normalized before hashing: * - Resolved to absolute path * - Lowercase on Windows for case-insensitivity * - Forward slashes normalized * * @param projectPath - Path to the project root * @returns First 32 characters of SHA256 hex digest * * @example * ```typescript * hashProjectPath('/Users/dev/my-project') * // => 'a1b2c3d4e5f6789001234567890abcde' * * // On Windows, paths are normalized: * hashProjectPath('C:\\Users\\Dev\\My-Project') * // Same as hashProjectPath('c:/users/dev/my-project') * ``` */ export declare function hashProjectPath(projectPath: string): string; /** * SMCP-057: Compute legacy (16-char) hash for backward compatibility * * Used during migration to support indexes created with the old hash format. * Should only be used for migration/compatibility checks. * * @param projectPath - Path to the project root * @returns First 16 characters of SHA256 hex digest (legacy format) */ export declare function hashProjectPathLegacy(projectPath: string): string; /** * Compute SHA256 hash synchronously for a file * * Use this only when async is not possible (e.g., in certain callback contexts). * Prefer hashFile for normal operations. * * @param filePath - Absolute path to the file * @returns SHA256 hex digest (64 characters) * @throws MCPError with FILE_NOT_FOUND if file doesn't exist */ export declare function hashFileSync(filePath: string): string; //# sourceMappingURL=hash.d.ts.map