@mcesystems/apple-kit 1.0.95 → 1.0.96
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 +258 -258
- package/dist/index.js +9 -5
- package/dist/index.js.map +2 -2
- package/dist/index.mjs +9 -5
- package/dist/index.mjs.map +3 -3
- package/dist/resources/plist/certificate-trust.xml +43 -43
- package/dist/resources/plist/wifi-enterprise.xml +59 -59
- package/dist/resources/plist/wifi-standard.xml +50 -50
- package/dist/types/index.d.ts +2 -1
- package/package.json +3 -3
- package/resources/ios.exe +0 -0
- package/resources/wintun-LICENSE.txt +84 -0
- package/resources/wintun.dll +0 -0
- package/scripts/README.md +209 -209
- package/scripts/build-windows.sh.template +222 -222
- package/dist/resources/bin/darwin/idevice_id +0 -0
- package/dist/resources/bin/darwin/idevicedebug +0 -0
- package/dist/resources/bin/darwin/idevicediagnostics +0 -0
- package/dist/resources/bin/darwin/ideviceinfo +0 -0
- package/dist/resources/bin/darwin/ideviceinstaller +0 -0
- package/dist/resources/bin/darwin/idevicename +0 -0
- package/dist/resources/bin/darwin/idevicepair +0 -0
- package/dist/resources/bin/darwin/idevicescreenshot +0 -0
- package/dist/resources/bin/darwin/idevicesyslog +0 -0
- package/dist/resources/bin/darwin/iproxy +0 -0
- package/dist/resources/bin/darwin/libcrypto.3.dylib +0 -0
- package/dist/resources/bin/darwin/libimobiledevice-1.0.6.dylib +0 -0
- package/dist/resources/bin/darwin/libimobiledevice-glue-1.0.0.dylib +0 -0
- package/dist/resources/bin/darwin/liblzma.5.dylib +0 -0
- package/dist/resources/bin/darwin/libplist-2.0.4.dylib +0 -0
- package/dist/resources/bin/darwin/libssl.3.dylib +0 -0
- package/dist/resources/bin/darwin/libusbmuxd-2.0.7.dylib +0 -0
- package/dist/resources/bin/darwin/libzip.5.dylib +0 -0
- package/dist/resources/bin/darwin/libzstd.1.dylib +0 -0
- package/dist/resources/licenses/LGPL-2.1.txt +0 -33
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/logic/actions/activation.d.ts +0 -12
- package/dist/types/logic/actions/activation.d.ts.map +0 -1
- package/dist/types/logic/actions/device.d.ts +0 -15
- package/dist/types/logic/actions/device.d.ts.map +0 -1
- package/dist/types/logic/actions/install.d.ts +0 -10
- package/dist/types/logic/actions/install.d.ts.map +0 -1
- package/dist/types/logic/actions/pair.d.ts +0 -6
- package/dist/types/logic/actions/pair.d.ts.map +0 -1
- package/dist/types/logic/actions/proxy.d.ts +0 -23
- package/dist/types/logic/actions/proxy.d.ts.map +0 -1
- package/dist/types/logic/actions/restore.d.ts +0 -36
- package/dist/types/logic/actions/restore.d.ts.map +0 -1
- package/dist/types/logic/actions/tool.d.ts +0 -8
- package/dist/types/logic/actions/tool.d.ts.map +0 -1
- package/dist/types/logic/activationFlow.d.ts +0 -15
- package/dist/types/logic/activationFlow.d.ts.map +0 -1
- package/dist/types/logic/appleDeviceKit.d.ts +0 -164
- package/dist/types/logic/appleDeviceKit.d.ts.map +0 -1
- package/dist/types/logic/dataParser.d.ts +0 -23
- package/dist/types/logic/dataParser.d.ts.map +0 -1
- package/dist/types/logic/iosCli.d.ts +0 -6
- package/dist/types/logic/iosCli.d.ts.map +0 -1
- package/dist/types/logic/utils/resolvePath.d.ts +0 -13
- package/dist/types/logic/utils/resolvePath.d.ts.map +0 -1
- package/dist/types/types/activation.d.ts +0 -28
- package/dist/types/types/activation.d.ts.map +0 -1
- package/dist/types/types/ios.d.ts +0 -152
- package/dist/types/types/ios.d.ts.map +0 -1
- package/dist/types/types/trust.d.ts +0 -10
- package/dist/types/types/trust.d.ts.map +0 -1
- package/dist/types/types/types.d.ts +0 -47
- package/dist/types/types/types.d.ts.map +0 -1
- package/dist/types/types/wifi.d.ts +0 -19
- package/dist/types/types/wifi.d.ts.map +0 -1
- package/dist/types/types.d.ts +0 -140
- package/dist/types/types.d.ts.map +0 -1
- package/dist/types/utils/debug.d.ts +0 -17
- package/dist/types/utils/debug.d.ts.map +0 -1
- package/dist/types/utils/templateLoader.d.ts +0 -8
- package/dist/types/utils/templateLoader.d.ts.map +0 -1
- package/dist/types/utils/wifiProfile.d.ts +0 -14
- package/dist/types/utils/wifiProfile.d.ts.map +0 -1
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.
|
package/dist/index.js
CHANGED
|
@@ -390,7 +390,6 @@ module.exports = __toCommonJS(index_exports);
|
|
|
390
390
|
// src/logic/appleDeviceKit.ts
|
|
391
391
|
var import_node_fs5 = require("node:fs");
|
|
392
392
|
var import_promises3 = require("node:fs/promises");
|
|
393
|
-
var import_promises4 = require("node:fs/promises");
|
|
394
393
|
var import_node_path5 = require("node:path");
|
|
395
394
|
|
|
396
395
|
// ../tool-debug/dist/index.mjs
|
|
@@ -1699,6 +1698,9 @@ ${out.stderr}`;
|
|
|
1699
1698
|
(0, import_node_fs2.rmSync)(lockdownFile, { force: true });
|
|
1700
1699
|
return true;
|
|
1701
1700
|
}
|
|
1701
|
+
getLockdownPath() {
|
|
1702
|
+
return getLockdownPath();
|
|
1703
|
+
}
|
|
1702
1704
|
};
|
|
1703
1705
|
|
|
1704
1706
|
// ../mdm-client/dist/index.mjs
|
|
@@ -39186,8 +39188,8 @@ var IosClient = class {
|
|
|
39186
39188
|
async devMode() {
|
|
39187
39189
|
return this.runIosCommand(["devmode", "enable", "--udid", this.udid]);
|
|
39188
39190
|
}
|
|
39189
|
-
async tunnelStart(userspace = false) {
|
|
39190
|
-
const args = ["tunnel", "start", "--udid", this.udid, ...userspace ? ["--userspace"] : []];
|
|
39191
|
+
async tunnelStart(userspace = false, pairRecordPath) {
|
|
39192
|
+
const args = ["tunnel", "start", `--pair-record-path=${pairRecordPath ?? "default"}`, "--udid", this.udid, ...userspace ? ["--userspace"] : []];
|
|
39191
39193
|
logDetail(`Spawning tunnel: ${this.iosPath} ${args.join(" ")}`);
|
|
39192
39194
|
const child = (0, import_node_child_process.spawn)(this.iosPath, args, {
|
|
39193
39195
|
windowsHide: true,
|
|
@@ -39394,7 +39396,9 @@ var AppleDeviceKit = class _AppleDeviceKit {
|
|
|
39394
39396
|
}
|
|
39395
39397
|
logInfo7(`Starting tunnel for device ${this.deviceId} (iOS 17+)`);
|
|
39396
39398
|
try {
|
|
39397
|
-
const
|
|
39399
|
+
const pairRecordPath = (0, import_node_path5.join)(this.deviceActions.getLockdownPath() ?? "", "RemotePairing", `${this.deviceId}`);
|
|
39400
|
+
await (0, import_promises3.mkdir)(pairRecordPath, { recursive: true });
|
|
39401
|
+
const tunnelProcess = await this.iosClient.tunnelStart(true, pairRecordPath);
|
|
39398
39402
|
this.tunnelProcess = tunnelProcess;
|
|
39399
39403
|
tunnelProcess.on("exit", (code) => {
|
|
39400
39404
|
logError3(`Tunnel process for device ${this.deviceId} exited with code ${code}`);
|
|
@@ -39620,7 +39624,7 @@ var AppleDeviceKit = class _AppleDeviceKit {
|
|
|
39620
39624
|
const tmpFilePath = (0, import_node_path5.join)(tmpDir, fileName);
|
|
39621
39625
|
try {
|
|
39622
39626
|
await (0, import_promises3.mkdir)(tmpDir, { recursive: true });
|
|
39623
|
-
await (0,
|
|
39627
|
+
await (0, import_promises3.writeFile)(tmpFilePath, fileData);
|
|
39624
39628
|
const stats = await (0, import_promises3.stat)(tmpFilePath);
|
|
39625
39629
|
logDetail2(`Temp file written: ${tmpFilePath}, size: ${stats.size} bytes`);
|
|
39626
39630
|
if (stats.size !== fileData.length) {
|