@mcesystems/apple-kit 1.0.32 → 1.0.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/README.md +284 -284
  2. package/dist/index.js.map +1 -1
  3. package/dist/index.mjs.map +1 -1
  4. package/dist/types/utils/portManager.d.ts +68 -0
  5. package/dist/types/utils/portManager.d.ts.map +1 -0
  6. package/package.json +1 -1
  7. package/scripts/README.md +209 -209
  8. package/scripts/build-windows.sh.template +134 -134
  9. package/scripts/export-resources.mts +856 -690
  10. package/dist/resources/bin/darwin/idevice_id +0 -0
  11. package/dist/resources/bin/darwin/idevicedebug +0 -0
  12. package/dist/resources/bin/darwin/idevicediagnostics +0 -0
  13. package/dist/resources/bin/darwin/ideviceinfo +0 -0
  14. package/dist/resources/bin/darwin/ideviceinstaller +0 -0
  15. package/dist/resources/bin/darwin/idevicename +0 -0
  16. package/dist/resources/bin/darwin/idevicepair +0 -0
  17. package/dist/resources/bin/darwin/idevicescreenshot +0 -0
  18. package/dist/resources/bin/darwin/idevicesyslog +0 -0
  19. package/dist/resources/bin/darwin/iproxy +0 -0
  20. package/dist/resources/bin/darwin/libcrypto.3.dylib +0 -0
  21. package/dist/resources/bin/darwin/libimobiledevice-1.0.6.dylib +0 -0
  22. package/dist/resources/bin/darwin/libimobiledevice-glue-1.0.0.dylib +0 -0
  23. package/dist/resources/bin/darwin/liblzma.5.dylib +0 -0
  24. package/dist/resources/bin/darwin/libplist-2.0.4.dylib +0 -0
  25. package/dist/resources/bin/darwin/libssl.3.dylib +0 -0
  26. package/dist/resources/bin/darwin/libusbmuxd-2.0.7.dylib +0 -0
  27. package/dist/resources/bin/darwin/libzip.5.dylib +0 -0
  28. package/dist/resources/bin/darwin/libzstd.1.dylib +0 -0
  29. package/dist/resources/licenses/LGPL-2.1.txt +0 -33
package/README.md CHANGED
@@ -1,284 +1,284 @@
1
- # @mcesystems/apple-kit
2
-
3
- iOS device management toolkit using libimobiledevice command-line tools. Provides device detection, app installation/uninstallation, port forwarding, activation, and device property access.
4
-
5
- ## Features
6
-
7
- - **Device Detection**: Monitor iOS device connections via USB plug-and-play
8
- - **App Management**: Install and uninstall iOS applications (.ipa files)
9
- - **Launch Apps**: Start applications on the device
10
- - **Port Forwarding**: Forward local ports to device ports (for debugging, etc.)
11
- - **Device Activation**: Check and manage device activation state
12
- - **Trust/Pairing**: Handle device trust and pairing
13
- - **Device Info**: Access device properties (name, model, iOS version, UDID, etc.)
14
- - **Cross-platform**: Works on Windows, macOS, and Linux
15
-
16
- ## Installation
17
-
18
- ```bash
19
- npm install @mcesystems/apple-kit
20
- ```
21
-
22
- ## Requirements
23
-
24
- - Node.js 18+
25
- - iOS device connected via USB
26
- - Device must be trusted/paired with the computer
27
-
28
- ### Platform-specific Requirements
29
-
30
- #### Windows
31
- - libimobiledevice binaries - use the export script (see below)
32
- - iTunes installed OR Apple Mobile Device Support
33
-
34
- #### macOS
35
- **Option 1: Use bundled binaries (recommended for distribution)**
36
-
37
- Use the export script to bundle binaries for your application:
38
- ```bash
39
- # Using npx (after installing the package)
40
- npx export-apple-resources /path/to/your-app/resources/apple-kit
41
-
42
- # Or run the script directly
43
- npx tsx node_modules/@mcesystems/apple-kit/scripts/export-resources.ts /path/to/your-app/resources
44
- ```
45
-
46
- See [scripts/README.md](./scripts/README.md) for detailed prerequisites and instructions.
47
-
48
- **Option 2: Use Homebrew installation (for development)**
49
- - Install via Homebrew: `brew install libimobiledevice ideviceinstaller`
50
- - Tools are auto-detected from `/opt/homebrew/bin` (Apple Silicon) or `/usr/local/bin` (Intel)
51
-
52
- #### Linux
53
- - libimobiledevice-utils: `sudo apt install libimobiledevice-utils`
54
- - Tools are auto-detected from `/usr/bin` or `/usr/local/bin`
55
-
56
- ### Binary Resolution Order
57
-
58
- The package looks for idevice tools in this order:
59
- 1. `IDeviceBinPath` environment variable (for custom paths)
60
- 2. Bundled resources in your app's `resources/bin/{platform}/` directory
61
- 3. Homebrew paths on macOS (`/opt/homebrew/bin`, `/usr/local/bin`)
62
- 4. System PATH (for global installations)
63
-
64
- ## Usage
65
-
66
- ### Device Monitoring
67
-
68
- ```typescript
69
- import { DevicesMonitor } from '@mcesystems/apple-kit';
70
-
71
- const monitor = new DevicesMonitor({
72
- logicalPortMap: {
73
- "Port_#0005.Hub_#0002": 1,
74
- "Port_#0006.Hub_#0002": 2
75
- }
76
- });
77
-
78
- const events = await monitor.startTracking();
79
-
80
- events.on('added', async (deviceKit) => {
81
- console.log(`iOS device connected: ${deviceKit.getDeviceId()}`);
82
- const info = await deviceKit.getDeviceInfo();
83
- console.log(` ${info.deviceName} - iOS ${info.productVersion}`);
84
- });
85
-
86
- events.on('removed', (deviceId, port) => {
87
- console.log(`iOS device disconnected: ${deviceId}`);
88
- });
89
-
90
- // Later: stop monitoring
91
- await monitor.stopTracking();
92
- ```
93
-
94
- ### Install/Uninstall Agent
95
-
96
- ```typescript
97
- import { AppleDeviceKit } from '@mcesystems/apple-kit';
98
-
99
- const device = new AppleDeviceKit('device-udid', 1);
100
-
101
- // Install an agent/app
102
- await device.installApp('/path/to/agent.ipa');
103
-
104
- // Check if installed
105
- const isInstalled = await device.isAppInstalled('com.example.agent');
106
-
107
- // List all installed apps
108
- const apps = await device.listApps();
109
-
110
- // Uninstall an agent/app
111
- await device.uninstallApp('com.example.agent');
112
- ```
113
-
114
- ### Device Info
115
-
116
- ```typescript
117
- const device = new AppleDeviceKit('device-udid', 1);
118
-
119
- const info = await device.getDeviceInfo();
120
- console.log(`Device: ${info.deviceName}`);
121
- console.log(`Model: ${info.productType}`);
122
- console.log(`iOS: ${info.productVersion} (${info.buildVersion})`);
123
- console.log(`Serial: ${info.serialNumber}`);
124
- console.log(`UDID: ${info.udid}`);
125
- ```
126
-
127
- ### Trust/Pairing
128
-
129
- ```typescript
130
- const device = new AppleDeviceKit('device-udid', 1);
131
-
132
- // Check if device is trusted
133
- const isPaired = await device.isPaired();
134
-
135
- // Initiate pairing (user must accept on device)
136
- await device.pair();
137
-
138
- // Wait for user to accept trust dialog
139
- await device.waitForPairing(60000); // 60 second timeout
140
-
141
- // Unpair device
142
- await device.unpair();
143
- ```
144
-
145
- ### Launch Application
146
-
147
- ```typescript
148
- const device = new AppleDeviceKit('device-udid', 1);
149
-
150
- // Launch an app
151
- await device.launchApp('com.example.myapp');
152
-
153
- // Launch with arguments
154
- await device.launchApp('com.example.myapp', ['--debug', '--port=8080']);
155
- ```
156
-
157
- ### Port Forwarding
158
-
159
- ```typescript
160
- const device = new AppleDeviceKit('device-udid', 1);
161
-
162
- // Forward local port 8080 to device port 8080
163
- const forward = device.startPortForward(8080, 8080);
164
-
165
- // Use the forwarded connection...
166
- // connect to localhost:8080 to reach device:8080
167
-
168
- // Stop forwarding when done
169
- forward.stop();
170
-
171
- // Or use async version that waits for ready
172
- const forwardAsync = await device.startPortForwardAsync(8080, 8080);
173
- ```
174
-
175
- ### Activation
176
-
177
- ```typescript
178
- const device = new AppleDeviceKit('device-udid', 1);
179
-
180
- // Get activation state
181
- const state = await device.getActivationState();
182
- console.log(`Activated: ${state.isActivated}`);
183
- console.log(`State: ${state.activationState}`);
184
-
185
- // Activate device (requires valid activation record)
186
- await device.activate();
187
-
188
- // Deactivate device
189
- await device.deactivate();
190
- ```
191
-
192
- ### Running Without iTunes (usbmuxd)
193
-
194
- On Windows, iTunes provides the Apple Mobile Device Service for USB communication. If you don't have iTunes installed, you can run the bundled `usbmuxd`:
195
-
196
- ```typescript
197
- import { startUsbmuxd, stopUsbmuxd, ensureUsbmuxd } from '@mcesystems/apple-kit';
198
-
199
- // Start usbmuxd daemon (required if iTunes is not installed)
200
- const daemon = startUsbmuxd();
201
-
202
- // Or ensure it's running (starts if not already running)
203
- ensureUsbmuxd();
204
-
205
- // Now you can use device operations...
206
- const devices = await AppleDeviceKit.listDevices();
207
-
208
- // When done, stop the daemon
209
- stopUsbmuxd();
210
- // or
211
- daemon.stop();
212
- ```
213
-
214
- **Note:** The usbmuxd daemon must be running before connecting devices. Start it before plugging in your iOS device.
215
-
216
- ## API Reference
217
-
218
- ### AppleDeviceKit
219
-
220
- **Static methods:**
221
- - `listDevices()`: Get all connected iOS devices
222
-
223
- **Device Info:**
224
- - `getDeviceInfo()`: Get device properties
225
- - `getDeviceId()`: Get the device UDID
226
- - `getPort()`: Get the logical port number
227
-
228
- **App Management:**
229
- - `installApp(ipaPath)`: Install an IPA file
230
- - `uninstallApp(bundleId)`: Uninstall an app by bundle ID
231
- - `isAppInstalled(bundleId)`: Check if app is installed
232
- - `listApps()`: List all installed user apps
233
- - `launchApp(bundleId, args?)`: Launch an application
234
-
235
- **Trust/Pairing:**
236
- - `isPaired()`: Check if device is paired/trusted
237
- - `pair()`: Initiate pairing (user must accept on device)
238
- - `unpair()`: Remove pairing/trust
239
- - `waitForPairing(timeout?)`: Wait for device to be paired
240
-
241
- **Port Forwarding:**
242
- - `startPortForward(localPort, devicePort)`: Start port forwarding
243
- - `startPortForwardAsync(localPort, devicePort)`: Start and wait for ready
244
-
245
- **Activation:**
246
- - `getActivationState()`: Get activation state
247
- - `activate()`: Activate the device
248
- - `deactivate()`: Deactivate the device
249
-
250
- ### DevicesMonitor
251
-
252
- - `startTracking()`: Start monitoring for iOS device connections
253
- - `stopTracking()`: Stop monitoring
254
- - `getKits()`: Get all currently tracked devices
255
- - `getKit(udid)`: Get a specific device kit by UDID
256
-
257
- ### usbmuxd Functions
258
-
259
- - `startUsbmuxd(foreground?)`: Start the usbmuxd daemon
260
- - `stopUsbmuxd()`: Stop the daemon
261
- - `isUsbmuxdRunning()`: Check if daemon is running
262
- - `ensureUsbmuxd()`: Start if not already running
263
-
264
- ### Types
265
-
266
- ```typescript
267
- interface PortForwardHandle {
268
- stop: () => void;
269
- localPort: number;
270
- devicePort: number;
271
- process: ChildProcess;
272
- }
273
-
274
- interface ActivationState {
275
- isActivated: boolean;
276
- activationState: string;
277
- }
278
- ```
279
-
280
- ## License
281
-
282
- ISC
283
-
284
- libimobiledevice is licensed under LGPL-2.1.
1
+ # @mcesystems/apple-kit
2
+
3
+ iOS device management toolkit using libimobiledevice command-line tools. Provides device detection, app installation/uninstallation, port forwarding, activation, and device property access.
4
+
5
+ ## Features
6
+
7
+ - **Device Detection**: Monitor iOS device connections via USB plug-and-play
8
+ - **App Management**: Install and uninstall iOS applications (.ipa files)
9
+ - **Launch Apps**: Start applications on the device
10
+ - **Port Forwarding**: Forward local ports to device ports (for debugging, etc.)
11
+ - **Device Activation**: Check and manage device activation state
12
+ - **Trust/Pairing**: Handle device trust and pairing
13
+ - **Device Info**: Access device properties (name, model, iOS version, UDID, etc.)
14
+ - **Cross-platform**: Works on Windows, macOS, and Linux
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ npm install @mcesystems/apple-kit
20
+ ```
21
+
22
+ ## Requirements
23
+
24
+ - Node.js 18+
25
+ - iOS device connected via USB
26
+ - Device must be trusted/paired with the computer
27
+
28
+ ### Platform-specific Requirements
29
+
30
+ #### Windows
31
+ - libimobiledevice binaries - use the export script (see below)
32
+ - iTunes installed OR Apple Mobile Device Support
33
+
34
+ #### macOS
35
+ **Option 1: Use bundled binaries (recommended for distribution)**
36
+
37
+ Use the export script to bundle binaries for your application:
38
+ ```bash
39
+ # Using npx (after installing the package)
40
+ npx export-apple-resources /path/to/your-app/resources/apple-kit
41
+
42
+ # Or run the script directly
43
+ npx tsx node_modules/@mcesystems/apple-kit/scripts/export-resources.ts /path/to/your-app/resources
44
+ ```
45
+
46
+ See [scripts/README.md](./scripts/README.md) for detailed prerequisites and instructions.
47
+
48
+ **Option 2: Use Homebrew installation (for development)**
49
+ - Install via Homebrew: `brew install libimobiledevice ideviceinstaller`
50
+ - Tools are auto-detected from `/opt/homebrew/bin` (Apple Silicon) or `/usr/local/bin` (Intel)
51
+
52
+ #### Linux
53
+ - libimobiledevice-utils: `sudo apt install libimobiledevice-utils`
54
+ - Tools are auto-detected from `/usr/bin` or `/usr/local/bin`
55
+
56
+ ### Binary Resolution Order
57
+
58
+ The package looks for idevice tools in this order:
59
+ 1. `IDeviceBinPath` environment variable (for custom paths)
60
+ 2. Bundled resources in your app's `resources/bin/{platform}/` directory
61
+ 3. Homebrew paths on macOS (`/opt/homebrew/bin`, `/usr/local/bin`)
62
+ 4. System PATH (for global installations)
63
+
64
+ ## Usage
65
+
66
+ ### Device Monitoring
67
+
68
+ ```typescript
69
+ import { DevicesMonitor } from '@mcesystems/apple-kit';
70
+
71
+ const monitor = new DevicesMonitor({
72
+ logicalPortMap: {
73
+ "Port_#0005.Hub_#0002": 1,
74
+ "Port_#0006.Hub_#0002": 2
75
+ }
76
+ });
77
+
78
+ const events = await monitor.startTracking();
79
+
80
+ events.on('added', async (deviceKit) => {
81
+ console.log(`iOS device connected: ${deviceKit.getDeviceId()}`);
82
+ const info = await deviceKit.getDeviceInfo();
83
+ console.log(` ${info.deviceName} - iOS ${info.productVersion}`);
84
+ });
85
+
86
+ events.on('removed', (deviceId, port) => {
87
+ console.log(`iOS device disconnected: ${deviceId}`);
88
+ });
89
+
90
+ // Later: stop monitoring
91
+ await monitor.stopTracking();
92
+ ```
93
+
94
+ ### Install/Uninstall Agent
95
+
96
+ ```typescript
97
+ import { AppleDeviceKit } from '@mcesystems/apple-kit';
98
+
99
+ const device = new AppleDeviceKit('device-udid', 1);
100
+
101
+ // Install an agent/app
102
+ await device.installApp('/path/to/agent.ipa');
103
+
104
+ // Check if installed
105
+ const isInstalled = await device.isAppInstalled('com.example.agent');
106
+
107
+ // List all installed apps
108
+ const apps = await device.listApps();
109
+
110
+ // Uninstall an agent/app
111
+ await device.uninstallApp('com.example.agent');
112
+ ```
113
+
114
+ ### Device Info
115
+
116
+ ```typescript
117
+ const device = new AppleDeviceKit('device-udid', 1);
118
+
119
+ const info = await device.getDeviceInfo();
120
+ console.log(`Device: ${info.deviceName}`);
121
+ console.log(`Model: ${info.productType}`);
122
+ console.log(`iOS: ${info.productVersion} (${info.buildVersion})`);
123
+ console.log(`Serial: ${info.serialNumber}`);
124
+ console.log(`UDID: ${info.udid}`);
125
+ ```
126
+
127
+ ### Trust/Pairing
128
+
129
+ ```typescript
130
+ const device = new AppleDeviceKit('device-udid', 1);
131
+
132
+ // Check if device is trusted
133
+ const isPaired = await device.isPaired();
134
+
135
+ // Initiate pairing (user must accept on device)
136
+ await device.pair();
137
+
138
+ // Wait for user to accept trust dialog
139
+ await device.waitForPairing(60000); // 60 second timeout
140
+
141
+ // Unpair device
142
+ await device.unpair();
143
+ ```
144
+
145
+ ### Launch Application
146
+
147
+ ```typescript
148
+ const device = new AppleDeviceKit('device-udid', 1);
149
+
150
+ // Launch an app
151
+ await device.launchApp('com.example.myapp');
152
+
153
+ // Launch with arguments
154
+ await device.launchApp('com.example.myapp', ['--debug', '--port=8080']);
155
+ ```
156
+
157
+ ### Port Forwarding
158
+
159
+ ```typescript
160
+ const device = new AppleDeviceKit('device-udid', 1);
161
+
162
+ // Forward local port 8080 to device port 8080
163
+ const forward = device.startPortForward(8080, 8080);
164
+
165
+ // Use the forwarded connection...
166
+ // connect to localhost:8080 to reach device:8080
167
+
168
+ // Stop forwarding when done
169
+ forward.stop();
170
+
171
+ // Or use async version that waits for ready
172
+ const forwardAsync = await device.startPortForwardAsync(8080, 8080);
173
+ ```
174
+
175
+ ### Activation
176
+
177
+ ```typescript
178
+ const device = new AppleDeviceKit('device-udid', 1);
179
+
180
+ // Get activation state
181
+ const state = await device.getActivationState();
182
+ console.log(`Activated: ${state.isActivated}`);
183
+ console.log(`State: ${state.activationState}`);
184
+
185
+ // Activate device (requires valid activation record)
186
+ await device.activate();
187
+
188
+ // Deactivate device
189
+ await device.deactivate();
190
+ ```
191
+
192
+ ### Running Without iTunes (usbmuxd)
193
+
194
+ On Windows, iTunes provides the Apple Mobile Device Service for USB communication. If you don't have iTunes installed, you can run the bundled `usbmuxd`:
195
+
196
+ ```typescript
197
+ import { startUsbmuxd, stopUsbmuxd, ensureUsbmuxd } from '@mcesystems/apple-kit';
198
+
199
+ // Start usbmuxd daemon (required if iTunes is not installed)
200
+ const daemon = startUsbmuxd();
201
+
202
+ // Or ensure it's running (starts if not already running)
203
+ ensureUsbmuxd();
204
+
205
+ // Now you can use device operations...
206
+ const devices = await AppleDeviceKit.listDevices();
207
+
208
+ // When done, stop the daemon
209
+ stopUsbmuxd();
210
+ // or
211
+ daemon.stop();
212
+ ```
213
+
214
+ **Note:** The usbmuxd daemon must be running before connecting devices. Start it before plugging in your iOS device.
215
+
216
+ ## API Reference
217
+
218
+ ### AppleDeviceKit
219
+
220
+ **Static methods:**
221
+ - `listDevices()`: Get all connected iOS devices
222
+
223
+ **Device Info:**
224
+ - `getDeviceInfo()`: Get device properties
225
+ - `getDeviceId()`: Get the device UDID
226
+ - `getPort()`: Get the logical port number
227
+
228
+ **App Management:**
229
+ - `installApp(ipaPath)`: Install an IPA file
230
+ - `uninstallApp(bundleId)`: Uninstall an app by bundle ID
231
+ - `isAppInstalled(bundleId)`: Check if app is installed
232
+ - `listApps()`: List all installed user apps
233
+ - `launchApp(bundleId, args?)`: Launch an application
234
+
235
+ **Trust/Pairing:**
236
+ - `isPaired()`: Check if device is paired/trusted
237
+ - `pair()`: Initiate pairing (user must accept on device)
238
+ - `unpair()`: Remove pairing/trust
239
+ - `waitForPairing(timeout?)`: Wait for device to be paired
240
+
241
+ **Port Forwarding:**
242
+ - `startPortForward(localPort, devicePort)`: Start port forwarding
243
+ - `startPortForwardAsync(localPort, devicePort)`: Start and wait for ready
244
+
245
+ **Activation:**
246
+ - `getActivationState()`: Get activation state
247
+ - `activate()`: Activate the device
248
+ - `deactivate()`: Deactivate the device
249
+
250
+ ### DevicesMonitor
251
+
252
+ - `startTracking()`: Start monitoring for iOS device connections
253
+ - `stopTracking()`: Stop monitoring
254
+ - `getKits()`: Get all currently tracked devices
255
+ - `getKit(udid)`: Get a specific device kit by UDID
256
+
257
+ ### usbmuxd Functions
258
+
259
+ - `startUsbmuxd(foreground?)`: Start the usbmuxd daemon
260
+ - `stopUsbmuxd()`: Stop the daemon
261
+ - `isUsbmuxdRunning()`: Check if daemon is running
262
+ - `ensureUsbmuxd()`: Start if not already running
263
+
264
+ ### Types
265
+
266
+ ```typescript
267
+ interface PortForwardHandle {
268
+ stop: () => void;
269
+ localPort: number;
270
+ devicePort: number;
271
+ process: ChildProcess;
272
+ }
273
+
274
+ interface ActivationState {
275
+ isActivated: boolean;
276
+ activationState: string;
277
+ }
278
+ ```
279
+
280
+ ## License
281
+
282
+ ISC
283
+
284
+ libimobiledevice is licensed under LGPL-2.1.