redactSecrets function
Masks bearer tokens, JWTs, long hex keys and password=-style values in free text.
Implementation
String redactSecrets(String input) {
if (input.isEmpty) return input;
return input
.replaceAll(_jwtRegex, '<jwt>')
.replaceAllMapped(_bearerRegex, (m) => '${m[1]} <redacted>')
.replaceAllMapped(_assignmentRegex, (m) => '${m[1]}${m[2]}<redacted>')
.replaceAll(_longHexRegex, '<hex>');
}