@mcesystems/apple-kit 1.0.68 → 1.0.69

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.
package/README.md CHANGED
@@ -1,258 +1,258 @@
1
- # @mcesystems/apple-kit
2
-
3
- iOS device management toolkit using libimobiledevice and go-ios command-line tools. We use both because they each provide capabilities that the other does not. The package provides app installation/uninstallation, port forwarding, activation, and device property access.
4
-
5
- ## Features
6
-
7
- - **App Management**: Install and uninstall iOS applications (.ipa files)
8
- - **Port Forwarding**: Forward local ports to device ports (for debugging, etc.)
9
- - **Device Activation**: Activate devices and skip setup steps
10
- - **Trust/Pairing**: Handle device trust and pairing
11
- - **Device Info**: Access device properties (name, model, iOS version, UDID, etc.)
12
- - **Profile Management**: List and remove configuration profiles
13
- - **Device Wipe**: Erase device data (factory reset)
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 tools (idevice\*)
28
- - go-ios `ios` CLI binary
29
-
30
- ### Platform-specific Requirements
31
-
32
- #### Windows
33
- - libimobiledevice binaries - use the export script (see below)
34
- - go-ios `ios.exe` (see Resources section below)
35
- - iTunes installed OR Apple Mobile Device Support
36
-
37
- #### macOS
38
- **Option 1: Use bundled binaries (recommended for distribution)**
39
-
40
- Use the export script to bundle libimobiledevice for your application:
41
- ```bash
42
- # Using npx (after installing the package)
43
- npx export-apple-resources /path/to/your-app/resources/apple-kit
44
-
45
- # Or run the script directly
46
- npx tsx node_modules/@mcesystems/apple-kit/scripts/export-resources.ts /path/to/your-app/resources
47
- ```
48
-
49
- See [scripts/README.md](./scripts/README.md) for detailed prerequisites and instructions.
50
-
51
- **Option 2: Use Homebrew installation (for development)**
52
- - Install via Homebrew: `brew install libimobiledevice ideviceinstaller`
53
- - Tools are auto-detected from `/opt/homebrew/bin` (Apple Silicon) or `/usr/local/bin` (Intel)
54
-
55
- #### Linux
56
- - libimobiledevice-utils: `sudo apt install libimobiledevice-utils`
57
- - Tools are auto-detected from `/usr/bin` or `/usr/local/bin`
58
-
59
- ### Resources and Binary Resolution
60
-
61
- Set a resources directory once so both toolchains can be located:
62
-
63
- ```typescript
64
- import path from "node:path";
65
- import { AppleDeviceKit } from "@mcesystems/apple-kit";
66
-
67
- AppleDeviceKit.setResourcesDir(path.join(process.cwd(), "resources"));
68
- ```
69
-
70
- If you do not set a resources directory, make sure both toolchains are on your PATH.
71
-
72
- The package looks for tools in this order:
73
- 1. `resourcesDir/ios/bin/{platform}/` (go-ios `ios` and libimobiledevice tools)
74
- 2. Homebrew paths on macOS (`/opt/homebrew/bin`, `/usr/local/bin`)
75
- 3. System PATH (for global installations)
76
-
77
- ## Usage
78
-
79
- ### List Devices (go-ios)
80
-
81
- ```typescript
82
- import { createIosCli } from "@mcesystems/apple-kit";
83
-
84
- // Example: <resourcesDir>/ios/bin/{platform}/ios(.exe)
85
- const cli = createIosCli("path/to/ios");
86
- const list = await cli.listDevices();
87
- console.log(list.udids);
88
- ```
89
-
90
- ### Install/Uninstall Agent
91
-
92
- ```typescript
93
- import { AppleDeviceKit } from '@mcesystems/apple-kit';
94
-
95
- const device = new AppleDeviceKit('device-udid', 1);
96
-
97
- // Install app locally, then (if MDM is configured) take over management
98
- await device.installApp('/path/to/agent.ipa', {
99
- appId: 'com.example.agent',
100
- url: 'https://example.com/agent.ipa',
101
- waitForInstalled: true
102
- });
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.info();
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.UniqueDeviceID}`);
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
- // Trust the device (initiates pairing and waits for user acceptance)
136
- await device.trustDevice(60000);
137
-
138
- // Unpair device
139
- await device.unpair();
140
- ```
141
-
142
- ### Port Forwarding
143
-
144
- ```typescript
145
- const device = new AppleDeviceKit('device-udid', 1);
146
-
147
- // Forward device port 8080 to a local port (auto-allocated)
148
- const forward = await device.startPortForwardAsync(8080);
149
- console.log(`Local port: ${forward.localPort}`);
150
-
151
- // Use the forwarded connection...
152
- // connect to localhost:8080 to reach device:8080
153
-
154
- // Stop forwarding when done
155
- device.closePortForward();
156
- ```
157
-
158
- ### Activation
159
-
160
- ```typescript
161
- const device = new AppleDeviceKit('device-udid', 1);
162
-
163
- // Get activation state
164
- const state = await device.getActivationState();
165
- console.log(`Activated: ${state.isActivated}`);
166
- console.log(`State: ${state.activationState}`);
167
-
168
- // Activate device (uses go-ios and MDM client)
169
- const cleanup = await device.activate();
170
- if (cleanup) {
171
- await cleanup(); // removes WiFi profile when done
172
- }
173
- ```
174
-
175
- The activation flow can install a WiFi profile based on environment variables:
176
- `WIFI_SSID`, `WIFI_PASSWORD`, `WIFI_ENCRYPTION`, `WIFI_HIDDEN`, `WIFI_ENTERPRISE`,
177
- `WIFI_USERNAME`, and `WIFI_EAP_TYPE`.
178
-
179
- ### Profiles
180
-
181
- ```typescript
182
- const device = new AppleDeviceKit('device-udid', 1);
183
-
184
- // List profiles
185
- const profiles = await device.listProfiles();
186
- console.log(profiles.profiles);
187
-
188
- // Remove a profile by identifier
189
- await device.removeProfile("com.example.profile");
190
- ```
191
-
192
- ### Wipe Device
193
-
194
- ```typescript
195
- const device = new AppleDeviceKit('device-udid', 1);
196
-
197
- // WARNING: this erases all data
198
- await device.wipe();
199
- ```
200
-
201
- ## API Reference
202
-
203
- ### AppleDeviceKit
204
-
205
- **Static methods:**
206
- - `setResourcesDir(dir)`: Configure resources location
207
-
208
- **Device Info:**
209
- - `info()`: Get device properties
210
- - `getDeviceId()`: Get the device UDID
211
- - `getLogicalPort()`: Get the logical port number
212
- - `getDevicePort()`: Get current local forwarded port (or null)
213
-
214
- **App Management:**
215
- - `installApp(ipaPath, options)`: Install IPA and take over via MDM if configured
216
- - `uninstallApp(bundleId)`: Uninstall an app by bundle ID
217
- - `isAppInstalled(bundleId)`: Check if app is installed
218
- - `listApps()`: List all installed user apps
219
-
220
- **Trust/Pairing:**
221
- - `isPaired()`: Check if device is paired/trusted
222
- - `pair()`: Initiate pairing (user must accept on device)
223
- - `trustDevice(timeout?, onWaiting?)`: Pair and wait for user acceptance
224
- - `unpair()`: Remove pairing/trust
225
- - `waitForPairing(timeout?, pollInterval?)`: Wait for device to be paired
226
-
227
- **Port Forwarding:**
228
- - `startPortForwardAsync(devicePort, startupTimeout?)`: Start and wait for ready
229
- - `closePortForward()`: Stop forwarding
230
-
231
- **Profiles:**
232
- - `listProfiles()`: List installed profiles
233
- - `removeProfile(identifier)`: Remove profile by identifier
234
-
235
- **Activation:**
236
- - `getActivationState()`: Get activation state
237
- - `activate()`: Activate the device (returns cleanup function)
238
-
239
- **Device Wipe:**
240
- - `wipe()`: Erase device data
241
-
242
- **Lifecycle:**
243
- - `dispose()`: Clean up resources and port forwards
244
-
245
- ### Types
246
-
247
- ```typescript
248
- interface ActivationState {
249
- isActivated: boolean;
250
- activationState: string;
251
- }
252
- ```
253
-
254
- ## License
255
-
256
- ISC
257
-
258
- libimobiledevice is licensed under LGPL-2.1.
1
+ # @mcesystems/apple-kit
2
+
3
+ iOS device management toolkit using libimobiledevice and go-ios command-line tools. We use both because they each provide capabilities that the other does not. The package provides app installation/uninstallation, port forwarding, activation, and device property access.
4
+
5
+ ## Features
6
+
7
+ - **App Management**: Install and uninstall iOS applications (.ipa files)
8
+ - **Port Forwarding**: Forward local ports to device ports (for debugging, etc.)
9
+ - **Device Activation**: Activate devices and skip setup steps
10
+ - **Trust/Pairing**: Handle device trust and pairing
11
+ - **Device Info**: Access device properties (name, model, iOS version, UDID, etc.)
12
+ - **Profile Management**: List and remove configuration profiles
13
+ - **Device Wipe**: Erase device data (factory reset)
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 tools (idevice\*)
28
+ - go-ios `ios` CLI binary
29
+
30
+ ### Platform-specific Requirements
31
+
32
+ #### Windows
33
+ - libimobiledevice binaries - use the export script (see below)
34
+ - go-ios `ios.exe` (see Resources section below)
35
+ - iTunes installed OR Apple Mobile Device Support
36
+
37
+ #### macOS
38
+ **Option 1: Use bundled binaries (recommended for distribution)**
39
+
40
+ Use the export script to bundle libimobiledevice for your application:
41
+ ```bash
42
+ # Using npx (after installing the package)
43
+ npx export-apple-resources /path/to/your-app/resources/apple-kit
44
+
45
+ # Or run the script directly
46
+ npx tsx node_modules/@mcesystems/apple-kit/scripts/export-resources.ts /path/to/your-app/resources
47
+ ```
48
+
49
+ See [scripts/README.md](./scripts/README.md) for detailed prerequisites and instructions.
50
+
51
+ **Option 2: Use Homebrew installation (for development)**
52
+ - Install via Homebrew: `brew install libimobiledevice ideviceinstaller`
53
+ - Tools are auto-detected from `/opt/homebrew/bin` (Apple Silicon) or `/usr/local/bin` (Intel)
54
+
55
+ #### Linux
56
+ - libimobiledevice-utils: `sudo apt install libimobiledevice-utils`
57
+ - Tools are auto-detected from `/usr/bin` or `/usr/local/bin`
58
+
59
+ ### Resources and Binary Resolution
60
+
61
+ Set a resources directory once so both toolchains can be located:
62
+
63
+ ```typescript
64
+ import path from "node:path";
65
+ import { AppleDeviceKit } from "@mcesystems/apple-kit";
66
+
67
+ AppleDeviceKit.setResourcesDir(path.join(process.cwd(), "resources"));
68
+ ```
69
+
70
+ If you do not set a resources directory, make sure both toolchains are on your PATH.
71
+
72
+ The package looks for tools in this order:
73
+ 1. `resourcesDir/ios/bin/{platform}/` (go-ios `ios` and libimobiledevice tools)
74
+ 2. Homebrew paths on macOS (`/opt/homebrew/bin`, `/usr/local/bin`)
75
+ 3. System PATH (for global installations)
76
+
77
+ ## Usage
78
+
79
+ ### List Devices (go-ios)
80
+
81
+ ```typescript
82
+ import { createIosCli } from "@mcesystems/apple-kit";
83
+
84
+ // Example: <resourcesDir>/ios/bin/{platform}/ios(.exe)
85
+ const cli = createIosCli("path/to/ios");
86
+ const list = await cli.listDevices();
87
+ console.log(list.udids);
88
+ ```
89
+
90
+ ### Install/Uninstall Agent
91
+
92
+ ```typescript
93
+ import { AppleDeviceKit } from '@mcesystems/apple-kit';
94
+
95
+ const device = new AppleDeviceKit('device-udid', 1);
96
+
97
+ // Install app locally, then (if MDM is configured) take over management
98
+ await device.installApp('/path/to/agent.ipa', {
99
+ appId: 'com.example.agent',
100
+ url: 'https://example.com/agent.ipa',
101
+ waitForInstalled: true
102
+ });
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.info();
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.UniqueDeviceID}`);
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
+ // Trust the device (initiates pairing and waits for user acceptance)
136
+ await device.trustDevice(60000);
137
+
138
+ // Unpair device
139
+ await device.unpair();
140
+ ```
141
+
142
+ ### Port Forwarding
143
+
144
+ ```typescript
145
+ const device = new AppleDeviceKit('device-udid', 1);
146
+
147
+ // Forward device port 8080 to a local port (auto-allocated)
148
+ const forward = await device.startPortForwardAsync(8080);
149
+ console.log(`Local port: ${forward.localPort}`);
150
+
151
+ // Use the forwarded connection...
152
+ // connect to localhost:8080 to reach device:8080
153
+
154
+ // Stop forwarding when done
155
+ device.closePortForward();
156
+ ```
157
+
158
+ ### Activation
159
+
160
+ ```typescript
161
+ const device = new AppleDeviceKit('device-udid', 1);
162
+
163
+ // Get activation state
164
+ const state = await device.getActivationState();
165
+ console.log(`Activated: ${state.isActivated}`);
166
+ console.log(`State: ${state.activationState}`);
167
+
168
+ // Activate device (uses go-ios and MDM client)
169
+ const cleanup = await device.activate();
170
+ if (cleanup) {
171
+ await cleanup(); // removes WiFi profile when done
172
+ }
173
+ ```
174
+
175
+ The activation flow can install a WiFi profile based on environment variables:
176
+ `WIFI_SSID`, `WIFI_PASSWORD`, `WIFI_ENCRYPTION`, `WIFI_HIDDEN`, `WIFI_ENTERPRISE`,
177
+ `WIFI_USERNAME`, and `WIFI_EAP_TYPE`.
178
+
179
+ ### Profiles
180
+
181
+ ```typescript
182
+ const device = new AppleDeviceKit('device-udid', 1);
183
+
184
+ // List profiles
185
+ const profiles = await device.listProfiles();
186
+ console.log(profiles.profiles);
187
+
188
+ // Remove a profile by identifier
189
+ await device.removeProfile("com.example.profile");
190
+ ```
191
+
192
+ ### Wipe Device
193
+
194
+ ```typescript
195
+ const device = new AppleDeviceKit('device-udid', 1);
196
+
197
+ // WARNING: this erases all data
198
+ await device.wipe();
199
+ ```
200
+
201
+ ## API Reference
202
+
203
+ ### AppleDeviceKit
204
+
205
+ **Static methods:**
206
+ - `setResourcesDir(dir)`: Configure resources location
207
+
208
+ **Device Info:**
209
+ - `info()`: Get device properties
210
+ - `getDeviceId()`: Get the device UDID
211
+ - `getLogicalPort()`: Get the logical port number
212
+ - `getDevicePort()`: Get current local forwarded port (or null)
213
+
214
+ **App Management:**
215
+ - `installApp(ipaPath, options)`: Install IPA and take over via MDM if configured
216
+ - `uninstallApp(bundleId)`: Uninstall an app by bundle ID
217
+ - `isAppInstalled(bundleId)`: Check if app is installed
218
+ - `listApps()`: List all installed user apps
219
+
220
+ **Trust/Pairing:**
221
+ - `isPaired()`: Check if device is paired/trusted
222
+ - `pair()`: Initiate pairing (user must accept on device)
223
+ - `trustDevice(timeout?, onWaiting?)`: Pair and wait for user acceptance
224
+ - `unpair()`: Remove pairing/trust
225
+ - `waitForPairing(timeout?, pollInterval?)`: Wait for device to be paired
226
+
227
+ **Port Forwarding:**
228
+ - `startPortForwardAsync(devicePort, startupTimeout?)`: Start and wait for ready
229
+ - `closePortForward()`: Stop forwarding
230
+
231
+ **Profiles:**
232
+ - `listProfiles()`: List installed profiles
233
+ - `removeProfile(identifier)`: Remove profile by identifier
234
+
235
+ **Activation:**
236
+ - `getActivationState()`: Get activation state
237
+ - `activate()`: Activate the device (returns cleanup function)
238
+
239
+ **Device Wipe:**
240
+ - `wipe()`: Erase device data
241
+
242
+ **Lifecycle:**
243
+ - `dispose()`: Clean up resources and port forwards
244
+
245
+ ### Types
246
+
247
+ ```typescript
248
+ interface ActivationState {
249
+ isActivated: boolean;
250
+ activationState: string;
251
+ }
252
+ ```
253
+
254
+ ## License
255
+
256
+ ISC
257
+
258
+ libimobiledevice is licensed under LGPL-2.1.