How rodolfoviolac/blur-sensitive-data works
Main Components
• Client/API Layer – Although this is a library and not a full-stack application, the entry point is its API. The core class (named “Obfuscator”) is exposed (via index.js/ts) that developers instantiate and pass either object or string data.
• Object Obfuscation Module – This component handles the deep traversal of objects, keyword matching (based on default and additional sensitivity keys), circular dependency handling, and delegation to relevant utility functions.
• String Obfuscation Module – This component uses regular expression matching based on default patterns (e.g., credit card, CPF, etc.) and additional custom patterns to obfuscate sensitive information contained in text.
• Configurations/Typings – The “src/typings” directory includes enums and interface definitions that strongly type and define the behavior for both modules.
• Utility Functions – The “src/utils” directory contains helper modules (objectHandler, sensitiveFields, stringHandler, stringsPatterns) that perform the concrete data transformations.
• Testing & Examples – Though not part of the runtime architecture, the “test” directory ensures each module functions as expected and “examples” show how to integrate and use the library.
Depicting Relationships & Interactions
• From the “Obfuscator API”, branch out into two separate pathways:
• One pathway goes to the “Object Obfuscation Module” for object-based inputs.
• The other pathway routes to the “String Obfuscation Module” for string inputs.
• Both modules use common “Utility Functions” for handling tasks such as pattern matching or deep object traversal.
• Configurations (such as replacerText, additionalObjectKeys, etc.) and “Typings” feed into both modules to customize their behavior.
• Optionally, include a “Test Suite” alongside these modules to indicate testing/validation of each component and configuration.
Architectural Patterns & Design Principles
• Modularity: The design clearly separates concerns by having distinct modules for object and string processing.
• Configurability: The use of configuration objects and custom parameters (as seen in the README examples) allows flexible integration.
• Reusability: Utility functions and shared type definitions are reused across the string and object modules, promoting DRY (Don’t Repeat Yourself) principles.
• Extensibility: The design supports adding more sensitive patterns or keys (both in objects and strings) without major refactoring.