ispectify_ws 5.0.0-dev34 copy "ispectify_ws: ^5.0.0-dev34" to clipboard
ispectify_ws: ^5.0.0-dev34 copied to clipboard

WebSocket diagnostics for ISpect with connection lifecycle, sent and received frame logging, grouping, and redaction.

ispectify_ws is a WebSocket interceptor for the ISpect toolkit, built on top of the ws client. It captures every sent/received frame, exposes connection lifecycle events, and redacts sensitive data before logging.

  • Frame-level capture for sent and received messages.
  • Error and close-event logging with stack traces.
  • Pluggable redaction — reuses the same engine as the HTTP interceptors.

Install #

dependencies:
  ws: ^1.0.0
  ispectify: ^5.0.0-dev34
  ispectify_ws: ^5.0.0-dev34

Quick start #

import 'package:ws/ws.dart';
import 'package:ispect/ispect.dart';
import 'package:ispectify_ws/ispectify_ws.dart';

final interceptor = ISpectWSInterceptor(
  logger: logger,
  settings: const ISpectWSInterceptorSettings(
    enabled: true,
    printSentData: true,
    printReceivedData: true,
    printReceivedMessage: true,
    printErrorData: true,
    printErrorMessage: true,
  ),
);

final client = WebSocketClient(
  WebSocketOptions.common(interceptors: [interceptor]),
);

// The interceptor needs a back-reference to the client for lifecycle events.
interceptor.setClient(client);

Settings #

const settings = ISpectWSInterceptorSettings(
  enabled: true,
  printSentData: true,
  printReceivedData: true,
  printReceivedMessage: true,
  printErrorData: true,
  printErrorMessage: true,
  enableRedaction: true,
);

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.

Redaction is a safety layer, not a substitute for data minimization. Prefer disabling body/header capture when payload contents are not needed, and add 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 treated as sensitive artifacts even when redaction is enabled.

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.


0
likes
0
points
2.03k
downloads

Publisher

verified publishershodev.live

Weekly Downloads

WebSocket diagnostics for ISpect with connection lifecycle, sent and received frame logging, grouping, and redaction.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

ispectify, ws

More

Packages that depend on ispectify_ws