@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
69 lines (68 loc) • 2.3 kB
TypeScript
import type { RedactionConfig, DataStreamEvent } from "../../types/index.js";
/**
* Redact sensitive data from a stream chunk.
*
* IMPORTANT: Redaction is DISABLED by default. You must set `config.enabled = true`
* to enable redaction. This is a security feature that requires explicit opt-in.
*
* @param chunk - The stream chunk to redact
* @param config - Redaction configuration (enabled: false by default)
* @returns The redacted chunk with sensitive data removed, or original if disabled
*
* @example
* ```typescript
* // Redaction disabled by default - returns chunk unchanged
* const unchanged = redactStreamChunk(chunk);
*
* // Enable redaction explicitly
* const redacted = redactStreamChunk(chunk, { enabled: true });
* // Sensitive fields replaced with "[REDACTED]"
* ```
*
* @example
* ```typescript
* // With custom configuration (must enable first)
* const redacted = redactStreamChunk(chunk, {
* enabled: true,
* additionalFields: ["customSecret"],
* preserveFields: ["result"], // Don't redact result
* });
* ```
*/
export declare function redactStreamChunk(chunk: DataStreamEvent, config?: RedactionConfig): DataStreamEvent;
/**
* Create a redaction transform function for streams.
*
* IMPORTANT: Redaction is DISABLED by default. You must set `config.enabled = true`
* to enable redaction. If not enabled, the returned function passes chunks through unchanged.
*
* @param config - Redaction configuration
* @returns A transform function for stream chunks
*
* @example
* ```typescript
* // Redaction disabled - chunks pass through unchanged
* const redactor = createStreamRedactor();
* const unchanged = redactor(chunk); // Returns original chunk
*
* // Enable redaction
* const redactor = createStreamRedactor({ enabled: true });
* const redactedStream = stream.pipeThrough(new TransformStream({
* transform: (chunk, controller) => {
* controller.enqueue(redactor(chunk));
* }
* }));
* ```
*
* @example
* ```typescript
* // With custom options
* const redactor = createStreamRedactor({
* enabled: true,
* redactToolArgs: true,
* redactToolResults: true,
* additionalFields: ["internalId"],
* });
* ```
*/
export declare function createStreamRedactor(config?: RedactionConfig): <T>(chunk: T) => T;