SensitiveDataMasker class

Recursively masks sensitive values inside the data structures recorded by the inspector (headers, query parameters, request body and response body).

Matching is done by key name, case-insensitively. Whenever a map entry whose key is contained in maskedKeys is encountered, its value is replaced by placeholder (or by the result of maskValueBuilder when provided).

The masker never mutates the original data: every map/list it touches is rebuilt, so masking the logged copy can't corrupt the real outgoing request or the live response.

String values are inspected too: when a string holds a JSON object/array (e.g. a stringified request body, or a stringified metadata blob), it is decoded, masked recursively and re-encoded so nested secrets are covered.

FormData and other unknown types are left untouched.

Constructors

SensitiveDataMasker({Set<String>? maskedKeys, String placeholder = '***', MaskValueBuilder? maskValueBuilder})

Properties

hashCode int
The hash code for this object.
no setterinherited
isEnabled bool
Whether this masker would actually change anything.
no setter
maskedKeys Set<String>
The (lower-cased) set of key names whose values are masked.
final
placeholder String
The value substituted for a masked entry when no maskValueBuilder is set.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

mask(dynamic data) → dynamic
Returns a masked copy of data, leaving the original untouched.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

defaultMaskedKeys → const Set<String>
A reasonable default set of sensitive key names to mask out of the box.