UNPKG

@himorishige/noren-core

Version:

Core PII detection, masking, and tokenization library built on Web Standards

77 lines 1.87 kB
import type { DetectUtils, Hit } from './types.js'; export type JsonHit = Hit & { jsonPath: string; keyName: string; }; export interface JsonDetectionResult { hits: JsonHit[]; isValidJson: boolean; fallbackToText: boolean; } /** * Streaming JSON detector for PII data * Uses key-based detection with fallback to text parsing */ export declare class JSONDetector { private currentPath; private hits; private arrayIndices; /** * Detect PII in JSON string */ detectInJson(jsonString: string, utils: DetectUtils): JsonDetectionResult; /** * Try parsing as NDJSON (newline-delimited JSON) */ private tryNDJSON; /** * Recursively traverse object/array structures */ private traverseObject; /** * Traverse array elements */ private traverseArray; /** * Traverse object properties */ private traverseObjectProperties; /** * Check if string value contains PII based on key name and content */ private checkStringValue; /** * Detect PII type from key name */ private detectPiiTypeFromKey; /** * Use existing detectors on string values */ private detectInStringValue; /** * Basic pattern matching for common PII types */ private basicPatternMatch; /** * Add a JSON-specific hit */ private addJsonHit; /** * Get current JSON path */ private getJsonPath; /** * Find the position of a value in the original JSON string * Simple fallback - just return default positions for now */ private findValuePosition; /** * Get risk level for PII type */ private getRiskLevel; } /** * JSON detector factory function */ export declare function createJSONDetector(): JSONDetector; //# sourceMappingURL=json-detector.d.ts.map