@mcesystems/apple-kit 1.0.71 → 1.0.73
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 +673 -252
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +673 -252
- package/dist/index.mjs.map +3 -3
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- 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/types/ios.d.ts +10 -0
- package/dist/types/types/ios.d.ts.map +1 -1
- package/dist/types/utils/wifiProfile.d.ts.map +1 -1
- package/package.json +5 -3
package/dist/index.mjs
CHANGED
|
@@ -834,55 +834,172 @@ var require_src = __commonJS({
|
|
|
834
834
|
}
|
|
835
835
|
});
|
|
836
836
|
var import_debug = __toESM(require_src());
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
}
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
837
|
+
function createLoggers(namespace, logLevel = process.env.LOG_LEVEL ?? "none") {
|
|
838
|
+
const logInfo9 = (0, import_debug.default)(`${namespace}:info`);
|
|
839
|
+
const logTask6 = (0, import_debug.default)(`${namespace}:task`);
|
|
840
|
+
const logError5 = (0, import_debug.default)(`${namespace}:error`);
|
|
841
|
+
const logDetail2 = (0, import_debug.default)(`${namespace}:detail`);
|
|
842
|
+
const logDebug = (0, import_debug.default)(`${namespace}:debug`);
|
|
843
|
+
const logWarning2 = (0, import_debug.default)(`${namespace}:warning`);
|
|
844
|
+
const logColor = (0, import_debug.default)(`${namespace}:color`);
|
|
845
|
+
logInfo9.color = "19";
|
|
846
|
+
logTask6.color = "25";
|
|
847
|
+
logError5.color = "1";
|
|
848
|
+
logDetail2.color = "199";
|
|
849
|
+
logWarning2.color = "186";
|
|
850
|
+
logDebug.color = "211";
|
|
851
|
+
logColor.enabled = true;
|
|
852
|
+
function setNamespace2(namespace2) {
|
|
853
|
+
logInfo9.namespace = `${namespace2}:info`;
|
|
854
|
+
logTask6.namespace = `${namespace2}:task`;
|
|
855
|
+
logError5.namespace = `${namespace2}:error`;
|
|
856
|
+
logDetail2.namespace = `${namespace2}:detail`;
|
|
857
|
+
logWarning2.namespace = `${namespace2}:warning`;
|
|
858
|
+
logDebug.namespace = `${namespace2}:debug`;
|
|
859
|
+
}
|
|
860
|
+
function setLogLevel(level) {
|
|
861
|
+
switch (level) {
|
|
862
|
+
case "info":
|
|
863
|
+
logInfo9.enabled = true;
|
|
864
|
+
logTask6.enabled = true;
|
|
865
|
+
logError5.enabled = true;
|
|
866
|
+
logWarning2.enabled = true;
|
|
867
|
+
logDetail2.enabled = false;
|
|
868
|
+
logDebug.enabled = false;
|
|
869
|
+
break;
|
|
870
|
+
case "debug":
|
|
871
|
+
logInfo9.enabled = true;
|
|
872
|
+
logTask6.enabled = true;
|
|
873
|
+
logError5.enabled = true;
|
|
874
|
+
logWarning2.enabled = true;
|
|
875
|
+
logDetail2.enabled = true;
|
|
876
|
+
logDebug.enabled = true;
|
|
877
|
+
break;
|
|
878
|
+
case "none":
|
|
879
|
+
logInfo9.enabled = false;
|
|
880
|
+
logTask6.enabled = false;
|
|
881
|
+
logError5.enabled = false;
|
|
882
|
+
logWarning2.enabled = false;
|
|
883
|
+
logDetail2.enabled = false;
|
|
884
|
+
logDebug.enabled = false;
|
|
885
|
+
break;
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
setLogLevel(logLevel);
|
|
889
|
+
function setColors(type, color) {
|
|
890
|
+
switch (type) {
|
|
891
|
+
case "info":
|
|
892
|
+
logInfo9.color = color;
|
|
893
|
+
break;
|
|
894
|
+
case "task":
|
|
895
|
+
logTask6.color = color;
|
|
896
|
+
break;
|
|
897
|
+
case "error":
|
|
898
|
+
logError5.color = color;
|
|
899
|
+
break;
|
|
900
|
+
case "detail":
|
|
901
|
+
logDetail2.color = color;
|
|
902
|
+
break;
|
|
903
|
+
case "warning":
|
|
904
|
+
logWarning2.color = color;
|
|
905
|
+
break;
|
|
906
|
+
case "debug":
|
|
907
|
+
logDebug.color = color;
|
|
908
|
+
break;
|
|
909
|
+
default:
|
|
910
|
+
throw new Error(`Invalid log type: ${type}`);
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
function printColors() {
|
|
914
|
+
for (let i = 0; i < 256; i++) {
|
|
915
|
+
logColor.color = `${i}`;
|
|
916
|
+
logColor(`${i}: ${i}`);
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
function logDataDetail(data, prefix = "# ") {
|
|
920
|
+
if (data === null || data === void 0) {
|
|
921
|
+
return `${prefix}<null or undefined>`;
|
|
922
|
+
}
|
|
923
|
+
if (typeof data !== "object") {
|
|
924
|
+
return `${prefix}${String(data)}`;
|
|
925
|
+
}
|
|
926
|
+
const keys = Object.keys(data);
|
|
927
|
+
let result = "";
|
|
928
|
+
for (const key of keys) {
|
|
929
|
+
result += `${prefix}${key}: `;
|
|
930
|
+
if (key in data) {
|
|
931
|
+
let dataKey = key;
|
|
932
|
+
if (key in data) {
|
|
933
|
+
dataKey = key;
|
|
934
|
+
const value = data[dataKey];
|
|
935
|
+
if (value === null || value === void 0) {
|
|
936
|
+
result += `<${value === null ? "null" : "undefined"}>
|
|
937
|
+
`;
|
|
938
|
+
} else if (typeof value === "object") {
|
|
939
|
+
result += `
|
|
940
|
+
${logDataDetail(value, `${prefix} `)}
|
|
941
|
+
`;
|
|
942
|
+
} else {
|
|
943
|
+
result += `${value}
|
|
944
|
+
`;
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
return result.trim();
|
|
950
|
+
}
|
|
951
|
+
function header(title, padding = 0) {
|
|
952
|
+
return `${" ".repeat(padding)}${"=".repeat(80)}
|
|
953
|
+
${" ".repeat(40 - title.length / 2)}${title}
|
|
954
|
+
${" ".repeat(padding)}${"=".repeat(80)}`;
|
|
955
|
+
}
|
|
956
|
+
function logHeader(title) {
|
|
957
|
+
logInfo9(`${header(title, 2)}`);
|
|
958
|
+
}
|
|
959
|
+
function logDataObject2(title, ...args) {
|
|
960
|
+
const stack = new Error().stack?.split("\n")[2] || "";
|
|
961
|
+
const stackMatch = stack.match(/\((.*):(\d+):(\d+)\)$/) || stack.match(/at (.*):(\d+):(\d+)$/);
|
|
962
|
+
let callerDetails = "";
|
|
963
|
+
if (stackMatch) {
|
|
964
|
+
const functionMatch = stack.match(/at (.+) \(/);
|
|
965
|
+
const functionName = functionMatch ? functionMatch[1] : "<anonymous>";
|
|
966
|
+
callerDetails = `${functionName}`;
|
|
967
|
+
}
|
|
968
|
+
logDetail2(`${header(`*${title}* ${callerDetails}`)}
|
|
969
|
+
${args.reduce((acc, arg) => `${acc}
|
|
970
|
+
${logDataDetail(arg)}`, "")}
|
|
971
|
+
|
|
972
|
+
${"=".repeat(80)}`);
|
|
885
973
|
}
|
|
974
|
+
function logErrorObject(error, extraDetails) {
|
|
975
|
+
if (error instanceof Error) {
|
|
976
|
+
logError5(`${extraDetails ? header(extraDetails, 1) : header(error.message, 1)}
|
|
977
|
+
Error Message:
|
|
978
|
+
${error.message}
|
|
979
|
+
Error Stack:
|
|
980
|
+
${error.stack}
|
|
981
|
+
${"=".repeat(80)}`);
|
|
982
|
+
} else {
|
|
983
|
+
logError5(`${extraDetails ? header(extraDetails, 1) : header(String(error), 1)}
|
|
984
|
+
${"=".repeat(80)}`);
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
return {
|
|
988
|
+
logInfo: logInfo9,
|
|
989
|
+
logTask: logTask6,
|
|
990
|
+
logError: logError5,
|
|
991
|
+
logDetail: logDetail2,
|
|
992
|
+
logDebug,
|
|
993
|
+
logWarning: logWarning2,
|
|
994
|
+
logColor,
|
|
995
|
+
setColors,
|
|
996
|
+
printColors,
|
|
997
|
+
logHeader,
|
|
998
|
+
logDataObject: logDataObject2,
|
|
999
|
+
logErrorObject,
|
|
1000
|
+
setLogLevel,
|
|
1001
|
+
setNamespace: setNamespace2
|
|
1002
|
+
};
|
|
886
1003
|
}
|
|
887
1004
|
|
|
888
1005
|
// ../../node_modules/.pnpm/get-port@7.1.0/node_modules/get-port/index.js
|
|
@@ -1021,6 +1138,7 @@ function portNumbers(from, to) {
|
|
|
1021
1138
|
}
|
|
1022
1139
|
|
|
1023
1140
|
// src/logic/actions/device.ts
|
|
1141
|
+
var { logTask } = createLoggers("apple-kit:device");
|
|
1024
1142
|
async function info(udid, iosCli2) {
|
|
1025
1143
|
logTask(`Getting device info for ${udid}`);
|
|
1026
1144
|
const result = await iosCli2.info(udid);
|
|
@@ -11052,14 +11170,14 @@ var require_form_data = __commonJS2({
|
|
|
11052
11170
|
this._error(new Error("Arrays are not supported."));
|
|
11053
11171
|
return;
|
|
11054
11172
|
}
|
|
11055
|
-
var
|
|
11173
|
+
var header = this._multiPartHeader(field, value, options);
|
|
11056
11174
|
var footer = this._multiPartFooter();
|
|
11057
|
-
append(
|
|
11175
|
+
append(header);
|
|
11058
11176
|
append(value);
|
|
11059
11177
|
append(footer);
|
|
11060
|
-
this._trackLength(
|
|
11178
|
+
this._trackLength(header, value, options);
|
|
11061
11179
|
};
|
|
11062
|
-
FormData2.prototype._trackLength = function(
|
|
11180
|
+
FormData2.prototype._trackLength = function(header, value, options) {
|
|
11063
11181
|
var valueLength = 0;
|
|
11064
11182
|
if (options.knownLength != null) {
|
|
11065
11183
|
valueLength += Number(options.knownLength);
|
|
@@ -11069,7 +11187,7 @@ var require_form_data = __commonJS2({
|
|
|
11069
11187
|
valueLength = Buffer.byteLength(value);
|
|
11070
11188
|
}
|
|
11071
11189
|
this._valueLength += valueLength;
|
|
11072
|
-
this._overheadLength += Buffer.byteLength(
|
|
11190
|
+
this._overheadLength += Buffer.byteLength(header) + FormData2.LINE_BREAK.length;
|
|
11073
11191
|
if (!value || !value.path && !(value.readable && hasOwn(value, "httpVersion")) && !(value instanceof Stream)) {
|
|
11074
11192
|
return;
|
|
11075
11193
|
}
|
|
@@ -11119,18 +11237,18 @@ var require_form_data = __commonJS2({
|
|
|
11119
11237
|
if (typeof options.header === "object") {
|
|
11120
11238
|
populate(headers, options.header);
|
|
11121
11239
|
}
|
|
11122
|
-
var
|
|
11240
|
+
var header;
|
|
11123
11241
|
for (var prop in headers) {
|
|
11124
11242
|
if (hasOwn(headers, prop)) {
|
|
11125
|
-
|
|
11126
|
-
if (
|
|
11243
|
+
header = headers[prop];
|
|
11244
|
+
if (header == null) {
|
|
11127
11245
|
continue;
|
|
11128
11246
|
}
|
|
11129
|
-
if (!Array.isArray(
|
|
11130
|
-
|
|
11247
|
+
if (!Array.isArray(header)) {
|
|
11248
|
+
header = [header];
|
|
11131
11249
|
}
|
|
11132
|
-
if (
|
|
11133
|
-
contents += prop + ": " +
|
|
11250
|
+
if (header.length) {
|
|
11251
|
+
contents += prop + ": " + header.join("; ") + FormData2.LINE_BREAK;
|
|
11134
11252
|
}
|
|
11135
11253
|
}
|
|
11136
11254
|
}
|
|
@@ -11182,13 +11300,13 @@ var require_form_data = __commonJS2({
|
|
|
11182
11300
|
return "--" + this.getBoundary() + "--" + FormData2.LINE_BREAK;
|
|
11183
11301
|
};
|
|
11184
11302
|
FormData2.prototype.getHeaders = function(userHeaders) {
|
|
11185
|
-
var
|
|
11303
|
+
var header;
|
|
11186
11304
|
var formHeaders = {
|
|
11187
11305
|
"content-type": "multipart/form-data; boundary=" + this.getBoundary()
|
|
11188
11306
|
};
|
|
11189
|
-
for (
|
|
11190
|
-
if (hasOwn(userHeaders,
|
|
11191
|
-
formHeaders[
|
|
11307
|
+
for (header in userHeaders) {
|
|
11308
|
+
if (hasOwn(userHeaders, header)) {
|
|
11309
|
+
formHeaders[header.toLowerCase()] = userHeaders[header];
|
|
11192
11310
|
}
|
|
11193
11311
|
}
|
|
11194
11312
|
return formHeaders;
|
|
@@ -36364,55 +36482,172 @@ var require_src2 = __commonJS22({
|
|
|
36364
36482
|
}
|
|
36365
36483
|
});
|
|
36366
36484
|
var import_debug2 = __toESM22(require_src2());
|
|
36367
|
-
|
|
36368
|
-
|
|
36369
|
-
|
|
36370
|
-
|
|
36371
|
-
|
|
36372
|
-
|
|
36373
|
-
|
|
36374
|
-
|
|
36375
|
-
|
|
36376
|
-
|
|
36377
|
-
|
|
36378
|
-
|
|
36379
|
-
|
|
36380
|
-
|
|
36381
|
-
|
|
36382
|
-
|
|
36383
|
-
|
|
36384
|
-
|
|
36385
|
-
|
|
36386
|
-
|
|
36387
|
-
|
|
36388
|
-
}
|
|
36389
|
-
|
|
36390
|
-
|
|
36391
|
-
|
|
36392
|
-
|
|
36393
|
-
|
|
36394
|
-
|
|
36395
|
-
|
|
36396
|
-
|
|
36397
|
-
|
|
36398
|
-
|
|
36399
|
-
|
|
36400
|
-
|
|
36401
|
-
|
|
36402
|
-
|
|
36403
|
-
|
|
36404
|
-
|
|
36405
|
-
|
|
36406
|
-
|
|
36407
|
-
|
|
36408
|
-
|
|
36409
|
-
|
|
36410
|
-
|
|
36411
|
-
|
|
36412
|
-
|
|
36413
|
-
|
|
36414
|
-
|
|
36485
|
+
function createLoggers2(namespace, logLevel = process.env.LOG_LEVEL ?? "none") {
|
|
36486
|
+
const logInfo22 = (0, import_debug2.default)(`${namespace}:info`);
|
|
36487
|
+
const logTask6 = (0, import_debug2.default)(`${namespace}:task`);
|
|
36488
|
+
const logError22 = (0, import_debug2.default)(`${namespace}:error`);
|
|
36489
|
+
const logDetail2 = (0, import_debug2.default)(`${namespace}:detail`);
|
|
36490
|
+
const logDebug = (0, import_debug2.default)(`${namespace}:debug`);
|
|
36491
|
+
const logWarning2 = (0, import_debug2.default)(`${namespace}:warning`);
|
|
36492
|
+
const logColor = (0, import_debug2.default)(`${namespace}:color`);
|
|
36493
|
+
logInfo22.color = "19";
|
|
36494
|
+
logTask6.color = "25";
|
|
36495
|
+
logError22.color = "1";
|
|
36496
|
+
logDetail2.color = "199";
|
|
36497
|
+
logWarning2.color = "186";
|
|
36498
|
+
logDebug.color = "211";
|
|
36499
|
+
logColor.enabled = true;
|
|
36500
|
+
function setNamespace2(namespace2) {
|
|
36501
|
+
logInfo22.namespace = `${namespace2}:info`;
|
|
36502
|
+
logTask6.namespace = `${namespace2}:task`;
|
|
36503
|
+
logError22.namespace = `${namespace2}:error`;
|
|
36504
|
+
logDetail2.namespace = `${namespace2}:detail`;
|
|
36505
|
+
logWarning2.namespace = `${namespace2}:warning`;
|
|
36506
|
+
logDebug.namespace = `${namespace2}:debug`;
|
|
36507
|
+
}
|
|
36508
|
+
function setLogLevel(level) {
|
|
36509
|
+
switch (level) {
|
|
36510
|
+
case "info":
|
|
36511
|
+
logInfo22.enabled = true;
|
|
36512
|
+
logTask6.enabled = true;
|
|
36513
|
+
logError22.enabled = true;
|
|
36514
|
+
logWarning2.enabled = true;
|
|
36515
|
+
logDetail2.enabled = false;
|
|
36516
|
+
logDebug.enabled = false;
|
|
36517
|
+
break;
|
|
36518
|
+
case "debug":
|
|
36519
|
+
logInfo22.enabled = true;
|
|
36520
|
+
logTask6.enabled = true;
|
|
36521
|
+
logError22.enabled = true;
|
|
36522
|
+
logWarning2.enabled = true;
|
|
36523
|
+
logDetail2.enabled = true;
|
|
36524
|
+
logDebug.enabled = true;
|
|
36525
|
+
break;
|
|
36526
|
+
case "none":
|
|
36527
|
+
logInfo22.enabled = false;
|
|
36528
|
+
logTask6.enabled = false;
|
|
36529
|
+
logError22.enabled = false;
|
|
36530
|
+
logWarning2.enabled = false;
|
|
36531
|
+
logDetail2.enabled = false;
|
|
36532
|
+
logDebug.enabled = false;
|
|
36533
|
+
break;
|
|
36534
|
+
}
|
|
36535
|
+
}
|
|
36536
|
+
setLogLevel(logLevel);
|
|
36537
|
+
function setColors(type, color) {
|
|
36538
|
+
switch (type) {
|
|
36539
|
+
case "info":
|
|
36540
|
+
logInfo22.color = color;
|
|
36541
|
+
break;
|
|
36542
|
+
case "task":
|
|
36543
|
+
logTask6.color = color;
|
|
36544
|
+
break;
|
|
36545
|
+
case "error":
|
|
36546
|
+
logError22.color = color;
|
|
36547
|
+
break;
|
|
36548
|
+
case "detail":
|
|
36549
|
+
logDetail2.color = color;
|
|
36550
|
+
break;
|
|
36551
|
+
case "warning":
|
|
36552
|
+
logWarning2.color = color;
|
|
36553
|
+
break;
|
|
36554
|
+
case "debug":
|
|
36555
|
+
logDebug.color = color;
|
|
36556
|
+
break;
|
|
36557
|
+
default:
|
|
36558
|
+
throw new Error(`Invalid log type: ${type}`);
|
|
36559
|
+
}
|
|
36560
|
+
}
|
|
36561
|
+
function printColors() {
|
|
36562
|
+
for (let i = 0; i < 256; i++) {
|
|
36563
|
+
logColor.color = `${i}`;
|
|
36564
|
+
logColor(`${i}: ${i}`);
|
|
36565
|
+
}
|
|
36566
|
+
}
|
|
36567
|
+
function logDataDetail(data, prefix = "# ") {
|
|
36568
|
+
if (data === null || data === void 0) {
|
|
36569
|
+
return `${prefix}<null or undefined>`;
|
|
36570
|
+
}
|
|
36571
|
+
if (typeof data !== "object") {
|
|
36572
|
+
return `${prefix}${String(data)}`;
|
|
36573
|
+
}
|
|
36574
|
+
const keys = Object.keys(data);
|
|
36575
|
+
let result = "";
|
|
36576
|
+
for (const key of keys) {
|
|
36577
|
+
result += `${prefix}${key}: `;
|
|
36578
|
+
if (key in data) {
|
|
36579
|
+
let dataKey = key;
|
|
36580
|
+
if (key in data) {
|
|
36581
|
+
dataKey = key;
|
|
36582
|
+
const value = data[dataKey];
|
|
36583
|
+
if (value === null || value === void 0) {
|
|
36584
|
+
result += `<${value === null ? "null" : "undefined"}>
|
|
36585
|
+
`;
|
|
36586
|
+
} else if (typeof value === "object") {
|
|
36587
|
+
result += `
|
|
36588
|
+
${logDataDetail(value, `${prefix} `)}
|
|
36589
|
+
`;
|
|
36590
|
+
} else {
|
|
36591
|
+
result += `${value}
|
|
36592
|
+
`;
|
|
36593
|
+
}
|
|
36594
|
+
}
|
|
36595
|
+
}
|
|
36596
|
+
}
|
|
36597
|
+
return result.trim();
|
|
36598
|
+
}
|
|
36599
|
+
function header(title, padding = 0) {
|
|
36600
|
+
return `${" ".repeat(padding)}${"=".repeat(80)}
|
|
36601
|
+
${" ".repeat(40 - title.length / 2)}${title}
|
|
36602
|
+
${" ".repeat(padding)}${"=".repeat(80)}`;
|
|
36603
|
+
}
|
|
36604
|
+
function logHeader(title) {
|
|
36605
|
+
logInfo22(`${header(title, 2)}`);
|
|
36415
36606
|
}
|
|
36607
|
+
function logDataObject2(title, ...args) {
|
|
36608
|
+
const stack = new Error().stack?.split("\n")[2] || "";
|
|
36609
|
+
const stackMatch = stack.match(/\((.*):(\d+):(\d+)\)$/) || stack.match(/at (.*):(\d+):(\d+)$/);
|
|
36610
|
+
let callerDetails = "";
|
|
36611
|
+
if (stackMatch) {
|
|
36612
|
+
const functionMatch = stack.match(/at (.+) \(/);
|
|
36613
|
+
const functionName = functionMatch ? functionMatch[1] : "<anonymous>";
|
|
36614
|
+
callerDetails = `${functionName}`;
|
|
36615
|
+
}
|
|
36616
|
+
logDetail2(`${header(`*${title}* ${callerDetails}`)}
|
|
36617
|
+
${args.reduce((acc, arg) => `${acc}
|
|
36618
|
+
${logDataDetail(arg)}`, "")}
|
|
36619
|
+
|
|
36620
|
+
${"=".repeat(80)}`);
|
|
36621
|
+
}
|
|
36622
|
+
function logErrorObject(error, extraDetails) {
|
|
36623
|
+
if (error instanceof Error) {
|
|
36624
|
+
logError22(`${extraDetails ? header(extraDetails, 1) : header(error.message, 1)}
|
|
36625
|
+
Error Message:
|
|
36626
|
+
${error.message}
|
|
36627
|
+
Error Stack:
|
|
36628
|
+
${error.stack}
|
|
36629
|
+
${"=".repeat(80)}`);
|
|
36630
|
+
} else {
|
|
36631
|
+
logError22(`${extraDetails ? header(extraDetails, 1) : header(String(error), 1)}
|
|
36632
|
+
${"=".repeat(80)}`);
|
|
36633
|
+
}
|
|
36634
|
+
}
|
|
36635
|
+
return {
|
|
36636
|
+
logInfo: logInfo22,
|
|
36637
|
+
logTask: logTask6,
|
|
36638
|
+
logError: logError22,
|
|
36639
|
+
logDetail: logDetail2,
|
|
36640
|
+
logDebug,
|
|
36641
|
+
logWarning: logWarning2,
|
|
36642
|
+
logColor,
|
|
36643
|
+
setColors,
|
|
36644
|
+
printColors,
|
|
36645
|
+
logHeader,
|
|
36646
|
+
logDataObject: logDataObject2,
|
|
36647
|
+
logErrorObject,
|
|
36648
|
+
setLogLevel,
|
|
36649
|
+
setNamespace: setNamespace2
|
|
36650
|
+
};
|
|
36416
36651
|
}
|
|
36417
36652
|
var AUTHORIZE_QUERY = `
|
|
36418
36653
|
query Authorize($input: AuthorizeInput!) {
|
|
@@ -36431,8 +36666,7 @@ var TOKEN_QUERY = `
|
|
|
36431
36666
|
}
|
|
36432
36667
|
}
|
|
36433
36668
|
`;
|
|
36434
|
-
|
|
36435
|
-
logNamespace2("auth");
|
|
36669
|
+
var { logInfo } = createLoggers2("auth");
|
|
36436
36670
|
var random = promisify(randomBytes);
|
|
36437
36671
|
async function getAuthToken(credentials, apiUrl) {
|
|
36438
36672
|
const authApiUrl = apiUrl || process.env.AUTH_API_URL;
|
|
@@ -36441,7 +36675,7 @@ async function getAuthToken(credentials, apiUrl) {
|
|
|
36441
36675
|
}
|
|
36442
36676
|
const { clientDecorator, variantConfigurationKey } = credentials;
|
|
36443
36677
|
const frameworkId = credentials.frameworkId || `apple-kit-${Date.now()}`;
|
|
36444
|
-
|
|
36678
|
+
logInfo(`Getting auth token for identifiers: ${variantConfigurationKey}`);
|
|
36445
36679
|
const randomSecret = (await random(8)).toString("hex");
|
|
36446
36680
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
36447
36681
|
const hash = createHash("sha256");
|
|
@@ -36512,7 +36746,7 @@ async function getAuthToken(credentials, apiUrl) {
|
|
|
36512
36746
|
}
|
|
36513
36747
|
async function readCredentialsFromFile(filePath) {
|
|
36514
36748
|
const fs = await import("node:fs/promises");
|
|
36515
|
-
|
|
36749
|
+
logInfo(`Reading credentials from: ${filePath}`);
|
|
36516
36750
|
const content = await fs.readFile(filePath, "utf-8");
|
|
36517
36751
|
const credentials = JSON.parse(content);
|
|
36518
36752
|
if (!credentials.clientDecorator || !credentials.variantConfigurationKey) {
|
|
@@ -37345,113 +37579,177 @@ var require_src22 = __commonJS3({
|
|
|
37345
37579
|
}
|
|
37346
37580
|
});
|
|
37347
37581
|
var import_debug22 = __toESM3(require_src22());
|
|
37348
|
-
|
|
37349
|
-
|
|
37350
|
-
|
|
37351
|
-
|
|
37352
|
-
|
|
37353
|
-
|
|
37354
|
-
|
|
37355
|
-
|
|
37356
|
-
|
|
37357
|
-
|
|
37358
|
-
|
|
37359
|
-
|
|
37360
|
-
|
|
37361
|
-
|
|
37362
|
-
|
|
37363
|
-
|
|
37364
|
-
|
|
37365
|
-
|
|
37366
|
-
|
|
37367
|
-
|
|
37368
|
-
|
|
37369
|
-
}
|
|
37370
|
-
|
|
37371
|
-
|
|
37372
|
-
|
|
37373
|
-
|
|
37374
|
-
|
|
37375
|
-
|
|
37376
|
-
|
|
37377
|
-
|
|
37378
|
-
|
|
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
|
-
|
|
37582
|
+
function createLoggers22(namespace, logLevel = process.env.LOG_LEVEL ?? "none") {
|
|
37583
|
+
const logInfo32 = (0, import_debug22.default)(`${namespace}:info`);
|
|
37584
|
+
const logTask6 = (0, import_debug22.default)(`${namespace}:task`);
|
|
37585
|
+
const logError22 = (0, import_debug22.default)(`${namespace}:error`);
|
|
37586
|
+
const logDetail2 = (0, import_debug22.default)(`${namespace}:detail`);
|
|
37587
|
+
const logDebug = (0, import_debug22.default)(`${namespace}:debug`);
|
|
37588
|
+
const logWarning2 = (0, import_debug22.default)(`${namespace}:warning`);
|
|
37589
|
+
const logColor = (0, import_debug22.default)(`${namespace}:color`);
|
|
37590
|
+
logInfo32.color = "19";
|
|
37591
|
+
logTask6.color = "25";
|
|
37592
|
+
logError22.color = "1";
|
|
37593
|
+
logDetail2.color = "199";
|
|
37594
|
+
logWarning2.color = "186";
|
|
37595
|
+
logDebug.color = "211";
|
|
37596
|
+
logColor.enabled = true;
|
|
37597
|
+
function setNamespace2(namespace2) {
|
|
37598
|
+
logInfo32.namespace = `${namespace2}:info`;
|
|
37599
|
+
logTask6.namespace = `${namespace2}:task`;
|
|
37600
|
+
logError22.namespace = `${namespace2}:error`;
|
|
37601
|
+
logDetail2.namespace = `${namespace2}:detail`;
|
|
37602
|
+
logWarning2.namespace = `${namespace2}:warning`;
|
|
37603
|
+
logDebug.namespace = `${namespace2}:debug`;
|
|
37604
|
+
}
|
|
37605
|
+
function setLogLevel(level) {
|
|
37606
|
+
switch (level) {
|
|
37607
|
+
case "info":
|
|
37608
|
+
logInfo32.enabled = true;
|
|
37609
|
+
logTask6.enabled = true;
|
|
37610
|
+
logError22.enabled = true;
|
|
37611
|
+
logWarning2.enabled = true;
|
|
37612
|
+
logDetail2.enabled = false;
|
|
37613
|
+
logDebug.enabled = false;
|
|
37614
|
+
break;
|
|
37615
|
+
case "debug":
|
|
37616
|
+
logInfo32.enabled = true;
|
|
37617
|
+
logTask6.enabled = true;
|
|
37618
|
+
logError22.enabled = true;
|
|
37619
|
+
logWarning2.enabled = true;
|
|
37620
|
+
logDetail2.enabled = true;
|
|
37621
|
+
logDebug.enabled = true;
|
|
37622
|
+
break;
|
|
37623
|
+
case "none":
|
|
37624
|
+
logInfo32.enabled = false;
|
|
37625
|
+
logTask6.enabled = false;
|
|
37626
|
+
logError22.enabled = false;
|
|
37627
|
+
logWarning2.enabled = false;
|
|
37628
|
+
logDetail2.enabled = false;
|
|
37629
|
+
logDebug.enabled = false;
|
|
37630
|
+
break;
|
|
37631
|
+
}
|
|
37632
|
+
}
|
|
37633
|
+
setLogLevel(logLevel);
|
|
37634
|
+
function setColors(type, color) {
|
|
37635
|
+
switch (type) {
|
|
37636
|
+
case "info":
|
|
37637
|
+
logInfo32.color = color;
|
|
37638
|
+
break;
|
|
37639
|
+
case "task":
|
|
37640
|
+
logTask6.color = color;
|
|
37641
|
+
break;
|
|
37642
|
+
case "error":
|
|
37643
|
+
logError22.color = color;
|
|
37644
|
+
break;
|
|
37645
|
+
case "detail":
|
|
37646
|
+
logDetail2.color = color;
|
|
37647
|
+
break;
|
|
37648
|
+
case "warning":
|
|
37649
|
+
logWarning2.color = color;
|
|
37650
|
+
break;
|
|
37651
|
+
case "debug":
|
|
37652
|
+
logDebug.color = color;
|
|
37653
|
+
break;
|
|
37654
|
+
default:
|
|
37655
|
+
throw new Error(`Invalid log type: ${type}`);
|
|
37656
|
+
}
|
|
37657
|
+
}
|
|
37658
|
+
function printColors() {
|
|
37659
|
+
for (let i = 0; i < 256; i++) {
|
|
37660
|
+
logColor.color = `${i}`;
|
|
37661
|
+
logColor(`${i}: ${i}`);
|
|
37662
|
+
}
|
|
37663
|
+
}
|
|
37664
|
+
function logDataDetail(data, prefix = "# ") {
|
|
37665
|
+
if (data === null || data === void 0) {
|
|
37666
|
+
return `${prefix}<null or undefined>`;
|
|
37667
|
+
}
|
|
37668
|
+
if (typeof data !== "object") {
|
|
37669
|
+
return `${prefix}${String(data)}`;
|
|
37670
|
+
}
|
|
37671
|
+
const keys = Object.keys(data);
|
|
37672
|
+
let result = "";
|
|
37673
|
+
for (const key of keys) {
|
|
37674
|
+
result += `${prefix}${key}: `;
|
|
37411
37675
|
if (key in data) {
|
|
37412
|
-
dataKey = key;
|
|
37413
|
-
|
|
37414
|
-
|
|
37415
|
-
|
|
37676
|
+
let dataKey = key;
|
|
37677
|
+
if (key in data) {
|
|
37678
|
+
dataKey = key;
|
|
37679
|
+
const value = data[dataKey];
|
|
37680
|
+
if (value === null || value === void 0) {
|
|
37681
|
+
result += `<${value === null ? "null" : "undefined"}>
|
|
37416
37682
|
`;
|
|
37417
|
-
|
|
37418
|
-
|
|
37419
|
-
${logDataDetail(value, `${prefix} `)}
|
|
37683
|
+
} else if (typeof value === "object") {
|
|
37684
|
+
result += `
|
|
37685
|
+
${logDataDetail(value, `${prefix} `)}
|
|
37420
37686
|
`;
|
|
37421
|
-
|
|
37422
|
-
|
|
37687
|
+
} else {
|
|
37688
|
+
result += `${value}
|
|
37423
37689
|
`;
|
|
37690
|
+
}
|
|
37424
37691
|
}
|
|
37425
37692
|
}
|
|
37426
37693
|
}
|
|
37694
|
+
return result.trim();
|
|
37427
37695
|
}
|
|
37428
|
-
|
|
37429
|
-
}
|
|
37430
|
-
function header(title, padding = 0) {
|
|
37431
|
-
return `${" ".repeat(padding)}${"=".repeat(80)}
|
|
37696
|
+
function header(title, padding = 0) {
|
|
37697
|
+
return `${" ".repeat(padding)}${"=".repeat(80)}
|
|
37432
37698
|
${" ".repeat(40 - title.length / 2)}${title}
|
|
37433
37699
|
${" ".repeat(padding)}${"=".repeat(80)}`;
|
|
37434
|
-
}
|
|
37435
|
-
function
|
|
37436
|
-
|
|
37437
|
-
|
|
37438
|
-
|
|
37439
|
-
|
|
37440
|
-
const
|
|
37441
|
-
|
|
37442
|
-
|
|
37443
|
-
|
|
37444
|
-
|
|
37700
|
+
}
|
|
37701
|
+
function logHeader(title) {
|
|
37702
|
+
logInfo32(`${header(title, 2)}`);
|
|
37703
|
+
}
|
|
37704
|
+
function logDataObject2(title, ...args) {
|
|
37705
|
+
const stack = new Error().stack?.split("\n")[2] || "";
|
|
37706
|
+
const stackMatch = stack.match(/\((.*):(\d+):(\d+)\)$/) || stack.match(/at (.*):(\d+):(\d+)$/);
|
|
37707
|
+
let callerDetails = "";
|
|
37708
|
+
if (stackMatch) {
|
|
37709
|
+
const functionMatch = stack.match(/at (.+) \(/);
|
|
37710
|
+
const functionName = functionMatch ? functionMatch[1] : "<anonymous>";
|
|
37711
|
+
callerDetails = `${functionName}`;
|
|
37712
|
+
}
|
|
37713
|
+
logDetail2(`${header(`*${title}* ${callerDetails}`)}
|
|
37445
37714
|
${args.reduce((acc, arg) => `${acc}
|
|
37446
37715
|
${logDataDetail(arg)}`, "")}
|
|
37447
|
-
|
|
37716
|
+
|
|
37448
37717
|
${"=".repeat(80)}`);
|
|
37718
|
+
}
|
|
37719
|
+
function logErrorObject(error, extraDetails) {
|
|
37720
|
+
if (error instanceof Error) {
|
|
37721
|
+
logError22(`${extraDetails ? header(extraDetails, 1) : header(error.message, 1)}
|
|
37722
|
+
Error Message:
|
|
37723
|
+
${error.message}
|
|
37724
|
+
Error Stack:
|
|
37725
|
+
${error.stack}
|
|
37726
|
+
${"=".repeat(80)}`);
|
|
37727
|
+
} else {
|
|
37728
|
+
logError22(`${extraDetails ? header(extraDetails, 1) : header(String(error), 1)}
|
|
37729
|
+
${"=".repeat(80)}`);
|
|
37730
|
+
}
|
|
37731
|
+
}
|
|
37732
|
+
return {
|
|
37733
|
+
logInfo: logInfo32,
|
|
37734
|
+
logTask: logTask6,
|
|
37735
|
+
logError: logError22,
|
|
37736
|
+
logDetail: logDetail2,
|
|
37737
|
+
logDebug,
|
|
37738
|
+
logWarning: logWarning2,
|
|
37739
|
+
logColor,
|
|
37740
|
+
setColors,
|
|
37741
|
+
printColors,
|
|
37742
|
+
logHeader,
|
|
37743
|
+
logDataObject: logDataObject2,
|
|
37744
|
+
logErrorObject,
|
|
37745
|
+
setLogLevel,
|
|
37746
|
+
setNamespace: setNamespace2
|
|
37747
|
+
};
|
|
37449
37748
|
}
|
|
37749
|
+
var { logInfo: logInfo2, logError, logWarning, logDataObject } = createLoggers22("mdm-client");
|
|
37450
37750
|
var MdmClient = class {
|
|
37451
37751
|
constructor(config) {
|
|
37452
37752
|
this.config = config;
|
|
37453
|
-
setLogLevel22(process.env.LOG_LEVEL ?? "none");
|
|
37454
|
-
logNamespace22("mdm-client");
|
|
37455
37753
|
logDataObject("MDM Client Config", { config });
|
|
37456
37754
|
if (!config.endpoint) {
|
|
37457
37755
|
throw new Error("MDM endpoint is required");
|
|
@@ -37472,7 +37770,7 @@ var MdmClient = class {
|
|
|
37472
37770
|
}
|
|
37473
37771
|
client;
|
|
37474
37772
|
async generateEnrollmentProfile(deviceId) {
|
|
37475
|
-
|
|
37773
|
+
logInfo2(`Generating enrollment profile for device ${deviceId}`);
|
|
37476
37774
|
const result = await this.client.request(GENERATE_ENROLLMENT_PROFILE, {
|
|
37477
37775
|
input: {
|
|
37478
37776
|
deviceId,
|
|
@@ -37482,7 +37780,7 @@ var MdmClient = class {
|
|
|
37482
37780
|
return result.generateEnrollmentProfile;
|
|
37483
37781
|
}
|
|
37484
37782
|
async waitForDeviceToEnroll(deviceId, previousOpRef) {
|
|
37485
|
-
|
|
37783
|
+
logInfo2(`Waiting for device ${deviceId} to enroll...`);
|
|
37486
37784
|
const result = await this.client.request(WAIT_FOR_DEVICE_TO_ENROLL, {
|
|
37487
37785
|
input: {
|
|
37488
37786
|
deviceId,
|
|
@@ -37492,7 +37790,7 @@ var MdmClient = class {
|
|
|
37492
37790
|
return result.waitForDeviceToEnroll;
|
|
37493
37791
|
}
|
|
37494
37792
|
async installApp(deviceId, options) {
|
|
37495
|
-
|
|
37793
|
+
logInfo2(`Installing app on device ${deviceId}`);
|
|
37496
37794
|
try {
|
|
37497
37795
|
const result = await this.client.request(INSTALL_APP, {
|
|
37498
37796
|
input: {
|
|
@@ -37510,7 +37808,7 @@ var MdmClient = class {
|
|
|
37510
37808
|
return result.installApp;
|
|
37511
37809
|
} catch (error) {
|
|
37512
37810
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
37513
|
-
|
|
37811
|
+
logError(`Failed to install app: ${errorMsg}`);
|
|
37514
37812
|
throw error;
|
|
37515
37813
|
}
|
|
37516
37814
|
}
|
|
@@ -37519,7 +37817,7 @@ async function createMDMClient() {
|
|
|
37519
37817
|
const endpoint = process.env.MDM_ENDPOINT;
|
|
37520
37818
|
const credPath = process.env.CREDENTIALS_PATH;
|
|
37521
37819
|
if (!endpoint || !credPath) {
|
|
37522
|
-
|
|
37820
|
+
logWarning("MDM endpoint or credentials path is not set");
|
|
37523
37821
|
logDataObject("Environment variables", { endpoint, credPath });
|
|
37524
37822
|
return void 0;
|
|
37525
37823
|
}
|
|
@@ -37637,8 +37935,9 @@ async function execIDevice(command, options = {}) {
|
|
|
37637
37935
|
}
|
|
37638
37936
|
|
|
37639
37937
|
// src/logic/actions/pair.ts
|
|
37938
|
+
var { logTask: logTask2, logInfo: logInfo3, logError: logError2 } = createLoggers("apple-kit:pair");
|
|
37640
37939
|
async function isPaired(udid) {
|
|
37641
|
-
|
|
37940
|
+
logTask2(`Checking pairing status for ${udid}`);
|
|
37642
37941
|
try {
|
|
37643
37942
|
const result = await runIDeviceTool("idevicepair", ["-u", udid, "validate"]);
|
|
37644
37943
|
if (!result) {
|
|
@@ -37650,38 +37949,38 @@ async function isPaired(udid) {
|
|
|
37650
37949
|
}
|
|
37651
37950
|
}
|
|
37652
37951
|
async function trustDevice(udid, timeout2 = 6e4, onWaitingForTrust) {
|
|
37653
|
-
|
|
37952
|
+
logTask2(`Trusting device ${udid}`);
|
|
37654
37953
|
if (await isPaired(udid)) {
|
|
37655
|
-
|
|
37954
|
+
logInfo3(`Device ${udid} is already trusted`);
|
|
37656
37955
|
return true;
|
|
37657
37956
|
}
|
|
37658
|
-
|
|
37957
|
+
logInfo3(`Initiating pairing for device ${udid}`);
|
|
37659
37958
|
try {
|
|
37660
37959
|
const pairResult = await pair(udid);
|
|
37661
37960
|
if (pairResult) {
|
|
37662
|
-
|
|
37961
|
+
logInfo3(`Device ${udid} paired successfully`);
|
|
37663
37962
|
return true;
|
|
37664
37963
|
}
|
|
37665
37964
|
} catch (error) {
|
|
37666
|
-
|
|
37965
|
+
logError2(`Pairing failed with ${udid}: ${error}`);
|
|
37667
37966
|
}
|
|
37668
|
-
|
|
37967
|
+
logInfo3("Please accept the trust dialog on the device...");
|
|
37669
37968
|
onWaitingForTrust?.();
|
|
37670
37969
|
try {
|
|
37671
37970
|
await waitForPairing(udid, timeout2, 1e3);
|
|
37672
|
-
|
|
37971
|
+
logInfo3(`Device ${udid} is now trusted`);
|
|
37673
37972
|
return true;
|
|
37674
37973
|
} catch {
|
|
37675
|
-
|
|
37974
|
+
logInfo3(`Timeout waiting for trust acceptance on device ${udid}`);
|
|
37676
37975
|
return false;
|
|
37677
37976
|
}
|
|
37678
37977
|
}
|
|
37679
37978
|
async function waitForPairing(udid, timeout2 = 12e4, pollInterval = 1e3) {
|
|
37680
|
-
|
|
37979
|
+
logTask2(`Waiting for pairing on device ${udid}`);
|
|
37681
37980
|
const startTime = Date.now();
|
|
37682
37981
|
while (Date.now() - startTime < timeout2) {
|
|
37683
37982
|
if (await isPaired(udid)) {
|
|
37684
|
-
|
|
37983
|
+
logInfo3(`Device ${udid} is now paired`);
|
|
37685
37984
|
return true;
|
|
37686
37985
|
}
|
|
37687
37986
|
await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
|
|
@@ -37689,7 +37988,7 @@ async function waitForPairing(udid, timeout2 = 12e4, pollInterval = 1e3) {
|
|
|
37689
37988
|
throw new Error(`Timeout waiting for device pairing after ${timeout2}ms`);
|
|
37690
37989
|
}
|
|
37691
37990
|
async function pair(udid) {
|
|
37692
|
-
|
|
37991
|
+
logTask2(`Initiating pairing for device ${udid}`);
|
|
37693
37992
|
try {
|
|
37694
37993
|
const result = await runIDeviceTool("idevicepair", ["-u", udid, "pair"]);
|
|
37695
37994
|
if (!result) {
|
|
@@ -37705,7 +38004,7 @@ async function pair(udid) {
|
|
|
37705
38004
|
}
|
|
37706
38005
|
}
|
|
37707
38006
|
async function unpair(udid) {
|
|
37708
|
-
|
|
38007
|
+
logTask2(`Un-pairing device ${udid}`);
|
|
37709
38008
|
try {
|
|
37710
38009
|
const result = await runIDeviceTool("idevicepair", ["-u", udid, "unpair"]);
|
|
37711
38010
|
if (!result) {
|
|
@@ -37718,24 +38017,25 @@ async function unpair(udid) {
|
|
|
37718
38017
|
}
|
|
37719
38018
|
|
|
37720
38019
|
// src/logic/actions/install.ts
|
|
38020
|
+
var { logTask: logTask3, logInfo: logInfo4 } = createLoggers("apple-kit:install");
|
|
37721
38021
|
async function installManagedApp(ipaPath, udid, iosCli2, options) {
|
|
37722
38022
|
const result = await iosCli2.installApp(udid, ipaPath);
|
|
37723
38023
|
const client = await createMDMClient();
|
|
37724
|
-
|
|
38024
|
+
logTask3("Installing app via MDM for management takeover");
|
|
37725
38025
|
if (client) {
|
|
37726
38026
|
await client.installApp(udid, options);
|
|
37727
38027
|
}
|
|
37728
38028
|
return result;
|
|
37729
38029
|
}
|
|
37730
38030
|
async function uninstallApp(bundleId, udid) {
|
|
37731
|
-
|
|
38031
|
+
logTask3(`Uninstalling app ${bundleId} from device ${udid}`);
|
|
37732
38032
|
if (!await isPaired(udid)) {
|
|
37733
38033
|
await waitForPairing(udid, 1e4);
|
|
37734
38034
|
}
|
|
37735
38035
|
await runIDeviceTool("ideviceinstaller", ["-u", udid, "uninstall", bundleId]);
|
|
37736
38036
|
}
|
|
37737
38037
|
async function listApps(udid) {
|
|
37738
|
-
|
|
38038
|
+
logTask3(`Listing apps on device ${udid}`);
|
|
37739
38039
|
if (!await isPaired(udid)) {
|
|
37740
38040
|
await waitForPairing(udid, 1e4);
|
|
37741
38041
|
}
|
|
@@ -37751,7 +38051,7 @@ async function listApps(udid) {
|
|
|
37751
38051
|
}
|
|
37752
38052
|
}
|
|
37753
38053
|
async function isAppInstalled(bundleId, udid) {
|
|
37754
|
-
|
|
38054
|
+
logTask3(`Checking if app ${bundleId} is installed on device ${udid}`);
|
|
37755
38055
|
const apps = await listApps(udid);
|
|
37756
38056
|
return apps.some((app) => app.bundleId === bundleId);
|
|
37757
38057
|
}
|
|
@@ -37759,9 +38059,10 @@ async function isAppInstalled(bundleId, udid) {
|
|
|
37759
38059
|
// src/logic/actions/proxy.ts
|
|
37760
38060
|
import { spawn } from "node:child_process";
|
|
37761
38061
|
import { join as join3 } from "node:path";
|
|
38062
|
+
var { logTask: logTask4, logInfo: logInfo5, logError: logError3 } = createLoggers("apple-kit:proxy");
|
|
37762
38063
|
function startPortForward(localPort, devicePort, udid, startupTimeout = 500) {
|
|
37763
38064
|
return new Promise((resolve2, reject) => {
|
|
37764
|
-
|
|
38065
|
+
logTask4(`Starting port forward ${localPort} -> ${devicePort} for device ${udid}`);
|
|
37765
38066
|
const binPath = getResourcesBinPath();
|
|
37766
38067
|
const ext = process.platform === "win32" ? ".exe" : "";
|
|
37767
38068
|
const toolPath = binPath ? join3(binPath, `iproxy${ext}`) : `iproxy${ext}`;
|
|
@@ -37772,9 +38073,9 @@ function startPortForward(localPort, devicePort, udid, startupTimeout = 500) {
|
|
|
37772
38073
|
if (binPath) {
|
|
37773
38074
|
spawnOptions.cwd = binPath;
|
|
37774
38075
|
}
|
|
37775
|
-
|
|
37776
|
-
|
|
37777
|
-
|
|
38076
|
+
logInfo5(`Spawning iproxy with path: ${toolPath}`);
|
|
38077
|
+
logInfo5(`Arguments: ${[localPort.toString(), devicePort.toString(), "-u", udid].join(" ")}`);
|
|
38078
|
+
logInfo5(`Options: ${JSON.stringify(spawnOptions)}`);
|
|
37778
38079
|
const child = spawn(
|
|
37779
38080
|
toolPath,
|
|
37780
38081
|
[localPort.toString(), devicePort.toString(), "-u", udid],
|
|
@@ -37783,10 +38084,10 @@ function startPortForward(localPort, devicePort, udid, startupTimeout = 500) {
|
|
|
37783
38084
|
let hasResolved = false;
|
|
37784
38085
|
let stderrOutput = "";
|
|
37785
38086
|
child.stdout?.on("data", (data) => {
|
|
37786
|
-
|
|
38087
|
+
logTask4(`${data.toString()}`);
|
|
37787
38088
|
});
|
|
37788
38089
|
child.stderr?.on("data", (data) => {
|
|
37789
|
-
|
|
38090
|
+
logError3(`${data.toString()}`);
|
|
37790
38091
|
const msg = data.toString();
|
|
37791
38092
|
stderrOutput += msg;
|
|
37792
38093
|
if (msg.toLowerCase().includes("error") && !hasResolved) {
|
|
@@ -37812,7 +38113,7 @@ function startPortForward(localPort, devicePort, udid, startupTimeout = 500) {
|
|
|
37812
38113
|
setTimeout(() => {
|
|
37813
38114
|
if (!hasResolved) {
|
|
37814
38115
|
hasResolved = true;
|
|
37815
|
-
|
|
38116
|
+
logTask4(`Port forward started: ${localPort} -> ${devicePort} for device ${udid}`);
|
|
37816
38117
|
resolve2({
|
|
37817
38118
|
result: {
|
|
37818
38119
|
localPort,
|
|
@@ -37826,7 +38127,7 @@ function startPortForward(localPort, devicePort, udid, startupTimeout = 500) {
|
|
|
37826
38127
|
}
|
|
37827
38128
|
function killPortForwardProcess(process3) {
|
|
37828
38129
|
if (process3 && !process3.killed) {
|
|
37829
|
-
|
|
38130
|
+
logTask4("Killing port forward process");
|
|
37830
38131
|
process3.kill();
|
|
37831
38132
|
}
|
|
37832
38133
|
}
|
|
@@ -37927,6 +38228,7 @@ function escapeXml(str) {
|
|
|
37927
38228
|
}
|
|
37928
38229
|
|
|
37929
38230
|
// src/utils/wifiProfile.ts
|
|
38231
|
+
var { logInfo: logInfo6 } = createLoggers("apple-kit:wifi-profile");
|
|
37930
38232
|
async function generateWifiProfile(config, options) {
|
|
37931
38233
|
const {
|
|
37932
38234
|
ssid,
|
|
@@ -37945,7 +38247,7 @@ async function generateWifiProfile(config, options) {
|
|
|
37945
38247
|
const payloadUuid = randomUUID().toUpperCase();
|
|
37946
38248
|
const profileId = `com.mce.wifi.${ssid.replace(/[^a-zA-Z0-9]/g, "")}.${Date.now()}`;
|
|
37947
38249
|
const payloadId = `${profileId}.payload`;
|
|
37948
|
-
|
|
38250
|
+
logInfo6(`Generating WiFi profile for SSID: ${ssid}, encryption: ${encryptionType}`);
|
|
37949
38251
|
const templateName = enterprise ? "wifi-enterprise.xml" : "wifi-standard.xml";
|
|
37950
38252
|
const template = await loadTemplate(templateName, options?.plistDir);
|
|
37951
38253
|
const variables = {
|
|
@@ -37984,7 +38286,7 @@ async function generateWifiProfile(config, options) {
|
|
|
37984
38286
|
async function generateWifiProfileFromEnv(options) {
|
|
37985
38287
|
const ssid = process.env.WIFI_SSID;
|
|
37986
38288
|
if (!ssid) {
|
|
37987
|
-
|
|
38289
|
+
logInfo6("WIFI_SSID not set, skipping WiFi profile generation");
|
|
37988
38290
|
return null;
|
|
37989
38291
|
}
|
|
37990
38292
|
const config = {
|
|
@@ -37996,7 +38298,7 @@ async function generateWifiProfileFromEnv(options) {
|
|
|
37996
38298
|
username: process.env.WIFI_USERNAME,
|
|
37997
38299
|
eapType: parseWifiEapType(process.env.WIFI_EAP_TYPE)
|
|
37998
38300
|
};
|
|
37999
|
-
|
|
38301
|
+
logInfo6(`Generating WiFi profile from env: SSID=${ssid}, enterprise=${config.enterprise}`);
|
|
38000
38302
|
return generateWifiProfile(config, options);
|
|
38001
38303
|
}
|
|
38002
38304
|
async function saveWifiProfileToTemp(profile) {
|
|
@@ -38007,7 +38309,7 @@ async function saveWifiProfileToTemp(profile) {
|
|
|
38007
38309
|
const fileName = `mce_wifi_${Date.now()}.mobileconfig`;
|
|
38008
38310
|
const filePath = path.join(tempDir, fileName);
|
|
38009
38311
|
await fs.writeFile(filePath, profile, "utf-8");
|
|
38010
|
-
|
|
38312
|
+
logInfo6(`WiFi profile saved to: ${filePath}`);
|
|
38011
38313
|
return filePath;
|
|
38012
38314
|
}
|
|
38013
38315
|
function getEapTypeNumber(eapType) {
|
|
@@ -38053,6 +38355,7 @@ function parseWifiEapType(value) {
|
|
|
38053
38355
|
// src/logic/activationFlow.ts
|
|
38054
38356
|
var DEFAULT_RETRIES = 150;
|
|
38055
38357
|
var DEFAULT_RETRY_DELAY_MS = 1e3;
|
|
38358
|
+
var { logTask: logTask5, logInfo: logInfo7, logError: logError4 } = createLoggers("apple-kit:activation");
|
|
38056
38359
|
var ActivationFlow = class {
|
|
38057
38360
|
iosCli;
|
|
38058
38361
|
mdmClient;
|
|
@@ -38061,7 +38364,7 @@ var ActivationFlow = class {
|
|
|
38061
38364
|
}
|
|
38062
38365
|
async run(udid, steps) {
|
|
38063
38366
|
this.mdmClient = await createMDMClient();
|
|
38064
|
-
|
|
38367
|
+
logTask5(`Starting activation flow for device ${udid}`);
|
|
38065
38368
|
await this.retryActivateCommand("activate device", () => this.iosCli.activate(udid));
|
|
38066
38369
|
const wifiProfileIdentifier = await this.installWifiProfile(udid);
|
|
38067
38370
|
await this.installMdmProfile(udid);
|
|
@@ -38083,7 +38386,7 @@ var ActivationFlow = class {
|
|
|
38083
38386
|
return wifiProfileIdentifier;
|
|
38084
38387
|
}
|
|
38085
38388
|
async installMdmProfile(udid) {
|
|
38086
|
-
|
|
38389
|
+
logTask5("Installing MDM enrollment profile");
|
|
38087
38390
|
const enrollmentProfile = await this.retry(
|
|
38088
38391
|
"generate mdm enrollment profile",
|
|
38089
38392
|
() => {
|
|
@@ -38108,7 +38411,7 @@ var ActivationFlow = class {
|
|
|
38108
38411
|
if (!profileIdentifier) {
|
|
38109
38412
|
return;
|
|
38110
38413
|
}
|
|
38111
|
-
|
|
38414
|
+
logTask5("Removing WiFi profile");
|
|
38112
38415
|
await this.retryIosCommand(
|
|
38113
38416
|
"remove wifi profile",
|
|
38114
38417
|
() => this.iosCli.removeProfile(udid, profileIdentifier)
|
|
@@ -38129,9 +38432,9 @@ var ActivationFlow = class {
|
|
|
38129
38432
|
}
|
|
38130
38433
|
} catch (error) {
|
|
38131
38434
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
38132
|
-
|
|
38435
|
+
logError4(`${label} failed: ${errorMsg}`);
|
|
38133
38436
|
}
|
|
38134
|
-
|
|
38437
|
+
logInfo7(`Retrying ${label}... ${attempt + 1} of ${retries}`);
|
|
38135
38438
|
await new Promise((resolve2) => setTimeout(resolve2, retryDelayMs));
|
|
38136
38439
|
}
|
|
38137
38440
|
throw new Error(`Failed to ${label} after ${retries} attempts`);
|
|
@@ -38140,16 +38443,16 @@ var ActivationFlow = class {
|
|
|
38140
38443
|
async function saveProfileToTemp(profile, prefix) {
|
|
38141
38444
|
const tempFilePath = join5(tmpdir(), `mce_${prefix}_${Date.now()}.mobileconfig`);
|
|
38142
38445
|
await writeFile(tempFilePath, profile, "utf-8");
|
|
38143
|
-
|
|
38446
|
+
logInfo7(`Profile saved to: ${tempFilePath}`);
|
|
38144
38447
|
return tempFilePath;
|
|
38145
38448
|
}
|
|
38146
38449
|
async function removeTempFile(filePath, label) {
|
|
38147
38450
|
try {
|
|
38148
38451
|
await unlink(filePath);
|
|
38149
|
-
|
|
38452
|
+
logInfo7(`Removed ${label} temp file: ${filePath}`);
|
|
38150
38453
|
} catch (error) {
|
|
38151
38454
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
38152
|
-
|
|
38455
|
+
logError4(`Failed to remove ${label} temp file: ${errorMsg}`);
|
|
38153
38456
|
}
|
|
38154
38457
|
}
|
|
38155
38458
|
function getProfileIdentifierFromProfile(profile) {
|
|
@@ -38184,6 +38487,7 @@ function isActivationSuccess(result) {
|
|
|
38184
38487
|
// src/logic/iosCli.ts
|
|
38185
38488
|
import { spawn as spawn2 } from "node:child_process";
|
|
38186
38489
|
import { join as join6 } from "node:path";
|
|
38490
|
+
var { logDetail } = createLoggers("apple-kit:ios-cli");
|
|
38187
38491
|
var ios;
|
|
38188
38492
|
function iosCli() {
|
|
38189
38493
|
const iosBinaryPath = resolveIosBinaryPath();
|
|
@@ -38331,6 +38635,44 @@ function parseProfileListOutput(output) {
|
|
|
38331
38635
|
}
|
|
38332
38636
|
return profiles;
|
|
38333
38637
|
}
|
|
38638
|
+
function parseFsyncTreeStdout(stdout) {
|
|
38639
|
+
return stdout.split(/\r?\n/).map((line) => line.trim()).filter((line) => line.length > 0).map((line) => line.replace(/^\|\s*\|-\s*/, "").replace(/^\|-\s*/, "")).filter((name) => name.length > 0);
|
|
38640
|
+
}
|
|
38641
|
+
function runIosCommandWithRawStdout(iosBinaryPath, args) {
|
|
38642
|
+
return new Promise((resolve2, reject) => {
|
|
38643
|
+
logDetail(`Running command: ${iosBinaryPath} ${args.join(" ")}`);
|
|
38644
|
+
const child = spawn2(iosBinaryPath, args, {
|
|
38645
|
+
windowsHide: true,
|
|
38646
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
38647
|
+
});
|
|
38648
|
+
let stdout = "";
|
|
38649
|
+
let stderr = "";
|
|
38650
|
+
child.stdout?.on("data", (data) => {
|
|
38651
|
+
stdout += data.toString();
|
|
38652
|
+
});
|
|
38653
|
+
child.stderr?.on("data", (data) => {
|
|
38654
|
+
stderr += data.toString();
|
|
38655
|
+
});
|
|
38656
|
+
child.on("error", (error) => {
|
|
38657
|
+
reject(error);
|
|
38658
|
+
});
|
|
38659
|
+
child.on("close", (code) => {
|
|
38660
|
+
const logMessages = stderr.split("\n").map((line) => line.trim()).filter((line) => line.length > 0).map((line) => safeParseJson(line)).filter((item) => Boolean(item)).map((lineJson) => ({
|
|
38661
|
+
level: lineJson.level,
|
|
38662
|
+
msg: lineJson.msg,
|
|
38663
|
+
timestamp: lineJson.timestamp
|
|
38664
|
+
}));
|
|
38665
|
+
const raw = {
|
|
38666
|
+
command: iosBinaryPath,
|
|
38667
|
+
args,
|
|
38668
|
+
output: [],
|
|
38669
|
+
logMessages,
|
|
38670
|
+
exitCode: code ?? 0
|
|
38671
|
+
};
|
|
38672
|
+
resolve2({ stdout, stderr, exitCode: code ?? 0, raw });
|
|
38673
|
+
});
|
|
38674
|
+
});
|
|
38675
|
+
}
|
|
38334
38676
|
function createIosCli(iosBinaryPath) {
|
|
38335
38677
|
return {
|
|
38336
38678
|
async listDevices() {
|
|
@@ -38393,18 +38735,97 @@ function createIosCli(iosBinaryPath) {
|
|
|
38393
38735
|
},
|
|
38394
38736
|
async installApp(deviceId, ipaPath) {
|
|
38395
38737
|
return runIosCommand(iosBinaryPath, ["install", `--path=${ipaPath}`, "--udid", deviceId]);
|
|
38738
|
+
},
|
|
38739
|
+
async tunnelStart(deviceId, userspace = false) {
|
|
38740
|
+
const args = ["tunnel", "start", "--udid", deviceId, ...userspace ? ["--userspace"] : []];
|
|
38741
|
+
logDetail(`Spawning tunnel: ${iosBinaryPath} ${args.join(" ")}`);
|
|
38742
|
+
const child = spawn2(iosBinaryPath, args, {
|
|
38743
|
+
windowsHide: true,
|
|
38744
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
38745
|
+
});
|
|
38746
|
+
return new Promise((resolve2, reject) => {
|
|
38747
|
+
let settled = false;
|
|
38748
|
+
const cleanup = () => {
|
|
38749
|
+
child.off("error", onError);
|
|
38750
|
+
child.off("exit", onExit);
|
|
38751
|
+
child.stdout?.off("data", onReadyCheck);
|
|
38752
|
+
child.stderr?.off("data", onReadyCheck);
|
|
38753
|
+
clearTimeout(readyTimeout);
|
|
38754
|
+
};
|
|
38755
|
+
const finish = (result) => {
|
|
38756
|
+
if (settled) return;
|
|
38757
|
+
settled = true;
|
|
38758
|
+
cleanup();
|
|
38759
|
+
if (result.reject) reject(result.reject);
|
|
38760
|
+
else if (result.resolve !== void 0) resolve2(result.resolve);
|
|
38761
|
+
};
|
|
38762
|
+
const onError = (err) => finish({ reject: err });
|
|
38763
|
+
const onExit = (code) => finish({ reject: new Error(`Tunnel exited early (code=${code})`) });
|
|
38764
|
+
const onReadyCheck = (data) => {
|
|
38765
|
+
const line = data.toString();
|
|
38766
|
+
const isReady = line.includes("Tunnel server started") || line.includes("tunnel") && (line.includes("listening") || line.includes("connected"));
|
|
38767
|
+
if (isReady) finish({ resolve: child });
|
|
38768
|
+
};
|
|
38769
|
+
const readyTimeout = setTimeout(() => finish({ resolve: child }), 1e4);
|
|
38770
|
+
child.once("error", onError);
|
|
38771
|
+
child.once("exit", onExit);
|
|
38772
|
+
child.stdout?.on("data", onReadyCheck);
|
|
38773
|
+
child.stderr?.on("data", onReadyCheck);
|
|
38774
|
+
});
|
|
38775
|
+
},
|
|
38776
|
+
async fsyncPull(deviceId, app, srcPath, dstPath) {
|
|
38777
|
+
return runIosCommand(iosBinaryPath, [
|
|
38778
|
+
"fsync",
|
|
38779
|
+
"--app",
|
|
38780
|
+
app,
|
|
38781
|
+
"pull",
|
|
38782
|
+
"--srcPath",
|
|
38783
|
+
srcPath,
|
|
38784
|
+
"--dstPath",
|
|
38785
|
+
dstPath,
|
|
38786
|
+
"--udid",
|
|
38787
|
+
deviceId
|
|
38788
|
+
]);
|
|
38789
|
+
},
|
|
38790
|
+
async fsyncPush(deviceId, app, srcPath, dstPath) {
|
|
38791
|
+
return runIosCommand(iosBinaryPath, [
|
|
38792
|
+
"fsync",
|
|
38793
|
+
"--app",
|
|
38794
|
+
app,
|
|
38795
|
+
"push",
|
|
38796
|
+
"--srcPath",
|
|
38797
|
+
srcPath,
|
|
38798
|
+
"--dstPath",
|
|
38799
|
+
dstPath,
|
|
38800
|
+
"--udid",
|
|
38801
|
+
deviceId
|
|
38802
|
+
]);
|
|
38803
|
+
},
|
|
38804
|
+
async fsyncTree(deviceId, app, path) {
|
|
38805
|
+
const args = [
|
|
38806
|
+
"fsync",
|
|
38807
|
+
"--app",
|
|
38808
|
+
app,
|
|
38809
|
+
"tree",
|
|
38810
|
+
"--udid",
|
|
38811
|
+
deviceId,
|
|
38812
|
+
...path !== void 0 && path !== "" ? ["--path", path] : []
|
|
38813
|
+
];
|
|
38814
|
+
const { stdout, raw } = await runIosCommandWithRawStdout(iosBinaryPath, args);
|
|
38815
|
+
const entries = parseFsyncTreeStdout(stdout);
|
|
38816
|
+
return { entries, raw };
|
|
38396
38817
|
}
|
|
38397
38818
|
};
|
|
38398
38819
|
}
|
|
38399
38820
|
|
|
38400
38821
|
// src/logic/appleDeviceKit.ts
|
|
38822
|
+
var { logInfo: logInfo8, setNamespace } = createLoggers("apple-kit");
|
|
38401
38823
|
var AppleDeviceKit = class {
|
|
38402
38824
|
constructor(udid, logicalPort) {
|
|
38403
38825
|
this.logicalPort = logicalPort;
|
|
38404
38826
|
this.deviceId = udid;
|
|
38405
|
-
|
|
38406
|
-
|
|
38407
|
-
logInfo(
|
|
38827
|
+
setNamespace(`apple-kit:${udid}`);
|
|
38828
|
+
logInfo8(
|
|
38408
38829
|
`AppleDeviceKit initialized for device: ${this.deviceId}, logical port: ${this.logicalPort}`
|
|
38409
38830
|
);
|
|
38410
38831
|
const iosBinaryPath = resolveIosBinaryPath();
|
|
@@ -38636,7 +39057,7 @@ var AppleDeviceKit = class {
|
|
|
38636
39057
|
if (this.isDisposed) {
|
|
38637
39058
|
return;
|
|
38638
39059
|
}
|
|
38639
|
-
|
|
39060
|
+
logInfo8(`Disposing AppleDeviceKit for device: ${this.deviceId}`);
|
|
38640
39061
|
this.closePortForward();
|
|
38641
39062
|
this.isDisposed = true;
|
|
38642
39063
|
}
|