@mcesystems/apple-kit 1.0.24 → 1.0.25

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.
Files changed (114) hide show
  1. package/README.md +284 -250
  2. package/dist/index.js +156 -22
  3. package/dist/index.js.map +3 -3
  4. package/dist/index.mjs +156 -24
  5. package/dist/index.mjs.map +3 -3
  6. package/dist/resources/bin/darwin/idevice_id +0 -0
  7. package/dist/resources/bin/darwin/idevicedebug +0 -0
  8. package/dist/resources/bin/darwin/idevicediagnostics +0 -0
  9. package/dist/resources/bin/darwin/ideviceinfo +0 -0
  10. package/dist/resources/bin/darwin/ideviceinstaller +0 -0
  11. package/dist/resources/bin/darwin/idevicename +0 -0
  12. package/dist/resources/bin/darwin/idevicepair +0 -0
  13. package/dist/resources/bin/darwin/idevicescreenshot +0 -0
  14. package/dist/resources/bin/darwin/idevicesyslog +0 -0
  15. package/dist/resources/bin/darwin/iproxy +0 -0
  16. package/dist/resources/bin/darwin/libcrypto.3.dylib +0 -0
  17. package/dist/resources/bin/darwin/libimobiledevice-1.0.6.dylib +0 -0
  18. package/dist/resources/bin/darwin/libimobiledevice-glue-1.0.0.dylib +0 -0
  19. package/dist/resources/bin/darwin/liblzma.5.dylib +0 -0
  20. package/dist/resources/bin/darwin/libplist-2.0.4.dylib +0 -0
  21. package/dist/resources/bin/darwin/libssl.3.dylib +0 -0
  22. package/dist/resources/bin/darwin/libusbmuxd-2.0.7.dylib +0 -0
  23. package/dist/resources/bin/darwin/libzip.5.dylib +0 -0
  24. package/dist/resources/bin/darwin/libzstd.1.dylib +0 -0
  25. package/{resources → dist/resources}/licenses/LGPL-2.1.txt +33 -33
  26. package/dist/types/logic/actions/device.d.ts.map +1 -1
  27. package/dist/types/logic/actions/proxy.d.ts.map +1 -1
  28. package/dist/types/logic/appleDeviceKit.d.ts +1 -1
  29. package/dist/types/logic/appleDeviceKit.d.ts.map +1 -1
  30. package/package.json +7 -4
  31. package/scripts/README.md +209 -0
  32. package/scripts/build-windows.sh.template +134 -0
  33. package/scripts/export-resources.ts +444 -0
  34. package/dist/types/utils/portManager.d.ts +0 -68
  35. package/dist/types/utils/portManager.d.ts.map +0 -1
  36. package/resources/bin/windows/bz2.dll +0 -0
  37. package/resources/bin/windows/getopt.dll +0 -0
  38. package/resources/bin/windows/iconv-2.dll +0 -0
  39. package/resources/bin/windows/idevice_id.exe +0 -0
  40. package/resources/bin/windows/ideviceactivation.exe +0 -0
  41. package/resources/bin/windows/idevicedebug.exe +0 -0
  42. package/resources/bin/windows/ideviceinfo.exe +0 -0
  43. package/resources/bin/windows/ideviceinstaller.exe +0 -0
  44. package/resources/bin/windows/idevicepair.exe +0 -0
  45. package/resources/bin/windows/imobiledevice.dll +0 -0
  46. package/resources/bin/windows/iproxy.exe +0 -0
  47. package/resources/bin/windows/libcrypto-1_1-x64.dll +0 -0
  48. package/resources/bin/windows/libcurl.dll +0 -0
  49. package/resources/bin/windows/libideviceactivation-1.0.dll +0 -0
  50. package/resources/bin/windows/libimobiledevice-1.0.dll +0 -0
  51. package/resources/bin/windows/libimobiledevice-glue-1.0.dll +0 -0
  52. package/resources/bin/windows/libplist-2.0.dll +0 -0
  53. package/resources/bin/windows/libssl-1_1-x64.dll +0 -0
  54. package/resources/bin/windows/libusb-1.0.dll +0 -0
  55. package/resources/bin/windows/libusb0.dll +0 -0
  56. package/resources/bin/windows/libusbmuxd-2.0.dll +0 -0
  57. package/resources/bin/windows/libxml2.dll +0 -0
  58. package/resources/bin/windows/lzma.dll +0 -0
  59. package/resources/bin/windows/pcre.dll +0 -0
  60. package/resources/bin/windows/pcreposix.dll +0 -0
  61. package/resources/bin/windows/plist.dll +0 -0
  62. package/resources/bin/windows/pthreadVC3.dll +0 -0
  63. package/resources/bin/windows/readline.dll +0 -0
  64. package/resources/bin/windows/usbmuxd.dll +0 -0
  65. package/resources/bin/windows/usbmuxd.exe +0 -0
  66. package/resources/bin/windows/vcruntime140.dll +0 -0
  67. package/resources/bin/windows/zip.dll +0 -0
  68. package/resources/bin/windows/zlib1.dll +0 -0
  69. package/resources/lib/include/libimobiledevice/afc.h +0 -413
  70. package/resources/lib/include/libimobiledevice/bt_packet_logger.h +0 -156
  71. package/resources/lib/include/libimobiledevice/companion_proxy.h +0 -212
  72. package/resources/lib/include/libimobiledevice/debugserver.h +0 -272
  73. package/resources/lib/include/libimobiledevice/diagnostics_relay.h +0 -228
  74. package/resources/lib/include/libimobiledevice/file_relay.h +0 -166
  75. package/resources/lib/include/libimobiledevice/heartbeat.h +0 -137
  76. package/resources/lib/include/libimobiledevice/house_arrest.h +0 -180
  77. package/resources/lib/include/libimobiledevice/installation_proxy.h +0 -505
  78. package/resources/lib/include/libimobiledevice/libimobiledevice.h +0 -444
  79. package/resources/lib/include/libimobiledevice/lockdown.h +0 -577
  80. package/resources/lib/include/libimobiledevice/misagent.h +0 -168
  81. package/resources/lib/include/libimobiledevice/mobile_image_mounter.h +0 -275
  82. package/resources/lib/include/libimobiledevice/mobileactivation.h +0 -192
  83. package/resources/lib/include/libimobiledevice/mobilebackup.h +0 -246
  84. package/resources/lib/include/libimobiledevice/mobilebackup2.h +0 -214
  85. package/resources/lib/include/libimobiledevice/mobilesync.h +0 -359
  86. package/resources/lib/include/libimobiledevice/notification_proxy.h +0 -202
  87. package/resources/lib/include/libimobiledevice/ostrace.h +0 -198
  88. package/resources/lib/include/libimobiledevice/preboard.h +0 -187
  89. package/resources/lib/include/libimobiledevice/property_list_service.h +0 -184
  90. package/resources/lib/include/libimobiledevice/restore.h +0 -179
  91. package/resources/lib/include/libimobiledevice/reverse_proxy.h +0 -213
  92. package/resources/lib/include/libimobiledevice/sbservices.h +0 -175
  93. package/resources/lib/include/libimobiledevice/screenshotr.h +0 -118
  94. package/resources/lib/include/libimobiledevice/service.h +0 -202
  95. package/resources/lib/include/libimobiledevice/syslog_relay.h +0 -184
  96. package/resources/lib/include/libimobiledevice/webinspector.h +0 -137
  97. package/resources/lib/include/plist/Array.h +0 -80
  98. package/resources/lib/include/plist/Boolean.h +0 -48
  99. package/resources/lib/include/plist/Data.h +0 -50
  100. package/resources/lib/include/plist/Date.h +0 -54
  101. package/resources/lib/include/plist/Dictionary.h +0 -73
  102. package/resources/lib/include/plist/Integer.h +0 -54
  103. package/resources/lib/include/plist/Key.h +0 -49
  104. package/resources/lib/include/plist/Node.h +0 -57
  105. package/resources/lib/include/plist/Real.h +0 -48
  106. package/resources/lib/include/plist/String.h +0 -52
  107. package/resources/lib/include/plist/Structure.h +0 -62
  108. package/resources/lib/include/plist/Uid.h +0 -48
  109. package/resources/lib/include/plist/plist++.h +0 -39
  110. package/resources/lib/include/plist/plist.h +0 -1448
  111. package/resources/lib/libimobiledevice-1.0.dll +0 -0
  112. package/resources/lib/libimobiledevice-1.0.dll.a +0 -0
  113. package/resources/lib/libplist-2.0.dll +0 -0
  114. package/resources/lib/libplist-2.0.dll.a +0 -0
package/dist/index.js CHANGED
@@ -986,7 +986,15 @@ function parseAppList(output) {
986
986
  }
987
987
 
988
988
  // src/logic/actions/device.ts
989
+ var import_meta = {};
989
990
  var execAsync = (0, import_node_util.promisify)(import_node_child_process.exec);
991
+ function getModuleDir() {
992
+ if (typeof import_meta !== "undefined" && import_meta.url) {
993
+ const { fileURLToPath } = require("node:url");
994
+ return (0, import_node_path.dirname)(fileURLToPath(import_meta.url));
995
+ }
996
+ return __dirname;
997
+ }
990
998
  async function getDeviceInfo(udid) {
991
999
  logTask(`Getting device info for ${udid}`);
992
1000
  const result = await runIDeviceTool("ideviceinfo", ["-u", udid]);
@@ -1015,12 +1023,17 @@ async function getDeviceInfo(udid) {
1015
1023
  };
1016
1024
  }
1017
1025
  async function runIDeviceTool(toolName, args = [], options = {}) {
1018
- const command = `"${toolName}${process.platform === "win32" ? ".exe" : ""}" ${args.map((a) => `"${a}"`).join(" ")}`;
1026
+ const binPath = getIDeviceBinPath();
1027
+ const ext = process.platform === "win32" ? ".exe" : "";
1028
+ const toolPath = binPath ? (0, import_node_path.join)(binPath, `${toolName}${ext}`) : `${toolName}${ext}`;
1029
+ const command = `"${toolPath}" ${args.map((a) => `"${a}"`).join(" ")}`;
1019
1030
  return execIDevice(command, options);
1020
1031
  }
1021
1032
  async function execIDevice(command, options = {}) {
1022
1033
  const binPath = getIDeviceBinPath();
1023
- options.cwd = binPath;
1034
+ if (binPath) {
1035
+ options.cwd = binPath;
1036
+ }
1024
1037
  const result = await execAsync(command, {
1025
1038
  ...options,
1026
1039
  env: process.env,
@@ -1032,12 +1045,66 @@ async function execIDevice(command, options = {}) {
1032
1045
  stderr: result.stderr.toString()
1033
1046
  };
1034
1047
  }
1048
+ function getPlatformDir() {
1049
+ const platform = process.platform;
1050
+ if (platform === "win32") {
1051
+ return "windows";
1052
+ }
1053
+ if (platform === "darwin") {
1054
+ return "darwin";
1055
+ }
1056
+ if (platform === "linux") {
1057
+ return "linux";
1058
+ }
1059
+ return platform;
1060
+ }
1061
+ function getBundledResourcesPath() {
1062
+ const moduleDir = getModuleDir();
1063
+ let packageRoot;
1064
+ if (moduleDir.includes("dist")) {
1065
+ packageRoot = (0, import_node_path.join)(moduleDir, "..", "..");
1066
+ } else {
1067
+ packageRoot = (0, import_node_path.join)(moduleDir, "..", "..", "..", "..");
1068
+ }
1069
+ const platformDir = getPlatformDir();
1070
+ const distPath = (0, import_node_path.join)(packageRoot, "dist", "resources", "bin", platformDir);
1071
+ if ((0, import_node_fs.existsSync)((0, import_node_path.join)(distPath, "idevice_id")) || (0, import_node_fs.existsSync)((0, import_node_path.join)(distPath, "idevice_id.exe"))) {
1072
+ return distPath;
1073
+ }
1074
+ const devPath = (0, import_node_path.join)(packageRoot, "resources", "bin", platformDir);
1075
+ if ((0, import_node_fs.existsSync)((0, import_node_path.join)(devPath, "idevice_id")) || (0, import_node_fs.existsSync)((0, import_node_path.join)(devPath, "idevice_id.exe"))) {
1076
+ return devPath;
1077
+ }
1078
+ return null;
1079
+ }
1035
1080
  function getResourcesBinPath() {
1036
- const binPath = process.env.IDeviceBinPath;
1037
- if (!binPath) {
1038
- throw new Error("IDeviceBinPath is not set");
1081
+ const envBinPath = process.env.IDeviceBinPath;
1082
+ if (envBinPath) {
1083
+ return envBinPath;
1084
+ }
1085
+ const bundledPath = getBundledResourcesPath();
1086
+ if (bundledPath) {
1087
+ return bundledPath;
1088
+ }
1089
+ if (process.platform === "darwin") {
1090
+ const homebrewArmPath = "/opt/homebrew/bin";
1091
+ if ((0, import_node_fs.existsSync)((0, import_node_path.join)(homebrewArmPath, "idevice_id"))) {
1092
+ return homebrewArmPath;
1093
+ }
1094
+ const homebrewIntelPath = "/usr/local/bin";
1095
+ if ((0, import_node_fs.existsSync)((0, import_node_path.join)(homebrewIntelPath, "idevice_id"))) {
1096
+ return homebrewIntelPath;
1097
+ }
1039
1098
  }
1040
- return binPath;
1099
+ if (process.platform === "linux") {
1100
+ const linuxPaths = ["/usr/bin", "/usr/local/bin"];
1101
+ for (const linuxPath of linuxPaths) {
1102
+ if ((0, import_node_fs.existsSync)((0, import_node_path.join)(linuxPath, "idevice_id"))) {
1103
+ return linuxPath;
1104
+ }
1105
+ }
1106
+ }
1107
+ return "";
1041
1108
  }
1042
1109
  function getIDeviceBinPath() {
1043
1110
  return getResourcesBinPath();
@@ -1346,27 +1413,94 @@ async function launchAppWithPymobiledevice3(bundleId, args, udid) {
1346
1413
 
1347
1414
  // src/logic/actions/proxy.ts
1348
1415
  var import_node_child_process2 = require("node:child_process");
1416
+ var import_node_fs2 = require("node:fs");
1349
1417
  var import_node_path2 = require("node:path");
1418
+ var import_meta2 = {};
1419
+ function getModuleDir2() {
1420
+ if (typeof import_meta2 !== "undefined" && import_meta2.url) {
1421
+ const { fileURLToPath } = require("node:url");
1422
+ return (0, import_node_path2.dirname)(fileURLToPath(import_meta2.url));
1423
+ }
1424
+ return __dirname;
1425
+ }
1426
+ function getPlatformDir2() {
1427
+ const platform = process.platform;
1428
+ if (platform === "win32") {
1429
+ return "windows";
1430
+ }
1431
+ if (platform === "darwin") {
1432
+ return "darwin";
1433
+ }
1434
+ if (platform === "linux") {
1435
+ return "linux";
1436
+ }
1437
+ return platform;
1438
+ }
1439
+ function getBundledResourcesPath2() {
1440
+ const moduleDir = getModuleDir2();
1441
+ let packageRoot;
1442
+ if (moduleDir.includes("dist")) {
1443
+ packageRoot = (0, import_node_path2.join)(moduleDir, "..", "..");
1444
+ } else {
1445
+ packageRoot = (0, import_node_path2.join)(moduleDir, "..", "..", "..", "..");
1446
+ }
1447
+ const platformDir = getPlatformDir2();
1448
+ const distPath = (0, import_node_path2.join)(packageRoot, "dist", "resources", "bin", platformDir);
1449
+ if ((0, import_node_fs2.existsSync)((0, import_node_path2.join)(distPath, "iproxy")) || (0, import_node_fs2.existsSync)((0, import_node_path2.join)(distPath, "iproxy.exe"))) {
1450
+ return distPath;
1451
+ }
1452
+ const devPath = (0, import_node_path2.join)(packageRoot, "resources", "bin", platformDir);
1453
+ if ((0, import_node_fs2.existsSync)((0, import_node_path2.join)(devPath, "iproxy")) || (0, import_node_fs2.existsSync)((0, import_node_path2.join)(devPath, "iproxy.exe"))) {
1454
+ return devPath;
1455
+ }
1456
+ return null;
1457
+ }
1350
1458
  function getResourcesBinPath2() {
1351
- const binPath = process.env.IDeviceBinPath;
1352
- if (!binPath) {
1353
- throw new Error("IDeviceBinPath is not set");
1459
+ const envBinPath = process.env.IDeviceBinPath;
1460
+ if (envBinPath) {
1461
+ return envBinPath;
1462
+ }
1463
+ const bundledPath = getBundledResourcesPath2();
1464
+ if (bundledPath) {
1465
+ return bundledPath;
1466
+ }
1467
+ if (process.platform === "darwin") {
1468
+ const homebrewArmPath = "/opt/homebrew/bin";
1469
+ if ((0, import_node_fs2.existsSync)((0, import_node_path2.join)(homebrewArmPath, "iproxy"))) {
1470
+ return homebrewArmPath;
1471
+ }
1472
+ const homebrewIntelPath = "/usr/local/bin";
1473
+ if ((0, import_node_fs2.existsSync)((0, import_node_path2.join)(homebrewIntelPath, "iproxy"))) {
1474
+ return homebrewIntelPath;
1475
+ }
1354
1476
  }
1355
- return binPath;
1477
+ if (process.platform === "linux") {
1478
+ const linuxPaths = ["/usr/bin", "/usr/local/bin"];
1479
+ for (const linuxPath of linuxPaths) {
1480
+ if ((0, import_node_fs2.existsSync)((0, import_node_path2.join)(linuxPath, "iproxy"))) {
1481
+ return linuxPath;
1482
+ }
1483
+ }
1484
+ }
1485
+ return "";
1356
1486
  }
1357
1487
  function startPortForward(localPort, devicePort, udid, startupTimeout = 500) {
1358
1488
  return new Promise((resolve, reject) => {
1359
1489
  logTask(`Starting port forward ${localPort} -> ${devicePort} for device ${udid}`);
1360
1490
  const binPath = getResourcesBinPath2();
1361
- const toolPath = (0, import_node_path2.join)(binPath, `iproxy${process.platform === "win32" ? ".exe" : ""}`);
1491
+ const ext = process.platform === "win32" ? ".exe" : "";
1492
+ const toolPath = binPath ? (0, import_node_path2.join)(binPath, `iproxy${ext}`) : `iproxy${ext}`;
1493
+ const spawnOptions = {
1494
+ windowsHide: true,
1495
+ stdio: ["ignore", "pipe", "pipe"]
1496
+ };
1497
+ if (binPath) {
1498
+ spawnOptions.cwd = binPath;
1499
+ }
1362
1500
  const child = (0, import_node_child_process2.spawn)(
1363
1501
  toolPath,
1364
1502
  [localPort.toString(), devicePort.toString(), "-u", udid],
1365
- {
1366
- cwd: binPath,
1367
- windowsHide: true,
1368
- stdio: ["ignore", "pipe", "pipe"]
1369
- }
1503
+ spawnOptions
1370
1504
  );
1371
1505
  let hasResolved = false;
1372
1506
  let stderrOutput = "";
@@ -1426,7 +1560,7 @@ var AppleDeviceKit = class {
1426
1560
  }
1427
1561
  deviceId;
1428
1562
  proxyProcess = null;
1429
- devicePort = null;
1563
+ localDevicePort = null;
1430
1564
  isDisposed = false;
1431
1565
  /**
1432
1566
  * Throws if the kit has been disposed
@@ -1554,9 +1688,9 @@ var AppleDeviceKit = class {
1554
1688
  async startPortForwardAsync(devicePort, startupTimeout = 500) {
1555
1689
  this.ensureNotDisposed();
1556
1690
  this.killProxyProcess();
1557
- this.devicePort = await getPorts({ port: portNumbers(3e4, 31e3) });
1691
+ this.localDevicePort = await getPorts({ port: portNumbers(3e4, 31e3) });
1558
1692
  const { result, process: process2 } = await startPortForward(
1559
- this.devicePort,
1693
+ this.localDevicePort,
1560
1694
  devicePort,
1561
1695
  this.deviceId,
1562
1696
  startupTimeout
@@ -1578,8 +1712,8 @@ var AppleDeviceKit = class {
1578
1712
  */
1579
1713
  closePortForward() {
1580
1714
  this.killProxyProcess();
1581
- if (this.devicePort) {
1582
- this.devicePort = null;
1715
+ if (this.localDevicePort) {
1716
+ this.localDevicePort = null;
1583
1717
  }
1584
1718
  }
1585
1719
  /**
@@ -1620,7 +1754,7 @@ var AppleDeviceKit = class {
1620
1754
  * Returns undefined if no port forward is active
1621
1755
  */
1622
1756
  getDevicePort() {
1623
- return this.devicePort;
1757
+ return this.localDevicePort;
1624
1758
  }
1625
1759
  /**
1626
1760
  * Check if this kit has been disposed