|
1 |
| -# usbmux-client |
2 |
| -A pure-js Node.js library for communicating with iPhones over USB via usbmux |
| 1 | +# Usbmux-Client [](https://github.com/httptoolkit/usbmux-client/actions) [](https://npmjs.com/package/usbmux-client) |
| 2 | + |
| 3 | +> _Part of [HTTP Toolkit](https://httptoolkit.com): powerful tools for building, testing & debugging HTTP(S)_ |
| 4 | +
|
| 5 | +A pure-js Node.js library for communicating with iPhones over USB via usbmux, with a pure-JS solution for Node.js that works on all platforms. |
| 6 | + |
| 7 | +This provides fully cross-platform access to iOS devices, supporting the usbmuxd daemon built into iTunes on Windows & Mac, and the libimobiledevice implementation on Linux. |
| 8 | + |
| 9 | +This is used within HTTP Toolkit to connect to TCP ports on a connected iPhone via USB, primarily to communicate with Frida using [Frida-JS](https://github.com/httptoolkit/frida-js/). It's currently focused on the core features required for that use case, but PRs to add support for more features are welcome. Right now it supports: |
| 10 | + |
| 11 | +* Monitoring the list of connected devices |
| 12 | +* Querying the metadata for any connected device (to get the device name, device type, UDID, architecture, etc) |
| 13 | +* Opening a direct connection to any port on the device itself |
| 14 | + |
| 15 | +## Example |
| 16 | + |
| 17 | +```javascript |
| 18 | +import { UsbmuxClient } from 'usbmux-client'; |
| 19 | + |
| 20 | +const client = new UsbmuxClient(); |
| 21 | + |
| 22 | +const devices = await client.getDevices(); |
| 23 | +// Returns a map from id to basic data like { |
| 24 | +// "1": { ConnectionType: "USB", DeviceId: "1", ... } |
| 25 | +// } |
| 26 | + |
| 27 | +const firstDeviceId = Object.keys(devices)[0]; |
| 28 | +const deviceMetadata = await client.queryAllDeviceValues(firstDeviceId); |
| 29 | +// Returns detailed data like { DeviceClass: "iPhone", DeviceName: "Alice's iPhone", ... } |
| 30 | + |
| 31 | +// Returns a net.Socket connected to the given port on the target device: |
| 32 | +const conn = await client.createDeviceTunnel(firstDeviceId, 1234); |
| 33 | +``` |
0 commit comments