normalizeAuthRateLimitIdentifier function

String? normalizeAuthRateLimitIdentifier(
  1. String? value
)

Applies the common safety boundary for endpoint-derived limiter keys.

Empty, overlong, or control-character-bearing values are discarded. The function does not lowercase or otherwise reinterpret identifiers because that canonicalization belongs to the endpoint's typed identifier policy.

Implementation

String? normalizeAuthRateLimitIdentifier(String? value) {
  if (value == null) return null;
  final normalized = value.trim();
  if (normalized.isEmpty ||
      normalized.length > authRateLimitIdentifierMaximumLength ||
      normalized.runes.any((rune) => rune <= 0x1f || rune == 0x7f)) {
    return null;
  }
  return normalized;
}