function maskSensitiveData(payload, attributesToMask = SENSITIVE_ATTRIBUTES) {
    // Deep copy
    let payloadStr = JSON.stringify(payload);
    
    attributesToMask.forEach(attr => {
        payloadStr = payloadStr.replace(
            new RegExp(`("${attr}"):(".+?"|\\d+)`, 'mgi'),
            '$1:"********"'
        );
    });
    
    return payloadStr;
}
Mask sensitive attributes in a payload

@param {Object} payload - The payload to mask
@param {string[]} [attributesToMask] - Custom list of attributes to mask
@returns {string} JSON string with masked values