@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.js CHANGED
@@ -873,14 +873,14 @@ function createLoggers(namespace, logLevel = process.env.LOG_LEVEL ?? "none") {
873
873
  const logInfo8 = (0, import_debug.default)(`${namespace}:info`);
874
874
  const logTask5 = (0, import_debug.default)(`${namespace}:task`);
875
875
  const logError3 = (0, import_debug.default)(`${namespace}:error`);
876
- const logDetail2 = (0, import_debug.default)(`${namespace}:detail`);
876
+ const logDetail3 = (0, import_debug.default)(`${namespace}:detail`);
877
877
  const logDebug = (0, import_debug.default)(`${namespace}:debug`);
878
878
  const logWarning3 = (0, import_debug.default)(`${namespace}:warning`);
879
879
  const logColor = (0, import_debug.default)(`${namespace}:color`);
880
880
  logInfo8.color = "19";
881
881
  logTask5.color = "25";
882
882
  logError3.color = "1";
883
- logDetail2.color = "199";
883
+ logDetail3.color = "199";
884
884
  logWarning3.color = "186";
885
885
  logDebug.color = "211";
886
886
  logColor.enabled = true;
@@ -888,7 +888,7 @@ function createLoggers(namespace, logLevel = process.env.LOG_LEVEL ?? "none") {
888
888
  logInfo8.namespace = `${namespace2}:info`;
889
889
  logTask5.namespace = `${namespace2}:task`;
890
890
  logError3.namespace = `${namespace2}:error`;
891
- logDetail2.namespace = `${namespace2}:detail`;
891
+ logDetail3.namespace = `${namespace2}:detail`;
892
892
  logWarning3.namespace = `${namespace2}:warning`;
893
893
  logDebug.namespace = `${namespace2}:debug`;
894
894
  }
@@ -899,7 +899,7 @@ function createLoggers(namespace, logLevel = process.env.LOG_LEVEL ?? "none") {
899
899
  logTask5.enabled = true;
900
900
  logError3.enabled = true;
901
901
  logWarning3.enabled = true;
902
- logDetail2.enabled = false;
902
+ logDetail3.enabled = false;
903
903
  logDebug.enabled = false;
904
904
  break;
905
905
  case "debug":
@@ -907,7 +907,7 @@ function createLoggers(namespace, logLevel = process.env.LOG_LEVEL ?? "none") {
907
907
  logTask5.enabled = true;
908
908
  logError3.enabled = true;
909
909
  logWarning3.enabled = true;
910
- logDetail2.enabled = true;
910
+ logDetail3.enabled = true;
911
911
  logDebug.enabled = true;
912
912
  break;
913
913
  case "none":
@@ -915,7 +915,7 @@ function createLoggers(namespace, logLevel = process.env.LOG_LEVEL ?? "none") {
915
915
  logTask5.enabled = false;
916
916
  logError3.enabled = false;
917
917
  logWarning3.enabled = false;
918
- logDetail2.enabled = false;
918
+ logDetail3.enabled = false;
919
919
  logDebug.enabled = false;
920
920
  break;
921
921
  }
@@ -933,7 +933,7 @@ function createLoggers(namespace, logLevel = process.env.LOG_LEVEL ?? "none") {
933
933
  logError3.color = color;
934
934
  break;
935
935
  case "detail":
936
- logDetail2.color = color;
936
+ logDetail3.color = color;
937
937
  break;
938
938
  case "warning":
939
939
  logWarning3.color = color;
@@ -1000,7 +1000,7 @@ ${" ".repeat(padding)}${"=".repeat(80)}`;
1000
1000
  const functionName = functionMatch ? functionMatch[1] : "<anonymous>";
1001
1001
  callerDetails = `${functionName}`;
1002
1002
  }
1003
- logDetail2(`${header(`*${title}* ${callerDetails}`)}
1003
+ logDetail3(`${header(`*${title}* ${callerDetails}`)}
1004
1004
  ${args.reduce((acc, arg) => `${acc}
1005
1005
  ${logDataDetail(arg)}`, "")}
1006
1006
 
@@ -1023,7 +1023,7 @@ ${"=".repeat(80)}`);
1023
1023
  logInfo: logInfo8,
1024
1024
  logTask: logTask5,
1025
1025
  logError: logError3,
1026
- logDetail: logDetail2,
1026
+ logDetail: logDetail3,
1027
1027
  logDebug,
1028
1028
  logWarning: logWarning3,
1029
1029
  logColor,
@@ -36610,14 +36610,14 @@ function createLoggers2(namespace, logLevel = process.env.LOG_LEVEL ?? "none") {
36610
36610
  const logInfo222 = (0, import_debug2.default)(`${namespace}:info`);
36611
36611
  const logTask5 = (0, import_debug2.default)(`${namespace}:task`);
36612
36612
  const logError22 = (0, import_debug2.default)(`${namespace}:error`);
36613
- const logDetail2 = (0, import_debug2.default)(`${namespace}:detail`);
36613
+ const logDetail3 = (0, import_debug2.default)(`${namespace}:detail`);
36614
36614
  const logDebug = (0, import_debug2.default)(`${namespace}:debug`);
36615
36615
  const logWarning22 = (0, import_debug2.default)(`${namespace}:warning`);
36616
36616
  const logColor = (0, import_debug2.default)(`${namespace}:color`);
36617
36617
  logInfo222.color = "19";
36618
36618
  logTask5.color = "25";
36619
36619
  logError22.color = "1";
36620
- logDetail2.color = "199";
36620
+ logDetail3.color = "199";
36621
36621
  logWarning22.color = "186";
36622
36622
  logDebug.color = "211";
36623
36623
  logColor.enabled = true;
@@ -36625,7 +36625,7 @@ function createLoggers2(namespace, logLevel = process.env.LOG_LEVEL ?? "none") {
36625
36625
  logInfo222.namespace = `${namespace2}:info`;
36626
36626
  logTask5.namespace = `${namespace2}:task`;
36627
36627
  logError22.namespace = `${namespace2}:error`;
36628
- logDetail2.namespace = `${namespace2}:detail`;
36628
+ logDetail3.namespace = `${namespace2}:detail`;
36629
36629
  logWarning22.namespace = `${namespace2}:warning`;
36630
36630
  logDebug.namespace = `${namespace2}:debug`;
36631
36631
  }
@@ -36636,7 +36636,7 @@ function createLoggers2(namespace, logLevel = process.env.LOG_LEVEL ?? "none") {
36636
36636
  logTask5.enabled = true;
36637
36637
  logError22.enabled = true;
36638
36638
  logWarning22.enabled = true;
36639
- logDetail2.enabled = false;
36639
+ logDetail3.enabled = false;
36640
36640
  logDebug.enabled = false;
36641
36641
  break;
36642
36642
  case "debug":
@@ -36644,7 +36644,7 @@ function createLoggers2(namespace, logLevel = process.env.LOG_LEVEL ?? "none") {
36644
36644
  logTask5.enabled = true;
36645
36645
  logError22.enabled = true;
36646
36646
  logWarning22.enabled = true;
36647
- logDetail2.enabled = true;
36647
+ logDetail3.enabled = true;
36648
36648
  logDebug.enabled = true;
36649
36649
  break;
36650
36650
  case "none":
@@ -36652,7 +36652,7 @@ function createLoggers2(namespace, logLevel = process.env.LOG_LEVEL ?? "none") {
36652
36652
  logTask5.enabled = false;
36653
36653
  logError22.enabled = false;
36654
36654
  logWarning22.enabled = false;
36655
- logDetail2.enabled = false;
36655
+ logDetail3.enabled = false;
36656
36656
  logDebug.enabled = false;
36657
36657
  break;
36658
36658
  }
@@ -36670,7 +36670,7 @@ function createLoggers2(namespace, logLevel = process.env.LOG_LEVEL ?? "none") {
36670
36670
  logError22.color = color;
36671
36671
  break;
36672
36672
  case "detail":
36673
- logDetail2.color = color;
36673
+ logDetail3.color = color;
36674
36674
  break;
36675
36675
  case "warning":
36676
36676
  logWarning22.color = color;
@@ -36737,7 +36737,7 @@ ${" ".repeat(padding)}${"=".repeat(80)}`;
36737
36737
  const functionName = functionMatch ? functionMatch[1] : "<anonymous>";
36738
36738
  callerDetails = `${functionName}`;
36739
36739
  }
36740
- logDetail2(`${header(`*${title}* ${callerDetails}`)}
36740
+ logDetail3(`${header(`*${title}* ${callerDetails}`)}
36741
36741
  ${args.reduce((acc, arg) => `${acc}
36742
36742
  ${logDataDetail(arg)}`, "")}
36743
36743
 
@@ -36760,7 +36760,7 @@ ${"=".repeat(80)}`);
36760
36760
  logInfo: logInfo222,
36761
36761
  logTask: logTask5,
36762
36762
  logError: logError22,
36763
- logDetail: logDetail2,
36763
+ logDetail: logDetail3,
36764
36764
  logDebug,
36765
36765
  logWarning: logWarning22,
36766
36766
  logColor,
@@ -37707,14 +37707,14 @@ function createLoggers22(namespace, logLevel = process.env.LOG_LEVEL ?? "none")
37707
37707
  const logInfo32 = (0, import_debug22.default)(`${namespace}:info`);
37708
37708
  const logTask5 = (0, import_debug22.default)(`${namespace}:task`);
37709
37709
  const logError22 = (0, import_debug22.default)(`${namespace}:error`);
37710
- const logDetail2 = (0, import_debug22.default)(`${namespace}:detail`);
37710
+ const logDetail3 = (0, import_debug22.default)(`${namespace}:detail`);
37711
37711
  const logDebug = (0, import_debug22.default)(`${namespace}:debug`);
37712
37712
  const logWarning22 = (0, import_debug22.default)(`${namespace}:warning`);
37713
37713
  const logColor = (0, import_debug22.default)(`${namespace}:color`);
37714
37714
  logInfo32.color = "19";
37715
37715
  logTask5.color = "25";
37716
37716
  logError22.color = "1";
37717
- logDetail2.color = "199";
37717
+ logDetail3.color = "199";
37718
37718
  logWarning22.color = "186";
37719
37719
  logDebug.color = "211";
37720
37720
  logColor.enabled = true;
@@ -37722,7 +37722,7 @@ function createLoggers22(namespace, logLevel = process.env.LOG_LEVEL ?? "none")
37722
37722
  logInfo32.namespace = `${namespace2}:info`;
37723
37723
  logTask5.namespace = `${namespace2}:task`;
37724
37724
  logError22.namespace = `${namespace2}:error`;
37725
- logDetail2.namespace = `${namespace2}:detail`;
37725
+ logDetail3.namespace = `${namespace2}:detail`;
37726
37726
  logWarning22.namespace = `${namespace2}:warning`;
37727
37727
  logDebug.namespace = `${namespace2}:debug`;
37728
37728
  }
@@ -37733,7 +37733,7 @@ function createLoggers22(namespace, logLevel = process.env.LOG_LEVEL ?? "none")
37733
37733
  logTask5.enabled = true;
37734
37734
  logError22.enabled = true;
37735
37735
  logWarning22.enabled = true;
37736
- logDetail2.enabled = false;
37736
+ logDetail3.enabled = false;
37737
37737
  logDebug.enabled = false;
37738
37738
  break;
37739
37739
  case "debug":
@@ -37741,7 +37741,7 @@ function createLoggers22(namespace, logLevel = process.env.LOG_LEVEL ?? "none")
37741
37741
  logTask5.enabled = true;
37742
37742
  logError22.enabled = true;
37743
37743
  logWarning22.enabled = true;
37744
- logDetail2.enabled = true;
37744
+ logDetail3.enabled = true;
37745
37745
  logDebug.enabled = true;
37746
37746
  break;
37747
37747
  case "none":
@@ -37749,7 +37749,7 @@ function createLoggers22(namespace, logLevel = process.env.LOG_LEVEL ?? "none")
37749
37749
  logTask5.enabled = false;
37750
37750
  logError22.enabled = false;
37751
37751
  logWarning22.enabled = false;
37752
- logDetail2.enabled = false;
37752
+ logDetail3.enabled = false;
37753
37753
  logDebug.enabled = false;
37754
37754
  break;
37755
37755
  }
@@ -37767,7 +37767,7 @@ function createLoggers22(namespace, logLevel = process.env.LOG_LEVEL ?? "none")
37767
37767
  logError22.color = color;
37768
37768
  break;
37769
37769
  case "detail":
37770
- logDetail2.color = color;
37770
+ logDetail3.color = color;
37771
37771
  break;
37772
37772
  case "warning":
37773
37773
  logWarning22.color = color;
@@ -37834,7 +37834,7 @@ ${" ".repeat(padding)}${"=".repeat(80)}`;
37834
37834
  const functionName = functionMatch ? functionMatch[1] : "<anonymous>";
37835
37835
  callerDetails = `${functionName}`;
37836
37836
  }
37837
- logDetail2(`${header(`*${title}* ${callerDetails}`)}
37837
+ logDetail3(`${header(`*${title}* ${callerDetails}`)}
37838
37838
  ${args.reduce((acc, arg) => `${acc}
37839
37839
  ${logDataDetail(arg)}`, "")}
37840
37840
 
@@ -37857,7 +37857,7 @@ ${"=".repeat(80)}`);
37857
37857
  logInfo: logInfo32,
37858
37858
  logTask: logTask5,
37859
37859
  logError: logError22,
37860
- logDetail: logDetail2,
37860
+ logDetail: logDetail3,
37861
37861
  logDebug,
37862
37862
  logWarning: logWarning22,
37863
37863
  logColor,
@@ -37967,10 +37967,7 @@ var InstallActions = class {
37967
37967
  return this.iosClient.installApp(ipaPath);
37968
37968
  }
37969
37969
  async installManagedApp(ipaPath, options) {
37970
- const fs9f4 = require("node:fs");
37971
- 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");
37972
37970
  const result = await this.iosClient.installApp(ipaPath);
37973
- 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");
37974
37971
  logInfo3("Installing app via MDM for management takeover");
37975
37972
  const mdmClient = await createMDMClient();
37976
37973
  if (!mdmClient) {
@@ -38003,7 +38000,7 @@ var InstallActions = class {
38003
38000
  };
38004
38001
 
38005
38002
  // src/logic/actions/proxy.ts
38006
- var { logTask: logTask2, logInfo: logInfo4, setNamespace: setNamespace3 } = createLoggers("");
38003
+ var { logTask: logTask2, logInfo: logInfo4, setNamespace: setNamespace3, logDetail } = createLoggers("");
38007
38004
  var ProxyActions = class {
38008
38005
  constructor(udid, iosClient) {
38009
38006
  this.udid = udid;
@@ -38011,15 +38008,26 @@ var ProxyActions = class {
38011
38008
  setNamespace3(`apple-${udid}`);
38012
38009
  }
38013
38010
  childProcess = /* @__PURE__ */ new Map();
38014
- async startPortForward(localPort, devicePort) {
38011
+ async startPortForward(localPort, devicePort, timeoutMs = 1e4) {
38015
38012
  logInfo4(`Starting port forward ${localPort} -> ${devicePort} for device ${this.udid}`);
38016
38013
  const result = this.iosClient.forward({ fromPort: localPort, toPort: devicePort });
38017
38014
  this.childProcess.set(this.udid, result);
38018
38015
  return new Promise((resolve2, reject) => {
38019
38016
  const timeout2 = setTimeout(() => {
38020
38017
  reject(new Error("Port forwarding timed out"));
38021
- }, 1e4);
38018
+ }, timeoutMs);
38022
38019
  result.stdout?.on("data", (data) => {
38020
+ logDetail("port forward stdout", data.toString());
38021
+ if (data.toString().includes("Started")) {
38022
+ clearTimeout(timeout2);
38023
+ resolve2({
38024
+ localPort,
38025
+ devicePort
38026
+ });
38027
+ }
38028
+ });
38029
+ result.stderr?.on("data", (data) => {
38030
+ logDetail("port forward stderr", data.toString());
38023
38031
  if (data.toString().includes("Started")) {
38024
38032
  clearTimeout(timeout2);
38025
38033
  resolve2({
@@ -38630,7 +38638,7 @@ var ProfileParser = class {
38630
38638
  };
38631
38639
 
38632
38640
  // src/logic/iosClient.ts
38633
- var { logDetail, setNamespace: setNamespace5, logTask: logTask4 } = createLoggers("");
38641
+ var { logDetail: logDetail2, setNamespace: setNamespace5, logTask: logTask4 } = createLoggers("");
38634
38642
  var IosClient = class {
38635
38643
  constructor(iosPath, udid, _usbmuxdAddress) {
38636
38644
  this.iosPath = iosPath;
@@ -38657,8 +38665,6 @@ var IosClient = class {
38657
38665
  }
38658
38666
  spawnIosCommand(args) {
38659
38667
  logTask4(`Running command: ${this.iosPath} ${args.join(" ")}`);
38660
- const fs9f3 = require("node:fs");
38661
- 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");
38662
38668
  const child = (0, import_node_child_process.spawn)(this.iosPath, args, {
38663
38669
  windowsHide: true,
38664
38670
  stdio: ["ignore", "pipe", "pipe"],
@@ -38763,48 +38769,10 @@ var IosClient = class {
38763
38769
  return this.spawnIosCommand(["forward", `--port=${fromPort}:${toPort}`, "--udid", this.udid]);
38764
38770
  }
38765
38771
  async info() {
38766
- const fs9f2 = require("node:fs");
38767
- 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");
38768
- const result = await this.runIosCommand(["info", "--udid", this.udid]);
38769
- 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");
38770
- return result;
38772
+ return this.runIosCommand(["info", "--udid", this.udid]);
38771
38773
  }
38772
38774
  async installApp(ipaPath) {
38773
- const fs9f = require("node:fs");
38774
- const path9f = require("node:path");
38775
- const lockdownApple = path9f.join(process.env.ProgramData ?? "C:\\ProgramData", "Apple", "Lockdown");
38776
- const lockdownCustom = process.env.LOCKDOWN_WINDOWS_PATH || "";
38777
- const appleSysCfgPath = path9f.join(lockdownApple, "SystemConfiguration.plist");
38778
- const customSysCfgPath = lockdownCustom ? path9f.join(lockdownCustom, "SystemConfiguration.plist") : "";
38779
- const appleDevPath = path9f.join(lockdownApple, this.udid + ".plist");
38780
- const customDevPath = lockdownCustom ? path9f.join(lockdownCustom, this.udid + ".plist") : "";
38781
- const readPlistBuid = (p) => {
38782
- try {
38783
- const c = fs9f.readFileSync(p, "utf8");
38784
- const m = c.match(/SystemBUID<\/key>\s*<string>([^<]+)<\/string>/);
38785
- return m ? m[1] : "NOT_FOUND_IN_XML";
38786
- } catch (e) {
38787
- return "READ_ERROR:" + e.message;
38788
- }
38789
- };
38790
- const readPlistHostId = (p) => {
38791
- try {
38792
- const c = fs9f.readFileSync(p, "utf8");
38793
- const m = c.match(/HostID<\/key>\s*<string>([^<]+)<\/string>/);
38794
- return m ? m[1] : "NOT_FOUND_IN_XML";
38795
- } catch (e) {
38796
- return "READ_ERROR:" + e.message;
38797
- }
38798
- };
38799
- const appleBuid = readPlistBuid(appleSysCfgPath);
38800
- const customBuid = customSysCfgPath ? readPlistBuid(customSysCfgPath) : "N/A";
38801
- const appleHostId = readPlistHostId(appleDevPath);
38802
- const customHostId = customDevPath ? readPlistHostId(customDevPath) : "N/A";
38803
- const buidMatch = appleBuid === customBuid;
38804
- 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");
38805
- const result = await this.runIosCommand(["install", `--path=${ipaPath}`, "--udid", this.udid]);
38806
- 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");
38807
- return result;
38775
+ return this.runIosCommand(["install", `--path=${ipaPath}`, "--udid", this.udid]);
38808
38776
  }
38809
38777
  async uninstallApp(bundleId) {
38810
38778
  return this.runIosCommand(["uninstall", bundleId, "--udid", this.udid]);
@@ -38830,7 +38798,7 @@ var IosClient = class {
38830
38798
  }
38831
38799
  async tunnelStart(userspace = false) {
38832
38800
  const args = ["tunnel", "start", "--udid", this.udid, ...userspace ? ["--userspace"] : []];
38833
- logDetail(`Spawning tunnel: ${this.iosPath} ${args.join(" ")}`);
38801
+ logDetail2(`Spawning tunnel: ${this.iosPath} ${args.join(" ")}`);
38834
38802
  const child = (0, import_node_child_process.spawn)(this.iosPath, args, {
38835
38803
  windowsHide: true,
38836
38804
  env: {
@@ -39083,11 +39051,11 @@ var AppleDeviceKit = class {
39083
39051
  * @param startupTimeout Time to wait for proxy to start (ms)
39084
39052
  * @returns The port forward result with the allocated local port
39085
39053
  */
39086
- async startPortForwardAsync(devicePort) {
39054
+ async startPortForwardAsync(devicePort, timeoutMs = 1e4) {
39087
39055
  this.ensureNotDisposed();
39088
39056
  this.killProxyProcess();
39089
39057
  this.localDevicePort = await getPorts({ port: portNumbers(3e4, 31e3) });
39090
- const result = await this.proxyActions.startPortForward(this.localDevicePort, devicePort);
39058
+ const result = await this.proxyActions.startPortForward(this.localDevicePort, devicePort, timeoutMs);
39091
39059
  return result;
39092
39060
  }
39093
39061
  /**