* Redact sensitive fields in card objects * Only redacts cvv and number, keeps other fields visible
(card: any)
| 32 | * Only redacts cvv and number, keeps other fields visible |
| 33 | */ |
| 34 | function redactCardObject(card: any): any { |
| 35 | if (Array.isArray(card)) { |
| 36 | return card.map(redactCardObject); |
| 37 | } |
| 38 | |
| 39 | if (typeof card === 'object' && card !== null) { |
| 40 | const redactedCard: any = {}; |
| 41 | for (const [key, value] of Object.entries(card)) { |
| 42 | // Only redact cvv and number fields in card object |
| 43 | if (key === 'cvv' || key === 'number') { |
| 44 | redactedCard[key] = '[REDACTED]'; |
| 45 | } else { |
| 46 | // Keep other card fields but recursively redact if they're objects |
| 47 | redactedCard[key] = redactSensitiveData(value); |
| 48 | } |
| 49 | } |
| 50 | return redactedCard; |
| 51 | } |
| 52 | |
| 53 | return card; |
| 54 | } |
| 55 | |
| 56 | function redactSensitiveData(obj: any): any { |
| 57 | if (obj === null || obj === undefined) { |
no test coverage detected