← iOS device
iOS·Guide
All tools

iOS Device

An iPhone or iPad over USB (or Wi-Fi, once paired), through usbmuxd, the system daemon that owns iOS devices, and the local agent, which only connects to usbmuxd and runs TLS. The page shows the device's values, its apps (with entitlements), the media area and the containers of development-signed apps, a live syslog, crash reports and installed provisioning profiles, and sends them to the matching viewers.

The device must trust this computer: unlock it, connect it and tap Trust (on macOS, Finder does the pairing). The pair record usbmuxd keeps is what the page uses to start an encrypted lockdown session.

Contents

  1. The protocols
  2. The library: Usbmux, Lockdown, AfcClient (lib/idevice.js)

1The protocols

2The library: Usbmux, Lockdown, AfcClient (lib/idevice.js)

lib/idevice.js holds these protocols with no user interface, as a JavaScript module. It imports lib/plist.js itself and works on an agent connection (an Agent from lib/agent.js) offering unixConnect(path), tcpConnect(host, port, timeout) and sockets with send, startTls, close, ondata and onclose; tests/idevice-mock.js is a fake one with a fake device.

import { Usbmux, Lockdown, AfcClient, DeviceConnection } from "../lib/idevice.js";
MethodWhat it does
Usbmux.connect(agent)usbmuxd: mux.devices() → [{ id, udid, connection, productId, location }], mux.pairRecord(udid), mux.buid(), mux.connect(deviceId, port) (a DeviceConnection tunnelled to a port on the device).
Lockdown.open(mux, device)A lockdown session (reopened by itself when the device closes an idle one): getValue(domain, key), service(name) → a DeviceConnection, close(), pair, sessionId.
lockdown.apps(type)The apps ("User", "System" or "Any") with their bundle values, Entitlements, Path, Container, SignerIdentity.
lockdown.afc(name)An AfcClient (the media area by default).
lockdown.appContainer(bundleId){ afc, scope }: the whole container of a development build (get-task-allow), or the Documents of an app with file sharing.
lockdown.syslog(onLines)The live system log, line by line (octal escapes decoded); returns the connection to close().
lockdown.crashReports()An AfcClient on the crash reports, after asking the mover to gather them.
lockdown.profiles()The installed provisioning profiles: [{ data, name, uuid, team, appId, expires, entitlements, devices, allDevices }].
Lockdown.errorText(code)A lockdown error code in words.
new AfcClient(connection)AFC on a service connection: list(path), info(path) → { size, type, dir, link, mtime, target }, dir(path), read(path, onProgress), write(path, bytes), mkdir(path), close().
new DeviceConnection(socket)A buffered connection over an agent socket: read(length) (exactly that many bytes), stream(onData), write(bytes), startTls({ cert, key }), close(), onclose, socket.
import { Usbmux, Lockdown } from "../lib/idevice.js";

const mux = await Usbmux.connect(agent);
const [device] = await mux.devices();
const lockdown = await Lockdown.open(mux, device);
console.log((await lockdown.getValue()).ProductVersion);
const apps = await lockdown.apps("User");
const { afc } = await lockdown.appContainer("com.example.app");
const preferences = await afc.read("/Library/Preferences/com.example.app.plist");