@juspay/neurolink
Version:
Universal AI Development Platform with working MCP integration, multi-provider support, voice (TTS/STT/realtime), and professional CLI. 58+ external MCP servers discoverable, multimodal file processing, RAG pipelines. Build, test, and deploy AI applicatio
170 lines (169 loc) • 5.4 kB
TypeScript
/**
* Config File Processor
*
* Processes configuration files (.env, .ini, .toml, .cfg, .conf, .properties).
* Automatically detects format based on extension and redacts sensitive values
* for security.
*
* Key features:
* - Format detection (env, ini, toml, properties)
* - Automatic secret redaction (passwords, tokens, API keys)
* - Key-value extraction for structured access
* - Security-first approach to config file handling
*
* Priority: 130 (lower priority - text-based config files)
*
* @module processors/code/ConfigProcessor
*
* @example
* ```typescript
* import { configProcessor, processConfig, isConfigFile } from "./code/index.js";
*
* // Check if a file is a config file
* if (isConfigFile("text/plain", ".env")) {
* const result = await processConfig({
* id: "file-123",
* name: ".env",
* mimetype: "text/plain",
* size: 512,
* buffer: envBuffer,
* });
*
* if (result.success) {
* console.log(`Format: ${result.data.format}`);
* console.log(`Redacted keys: ${result.data.redactedKeys.join(", ")}`);
* }
* }
* ```
*/
import { BaseFileProcessor } from "../base/BaseFileProcessor.js";
import type { FileInfo, ProcessorFileProcessingResult, ProcessOptions, ProcessedConfig } from "../../types/index.js";
/**
* Config Processor - handles configuration files with security redaction.
*
* Automatically detects the format based on file extension and extracts
* key-value pairs while redacting sensitive values for security.
*
* Priority: 130 (processed after binary/document formats)
*
* @example
* ```typescript
* const processor = new ConfigProcessor();
*
* const result = await processor.processFile({
* id: "file-123",
* name: ".env",
* mimetype: "text/plain",
* size: 512,
* buffer: envBuffer,
* });
*
* if (result.success) {
* console.log(`Detected format: ${result.data.format}`);
* console.log(`Redacted ${result.data.redactedKeys.length} sensitive keys`);
* }
* ```
*/
export declare class ConfigProcessor extends BaseFileProcessor<ProcessedConfig> {
constructor();
/**
* Override to check for exact filename matches like ".env" files.
*
* @param mimetype - MIME type of the file
* @param filename - Filename for detection
* @returns true if the file is a supported config file
*/
isFileSupported(mimetype: string, filename: string): boolean;
/**
* Build the processed config result.
* Detects format, extracts key-values, and redacts sensitive content.
*
* @param buffer - Raw file content
* @param fileInfo - Original file information
* @returns Processed config with redacted content and key-value pairs
*/
protected buildProcessedResult(buffer: Buffer, fileInfo: FileInfo): ProcessedConfig;
/**
* Detect the configuration format based on extension and content.
*
* @param ext - File extension (with leading dot)
* @param content - File content for format heuristics
* @returns Detected format
*/
private detectFormat;
/**
* Parse configuration content and redact sensitive values.
*
* @param content - Raw configuration content
* @param format - Detected format
* @returns Key-value pairs and list of redacted keys
*/
private parseAndRedact;
/**
* Check if a key likely contains sensitive data.
*
* @param key - Key name to check
* @returns true if the key matches a sensitive pattern
*/
private isSensitiveKey;
/**
* Redact sensitive values in the original content.
*
* @param content - Original configuration content
* @param redactedKeys - Keys to redact
* @returns Content with redacted values
*/
private redactContent;
/**
* Extract file extension from filename.
*
* @param filename - Filename to extract extension from
* @returns Extension with leading dot or null
*/
private getExtension;
}
/**
* Singleton instance of the ConfigProcessor.
* Use this for all configuration file processing to share configuration.
*/
export declare const configProcessor: ConfigProcessor;
/**
* Check if a file is a configuration file.
*
* @param mimetype - MIME type of the file
* @param filename - Filename for detection
* @returns true if the file is a supported config file
*
* @example
* ```typescript
* if (isConfigFile("text/plain", ".env")) {
* console.log("This is a config file");
* }
* ```
*/
export declare function isConfigFile(mimetype: string, filename: string): boolean;
/**
* Process a configuration file.
*
* @param fileInfo - File information (can include URL or buffer)
* @param options - Optional processing options
* @returns Processing result with success flag and either data or error
*
* @example
* ```typescript
* const result = await processConfig({
* id: "file-123",
* name: ".env.production",
* mimetype: "text/plain",
* size: 1024,
* buffer: configBuffer,
* });
*
* if (result.success) {
* console.log(`Format: ${result.data.format}`);
* console.log(`Keys: ${Object.keys(result.data.keyValues).length}`);
* console.log(`Redacted: ${result.data.redactedKeys.join(", ")}`);
* }
* ```
*/
export declare function processConfig(fileInfo: FileInfo, options?: ProcessOptions): Promise<ProcessorFileProcessingResult<ProcessedConfig>>;