@mcesystems/apple-kit 1.0.86 → 1.0.87

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
@@ -838,14 +838,14 @@ function createLoggers(namespace, logLevel = process.env.LOG_LEVEL ?? "none") {
838
838
  const logInfo8 = (0, import_debug.default)(`${namespace}:info`);
839
839
  const logTask5 = (0, import_debug.default)(`${namespace}:task`);
840
840
  const logError3 = (0, import_debug.default)(`${namespace}:error`);
841
- const logDetail2 = (0, import_debug.default)(`${namespace}:detail`);
841
+ const logDetail3 = (0, import_debug.default)(`${namespace}:detail`);
842
842
  const logDebug = (0, import_debug.default)(`${namespace}:debug`);
843
843
  const logWarning3 = (0, import_debug.default)(`${namespace}:warning`);
844
844
  const logColor = (0, import_debug.default)(`${namespace}:color`);
845
845
  logInfo8.color = "19";
846
846
  logTask5.color = "25";
847
847
  logError3.color = "1";
848
- logDetail2.color = "199";
848
+ logDetail3.color = "199";
849
849
  logWarning3.color = "186";
850
850
  logDebug.color = "211";
851
851
  logColor.enabled = true;
@@ -853,7 +853,7 @@ function createLoggers(namespace, logLevel = process.env.LOG_LEVEL ?? "none") {
853
853
  logInfo8.namespace = `${namespace2}:info`;
854
854
  logTask5.namespace = `${namespace2}:task`;
855
855
  logError3.namespace = `${namespace2}:error`;
856
- logDetail2.namespace = `${namespace2}:detail`;
856
+ logDetail3.namespace = `${namespace2}:detail`;
857
857
  logWarning3.namespace = `${namespace2}:warning`;
858
858
  logDebug.namespace = `${namespace2}:debug`;
859
859
  }
@@ -864,7 +864,7 @@ function createLoggers(namespace, logLevel = process.env.LOG_LEVEL ?? "none") {
864
864
  logTask5.enabled = true;
865
865
  logError3.enabled = true;
866
866
  logWarning3.enabled = true;
867
- logDetail2.enabled = false;
867
+ logDetail3.enabled = false;
868
868
  logDebug.enabled = false;
869
869
  break;
870
870
  case "debug":
@@ -872,7 +872,7 @@ function createLoggers(namespace, logLevel = process.env.LOG_LEVEL ?? "none") {
872
872
  logTask5.enabled = true;
873
873
  logError3.enabled = true;
874
874
  logWarning3.enabled = true;
875
- logDetail2.enabled = true;
875
+ logDetail3.enabled = true;
876
876
  logDebug.enabled = true;
877
877
  break;
878
878
  case "none":
@@ -880,7 +880,7 @@ function createLoggers(namespace, logLevel = process.env.LOG_LEVEL ?? "none") {
880
880
  logTask5.enabled = false;
881
881
  logError3.enabled = false;
882
882
  logWarning3.enabled = false;
883
- logDetail2.enabled = false;
883
+ logDetail3.enabled = false;
884
884
  logDebug.enabled = false;
885
885
  break;
886
886
  }
@@ -898,7 +898,7 @@ function createLoggers(namespace, logLevel = process.env.LOG_LEVEL ?? "none") {
898
898
  logError3.color = color;
899
899
  break;
900
900
  case "detail":
901
- logDetail2.color = color;
901
+ logDetail3.color = color;
902
902
  break;
903
903
  case "warning":
904
904
  logWarning3.color = color;
@@ -965,7 +965,7 @@ ${" ".repeat(padding)}${"=".repeat(80)}`;
965
965
  const functionName = functionMatch ? functionMatch[1] : "<anonymous>";
966
966
  callerDetails = `${functionName}`;
967
967
  }
968
- logDetail2(`${header(`*${title}* ${callerDetails}`)}
968
+ logDetail3(`${header(`*${title}* ${callerDetails}`)}
969
969
  ${args.reduce((acc, arg) => `${acc}
970
970
  ${logDataDetail(arg)}`, "")}
971
971
 
@@ -988,7 +988,7 @@ ${"=".repeat(80)}`);
988
988
  logInfo: logInfo8,
989
989
  logTask: logTask5,
990
990
  logError: logError3,
991
- logDetail: logDetail2,
991
+ logDetail: logDetail3,
992
992
  logDebug,
993
993
  logWarning: logWarning3,
994
994
  logColor,
@@ -36575,14 +36575,14 @@ function createLoggers2(namespace, logLevel = process.env.LOG_LEVEL ?? "none") {
36575
36575
  const logInfo222 = (0, import_debug2.default)(`${namespace}:info`);
36576
36576
  const logTask5 = (0, import_debug2.default)(`${namespace}:task`);
36577
36577
  const logError22 = (0, import_debug2.default)(`${namespace}:error`);
36578
- const logDetail2 = (0, import_debug2.default)(`${namespace}:detail`);
36578
+ const logDetail3 = (0, import_debug2.default)(`${namespace}:detail`);
36579
36579
  const logDebug = (0, import_debug2.default)(`${namespace}:debug`);
36580
36580
  const logWarning22 = (0, import_debug2.default)(`${namespace}:warning`);
36581
36581
  const logColor = (0, import_debug2.default)(`${namespace}:color`);
36582
36582
  logInfo222.color = "19";
36583
36583
  logTask5.color = "25";
36584
36584
  logError22.color = "1";
36585
- logDetail2.color = "199";
36585
+ logDetail3.color = "199";
36586
36586
  logWarning22.color = "186";
36587
36587
  logDebug.color = "211";
36588
36588
  logColor.enabled = true;
@@ -36590,7 +36590,7 @@ function createLoggers2(namespace, logLevel = process.env.LOG_LEVEL ?? "none") {
36590
36590
  logInfo222.namespace = `${namespace2}:info`;
36591
36591
  logTask5.namespace = `${namespace2}:task`;
36592
36592
  logError22.namespace = `${namespace2}:error`;
36593
- logDetail2.namespace = `${namespace2}:detail`;
36593
+ logDetail3.namespace = `${namespace2}:detail`;
36594
36594
  logWarning22.namespace = `${namespace2}:warning`;
36595
36595
  logDebug.namespace = `${namespace2}:debug`;
36596
36596
  }
@@ -36601,7 +36601,7 @@ function createLoggers2(namespace, logLevel = process.env.LOG_LEVEL ?? "none") {
36601
36601
  logTask5.enabled = true;
36602
36602
  logError22.enabled = true;
36603
36603
  logWarning22.enabled = true;
36604
- logDetail2.enabled = false;
36604
+ logDetail3.enabled = false;
36605
36605
  logDebug.enabled = false;
36606
36606
  break;
36607
36607
  case "debug":
@@ -36609,7 +36609,7 @@ function createLoggers2(namespace, logLevel = process.env.LOG_LEVEL ?? "none") {
36609
36609
  logTask5.enabled = true;
36610
36610
  logError22.enabled = true;
36611
36611
  logWarning22.enabled = true;
36612
- logDetail2.enabled = true;
36612
+ logDetail3.enabled = true;
36613
36613
  logDebug.enabled = true;
36614
36614
  break;
36615
36615
  case "none":
@@ -36617,7 +36617,7 @@ function createLoggers2(namespace, logLevel = process.env.LOG_LEVEL ?? "none") {
36617
36617
  logTask5.enabled = false;
36618
36618
  logError22.enabled = false;
36619
36619
  logWarning22.enabled = false;
36620
- logDetail2.enabled = false;
36620
+ logDetail3.enabled = false;
36621
36621
  logDebug.enabled = false;
36622
36622
  break;
36623
36623
  }
@@ -36635,7 +36635,7 @@ function createLoggers2(namespace, logLevel = process.env.LOG_LEVEL ?? "none") {
36635
36635
  logError22.color = color;
36636
36636
  break;
36637
36637
  case "detail":
36638
- logDetail2.color = color;
36638
+ logDetail3.color = color;
36639
36639
  break;
36640
36640
  case "warning":
36641
36641
  logWarning22.color = color;
@@ -36702,7 +36702,7 @@ ${" ".repeat(padding)}${"=".repeat(80)}`;
36702
36702
  const functionName = functionMatch ? functionMatch[1] : "<anonymous>";
36703
36703
  callerDetails = `${functionName}`;
36704
36704
  }
36705
- logDetail2(`${header(`*${title}* ${callerDetails}`)}
36705
+ logDetail3(`${header(`*${title}* ${callerDetails}`)}
36706
36706
  ${args.reduce((acc, arg) => `${acc}
36707
36707
  ${logDataDetail(arg)}`, "")}
36708
36708
 
@@ -36725,7 +36725,7 @@ ${"=".repeat(80)}`);
36725
36725
  logInfo: logInfo222,
36726
36726
  logTask: logTask5,
36727
36727
  logError: logError22,
36728
- logDetail: logDetail2,
36728
+ logDetail: logDetail3,
36729
36729
  logDebug,
36730
36730
  logWarning: logWarning22,
36731
36731
  logColor,
@@ -37672,14 +37672,14 @@ function createLoggers22(namespace, logLevel = process.env.LOG_LEVEL ?? "none")
37672
37672
  const logInfo32 = (0, import_debug22.default)(`${namespace}:info`);
37673
37673
  const logTask5 = (0, import_debug22.default)(`${namespace}:task`);
37674
37674
  const logError22 = (0, import_debug22.default)(`${namespace}:error`);
37675
- const logDetail2 = (0, import_debug22.default)(`${namespace}:detail`);
37675
+ const logDetail3 = (0, import_debug22.default)(`${namespace}:detail`);
37676
37676
  const logDebug = (0, import_debug22.default)(`${namespace}:debug`);
37677
37677
  const logWarning22 = (0, import_debug22.default)(`${namespace}:warning`);
37678
37678
  const logColor = (0, import_debug22.default)(`${namespace}:color`);
37679
37679
  logInfo32.color = "19";
37680
37680
  logTask5.color = "25";
37681
37681
  logError22.color = "1";
37682
- logDetail2.color = "199";
37682
+ logDetail3.color = "199";
37683
37683
  logWarning22.color = "186";
37684
37684
  logDebug.color = "211";
37685
37685
  logColor.enabled = true;
@@ -37687,7 +37687,7 @@ function createLoggers22(namespace, logLevel = process.env.LOG_LEVEL ?? "none")
37687
37687
  logInfo32.namespace = `${namespace2}:info`;
37688
37688
  logTask5.namespace = `${namespace2}:task`;
37689
37689
  logError22.namespace = `${namespace2}:error`;
37690
- logDetail2.namespace = `${namespace2}:detail`;
37690
+ logDetail3.namespace = `${namespace2}:detail`;
37691
37691
  logWarning22.namespace = `${namespace2}:warning`;
37692
37692
  logDebug.namespace = `${namespace2}:debug`;
37693
37693
  }
@@ -37698,7 +37698,7 @@ function createLoggers22(namespace, logLevel = process.env.LOG_LEVEL ?? "none")
37698
37698
  logTask5.enabled = true;
37699
37699
  logError22.enabled = true;
37700
37700
  logWarning22.enabled = true;
37701
- logDetail2.enabled = false;
37701
+ logDetail3.enabled = false;
37702
37702
  logDebug.enabled = false;
37703
37703
  break;
37704
37704
  case "debug":
@@ -37706,7 +37706,7 @@ function createLoggers22(namespace, logLevel = process.env.LOG_LEVEL ?? "none")
37706
37706
  logTask5.enabled = true;
37707
37707
  logError22.enabled = true;
37708
37708
  logWarning22.enabled = true;
37709
- logDetail2.enabled = true;
37709
+ logDetail3.enabled = true;
37710
37710
  logDebug.enabled = true;
37711
37711
  break;
37712
37712
  case "none":
@@ -37714,7 +37714,7 @@ function createLoggers22(namespace, logLevel = process.env.LOG_LEVEL ?? "none")
37714
37714
  logTask5.enabled = false;
37715
37715
  logError22.enabled = false;
37716
37716
  logWarning22.enabled = false;
37717
- logDetail2.enabled = false;
37717
+ logDetail3.enabled = false;
37718
37718
  logDebug.enabled = false;
37719
37719
  break;
37720
37720
  }
@@ -37732,7 +37732,7 @@ function createLoggers22(namespace, logLevel = process.env.LOG_LEVEL ?? "none")
37732
37732
  logError22.color = color;
37733
37733
  break;
37734
37734
  case "detail":
37735
- logDetail2.color = color;
37735
+ logDetail3.color = color;
37736
37736
  break;
37737
37737
  case "warning":
37738
37738
  logWarning22.color = color;
@@ -37799,7 +37799,7 @@ ${" ".repeat(padding)}${"=".repeat(80)}`;
37799
37799
  const functionName = functionMatch ? functionMatch[1] : "<anonymous>";
37800
37800
  callerDetails = `${functionName}`;
37801
37801
  }
37802
- logDetail2(`${header(`*${title}* ${callerDetails}`)}
37802
+ logDetail3(`${header(`*${title}* ${callerDetails}`)}
37803
37803
  ${args.reduce((acc, arg) => `${acc}
37804
37804
  ${logDataDetail(arg)}`, "")}
37805
37805
 
@@ -37822,7 +37822,7 @@ ${"=".repeat(80)}`);
37822
37822
  logInfo: logInfo32,
37823
37823
  logTask: logTask5,
37824
37824
  logError: logError22,
37825
- logDetail: logDetail2,
37825
+ logDetail: logDetail3,
37826
37826
  logDebug,
37827
37827
  logWarning: logWarning22,
37828
37828
  logColor,
@@ -37932,10 +37932,7 @@ var InstallActions = class {
37932
37932
  return this.iosClient.installApp(ipaPath);
37933
37933
  }
37934
37934
  async installManagedApp(ipaPath, options) {
37935
- const fs9f4 = __require("node:fs");
37936
- fs9f4.appendFileSync("debug-9f3919.log", JSON.stringify({ sessionId: "9f3919", location: "install.ts:installManagedApp:entry", message: "installManagedApp called", data: { ipaPath, udid: this.udid, options }, timestamp: Date.now(), hypothesisId: "C" }) + "\n");
37937
37935
  const result = await this.iosClient.installApp(ipaPath);
37938
- fs9f4.appendFileSync("debug-9f3919.log", JSON.stringify({ sessionId: "9f3919", location: "install.ts:installManagedApp:afterInstall", message: "iosClient.installApp returned", data: { exitCode: result.exitCode, stderr: result.raw.stderr.substring(0, 2e3), stdout: result.raw.stdout.substring(0, 2e3) }, timestamp: Date.now(), hypothesisId: "A" }) + "\n");
37939
37936
  logInfo3("Installing app via MDM for management takeover");
37940
37937
  const mdmClient = await createMDMClient();
37941
37938
  if (!mdmClient) {
@@ -37968,7 +37965,7 @@ var InstallActions = class {
37968
37965
  };
37969
37966
 
37970
37967
  // src/logic/actions/proxy.ts
37971
- var { logTask: logTask2, logInfo: logInfo4, setNamespace: setNamespace3 } = createLoggers("");
37968
+ var { logTask: logTask2, logInfo: logInfo4, setNamespace: setNamespace3, logDetail } = createLoggers("");
37972
37969
  var ProxyActions = class {
37973
37970
  constructor(udid, iosClient) {
37974
37971
  this.udid = udid;
@@ -37976,15 +37973,26 @@ var ProxyActions = class {
37976
37973
  setNamespace3(`apple-${udid}`);
37977
37974
  }
37978
37975
  childProcess = /* @__PURE__ */ new Map();
37979
- async startPortForward(localPort, devicePort) {
37976
+ async startPortForward(localPort, devicePort, timeoutMs = 1e4) {
37980
37977
  logInfo4(`Starting port forward ${localPort} -> ${devicePort} for device ${this.udid}`);
37981
37978
  const result = this.iosClient.forward({ fromPort: localPort, toPort: devicePort });
37982
37979
  this.childProcess.set(this.udid, result);
37983
37980
  return new Promise((resolve2, reject) => {
37984
37981
  const timeout2 = setTimeout(() => {
37985
37982
  reject(new Error("Port forwarding timed out"));
37986
- }, 1e4);
37983
+ }, timeoutMs);
37987
37984
  result.stdout?.on("data", (data) => {
37985
+ logDetail("port forward stdout", data.toString());
37986
+ if (data.toString().includes("Started")) {
37987
+ clearTimeout(timeout2);
37988
+ resolve2({
37989
+ localPort,
37990
+ devicePort
37991
+ });
37992
+ }
37993
+ });
37994
+ result.stderr?.on("data", (data) => {
37995
+ logDetail("port forward stderr", data.toString());
37988
37996
  if (data.toString().includes("Started")) {
37989
37997
  clearTimeout(timeout2);
37990
37998
  resolve2({
@@ -38594,7 +38602,7 @@ var ProfileParser = class {
38594
38602
  };
38595
38603
 
38596
38604
  // src/logic/iosClient.ts
38597
- var { logDetail, setNamespace: setNamespace5, logTask: logTask4 } = createLoggers("");
38605
+ var { logDetail: logDetail2, setNamespace: setNamespace5, logTask: logTask4 } = createLoggers("");
38598
38606
  var IosClient = class {
38599
38607
  constructor(iosPath, udid, _usbmuxdAddress) {
38600
38608
  this.iosPath = iosPath;
@@ -38621,8 +38629,6 @@ var IosClient = class {
38621
38629
  }
38622
38630
  spawnIosCommand(args) {
38623
38631
  logTask4(`Running command: ${this.iosPath} ${args.join(" ")}`);
38624
- const fs9f3 = __require("node:fs");
38625
- fs9f3.appendFileSync("debug-9f3919.log", JSON.stringify({ sessionId: "9f3919", location: "iosClient.ts:spawnIosCommand", message: "spawning ios command", data: { iosPath: this.iosPath, args, USBMUXD_SOCKET_ADDRESS: this.usbmuxdAddress, command: args[0] }, timestamp: Date.now(), hypothesisId: "D" }) + "\n");
38626
38632
  const child = spawn(this.iosPath, args, {
38627
38633
  windowsHide: true,
38628
38634
  stdio: ["ignore", "pipe", "pipe"],
@@ -38727,48 +38733,10 @@ var IosClient = class {
38727
38733
  return this.spawnIosCommand(["forward", `--port=${fromPort}:${toPort}`, "--udid", this.udid]);
38728
38734
  }
38729
38735
  async info() {
38730
- const fs9f2 = __require("node:fs");
38731
- fs9f2.appendFileSync("debug-9f3919.log", JSON.stringify({ sessionId: "9f3919", location: "iosClient.ts:info:entry", message: "info called (working command for comparison)", data: { udid: this.udid, usbmuxdAddress: this._usbmuxdAddress }, timestamp: Date.now(), hypothesisId: "E" }) + "\n");
38732
- const result = await this.runIosCommand(["info", "--udid", this.udid]);
38733
- fs9f2.appendFileSync("debug-9f3919.log", JSON.stringify({ sessionId: "9f3919", location: "iosClient.ts:info:result", message: "info completed (working command for comparison)", data: { exitCode: result.exitCode, hasOutput: result.output.length > 0, stderr: result.raw.stderr.substring(0, 500) }, timestamp: Date.now(), hypothesisId: "E" }) + "\n");
38734
- return result;
38736
+ return this.runIosCommand(["info", "--udid", this.udid]);
38735
38737
  }
38736
38738
  async installApp(ipaPath) {
38737
- const fs9f = __require("node:fs");
38738
- const path9f = __require("node:path");
38739
- const lockdownApple = path9f.join(process.env.ProgramData ?? "C:\\ProgramData", "Apple", "Lockdown");
38740
- const lockdownCustom = process.env.LOCKDOWN_WINDOWS_PATH || "";
38741
- const appleSysCfgPath = path9f.join(lockdownApple, "SystemConfiguration.plist");
38742
- const customSysCfgPath = lockdownCustom ? path9f.join(lockdownCustom, "SystemConfiguration.plist") : "";
38743
- const appleDevPath = path9f.join(lockdownApple, this.udid + ".plist");
38744
- const customDevPath = lockdownCustom ? path9f.join(lockdownCustom, this.udid + ".plist") : "";
38745
- const readPlistBuid = (p) => {
38746
- try {
38747
- const c = fs9f.readFileSync(p, "utf8");
38748
- const m = c.match(/SystemBUID<\/key>\s*<string>([^<]+)<\/string>/);
38749
- return m ? m[1] : "NOT_FOUND_IN_XML";
38750
- } catch (e) {
38751
- return "READ_ERROR:" + e.message;
38752
- }
38753
- };
38754
- const readPlistHostId = (p) => {
38755
- try {
38756
- const c = fs9f.readFileSync(p, "utf8");
38757
- const m = c.match(/HostID<\/key>\s*<string>([^<]+)<\/string>/);
38758
- return m ? m[1] : "NOT_FOUND_IN_XML";
38759
- } catch (e) {
38760
- return "READ_ERROR:" + e.message;
38761
- }
38762
- };
38763
- const appleBuid = readPlistBuid(appleSysCfgPath);
38764
- const customBuid = customSysCfgPath ? readPlistBuid(customSysCfgPath) : "N/A";
38765
- const appleHostId = readPlistHostId(appleDevPath);
38766
- const customHostId = customDevPath ? readPlistHostId(customDevPath) : "N/A";
38767
- const buidMatch = appleBuid === customBuid;
38768
- fs9f.appendFileSync(path9f.join(process.cwd(), "debug-9f3919.log"), JSON.stringify({ sessionId: "9f3919", location: "iosClient.ts:installApp:lockdown-buid-compare", message: "SystemBUID and HostID comparison", data: { appleBuid, customBuid, buidMatch, appleHostId, customHostId, hostIdMatch: appleHostId === customHostId, usbmuxdAddress: this._usbmuxdAddress }, timestamp: Date.now(), hypothesisId: "F" }) + "\n");
38769
- const result = await this.runIosCommand(["install", `--path=${ipaPath}`, "--udid", this.udid]);
38770
- fs9f.appendFileSync(path9f.join(process.cwd(), "debug-9f3919.log"), JSON.stringify({ sessionId: "9f3919", location: "iosClient.ts:installApp:result", message: "installApp completed", data: { exitCode: result.exitCode, stderr: result.raw.stderr.substring(0, 2e3), stdout: result.raw.stdout.substring(0, 2e3) }, timestamp: Date.now(), hypothesisId: "A" }) + "\n");
38771
- return result;
38739
+ return this.runIosCommand(["install", `--path=${ipaPath}`, "--udid", this.udid]);
38772
38740
  }
38773
38741
  async uninstallApp(bundleId) {
38774
38742
  return this.runIosCommand(["uninstall", bundleId, "--udid", this.udid]);
@@ -38794,7 +38762,7 @@ var IosClient = class {
38794
38762
  }
38795
38763
  async tunnelStart(userspace = false) {
38796
38764
  const args = ["tunnel", "start", "--udid", this.udid, ...userspace ? ["--userspace"] : []];
38797
- logDetail(`Spawning tunnel: ${this.iosPath} ${args.join(" ")}`);
38765
+ logDetail2(`Spawning tunnel: ${this.iosPath} ${args.join(" ")}`);
38798
38766
  const child = spawn(this.iosPath, args, {
38799
38767
  windowsHide: true,
38800
38768
  env: {
@@ -39047,11 +39015,11 @@ var AppleDeviceKit = class {
39047
39015
  * @param startupTimeout Time to wait for proxy to start (ms)
39048
39016
  * @returns The port forward result with the allocated local port
39049
39017
  */
39050
- async startPortForwardAsync(devicePort) {
39018
+ async startPortForwardAsync(devicePort, timeoutMs = 1e4) {
39051
39019
  this.ensureNotDisposed();
39052
39020
  this.killProxyProcess();
39053
39021
  this.localDevicePort = await getPorts({ port: portNumbers(3e4, 31e3) });
39054
- const result = await this.proxyActions.startPortForward(this.localDevicePort, devicePort);
39022
+ const result = await this.proxyActions.startPortForward(this.localDevicePort, devicePort, timeoutMs);
39055
39023
  return result;
39056
39024
  }
39057
39025
  /**