@mcesystems/apple-kit 1.0.84 → 1.0.86

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
@@ -1147,9 +1147,9 @@ function throwIfAborted(signal) {
1147
1147
  }
1148
1148
  }
1149
1149
  var { logTask, logInfo, setNamespace } = createLoggers("apple-kit:device");
1150
- function getAppleLockdownPath() {
1150
+ function getLockdownPath() {
1151
1151
  if (process.platform === "win32") {
1152
- return join(process.env.ProgramData ?? "C:\\ProgramData", "Apple", "Lockdown");
1152
+ return process.env.LOCKDOWN_WINDOWS_PATH || join(process.env.ProgramData ?? "C:\\ProgramData", "Apple", "Lockdown");
1153
1153
  }
1154
1154
  if (process.platform === "darwin") {
1155
1155
  return "/var/db/lockdown";
@@ -1243,7 +1243,7 @@ var DeviceActions = class {
1243
1243
  }
1244
1244
  async unpair() {
1245
1245
  logInfo(`Un-pairing device ${this.udid}`);
1246
- const lockdownDir = getAppleLockdownPath();
1246
+ const lockdownDir = getLockdownPath();
1247
1247
  if (!lockdownDir) {
1248
1248
  throw new Error("Cannot determine lockdown directory for this platform");
1249
1249
  }
@@ -37932,7 +37932,10 @@ 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");
37935
37937
  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");
37936
37939
  logInfo3("Installing app via MDM for management takeover");
37937
37940
  const mdmClient = await createMDMClient();
37938
37941
  if (!mdmClient) {
@@ -37975,7 +37978,8 @@ var ProxyActions = class {
37975
37978
  childProcess = /* @__PURE__ */ new Map();
37976
37979
  async startPortForward(localPort, devicePort) {
37977
37980
  logInfo4(`Starting port forward ${localPort} -> ${devicePort} for device ${this.udid}`);
37978
- const result = await this.iosClient.forward({ fromPort: localPort, toPort: devicePort });
37981
+ const result = this.iosClient.forward({ fromPort: localPort, toPort: devicePort });
37982
+ this.childProcess.set(this.udid, result);
37979
37983
  return new Promise((resolve2, reject) => {
37980
37984
  const timeout2 = setTimeout(() => {
37981
37985
  reject(new Error("Port forwarding timed out"));
@@ -38617,6 +38621,8 @@ var IosClient = class {
38617
38621
  }
38618
38622
  spawnIosCommand(args) {
38619
38623
  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");
38620
38626
  const child = spawn(this.iosPath, args, {
38621
38627
  windowsHide: true,
38622
38628
  stdio: ["ignore", "pipe", "pipe"],
@@ -38717,14 +38723,52 @@ var IosClient = class {
38717
38723
  async pair() {
38718
38724
  return this.runIosCommand(["pair", "--udid", this.udid]);
38719
38725
  }
38720
- async forward({ fromPort, toPort }) {
38726
+ forward({ fromPort, toPort }) {
38721
38727
  return this.spawnIosCommand(["forward", `--port=${fromPort}:${toPort}`, "--udid", this.udid]);
38722
38728
  }
38723
38729
  async info() {
38724
- return this.runIosCommand(["info", "--udid", this.udid]);
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;
38725
38735
  }
38726
38736
  async installApp(ipaPath) {
38727
- return this.runIosCommand(["install", `--path=${ipaPath}`, "--udid", this.udid]);
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;
38728
38772
  }
38729
38773
  async uninstallApp(bundleId) {
38730
38774
  return this.runIosCommand(["uninstall", bundleId, "--udid", this.udid]);