namespace MxGateway.Client.Cli;
/// Utility to redact API keys from error messages for safe output.
internal static class MxGatewayCliSecretRedactor
{
/// Replaces occurrences of the API key in the value with a redacted placeholder.
/// The message text to redact.
/// The API key to remove; no redaction if null or empty.
public static string Redact(string value, string? apiKey)
{
if (string.IsNullOrEmpty(value) || string.IsNullOrEmpty(apiKey))
{
return value;
}
return value.Replace(apiKey, "[redacted]", StringComparison.Ordinal);
}
}