ispectify_http 5.0.0-dev42
ispectify_http: ^5.0.0-dev42 copied to clipboard
http_interceptor integration for ISpect with correlated HTTP request, response, error, timing, and redacted payload logs.
ispectify_http is an http_interceptor interceptor for the ISpect toolkit. It captures requests made through the package:http client, pairs them into transactions, and redacts sensitive data before logging.
- Request / response / error capture with headers, body, status, and duration.
- Redaction of auth headers, tokens, PII, and financial data (on by default).
- Compatible with every
InterceptedClientfromhttp_interceptor.
Install #
dependencies:
http: ^1.0.0
http_interceptor: ^2.0.0
ispectify: ^5.0.0-dev42
ispectify_http: ^5.0.0-dev42
Quick start #
import 'package:http_interceptor/http_interceptor.dart' as http_interceptor;
import 'package:ispect/ispect.dart';
import 'package:ispectify_http/ispectify_http.dart';
final client = http_interceptor.InterceptedClient.build(interceptors: []);
ISpect.run(
() => runApp(const MyApp()),
logger: logger,
onInit: () {
client.interceptors.add(
ISpectHttpInterceptor(
logger: logger,
settings: const ISpectHttpInterceptorSettings(
printRequestHeaders: true,
printResponseHeaders: true,
),
),
);
},
);
Settings #
ISpectHttpInterceptorSettings mirrors the Dio variant — headers / body capture toggles, with enableRedaction: true by default.
const settings = ISpectHttpInterceptorSettings(
printRequestHeaders: true,
printRequestData: true,
printResponseHeaders: false,
printResponseData: true,
enableRedaction: true,
);
Preset factories and a builder are available too — see the source of ISpectHttpInterceptorSettingsBuilder for development(), staging(), production() presets.
Data redaction #
Sensitive data is automatically masked before it reaches logs or observers. Redaction is enabled by default — built-in rules cover auth headers, tokens, passwords, API keys, cookies, PII (SSN, passport, driver's license), financial data (credit cards, IBAN), phone numbers, and more.
The same redaction model is used beyond initial capture: supported exports, clipboard helpers, cURL generation, and observer payloads can pass through the shared redaction pipeline before data leaves the app/debug session.
Redaction works best together with focused capture. Keep body/header logging disabled when payload contents are not needed, and register project-specific keys for business identifiers that only your application understands.
Custom keys and patterns #
import 'package:ispectify/ispectify.dart';
final redactor = RedactionService(
sensitiveKeys: {
...defaultSensitiveKeys,
'x-custom-secret',
'internal_token',
},
sensitiveKeyPatterns: [
RegExp(r'my_app_secret_\w+', caseSensitive: false),
],
// Keys where the value is replaced entirely (not edge-masked).
fullyMaskedKeys: {'filename'},
placeholder: '***',
visibleEdgeLength: 3,
redactBinary: true,
redactBase64: true,
);
Ignoring defaults #
final redactor = RedactionService(
// e.g., ?mobile=true is a platform flag, not a phone number.
ignoredKeys: {'mobile', 'platform_token'},
ignoredValues: {'<test-token>', 'public-api-key'},
);
Disabling #
Each interceptor accepts enableRedaction: false on its settings object. See the per-package README for the exact settings type.
Only disable redaction in isolated local or deterministic test environments. Exported sessions and observer events should be handled according to the data they contain.
Custom redactor:
ISpectHttpInterceptor(
logger: logger,
redactor: RedactionService(
sensitiveKeys: {...defaultSensitiveKeys, 'x-internal-token'},
),
);
The ISpect toolkit #
ISpect is a modular monorepo. Install only what your project needs — each package works independently.
| Package | What it does |
|---|---|
ispect |
Flutter UI — debug panel, log viewer, navigation observer, inspector integration |
ispect_layout |
Visual layout inspector — sizes, constraints, decorations, compare mode, color picker |
ispectify |
Pure-Dart logging core — typed log entries, filtering, tracing, observers |
ispectify_dio |
Dio HTTP interceptor with automatic redaction |
ispectify_http |
http package interceptor with automatic redaction |
ispectify_ws |
WebSocket traffic capture with automatic redaction |
ispectify_db |
Database operation tracing (SQL, ORM, KV stores) |
ispectify_bloc |
BLoC event / state / transition observer |
Contributing #
Contributions are welcome. See CONTRIBUTING.md for guidelines, and open issues or pull requests at the ISpect repository.
License #
MIT — see LICENSE.