@mcesystems/apple-kit 1.0.0

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 (47) hide show
  1. package/README.md +250 -0
  2. package/dist/index.js +680 -0
  3. package/dist/index.js.map +7 -0
  4. package/dist/types/index.d.ts +11 -0
  5. package/dist/types/index.d.ts.map +1 -0
  6. package/dist/types/logic/appleDeviceKit.d.ts +68 -0
  7. package/dist/types/logic/appleDeviceKit.d.ts.map +1 -0
  8. package/dist/types/logic/devicesMonitor.d.ts +45 -0
  9. package/dist/types/logic/devicesMonitor.d.ts.map +1 -0
  10. package/dist/types/types.d.ts +127 -0
  11. package/dist/types/types.d.ts.map +1 -0
  12. package/dist/types/utils/debug.d.ts +9 -0
  13. package/dist/types/utils/debug.d.ts.map +1 -0
  14. package/dist/types/utils/exec.d.ts +14 -0
  15. package/dist/types/utils/exec.d.ts.map +1 -0
  16. package/dist/types/utils/idevicePath.d.ts +19 -0
  17. package/dist/types/utils/idevicePath.d.ts.map +1 -0
  18. package/package.json +63 -0
  19. package/resources/bin/windows/bz2.dll +0 -0
  20. package/resources/bin/windows/getopt.dll +0 -0
  21. package/resources/bin/windows/iconv-2.dll +0 -0
  22. package/resources/bin/windows/idevice_id.exe +0 -0
  23. package/resources/bin/windows/ideviceactivation.exe +0 -0
  24. package/resources/bin/windows/idevicedebug.exe +0 -0
  25. package/resources/bin/windows/ideviceinfo.exe +0 -0
  26. package/resources/bin/windows/ideviceinstaller.exe +0 -0
  27. package/resources/bin/windows/idevicepair.exe +0 -0
  28. package/resources/bin/windows/imobiledevice.dll +0 -0
  29. package/resources/bin/windows/iproxy.exe +0 -0
  30. package/resources/bin/windows/libcrypto-1_1-x64.dll +0 -0
  31. package/resources/bin/windows/libcurl.dll +0 -0
  32. package/resources/bin/windows/libssl-1_1-x64.dll +0 -0
  33. package/resources/bin/windows/libusb-1.0.dll +0 -0
  34. package/resources/bin/windows/libusb0.dll +0 -0
  35. package/resources/bin/windows/libxml2.dll +0 -0
  36. package/resources/bin/windows/lzma.dll +0 -0
  37. package/resources/bin/windows/pcre.dll +0 -0
  38. package/resources/bin/windows/pcreposix.dll +0 -0
  39. package/resources/bin/windows/plist.dll +0 -0
  40. package/resources/bin/windows/pthreadVC3.dll +0 -0
  41. package/resources/bin/windows/readline.dll +0 -0
  42. package/resources/bin/windows/usbmuxd.dll +0 -0
  43. package/resources/bin/windows/usbmuxd.exe +0 -0
  44. package/resources/bin/windows/vcruntime140.dll +0 -0
  45. package/resources/bin/windows/zip.dll +0 -0
  46. package/resources/bin/windows/zlib1.dll +0 -0
  47. package/resources/licenses/LGPL-2.1.txt +33 -0
package/README.md ADDED
@@ -0,0 +1,250 @@
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
+ - libimobiledevice binaries (included for Windows, see BUILD.md for other platforms)
28
+ - iTunes installed OR run the bundled `usbmuxd` (see below)
29
+
30
+ ## Usage
31
+
32
+ ### Device Monitoring
33
+
34
+ ```typescript
35
+ import { DevicesMonitor } from '@mcesystems/apple-kit';
36
+
37
+ const monitor = new DevicesMonitor({
38
+ logicalPortMap: {
39
+ "Port_#0005.Hub_#0002": 1,
40
+ "Port_#0006.Hub_#0002": 2
41
+ }
42
+ });
43
+
44
+ const events = await monitor.startTracking();
45
+
46
+ events.on('added', async (deviceKit) => {
47
+ console.log(`iOS device connected: ${deviceKit.getDeviceId()}`);
48
+ const info = await deviceKit.getDeviceInfo();
49
+ console.log(` ${info.deviceName} - iOS ${info.productVersion}`);
50
+ });
51
+
52
+ events.on('removed', (deviceId, port) => {
53
+ console.log(`iOS device disconnected: ${deviceId}`);
54
+ });
55
+
56
+ // Later: stop monitoring
57
+ await monitor.stopTracking();
58
+ ```
59
+
60
+ ### Install/Uninstall Agent
61
+
62
+ ```typescript
63
+ import { AppleDeviceKit } from '@mcesystems/apple-kit';
64
+
65
+ const device = new AppleDeviceKit('device-udid', 1);
66
+
67
+ // Install an agent/app
68
+ await device.installApp('/path/to/agent.ipa');
69
+
70
+ // Check if installed
71
+ const isInstalled = await device.isAppInstalled('com.example.agent');
72
+
73
+ // List all installed apps
74
+ const apps = await device.listApps();
75
+
76
+ // Uninstall an agent/app
77
+ await device.uninstallApp('com.example.agent');
78
+ ```
79
+
80
+ ### Device Info
81
+
82
+ ```typescript
83
+ const device = new AppleDeviceKit('device-udid', 1);
84
+
85
+ const info = await device.getDeviceInfo();
86
+ console.log(`Device: ${info.deviceName}`);
87
+ console.log(`Model: ${info.productType}`);
88
+ console.log(`iOS: ${info.productVersion} (${info.buildVersion})`);
89
+ console.log(`Serial: ${info.serialNumber}`);
90
+ console.log(`UDID: ${info.udid}`);
91
+ ```
92
+
93
+ ### Trust/Pairing
94
+
95
+ ```typescript
96
+ const device = new AppleDeviceKit('device-udid', 1);
97
+
98
+ // Check if device is trusted
99
+ const isPaired = await device.isPaired();
100
+
101
+ // Initiate pairing (user must accept on device)
102
+ await device.pair();
103
+
104
+ // Wait for user to accept trust dialog
105
+ await device.waitForPairing(60000); // 60 second timeout
106
+
107
+ // Unpair device
108
+ await device.unpair();
109
+ ```
110
+
111
+ ### Launch Application
112
+
113
+ ```typescript
114
+ const device = new AppleDeviceKit('device-udid', 1);
115
+
116
+ // Launch an app
117
+ await device.launchApp('com.example.myapp');
118
+
119
+ // Launch with arguments
120
+ await device.launchApp('com.example.myapp', ['--debug', '--port=8080']);
121
+ ```
122
+
123
+ ### Port Forwarding
124
+
125
+ ```typescript
126
+ const device = new AppleDeviceKit('device-udid', 1);
127
+
128
+ // Forward local port 8080 to device port 8080
129
+ const forward = device.startPortForward(8080, 8080);
130
+
131
+ // Use the forwarded connection...
132
+ // connect to localhost:8080 to reach device:8080
133
+
134
+ // Stop forwarding when done
135
+ forward.stop();
136
+
137
+ // Or use async version that waits for ready
138
+ const forwardAsync = await device.startPortForwardAsync(8080, 8080);
139
+ ```
140
+
141
+ ### Activation
142
+
143
+ ```typescript
144
+ const device = new AppleDeviceKit('device-udid', 1);
145
+
146
+ // Get activation state
147
+ const state = await device.getActivationState();
148
+ console.log(`Activated: ${state.isActivated}`);
149
+ console.log(`State: ${state.activationState}`);
150
+
151
+ // Activate device (requires valid activation record)
152
+ await device.activate();
153
+
154
+ // Deactivate device
155
+ await device.deactivate();
156
+ ```
157
+
158
+ ### Running Without iTunes (usbmuxd)
159
+
160
+ 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`:
161
+
162
+ ```typescript
163
+ import { startUsbmuxd, stopUsbmuxd, ensureUsbmuxd } from '@mcesystems/apple-kit';
164
+
165
+ // Start usbmuxd daemon (required if iTunes is not installed)
166
+ const daemon = startUsbmuxd();
167
+
168
+ // Or ensure it's running (starts if not already running)
169
+ ensureUsbmuxd();
170
+
171
+ // Now you can use device operations...
172
+ const devices = await AppleDeviceKit.listDevices();
173
+
174
+ // When done, stop the daemon
175
+ stopUsbmuxd();
176
+ // or
177
+ daemon.stop();
178
+ ```
179
+
180
+ **Note:** The usbmuxd daemon must be running before connecting devices. Start it before plugging in your iOS device.
181
+
182
+ ## API Reference
183
+
184
+ ### AppleDeviceKit
185
+
186
+ **Static methods:**
187
+ - `listDevices()`: Get all connected iOS devices
188
+
189
+ **Device Info:**
190
+ - `getDeviceInfo()`: Get device properties
191
+ - `getDeviceId()`: Get the device UDID
192
+ - `getPort()`: Get the logical port number
193
+
194
+ **App Management:**
195
+ - `installApp(ipaPath)`: Install an IPA file
196
+ - `uninstallApp(bundleId)`: Uninstall an app by bundle ID
197
+ - `isAppInstalled(bundleId)`: Check if app is installed
198
+ - `listApps()`: List all installed user apps
199
+ - `launchApp(bundleId, args?)`: Launch an application
200
+
201
+ **Trust/Pairing:**
202
+ - `isPaired()`: Check if device is paired/trusted
203
+ - `pair()`: Initiate pairing (user must accept on device)
204
+ - `unpair()`: Remove pairing/trust
205
+ - `waitForPairing(timeout?)`: Wait for device to be paired
206
+
207
+ **Port Forwarding:**
208
+ - `startPortForward(localPort, devicePort)`: Start port forwarding
209
+ - `startPortForwardAsync(localPort, devicePort)`: Start and wait for ready
210
+
211
+ **Activation:**
212
+ - `getActivationState()`: Get activation state
213
+ - `activate()`: Activate the device
214
+ - `deactivate()`: Deactivate the device
215
+
216
+ ### DevicesMonitor
217
+
218
+ - `startTracking()`: Start monitoring for iOS device connections
219
+ - `stopTracking()`: Stop monitoring
220
+ - `getKits()`: Get all currently tracked devices
221
+ - `getKit(udid)`: Get a specific device kit by UDID
222
+
223
+ ### usbmuxd Functions
224
+
225
+ - `startUsbmuxd(foreground?)`: Start the usbmuxd daemon
226
+ - `stopUsbmuxd()`: Stop the daemon
227
+ - `isUsbmuxdRunning()`: Check if daemon is running
228
+ - `ensureUsbmuxd()`: Start if not already running
229
+
230
+ ### Types
231
+
232
+ ```typescript
233
+ interface PortForwardHandle {
234
+ stop: () => void;
235
+ localPort: number;
236
+ devicePort: number;
237
+ process: ChildProcess;
238
+ }
239
+
240
+ interface ActivationState {
241
+ isActivated: boolean;
242
+ activationState: string;
243
+ }
244
+ ```
245
+
246
+ ## License
247
+
248
+ ISC
249
+
250
+ libimobiledevice is licensed under LGPL-2.1.