@mcesystems/apple-kit 1.0.52 → 1.0.53

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 CHANGED
@@ -33953,6 +33953,9 @@ function createIosCli(iosBinaryPath) {
33953
33953
  async installProfile(deviceId, profilePath) {
33954
33954
  return runIosCommand(iosBinaryPath, ["profile", "add", profilePath, "--udid", deviceId]);
33955
33955
  },
33956
+ async removeProfile(deviceId, profileName) {
33957
+ return runIosCommand(iosBinaryPath, ["profile", "remove", profileName, "--udid", deviceId]);
33958
+ },
33956
33959
  async skipSteps(deviceId) {
33957
33960
  return runIosCommand(iosBinaryPath, ["prepare", "--skip-all", "--udid", deviceId]);
33958
33961
  },
@@ -33979,7 +33982,9 @@ function createIosCli(iosBinaryPath) {
33979
33982
  // src/logic/activationFlow.ts
33980
33983
  var import_meta3 = {};
33981
33984
  var DEFAULT_RETRIES = 150;
33982
- var DEFAULT_RETRY_DELAY_MS = 2e3;
33985
+ var DEFAULT_RETRY_DELAY_MS = 1e3;
33986
+ var TIME_BETWEEN_INSTALLS = 5e3;
33987
+ var TIME_TO_WAIT_FOR_MANAGED_APP_INSTALL = 1e4;
33983
33988
  function sleep(ms) {
33984
33989
  return new Promise((resolve5) => setTimeout(resolve5, ms));
33985
33990
  }
@@ -34007,23 +34012,27 @@ var ActivationFlow = class {
34007
34012
  await this.retryIosCommand("wipe", () => this.iosCli.wipe(udid));
34008
34013
  return "wiped";
34009
34014
  }
34010
- await this.installWifiProfile(udid);
34015
+ const wifiProfileIdentifier = await this.installWifiProfile(udid);
34011
34016
  await this.installMdmProfile(udid);
34012
34017
  await this.retryIosCommand("skip steps", () => this.iosCli.skipSteps(udid));
34013
34018
  await this.installManagedApp(udid);
34019
+ await sleep(TIME_TO_WAIT_FOR_MANAGED_APP_INSTALL);
34020
+ await this.removeWifiProfile(udid, wifiProfileIdentifier);
34014
34021
  return "activated";
34015
34022
  }
34016
34023
  async installWifiProfile(udid) {
34017
34024
  const wifiProfile = await generateWifiProfileFromEnv();
34018
34025
  if (!wifiProfile) {
34019
- return;
34026
+ return void 0;
34020
34027
  }
34021
34028
  const wifiProfilePath = await saveWifiProfileToTemp(wifiProfile);
34029
+ const wifiProfileIdentifier = getProfileIdentifierFromProfile(wifiProfile);
34022
34030
  await this.retryIosCommand(
34023
34031
  "install wifi profile",
34024
34032
  () => this.iosCli.installProfile(udid, wifiProfilePath)
34025
34033
  );
34026
34034
  await removeTempFile(wifiProfilePath, "wifi profile");
34035
+ return wifiProfileIdentifier;
34027
34036
  }
34028
34037
  async getActivationState(udid) {
34029
34038
  const infoResult = await this.retryIosCommand("device info", () => this.iosCli.info(udid));
@@ -34081,9 +34090,19 @@ var ActivationFlow = class {
34081
34090
  const mdmInstallOptions = getMdmInstallOptionsFromEnv();
34082
34091
  const client = await this.requireMdmClient();
34083
34092
  logTask("Installing app via MDM for management takeover");
34084
- await sleep(1e4);
34093
+ await sleep(TIME_BETWEEN_INSTALLS);
34085
34094
  client.installApp(udid, mdmInstallOptions);
34086
34095
  }
34096
+ async removeWifiProfile(udid, profileIdentifier) {
34097
+ if (!profileIdentifier) {
34098
+ return;
34099
+ }
34100
+ logTask("Removing WiFi profile");
34101
+ await this.retryIosCommand(
34102
+ "remove wifi profile",
34103
+ () => this.iosCli.removeProfile(udid, profileIdentifier)
34104
+ );
34105
+ }
34087
34106
  async requireMdmClient() {
34088
34107
  const client = await this.mdmClientPromise;
34089
34108
  if (!client) {
@@ -34163,6 +34182,19 @@ function parseBooleanEnv(value) {
34163
34182
  }
34164
34183
  return void 0;
34165
34184
  }
34185
+ function getProfileIdentifierFromProfile(profile) {
34186
+ const pattern = /<key>PayloadIdentifier<\/key>\s*<string>([^<]+)<\/string>/g;
34187
+ const matches = [];
34188
+ let match = pattern.exec(profile);
34189
+ while (match) {
34190
+ matches.push(match[1].trim());
34191
+ match = pattern.exec(profile);
34192
+ }
34193
+ if (matches.length === 0) {
34194
+ return void 0;
34195
+ }
34196
+ return matches[matches.length - 1];
34197
+ }
34166
34198
  function resolveResourcesDir(resourcesDir) {
34167
34199
  if (resourcesDir) {
34168
34200
  return (0, import_node_path7.resolve)(resourcesDir);