@mcesystems/apple-kit 1.0.54 → 1.0.55
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/dist/index.js +40 -119
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +40 -119
- package/dist/index.mjs.map +3 -3
- package/dist/types/logic/actions/install.d.ts +1 -0
- package/dist/types/logic/actions/install.d.ts.map +1 -1
- package/dist/types/logic/activationFlow.d.ts +1 -3
- package/dist/types/logic/activationFlow.d.ts.map +1 -1
- package/dist/types/logic/appleDeviceKit.d.ts +3 -3
- package/dist/types/logic/appleDeviceKit.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -33369,19 +33369,46 @@ async function unpair(udid) {
|
|
|
33369
33369
|
}
|
|
33370
33370
|
|
|
33371
33371
|
// src/logic/actions/install.ts
|
|
33372
|
-
async function installApp(ipaPath, udid, options) {
|
|
33373
|
-
if (options?.installViaMdm) {
|
|
33374
|
-
logTask(`Installing app on device ${udid} via MDM`);
|
|
33375
|
-
const mdmClient = await resolveMdmClient(options.mdm);
|
|
33376
|
-
const mdmInstallOptions = getMdmInstallOptions(options.mdm);
|
|
33377
|
-
await mdmClient.installApp(udid, mdmInstallOptions);
|
|
33378
|
-
}
|
|
33379
|
-
await installLocalApp(ipaPath, udid);
|
|
33380
|
-
}
|
|
33381
33372
|
async function installLocalApp(ipaPath, udid) {
|
|
33382
33373
|
logTask(`Installing app ${ipaPath} on device ${udid}`);
|
|
33383
33374
|
await runIDeviceTool("ideviceinstaller", ["-u", udid, "install", ipaPath]);
|
|
33384
33375
|
}
|
|
33376
|
+
function getMdmInstallOptionsFromEnv() {
|
|
33377
|
+
const appId = process.env.MDM_APP_ID;
|
|
33378
|
+
const url = process.env.MDM_APP_URL;
|
|
33379
|
+
const waitForInstalled = parseBooleanEnv(process.env.MDM_APP_WAIT_FOR_INSTALLED);
|
|
33380
|
+
if (!appId && !url) {
|
|
33381
|
+
throw new Error("MDM install requires MDM_APP_ID or MDM_APP_URL.");
|
|
33382
|
+
}
|
|
33383
|
+
return {
|
|
33384
|
+
appId,
|
|
33385
|
+
url,
|
|
33386
|
+
waitForInstalled
|
|
33387
|
+
};
|
|
33388
|
+
}
|
|
33389
|
+
function parseBooleanEnv(value) {
|
|
33390
|
+
if (!value) {
|
|
33391
|
+
return void 0;
|
|
33392
|
+
}
|
|
33393
|
+
const normalized = value.trim().toLowerCase();
|
|
33394
|
+
if (normalized === "true" || normalized === "1" || normalized === "yes") {
|
|
33395
|
+
return true;
|
|
33396
|
+
}
|
|
33397
|
+
if (normalized === "false" || normalized === "0" || normalized === "no") {
|
|
33398
|
+
return false;
|
|
33399
|
+
}
|
|
33400
|
+
return void 0;
|
|
33401
|
+
}
|
|
33402
|
+
async function installManagedApp(ipaPath, udid, timeBetweenInstalls) {
|
|
33403
|
+
await installLocalApp(ipaPath, udid);
|
|
33404
|
+
const mdmInstallOptions = getMdmInstallOptionsFromEnv();
|
|
33405
|
+
const client = await createMdmClientFromEnv();
|
|
33406
|
+
logTask("Installing app via MDM for management takeover");
|
|
33407
|
+
await new Promise((resolve5) => setTimeout(resolve5, timeBetweenInstalls));
|
|
33408
|
+
if (client) {
|
|
33409
|
+
client.installApp(udid, mdmInstallOptions);
|
|
33410
|
+
}
|
|
33411
|
+
}
|
|
33385
33412
|
async function uninstallApp(bundleId, udid) {
|
|
33386
33413
|
logTask(`Uninstalling app ${bundleId} from device ${udid}`);
|
|
33387
33414
|
if (!await isPaired(udid)) {
|
|
@@ -33466,33 +33493,6 @@ async function launchApp(bundleId, args, udid) {
|
|
|
33466
33493
|
throw error;
|
|
33467
33494
|
}
|
|
33468
33495
|
}
|
|
33469
|
-
async function resolveMdmClient(options) {
|
|
33470
|
-
if (options?.client) {
|
|
33471
|
-
return options.client;
|
|
33472
|
-
}
|
|
33473
|
-
if (options?.clientConfig) {
|
|
33474
|
-
return createMdmClient(options.clientConfig);
|
|
33475
|
-
}
|
|
33476
|
-
const envClient = await createMdmClientFromEnv();
|
|
33477
|
-
if (!envClient) {
|
|
33478
|
-
throw new Error(
|
|
33479
|
-
"MDM client not configured. Set MDM_ENDPOINT and MDM_CRED_PATH or pass mdm.client."
|
|
33480
|
-
);
|
|
33481
|
-
}
|
|
33482
|
-
return envClient;
|
|
33483
|
-
}
|
|
33484
|
-
function getMdmInstallOptions(options) {
|
|
33485
|
-
const appId = options?.appId;
|
|
33486
|
-
const url = options?.url;
|
|
33487
|
-
if (!appId && !url) {
|
|
33488
|
-
throw new Error("MDM install requires an appId or url.");
|
|
33489
|
-
}
|
|
33490
|
-
return {
|
|
33491
|
-
appId,
|
|
33492
|
-
url,
|
|
33493
|
-
waitForInstalled: options?.waitForInstalled
|
|
33494
|
-
};
|
|
33495
|
-
}
|
|
33496
33496
|
async function launchAppWithPymobiledevice3(bundleId, args, udid) {
|
|
33497
33497
|
logTask(`Launching app ${bundleId} using pymobiledevice3`);
|
|
33498
33498
|
const { exec } = await import("node:child_process");
|
|
@@ -33669,7 +33669,6 @@ function killPortForwardProcess(process2) {
|
|
|
33669
33669
|
}
|
|
33670
33670
|
|
|
33671
33671
|
// src/logic/activationFlow.ts
|
|
33672
|
-
var import_node_fs4 = require("node:fs");
|
|
33673
33672
|
var import_promises2 = require("node:fs/promises");
|
|
33674
33673
|
var import_node_os2 = require("node:os");
|
|
33675
33674
|
var import_node_path7 = require("node:path");
|
|
@@ -33983,16 +33982,9 @@ function createIosCli(iosBinaryPath) {
|
|
|
33983
33982
|
var import_meta3 = {};
|
|
33984
33983
|
var DEFAULT_RETRIES = 150;
|
|
33985
33984
|
var DEFAULT_RETRY_DELAY_MS = 1e3;
|
|
33986
|
-
var TIME_BETWEEN_INSTALLS = 1e4;
|
|
33987
|
-
var TIME_TO_WAIT_FOR_MANAGED_APP_INSTALL = 1e4;
|
|
33988
|
-
function sleep(ms) {
|
|
33989
|
-
return new Promise((resolve5) => setTimeout(resolve5, ms));
|
|
33990
|
-
}
|
|
33991
33985
|
var ActivationFlow = class {
|
|
33992
33986
|
iosCli;
|
|
33993
33987
|
mdmClientPromise;
|
|
33994
|
-
// private readonly organizationName?: string;
|
|
33995
|
-
resourcesDir;
|
|
33996
33988
|
constructor(config) {
|
|
33997
33989
|
const iosBinaryPath = resolveIosBinaryPath(config);
|
|
33998
33990
|
if (!iosBinaryPath) {
|
|
@@ -34000,7 +33992,6 @@ var ActivationFlow = class {
|
|
|
34000
33992
|
}
|
|
34001
33993
|
this.iosCli = createIosCli(iosBinaryPath);
|
|
34002
33994
|
this.mdmClientPromise = createMdmClientFromEnv({ resourcesDir: config.resourcesDir });
|
|
34003
|
-
this.resourcesDir = config.resourcesDir;
|
|
34004
33995
|
}
|
|
34005
33996
|
async run(udid) {
|
|
34006
33997
|
logTask(`Starting activation flow for device ${udid}`);
|
|
@@ -34010,15 +34001,12 @@ var ActivationFlow = class {
|
|
|
34010
34001
|
await this.retryActivateCommand("activate device", () => this.iosCli.activate(udid));
|
|
34011
34002
|
} else {
|
|
34012
34003
|
await this.retryIosCommand("wipe", () => this.iosCli.wipe(udid));
|
|
34013
|
-
return
|
|
34004
|
+
return void 0;
|
|
34014
34005
|
}
|
|
34015
34006
|
const wifiProfileIdentifier = await this.installWifiProfile(udid);
|
|
34016
34007
|
await this.installMdmProfile(udid);
|
|
34017
34008
|
await this.retryIosCommand("skip steps", () => this.iosCli.skipSteps(udid));
|
|
34018
|
-
|
|
34019
|
-
await sleep(TIME_TO_WAIT_FOR_MANAGED_APP_INSTALL);
|
|
34020
|
-
await this.removeWifiProfile(udid, wifiProfileIdentifier);
|
|
34021
|
-
return "activated";
|
|
34009
|
+
return () => this.removeWifiProfile(udid, wifiProfileIdentifier);
|
|
34022
34010
|
}
|
|
34023
34011
|
async installWifiProfile(udid) {
|
|
34024
34012
|
const wifiProfile = await generateWifiProfileFromEnv();
|
|
@@ -34060,39 +34048,6 @@ var ActivationFlow = class {
|
|
|
34060
34048
|
);
|
|
34061
34049
|
await removeTempFile(profilePath, "mdm profile");
|
|
34062
34050
|
}
|
|
34063
|
-
// private async installTrustProfile(udid: string): Promise<void> {
|
|
34064
|
-
// const resourcesProfilePath = getResourcesTrustProfilePath(this.resourcesDir);
|
|
34065
|
-
// if (existsSync(resourcesProfilePath)) {
|
|
34066
|
-
// logTask("Installing trust profile from resources");
|
|
34067
|
-
// await this.retryIosCommand("install trust profile", () =>
|
|
34068
|
-
// this.iosCli.installProfile(udid, resourcesProfilePath)
|
|
34069
|
-
// );
|
|
34070
|
-
// return;
|
|
34071
|
-
// }
|
|
34072
|
-
// if (!this.organizationName) {
|
|
34073
|
-
// logError("ORGANIZATION_NAME is required to generate trust profile");
|
|
34074
|
-
// throw new Error("ORGANIZATION_NAME is required for trust profile generation");
|
|
34075
|
-
// }
|
|
34076
|
-
// const trustProfile = await generateTrustProfileFromEnv(this.organizationName);
|
|
34077
|
-
// if (!trustProfile) {
|
|
34078
|
-
// return;
|
|
34079
|
-
// }
|
|
34080
|
-
// logTask("Generating trust profile and saving to resources");
|
|
34081
|
-
// await ensureResourcesDirExists(this.resourcesDir);
|
|
34082
|
-
// await writeFile(resourcesProfilePath, trustProfile, "utf-8");
|
|
34083
|
-
// await this.retryIosCommand("install trust profile", () =>
|
|
34084
|
-
// this.iosCli.installProfile(udid, resourcesProfilePath)
|
|
34085
|
-
// );
|
|
34086
|
-
// }
|
|
34087
|
-
async installManagedApp(udid) {
|
|
34088
|
-
const ipaPath = resolveManagedAppPath(this.resourcesDir);
|
|
34089
|
-
await installLocalApp(ipaPath, udid);
|
|
34090
|
-
const mdmInstallOptions = getMdmInstallOptionsFromEnv();
|
|
34091
|
-
const client = await this.requireMdmClient();
|
|
34092
|
-
logTask("Installing app via MDM for management takeover");
|
|
34093
|
-
await sleep(TIME_BETWEEN_INSTALLS);
|
|
34094
|
-
client.installApp(udid, mdmInstallOptions);
|
|
34095
|
-
}
|
|
34096
34051
|
async removeWifiProfile(udid, profileIdentifier) {
|
|
34097
34052
|
if (!profileIdentifier) {
|
|
34098
34053
|
return;
|
|
@@ -34148,40 +34103,6 @@ async function removeTempFile(filePath, label) {
|
|
|
34148
34103
|
logError(`Failed to remove ${label} temp file: ${errorMsg}`);
|
|
34149
34104
|
}
|
|
34150
34105
|
}
|
|
34151
|
-
function resolveManagedAppPath(resourcesDir) {
|
|
34152
|
-
const resolvedResourcesDir = resolveResourcesDir(resourcesDir);
|
|
34153
|
-
const ipaPath = (0, import_node_path7.join)(resolvedResourcesDir, "deviceagent.ipa");
|
|
34154
|
-
if (!(0, import_node_fs4.existsSync)(ipaPath)) {
|
|
34155
|
-
throw new Error(`Managed app IPA not found at ${ipaPath}`);
|
|
34156
|
-
}
|
|
34157
|
-
return ipaPath;
|
|
34158
|
-
}
|
|
34159
|
-
function getMdmInstallOptionsFromEnv() {
|
|
34160
|
-
const appId = process.env.MDM_APP_ID;
|
|
34161
|
-
const url = process.env.MDM_APP_URL;
|
|
34162
|
-
const waitForInstalled = parseBooleanEnv(process.env.MDM_APP_WAIT_FOR_INSTALLED);
|
|
34163
|
-
if (!appId && !url) {
|
|
34164
|
-
throw new Error("MDM install requires MDM_APP_ID or MDM_APP_URL.");
|
|
34165
|
-
}
|
|
34166
|
-
return {
|
|
34167
|
-
appId,
|
|
34168
|
-
url,
|
|
34169
|
-
waitForInstalled
|
|
34170
|
-
};
|
|
34171
|
-
}
|
|
34172
|
-
function parseBooleanEnv(value) {
|
|
34173
|
-
if (!value) {
|
|
34174
|
-
return void 0;
|
|
34175
|
-
}
|
|
34176
|
-
const normalized = value.trim().toLowerCase();
|
|
34177
|
-
if (normalized === "true" || normalized === "1" || normalized === "yes") {
|
|
34178
|
-
return true;
|
|
34179
|
-
}
|
|
34180
|
-
if (normalized === "false" || normalized === "0" || normalized === "no") {
|
|
34181
|
-
return false;
|
|
34182
|
-
}
|
|
34183
|
-
return void 0;
|
|
34184
|
-
}
|
|
34185
34106
|
function getProfileIdentifierFromProfile(profile) {
|
|
34186
34107
|
const pattern = /<key>PayloadIdentifier<\/key>\s*<string>([^<]+)<\/string>/g;
|
|
34187
34108
|
const matches = [];
|
|
@@ -34328,9 +34249,9 @@ var AppleDeviceKit = class {
|
|
|
34328
34249
|
*
|
|
34329
34250
|
* @param ipaPath Path to the IPA file
|
|
34330
34251
|
*/
|
|
34331
|
-
async installApp(ipaPath,
|
|
34252
|
+
async installApp(ipaPath, timeBetweenInstalls = 1e4) {
|
|
34332
34253
|
this.ensureNotDisposed();
|
|
34333
|
-
|
|
34254
|
+
return installManagedApp(ipaPath, this.deviceId, timeBetweenInstalls);
|
|
34334
34255
|
}
|
|
34335
34256
|
/**
|
|
34336
34257
|
* Uninstall an app by bundle ID (uninstall agent)
|