Home
Softono
wiretapKMP

wiretapKMP

Open source Apache-2.0 Kotlin
68
Stars
1
Forks
7
Issues
0
Watchers
1 week
Last Commit

About wiretapKMP

Kotlin Multiplatform library for network inspection and mocking. Intercept HTTP and WebSocket traffic, mock API responses, and throttle requests.

Platforms

Web Self-hosted iOS Android

Languages

Kotlin

WiretapKMP β€” Powerful, Cross-Platform Network Inspection for Kotlin Multiplatform

Build Coverage Maven Central

WiretapKMP is a drop-in network inspector and mocker for Kotlin Multiplatform apps. Add one dependency, install the plugin, and inspect every HTTP request, WebSocket message, and SSE event β€” or mock and throttle them β€” all from a built-in UI. No proxy needed.

Early Preview β€” We're looking for early adopters and feedback! Open an issue or start a discussion.

πŸš€ Quick Start

// Ktor
val client = HttpClient {
    install(WiretapKtorHttpPlugin)
}

// OkHttp
val client = OkHttpClient.Builder()
    .addInterceptor(WiretapOkHttpInterceptor())
    .build()

That's it. Open your app and shake the device (or press Ctrl+Shift+D on desktop) to launch the inspector.

βœ… What You Get

HTTP WebSocket SSE
Ktor βœ… βœ… βœ…
OkHttp βœ… βœ… βœ…
URLSession βœ… β€” β€”
Android iOS JVM Desktop
Ktor βœ… βœ… βœ…
OkHttp βœ… β€” βœ…
URLSession β€” βœ… β€”

πŸ“Έ Screenshots

Overview Request Response
WebSocket Messages Notifications

⭐ Key Features

  • Zero-config logging β€” install the plugin and all traffic is captured automatically
  • API mocking β€” return fake responses without hitting the network. Match on method, URL, headers, and body
  • Request throttling β€” simulate slow connections with fixed or random delays
  • Header masking β€” redact Authorization, Cookie, or any sensitive header from logs
  • Shake to launch β€” built-in gesture to open the inspector (no UI code required)
  • No-op variants β€” swap to wiretap-ktor-noop / wiretap-okhttp-noop for release builds with zero overhead
  • Share as file β€” export any log entry via the platform share sheet
More screenshots

API Mocking & Rules Engine

Mocked Requests Mock Rule Rules List

List-Detail Pane (Tablet / Desktop)

πŸ“‘ SSE Inspection (Experimental)

WiretapKMP can inspect Server-Sent Events (SSE) streams β€” log every connection, event, and status change right alongside your HTTP and WebSocket traffic.

⚠️ SSE inspection is in early preview. APIs are marked with @ExperimentalWiretapSseApi and may change in future releases.

Ktor

Install the SSE plugin β€” sessions are wrapped automatically:

@OptIn(ExperimentalWiretapSseApi::class)
val client = HttpClient {
    install(SSE)
    install(WiretapKtorSsePlugin)    // SSE logging
    install(WiretapKtorHttpPlugin)   // HTTP logging
}

client.sse("https://api.example.com/stream") {
    incoming.collect { event ->
        println("Event: ${event.event} β€” ${event.data}")
    }
}

OkHttp

Wrap your EventSourceListener with .wiretapped():

val client = OkHttpClient.Builder()
    .addInterceptor(WiretapOkHttpInterceptor())
    .build()

val request = Request.Builder().url("https://api.example.com/stream").build()
val factory = EventSources.createFactory(client)

@OptIn(ExperimentalWiretapSseApi::class)
factory.newEventSource(request, myListener.wiretapped())

What Gets Logged

Connection Events
URL, headers, status (Open β†’ Closed/Failed), timestamps Event type, data payload, event ID, byte count, timestamp

For full details, see the Ktor SSE guide and OkHttp SSE guide.

πŸ“¦ Installation

// build.gradle.kts
debugImplementation("dev.skymansandy:wiretap-ktor:1.0.0-RC15")
releaseImplementation("dev.skymansandy:wiretap-ktor-noop:1.0.0-RC15")

// or for OkHttp
debugImplementation("dev.skymansandy:wiretap-okhttp:1.0.0-RC15")
releaseImplementation("dev.skymansandy:wiretap-okhttp-noop:1.0.0-RC15")

For full setup including URLSession and advanced configuration, see the Getting Started guide.

πŸ“– Documentation

Full docs Β· Getting Started Β· API Reference

🀝 Contributing

Contributions are welcome! Fork the repo, create a feature branch, and open a PR.

πŸ™ Acknowledgements

Kotlin Multiplatform Β· Compose Multiplatform Β· Ktor Β· Room Β· Koin Β· OkHttp Β· SKIE Β· KMMBridge