NetworkPayloadSanitizer class final
Provides reusable sanitization helpers for network payloads.
Handles string-key normalization, optional redaction, and conversion of arbitrary values into map representations consumable by log models.
Constructors
- NetworkPayloadSanitizer(RedactionService _redactor, {DiagnosticResourceLimits resourceLimits = DiagnosticResourceLimits.balanced})
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
body(
Object? data, {required bool enableRedaction, Object? normalizer(Object? value)?, Set< String> ? ignoredValues, Set<String> ? ignoredKeys, DiagnosticCaptureMode captureMode = DiagnosticCaptureMode.strict}) → Object? -
Redacts (if enabled) and returns the provided body, optionally applying
a
normalizerbefore redaction. -
bodyWithProvenance(
Object? data, {required bool enableRedaction, Object? normalizer(Object? value)?, Set< String> ? ignoredValues, Set<String> ? ignoredKeys, DiagnosticCaptureMode captureMode = DiagnosticCaptureMode.strict}) → ({Object? body, bool redacted}) - Like body, and also reports whether redaction changed the bounded input.
-
ensureMap(
Object? value) → Map< String, dynamic> -
Ensures the value is represented as a string-keyed map. Non-map values are
wrapped in
{ 'data': value }. -
headersMap(
Map? headers, {required bool enableRedaction, Set< String> ? ignoredValues, Set<String> ? ignoredKeys}) → Map<String, dynamic> - Returns a string-keyed map of headers, applying redaction when enabled.
-
headersMapWithProvenance(
Map? headers, {required bool enableRedaction, Set< String> ? ignoredValues, Set<String> ? ignoredKeys}) → ({Map<String, dynamic> headers, List<String> redactedKeys}) - Like headersMap, and also reports which header keys redaction changed.
-
headersOrNull(
Map? headers, {required bool enableRedaction}) → Map< String, dynamic> ? - Returns null if the headers map is empty after sanitization.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
nullIfEmpty<
K, V> (Map< K, V> ? map) → Map<K, V> ? - Returns null when the provided map is null or empty; otherwise returns the map.
-
stringKeyMap(
Map? input) → Map< String, dynamic> - Converts a map with arbitrary key types into a string-keyed map.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
decodeJsonGracefully(
Object? value, {DiagnosticResourceLimits resourceLimits = DiagnosticResourceLimits.balanced}) → Object? -
Attempts to decode
valueas bounded JSON. -
encodeJsonGracefully(
Object? value, {DiagnosticCaptureMode captureMode = DiagnosticCaptureMode.strict, DiagnosticResourceLimits resourceLimits = DiagnosticResourceLimits.balanced}) → Object? - Creates a bounded payload snapshot using the selected capture policy.
-
jsonEquals(
Object? left, Object? right, DiagnosticResourceLimits resourceLimits) → bool - Structural equality over JSON-shaped values, bounded by DiagnosticResourceLimits.maxTraversalNodes.
-
toStringKeyMap(
Map? input, {DiagnosticCaptureMode captureMode = DiagnosticCaptureMode.strict, DiagnosticResourceLimits resourceLimits = DiagnosticResourceLimits.balanced, int? maxEntries}) → Map< String, dynamic> -
Converts a map with arbitrary key types into a
Map<String, dynamic>.