RedactionConfig class
Privacy / size guardrails applied to captured network entries and individual log messages.
Defaults are conservative: common auth and session header keys are
masked, request and response bodies are truncated to 2 KB, and any
single log message longer than 8 KB is truncated. Pass a custom
instance to ShakeContext.recordNetwork or to the
ShakeDioInterceptor constructor to widen or tighten the policy.
- Annotations
Constructors
-
RedactionConfig({Set<
String> redactedHeaderKeys = const {'authorization', 'cookie', 'set-cookie', 'proxy-authorization', 'x-api-key', 'x-auth-token'}, Set<String> redactedBodyKeys = const {'password', 'pass', 'pwd', 'token', 'access_token', 'refresh_token', 'api_key', 'apikey', 'secret', 'authorization'}, int? maxBodyChars = 2048, int? maxLogChars = 8192, String maskText = '«redacted»'}) -
const
Properties
- hashCode → int
-
The hash code for this object.
no setteroverride
- maskText → String
-
Replacement text inserted in place of redacted values.
final
- maxBodyChars → int?
-
Maximum length, in characters, of request/response bodies stored on a
NetworkLog. Excess is replaced with
… <N more chars>. Set tonullto skip truncation.final - maxLogChars → int?
-
Maximum length, in characters, of any single log message. Excess is
truncated with the same
… <N more chars>suffix. Set tonullto keep the full string (use with care — a single multi-MB line can dominate the buffer).final -
redactedBodyKeys
→ Set<
String> -
JSON-ish body keys whose values are replaced with maskText before
being stored. Applies a simple regex over the serialized body string —
this is heuristic, not a JSON parser, but it catches the common shapes
(
"password":"hunter2",password=hunter2,"token": "abc").final -
redactedHeaderKeys
→ Set<
String> -
Header keys (case-insensitive) whose values are replaced with maskText
before being stored on a NetworkLog. Match is exact, not substring.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
redactBody(
String? body) → String? - Apply body redaction + truncation to a request/response body string.
-
redactHeaders(
Map< String, String> headers) → Map<String, String> -
Return a copy of
headerswhere any key listed in redactedHeaderKeys is replaced with maskText. Lookup is case-insensitive. -
toString(
) → String -
A string representation of this object.
inherited
-
truncateLog(
String message) → String - Apply truncation to a free-form log message.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override
Constants
- disabled → const RedactionConfig
- No-op policy: nothing is masked or truncated. Useful for tests or for fully trusted environments.