| 10 | * @returns {string} - Masked string |
| 11 | */ |
| 12 | export function maskData(input, config) { |
| 13 | if (!config) { |
| 14 | return input |
| 15 | } |
| 16 | |
| 17 | // Handle boolean config (backward compatibility) |
| 18 | if (typeof config === 'boolean' && config === true) { |
| 19 | return maskSensitiveData(input) |
| 20 | } |
| 21 | |
| 22 | // Handle object config with custom patterns |
| 23 | if (typeof config === 'object' && config.enabled === true) { |
| 24 | const customPatterns = config.patterns || [] |
| 25 | return maskSensitiveData(input, customPatterns) |
| 26 | } |
| 27 | |
| 28 | return input |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * Check if masking is enabled based on global configuration |