Skip to content

Network and Socket Interception

I don’t codddde edited this page Sep 13, 2026 · 1 revision

Network and Socket Interception

Allislet v1.0.0-alpha includes a robust interception layer for browser network traffic and realtime socket communication. This is one of the main reasons the SDK is useful as a debugging shell, automation overlay, or browser tooling suite.

Network interception goals

The network runtime exists to expose host-page traffic in a controlled and observable way. This includes:

  • fetch monitoring
  • XHR inspection
  • network mocking
  • socket connection tracking
  • bearer token extraction
  • request-level diagnostics

Fetch and XHR patching

The SDK provides patchFetch and patchXHR to intercept request flows from the target page.

patchFetch

This intercepts calls to fetch so the runtime can:

  • inspect URL and method
  • read response metadata
  • monitor latency
  • capture request bodies
  • rewrite or test special conditions

patchXHR

This is the XMLHTTPRequest path for older or legacy client code. It allows the SDK to observe or alter request flows that are not handled by fetch.

This matters in browser environments where:

  • older libraries still rely on XHR
  • auth flows use XMLHTTPRequest internally
  • testing harnesses need compatibility coverage

Request simulation and failure injection

The SDK includes NetworkMock to test flows under controlled conditions. Supporting patterns include:

  • silent200 responses
  • request dropping
  • latency injection
  • forced failure handling

These behaviors support debugging and validation without modifying the underlying app logic.

WebSocket manager

The WebSocketManager tracks the current set of socket connections and provides runtime operations to manage them.

Features include:

  • connection tracking
  • lockClosed behavior
  • forceDisconnect semantics
  • frame injection or sniffing for socket activity
  • connection state observation

This makes it possible to inspect or control live client communication in a highly targeted way.

SocketIoBridge

The SocketIoBridge handles integration with socket-based communication patterns, allowing app-level services to react to live socket events in a structured way.

This is important for:

  • realtime dashboards
  • DM or chat overlays
  • user notification flows
  • multi-client admin actions

Service worker and execution integration

The runtime can also coordinate service worker registration and lifecycle concerns through ServiceWorkerRegistrar.

This supports:

  • script caching patterns
  • background worker setup
  • controlled lifecycle management
  • runtime monitoring for injected app scenarios

CSP-safe script execution

Allislet includes CSPSafe injection logic to work with stricter Content Security Policy restrictions. This solves a common browser compatibility problem: even if the page blocks some forms of script injection, the SDK can still use safer injection strategies such as Blob-based execution paths.

The purpose is to maintain executable behavior without violating the host page’s security model.

Anti-detection and execution hardening

The runtime includes AntiDetect to reduce trigger patterns and simplify noise from browser instrumentation.

This includes:

  • stack trace stripping
  • global randomizers
  • environment-level obfuscation measures
  • safer runtime execution behavior

These mechanisms matter because browser automation and injected tooling can be noisy or easily fingerprinted if they are too obvious.

Bearer token extraction

BearerExtractor is designed to inspect request metadata and extract JWT or token-like values from request flows.

Use cases include:

  • runtime auth inspection
  • debugging authorization flows
  • controlled session analysis in trusted environments
  • integration with admin or debug views

Browser-level data capture

The network runtime is not only about observing requests. It also aligns with the broader runtime system that supports:

  • PageExecutor for script execution
  • ConsoleRedirector for logging capture
  • EventBus for cross-service observability
  • GlobalStorage for state memory

Together, these create an app-wide instrumentation layer for browser-level debugging.

Operational benefits

The network and socket interception system gives Allislet these advantages:

  • precise visibility into page communication
  • injectable runtime control for tests and devtools workflows
  • safer browser automation behavior
  • better debugging for realtime or auth-centric apps
  • structured support for admin and chat activity

Recommended use cases

Use this layer when you need to:

  • debug page requests and auth flows
  • monitor or shape socket traffic
  • test degraded network conditions
  • inspect browser interactions live
  • observe or patch application runtime behavior inside a protected host page

Summary

The network and socket layer turns Allislet into more than a UI shell. It gives the framework real browser instrumentation capabilities and turns the host page into a controlled execution environment where request flow, socket state, and runtime behavior can be observed and shaped.

Clone this wiki locally