@mcesystems/apple-kit 1.0.72 → 1.0.74
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 +121 -2
- package/dist/index.js.map +2 -2
- package/dist/index.mjs +119 -1
- package/dist/index.mjs.map +2 -2
- 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 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/logic/iosCli.d.ts.map +1 -1
- package/dist/types/types/ios.d.ts +10 -0
- package/dist/types/types/ios.d.ts.map +1 -1
- package/package.json +4 -4
- package/scripts/README.md +209 -209
- package/scripts/build-windows.sh.template +222 -222
- package/dist/resources/plist/ddm-managed-app.xml +0 -55
- package/dist/types/graphql/queries.d.ts +0 -9
- package/dist/types/graphql/queries.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/appState.d.ts +0 -2
- package/dist/types/logic/actions/appState.d.ts.map +0 -1
- package/dist/types/logic/actions/usbmuxd.d.ts +0 -10
- package/dist/types/logic/actions/usbmuxd.d.ts.map +0 -1
- package/dist/types/types/auth.d.ts +0 -13
- package/dist/types/types/auth.d.ts.map +0 -1
- package/dist/types/types/install.d.ts +0 -13
- package/dist/types/types/install.d.ts.map +0 -1
- package/dist/types/types/mdm.d.ts +0 -33
- package/dist/types/types/mdm.d.ts.map +0 -1
- package/dist/types/types.d.ts +0 -173
- package/dist/types/types.d.ts.map +0 -1
- package/dist/types/utils/authClient.d.ts +0 -7
- package/dist/types/utils/authClient.d.ts.map +0 -1
- package/dist/types/utils/ddmDeclaration.d.ts +0 -8
- package/dist/types/utils/ddmDeclaration.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/installRawProfileRetry.d.ts +0 -7
- package/dist/types/utils/installRawProfileRetry.d.ts.map +0 -1
- package/dist/types/utils/mdmClient.d.ts +0 -7
- package/dist/types/utils/mdmClient.d.ts.map +0 -1
- package/dist/types/utils/trustProfile.d.ts +0 -12
- package/dist/types/utils/trustProfile.d.ts.map +0 -1
- package/resources/ios.exe +0 -0
- package/resources/wintun-LICENSE.txt +0 -84
- package/resources/wintun.dll +0 -0
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
|
@@ -32,7 +32,8 @@ var index_exports = {};
|
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
ActivationFlow: () => ActivationFlow,
|
|
34
34
|
AppleDeviceKit: () => AppleDeviceKit,
|
|
35
|
-
createIosCli: () => createIosCli
|
|
35
|
+
createIosCli: () => createIosCli,
|
|
36
|
+
iosCli: () => iosCli
|
|
36
37
|
});
|
|
37
38
|
module.exports = __toCommonJS(index_exports);
|
|
38
39
|
|
|
@@ -38667,6 +38668,44 @@ function parseProfileListOutput(output) {
|
|
|
38667
38668
|
}
|
|
38668
38669
|
return profiles;
|
|
38669
38670
|
}
|
|
38671
|
+
function parseFsyncTreeStdout(stdout) {
|
|
38672
|
+
return stdout.split(/\r?\n/).map((line) => line.trim()).filter((line) => line.length > 0).map((line) => line.replace(/^\|\s*\|-\s*/, "").replace(/^\|-\s*/, "")).filter((name) => name.length > 0);
|
|
38673
|
+
}
|
|
38674
|
+
function runIosCommandWithRawStdout(iosBinaryPath, args) {
|
|
38675
|
+
return new Promise((resolve2, reject) => {
|
|
38676
|
+
logDetail(`Running command: ${iosBinaryPath} ${args.join(" ")}`);
|
|
38677
|
+
const child = (0, import_node_child_process3.spawn)(iosBinaryPath, args, {
|
|
38678
|
+
windowsHide: true,
|
|
38679
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
38680
|
+
});
|
|
38681
|
+
let stdout = "";
|
|
38682
|
+
let stderr = "";
|
|
38683
|
+
child.stdout?.on("data", (data) => {
|
|
38684
|
+
stdout += data.toString();
|
|
38685
|
+
});
|
|
38686
|
+
child.stderr?.on("data", (data) => {
|
|
38687
|
+
stderr += data.toString();
|
|
38688
|
+
});
|
|
38689
|
+
child.on("error", (error) => {
|
|
38690
|
+
reject(error);
|
|
38691
|
+
});
|
|
38692
|
+
child.on("close", (code) => {
|
|
38693
|
+
const logMessages = stderr.split("\n").map((line) => line.trim()).filter((line) => line.length > 0).map((line) => safeParseJson(line)).filter((item) => Boolean(item)).map((lineJson) => ({
|
|
38694
|
+
level: lineJson.level,
|
|
38695
|
+
msg: lineJson.msg,
|
|
38696
|
+
timestamp: lineJson.timestamp
|
|
38697
|
+
}));
|
|
38698
|
+
const raw = {
|
|
38699
|
+
command: iosBinaryPath,
|
|
38700
|
+
args,
|
|
38701
|
+
output: [],
|
|
38702
|
+
logMessages,
|
|
38703
|
+
exitCode: code ?? 0
|
|
38704
|
+
};
|
|
38705
|
+
resolve2({ stdout, stderr, exitCode: code ?? 0, raw });
|
|
38706
|
+
});
|
|
38707
|
+
});
|
|
38708
|
+
}
|
|
38670
38709
|
function createIosCli(iosBinaryPath) {
|
|
38671
38710
|
return {
|
|
38672
38711
|
async listDevices() {
|
|
@@ -38729,6 +38768,85 @@ function createIosCli(iosBinaryPath) {
|
|
|
38729
38768
|
},
|
|
38730
38769
|
async installApp(deviceId, ipaPath) {
|
|
38731
38770
|
return runIosCommand(iosBinaryPath, ["install", `--path=${ipaPath}`, "--udid", deviceId]);
|
|
38771
|
+
},
|
|
38772
|
+
async tunnelStart(deviceId, userspace = false) {
|
|
38773
|
+
const args = ["tunnel", "start", "--udid", deviceId, ...userspace ? ["--userspace"] : []];
|
|
38774
|
+
logDetail(`Spawning tunnel: ${iosBinaryPath} ${args.join(" ")}`);
|
|
38775
|
+
const child = (0, import_node_child_process3.spawn)(iosBinaryPath, args, {
|
|
38776
|
+
windowsHide: true,
|
|
38777
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
38778
|
+
});
|
|
38779
|
+
return new Promise((resolve2, reject) => {
|
|
38780
|
+
let settled = false;
|
|
38781
|
+
const cleanup = () => {
|
|
38782
|
+
child.off("error", onError);
|
|
38783
|
+
child.off("exit", onExit);
|
|
38784
|
+
child.stdout?.off("data", onReadyCheck);
|
|
38785
|
+
child.stderr?.off("data", onReadyCheck);
|
|
38786
|
+
clearTimeout(readyTimeout);
|
|
38787
|
+
};
|
|
38788
|
+
const finish = (result) => {
|
|
38789
|
+
if (settled) return;
|
|
38790
|
+
settled = true;
|
|
38791
|
+
cleanup();
|
|
38792
|
+
if (result.reject) reject(result.reject);
|
|
38793
|
+
else if (result.resolve !== void 0) resolve2(result.resolve);
|
|
38794
|
+
};
|
|
38795
|
+
const onError = (err) => finish({ reject: err });
|
|
38796
|
+
const onExit = (code) => finish({ reject: new Error(`Tunnel exited early (code=${code})`) });
|
|
38797
|
+
const onReadyCheck = (data) => {
|
|
38798
|
+
const line = data.toString();
|
|
38799
|
+
const isReady = line.includes("Tunnel server started") || line.includes("tunnel") && (line.includes("listening") || line.includes("connected"));
|
|
38800
|
+
if (isReady) finish({ resolve: child });
|
|
38801
|
+
};
|
|
38802
|
+
const readyTimeout = setTimeout(() => finish({ resolve: child }), 1e4);
|
|
38803
|
+
child.once("error", onError);
|
|
38804
|
+
child.once("exit", onExit);
|
|
38805
|
+
child.stdout?.on("data", onReadyCheck);
|
|
38806
|
+
child.stderr?.on("data", onReadyCheck);
|
|
38807
|
+
});
|
|
38808
|
+
},
|
|
38809
|
+
async fsyncPull(deviceId, app, srcPath, dstPath) {
|
|
38810
|
+
return runIosCommand(iosBinaryPath, [
|
|
38811
|
+
"fsync",
|
|
38812
|
+
"--app",
|
|
38813
|
+
app,
|
|
38814
|
+
"pull",
|
|
38815
|
+
"--srcPath",
|
|
38816
|
+
srcPath,
|
|
38817
|
+
"--dstPath",
|
|
38818
|
+
dstPath,
|
|
38819
|
+
"--udid",
|
|
38820
|
+
deviceId
|
|
38821
|
+
]);
|
|
38822
|
+
},
|
|
38823
|
+
async fsyncPush(deviceId, app, srcPath, dstPath) {
|
|
38824
|
+
return runIosCommand(iosBinaryPath, [
|
|
38825
|
+
"fsync",
|
|
38826
|
+
"--app",
|
|
38827
|
+
app,
|
|
38828
|
+
"push",
|
|
38829
|
+
"--srcPath",
|
|
38830
|
+
srcPath,
|
|
38831
|
+
"--dstPath",
|
|
38832
|
+
dstPath,
|
|
38833
|
+
"--udid",
|
|
38834
|
+
deviceId
|
|
38835
|
+
]);
|
|
38836
|
+
},
|
|
38837
|
+
async fsyncTree(deviceId, app, path) {
|
|
38838
|
+
const args = [
|
|
38839
|
+
"fsync",
|
|
38840
|
+
"--app",
|
|
38841
|
+
app,
|
|
38842
|
+
"tree",
|
|
38843
|
+
"--udid",
|
|
38844
|
+
deviceId,
|
|
38845
|
+
...path !== void 0 && path !== "" ? ["--path", path] : []
|
|
38846
|
+
];
|
|
38847
|
+
const { stdout, raw } = await runIosCommandWithRawStdout(iosBinaryPath, args);
|
|
38848
|
+
const entries = parseFsyncTreeStdout(stdout);
|
|
38849
|
+
return { entries, raw };
|
|
38732
38850
|
}
|
|
38733
38851
|
};
|
|
38734
38852
|
}
|
|
@@ -38987,7 +39105,8 @@ var AppleDeviceKit = class {
|
|
|
38987
39105
|
0 && (module.exports = {
|
|
38988
39106
|
ActivationFlow,
|
|
38989
39107
|
AppleDeviceKit,
|
|
38990
|
-
createIosCli
|
|
39108
|
+
createIosCli,
|
|
39109
|
+
iosCli
|
|
38991
39110
|
});
|
|
38992
39111
|
/*! Bundled license information:
|
|
38993
39112
|
|