@mcesystems/apple-kit 1.0.50 → 1.0.52

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.mjs CHANGED
@@ -15027,19 +15027,19 @@ var require_printer = __commonJS({
15027
15027
  },
15028
15028
  // Document
15029
15029
  Document: function Document(node) {
15030
- return join10(node.definitions, "\n\n") + "\n";
15030
+ return join9(node.definitions, "\n\n") + "\n";
15031
15031
  },
15032
15032
  OperationDefinition: function OperationDefinition(node) {
15033
15033
  var op = node.operation;
15034
15034
  var name = node.name;
15035
- var varDefs = wrap("(", join10(node.variableDefinitions, ", "), ")");
15036
- var directives = join10(node.directives, " ");
15035
+ var varDefs = wrap("(", join9(node.variableDefinitions, ", "), ")");
15036
+ var directives = join9(node.directives, " ");
15037
15037
  var selectionSet = node.selectionSet;
15038
- return !name && !directives && !varDefs && op === "query" ? selectionSet : join10([op, join10([name, varDefs]), directives, selectionSet], " ");
15038
+ return !name && !directives && !varDefs && op === "query" ? selectionSet : join9([op, join9([name, varDefs]), directives, selectionSet], " ");
15039
15039
  },
15040
15040
  VariableDefinition: function VariableDefinition(_ref) {
15041
15041
  var variable = _ref.variable, type = _ref.type, defaultValue = _ref.defaultValue, directives = _ref.directives;
15042
- return variable + ": " + type + wrap(" = ", defaultValue) + wrap(" ", join10(directives, " "));
15042
+ return variable + ": " + type + wrap(" = ", defaultValue) + wrap(" ", join9(directives, " "));
15043
15043
  },
15044
15044
  SelectionSet: function SelectionSet(_ref2) {
15045
15045
  var selections = _ref2.selections;
@@ -15047,7 +15047,7 @@ var require_printer = __commonJS({
15047
15047
  },
15048
15048
  Field: function Field(_ref3) {
15049
15049
  var alias = _ref3.alias, name = _ref3.name, args = _ref3.arguments, directives = _ref3.directives, selectionSet = _ref3.selectionSet;
15050
- return join10([wrap("", alias, ": ") + name + wrap("(", join10(args, ", "), ")"), join10(directives, " "), selectionSet], " ");
15050
+ return join9([wrap("", alias, ": ") + name + wrap("(", join9(args, ", "), ")"), join9(directives, " "), selectionSet], " ");
15051
15051
  },
15052
15052
  Argument: function Argument(_ref4) {
15053
15053
  var name = _ref4.name, value = _ref4.value;
@@ -15056,18 +15056,18 @@ var require_printer = __commonJS({
15056
15056
  // Fragments
15057
15057
  FragmentSpread: function FragmentSpread(_ref5) {
15058
15058
  var name = _ref5.name, directives = _ref5.directives;
15059
- return "..." + name + wrap(" ", join10(directives, " "));
15059
+ return "..." + name + wrap(" ", join9(directives, " "));
15060
15060
  },
15061
15061
  InlineFragment: function InlineFragment(_ref6) {
15062
15062
  var typeCondition = _ref6.typeCondition, directives = _ref6.directives, selectionSet = _ref6.selectionSet;
15063
- return join10(["...", wrap("on ", typeCondition), join10(directives, " "), selectionSet], " ");
15063
+ return join9(["...", wrap("on ", typeCondition), join9(directives, " "), selectionSet], " ");
15064
15064
  },
15065
15065
  FragmentDefinition: function FragmentDefinition(_ref7) {
15066
15066
  var name = _ref7.name, typeCondition = _ref7.typeCondition, variableDefinitions = _ref7.variableDefinitions, directives = _ref7.directives, selectionSet = _ref7.selectionSet;
15067
15067
  return (
15068
15068
  // Note: fragment variable definitions are experimental and may be changed
15069
15069
  // or removed in the future.
15070
- "fragment ".concat(name).concat(wrap("(", join10(variableDefinitions, ", "), ")"), " ") + "on ".concat(typeCondition, " ").concat(wrap("", join10(directives, " "), " ")) + selectionSet
15070
+ "fragment ".concat(name).concat(wrap("(", join9(variableDefinitions, ", "), ")"), " ") + "on ".concat(typeCondition, " ").concat(wrap("", join9(directives, " "), " ")) + selectionSet
15071
15071
  );
15072
15072
  },
15073
15073
  // Value
@@ -15096,11 +15096,11 @@ var require_printer = __commonJS({
15096
15096
  },
15097
15097
  ListValue: function ListValue(_ref13) {
15098
15098
  var values = _ref13.values;
15099
- return "[" + join10(values, ", ") + "]";
15099
+ return "[" + join9(values, ", ") + "]";
15100
15100
  },
15101
15101
  ObjectValue: function ObjectValue(_ref14) {
15102
15102
  var fields = _ref14.fields;
15103
- return "{" + join10(fields, ", ") + "}";
15103
+ return "{" + join9(fields, ", ") + "}";
15104
15104
  },
15105
15105
  ObjectField: function ObjectField(_ref15) {
15106
15106
  var name = _ref15.name, value = _ref15.value;
@@ -15109,7 +15109,7 @@ var require_printer = __commonJS({
15109
15109
  // Directive
15110
15110
  Directive: function Directive(_ref16) {
15111
15111
  var name = _ref16.name, args = _ref16.arguments;
15112
- return "@" + name + wrap("(", join10(args, ", "), ")");
15112
+ return "@" + name + wrap("(", join9(args, ", "), ")");
15113
15113
  },
15114
15114
  // Type
15115
15115
  NamedType: function NamedType(_ref17) {
@@ -15127,7 +15127,7 @@ var require_printer = __commonJS({
15127
15127
  // Type System Definitions
15128
15128
  SchemaDefinition: function SchemaDefinition(_ref20) {
15129
15129
  var directives = _ref20.directives, operationTypes = _ref20.operationTypes;
15130
- return join10(["schema", join10(directives, " "), block(operationTypes)], " ");
15130
+ return join9(["schema", join9(directives, " "), block(operationTypes)], " ");
15131
15131
  },
15132
15132
  OperationTypeDefinition: function OperationTypeDefinition(_ref21) {
15133
15133
  var operation = _ref21.operation, type = _ref21.type;
@@ -15135,85 +15135,85 @@ var require_printer = __commonJS({
15135
15135
  },
15136
15136
  ScalarTypeDefinition: addDescription(function(_ref22) {
15137
15137
  var name = _ref22.name, directives = _ref22.directives;
15138
- return join10(["scalar", name, join10(directives, " ")], " ");
15138
+ return join9(["scalar", name, join9(directives, " ")], " ");
15139
15139
  }),
15140
15140
  ObjectTypeDefinition: addDescription(function(_ref23) {
15141
15141
  var name = _ref23.name, interfaces = _ref23.interfaces, directives = _ref23.directives, fields = _ref23.fields;
15142
- return join10(["type", name, wrap("implements ", join10(interfaces, " & ")), join10(directives, " "), block(fields)], " ");
15142
+ return join9(["type", name, wrap("implements ", join9(interfaces, " & ")), join9(directives, " "), block(fields)], " ");
15143
15143
  }),
15144
15144
  FieldDefinition: addDescription(function(_ref24) {
15145
15145
  var name = _ref24.name, args = _ref24.arguments, type = _ref24.type, directives = _ref24.directives;
15146
- return name + (hasMultilineItems(args) ? wrap("(\n", indent(join10(args, "\n")), "\n)") : wrap("(", join10(args, ", "), ")")) + ": " + type + wrap(" ", join10(directives, " "));
15146
+ return name + (hasMultilineItems(args) ? wrap("(\n", indent(join9(args, "\n")), "\n)") : wrap("(", join9(args, ", "), ")")) + ": " + type + wrap(" ", join9(directives, " "));
15147
15147
  }),
15148
15148
  InputValueDefinition: addDescription(function(_ref25) {
15149
15149
  var name = _ref25.name, type = _ref25.type, defaultValue = _ref25.defaultValue, directives = _ref25.directives;
15150
- return join10([name + ": " + type, wrap("= ", defaultValue), join10(directives, " ")], " ");
15150
+ return join9([name + ": " + type, wrap("= ", defaultValue), join9(directives, " ")], " ");
15151
15151
  }),
15152
15152
  InterfaceTypeDefinition: addDescription(function(_ref26) {
15153
15153
  var name = _ref26.name, directives = _ref26.directives, fields = _ref26.fields;
15154
- return join10(["interface", name, join10(directives, " "), block(fields)], " ");
15154
+ return join9(["interface", name, join9(directives, " "), block(fields)], " ");
15155
15155
  }),
15156
15156
  UnionTypeDefinition: addDescription(function(_ref27) {
15157
15157
  var name = _ref27.name, directives = _ref27.directives, types = _ref27.types;
15158
- return join10(["union", name, join10(directives, " "), types && types.length !== 0 ? "= " + join10(types, " | ") : ""], " ");
15158
+ return join9(["union", name, join9(directives, " "), types && types.length !== 0 ? "= " + join9(types, " | ") : ""], " ");
15159
15159
  }),
15160
15160
  EnumTypeDefinition: addDescription(function(_ref28) {
15161
15161
  var name = _ref28.name, directives = _ref28.directives, values = _ref28.values;
15162
- return join10(["enum", name, join10(directives, " "), block(values)], " ");
15162
+ return join9(["enum", name, join9(directives, " "), block(values)], " ");
15163
15163
  }),
15164
15164
  EnumValueDefinition: addDescription(function(_ref29) {
15165
15165
  var name = _ref29.name, directives = _ref29.directives;
15166
- return join10([name, join10(directives, " ")], " ");
15166
+ return join9([name, join9(directives, " ")], " ");
15167
15167
  }),
15168
15168
  InputObjectTypeDefinition: addDescription(function(_ref30) {
15169
15169
  var name = _ref30.name, directives = _ref30.directives, fields = _ref30.fields;
15170
- return join10(["input", name, join10(directives, " "), block(fields)], " ");
15170
+ return join9(["input", name, join9(directives, " "), block(fields)], " ");
15171
15171
  }),
15172
15172
  DirectiveDefinition: addDescription(function(_ref31) {
15173
15173
  var name = _ref31.name, args = _ref31.arguments, repeatable = _ref31.repeatable, locations = _ref31.locations;
15174
- return "directive @" + name + (hasMultilineItems(args) ? wrap("(\n", indent(join10(args, "\n")), "\n)") : wrap("(", join10(args, ", "), ")")) + (repeatable ? " repeatable" : "") + " on " + join10(locations, " | ");
15174
+ return "directive @" + name + (hasMultilineItems(args) ? wrap("(\n", indent(join9(args, "\n")), "\n)") : wrap("(", join9(args, ", "), ")")) + (repeatable ? " repeatable" : "") + " on " + join9(locations, " | ");
15175
15175
  }),
15176
15176
  SchemaExtension: function SchemaExtension(_ref32) {
15177
15177
  var directives = _ref32.directives, operationTypes = _ref32.operationTypes;
15178
- return join10(["extend schema", join10(directives, " "), block(operationTypes)], " ");
15178
+ return join9(["extend schema", join9(directives, " "), block(operationTypes)], " ");
15179
15179
  },
15180
15180
  ScalarTypeExtension: function ScalarTypeExtension(_ref33) {
15181
15181
  var name = _ref33.name, directives = _ref33.directives;
15182
- return join10(["extend scalar", name, join10(directives, " ")], " ");
15182
+ return join9(["extend scalar", name, join9(directives, " ")], " ");
15183
15183
  },
15184
15184
  ObjectTypeExtension: function ObjectTypeExtension(_ref34) {
15185
15185
  var name = _ref34.name, interfaces = _ref34.interfaces, directives = _ref34.directives, fields = _ref34.fields;
15186
- return join10(["extend type", name, wrap("implements ", join10(interfaces, " & ")), join10(directives, " "), block(fields)], " ");
15186
+ return join9(["extend type", name, wrap("implements ", join9(interfaces, " & ")), join9(directives, " "), block(fields)], " ");
15187
15187
  },
15188
15188
  InterfaceTypeExtension: function InterfaceTypeExtension(_ref35) {
15189
15189
  var name = _ref35.name, directives = _ref35.directives, fields = _ref35.fields;
15190
- return join10(["extend interface", name, join10(directives, " "), block(fields)], " ");
15190
+ return join9(["extend interface", name, join9(directives, " "), block(fields)], " ");
15191
15191
  },
15192
15192
  UnionTypeExtension: function UnionTypeExtension(_ref36) {
15193
15193
  var name = _ref36.name, directives = _ref36.directives, types = _ref36.types;
15194
- return join10(["extend union", name, join10(directives, " "), types && types.length !== 0 ? "= " + join10(types, " | ") : ""], " ");
15194
+ return join9(["extend union", name, join9(directives, " "), types && types.length !== 0 ? "= " + join9(types, " | ") : ""], " ");
15195
15195
  },
15196
15196
  EnumTypeExtension: function EnumTypeExtension(_ref37) {
15197
15197
  var name = _ref37.name, directives = _ref37.directives, values = _ref37.values;
15198
- return join10(["extend enum", name, join10(directives, " "), block(values)], " ");
15198
+ return join9(["extend enum", name, join9(directives, " "), block(values)], " ");
15199
15199
  },
15200
15200
  InputObjectTypeExtension: function InputObjectTypeExtension(_ref38) {
15201
15201
  var name = _ref38.name, directives = _ref38.directives, fields = _ref38.fields;
15202
- return join10(["extend input", name, join10(directives, " "), block(fields)], " ");
15202
+ return join9(["extend input", name, join9(directives, " "), block(fields)], " ");
15203
15203
  }
15204
15204
  };
15205
15205
  function addDescription(cb) {
15206
15206
  return function(node) {
15207
- return join10([node.description, cb(node)], "\n");
15207
+ return join9([node.description, cb(node)], "\n");
15208
15208
  };
15209
15209
  }
15210
- function join10(maybeArray, separator) {
15210
+ function join9(maybeArray, separator) {
15211
15211
  return maybeArray ? maybeArray.filter(function(x) {
15212
15212
  return x;
15213
15213
  }).join(separator || "") : "";
15214
15214
  }
15215
15215
  function block(array) {
15216
- return array && array.length !== 0 ? "{\n" + indent(join10(array, "\n")) + "\n}" : "";
15216
+ return array && array.length !== 0 ? "{\n" + indent(join9(array, "\n")) + "\n}" : "";
15217
15217
  }
15218
15218
  function wrap(start, maybeString, end) {
15219
15219
  return maybeString ? start + maybeString + (end || "") : "";
@@ -33361,12 +33361,11 @@ async function installApp(ipaPath, udid, options) {
33361
33361
  const mdmClient = await resolveMdmClient(options.mdm);
33362
33362
  const mdmInstallOptions = getMdmInstallOptions(options.mdm);
33363
33363
  await mdmClient.installApp(udid, mdmInstallOptions);
33364
- return;
33365
33364
  }
33365
+ await installLocalApp(ipaPath, udid);
33366
+ }
33367
+ async function installLocalApp(ipaPath, udid) {
33366
33368
  logTask(`Installing app ${ipaPath} on device ${udid}`);
33367
- if (!await isPaired(udid)) {
33368
- await waitForPairing(udid, 1e4);
33369
- }
33370
33369
  await runIDeviceTool("ideviceinstaller", ["-u", udid, "install", ipaPath]);
33371
33370
  }
33372
33371
  async function uninstallApp(bundleId, udid) {
@@ -33657,16 +33656,13 @@ function killPortForwardProcess(process2) {
33657
33656
 
33658
33657
  // src/logic/activationFlow.ts
33659
33658
  import { existsSync as existsSync4 } from "node:fs";
33660
- import { mkdir, unlink, writeFile as writeFile2 } from "node:fs/promises";
33661
- import { tmpdir as tmpdir2 } from "node:os";
33662
- import { dirname as dirname3, join as join8, resolve as resolve4 } from "node:path";
33659
+ import { unlink, writeFile } from "node:fs/promises";
33660
+ import { tmpdir } from "node:os";
33661
+ import { dirname as dirname3, join as join7, resolve as resolve4 } from "node:path";
33663
33662
  import { fileURLToPath as fileURLToPath2 } from "node:url";
33664
33663
 
33665
- // src/utils/trustProfile.ts
33664
+ // src/utils/wifiProfile.ts
33666
33665
  import { randomUUID } from "node:crypto";
33667
- import { writeFile } from "node:fs/promises";
33668
- import { tmpdir } from "node:os";
33669
- import { join as join7 } from "node:path";
33670
33666
 
33671
33667
  // src/utils/templateLoader.ts
33672
33668
  import { existsSync as existsSync3 } from "node:fs";
@@ -33755,56 +33751,7 @@ function escapeXml(str) {
33755
33751
  return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
33756
33752
  }
33757
33753
 
33758
- // src/utils/trustProfile.ts
33759
- async function generateTrustProfile(config, options) {
33760
- const {
33761
- organizationName,
33762
- certificateBase64,
33763
- certificateDisplayName = `${organizationName} Enterprise Certificate`,
33764
- profileDisplayName = `${organizationName} Enterprise Trust`
33765
- } = config;
33766
- const profileUuid = randomUUID().toUpperCase();
33767
- const certificateUuid = randomUUID().toUpperCase();
33768
- const orgShortName = organizationName.split(/\s+/)[0].toLowerCase();
33769
- const timestamp = Date.now();
33770
- const profileId = `com.${orgShortName}.enterprise.trust.${timestamp}`;
33771
- const payloadId = `${profileId}.cert`;
33772
- logInfo(`Generating trust profile for: ${organizationName}`);
33773
- const cleanCertBase64 = certificateBase64.replace(/-----BEGIN CERTIFICATE-----/g, "").replace(/-----END CERTIFICATE-----/g, "").replace(/\s/g, "");
33774
- const template = await loadTemplate("certificate-trust.xml", options?.plistDir);
33775
- const certificateFileName = `${orgShortName}_enterprise.cer`;
33776
- const variables = {
33777
- organizationName,
33778
- certificateBase64: cleanCertBase64,
33779
- certificateDescription: `Trusts ${organizationName} enterprise apps`,
33780
- certificateDisplayName,
33781
- profileDisplayName,
33782
- profileId,
33783
- profileUuid,
33784
- payloadId,
33785
- certificateUuid,
33786
- certificateFileName,
33787
- removalDisallowed: "false"
33788
- };
33789
- return processTemplate(template, variables);
33790
- }
33791
- async function generateTrustProfileFromEnv(organizationName, options) {
33792
- const certBase64 = process.env.TRUST_CERT_BASE64;
33793
- if (!certBase64) {
33794
- logInfo("TRUST_CERT_BASE64 environment variable not set, skipping trust profile generation.");
33795
- return void 0;
33796
- }
33797
- return generateTrustProfile(
33798
- {
33799
- organizationName,
33800
- certificateBase64: certBase64
33801
- },
33802
- options
33803
- );
33804
- }
33805
-
33806
33754
  // src/utils/wifiProfile.ts
33807
- import { randomUUID as randomUUID2 } from "node:crypto";
33808
33755
  async function generateWifiProfile(config, options) {
33809
33756
  const {
33810
33757
  ssid,
@@ -33819,8 +33766,8 @@ async function generateWifiProfile(config, options) {
33819
33766
  eapType = "PEAP",
33820
33767
  acceptAnyCertificate = true
33821
33768
  } = config;
33822
- const profileUuid = randomUUID2().toUpperCase();
33823
- const payloadUuid = randomUUID2().toUpperCase();
33769
+ const profileUuid = randomUUID().toUpperCase();
33770
+ const payloadUuid = randomUUID().toUpperCase();
33824
33771
  const profileId = `com.mce.wifi.${ssid.replace(/[^a-zA-Z0-9]/g, "")}.${Date.now()}`;
33825
33772
  const payloadId = `${profileId}.payload`;
33826
33773
  logInfo(`Generating WiFi profile for SSID: ${ssid}, encryption: ${encryptionType}`);
@@ -34017,10 +33964,13 @@ function createIosCli(iosBinaryPath) {
34017
33964
  // src/logic/activationFlow.ts
34018
33965
  var DEFAULT_RETRIES = 150;
34019
33966
  var DEFAULT_RETRY_DELAY_MS = 2e3;
33967
+ function sleep(ms) {
33968
+ return new Promise((resolve5) => setTimeout(resolve5, ms));
33969
+ }
34020
33970
  var ActivationFlow = class {
34021
33971
  iosCli;
34022
33972
  mdmClientPromise;
34023
- organizationName;
33973
+ // private readonly organizationName?: string;
34024
33974
  resourcesDir;
34025
33975
  constructor(config) {
34026
33976
  const iosBinaryPath = resolveIosBinaryPath(config);
@@ -34029,7 +33979,6 @@ var ActivationFlow = class {
34029
33979
  }
34030
33980
  this.iosCli = createIosCli(iosBinaryPath);
34031
33981
  this.mdmClientPromise = createMdmClientFromEnv({ resourcesDir: config.resourcesDir });
34032
- this.organizationName = config.organizationName ?? process.env.ORGANIZATION_NAME;
34033
33982
  this.resourcesDir = config.resourcesDir;
34034
33983
  }
34035
33984
  async run(udid) {
@@ -34045,12 +33994,11 @@ var ActivationFlow = class {
34045
33994
  await this.installWifiProfile(udid);
34046
33995
  await this.installMdmProfile(udid);
34047
33996
  await this.retryIosCommand("skip steps", () => this.iosCli.skipSteps(udid));
34048
- await this.installTrustProfile(udid);
33997
+ await this.installManagedApp(udid);
34049
33998
  return "activated";
34050
33999
  }
34051
34000
  async installWifiProfile(udid) {
34052
- const plistDir = this.resourcesDir ? resolveResourcesPlistDir(this.resourcesDir) : void 0;
34053
- const wifiProfile = await generateWifiProfileFromEnv({ plistDir });
34001
+ const wifiProfile = await generateWifiProfileFromEnv();
34054
34002
  if (!wifiProfile) {
34055
34003
  return;
34056
34004
  }
@@ -34070,15 +34018,6 @@ var ActivationFlow = class {
34070
34018
  return activationState;
34071
34019
  }
34072
34020
  async installMdmProfile(udid) {
34073
- const offlineProfilePath = getResourcesEnrollmentProfilePath(this.resourcesDir, udid);
34074
- if (offlineProfilePath) {
34075
- logTask("Installing MDM enrollment profile from resources");
34076
- await this.retryIosCommand(
34077
- "install mdm profile",
34078
- () => this.iosCli.installProfile(udid, offlineProfilePath)
34079
- );
34080
- return;
34081
- }
34082
34021
  const client = await this.requireMdmClient();
34083
34022
  logTask("Installing MDM enrollment profile");
34084
34023
  const enrollmentProfile = await this.retry(
@@ -34096,32 +34035,38 @@ var ActivationFlow = class {
34096
34035
  );
34097
34036
  await removeTempFile(profilePath, "mdm profile");
34098
34037
  }
34099
- async installTrustProfile(udid) {
34100
- const resourcesProfilePath = getResourcesTrustProfilePath(this.resourcesDir);
34101
- if (existsSync4(resourcesProfilePath)) {
34102
- logTask("Installing trust profile from resources");
34103
- await this.retryIosCommand(
34104
- "install trust profile",
34105
- () => this.iosCli.installProfile(udid, resourcesProfilePath)
34106
- );
34107
- return;
34108
- }
34109
- if (!this.organizationName) {
34110
- logError("ORGANIZATION_NAME is required to generate trust profile");
34111
- throw new Error("ORGANIZATION_NAME is required for trust profile generation");
34112
- }
34113
- const plistDir = this.resourcesDir ? resolveResourcesPlistDir(this.resourcesDir) : void 0;
34114
- const trustProfile = await generateTrustProfileFromEnv(this.organizationName, { plistDir });
34115
- if (!trustProfile) {
34116
- return;
34117
- }
34118
- logTask("Generating trust profile and saving to resources");
34119
- await ensureResourcesDirExists(this.resourcesDir);
34120
- await writeFile2(resourcesProfilePath, trustProfile, "utf-8");
34121
- await this.retryIosCommand(
34122
- "install trust profile",
34123
- () => this.iosCli.installProfile(udid, resourcesProfilePath)
34124
- );
34038
+ // private async installTrustProfile(udid: string): Promise<void> {
34039
+ // const resourcesProfilePath = getResourcesTrustProfilePath(this.resourcesDir);
34040
+ // if (existsSync(resourcesProfilePath)) {
34041
+ // logTask("Installing trust profile from resources");
34042
+ // await this.retryIosCommand("install trust profile", () =>
34043
+ // this.iosCli.installProfile(udid, resourcesProfilePath)
34044
+ // );
34045
+ // return;
34046
+ // }
34047
+ // if (!this.organizationName) {
34048
+ // logError("ORGANIZATION_NAME is required to generate trust profile");
34049
+ // throw new Error("ORGANIZATION_NAME is required for trust profile generation");
34050
+ // }
34051
+ // const trustProfile = await generateTrustProfileFromEnv(this.organizationName);
34052
+ // if (!trustProfile) {
34053
+ // return;
34054
+ // }
34055
+ // logTask("Generating trust profile and saving to resources");
34056
+ // await ensureResourcesDirExists(this.resourcesDir);
34057
+ // await writeFile(resourcesProfilePath, trustProfile, "utf-8");
34058
+ // await this.retryIosCommand("install trust profile", () =>
34059
+ // this.iosCli.installProfile(udid, resourcesProfilePath)
34060
+ // );
34061
+ // }
34062
+ async installManagedApp(udid) {
34063
+ const ipaPath = resolveManagedAppPath(this.resourcesDir);
34064
+ await installLocalApp(ipaPath, udid);
34065
+ const mdmInstallOptions = getMdmInstallOptionsFromEnv();
34066
+ const client = await this.requireMdmClient();
34067
+ logTask("Installing app via MDM for management takeover");
34068
+ await sleep(1e4);
34069
+ client.installApp(udid, mdmInstallOptions);
34125
34070
  }
34126
34071
  async requireMdmClient() {
34127
34072
  const client = await this.mdmClientPromise;
@@ -34154,8 +34099,8 @@ var ActivationFlow = class {
34154
34099
  }
34155
34100
  };
34156
34101
  async function saveProfileToTemp(profile, prefix) {
34157
- const tempFilePath = join8(tmpdir2(), `mce_${prefix}_${Date.now()}.mobileconfig`);
34158
- await writeFile2(tempFilePath, profile, "utf-8");
34102
+ const tempFilePath = join7(tmpdir(), `mce_${prefix}_${Date.now()}.mobileconfig`);
34103
+ await writeFile(tempFilePath, profile, "utf-8");
34159
34104
  logInfo(`Profile saved to: ${tempFilePath}`);
34160
34105
  return tempFilePath;
34161
34106
  }
@@ -34168,13 +34113,39 @@ async function removeTempFile(filePath, label) {
34168
34113
  logError(`Failed to remove ${label} temp file: ${errorMsg}`);
34169
34114
  }
34170
34115
  }
34171
- function getResourcesTrustProfilePath(resourcesDir) {
34116
+ function resolveManagedAppPath(resourcesDir) {
34172
34117
  const resolvedResourcesDir = resolveResourcesDir(resourcesDir);
34173
- return join8(resolvedResourcesDir, "trust_profile.mobileconfig");
34118
+ const ipaPath = join7(resolvedResourcesDir, "deviceagent.ipa");
34119
+ if (!existsSync4(ipaPath)) {
34120
+ throw new Error(`Managed app IPA not found at ${ipaPath}`);
34121
+ }
34122
+ return ipaPath;
34174
34123
  }
34175
- async function ensureResourcesDirExists(resourcesDir) {
34176
- const resolvedResourcesDir = resolveResourcesDir(resourcesDir);
34177
- await mkdir(resolvedResourcesDir, { recursive: true });
34124
+ function getMdmInstallOptionsFromEnv() {
34125
+ const appId = process.env.MDM_APP_ID;
34126
+ const url = process.env.MDM_APP_URL;
34127
+ const waitForInstalled = parseBooleanEnv(process.env.MDM_APP_WAIT_FOR_INSTALLED);
34128
+ if (!appId && !url) {
34129
+ throw new Error("MDM install requires MDM_APP_ID or MDM_APP_URL.");
34130
+ }
34131
+ return {
34132
+ appId,
34133
+ url,
34134
+ waitForInstalled
34135
+ };
34136
+ }
34137
+ function parseBooleanEnv(value) {
34138
+ if (!value) {
34139
+ return void 0;
34140
+ }
34141
+ const normalized = value.trim().toLowerCase();
34142
+ if (normalized === "true" || normalized === "1" || normalized === "yes") {
34143
+ return true;
34144
+ }
34145
+ if (normalized === "false" || normalized === "0" || normalized === "no") {
34146
+ return false;
34147
+ }
34148
+ return void 0;
34178
34149
  }
34179
34150
  function resolveResourcesDir(resourcesDir) {
34180
34151
  if (resourcesDir) {
@@ -34182,25 +34153,8 @@ function resolveResourcesDir(resourcesDir) {
34182
34153
  }
34183
34154
  const currentFile = fileURLToPath2(import.meta.url);
34184
34155
  const currentDir = dirname3(currentFile);
34185
- const packageRoot = join8(currentDir, "..", "..");
34186
- return join8(packageRoot, "resources");
34187
- }
34188
- function resolveResourcesPlistDir(resourcesDir) {
34189
- return join8(resolveResourcesDir(resourcesDir), "plist");
34190
- }
34191
- function getResourcesEnrollmentProfilePath(resourcesDir, udid) {
34192
- const baseDir = resolveResourcesDir(resourcesDir);
34193
- const mdmDir = join8(baseDir, "mdm");
34194
- const candidates = [
34195
- udid ? join8(mdmDir, `enrollment_${udid}.mobileconfig`) : void 0,
34196
- join8(mdmDir, "enrollment.mobileconfig")
34197
- ];
34198
- for (const candidate of candidates) {
34199
- if (candidate && existsSync4(candidate)) {
34200
- return candidate;
34201
- }
34202
- }
34203
- return void 0;
34156
+ const packageRoot = join7(currentDir, "..", "..");
34157
+ return join7(packageRoot, "resources");
34204
34158
  }
34205
34159
  function resolveIosBinaryPath(config) {
34206
34160
  if (config.iosBinaryPath) {
@@ -34211,7 +34165,7 @@ function resolveIosBinaryPath(config) {
34211
34165
  }
34212
34166
  const platform = process.platform;
34213
34167
  const binaryName = platform === "win32" ? "ios.exe" : "ios";
34214
- return join8(resolveResourcesDir(config.resourcesDir), "ios", "bin", platform, binaryName);
34168
+ return join7(resolveResourcesDir(config.resourcesDir), "ios", "bin", platform, binaryName);
34215
34169
  }
34216
34170
  function getActivationState2(output) {
34217
34171
  if (!Array.isArray(output) || output.length === 0) {
@@ -34486,7 +34440,7 @@ var AppleDeviceKit = class {
34486
34440
 
34487
34441
  // src/logic/actions/usbmuxd.ts
34488
34442
  import { spawn as spawn3 } from "node:child_process";
34489
- import { join as join9 } from "node:path";
34443
+ import { join as join8 } from "node:path";
34490
34444
  var usbmuxdProcess = null;
34491
34445
  function startUsbmuxd(foreground = false, options) {
34492
34446
  const current = usbmuxdProcess;
@@ -34496,7 +34450,7 @@ function startUsbmuxd(foreground = false, options) {
34496
34450
  }
34497
34451
  const binPath = getResourcesBinPath({ resourcesDir: options?.resourcesDir });
34498
34452
  const ext = process.platform === "win32" ? ".exe" : "";
34499
- const toolPath = binPath ? join9(binPath, `usbmuxd${ext}`) : `usbmuxd${ext}`;
34453
+ const toolPath = binPath ? join8(binPath, `usbmuxd${ext}`) : `usbmuxd${ext}`;
34500
34454
  const args = foreground ? ["-f"] : [];
34501
34455
  const spawnOptions = {
34502
34456
  windowsHide: true,