@mcesystems/apple-kit 1.0.71 → 1.0.72
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 +556 -252
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +556 -252
- package/dist/index.mjs.map +3 -3
- package/dist/types/logic/actions/device.d.ts.map +1 -1
- package/dist/types/logic/actions/install.d.ts.map +1 -1
- package/dist/types/logic/actions/pair.d.ts.map +1 -1
- package/dist/types/logic/actions/proxy.d.ts.map +1 -1
- package/dist/types/logic/actions/restore.d.ts.map +1 -1
- package/dist/types/logic/activationFlow.d.ts.map +1 -1
- package/dist/types/logic/appleDeviceKit.d.ts.map +1 -1
- package/dist/types/logic/iosCli.d.ts.map +1 -1
- package/dist/types/utils/wifiProfile.d.ts.map +1 -1
- package/package.json +5 -3
package/dist/index.js
CHANGED
|
@@ -865,55 +865,172 @@ var require_src = __commonJS({
|
|
|
865
865
|
}
|
|
866
866
|
});
|
|
867
867
|
var import_debug = __toESM2(require_src());
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
}
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
868
|
+
function createLoggers(namespace, logLevel = process.env.LOG_LEVEL ?? "none") {
|
|
869
|
+
const logInfo9 = (0, import_debug.default)(`${namespace}:info`);
|
|
870
|
+
const logTask6 = (0, import_debug.default)(`${namespace}:task`);
|
|
871
|
+
const logError5 = (0, import_debug.default)(`${namespace}:error`);
|
|
872
|
+
const logDetail2 = (0, import_debug.default)(`${namespace}:detail`);
|
|
873
|
+
const logDebug = (0, import_debug.default)(`${namespace}:debug`);
|
|
874
|
+
const logWarning2 = (0, import_debug.default)(`${namespace}:warning`);
|
|
875
|
+
const logColor = (0, import_debug.default)(`${namespace}:color`);
|
|
876
|
+
logInfo9.color = "19";
|
|
877
|
+
logTask6.color = "25";
|
|
878
|
+
logError5.color = "1";
|
|
879
|
+
logDetail2.color = "199";
|
|
880
|
+
logWarning2.color = "186";
|
|
881
|
+
logDebug.color = "211";
|
|
882
|
+
logColor.enabled = true;
|
|
883
|
+
function setNamespace2(namespace2) {
|
|
884
|
+
logInfo9.namespace = `${namespace2}:info`;
|
|
885
|
+
logTask6.namespace = `${namespace2}:task`;
|
|
886
|
+
logError5.namespace = `${namespace2}:error`;
|
|
887
|
+
logDetail2.namespace = `${namespace2}:detail`;
|
|
888
|
+
logWarning2.namespace = `${namespace2}:warning`;
|
|
889
|
+
logDebug.namespace = `${namespace2}:debug`;
|
|
890
|
+
}
|
|
891
|
+
function setLogLevel(level) {
|
|
892
|
+
switch (level) {
|
|
893
|
+
case "info":
|
|
894
|
+
logInfo9.enabled = true;
|
|
895
|
+
logTask6.enabled = true;
|
|
896
|
+
logError5.enabled = true;
|
|
897
|
+
logWarning2.enabled = true;
|
|
898
|
+
logDetail2.enabled = false;
|
|
899
|
+
logDebug.enabled = false;
|
|
900
|
+
break;
|
|
901
|
+
case "debug":
|
|
902
|
+
logInfo9.enabled = true;
|
|
903
|
+
logTask6.enabled = true;
|
|
904
|
+
logError5.enabled = true;
|
|
905
|
+
logWarning2.enabled = true;
|
|
906
|
+
logDetail2.enabled = true;
|
|
907
|
+
logDebug.enabled = true;
|
|
908
|
+
break;
|
|
909
|
+
case "none":
|
|
910
|
+
logInfo9.enabled = false;
|
|
911
|
+
logTask6.enabled = false;
|
|
912
|
+
logError5.enabled = false;
|
|
913
|
+
logWarning2.enabled = false;
|
|
914
|
+
logDetail2.enabled = false;
|
|
915
|
+
logDebug.enabled = false;
|
|
916
|
+
break;
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
setLogLevel(logLevel);
|
|
920
|
+
function setColors(type, color) {
|
|
921
|
+
switch (type) {
|
|
922
|
+
case "info":
|
|
923
|
+
logInfo9.color = color;
|
|
924
|
+
break;
|
|
925
|
+
case "task":
|
|
926
|
+
logTask6.color = color;
|
|
927
|
+
break;
|
|
928
|
+
case "error":
|
|
929
|
+
logError5.color = color;
|
|
930
|
+
break;
|
|
931
|
+
case "detail":
|
|
932
|
+
logDetail2.color = color;
|
|
933
|
+
break;
|
|
934
|
+
case "warning":
|
|
935
|
+
logWarning2.color = color;
|
|
936
|
+
break;
|
|
937
|
+
case "debug":
|
|
938
|
+
logDebug.color = color;
|
|
939
|
+
break;
|
|
940
|
+
default:
|
|
941
|
+
throw new Error(`Invalid log type: ${type}`);
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
function printColors() {
|
|
945
|
+
for (let i = 0; i < 256; i++) {
|
|
946
|
+
logColor.color = `${i}`;
|
|
947
|
+
logColor(`${i}: ${i}`);
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
function logDataDetail(data, prefix = "# ") {
|
|
951
|
+
if (data === null || data === void 0) {
|
|
952
|
+
return `${prefix}<null or undefined>`;
|
|
953
|
+
}
|
|
954
|
+
if (typeof data !== "object") {
|
|
955
|
+
return `${prefix}${String(data)}`;
|
|
956
|
+
}
|
|
957
|
+
const keys = Object.keys(data);
|
|
958
|
+
let result = "";
|
|
959
|
+
for (const key of keys) {
|
|
960
|
+
result += `${prefix}${key}: `;
|
|
961
|
+
if (key in data) {
|
|
962
|
+
let dataKey = key;
|
|
963
|
+
if (key in data) {
|
|
964
|
+
dataKey = key;
|
|
965
|
+
const value = data[dataKey];
|
|
966
|
+
if (value === null || value === void 0) {
|
|
967
|
+
result += `<${value === null ? "null" : "undefined"}>
|
|
968
|
+
`;
|
|
969
|
+
} else if (typeof value === "object") {
|
|
970
|
+
result += `
|
|
971
|
+
${logDataDetail(value, `${prefix} `)}
|
|
972
|
+
`;
|
|
973
|
+
} else {
|
|
974
|
+
result += `${value}
|
|
975
|
+
`;
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
return result.trim();
|
|
981
|
+
}
|
|
982
|
+
function header(title, padding = 0) {
|
|
983
|
+
return `${" ".repeat(padding)}${"=".repeat(80)}
|
|
984
|
+
${" ".repeat(40 - title.length / 2)}${title}
|
|
985
|
+
${" ".repeat(padding)}${"=".repeat(80)}`;
|
|
916
986
|
}
|
|
987
|
+
function logHeader(title) {
|
|
988
|
+
logInfo9(`${header(title, 2)}`);
|
|
989
|
+
}
|
|
990
|
+
function logDataObject2(title, ...args) {
|
|
991
|
+
const stack = new Error().stack?.split("\n")[2] || "";
|
|
992
|
+
const stackMatch = stack.match(/\((.*):(\d+):(\d+)\)$/) || stack.match(/at (.*):(\d+):(\d+)$/);
|
|
993
|
+
let callerDetails = "";
|
|
994
|
+
if (stackMatch) {
|
|
995
|
+
const functionMatch = stack.match(/at (.+) \(/);
|
|
996
|
+
const functionName = functionMatch ? functionMatch[1] : "<anonymous>";
|
|
997
|
+
callerDetails = `${functionName}`;
|
|
998
|
+
}
|
|
999
|
+
logDetail2(`${header(`*${title}* ${callerDetails}`)}
|
|
1000
|
+
${args.reduce((acc, arg) => `${acc}
|
|
1001
|
+
${logDataDetail(arg)}`, "")}
|
|
1002
|
+
|
|
1003
|
+
${"=".repeat(80)}`);
|
|
1004
|
+
}
|
|
1005
|
+
function logErrorObject(error, extraDetails) {
|
|
1006
|
+
if (error instanceof Error) {
|
|
1007
|
+
logError5(`${extraDetails ? header(extraDetails, 1) : header(error.message, 1)}
|
|
1008
|
+
Error Message:
|
|
1009
|
+
${error.message}
|
|
1010
|
+
Error Stack:
|
|
1011
|
+
${error.stack}
|
|
1012
|
+
${"=".repeat(80)}`);
|
|
1013
|
+
} else {
|
|
1014
|
+
logError5(`${extraDetails ? header(extraDetails, 1) : header(String(error), 1)}
|
|
1015
|
+
${"=".repeat(80)}`);
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
return {
|
|
1019
|
+
logInfo: logInfo9,
|
|
1020
|
+
logTask: logTask6,
|
|
1021
|
+
logError: logError5,
|
|
1022
|
+
logDetail: logDetail2,
|
|
1023
|
+
logDebug,
|
|
1024
|
+
logWarning: logWarning2,
|
|
1025
|
+
logColor,
|
|
1026
|
+
setColors,
|
|
1027
|
+
printColors,
|
|
1028
|
+
logHeader,
|
|
1029
|
+
logDataObject: logDataObject2,
|
|
1030
|
+
logErrorObject,
|
|
1031
|
+
setLogLevel,
|
|
1032
|
+
setNamespace: setNamespace2
|
|
1033
|
+
};
|
|
917
1034
|
}
|
|
918
1035
|
|
|
919
1036
|
// ../../node_modules/.pnpm/get-port@7.1.0/node_modules/get-port/index.js
|
|
@@ -1052,6 +1169,7 @@ function portNumbers(from, to) {
|
|
|
1052
1169
|
}
|
|
1053
1170
|
|
|
1054
1171
|
// src/logic/actions/device.ts
|
|
1172
|
+
var { logTask } = createLoggers("apple-kit:device");
|
|
1055
1173
|
async function info(udid, iosCli2) {
|
|
1056
1174
|
logTask(`Getting device info for ${udid}`);
|
|
1057
1175
|
const result = await iosCli2.info(udid);
|
|
@@ -11083,14 +11201,14 @@ var require_form_data = __commonJS2({
|
|
|
11083
11201
|
this._error(new Error("Arrays are not supported."));
|
|
11084
11202
|
return;
|
|
11085
11203
|
}
|
|
11086
|
-
var
|
|
11204
|
+
var header = this._multiPartHeader(field, value, options);
|
|
11087
11205
|
var footer = this._multiPartFooter();
|
|
11088
|
-
append(
|
|
11206
|
+
append(header);
|
|
11089
11207
|
append(value);
|
|
11090
11208
|
append(footer);
|
|
11091
|
-
this._trackLength(
|
|
11209
|
+
this._trackLength(header, value, options);
|
|
11092
11210
|
};
|
|
11093
|
-
FormData2.prototype._trackLength = function(
|
|
11211
|
+
FormData2.prototype._trackLength = function(header, value, options) {
|
|
11094
11212
|
var valueLength = 0;
|
|
11095
11213
|
if (options.knownLength != null) {
|
|
11096
11214
|
valueLength += Number(options.knownLength);
|
|
@@ -11100,7 +11218,7 @@ var require_form_data = __commonJS2({
|
|
|
11100
11218
|
valueLength = Buffer.byteLength(value);
|
|
11101
11219
|
}
|
|
11102
11220
|
this._valueLength += valueLength;
|
|
11103
|
-
this._overheadLength += Buffer.byteLength(
|
|
11221
|
+
this._overheadLength += Buffer.byteLength(header) + FormData2.LINE_BREAK.length;
|
|
11104
11222
|
if (!value || !value.path && !(value.readable && hasOwn(value, "httpVersion")) && !(value instanceof Stream)) {
|
|
11105
11223
|
return;
|
|
11106
11224
|
}
|
|
@@ -11150,18 +11268,18 @@ var require_form_data = __commonJS2({
|
|
|
11150
11268
|
if (typeof options.header === "object") {
|
|
11151
11269
|
populate(headers, options.header);
|
|
11152
11270
|
}
|
|
11153
|
-
var
|
|
11271
|
+
var header;
|
|
11154
11272
|
for (var prop in headers) {
|
|
11155
11273
|
if (hasOwn(headers, prop)) {
|
|
11156
|
-
|
|
11157
|
-
if (
|
|
11274
|
+
header = headers[prop];
|
|
11275
|
+
if (header == null) {
|
|
11158
11276
|
continue;
|
|
11159
11277
|
}
|
|
11160
|
-
if (!Array.isArray(
|
|
11161
|
-
|
|
11278
|
+
if (!Array.isArray(header)) {
|
|
11279
|
+
header = [header];
|
|
11162
11280
|
}
|
|
11163
|
-
if (
|
|
11164
|
-
contents += prop + ": " +
|
|
11281
|
+
if (header.length) {
|
|
11282
|
+
contents += prop + ": " + header.join("; ") + FormData2.LINE_BREAK;
|
|
11165
11283
|
}
|
|
11166
11284
|
}
|
|
11167
11285
|
}
|
|
@@ -11213,13 +11331,13 @@ var require_form_data = __commonJS2({
|
|
|
11213
11331
|
return "--" + this.getBoundary() + "--" + FormData2.LINE_BREAK;
|
|
11214
11332
|
};
|
|
11215
11333
|
FormData2.prototype.getHeaders = function(userHeaders) {
|
|
11216
|
-
var
|
|
11334
|
+
var header;
|
|
11217
11335
|
var formHeaders = {
|
|
11218
11336
|
"content-type": "multipart/form-data; boundary=" + this.getBoundary()
|
|
11219
11337
|
};
|
|
11220
|
-
for (
|
|
11221
|
-
if (hasOwn(userHeaders,
|
|
11222
|
-
formHeaders[
|
|
11338
|
+
for (header in userHeaders) {
|
|
11339
|
+
if (hasOwn(userHeaders, header)) {
|
|
11340
|
+
formHeaders[header.toLowerCase()] = userHeaders[header];
|
|
11223
11341
|
}
|
|
11224
11342
|
}
|
|
11225
11343
|
return formHeaders;
|
|
@@ -36395,55 +36513,172 @@ var require_src2 = __commonJS22({
|
|
|
36395
36513
|
}
|
|
36396
36514
|
});
|
|
36397
36515
|
var import_debug2 = __toESM22(require_src2());
|
|
36398
|
-
|
|
36399
|
-
|
|
36400
|
-
|
|
36401
|
-
|
|
36402
|
-
|
|
36403
|
-
|
|
36404
|
-
|
|
36405
|
-
|
|
36406
|
-
|
|
36407
|
-
|
|
36408
|
-
|
|
36409
|
-
|
|
36410
|
-
|
|
36411
|
-
|
|
36412
|
-
|
|
36413
|
-
|
|
36414
|
-
|
|
36415
|
-
|
|
36416
|
-
|
|
36417
|
-
|
|
36418
|
-
|
|
36419
|
-
}
|
|
36420
|
-
|
|
36421
|
-
|
|
36422
|
-
|
|
36423
|
-
|
|
36424
|
-
|
|
36425
|
-
|
|
36426
|
-
|
|
36427
|
-
|
|
36428
|
-
|
|
36429
|
-
|
|
36430
|
-
|
|
36431
|
-
|
|
36432
|
-
|
|
36433
|
-
|
|
36434
|
-
|
|
36435
|
-
|
|
36436
|
-
|
|
36437
|
-
|
|
36438
|
-
|
|
36439
|
-
|
|
36440
|
-
|
|
36441
|
-
|
|
36442
|
-
|
|
36443
|
-
|
|
36444
|
-
|
|
36445
|
-
|
|
36516
|
+
function createLoggers2(namespace, logLevel = process.env.LOG_LEVEL ?? "none") {
|
|
36517
|
+
const logInfo22 = (0, import_debug2.default)(`${namespace}:info`);
|
|
36518
|
+
const logTask6 = (0, import_debug2.default)(`${namespace}:task`);
|
|
36519
|
+
const logError22 = (0, import_debug2.default)(`${namespace}:error`);
|
|
36520
|
+
const logDetail2 = (0, import_debug2.default)(`${namespace}:detail`);
|
|
36521
|
+
const logDebug = (0, import_debug2.default)(`${namespace}:debug`);
|
|
36522
|
+
const logWarning2 = (0, import_debug2.default)(`${namespace}:warning`);
|
|
36523
|
+
const logColor = (0, import_debug2.default)(`${namespace}:color`);
|
|
36524
|
+
logInfo22.color = "19";
|
|
36525
|
+
logTask6.color = "25";
|
|
36526
|
+
logError22.color = "1";
|
|
36527
|
+
logDetail2.color = "199";
|
|
36528
|
+
logWarning2.color = "186";
|
|
36529
|
+
logDebug.color = "211";
|
|
36530
|
+
logColor.enabled = true;
|
|
36531
|
+
function setNamespace2(namespace2) {
|
|
36532
|
+
logInfo22.namespace = `${namespace2}:info`;
|
|
36533
|
+
logTask6.namespace = `${namespace2}:task`;
|
|
36534
|
+
logError22.namespace = `${namespace2}:error`;
|
|
36535
|
+
logDetail2.namespace = `${namespace2}:detail`;
|
|
36536
|
+
logWarning2.namespace = `${namespace2}:warning`;
|
|
36537
|
+
logDebug.namespace = `${namespace2}:debug`;
|
|
36538
|
+
}
|
|
36539
|
+
function setLogLevel(level) {
|
|
36540
|
+
switch (level) {
|
|
36541
|
+
case "info":
|
|
36542
|
+
logInfo22.enabled = true;
|
|
36543
|
+
logTask6.enabled = true;
|
|
36544
|
+
logError22.enabled = true;
|
|
36545
|
+
logWarning2.enabled = true;
|
|
36546
|
+
logDetail2.enabled = false;
|
|
36547
|
+
logDebug.enabled = false;
|
|
36548
|
+
break;
|
|
36549
|
+
case "debug":
|
|
36550
|
+
logInfo22.enabled = true;
|
|
36551
|
+
logTask6.enabled = true;
|
|
36552
|
+
logError22.enabled = true;
|
|
36553
|
+
logWarning2.enabled = true;
|
|
36554
|
+
logDetail2.enabled = true;
|
|
36555
|
+
logDebug.enabled = true;
|
|
36556
|
+
break;
|
|
36557
|
+
case "none":
|
|
36558
|
+
logInfo22.enabled = false;
|
|
36559
|
+
logTask6.enabled = false;
|
|
36560
|
+
logError22.enabled = false;
|
|
36561
|
+
logWarning2.enabled = false;
|
|
36562
|
+
logDetail2.enabled = false;
|
|
36563
|
+
logDebug.enabled = false;
|
|
36564
|
+
break;
|
|
36565
|
+
}
|
|
36566
|
+
}
|
|
36567
|
+
setLogLevel(logLevel);
|
|
36568
|
+
function setColors(type, color) {
|
|
36569
|
+
switch (type) {
|
|
36570
|
+
case "info":
|
|
36571
|
+
logInfo22.color = color;
|
|
36572
|
+
break;
|
|
36573
|
+
case "task":
|
|
36574
|
+
logTask6.color = color;
|
|
36575
|
+
break;
|
|
36576
|
+
case "error":
|
|
36577
|
+
logError22.color = color;
|
|
36578
|
+
break;
|
|
36579
|
+
case "detail":
|
|
36580
|
+
logDetail2.color = color;
|
|
36581
|
+
break;
|
|
36582
|
+
case "warning":
|
|
36583
|
+
logWarning2.color = color;
|
|
36584
|
+
break;
|
|
36585
|
+
case "debug":
|
|
36586
|
+
logDebug.color = color;
|
|
36587
|
+
break;
|
|
36588
|
+
default:
|
|
36589
|
+
throw new Error(`Invalid log type: ${type}`);
|
|
36590
|
+
}
|
|
36591
|
+
}
|
|
36592
|
+
function printColors() {
|
|
36593
|
+
for (let i = 0; i < 256; i++) {
|
|
36594
|
+
logColor.color = `${i}`;
|
|
36595
|
+
logColor(`${i}: ${i}`);
|
|
36596
|
+
}
|
|
36597
|
+
}
|
|
36598
|
+
function logDataDetail(data, prefix = "# ") {
|
|
36599
|
+
if (data === null || data === void 0) {
|
|
36600
|
+
return `${prefix}<null or undefined>`;
|
|
36601
|
+
}
|
|
36602
|
+
if (typeof data !== "object") {
|
|
36603
|
+
return `${prefix}${String(data)}`;
|
|
36604
|
+
}
|
|
36605
|
+
const keys = Object.keys(data);
|
|
36606
|
+
let result = "";
|
|
36607
|
+
for (const key of keys) {
|
|
36608
|
+
result += `${prefix}${key}: `;
|
|
36609
|
+
if (key in data) {
|
|
36610
|
+
let dataKey = key;
|
|
36611
|
+
if (key in data) {
|
|
36612
|
+
dataKey = key;
|
|
36613
|
+
const value = data[dataKey];
|
|
36614
|
+
if (value === null || value === void 0) {
|
|
36615
|
+
result += `<${value === null ? "null" : "undefined"}>
|
|
36616
|
+
`;
|
|
36617
|
+
} else if (typeof value === "object") {
|
|
36618
|
+
result += `
|
|
36619
|
+
${logDataDetail(value, `${prefix} `)}
|
|
36620
|
+
`;
|
|
36621
|
+
} else {
|
|
36622
|
+
result += `${value}
|
|
36623
|
+
`;
|
|
36624
|
+
}
|
|
36625
|
+
}
|
|
36626
|
+
}
|
|
36627
|
+
}
|
|
36628
|
+
return result.trim();
|
|
36629
|
+
}
|
|
36630
|
+
function header(title, padding = 0) {
|
|
36631
|
+
return `${" ".repeat(padding)}${"=".repeat(80)}
|
|
36632
|
+
${" ".repeat(40 - title.length / 2)}${title}
|
|
36633
|
+
${" ".repeat(padding)}${"=".repeat(80)}`;
|
|
36634
|
+
}
|
|
36635
|
+
function logHeader(title) {
|
|
36636
|
+
logInfo22(`${header(title, 2)}`);
|
|
36446
36637
|
}
|
|
36638
|
+
function logDataObject2(title, ...args) {
|
|
36639
|
+
const stack = new Error().stack?.split("\n")[2] || "";
|
|
36640
|
+
const stackMatch = stack.match(/\((.*):(\d+):(\d+)\)$/) || stack.match(/at (.*):(\d+):(\d+)$/);
|
|
36641
|
+
let callerDetails = "";
|
|
36642
|
+
if (stackMatch) {
|
|
36643
|
+
const functionMatch = stack.match(/at (.+) \(/);
|
|
36644
|
+
const functionName = functionMatch ? functionMatch[1] : "<anonymous>";
|
|
36645
|
+
callerDetails = `${functionName}`;
|
|
36646
|
+
}
|
|
36647
|
+
logDetail2(`${header(`*${title}* ${callerDetails}`)}
|
|
36648
|
+
${args.reduce((acc, arg) => `${acc}
|
|
36649
|
+
${logDataDetail(arg)}`, "")}
|
|
36650
|
+
|
|
36651
|
+
${"=".repeat(80)}`);
|
|
36652
|
+
}
|
|
36653
|
+
function logErrorObject(error, extraDetails) {
|
|
36654
|
+
if (error instanceof Error) {
|
|
36655
|
+
logError22(`${extraDetails ? header(extraDetails, 1) : header(error.message, 1)}
|
|
36656
|
+
Error Message:
|
|
36657
|
+
${error.message}
|
|
36658
|
+
Error Stack:
|
|
36659
|
+
${error.stack}
|
|
36660
|
+
${"=".repeat(80)}`);
|
|
36661
|
+
} else {
|
|
36662
|
+
logError22(`${extraDetails ? header(extraDetails, 1) : header(String(error), 1)}
|
|
36663
|
+
${"=".repeat(80)}`);
|
|
36664
|
+
}
|
|
36665
|
+
}
|
|
36666
|
+
return {
|
|
36667
|
+
logInfo: logInfo22,
|
|
36668
|
+
logTask: logTask6,
|
|
36669
|
+
logError: logError22,
|
|
36670
|
+
logDetail: logDetail2,
|
|
36671
|
+
logDebug,
|
|
36672
|
+
logWarning: logWarning2,
|
|
36673
|
+
logColor,
|
|
36674
|
+
setColors,
|
|
36675
|
+
printColors,
|
|
36676
|
+
logHeader,
|
|
36677
|
+
logDataObject: logDataObject2,
|
|
36678
|
+
logErrorObject,
|
|
36679
|
+
setLogLevel,
|
|
36680
|
+
setNamespace: setNamespace2
|
|
36681
|
+
};
|
|
36447
36682
|
}
|
|
36448
36683
|
var AUTHORIZE_QUERY = `
|
|
36449
36684
|
query Authorize($input: AuthorizeInput!) {
|
|
@@ -36462,8 +36697,7 @@ var TOKEN_QUERY = `
|
|
|
36462
36697
|
}
|
|
36463
36698
|
}
|
|
36464
36699
|
`;
|
|
36465
|
-
|
|
36466
|
-
logNamespace2("auth");
|
|
36700
|
+
var { logInfo } = createLoggers2("auth");
|
|
36467
36701
|
var random = (0, import_node_util.promisify)(import_node_crypto.randomBytes);
|
|
36468
36702
|
async function getAuthToken(credentials, apiUrl) {
|
|
36469
36703
|
const authApiUrl = apiUrl || process.env.AUTH_API_URL;
|
|
@@ -36472,7 +36706,7 @@ async function getAuthToken(credentials, apiUrl) {
|
|
|
36472
36706
|
}
|
|
36473
36707
|
const { clientDecorator, variantConfigurationKey } = credentials;
|
|
36474
36708
|
const frameworkId = credentials.frameworkId || `apple-kit-${Date.now()}`;
|
|
36475
|
-
|
|
36709
|
+
logInfo(`Getting auth token for identifiers: ${variantConfigurationKey}`);
|
|
36476
36710
|
const randomSecret = (await random(8)).toString("hex");
|
|
36477
36711
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
36478
36712
|
const hash = (0, import_node_crypto.createHash)("sha256");
|
|
@@ -36543,7 +36777,7 @@ async function getAuthToken(credentials, apiUrl) {
|
|
|
36543
36777
|
}
|
|
36544
36778
|
async function readCredentialsFromFile(filePath) {
|
|
36545
36779
|
const fs = await import("node:fs/promises");
|
|
36546
|
-
|
|
36780
|
+
logInfo(`Reading credentials from: ${filePath}`);
|
|
36547
36781
|
const content = await fs.readFile(filePath, "utf-8");
|
|
36548
36782
|
const credentials = JSON.parse(content);
|
|
36549
36783
|
if (!credentials.clientDecorator || !credentials.variantConfigurationKey) {
|
|
@@ -37376,113 +37610,177 @@ var require_src22 = __commonJS3({
|
|
|
37376
37610
|
}
|
|
37377
37611
|
});
|
|
37378
37612
|
var import_debug22 = __toESM32(require_src22());
|
|
37379
|
-
|
|
37380
|
-
|
|
37381
|
-
|
|
37382
|
-
|
|
37383
|
-
|
|
37384
|
-
|
|
37385
|
-
|
|
37386
|
-
|
|
37387
|
-
|
|
37388
|
-
|
|
37389
|
-
|
|
37390
|
-
|
|
37391
|
-
|
|
37392
|
-
|
|
37393
|
-
|
|
37394
|
-
|
|
37395
|
-
|
|
37396
|
-
|
|
37397
|
-
|
|
37398
|
-
|
|
37399
|
-
|
|
37400
|
-
}
|
|
37401
|
-
|
|
37402
|
-
|
|
37403
|
-
|
|
37404
|
-
|
|
37405
|
-
|
|
37406
|
-
|
|
37407
|
-
|
|
37408
|
-
|
|
37409
|
-
|
|
37410
|
-
|
|
37411
|
-
|
|
37412
|
-
|
|
37413
|
-
|
|
37414
|
-
|
|
37415
|
-
|
|
37416
|
-
|
|
37417
|
-
|
|
37418
|
-
|
|
37419
|
-
|
|
37420
|
-
|
|
37421
|
-
|
|
37422
|
-
|
|
37423
|
-
|
|
37424
|
-
|
|
37425
|
-
|
|
37426
|
-
|
|
37427
|
-
|
|
37428
|
-
}
|
|
37429
|
-
|
|
37430
|
-
|
|
37431
|
-
|
|
37432
|
-
|
|
37433
|
-
|
|
37434
|
-
|
|
37435
|
-
|
|
37436
|
-
|
|
37437
|
-
|
|
37438
|
-
|
|
37439
|
-
|
|
37440
|
-
|
|
37441
|
-
|
|
37613
|
+
function createLoggers22(namespace, logLevel = process.env.LOG_LEVEL ?? "none") {
|
|
37614
|
+
const logInfo32 = (0, import_debug22.default)(`${namespace}:info`);
|
|
37615
|
+
const logTask6 = (0, import_debug22.default)(`${namespace}:task`);
|
|
37616
|
+
const logError22 = (0, import_debug22.default)(`${namespace}:error`);
|
|
37617
|
+
const logDetail2 = (0, import_debug22.default)(`${namespace}:detail`);
|
|
37618
|
+
const logDebug = (0, import_debug22.default)(`${namespace}:debug`);
|
|
37619
|
+
const logWarning2 = (0, import_debug22.default)(`${namespace}:warning`);
|
|
37620
|
+
const logColor = (0, import_debug22.default)(`${namespace}:color`);
|
|
37621
|
+
logInfo32.color = "19";
|
|
37622
|
+
logTask6.color = "25";
|
|
37623
|
+
logError22.color = "1";
|
|
37624
|
+
logDetail2.color = "199";
|
|
37625
|
+
logWarning2.color = "186";
|
|
37626
|
+
logDebug.color = "211";
|
|
37627
|
+
logColor.enabled = true;
|
|
37628
|
+
function setNamespace2(namespace2) {
|
|
37629
|
+
logInfo32.namespace = `${namespace2}:info`;
|
|
37630
|
+
logTask6.namespace = `${namespace2}:task`;
|
|
37631
|
+
logError22.namespace = `${namespace2}:error`;
|
|
37632
|
+
logDetail2.namespace = `${namespace2}:detail`;
|
|
37633
|
+
logWarning2.namespace = `${namespace2}:warning`;
|
|
37634
|
+
logDebug.namespace = `${namespace2}:debug`;
|
|
37635
|
+
}
|
|
37636
|
+
function setLogLevel(level) {
|
|
37637
|
+
switch (level) {
|
|
37638
|
+
case "info":
|
|
37639
|
+
logInfo32.enabled = true;
|
|
37640
|
+
logTask6.enabled = true;
|
|
37641
|
+
logError22.enabled = true;
|
|
37642
|
+
logWarning2.enabled = true;
|
|
37643
|
+
logDetail2.enabled = false;
|
|
37644
|
+
logDebug.enabled = false;
|
|
37645
|
+
break;
|
|
37646
|
+
case "debug":
|
|
37647
|
+
logInfo32.enabled = true;
|
|
37648
|
+
logTask6.enabled = true;
|
|
37649
|
+
logError22.enabled = true;
|
|
37650
|
+
logWarning2.enabled = true;
|
|
37651
|
+
logDetail2.enabled = true;
|
|
37652
|
+
logDebug.enabled = true;
|
|
37653
|
+
break;
|
|
37654
|
+
case "none":
|
|
37655
|
+
logInfo32.enabled = false;
|
|
37656
|
+
logTask6.enabled = false;
|
|
37657
|
+
logError22.enabled = false;
|
|
37658
|
+
logWarning2.enabled = false;
|
|
37659
|
+
logDetail2.enabled = false;
|
|
37660
|
+
logDebug.enabled = false;
|
|
37661
|
+
break;
|
|
37662
|
+
}
|
|
37663
|
+
}
|
|
37664
|
+
setLogLevel(logLevel);
|
|
37665
|
+
function setColors(type, color) {
|
|
37666
|
+
switch (type) {
|
|
37667
|
+
case "info":
|
|
37668
|
+
logInfo32.color = color;
|
|
37669
|
+
break;
|
|
37670
|
+
case "task":
|
|
37671
|
+
logTask6.color = color;
|
|
37672
|
+
break;
|
|
37673
|
+
case "error":
|
|
37674
|
+
logError22.color = color;
|
|
37675
|
+
break;
|
|
37676
|
+
case "detail":
|
|
37677
|
+
logDetail2.color = color;
|
|
37678
|
+
break;
|
|
37679
|
+
case "warning":
|
|
37680
|
+
logWarning2.color = color;
|
|
37681
|
+
break;
|
|
37682
|
+
case "debug":
|
|
37683
|
+
logDebug.color = color;
|
|
37684
|
+
break;
|
|
37685
|
+
default:
|
|
37686
|
+
throw new Error(`Invalid log type: ${type}`);
|
|
37687
|
+
}
|
|
37688
|
+
}
|
|
37689
|
+
function printColors() {
|
|
37690
|
+
for (let i = 0; i < 256; i++) {
|
|
37691
|
+
logColor.color = `${i}`;
|
|
37692
|
+
logColor(`${i}: ${i}`);
|
|
37693
|
+
}
|
|
37694
|
+
}
|
|
37695
|
+
function logDataDetail(data, prefix = "# ") {
|
|
37696
|
+
if (data === null || data === void 0) {
|
|
37697
|
+
return `${prefix}<null or undefined>`;
|
|
37698
|
+
}
|
|
37699
|
+
if (typeof data !== "object") {
|
|
37700
|
+
return `${prefix}${String(data)}`;
|
|
37701
|
+
}
|
|
37702
|
+
const keys = Object.keys(data);
|
|
37703
|
+
let result = "";
|
|
37704
|
+
for (const key of keys) {
|
|
37705
|
+
result += `${prefix}${key}: `;
|
|
37442
37706
|
if (key in data) {
|
|
37443
|
-
dataKey = key;
|
|
37444
|
-
|
|
37445
|
-
|
|
37446
|
-
|
|
37707
|
+
let dataKey = key;
|
|
37708
|
+
if (key in data) {
|
|
37709
|
+
dataKey = key;
|
|
37710
|
+
const value = data[dataKey];
|
|
37711
|
+
if (value === null || value === void 0) {
|
|
37712
|
+
result += `<${value === null ? "null" : "undefined"}>
|
|
37447
37713
|
`;
|
|
37448
|
-
|
|
37449
|
-
|
|
37450
|
-
${logDataDetail(value, `${prefix} `)}
|
|
37714
|
+
} else if (typeof value === "object") {
|
|
37715
|
+
result += `
|
|
37716
|
+
${logDataDetail(value, `${prefix} `)}
|
|
37451
37717
|
`;
|
|
37452
|
-
|
|
37453
|
-
|
|
37718
|
+
} else {
|
|
37719
|
+
result += `${value}
|
|
37454
37720
|
`;
|
|
37721
|
+
}
|
|
37455
37722
|
}
|
|
37456
37723
|
}
|
|
37457
37724
|
}
|
|
37725
|
+
return result.trim();
|
|
37458
37726
|
}
|
|
37459
|
-
|
|
37460
|
-
}
|
|
37461
|
-
function header(title, padding = 0) {
|
|
37462
|
-
return `${" ".repeat(padding)}${"=".repeat(80)}
|
|
37727
|
+
function header(title, padding = 0) {
|
|
37728
|
+
return `${" ".repeat(padding)}${"=".repeat(80)}
|
|
37463
37729
|
${" ".repeat(40 - title.length / 2)}${title}
|
|
37464
37730
|
${" ".repeat(padding)}${"=".repeat(80)}`;
|
|
37465
|
-
}
|
|
37466
|
-
function
|
|
37467
|
-
|
|
37468
|
-
|
|
37469
|
-
|
|
37470
|
-
|
|
37471
|
-
const
|
|
37472
|
-
|
|
37473
|
-
|
|
37474
|
-
|
|
37475
|
-
|
|
37731
|
+
}
|
|
37732
|
+
function logHeader(title) {
|
|
37733
|
+
logInfo32(`${header(title, 2)}`);
|
|
37734
|
+
}
|
|
37735
|
+
function logDataObject2(title, ...args) {
|
|
37736
|
+
const stack = new Error().stack?.split("\n")[2] || "";
|
|
37737
|
+
const stackMatch = stack.match(/\((.*):(\d+):(\d+)\)$/) || stack.match(/at (.*):(\d+):(\d+)$/);
|
|
37738
|
+
let callerDetails = "";
|
|
37739
|
+
if (stackMatch) {
|
|
37740
|
+
const functionMatch = stack.match(/at (.+) \(/);
|
|
37741
|
+
const functionName = functionMatch ? functionMatch[1] : "<anonymous>";
|
|
37742
|
+
callerDetails = `${functionName}`;
|
|
37743
|
+
}
|
|
37744
|
+
logDetail2(`${header(`*${title}* ${callerDetails}`)}
|
|
37476
37745
|
${args.reduce((acc, arg) => `${acc}
|
|
37477
37746
|
${logDataDetail(arg)}`, "")}
|
|
37478
|
-
|
|
37747
|
+
|
|
37479
37748
|
${"=".repeat(80)}`);
|
|
37749
|
+
}
|
|
37750
|
+
function logErrorObject(error, extraDetails) {
|
|
37751
|
+
if (error instanceof Error) {
|
|
37752
|
+
logError22(`${extraDetails ? header(extraDetails, 1) : header(error.message, 1)}
|
|
37753
|
+
Error Message:
|
|
37754
|
+
${error.message}
|
|
37755
|
+
Error Stack:
|
|
37756
|
+
${error.stack}
|
|
37757
|
+
${"=".repeat(80)}`);
|
|
37758
|
+
} else {
|
|
37759
|
+
logError22(`${extraDetails ? header(extraDetails, 1) : header(String(error), 1)}
|
|
37760
|
+
${"=".repeat(80)}`);
|
|
37761
|
+
}
|
|
37762
|
+
}
|
|
37763
|
+
return {
|
|
37764
|
+
logInfo: logInfo32,
|
|
37765
|
+
logTask: logTask6,
|
|
37766
|
+
logError: logError22,
|
|
37767
|
+
logDetail: logDetail2,
|
|
37768
|
+
logDebug,
|
|
37769
|
+
logWarning: logWarning2,
|
|
37770
|
+
logColor,
|
|
37771
|
+
setColors,
|
|
37772
|
+
printColors,
|
|
37773
|
+
logHeader,
|
|
37774
|
+
logDataObject: logDataObject2,
|
|
37775
|
+
logErrorObject,
|
|
37776
|
+
setLogLevel,
|
|
37777
|
+
setNamespace: setNamespace2
|
|
37778
|
+
};
|
|
37480
37779
|
}
|
|
37780
|
+
var { logInfo: logInfo2, logError, logWarning, logDataObject } = createLoggers22("mdm-client");
|
|
37481
37781
|
var MdmClient = class {
|
|
37482
37782
|
constructor(config) {
|
|
37483
37783
|
this.config = config;
|
|
37484
|
-
setLogLevel22(process.env.LOG_LEVEL ?? "none");
|
|
37485
|
-
logNamespace22("mdm-client");
|
|
37486
37784
|
logDataObject("MDM Client Config", { config });
|
|
37487
37785
|
if (!config.endpoint) {
|
|
37488
37786
|
throw new Error("MDM endpoint is required");
|
|
@@ -37503,7 +37801,7 @@ var MdmClient = class {
|
|
|
37503
37801
|
}
|
|
37504
37802
|
client;
|
|
37505
37803
|
async generateEnrollmentProfile(deviceId) {
|
|
37506
|
-
|
|
37804
|
+
logInfo2(`Generating enrollment profile for device ${deviceId}`);
|
|
37507
37805
|
const result = await this.client.request(GENERATE_ENROLLMENT_PROFILE, {
|
|
37508
37806
|
input: {
|
|
37509
37807
|
deviceId,
|
|
@@ -37513,7 +37811,7 @@ var MdmClient = class {
|
|
|
37513
37811
|
return result.generateEnrollmentProfile;
|
|
37514
37812
|
}
|
|
37515
37813
|
async waitForDeviceToEnroll(deviceId, previousOpRef) {
|
|
37516
|
-
|
|
37814
|
+
logInfo2(`Waiting for device ${deviceId} to enroll...`);
|
|
37517
37815
|
const result = await this.client.request(WAIT_FOR_DEVICE_TO_ENROLL, {
|
|
37518
37816
|
input: {
|
|
37519
37817
|
deviceId,
|
|
@@ -37523,7 +37821,7 @@ var MdmClient = class {
|
|
|
37523
37821
|
return result.waitForDeviceToEnroll;
|
|
37524
37822
|
}
|
|
37525
37823
|
async installApp(deviceId, options) {
|
|
37526
|
-
|
|
37824
|
+
logInfo2(`Installing app on device ${deviceId}`);
|
|
37527
37825
|
try {
|
|
37528
37826
|
const result = await this.client.request(INSTALL_APP, {
|
|
37529
37827
|
input: {
|
|
@@ -37541,7 +37839,7 @@ var MdmClient = class {
|
|
|
37541
37839
|
return result.installApp;
|
|
37542
37840
|
} catch (error) {
|
|
37543
37841
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
37544
|
-
|
|
37842
|
+
logError(`Failed to install app: ${errorMsg}`);
|
|
37545
37843
|
throw error;
|
|
37546
37844
|
}
|
|
37547
37845
|
}
|
|
@@ -37550,7 +37848,7 @@ async function createMDMClient() {
|
|
|
37550
37848
|
const endpoint = process.env.MDM_ENDPOINT;
|
|
37551
37849
|
const credPath = process.env.CREDENTIALS_PATH;
|
|
37552
37850
|
if (!endpoint || !credPath) {
|
|
37553
|
-
|
|
37851
|
+
logWarning("MDM endpoint or credentials path is not set");
|
|
37554
37852
|
logDataObject("Environment variables", { endpoint, credPath });
|
|
37555
37853
|
return void 0;
|
|
37556
37854
|
}
|
|
@@ -37668,8 +37966,9 @@ async function execIDevice(command, options = {}) {
|
|
|
37668
37966
|
}
|
|
37669
37967
|
|
|
37670
37968
|
// src/logic/actions/pair.ts
|
|
37969
|
+
var { logTask: logTask2, logInfo: logInfo3, logError: logError2 } = createLoggers("apple-kit:pair");
|
|
37671
37970
|
async function isPaired(udid) {
|
|
37672
|
-
|
|
37971
|
+
logTask2(`Checking pairing status for ${udid}`);
|
|
37673
37972
|
try {
|
|
37674
37973
|
const result = await runIDeviceTool("idevicepair", ["-u", udid, "validate"]);
|
|
37675
37974
|
if (!result) {
|
|
@@ -37681,38 +37980,38 @@ async function isPaired(udid) {
|
|
|
37681
37980
|
}
|
|
37682
37981
|
}
|
|
37683
37982
|
async function trustDevice(udid, timeout2 = 6e4, onWaitingForTrust) {
|
|
37684
|
-
|
|
37983
|
+
logTask2(`Trusting device ${udid}`);
|
|
37685
37984
|
if (await isPaired(udid)) {
|
|
37686
|
-
|
|
37985
|
+
logInfo3(`Device ${udid} is already trusted`);
|
|
37687
37986
|
return true;
|
|
37688
37987
|
}
|
|
37689
|
-
|
|
37988
|
+
logInfo3(`Initiating pairing for device ${udid}`);
|
|
37690
37989
|
try {
|
|
37691
37990
|
const pairResult = await pair(udid);
|
|
37692
37991
|
if (pairResult) {
|
|
37693
|
-
|
|
37992
|
+
logInfo3(`Device ${udid} paired successfully`);
|
|
37694
37993
|
return true;
|
|
37695
37994
|
}
|
|
37696
37995
|
} catch (error) {
|
|
37697
|
-
|
|
37996
|
+
logError2(`Pairing failed with ${udid}: ${error}`);
|
|
37698
37997
|
}
|
|
37699
|
-
|
|
37998
|
+
logInfo3("Please accept the trust dialog on the device...");
|
|
37700
37999
|
onWaitingForTrust?.();
|
|
37701
38000
|
try {
|
|
37702
38001
|
await waitForPairing(udid, timeout2, 1e3);
|
|
37703
|
-
|
|
38002
|
+
logInfo3(`Device ${udid} is now trusted`);
|
|
37704
38003
|
return true;
|
|
37705
38004
|
} catch {
|
|
37706
|
-
|
|
38005
|
+
logInfo3(`Timeout waiting for trust acceptance on device ${udid}`);
|
|
37707
38006
|
return false;
|
|
37708
38007
|
}
|
|
37709
38008
|
}
|
|
37710
38009
|
async function waitForPairing(udid, timeout2 = 12e4, pollInterval = 1e3) {
|
|
37711
|
-
|
|
38010
|
+
logTask2(`Waiting for pairing on device ${udid}`);
|
|
37712
38011
|
const startTime = Date.now();
|
|
37713
38012
|
while (Date.now() - startTime < timeout2) {
|
|
37714
38013
|
if (await isPaired(udid)) {
|
|
37715
|
-
|
|
38014
|
+
logInfo3(`Device ${udid} is now paired`);
|
|
37716
38015
|
return true;
|
|
37717
38016
|
}
|
|
37718
38017
|
await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
|
|
@@ -37720,7 +38019,7 @@ async function waitForPairing(udid, timeout2 = 12e4, pollInterval = 1e3) {
|
|
|
37720
38019
|
throw new Error(`Timeout waiting for device pairing after ${timeout2}ms`);
|
|
37721
38020
|
}
|
|
37722
38021
|
async function pair(udid) {
|
|
37723
|
-
|
|
38022
|
+
logTask2(`Initiating pairing for device ${udid}`);
|
|
37724
38023
|
try {
|
|
37725
38024
|
const result = await runIDeviceTool("idevicepair", ["-u", udid, "pair"]);
|
|
37726
38025
|
if (!result) {
|
|
@@ -37736,7 +38035,7 @@ async function pair(udid) {
|
|
|
37736
38035
|
}
|
|
37737
38036
|
}
|
|
37738
38037
|
async function unpair(udid) {
|
|
37739
|
-
|
|
38038
|
+
logTask2(`Un-pairing device ${udid}`);
|
|
37740
38039
|
try {
|
|
37741
38040
|
const result = await runIDeviceTool("idevicepair", ["-u", udid, "unpair"]);
|
|
37742
38041
|
if (!result) {
|
|
@@ -37749,24 +38048,25 @@ async function unpair(udid) {
|
|
|
37749
38048
|
}
|
|
37750
38049
|
|
|
37751
38050
|
// src/logic/actions/install.ts
|
|
38051
|
+
var { logTask: logTask3, logInfo: logInfo4 } = createLoggers("apple-kit:install");
|
|
37752
38052
|
async function installManagedApp(ipaPath, udid, iosCli2, options) {
|
|
37753
38053
|
const result = await iosCli2.installApp(udid, ipaPath);
|
|
37754
38054
|
const client = await createMDMClient();
|
|
37755
|
-
|
|
38055
|
+
logTask3("Installing app via MDM for management takeover");
|
|
37756
38056
|
if (client) {
|
|
37757
38057
|
await client.installApp(udid, options);
|
|
37758
38058
|
}
|
|
37759
38059
|
return result;
|
|
37760
38060
|
}
|
|
37761
38061
|
async function uninstallApp(bundleId, udid) {
|
|
37762
|
-
|
|
38062
|
+
logTask3(`Uninstalling app ${bundleId} from device ${udid}`);
|
|
37763
38063
|
if (!await isPaired(udid)) {
|
|
37764
38064
|
await waitForPairing(udid, 1e4);
|
|
37765
38065
|
}
|
|
37766
38066
|
await runIDeviceTool("ideviceinstaller", ["-u", udid, "uninstall", bundleId]);
|
|
37767
38067
|
}
|
|
37768
38068
|
async function listApps(udid) {
|
|
37769
|
-
|
|
38069
|
+
logTask3(`Listing apps on device ${udid}`);
|
|
37770
38070
|
if (!await isPaired(udid)) {
|
|
37771
38071
|
await waitForPairing(udid, 1e4);
|
|
37772
38072
|
}
|
|
@@ -37782,7 +38082,7 @@ async function listApps(udid) {
|
|
|
37782
38082
|
}
|
|
37783
38083
|
}
|
|
37784
38084
|
async function isAppInstalled(bundleId, udid) {
|
|
37785
|
-
|
|
38085
|
+
logTask3(`Checking if app ${bundleId} is installed on device ${udid}`);
|
|
37786
38086
|
const apps = await listApps(udid);
|
|
37787
38087
|
return apps.some((app) => app.bundleId === bundleId);
|
|
37788
38088
|
}
|
|
@@ -37790,9 +38090,10 @@ async function isAppInstalled(bundleId, udid) {
|
|
|
37790
38090
|
// src/logic/actions/proxy.ts
|
|
37791
38091
|
var import_node_child_process2 = require("node:child_process");
|
|
37792
38092
|
var import_node_path3 = require("node:path");
|
|
38093
|
+
var { logTask: logTask4, logInfo: logInfo5, logError: logError3 } = createLoggers("apple-kit:proxy");
|
|
37793
38094
|
function startPortForward(localPort, devicePort, udid, startupTimeout = 500) {
|
|
37794
38095
|
return new Promise((resolve2, reject) => {
|
|
37795
|
-
|
|
38096
|
+
logTask4(`Starting port forward ${localPort} -> ${devicePort} for device ${udid}`);
|
|
37796
38097
|
const binPath = getResourcesBinPath();
|
|
37797
38098
|
const ext = process.platform === "win32" ? ".exe" : "";
|
|
37798
38099
|
const toolPath = binPath ? (0, import_node_path3.join)(binPath, `iproxy${ext}`) : `iproxy${ext}`;
|
|
@@ -37803,9 +38104,9 @@ function startPortForward(localPort, devicePort, udid, startupTimeout = 500) {
|
|
|
37803
38104
|
if (binPath) {
|
|
37804
38105
|
spawnOptions.cwd = binPath;
|
|
37805
38106
|
}
|
|
37806
|
-
|
|
37807
|
-
|
|
37808
|
-
|
|
38107
|
+
logInfo5(`Spawning iproxy with path: ${toolPath}`);
|
|
38108
|
+
logInfo5(`Arguments: ${[localPort.toString(), devicePort.toString(), "-u", udid].join(" ")}`);
|
|
38109
|
+
logInfo5(`Options: ${JSON.stringify(spawnOptions)}`);
|
|
37809
38110
|
const child = (0, import_node_child_process2.spawn)(
|
|
37810
38111
|
toolPath,
|
|
37811
38112
|
[localPort.toString(), devicePort.toString(), "-u", udid],
|
|
@@ -37814,10 +38115,10 @@ function startPortForward(localPort, devicePort, udid, startupTimeout = 500) {
|
|
|
37814
38115
|
let hasResolved = false;
|
|
37815
38116
|
let stderrOutput = "";
|
|
37816
38117
|
child.stdout?.on("data", (data) => {
|
|
37817
|
-
|
|
38118
|
+
logTask4(`${data.toString()}`);
|
|
37818
38119
|
});
|
|
37819
38120
|
child.stderr?.on("data", (data) => {
|
|
37820
|
-
|
|
38121
|
+
logError3(`${data.toString()}`);
|
|
37821
38122
|
const msg = data.toString();
|
|
37822
38123
|
stderrOutput += msg;
|
|
37823
38124
|
if (msg.toLowerCase().includes("error") && !hasResolved) {
|
|
@@ -37843,7 +38144,7 @@ function startPortForward(localPort, devicePort, udid, startupTimeout = 500) {
|
|
|
37843
38144
|
setTimeout(() => {
|
|
37844
38145
|
if (!hasResolved) {
|
|
37845
38146
|
hasResolved = true;
|
|
37846
|
-
|
|
38147
|
+
logTask4(`Port forward started: ${localPort} -> ${devicePort} for device ${udid}`);
|
|
37847
38148
|
resolve2({
|
|
37848
38149
|
result: {
|
|
37849
38150
|
localPort,
|
|
@@ -37857,7 +38158,7 @@ function startPortForward(localPort, devicePort, udid, startupTimeout = 500) {
|
|
|
37857
38158
|
}
|
|
37858
38159
|
function killPortForwardProcess(process3) {
|
|
37859
38160
|
if (process3 && !process3.killed) {
|
|
37860
|
-
|
|
38161
|
+
logTask4("Killing port forward process");
|
|
37861
38162
|
process3.kill();
|
|
37862
38163
|
}
|
|
37863
38164
|
}
|
|
@@ -37959,6 +38260,7 @@ function escapeXml(str) {
|
|
|
37959
38260
|
}
|
|
37960
38261
|
|
|
37961
38262
|
// src/utils/wifiProfile.ts
|
|
38263
|
+
var { logInfo: logInfo6 } = createLoggers("apple-kit:wifi-profile");
|
|
37962
38264
|
async function generateWifiProfile(config, options) {
|
|
37963
38265
|
const {
|
|
37964
38266
|
ssid,
|
|
@@ -37977,7 +38279,7 @@ async function generateWifiProfile(config, options) {
|
|
|
37977
38279
|
const payloadUuid = (0, import_node_crypto2.randomUUID)().toUpperCase();
|
|
37978
38280
|
const profileId = `com.mce.wifi.${ssid.replace(/[^a-zA-Z0-9]/g, "")}.${Date.now()}`;
|
|
37979
38281
|
const payloadId = `${profileId}.payload`;
|
|
37980
|
-
|
|
38282
|
+
logInfo6(`Generating WiFi profile for SSID: ${ssid}, encryption: ${encryptionType}`);
|
|
37981
38283
|
const templateName = enterprise ? "wifi-enterprise.xml" : "wifi-standard.xml";
|
|
37982
38284
|
const template = await loadTemplate(templateName, options?.plistDir);
|
|
37983
38285
|
const variables = {
|
|
@@ -38016,7 +38318,7 @@ async function generateWifiProfile(config, options) {
|
|
|
38016
38318
|
async function generateWifiProfileFromEnv(options) {
|
|
38017
38319
|
const ssid = process.env.WIFI_SSID;
|
|
38018
38320
|
if (!ssid) {
|
|
38019
|
-
|
|
38321
|
+
logInfo6("WIFI_SSID not set, skipping WiFi profile generation");
|
|
38020
38322
|
return null;
|
|
38021
38323
|
}
|
|
38022
38324
|
const config = {
|
|
@@ -38028,7 +38330,7 @@ async function generateWifiProfileFromEnv(options) {
|
|
|
38028
38330
|
username: process.env.WIFI_USERNAME,
|
|
38029
38331
|
eapType: parseWifiEapType(process.env.WIFI_EAP_TYPE)
|
|
38030
38332
|
};
|
|
38031
|
-
|
|
38333
|
+
logInfo6(`Generating WiFi profile from env: SSID=${ssid}, enterprise=${config.enterprise}`);
|
|
38032
38334
|
return generateWifiProfile(config, options);
|
|
38033
38335
|
}
|
|
38034
38336
|
async function saveWifiProfileToTemp(profile) {
|
|
@@ -38039,7 +38341,7 @@ async function saveWifiProfileToTemp(profile) {
|
|
|
38039
38341
|
const fileName = `mce_wifi_${Date.now()}.mobileconfig`;
|
|
38040
38342
|
const filePath = path.join(tempDir, fileName);
|
|
38041
38343
|
await fs.writeFile(filePath, profile, "utf-8");
|
|
38042
|
-
|
|
38344
|
+
logInfo6(`WiFi profile saved to: ${filePath}`);
|
|
38043
38345
|
return filePath;
|
|
38044
38346
|
}
|
|
38045
38347
|
function getEapTypeNumber(eapType) {
|
|
@@ -38085,6 +38387,7 @@ function parseWifiEapType(value) {
|
|
|
38085
38387
|
// src/logic/activationFlow.ts
|
|
38086
38388
|
var DEFAULT_RETRIES = 150;
|
|
38087
38389
|
var DEFAULT_RETRY_DELAY_MS = 1e3;
|
|
38390
|
+
var { logTask: logTask5, logInfo: logInfo7, logError: logError4 } = createLoggers("apple-kit:activation");
|
|
38088
38391
|
var ActivationFlow = class {
|
|
38089
38392
|
iosCli;
|
|
38090
38393
|
mdmClient;
|
|
@@ -38093,7 +38396,7 @@ var ActivationFlow = class {
|
|
|
38093
38396
|
}
|
|
38094
38397
|
async run(udid, steps) {
|
|
38095
38398
|
this.mdmClient = await createMDMClient();
|
|
38096
|
-
|
|
38399
|
+
logTask5(`Starting activation flow for device ${udid}`);
|
|
38097
38400
|
await this.retryActivateCommand("activate device", () => this.iosCli.activate(udid));
|
|
38098
38401
|
const wifiProfileIdentifier = await this.installWifiProfile(udid);
|
|
38099
38402
|
await this.installMdmProfile(udid);
|
|
@@ -38115,7 +38418,7 @@ var ActivationFlow = class {
|
|
|
38115
38418
|
return wifiProfileIdentifier;
|
|
38116
38419
|
}
|
|
38117
38420
|
async installMdmProfile(udid) {
|
|
38118
|
-
|
|
38421
|
+
logTask5("Installing MDM enrollment profile");
|
|
38119
38422
|
const enrollmentProfile = await this.retry(
|
|
38120
38423
|
"generate mdm enrollment profile",
|
|
38121
38424
|
() => {
|
|
@@ -38140,7 +38443,7 @@ var ActivationFlow = class {
|
|
|
38140
38443
|
if (!profileIdentifier) {
|
|
38141
38444
|
return;
|
|
38142
38445
|
}
|
|
38143
|
-
|
|
38446
|
+
logTask5("Removing WiFi profile");
|
|
38144
38447
|
await this.retryIosCommand(
|
|
38145
38448
|
"remove wifi profile",
|
|
38146
38449
|
() => this.iosCli.removeProfile(udid, profileIdentifier)
|
|
@@ -38161,9 +38464,9 @@ var ActivationFlow = class {
|
|
|
38161
38464
|
}
|
|
38162
38465
|
} catch (error) {
|
|
38163
38466
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
38164
|
-
|
|
38467
|
+
logError4(`${label} failed: ${errorMsg}`);
|
|
38165
38468
|
}
|
|
38166
|
-
|
|
38469
|
+
logInfo7(`Retrying ${label}... ${attempt + 1} of ${retries}`);
|
|
38167
38470
|
await new Promise((resolve2) => setTimeout(resolve2, retryDelayMs));
|
|
38168
38471
|
}
|
|
38169
38472
|
throw new Error(`Failed to ${label} after ${retries} attempts`);
|
|
@@ -38172,16 +38475,16 @@ var ActivationFlow = class {
|
|
|
38172
38475
|
async function saveProfileToTemp(profile, prefix) {
|
|
38173
38476
|
const tempFilePath = (0, import_node_path5.join)((0, import_node_os5.tmpdir)(), `mce_${prefix}_${Date.now()}.mobileconfig`);
|
|
38174
38477
|
await (0, import_promises2.writeFile)(tempFilePath, profile, "utf-8");
|
|
38175
|
-
|
|
38478
|
+
logInfo7(`Profile saved to: ${tempFilePath}`);
|
|
38176
38479
|
return tempFilePath;
|
|
38177
38480
|
}
|
|
38178
38481
|
async function removeTempFile(filePath, label) {
|
|
38179
38482
|
try {
|
|
38180
38483
|
await (0, import_promises2.unlink)(filePath);
|
|
38181
|
-
|
|
38484
|
+
logInfo7(`Removed ${label} temp file: ${filePath}`);
|
|
38182
38485
|
} catch (error) {
|
|
38183
38486
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
38184
|
-
|
|
38487
|
+
logError4(`Failed to remove ${label} temp file: ${errorMsg}`);
|
|
38185
38488
|
}
|
|
38186
38489
|
}
|
|
38187
38490
|
function getProfileIdentifierFromProfile(profile) {
|
|
@@ -38216,6 +38519,7 @@ function isActivationSuccess(result) {
|
|
|
38216
38519
|
// src/logic/iosCli.ts
|
|
38217
38520
|
var import_node_child_process3 = require("node:child_process");
|
|
38218
38521
|
var import_node_path6 = require("node:path");
|
|
38522
|
+
var { logDetail } = createLoggers("apple-kit:ios-cli");
|
|
38219
38523
|
var ios;
|
|
38220
38524
|
function iosCli() {
|
|
38221
38525
|
const iosBinaryPath = resolveIosBinaryPath();
|
|
@@ -38430,13 +38734,13 @@ function createIosCli(iosBinaryPath) {
|
|
|
38430
38734
|
}
|
|
38431
38735
|
|
|
38432
38736
|
// src/logic/appleDeviceKit.ts
|
|
38737
|
+
var { logInfo: logInfo8, setNamespace } = createLoggers("apple-kit");
|
|
38433
38738
|
var AppleDeviceKit = class {
|
|
38434
38739
|
constructor(udid, logicalPort) {
|
|
38435
38740
|
this.logicalPort = logicalPort;
|
|
38436
38741
|
this.deviceId = udid;
|
|
38437
|
-
|
|
38438
|
-
|
|
38439
|
-
logInfo(
|
|
38742
|
+
setNamespace(`apple-kit:${udid}`);
|
|
38743
|
+
logInfo8(
|
|
38440
38744
|
`AppleDeviceKit initialized for device: ${this.deviceId}, logical port: ${this.logicalPort}`
|
|
38441
38745
|
);
|
|
38442
38746
|
const iosBinaryPath = resolveIosBinaryPath();
|
|
@@ -38668,7 +38972,7 @@ var AppleDeviceKit = class {
|
|
|
38668
38972
|
if (this.isDisposed) {
|
|
38669
38973
|
return;
|
|
38670
38974
|
}
|
|
38671
|
-
|
|
38975
|
+
logInfo8(`Disposing AppleDeviceKit for device: ${this.deviceId}`);
|
|
38672
38976
|
this.closePortForward();
|
|
38673
38977
|
this.isDisposed = true;
|
|
38674
38978
|
}
|