npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

libijs

v0.1.3

Published

A node.js library for communicating with iOS devices over USB.

Downloads

5

Readme

libijs

A node.js library for communicating with iOS devices over USB.

This is a pure javascript implementation of libimobiledevice, implementing everything needed for communicating with iOS device services through usbmuxd (the dameon\service responsible for communication with iOS devices over USB). Our goal is to evantually provide most of libimobiledevice's functionality, in an API suitable for node.js.

Note that libijs is still an early proof of concept, and is not ready for production yet.

Features

  • Provides a convenient node.js API for communicating with iOS devices and their services over usbmuxd.
  • Provides base classes for implementing more services, like the PropertyListService class.
  • Implements several ready to use command line tools.

Current status

  • usbmux (client): All known functionality is implemented
  • lockdownd:
    • Implemented commands:
      • QueryType
      • StartSession\StopSession
      • StartService
      • GetValue\SetValue\RemoveValue
    • Pairing, which is handled by usbmuxd, is not implemented (yet).
  • Implemented Services:
    • afc:
      • Multiplexes requests over a single connection to the afc service. Combined with node's async nature, this introduces a major performance improvment over libimobiledevice's afc client.
      • Provides a convient native interface:
        • node.js stream interface for reading\writing remote files
        • Walking remote dirs
    • diagnostics_relay
    • installation_proxy
    • MCInstall
    • mobileactivationd
    • mobilebackup2
    • notification_proxy
    • springboardservices
    • syslog_relay
  • Tools:
    • apps: similar to ideviceinstaller. Currently supports listing, installing (excluding ipcc) and uninstalling apps
    • backup: similar to libimobiledevice's idevicebackup2.c, currently supports only backup & restore operations
    • diagnostics: similar to libimobiledevice's idevicediagnostics
    • info: similar to libimobiledevice's ideviceinfo
    • syslog: similar to libimobiledevice's idevicesyslog

Installation

Simply install using npm\yarn:

npm install libijs

or

yarn add libijs

Implementation Details

  • The deviceManager uses one permanent usbmuxd connection for device listing and monitoring. Thus, the deviceManager will always maintain an updated list of connected devices, reducing the overhead of querying usbmuxd each time a device list is needed.
  • AFC implementation uses the "packet number" to track requests\responses, enabling it to send multiple requests simultaneously. For example, when downloading a remote folder, "download file" requests are sent while "walking" the remote folder, which seems to greatly improve performance.
  • We use our own implementations for the usbmux client and binary plist handling.
  • Instead of using Promises and EventEmitters, we use our internal JarvisEmitter.

Usage\API examples

TODO

Examples

  • Connect to lockdownd and query a value:

    const libijs = require("libijs");
    const meaco = require("meaco");
      
    const udid = ...;
      
    const queryDeviceVersion = function queryDevice(device) {
    	return meaco(function* doQueryDevice() {
    		// Connect to lockdownd
    		const lockdownClient = yield libijs.lockdownd.getClient(device);
      		
    		// Query the device type and iOS version
    		const productType = yield lockdownClient.getValue(null, "ProductType");
    		const iosVersion = yield lockdownClient.getValue(null, "ProductVersion");
    		console.log(`${productType} device running iOS ${iosVersion}`);
      		
    		yield lockdownClient.close();
    	});
    };
      
    const deviceManager = libijs.createClient().deviceManager;
    deviceManager.ready(() => {
    	const device = deviceManager.getDevice(udid);
    	if (device) {
    		queryDeviceVersion(device);
    	} else {
    		console.log("Couldn't find device");
    	}
    });
  • Download a file using the AFC stream API:

    const libijs = require("libijs");
    const meaco = require("meaco");
    const JarvisEmitter = require("jarvis-emitter");
    const fs = require("fs");
    
    const udid = ...;
    
    const afcExample = function afcExample(afcClient) {
    	return meaco(function* doAfcExample() {
    		// List a remote dir
    		yield afcClient.walk("/", false, true)
    			.item((item) => { console.log(`${item.relativeToRoot} - ${item.stats.st_size} bytes`); });
    
    		// Download a file
    		yield afcClient.downloadFile("DCIM/100APPLE/IMG_0001.JPG", "./IMG_0001.JPG");
    
    		// Use the stream api to read a file
    		console.log("\nVoiceMemos.plist:");
    		const remoteFile = yield afcClient.openFileAsReadableStream("iTunes_Control/iTunes/VoiceMemos.plist");
    		const fileReadDone = new JarvisEmitter();
    		remoteFile
    			.on("data", (data) => {
    				console.log(data.toString());
    			})
    			.on("end", () => {
    				fileReadDone.callDone();
    			});
    		yield fileReadDone;
    
    		// Disconnect from the afcd service
    		yield afcClient.close();
    	});
    };
    
    const deviceManager = libijs.createClient().deviceManager;
    deviceManager.ready(() => {
    	const device = deviceManager.getDevice();
    	libijs.services.getService(device, "afc").done(afcExample);
    });

Legal

libijs is licensed under the MIT license.
Apple, iTunes, iPhone, iPad, Apple Watch, iPod, and iPod Touch are trademarks of Apple Inc.