@mcesystems/apple-kit 1.0.74 → 1.0.76
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/README.md +258 -258
- package/dist/index.js +850 -896
- package/dist/index.js.map +4 -4
- package/dist/index.mjs +847 -892
- package/dist/index.mjs.map +4 -4
- package/dist/resources/plist/certificate-trust.xml +43 -43
- package/dist/resources/plist/ddm-managed-app.xml +55 -0
- package/dist/resources/plist/wifi-enterprise.xml +59 -59
- package/dist/resources/plist/wifi-standard.xml +50 -50
- package/dist/types/graphql/queries.d.ts +9 -0
- package/dist/types/graphql/queries.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/logic/actions/activation.d.ts +12 -0
- package/dist/types/logic/actions/activation.d.ts.map +1 -0
- package/dist/types/logic/actions/appState.d.ts +2 -0
- package/dist/types/logic/actions/appState.d.ts.map +1 -0
- package/dist/types/logic/actions/device.d.ts +22 -13
- package/dist/types/logic/actions/device.d.ts.map +1 -1
- package/dist/types/logic/actions/install.d.ts +12 -7
- package/dist/types/logic/actions/install.d.ts.map +1 -1
- package/dist/types/logic/actions/proxy.d.ts +9 -21
- package/dist/types/logic/actions/proxy.d.ts.map +1 -1
- package/dist/types/logic/actions/usbmuxd.d.ts +10 -0
- package/dist/types/logic/actions/usbmuxd.d.ts.map +1 -0
- package/dist/types/logic/activationFlow.d.ts +5 -4
- package/dist/types/logic/activationFlow.d.ts.map +1 -1
- package/dist/types/logic/appleDeviceKit.d.ts +11 -10
- package/dist/types/logic/appleDeviceKit.d.ts.map +1 -1
- package/dist/types/logic/iosClient.d.ts +50 -0
- package/dist/types/logic/iosClient.d.ts.map +1 -0
- package/dist/types/logic/profileParser.d.ts +13 -0
- package/dist/types/logic/profileParser.d.ts.map +1 -0
- package/dist/types/types/auth.d.ts +13 -0
- package/dist/types/types/auth.d.ts.map +1 -0
- package/dist/types/types/install.d.ts +13 -0
- package/dist/types/types/install.d.ts.map +1 -0
- package/dist/types/types/ios.d.ts +4 -0
- package/dist/types/types/ios.d.ts.map +1 -1
- package/dist/types/types/mdm.d.ts +33 -0
- package/dist/types/types/mdm.d.ts.map +1 -0
- package/dist/types/types.d.ts +173 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/utils/authClient.d.ts +7 -0
- package/dist/types/utils/authClient.d.ts.map +1 -0
- package/dist/types/utils/ddmDeclaration.d.ts +8 -0
- package/dist/types/utils/ddmDeclaration.d.ts.map +1 -0
- package/dist/types/utils/debug.d.ts +17 -0
- package/dist/types/utils/debug.d.ts.map +1 -0
- package/dist/types/utils/installRawProfileRetry.d.ts +7 -0
- package/dist/types/utils/installRawProfileRetry.d.ts.map +1 -0
- package/dist/types/utils/mdmClient.d.ts +7 -0
- package/dist/types/utils/mdmClient.d.ts.map +1 -0
- package/dist/types/utils/trustProfile.d.ts +12 -0
- package/dist/types/utils/trustProfile.d.ts.map +1 -0
- package/package.json +7 -5
- package/resources/ios.exe +0 -0
- package/resources/wintun-LICENSE.txt +84 -0
- package/resources/wintun.dll +0 -0
- package/scripts/README.md +209 -209
- package/scripts/build-windows.sh.template +222 -222
package/dist/index.mjs
CHANGED
|
@@ -835,52 +835,52 @@ var require_src = __commonJS({
|
|
|
835
835
|
});
|
|
836
836
|
var import_debug = __toESM(require_src());
|
|
837
837
|
function createLoggers(namespace, logLevel = process.env.LOG_LEVEL ?? "none") {
|
|
838
|
-
const
|
|
839
|
-
const
|
|
840
|
-
const
|
|
841
|
-
const
|
|
838
|
+
const logInfo8 = (0, import_debug.default)(`${namespace}:info`);
|
|
839
|
+
const logTask4 = (0, import_debug.default)(`${namespace}:task`);
|
|
840
|
+
const logError4 = (0, import_debug.default)(`${namespace}:error`);
|
|
841
|
+
const logDetail3 = (0, import_debug.default)(`${namespace}:detail`);
|
|
842
842
|
const logDebug = (0, import_debug.default)(`${namespace}:debug`);
|
|
843
843
|
const logWarning2 = (0, import_debug.default)(`${namespace}:warning`);
|
|
844
844
|
const logColor = (0, import_debug.default)(`${namespace}:color`);
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
845
|
+
logInfo8.color = "19";
|
|
846
|
+
logTask4.color = "25";
|
|
847
|
+
logError4.color = "1";
|
|
848
|
+
logDetail3.color = "199";
|
|
849
849
|
logWarning2.color = "186";
|
|
850
850
|
logDebug.color = "211";
|
|
851
851
|
logColor.enabled = true;
|
|
852
|
-
function
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
852
|
+
function setNamespace7(namespace2) {
|
|
853
|
+
logInfo8.namespace = `${namespace2}:info`;
|
|
854
|
+
logTask4.namespace = `${namespace2}:task`;
|
|
855
|
+
logError4.namespace = `${namespace2}:error`;
|
|
856
|
+
logDetail3.namespace = `${namespace2}:detail`;
|
|
857
857
|
logWarning2.namespace = `${namespace2}:warning`;
|
|
858
858
|
logDebug.namespace = `${namespace2}:debug`;
|
|
859
859
|
}
|
|
860
860
|
function setLogLevel(level) {
|
|
861
861
|
switch (level) {
|
|
862
862
|
case "info":
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
863
|
+
logInfo8.enabled = true;
|
|
864
|
+
logTask4.enabled = true;
|
|
865
|
+
logError4.enabled = true;
|
|
866
866
|
logWarning2.enabled = true;
|
|
867
|
-
|
|
867
|
+
logDetail3.enabled = false;
|
|
868
868
|
logDebug.enabled = false;
|
|
869
869
|
break;
|
|
870
870
|
case "debug":
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
871
|
+
logInfo8.enabled = true;
|
|
872
|
+
logTask4.enabled = true;
|
|
873
|
+
logError4.enabled = true;
|
|
874
874
|
logWarning2.enabled = true;
|
|
875
|
-
|
|
875
|
+
logDetail3.enabled = true;
|
|
876
876
|
logDebug.enabled = true;
|
|
877
877
|
break;
|
|
878
878
|
case "none":
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
879
|
+
logInfo8.enabled = false;
|
|
880
|
+
logTask4.enabled = false;
|
|
881
|
+
logError4.enabled = false;
|
|
882
882
|
logWarning2.enabled = false;
|
|
883
|
-
|
|
883
|
+
logDetail3.enabled = false;
|
|
884
884
|
logDebug.enabled = false;
|
|
885
885
|
break;
|
|
886
886
|
}
|
|
@@ -889,16 +889,16 @@ function createLoggers(namespace, logLevel = process.env.LOG_LEVEL ?? "none") {
|
|
|
889
889
|
function setColors(type, color) {
|
|
890
890
|
switch (type) {
|
|
891
891
|
case "info":
|
|
892
|
-
|
|
892
|
+
logInfo8.color = color;
|
|
893
893
|
break;
|
|
894
894
|
case "task":
|
|
895
|
-
|
|
895
|
+
logTask4.color = color;
|
|
896
896
|
break;
|
|
897
897
|
case "error":
|
|
898
|
-
|
|
898
|
+
logError4.color = color;
|
|
899
899
|
break;
|
|
900
900
|
case "detail":
|
|
901
|
-
|
|
901
|
+
logDetail3.color = color;
|
|
902
902
|
break;
|
|
903
903
|
case "warning":
|
|
904
904
|
logWarning2.color = color;
|
|
@@ -937,7 +937,7 @@ function createLoggers(namespace, logLevel = process.env.LOG_LEVEL ?? "none") {
|
|
|
937
937
|
`;
|
|
938
938
|
} else if (typeof value === "object") {
|
|
939
939
|
result += `
|
|
940
|
-
|
|
940
|
+
${logDataDetail(value, `${prefix} `)}
|
|
941
941
|
`;
|
|
942
942
|
} else {
|
|
943
943
|
result += `${value}
|
|
@@ -954,9 +954,9 @@ ${" ".repeat(40 - title.length / 2)}${title}
|
|
|
954
954
|
${" ".repeat(padding)}${"=".repeat(80)}`;
|
|
955
955
|
}
|
|
956
956
|
function logHeader(title) {
|
|
957
|
-
|
|
957
|
+
logInfo8(`${header(title, 2)}`);
|
|
958
958
|
}
|
|
959
|
-
function
|
|
959
|
+
function logDataObject3(title, ...args) {
|
|
960
960
|
const stack = new Error().stack?.split("\n")[2] || "";
|
|
961
961
|
const stackMatch = stack.match(/\((.*):(\d+):(\d+)\)$/) || stack.match(/at (.*):(\d+):(\d+)$/);
|
|
962
962
|
let callerDetails = "";
|
|
@@ -965,7 +965,7 @@ ${" ".repeat(padding)}${"=".repeat(80)}`;
|
|
|
965
965
|
const functionName = functionMatch ? functionMatch[1] : "<anonymous>";
|
|
966
966
|
callerDetails = `${functionName}`;
|
|
967
967
|
}
|
|
968
|
-
|
|
968
|
+
logDetail3(`${header(`*${title}* ${callerDetails}`)}
|
|
969
969
|
${args.reduce((acc, arg) => `${acc}
|
|
970
970
|
${logDataDetail(arg)}`, "")}
|
|
971
971
|
|
|
@@ -973,32 +973,32 @@ ${"=".repeat(80)}`);
|
|
|
973
973
|
}
|
|
974
974
|
function logErrorObject(error, extraDetails) {
|
|
975
975
|
if (error instanceof Error) {
|
|
976
|
-
|
|
976
|
+
logError4(`${extraDetails ? header(extraDetails, 1) : header(error.message, 1)}
|
|
977
977
|
Error Message:
|
|
978
978
|
${error.message}
|
|
979
979
|
Error Stack:
|
|
980
980
|
${error.stack}
|
|
981
981
|
${"=".repeat(80)}`);
|
|
982
982
|
} else {
|
|
983
|
-
|
|
983
|
+
logError4(`${extraDetails ? header(extraDetails, 1) : header(String(error), 1)}
|
|
984
984
|
${"=".repeat(80)}`);
|
|
985
985
|
}
|
|
986
986
|
}
|
|
987
987
|
return {
|
|
988
|
-
logInfo:
|
|
989
|
-
logTask:
|
|
990
|
-
logError:
|
|
991
|
-
logDetail:
|
|
988
|
+
logInfo: logInfo8,
|
|
989
|
+
logTask: logTask4,
|
|
990
|
+
logError: logError4,
|
|
991
|
+
logDetail: logDetail3,
|
|
992
992
|
logDebug,
|
|
993
993
|
logWarning: logWarning2,
|
|
994
994
|
logColor,
|
|
995
995
|
setColors,
|
|
996
996
|
printColors,
|
|
997
997
|
logHeader,
|
|
998
|
-
logDataObject:
|
|
998
|
+
logDataObject: logDataObject3,
|
|
999
999
|
logErrorObject,
|
|
1000
1000
|
setLogLevel,
|
|
1001
|
-
setNamespace:
|
|
1001
|
+
setNamespace: setNamespace7
|
|
1002
1002
|
};
|
|
1003
1003
|
}
|
|
1004
1004
|
|
|
@@ -1138,35 +1138,125 @@ function portNumbers(from, to) {
|
|
|
1138
1138
|
}
|
|
1139
1139
|
|
|
1140
1140
|
// src/logic/actions/device.ts
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
};
|
|
1157
|
-
}
|
|
1158
|
-
async function wipeDevice(udid, iosCli2) {
|
|
1159
|
-
logTask(`Wiping device ${udid}`);
|
|
1160
|
-
await iosCli2.wipe(udid);
|
|
1161
|
-
}
|
|
1162
|
-
async function removeProfile(profileIdentifier, udid, iosCli2) {
|
|
1163
|
-
logTask(`Removing profile ${profileIdentifier} from device ${udid}`);
|
|
1164
|
-
await iosCli2.removeProfile(udid, profileIdentifier);
|
|
1165
|
-
}
|
|
1166
|
-
async function listProfiles(udid, iosCli2) {
|
|
1167
|
-
logTask(`Listing profiles for device ${udid}`);
|
|
1168
|
-
return iosCli2.listProfiles(udid);
|
|
1141
|
+
import { existsSync } from "node:fs";
|
|
1142
|
+
import { rmSync } from "node:fs";
|
|
1143
|
+
import { join } from "node:path";
|
|
1144
|
+
var { logTask, logInfo, logDetail, setNamespace, logDataObject } = createLoggers("apple-kit:device");
|
|
1145
|
+
function getAppleLockdownPath() {
|
|
1146
|
+
if (process.platform === "win32") {
|
|
1147
|
+
return join(process.env.ProgramData ?? "C:\\ProgramData", "Apple", "Lockdown");
|
|
1148
|
+
}
|
|
1149
|
+
if (process.platform === "darwin") {
|
|
1150
|
+
return "/var/db/lockdown";
|
|
1151
|
+
}
|
|
1152
|
+
if (process.platform === "linux") {
|
|
1153
|
+
return "/var/lib/lockdown";
|
|
1154
|
+
}
|
|
1155
|
+
return null;
|
|
1169
1156
|
}
|
|
1157
|
+
var DeviceActions = class {
|
|
1158
|
+
constructor(udid, iosClient) {
|
|
1159
|
+
this.udid = udid;
|
|
1160
|
+
this.iosClient = iosClient;
|
|
1161
|
+
setNamespace(`apple-${udid}`);
|
|
1162
|
+
}
|
|
1163
|
+
async info() {
|
|
1164
|
+
logInfo(`Getting device info for ${this.udid}`);
|
|
1165
|
+
const result = await this.iosClient.info();
|
|
1166
|
+
if (!result) {
|
|
1167
|
+
throw new Error("Failed to get device info");
|
|
1168
|
+
}
|
|
1169
|
+
return result.output[0];
|
|
1170
|
+
}
|
|
1171
|
+
async listDevices() {
|
|
1172
|
+
logInfo("Listing devices");
|
|
1173
|
+
return this.iosClient.listDevices();
|
|
1174
|
+
}
|
|
1175
|
+
async wipe() {
|
|
1176
|
+
logInfo(`Wiping device ${this.udid}`);
|
|
1177
|
+
await this.iosClient.wipe();
|
|
1178
|
+
}
|
|
1179
|
+
async removeProfile(profileIdentifier) {
|
|
1180
|
+
logInfo(`Removing profile ${profileIdentifier} from device ${this.udid}`);
|
|
1181
|
+
await this.iosClient.removeProfile(profileIdentifier);
|
|
1182
|
+
}
|
|
1183
|
+
async listProfiles() {
|
|
1184
|
+
logInfo(`Listing profiles for device ${this.udid}`);
|
|
1185
|
+
return this.iosClient.listProfiles();
|
|
1186
|
+
}
|
|
1187
|
+
async pair() {
|
|
1188
|
+
logInfo(`Pairing device ${this.udid}`);
|
|
1189
|
+
const result = await this.iosClient.pair();
|
|
1190
|
+
if (!result) {
|
|
1191
|
+
return false;
|
|
1192
|
+
}
|
|
1193
|
+
logDataObject("IOS pair results", { result });
|
|
1194
|
+
return result.raw.stderr.includes("Successfully paired");
|
|
1195
|
+
}
|
|
1196
|
+
async isPaired() {
|
|
1197
|
+
logInfo(`Checking if device ${this.udid} is paired`);
|
|
1198
|
+
try {
|
|
1199
|
+
const deviceInfo = await this.info();
|
|
1200
|
+
const trusted = deviceInfo.TrustedHostAttached === true;
|
|
1201
|
+
logDetail(`Device ${this.udid} TrustedHostAttached: ${trusted}`);
|
|
1202
|
+
return trusted;
|
|
1203
|
+
} catch (error) {
|
|
1204
|
+
logDetail(`Device ${this.udid} info failed (not paired or unreachable): ${error}`);
|
|
1205
|
+
return false;
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
async trustDevice({
|
|
1209
|
+
timeout: timeout2 = 6e4,
|
|
1210
|
+
onWaitingForTrust
|
|
1211
|
+
}) {
|
|
1212
|
+
logInfo(`Trusting device ${this.udid}`);
|
|
1213
|
+
if (await this.isPaired()) {
|
|
1214
|
+
logInfo(`Device ${this.udid} is already trusted (lockdown file exists)`);
|
|
1215
|
+
return true;
|
|
1216
|
+
}
|
|
1217
|
+
logInfo("Initiating pairing to show trust dialog on device...");
|
|
1218
|
+
await this.pair();
|
|
1219
|
+
logInfo("Please accept the trust dialog on the device...");
|
|
1220
|
+
onWaitingForTrust?.();
|
|
1221
|
+
try {
|
|
1222
|
+
await this.waitForPairing({ timeout: timeout2, pollInterval: 1e3 });
|
|
1223
|
+
logInfo(`Device ${this.udid} is now trusted`);
|
|
1224
|
+
return true;
|
|
1225
|
+
} catch {
|
|
1226
|
+
logInfo(`Timeout waiting for trust acceptance on device ${this.udid}`);
|
|
1227
|
+
return false;
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
async waitForPairing({
|
|
1231
|
+
timeout: timeout2 = 12e4,
|
|
1232
|
+
pollInterval = 1e3
|
|
1233
|
+
}) {
|
|
1234
|
+
logTask(`Waiting for pairing on device ${this.udid}`);
|
|
1235
|
+
const startTime = Date.now();
|
|
1236
|
+
while (Date.now() - startTime < timeout2) {
|
|
1237
|
+
if (await this.isPaired()) {
|
|
1238
|
+
logInfo(`Device ${this.udid} is now paired`);
|
|
1239
|
+
return true;
|
|
1240
|
+
}
|
|
1241
|
+
await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
|
|
1242
|
+
}
|
|
1243
|
+
throw new Error(`Timeout waiting for device pairing after ${timeout2}ms`);
|
|
1244
|
+
}
|
|
1245
|
+
async unpair() {
|
|
1246
|
+
logInfo(`Un-pairing device ${this.udid}`);
|
|
1247
|
+
const lockdownDir = getAppleLockdownPath();
|
|
1248
|
+
if (!lockdownDir) {
|
|
1249
|
+
throw new Error("Cannot determine lockdown directory for this platform");
|
|
1250
|
+
}
|
|
1251
|
+
const lockdownFile = join(lockdownDir, `${this.udid}.plist`);
|
|
1252
|
+
if (!existsSync(lockdownFile)) {
|
|
1253
|
+
logInfo(`Lockdown file ${lockdownFile} not found, device is not paired`);
|
|
1254
|
+
return false;
|
|
1255
|
+
}
|
|
1256
|
+
rmSync(lockdownFile, { force: true });
|
|
1257
|
+
return true;
|
|
1258
|
+
}
|
|
1259
|
+
};
|
|
1170
1260
|
|
|
1171
1261
|
// ../mdm-client/dist/index.mjs
|
|
1172
1262
|
import { createHash, randomBytes } from "node:crypto";
|
|
@@ -15283,16 +15373,16 @@ var require_printer = __commonJS2({
|
|
|
15283
15373
|
},
|
|
15284
15374
|
// Document
|
|
15285
15375
|
Document: {
|
|
15286
|
-
leave: (node) =>
|
|
15376
|
+
leave: (node) => join5(node.definitions, "\n\n")
|
|
15287
15377
|
},
|
|
15288
15378
|
OperationDefinition: {
|
|
15289
15379
|
leave(node) {
|
|
15290
|
-
const varDefs = hasMultilineItems(node.variableDefinitions) ? wrap("(\n",
|
|
15291
|
-
const prefix = wrap("", node.description, "\n") +
|
|
15380
|
+
const varDefs = hasMultilineItems(node.variableDefinitions) ? wrap("(\n", join5(node.variableDefinitions, "\n"), "\n)") : wrap("(", join5(node.variableDefinitions, ", "), ")");
|
|
15381
|
+
const prefix = wrap("", node.description, "\n") + join5(
|
|
15292
15382
|
[
|
|
15293
15383
|
node.operation,
|
|
15294
|
-
|
|
15295
|
-
|
|
15384
|
+
join5([node.name, varDefs]),
|
|
15385
|
+
join5(node.directives, " ")
|
|
15296
15386
|
],
|
|
15297
15387
|
" "
|
|
15298
15388
|
);
|
|
@@ -15300,7 +15390,7 @@ var require_printer = __commonJS2({
|
|
|
15300
15390
|
}
|
|
15301
15391
|
},
|
|
15302
15392
|
VariableDefinition: {
|
|
15303
|
-
leave: ({ variable, type, defaultValue, directives, description }) => wrap("", description, "\n") + variable + ": " + type + wrap(" = ", defaultValue) + wrap(" ",
|
|
15393
|
+
leave: ({ variable, type, defaultValue, directives, description }) => wrap("", description, "\n") + variable + ": " + type + wrap(" = ", defaultValue) + wrap(" ", join5(directives, " "))
|
|
15304
15394
|
},
|
|
15305
15395
|
SelectionSet: {
|
|
15306
15396
|
leave: ({ selections }) => block(selections)
|
|
@@ -15308,11 +15398,11 @@ var require_printer = __commonJS2({
|
|
|
15308
15398
|
Field: {
|
|
15309
15399
|
leave({ alias, name, arguments: args, directives, selectionSet }) {
|
|
15310
15400
|
const prefix = wrap("", alias, ": ") + name;
|
|
15311
|
-
let argsLine = prefix + wrap("(",
|
|
15401
|
+
let argsLine = prefix + wrap("(", join5(args, ", "), ")");
|
|
15312
15402
|
if (argsLine.length > MAX_LINE_LENGTH) {
|
|
15313
|
-
argsLine = prefix + wrap("(\n", indent(
|
|
15403
|
+
argsLine = prefix + wrap("(\n", indent(join5(args, "\n")), "\n)");
|
|
15314
15404
|
}
|
|
15315
|
-
return
|
|
15405
|
+
return join5([argsLine, join5(directives, " "), selectionSet], " ");
|
|
15316
15406
|
}
|
|
15317
15407
|
},
|
|
15318
15408
|
Argument: {
|
|
@@ -15320,14 +15410,14 @@ var require_printer = __commonJS2({
|
|
|
15320
15410
|
},
|
|
15321
15411
|
// Fragments
|
|
15322
15412
|
FragmentSpread: {
|
|
15323
|
-
leave: ({ name, directives }) => "..." + name + wrap(" ",
|
|
15413
|
+
leave: ({ name, directives }) => "..." + name + wrap(" ", join5(directives, " "))
|
|
15324
15414
|
},
|
|
15325
15415
|
InlineFragment: {
|
|
15326
|
-
leave: ({ typeCondition, directives, selectionSet }) =>
|
|
15416
|
+
leave: ({ typeCondition, directives, selectionSet }) => join5(
|
|
15327
15417
|
[
|
|
15328
15418
|
"...",
|
|
15329
15419
|
wrap("on ", typeCondition),
|
|
15330
|
-
|
|
15420
|
+
join5(directives, " "),
|
|
15331
15421
|
selectionSet
|
|
15332
15422
|
],
|
|
15333
15423
|
" "
|
|
@@ -15343,7 +15433,7 @@ var require_printer = __commonJS2({
|
|
|
15343
15433
|
description
|
|
15344
15434
|
}) => wrap("", description, "\n") + // Note: fragment variable definitions are experimental and may be changed
|
|
15345
15435
|
// or removed in the future.
|
|
15346
|
-
`fragment ${name}${wrap("(",
|
|
15436
|
+
`fragment ${name}${wrap("(", join5(variableDefinitions, ", "), ")")} on ${typeCondition} ${wrap("", join5(directives, " "), " ")}` + selectionSet
|
|
15347
15437
|
},
|
|
15348
15438
|
// Value
|
|
15349
15439
|
IntValue: {
|
|
@@ -15365,17 +15455,17 @@ var require_printer = __commonJS2({
|
|
|
15365
15455
|
leave: ({ value }) => value
|
|
15366
15456
|
},
|
|
15367
15457
|
ListValue: {
|
|
15368
|
-
leave: ({ values }) => "[" +
|
|
15458
|
+
leave: ({ values }) => "[" + join5(values, ", ") + "]"
|
|
15369
15459
|
},
|
|
15370
15460
|
ObjectValue: {
|
|
15371
|
-
leave: ({ fields }) => "{" +
|
|
15461
|
+
leave: ({ fields }) => "{" + join5(fields, ", ") + "}"
|
|
15372
15462
|
},
|
|
15373
15463
|
ObjectField: {
|
|
15374
15464
|
leave: ({ name, value }) => name + ": " + value
|
|
15375
15465
|
},
|
|
15376
15466
|
// Directive
|
|
15377
15467
|
Directive: {
|
|
15378
|
-
leave: ({ name, arguments: args }) => "@" + name + wrap("(",
|
|
15468
|
+
leave: ({ name, arguments: args }) => "@" + name + wrap("(", join5(args, ", "), ")")
|
|
15379
15469
|
},
|
|
15380
15470
|
// Type
|
|
15381
15471
|
NamedType: {
|
|
@@ -15389,138 +15479,138 @@ var require_printer = __commonJS2({
|
|
|
15389
15479
|
},
|
|
15390
15480
|
// Type System Definitions
|
|
15391
15481
|
SchemaDefinition: {
|
|
15392
|
-
leave: ({ description, directives, operationTypes }) => wrap("", description, "\n") +
|
|
15482
|
+
leave: ({ description, directives, operationTypes }) => wrap("", description, "\n") + join5(["schema", join5(directives, " "), block(operationTypes)], " ")
|
|
15393
15483
|
},
|
|
15394
15484
|
OperationTypeDefinition: {
|
|
15395
15485
|
leave: ({ operation, type }) => operation + ": " + type
|
|
15396
15486
|
},
|
|
15397
15487
|
ScalarTypeDefinition: {
|
|
15398
|
-
leave: ({ description, name, directives }) => wrap("", description, "\n") +
|
|
15488
|
+
leave: ({ description, name, directives }) => wrap("", description, "\n") + join5(["scalar", name, join5(directives, " ")], " ")
|
|
15399
15489
|
},
|
|
15400
15490
|
ObjectTypeDefinition: {
|
|
15401
|
-
leave: ({ description, name, interfaces, directives, fields }) => wrap("", description, "\n") +
|
|
15491
|
+
leave: ({ description, name, interfaces, directives, fields }) => wrap("", description, "\n") + join5(
|
|
15402
15492
|
[
|
|
15403
15493
|
"type",
|
|
15404
15494
|
name,
|
|
15405
|
-
wrap("implements ",
|
|
15406
|
-
|
|
15495
|
+
wrap("implements ", join5(interfaces, " & ")),
|
|
15496
|
+
join5(directives, " "),
|
|
15407
15497
|
block(fields)
|
|
15408
15498
|
],
|
|
15409
15499
|
" "
|
|
15410
15500
|
)
|
|
15411
15501
|
},
|
|
15412
15502
|
FieldDefinition: {
|
|
15413
|
-
leave: ({ description, name, arguments: args, type, directives }) => wrap("", description, "\n") + name + (hasMultilineItems(args) ? wrap("(\n", indent(
|
|
15503
|
+
leave: ({ description, name, arguments: args, type, directives }) => wrap("", description, "\n") + name + (hasMultilineItems(args) ? wrap("(\n", indent(join5(args, "\n")), "\n)") : wrap("(", join5(args, ", "), ")")) + ": " + type + wrap(" ", join5(directives, " "))
|
|
15414
15504
|
},
|
|
15415
15505
|
InputValueDefinition: {
|
|
15416
|
-
leave: ({ description, name, type, defaultValue, directives }) => wrap("", description, "\n") +
|
|
15417
|
-
[name + ": " + type, wrap("= ", defaultValue),
|
|
15506
|
+
leave: ({ description, name, type, defaultValue, directives }) => wrap("", description, "\n") + join5(
|
|
15507
|
+
[name + ": " + type, wrap("= ", defaultValue), join5(directives, " ")],
|
|
15418
15508
|
" "
|
|
15419
15509
|
)
|
|
15420
15510
|
},
|
|
15421
15511
|
InterfaceTypeDefinition: {
|
|
15422
|
-
leave: ({ description, name, interfaces, directives, fields }) => wrap("", description, "\n") +
|
|
15512
|
+
leave: ({ description, name, interfaces, directives, fields }) => wrap("", description, "\n") + join5(
|
|
15423
15513
|
[
|
|
15424
15514
|
"interface",
|
|
15425
15515
|
name,
|
|
15426
|
-
wrap("implements ",
|
|
15427
|
-
|
|
15516
|
+
wrap("implements ", join5(interfaces, " & ")),
|
|
15517
|
+
join5(directives, " "),
|
|
15428
15518
|
block(fields)
|
|
15429
15519
|
],
|
|
15430
15520
|
" "
|
|
15431
15521
|
)
|
|
15432
15522
|
},
|
|
15433
15523
|
UnionTypeDefinition: {
|
|
15434
|
-
leave: ({ description, name, directives, types }) => wrap("", description, "\n") +
|
|
15435
|
-
["union", name,
|
|
15524
|
+
leave: ({ description, name, directives, types }) => wrap("", description, "\n") + join5(
|
|
15525
|
+
["union", name, join5(directives, " "), wrap("= ", join5(types, " | "))],
|
|
15436
15526
|
" "
|
|
15437
15527
|
)
|
|
15438
15528
|
},
|
|
15439
15529
|
EnumTypeDefinition: {
|
|
15440
|
-
leave: ({ description, name, directives, values }) => wrap("", description, "\n") +
|
|
15530
|
+
leave: ({ description, name, directives, values }) => wrap("", description, "\n") + join5(["enum", name, join5(directives, " "), block(values)], " ")
|
|
15441
15531
|
},
|
|
15442
15532
|
EnumValueDefinition: {
|
|
15443
|
-
leave: ({ description, name, directives }) => wrap("", description, "\n") +
|
|
15533
|
+
leave: ({ description, name, directives }) => wrap("", description, "\n") + join5([name, join5(directives, " ")], " ")
|
|
15444
15534
|
},
|
|
15445
15535
|
InputObjectTypeDefinition: {
|
|
15446
|
-
leave: ({ description, name, directives, fields }) => wrap("", description, "\n") +
|
|
15536
|
+
leave: ({ description, name, directives, fields }) => wrap("", description, "\n") + join5(["input", name, join5(directives, " "), block(fields)], " ")
|
|
15447
15537
|
},
|
|
15448
15538
|
DirectiveDefinition: {
|
|
15449
|
-
leave: ({ description, name, arguments: args, repeatable, locations }) => wrap("", description, "\n") + "directive @" + name + (hasMultilineItems(args) ? wrap("(\n", indent(
|
|
15539
|
+
leave: ({ description, name, arguments: args, repeatable, locations }) => wrap("", description, "\n") + "directive @" + name + (hasMultilineItems(args) ? wrap("(\n", indent(join5(args, "\n")), "\n)") : wrap("(", join5(args, ", "), ")")) + (repeatable ? " repeatable" : "") + " on " + join5(locations, " | ")
|
|
15450
15540
|
},
|
|
15451
15541
|
SchemaExtension: {
|
|
15452
|
-
leave: ({ directives, operationTypes }) =>
|
|
15453
|
-
["extend schema",
|
|
15542
|
+
leave: ({ directives, operationTypes }) => join5(
|
|
15543
|
+
["extend schema", join5(directives, " "), block(operationTypes)],
|
|
15454
15544
|
" "
|
|
15455
15545
|
)
|
|
15456
15546
|
},
|
|
15457
15547
|
ScalarTypeExtension: {
|
|
15458
|
-
leave: ({ name, directives }) =>
|
|
15548
|
+
leave: ({ name, directives }) => join5(["extend scalar", name, join5(directives, " ")], " ")
|
|
15459
15549
|
},
|
|
15460
15550
|
ObjectTypeExtension: {
|
|
15461
|
-
leave: ({ name, interfaces, directives, fields }) =>
|
|
15551
|
+
leave: ({ name, interfaces, directives, fields }) => join5(
|
|
15462
15552
|
[
|
|
15463
15553
|
"extend type",
|
|
15464
15554
|
name,
|
|
15465
|
-
wrap("implements ",
|
|
15466
|
-
|
|
15555
|
+
wrap("implements ", join5(interfaces, " & ")),
|
|
15556
|
+
join5(directives, " "),
|
|
15467
15557
|
block(fields)
|
|
15468
15558
|
],
|
|
15469
15559
|
" "
|
|
15470
15560
|
)
|
|
15471
15561
|
},
|
|
15472
15562
|
InterfaceTypeExtension: {
|
|
15473
|
-
leave: ({ name, interfaces, directives, fields }) =>
|
|
15563
|
+
leave: ({ name, interfaces, directives, fields }) => join5(
|
|
15474
15564
|
[
|
|
15475
15565
|
"extend interface",
|
|
15476
15566
|
name,
|
|
15477
|
-
wrap("implements ",
|
|
15478
|
-
|
|
15567
|
+
wrap("implements ", join5(interfaces, " & ")),
|
|
15568
|
+
join5(directives, " "),
|
|
15479
15569
|
block(fields)
|
|
15480
15570
|
],
|
|
15481
15571
|
" "
|
|
15482
15572
|
)
|
|
15483
15573
|
},
|
|
15484
15574
|
UnionTypeExtension: {
|
|
15485
|
-
leave: ({ name, directives, types }) =>
|
|
15575
|
+
leave: ({ name, directives, types }) => join5(
|
|
15486
15576
|
[
|
|
15487
15577
|
"extend union",
|
|
15488
15578
|
name,
|
|
15489
|
-
|
|
15490
|
-
wrap("= ",
|
|
15579
|
+
join5(directives, " "),
|
|
15580
|
+
wrap("= ", join5(types, " | "))
|
|
15491
15581
|
],
|
|
15492
15582
|
" "
|
|
15493
15583
|
)
|
|
15494
15584
|
},
|
|
15495
15585
|
EnumTypeExtension: {
|
|
15496
|
-
leave: ({ name, directives, values }) =>
|
|
15586
|
+
leave: ({ name, directives, values }) => join5(["extend enum", name, join5(directives, " "), block(values)], " ")
|
|
15497
15587
|
},
|
|
15498
15588
|
InputObjectTypeExtension: {
|
|
15499
|
-
leave: ({ name, directives, fields }) =>
|
|
15589
|
+
leave: ({ name, directives, fields }) => join5(["extend input", name, join5(directives, " "), block(fields)], " ")
|
|
15500
15590
|
},
|
|
15501
15591
|
// Schema Coordinates
|
|
15502
15592
|
TypeCoordinate: {
|
|
15503
15593
|
leave: ({ name }) => name
|
|
15504
15594
|
},
|
|
15505
15595
|
MemberCoordinate: {
|
|
15506
|
-
leave: ({ name, memberName }) =>
|
|
15596
|
+
leave: ({ name, memberName }) => join5([name, wrap(".", memberName)])
|
|
15507
15597
|
},
|
|
15508
15598
|
ArgumentCoordinate: {
|
|
15509
|
-
leave: ({ name, fieldName, argumentName }) =>
|
|
15599
|
+
leave: ({ name, fieldName, argumentName }) => join5([name, wrap(".", fieldName), wrap("(", argumentName, ":)")])
|
|
15510
15600
|
},
|
|
15511
15601
|
DirectiveCoordinate: {
|
|
15512
|
-
leave: ({ name }) =>
|
|
15602
|
+
leave: ({ name }) => join5(["@", name])
|
|
15513
15603
|
},
|
|
15514
15604
|
DirectiveArgumentCoordinate: {
|
|
15515
|
-
leave: ({ name, argumentName }) =>
|
|
15605
|
+
leave: ({ name, argumentName }) => join5(["@", name, wrap("(", argumentName, ":)")])
|
|
15516
15606
|
}
|
|
15517
15607
|
};
|
|
15518
|
-
function
|
|
15608
|
+
function join5(maybeArray, separator = "") {
|
|
15519
15609
|
var _maybeArray$filter$jo;
|
|
15520
15610
|
return (_maybeArray$filter$jo = maybeArray === null || maybeArray === void 0 ? void 0 : maybeArray.filter((x) => x).join(separator)) !== null && _maybeArray$filter$jo !== void 0 ? _maybeArray$filter$jo : "";
|
|
15521
15611
|
}
|
|
15522
15612
|
function block(array) {
|
|
15523
|
-
return wrap("{\n", indent(
|
|
15613
|
+
return wrap("{\n", indent(join5(array, "\n")), "\n}");
|
|
15524
15614
|
}
|
|
15525
15615
|
function wrap(start, maybeString, end = "") {
|
|
15526
15616
|
return maybeString != null && maybeString !== "" ? start + maybeString + end : "";
|
|
@@ -22767,7 +22857,7 @@ var require_execute = __commonJS2({
|
|
|
22767
22857
|
}
|
|
22768
22858
|
const returnType = fieldDef.type;
|
|
22769
22859
|
const resolveFn = (_fieldDef$resolve = fieldDef.resolve) !== null && _fieldDef$resolve !== void 0 ? _fieldDef$resolve : exeContext.fieldResolver;
|
|
22770
|
-
const
|
|
22860
|
+
const info = buildResolveInfo(
|
|
22771
22861
|
exeContext,
|
|
22772
22862
|
fieldDef,
|
|
22773
22863
|
fieldNodes,
|
|
@@ -22781,18 +22871,18 @@ var require_execute = __commonJS2({
|
|
|
22781
22871
|
exeContext.variableValues
|
|
22782
22872
|
);
|
|
22783
22873
|
const contextValue = exeContext.contextValue;
|
|
22784
|
-
const result = resolveFn(source, args, contextValue,
|
|
22874
|
+
const result = resolveFn(source, args, contextValue, info);
|
|
22785
22875
|
let completed;
|
|
22786
22876
|
if ((0, _isPromise.isPromise)(result)) {
|
|
22787
22877
|
completed = result.then(
|
|
22788
|
-
(resolved) => completeValue(exeContext, returnType, fieldNodes,
|
|
22878
|
+
(resolved) => completeValue(exeContext, returnType, fieldNodes, info, path, resolved)
|
|
22789
22879
|
);
|
|
22790
22880
|
} else {
|
|
22791
22881
|
completed = completeValue(
|
|
22792
22882
|
exeContext,
|
|
22793
22883
|
returnType,
|
|
22794
22884
|
fieldNodes,
|
|
22795
|
-
|
|
22885
|
+
info,
|
|
22796
22886
|
path,
|
|
22797
22887
|
result
|
|
22798
22888
|
);
|
|
@@ -22838,7 +22928,7 @@ var require_execute = __commonJS2({
|
|
|
22838
22928
|
exeContext.errors.push(error);
|
|
22839
22929
|
return null;
|
|
22840
22930
|
}
|
|
22841
|
-
function completeValue(exeContext, returnType, fieldNodes,
|
|
22931
|
+
function completeValue(exeContext, returnType, fieldNodes, info, path, result) {
|
|
22842
22932
|
if (result instanceof Error) {
|
|
22843
22933
|
throw result;
|
|
22844
22934
|
}
|
|
@@ -22847,13 +22937,13 @@ var require_execute = __commonJS2({
|
|
|
22847
22937
|
exeContext,
|
|
22848
22938
|
returnType.ofType,
|
|
22849
22939
|
fieldNodes,
|
|
22850
|
-
|
|
22940
|
+
info,
|
|
22851
22941
|
path,
|
|
22852
22942
|
result
|
|
22853
22943
|
);
|
|
22854
22944
|
if (completed === null) {
|
|
22855
22945
|
throw new Error(
|
|
22856
|
-
`Cannot return null for non-nullable field ${
|
|
22946
|
+
`Cannot return null for non-nullable field ${info.parentType.name}.${info.fieldName}.`
|
|
22857
22947
|
);
|
|
22858
22948
|
}
|
|
22859
22949
|
return completed;
|
|
@@ -22866,7 +22956,7 @@ var require_execute = __commonJS2({
|
|
|
22866
22956
|
exeContext,
|
|
22867
22957
|
returnType,
|
|
22868
22958
|
fieldNodes,
|
|
22869
|
-
|
|
22959
|
+
info,
|
|
22870
22960
|
path,
|
|
22871
22961
|
result
|
|
22872
22962
|
);
|
|
@@ -22879,7 +22969,7 @@ var require_execute = __commonJS2({
|
|
|
22879
22969
|
exeContext,
|
|
22880
22970
|
returnType,
|
|
22881
22971
|
fieldNodes,
|
|
22882
|
-
|
|
22972
|
+
info,
|
|
22883
22973
|
path,
|
|
22884
22974
|
result
|
|
22885
22975
|
);
|
|
@@ -22889,7 +22979,7 @@ var require_execute = __commonJS2({
|
|
|
22889
22979
|
exeContext,
|
|
22890
22980
|
returnType,
|
|
22891
22981
|
fieldNodes,
|
|
22892
|
-
|
|
22982
|
+
info,
|
|
22893
22983
|
path,
|
|
22894
22984
|
result
|
|
22895
22985
|
);
|
|
@@ -22899,10 +22989,10 @@ var require_execute = __commonJS2({
|
|
|
22899
22989
|
"Cannot complete value of unexpected output type: " + (0, _inspect.inspect)(returnType)
|
|
22900
22990
|
);
|
|
22901
22991
|
}
|
|
22902
|
-
function completeListValue(exeContext, returnType, fieldNodes,
|
|
22992
|
+
function completeListValue(exeContext, returnType, fieldNodes, info, path, result) {
|
|
22903
22993
|
if (!(0, _isIterableObject.isIterableObject)(result)) {
|
|
22904
22994
|
throw new _GraphQLError.GraphQLError(
|
|
22905
|
-
`Expected Iterable, but did not find one for field "${
|
|
22995
|
+
`Expected Iterable, but did not find one for field "${info.parentType.name}.${info.fieldName}".`
|
|
22906
22996
|
);
|
|
22907
22997
|
}
|
|
22908
22998
|
const itemType = returnType.ofType;
|
|
@@ -22917,7 +23007,7 @@ var require_execute = __commonJS2({
|
|
|
22917
23007
|
exeContext,
|
|
22918
23008
|
itemType,
|
|
22919
23009
|
fieldNodes,
|
|
22920
|
-
|
|
23010
|
+
info,
|
|
22921
23011
|
itemPath,
|
|
22922
23012
|
resolved
|
|
22923
23013
|
)
|
|
@@ -22927,7 +23017,7 @@ var require_execute = __commonJS2({
|
|
|
22927
23017
|
exeContext,
|
|
22928
23018
|
itemType,
|
|
22929
23019
|
fieldNodes,
|
|
22930
|
-
|
|
23020
|
+
info,
|
|
22931
23021
|
itemPath,
|
|
22932
23022
|
item
|
|
22933
23023
|
);
|
|
@@ -22966,11 +23056,11 @@ var require_execute = __commonJS2({
|
|
|
22966
23056
|
}
|
|
22967
23057
|
return serializedResult;
|
|
22968
23058
|
}
|
|
22969
|
-
function completeAbstractValue(exeContext, returnType, fieldNodes,
|
|
23059
|
+
function completeAbstractValue(exeContext, returnType, fieldNodes, info, path, result) {
|
|
22970
23060
|
var _returnType$resolveTy;
|
|
22971
23061
|
const resolveTypeFn = (_returnType$resolveTy = returnType.resolveType) !== null && _returnType$resolveTy !== void 0 ? _returnType$resolveTy : exeContext.typeResolver;
|
|
22972
23062
|
const contextValue = exeContext.contextValue;
|
|
22973
|
-
const runtimeType = resolveTypeFn(result, contextValue,
|
|
23063
|
+
const runtimeType = resolveTypeFn(result, contextValue, info, returnType);
|
|
22974
23064
|
if ((0, _isPromise.isPromise)(runtimeType)) {
|
|
22975
23065
|
return runtimeType.then(
|
|
22976
23066
|
(resolvedRuntimeType) => completeObjectValue(
|
|
@@ -22980,11 +23070,11 @@ var require_execute = __commonJS2({
|
|
|
22980
23070
|
exeContext,
|
|
22981
23071
|
returnType,
|
|
22982
23072
|
fieldNodes,
|
|
22983
|
-
|
|
23073
|
+
info,
|
|
22984
23074
|
result
|
|
22985
23075
|
),
|
|
22986
23076
|
fieldNodes,
|
|
22987
|
-
|
|
23077
|
+
info,
|
|
22988
23078
|
path,
|
|
22989
23079
|
result
|
|
22990
23080
|
)
|
|
@@ -22997,19 +23087,19 @@ var require_execute = __commonJS2({
|
|
|
22997
23087
|
exeContext,
|
|
22998
23088
|
returnType,
|
|
22999
23089
|
fieldNodes,
|
|
23000
|
-
|
|
23090
|
+
info,
|
|
23001
23091
|
result
|
|
23002
23092
|
),
|
|
23003
23093
|
fieldNodes,
|
|
23004
|
-
|
|
23094
|
+
info,
|
|
23005
23095
|
path,
|
|
23006
23096
|
result
|
|
23007
23097
|
);
|
|
23008
23098
|
}
|
|
23009
|
-
function ensureValidRuntimeType(runtimeTypeName, exeContext, returnType, fieldNodes,
|
|
23099
|
+
function ensureValidRuntimeType(runtimeTypeName, exeContext, returnType, fieldNodes, info, result) {
|
|
23010
23100
|
if (runtimeTypeName == null) {
|
|
23011
23101
|
throw new _GraphQLError.GraphQLError(
|
|
23012
|
-
`Abstract type "${returnType.name}" must resolve to an Object type at runtime for field "${
|
|
23102
|
+
`Abstract type "${returnType.name}" must resolve to an Object type at runtime for field "${info.parentType.name}.${info.fieldName}". Either the "${returnType.name}" type should provide a "resolveType" function or each possible type should provide an "isTypeOf" function.`,
|
|
23013
23103
|
fieldNodes
|
|
23014
23104
|
);
|
|
23015
23105
|
}
|
|
@@ -23020,7 +23110,7 @@ var require_execute = __commonJS2({
|
|
|
23020
23110
|
}
|
|
23021
23111
|
if (typeof runtimeTypeName !== "string") {
|
|
23022
23112
|
throw new _GraphQLError.GraphQLError(
|
|
23023
|
-
`Abstract type "${returnType.name}" must resolve to an Object type at runtime for field "${
|
|
23113
|
+
`Abstract type "${returnType.name}" must resolve to an Object type at runtime for field "${info.parentType.name}.${info.fieldName}" with value ${(0, _inspect.inspect)(result)}, received "${(0, _inspect.inspect)(runtimeTypeName)}".`
|
|
23024
23114
|
);
|
|
23025
23115
|
}
|
|
23026
23116
|
const runtimeType = exeContext.schema.getType(runtimeTypeName);
|
|
@@ -23050,10 +23140,10 @@ var require_execute = __commonJS2({
|
|
|
23050
23140
|
}
|
|
23051
23141
|
return runtimeType;
|
|
23052
23142
|
}
|
|
23053
|
-
function completeObjectValue(exeContext, returnType, fieldNodes,
|
|
23143
|
+
function completeObjectValue(exeContext, returnType, fieldNodes, info, path, result) {
|
|
23054
23144
|
const subFieldNodes = collectSubfields(exeContext, returnType, fieldNodes);
|
|
23055
23145
|
if (returnType.isTypeOf) {
|
|
23056
|
-
const isTypeOf = returnType.isTypeOf(result, exeContext.contextValue,
|
|
23146
|
+
const isTypeOf = returnType.isTypeOf(result, exeContext.contextValue, info);
|
|
23057
23147
|
if ((0, _isPromise.isPromise)(isTypeOf)) {
|
|
23058
23148
|
return isTypeOf.then((resolvedIsTypeOf) => {
|
|
23059
23149
|
if (!resolvedIsTypeOf) {
|
|
@@ -23082,16 +23172,16 @@ var require_execute = __commonJS2({
|
|
|
23082
23172
|
}
|
|
23083
23173
|
);
|
|
23084
23174
|
}
|
|
23085
|
-
var defaultTypeResolver = function(value, contextValue,
|
|
23175
|
+
var defaultTypeResolver = function(value, contextValue, info, abstractType) {
|
|
23086
23176
|
if ((0, _isObjectLike.isObjectLike)(value) && typeof value.__typename === "string") {
|
|
23087
23177
|
return value.__typename;
|
|
23088
23178
|
}
|
|
23089
|
-
const possibleTypes =
|
|
23179
|
+
const possibleTypes = info.schema.getPossibleTypes(abstractType);
|
|
23090
23180
|
const promisedIsTypeOfResults = [];
|
|
23091
23181
|
for (let i = 0; i < possibleTypes.length; i++) {
|
|
23092
23182
|
const type = possibleTypes[i];
|
|
23093
23183
|
if (type.isTypeOf) {
|
|
23094
|
-
const isTypeOfResult = type.isTypeOf(value, contextValue,
|
|
23184
|
+
const isTypeOfResult = type.isTypeOf(value, contextValue, info);
|
|
23095
23185
|
if ((0, _isPromise.isPromise)(isTypeOfResult)) {
|
|
23096
23186
|
promisedIsTypeOfResults[i] = isTypeOfResult;
|
|
23097
23187
|
} else if (isTypeOfResult) {
|
|
@@ -23114,11 +23204,11 @@ var require_execute = __commonJS2({
|
|
|
23114
23204
|
}
|
|
23115
23205
|
};
|
|
23116
23206
|
exports.defaultTypeResolver = defaultTypeResolver;
|
|
23117
|
-
var defaultFieldResolver = function(source, args, contextValue,
|
|
23207
|
+
var defaultFieldResolver = function(source, args, contextValue, info) {
|
|
23118
23208
|
if ((0, _isObjectLike.isObjectLike)(source) || typeof source === "function") {
|
|
23119
|
-
const property = source[
|
|
23209
|
+
const property = source[info.fieldName];
|
|
23120
23210
|
if (typeof property === "function") {
|
|
23121
|
-
return source[
|
|
23211
|
+
return source[info.fieldName](args, contextValue, info);
|
|
23122
23212
|
}
|
|
23123
23213
|
return property;
|
|
23124
23214
|
}
|
|
@@ -24145,7 +24235,7 @@ var require_subscribe = __commonJS2({
|
|
|
24145
24235
|
);
|
|
24146
24236
|
}
|
|
24147
24237
|
const path = (0, _Path.addPath)(void 0, responseName, rootType.name);
|
|
24148
|
-
const
|
|
24238
|
+
const info = (0, _execute.buildResolveInfo)(
|
|
24149
24239
|
exeContext,
|
|
24150
24240
|
fieldDef,
|
|
24151
24241
|
fieldNodes,
|
|
@@ -24161,7 +24251,7 @@ var require_subscribe = __commonJS2({
|
|
|
24161
24251
|
);
|
|
24162
24252
|
const contextValue = exeContext.contextValue;
|
|
24163
24253
|
const resolveFn = (_fieldDef$subscribe = fieldDef.subscribe) !== null && _fieldDef$subscribe !== void 0 ? _fieldDef$subscribe : exeContext.subscribeFieldResolver;
|
|
24164
|
-
const eventStream = await resolveFn(rootValue, args, contextValue,
|
|
24254
|
+
const eventStream = await resolveFn(rootValue, args, contextValue, info);
|
|
24165
24255
|
if (eventStream instanceof Error) {
|
|
24166
24256
|
throw eventStream;
|
|
24167
24257
|
}
|
|
@@ -34322,17 +34412,17 @@ var require_lib3 = __commonJS2({
|
|
|
34322
34412
|
throw new TypeError("Header pairs must be iterable");
|
|
34323
34413
|
}
|
|
34324
34414
|
const pairs = [];
|
|
34325
|
-
for (const
|
|
34326
|
-
if (typeof
|
|
34415
|
+
for (const pair of init) {
|
|
34416
|
+
if (typeof pair !== "object" || typeof pair[Symbol.iterator] !== "function") {
|
|
34327
34417
|
throw new TypeError("Each header pair must be iterable");
|
|
34328
34418
|
}
|
|
34329
|
-
pairs.push(Array.from(
|
|
34419
|
+
pairs.push(Array.from(pair));
|
|
34330
34420
|
}
|
|
34331
|
-
for (const
|
|
34332
|
-
if (
|
|
34421
|
+
for (const pair of pairs) {
|
|
34422
|
+
if (pair.length !== 2) {
|
|
34333
34423
|
throw new TypeError("Each header pair must be a name/value tuple");
|
|
34334
34424
|
}
|
|
34335
|
-
this.append(
|
|
34425
|
+
this.append(pair[0], pair[1]);
|
|
34336
34426
|
}
|
|
34337
34427
|
} else {
|
|
34338
34428
|
for (const key of Object.keys(init)) {
|
|
@@ -36483,52 +36573,52 @@ var require_src2 = __commonJS22({
|
|
|
36483
36573
|
});
|
|
36484
36574
|
var import_debug2 = __toESM22(require_src2());
|
|
36485
36575
|
function createLoggers2(namespace, logLevel = process.env.LOG_LEVEL ?? "none") {
|
|
36486
|
-
const
|
|
36487
|
-
const
|
|
36576
|
+
const logInfo222 = (0, import_debug2.default)(`${namespace}:info`);
|
|
36577
|
+
const logTask4 = (0, import_debug2.default)(`${namespace}:task`);
|
|
36488
36578
|
const logError22 = (0, import_debug2.default)(`${namespace}:error`);
|
|
36489
|
-
const
|
|
36579
|
+
const logDetail3 = (0, import_debug2.default)(`${namespace}:detail`);
|
|
36490
36580
|
const logDebug = (0, import_debug2.default)(`${namespace}:debug`);
|
|
36491
36581
|
const logWarning2 = (0, import_debug2.default)(`${namespace}:warning`);
|
|
36492
36582
|
const logColor = (0, import_debug2.default)(`${namespace}:color`);
|
|
36493
|
-
|
|
36494
|
-
|
|
36583
|
+
logInfo222.color = "19";
|
|
36584
|
+
logTask4.color = "25";
|
|
36495
36585
|
logError22.color = "1";
|
|
36496
|
-
|
|
36586
|
+
logDetail3.color = "199";
|
|
36497
36587
|
logWarning2.color = "186";
|
|
36498
36588
|
logDebug.color = "211";
|
|
36499
36589
|
logColor.enabled = true;
|
|
36500
|
-
function
|
|
36501
|
-
|
|
36502
|
-
|
|
36590
|
+
function setNamespace7(namespace2) {
|
|
36591
|
+
logInfo222.namespace = `${namespace2}:info`;
|
|
36592
|
+
logTask4.namespace = `${namespace2}:task`;
|
|
36503
36593
|
logError22.namespace = `${namespace2}:error`;
|
|
36504
|
-
|
|
36594
|
+
logDetail3.namespace = `${namespace2}:detail`;
|
|
36505
36595
|
logWarning2.namespace = `${namespace2}:warning`;
|
|
36506
36596
|
logDebug.namespace = `${namespace2}:debug`;
|
|
36507
36597
|
}
|
|
36508
36598
|
function setLogLevel(level) {
|
|
36509
36599
|
switch (level) {
|
|
36510
36600
|
case "info":
|
|
36511
|
-
|
|
36512
|
-
|
|
36601
|
+
logInfo222.enabled = true;
|
|
36602
|
+
logTask4.enabled = true;
|
|
36513
36603
|
logError22.enabled = true;
|
|
36514
36604
|
logWarning2.enabled = true;
|
|
36515
|
-
|
|
36605
|
+
logDetail3.enabled = false;
|
|
36516
36606
|
logDebug.enabled = false;
|
|
36517
36607
|
break;
|
|
36518
36608
|
case "debug":
|
|
36519
|
-
|
|
36520
|
-
|
|
36609
|
+
logInfo222.enabled = true;
|
|
36610
|
+
logTask4.enabled = true;
|
|
36521
36611
|
logError22.enabled = true;
|
|
36522
36612
|
logWarning2.enabled = true;
|
|
36523
|
-
|
|
36613
|
+
logDetail3.enabled = true;
|
|
36524
36614
|
logDebug.enabled = true;
|
|
36525
36615
|
break;
|
|
36526
36616
|
case "none":
|
|
36527
|
-
|
|
36528
|
-
|
|
36617
|
+
logInfo222.enabled = false;
|
|
36618
|
+
logTask4.enabled = false;
|
|
36529
36619
|
logError22.enabled = false;
|
|
36530
36620
|
logWarning2.enabled = false;
|
|
36531
|
-
|
|
36621
|
+
logDetail3.enabled = false;
|
|
36532
36622
|
logDebug.enabled = false;
|
|
36533
36623
|
break;
|
|
36534
36624
|
}
|
|
@@ -36537,16 +36627,16 @@ function createLoggers2(namespace, logLevel = process.env.LOG_LEVEL ?? "none") {
|
|
|
36537
36627
|
function setColors(type, color) {
|
|
36538
36628
|
switch (type) {
|
|
36539
36629
|
case "info":
|
|
36540
|
-
|
|
36630
|
+
logInfo222.color = color;
|
|
36541
36631
|
break;
|
|
36542
36632
|
case "task":
|
|
36543
|
-
|
|
36633
|
+
logTask4.color = color;
|
|
36544
36634
|
break;
|
|
36545
36635
|
case "error":
|
|
36546
36636
|
logError22.color = color;
|
|
36547
36637
|
break;
|
|
36548
36638
|
case "detail":
|
|
36549
|
-
|
|
36639
|
+
logDetail3.color = color;
|
|
36550
36640
|
break;
|
|
36551
36641
|
case "warning":
|
|
36552
36642
|
logWarning2.color = color;
|
|
@@ -36585,7 +36675,7 @@ function createLoggers2(namespace, logLevel = process.env.LOG_LEVEL ?? "none") {
|
|
|
36585
36675
|
`;
|
|
36586
36676
|
} else if (typeof value === "object") {
|
|
36587
36677
|
result += `
|
|
36588
|
-
|
|
36678
|
+
${logDataDetail(value, `${prefix} `)}
|
|
36589
36679
|
`;
|
|
36590
36680
|
} else {
|
|
36591
36681
|
result += `${value}
|
|
@@ -36602,9 +36692,9 @@ ${" ".repeat(40 - title.length / 2)}${title}
|
|
|
36602
36692
|
${" ".repeat(padding)}${"=".repeat(80)}`;
|
|
36603
36693
|
}
|
|
36604
36694
|
function logHeader(title) {
|
|
36605
|
-
|
|
36695
|
+
logInfo222(`${header(title, 2)}`);
|
|
36606
36696
|
}
|
|
36607
|
-
function
|
|
36697
|
+
function logDataObject22(title, ...args) {
|
|
36608
36698
|
const stack = new Error().stack?.split("\n")[2] || "";
|
|
36609
36699
|
const stackMatch = stack.match(/\((.*):(\d+):(\d+)\)$/) || stack.match(/at (.*):(\d+):(\d+)$/);
|
|
36610
36700
|
let callerDetails = "";
|
|
@@ -36613,7 +36703,7 @@ ${" ".repeat(padding)}${"=".repeat(80)}`;
|
|
|
36613
36703
|
const functionName = functionMatch ? functionMatch[1] : "<anonymous>";
|
|
36614
36704
|
callerDetails = `${functionName}`;
|
|
36615
36705
|
}
|
|
36616
|
-
|
|
36706
|
+
logDetail3(`${header(`*${title}* ${callerDetails}`)}
|
|
36617
36707
|
${args.reduce((acc, arg) => `${acc}
|
|
36618
36708
|
${logDataDetail(arg)}`, "")}
|
|
36619
36709
|
|
|
@@ -36633,20 +36723,20 @@ ${"=".repeat(80)}`);
|
|
|
36633
36723
|
}
|
|
36634
36724
|
}
|
|
36635
36725
|
return {
|
|
36636
|
-
logInfo:
|
|
36637
|
-
logTask:
|
|
36726
|
+
logInfo: logInfo222,
|
|
36727
|
+
logTask: logTask4,
|
|
36638
36728
|
logError: logError22,
|
|
36639
|
-
logDetail:
|
|
36729
|
+
logDetail: logDetail3,
|
|
36640
36730
|
logDebug,
|
|
36641
36731
|
logWarning: logWarning2,
|
|
36642
36732
|
logColor,
|
|
36643
36733
|
setColors,
|
|
36644
36734
|
printColors,
|
|
36645
36735
|
logHeader,
|
|
36646
|
-
logDataObject:
|
|
36736
|
+
logDataObject: logDataObject22,
|
|
36647
36737
|
logErrorObject,
|
|
36648
36738
|
setLogLevel,
|
|
36649
|
-
setNamespace:
|
|
36739
|
+
setNamespace: setNamespace7
|
|
36650
36740
|
};
|
|
36651
36741
|
}
|
|
36652
36742
|
var AUTHORIZE_QUERY = `
|
|
@@ -36666,7 +36756,7 @@ var TOKEN_QUERY = `
|
|
|
36666
36756
|
}
|
|
36667
36757
|
}
|
|
36668
36758
|
`;
|
|
36669
|
-
var { logInfo } = createLoggers2("auth");
|
|
36759
|
+
var { logInfo: logInfo2 } = createLoggers2("auth");
|
|
36670
36760
|
var random = promisify(randomBytes);
|
|
36671
36761
|
async function getAuthToken(credentials, apiUrl) {
|
|
36672
36762
|
const authApiUrl = apiUrl || process.env.AUTH_API_URL;
|
|
@@ -36675,7 +36765,7 @@ async function getAuthToken(credentials, apiUrl) {
|
|
|
36675
36765
|
}
|
|
36676
36766
|
const { clientDecorator, variantConfigurationKey } = credentials;
|
|
36677
36767
|
const frameworkId = credentials.frameworkId || `apple-kit-${Date.now()}`;
|
|
36678
|
-
|
|
36768
|
+
logInfo2(`Getting auth token for identifiers: ${variantConfigurationKey}`);
|
|
36679
36769
|
const randomSecret = (await random(8)).toString("hex");
|
|
36680
36770
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
36681
36771
|
const hash = createHash("sha256");
|
|
@@ -36746,7 +36836,7 @@ async function getAuthToken(credentials, apiUrl) {
|
|
|
36746
36836
|
}
|
|
36747
36837
|
async function readCredentialsFromFile(filePath) {
|
|
36748
36838
|
const fs = await import("node:fs/promises");
|
|
36749
|
-
|
|
36839
|
+
logInfo2(`Reading credentials from: ${filePath}`);
|
|
36750
36840
|
const content = await fs.readFile(filePath, "utf-8");
|
|
36751
36841
|
const credentials = JSON.parse(content);
|
|
36752
36842
|
if (!credentials.clientDecorator || !credentials.variantConfigurationKey) {
|
|
@@ -37581,24 +37671,24 @@ var require_src22 = __commonJS3({
|
|
|
37581
37671
|
var import_debug22 = __toESM3(require_src22());
|
|
37582
37672
|
function createLoggers22(namespace, logLevel = process.env.LOG_LEVEL ?? "none") {
|
|
37583
37673
|
const logInfo32 = (0, import_debug22.default)(`${namespace}:info`);
|
|
37584
|
-
const
|
|
37674
|
+
const logTask4 = (0, import_debug22.default)(`${namespace}:task`);
|
|
37585
37675
|
const logError22 = (0, import_debug22.default)(`${namespace}:error`);
|
|
37586
|
-
const
|
|
37676
|
+
const logDetail3 = (0, import_debug22.default)(`${namespace}:detail`);
|
|
37587
37677
|
const logDebug = (0, import_debug22.default)(`${namespace}:debug`);
|
|
37588
37678
|
const logWarning2 = (0, import_debug22.default)(`${namespace}:warning`);
|
|
37589
37679
|
const logColor = (0, import_debug22.default)(`${namespace}:color`);
|
|
37590
37680
|
logInfo32.color = "19";
|
|
37591
|
-
|
|
37681
|
+
logTask4.color = "25";
|
|
37592
37682
|
logError22.color = "1";
|
|
37593
|
-
|
|
37683
|
+
logDetail3.color = "199";
|
|
37594
37684
|
logWarning2.color = "186";
|
|
37595
37685
|
logDebug.color = "211";
|
|
37596
37686
|
logColor.enabled = true;
|
|
37597
|
-
function
|
|
37687
|
+
function setNamespace7(namespace2) {
|
|
37598
37688
|
logInfo32.namespace = `${namespace2}:info`;
|
|
37599
|
-
|
|
37689
|
+
logTask4.namespace = `${namespace2}:task`;
|
|
37600
37690
|
logError22.namespace = `${namespace2}:error`;
|
|
37601
|
-
|
|
37691
|
+
logDetail3.namespace = `${namespace2}:detail`;
|
|
37602
37692
|
logWarning2.namespace = `${namespace2}:warning`;
|
|
37603
37693
|
logDebug.namespace = `${namespace2}:debug`;
|
|
37604
37694
|
}
|
|
@@ -37606,26 +37696,26 @@ function createLoggers22(namespace, logLevel = process.env.LOG_LEVEL ?? "none")
|
|
|
37606
37696
|
switch (level) {
|
|
37607
37697
|
case "info":
|
|
37608
37698
|
logInfo32.enabled = true;
|
|
37609
|
-
|
|
37699
|
+
logTask4.enabled = true;
|
|
37610
37700
|
logError22.enabled = true;
|
|
37611
37701
|
logWarning2.enabled = true;
|
|
37612
|
-
|
|
37702
|
+
logDetail3.enabled = false;
|
|
37613
37703
|
logDebug.enabled = false;
|
|
37614
37704
|
break;
|
|
37615
37705
|
case "debug":
|
|
37616
37706
|
logInfo32.enabled = true;
|
|
37617
|
-
|
|
37707
|
+
logTask4.enabled = true;
|
|
37618
37708
|
logError22.enabled = true;
|
|
37619
37709
|
logWarning2.enabled = true;
|
|
37620
|
-
|
|
37710
|
+
logDetail3.enabled = true;
|
|
37621
37711
|
logDebug.enabled = true;
|
|
37622
37712
|
break;
|
|
37623
37713
|
case "none":
|
|
37624
37714
|
logInfo32.enabled = false;
|
|
37625
|
-
|
|
37715
|
+
logTask4.enabled = false;
|
|
37626
37716
|
logError22.enabled = false;
|
|
37627
37717
|
logWarning2.enabled = false;
|
|
37628
|
-
|
|
37718
|
+
logDetail3.enabled = false;
|
|
37629
37719
|
logDebug.enabled = false;
|
|
37630
37720
|
break;
|
|
37631
37721
|
}
|
|
@@ -37637,13 +37727,13 @@ function createLoggers22(namespace, logLevel = process.env.LOG_LEVEL ?? "none")
|
|
|
37637
37727
|
logInfo32.color = color;
|
|
37638
37728
|
break;
|
|
37639
37729
|
case "task":
|
|
37640
|
-
|
|
37730
|
+
logTask4.color = color;
|
|
37641
37731
|
break;
|
|
37642
37732
|
case "error":
|
|
37643
37733
|
logError22.color = color;
|
|
37644
37734
|
break;
|
|
37645
37735
|
case "detail":
|
|
37646
|
-
|
|
37736
|
+
logDetail3.color = color;
|
|
37647
37737
|
break;
|
|
37648
37738
|
case "warning":
|
|
37649
37739
|
logWarning2.color = color;
|
|
@@ -37682,7 +37772,7 @@ function createLoggers22(namespace, logLevel = process.env.LOG_LEVEL ?? "none")
|
|
|
37682
37772
|
`;
|
|
37683
37773
|
} else if (typeof value === "object") {
|
|
37684
37774
|
result += `
|
|
37685
|
-
|
|
37775
|
+
${logDataDetail(value, `${prefix} `)}
|
|
37686
37776
|
`;
|
|
37687
37777
|
} else {
|
|
37688
37778
|
result += `${value}
|
|
@@ -37701,7 +37791,7 @@ ${" ".repeat(padding)}${"=".repeat(80)}`;
|
|
|
37701
37791
|
function logHeader(title) {
|
|
37702
37792
|
logInfo32(`${header(title, 2)}`);
|
|
37703
37793
|
}
|
|
37704
|
-
function
|
|
37794
|
+
function logDataObject22(title, ...args) {
|
|
37705
37795
|
const stack = new Error().stack?.split("\n")[2] || "";
|
|
37706
37796
|
const stackMatch = stack.match(/\((.*):(\d+):(\d+)\)$/) || stack.match(/at (.*):(\d+):(\d+)$/);
|
|
37707
37797
|
let callerDetails = "";
|
|
@@ -37710,7 +37800,7 @@ ${" ".repeat(padding)}${"=".repeat(80)}`;
|
|
|
37710
37800
|
const functionName = functionMatch ? functionMatch[1] : "<anonymous>";
|
|
37711
37801
|
callerDetails = `${functionName}`;
|
|
37712
37802
|
}
|
|
37713
|
-
|
|
37803
|
+
logDetail3(`${header(`*${title}* ${callerDetails}`)}
|
|
37714
37804
|
${args.reduce((acc, arg) => `${acc}
|
|
37715
37805
|
${logDataDetail(arg)}`, "")}
|
|
37716
37806
|
|
|
@@ -37731,26 +37821,26 @@ ${"=".repeat(80)}`);
|
|
|
37731
37821
|
}
|
|
37732
37822
|
return {
|
|
37733
37823
|
logInfo: logInfo32,
|
|
37734
|
-
logTask:
|
|
37824
|
+
logTask: logTask4,
|
|
37735
37825
|
logError: logError22,
|
|
37736
|
-
logDetail:
|
|
37826
|
+
logDetail: logDetail3,
|
|
37737
37827
|
logDebug,
|
|
37738
37828
|
logWarning: logWarning2,
|
|
37739
37829
|
logColor,
|
|
37740
37830
|
setColors,
|
|
37741
37831
|
printColors,
|
|
37742
37832
|
logHeader,
|
|
37743
|
-
logDataObject:
|
|
37833
|
+
logDataObject: logDataObject22,
|
|
37744
37834
|
logErrorObject,
|
|
37745
37835
|
setLogLevel,
|
|
37746
|
-
setNamespace:
|
|
37836
|
+
setNamespace: setNamespace7
|
|
37747
37837
|
};
|
|
37748
37838
|
}
|
|
37749
|
-
var { logInfo:
|
|
37839
|
+
var { logInfo: logInfo22, logError, logWarning, logDataObject: logDataObject2 } = createLoggers22("mdm-client");
|
|
37750
37840
|
var MdmClient = class {
|
|
37751
37841
|
constructor(config) {
|
|
37752
37842
|
this.config = config;
|
|
37753
|
-
|
|
37843
|
+
logDataObject2("MDM Client Config", { config });
|
|
37754
37844
|
if (!config.endpoint) {
|
|
37755
37845
|
throw new Error("MDM endpoint is required");
|
|
37756
37846
|
}
|
|
@@ -37770,7 +37860,7 @@ var MdmClient = class {
|
|
|
37770
37860
|
}
|
|
37771
37861
|
client;
|
|
37772
37862
|
async generateEnrollmentProfile(deviceId) {
|
|
37773
|
-
|
|
37863
|
+
logInfo22(`Generating enrollment profile for device ${deviceId}`);
|
|
37774
37864
|
const result = await this.client.request(GENERATE_ENROLLMENT_PROFILE, {
|
|
37775
37865
|
input: {
|
|
37776
37866
|
deviceId,
|
|
@@ -37780,7 +37870,7 @@ var MdmClient = class {
|
|
|
37780
37870
|
return result.generateEnrollmentProfile;
|
|
37781
37871
|
}
|
|
37782
37872
|
async waitForDeviceToEnroll(deviceId, previousOpRef) {
|
|
37783
|
-
|
|
37873
|
+
logInfo22(`Waiting for device ${deviceId} to enroll...`);
|
|
37784
37874
|
const result = await this.client.request(WAIT_FOR_DEVICE_TO_ENROLL, {
|
|
37785
37875
|
input: {
|
|
37786
37876
|
deviceId,
|
|
@@ -37790,7 +37880,7 @@ var MdmClient = class {
|
|
|
37790
37880
|
return result.waitForDeviceToEnroll;
|
|
37791
37881
|
}
|
|
37792
37882
|
async installApp(deviceId, options) {
|
|
37793
|
-
|
|
37883
|
+
logInfo22(`Installing app on device ${deviceId}`);
|
|
37794
37884
|
try {
|
|
37795
37885
|
const result = await this.client.request(INSTALL_APP, {
|
|
37796
37886
|
input: {
|
|
@@ -37818,7 +37908,7 @@ async function createMDMClient() {
|
|
|
37818
37908
|
const credPath = process.env.CREDENTIALS_PATH;
|
|
37819
37909
|
if (!endpoint || !credPath) {
|
|
37820
37910
|
logWarning("MDM endpoint or credentials path is not set");
|
|
37821
|
-
|
|
37911
|
+
logDataObject2("Environment variables", { endpoint, credPath });
|
|
37822
37912
|
return void 0;
|
|
37823
37913
|
}
|
|
37824
37914
|
const credentials = await readCredentialsFromFile(credPath);
|
|
@@ -37830,32 +37920,109 @@ async function createMDMClient() {
|
|
|
37830
37920
|
});
|
|
37831
37921
|
}
|
|
37832
37922
|
|
|
37833
|
-
// src/logic/
|
|
37834
|
-
|
|
37835
|
-
|
|
37836
|
-
|
|
37837
|
-
|
|
37838
|
-
|
|
37839
|
-
|
|
37840
|
-
|
|
37841
|
-
|
|
37842
|
-
|
|
37843
|
-
|
|
37844
|
-
|
|
37923
|
+
// src/logic/actions/install.ts
|
|
37924
|
+
var { logInfo: logInfo3, setNamespace: setNamespace2 } = createLoggers("apple-kit:install");
|
|
37925
|
+
var InstallActions = class {
|
|
37926
|
+
constructor(udid, iosClient) {
|
|
37927
|
+
this.udid = udid;
|
|
37928
|
+
this.iosClient = iosClient;
|
|
37929
|
+
setNamespace2(`apple-${udid}`);
|
|
37930
|
+
}
|
|
37931
|
+
async installLocalApp(ipaPath) {
|
|
37932
|
+
logInfo3(`Installing app ${ipaPath} on device ${this.udid}`);
|
|
37933
|
+
return this.iosClient.installApp(ipaPath);
|
|
37934
|
+
}
|
|
37935
|
+
async installManagedApp(ipaPath, options) {
|
|
37936
|
+
const result = await this.iosClient.installApp(ipaPath);
|
|
37937
|
+
logInfo3("Installing app via MDM for management takeover");
|
|
37938
|
+
const mdmClient = await createMDMClient();
|
|
37939
|
+
if (!mdmClient) {
|
|
37940
|
+
throw new Error("Failed to create MDM client");
|
|
37941
|
+
}
|
|
37942
|
+
await mdmClient.installApp(this.udid, options);
|
|
37943
|
+
return result;
|
|
37944
|
+
}
|
|
37945
|
+
async uninstallApp(bundleId) {
|
|
37946
|
+
logInfo3(`Uninstalling app ${bundleId} from device ${this.udid}`);
|
|
37947
|
+
return await this.iosClient.uninstallApp(bundleId);
|
|
37948
|
+
}
|
|
37949
|
+
async listApps() {
|
|
37950
|
+
logInfo3(`Listing apps on device ${this.udid}`);
|
|
37951
|
+
const result = await this.iosClient.listApps();
|
|
37952
|
+
return result.map((app) => ({
|
|
37953
|
+
bundleId: app.bundleId,
|
|
37954
|
+
version: app.version,
|
|
37955
|
+
displayName: app.displayName,
|
|
37956
|
+
bundleVersion: app.version
|
|
37957
|
+
}));
|
|
37958
|
+
}
|
|
37959
|
+
async isAppInstalled(bundleId) {
|
|
37960
|
+
logInfo3(`Checking if app ${bundleId} is installed on device ${this.udid}`);
|
|
37961
|
+
const apps = await this.listApps();
|
|
37962
|
+
return apps.some((app) => app.bundleId === bundleId);
|
|
37963
|
+
}
|
|
37964
|
+
//TODO: add a method to launch an app, currently I've tried to launch it using ios launch
|
|
37965
|
+
// even if devmode is enabled and device restarted and using tunnel, it's not working.
|
|
37966
|
+
};
|
|
37967
|
+
|
|
37968
|
+
// src/logic/actions/proxy.ts
|
|
37969
|
+
var { logTask: logTask2, logInfo: logInfo4, setNamespace: setNamespace3 } = createLoggers("");
|
|
37970
|
+
var ProxyActions = class {
|
|
37971
|
+
constructor(udid, iosClient) {
|
|
37972
|
+
this.udid = udid;
|
|
37973
|
+
this.iosClient = iosClient;
|
|
37974
|
+
setNamespace3(`apple-${udid}`);
|
|
37975
|
+
}
|
|
37976
|
+
childProcess = /* @__PURE__ */ new Map();
|
|
37977
|
+
async startPortForward(localPort, devicePort) {
|
|
37978
|
+
logInfo4(`Starting port forward ${localPort} -> ${devicePort} for device ${this.udid}`);
|
|
37979
|
+
const result = await this.iosClient.forward({ fromPort: localPort, toPort: devicePort });
|
|
37980
|
+
return new Promise((resolve2, reject) => {
|
|
37981
|
+
const timeout2 = setTimeout(() => {
|
|
37982
|
+
reject(new Error("Port forwarding timed out"));
|
|
37983
|
+
}, 1e4);
|
|
37984
|
+
result.stdout?.on("data", (data) => {
|
|
37985
|
+
if (data.toString().includes("Started")) {
|
|
37986
|
+
clearTimeout(timeout2);
|
|
37987
|
+
resolve2({
|
|
37988
|
+
localPort,
|
|
37989
|
+
devicePort
|
|
37990
|
+
});
|
|
37991
|
+
}
|
|
37992
|
+
});
|
|
37993
|
+
result.on("error", (err) => {
|
|
37994
|
+
clearTimeout(timeout2);
|
|
37995
|
+
reject(err);
|
|
37845
37996
|
});
|
|
37997
|
+
});
|
|
37998
|
+
}
|
|
37999
|
+
async killPortForward() {
|
|
38000
|
+
const process3 = this.childProcess.get(this.udid);
|
|
38001
|
+
if (process3 && !process3.killed) {
|
|
38002
|
+
logTask2("Killing port forward process");
|
|
38003
|
+
process3.kill();
|
|
38004
|
+
this.childProcess.delete(this.udid);
|
|
37846
38005
|
}
|
|
37847
38006
|
}
|
|
37848
|
-
|
|
37849
|
-
}
|
|
38007
|
+
};
|
|
37850
38008
|
|
|
37851
|
-
// src/logic/
|
|
37852
|
-
import {
|
|
37853
|
-
import {
|
|
37854
|
-
import {
|
|
38009
|
+
// src/logic/activationFlow.ts
|
|
38010
|
+
import { unlink, writeFile } from "node:fs/promises";
|
|
38011
|
+
import { tmpdir } from "node:os";
|
|
38012
|
+
import { join as join4 } from "node:path";
|
|
38013
|
+
|
|
38014
|
+
// src/utils/wifiProfile.ts
|
|
38015
|
+
import { randomUUID } from "node:crypto";
|
|
38016
|
+
|
|
38017
|
+
// src/utils/templateLoader.ts
|
|
38018
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
38019
|
+
import { readFile } from "node:fs/promises";
|
|
38020
|
+
import { dirname, isAbsolute, join as join3, resolve } from "node:path";
|
|
38021
|
+
import { fileURLToPath } from "node:url";
|
|
37855
38022
|
|
|
37856
38023
|
// src/logic/utils/resolvePath.ts
|
|
37857
|
-
import { existsSync } from "node:fs";
|
|
37858
|
-
import { join } from "node:path";
|
|
38024
|
+
import { existsSync as existsSync2 } from "node:fs";
|
|
38025
|
+
import { join as join2 } from "node:path";
|
|
37859
38026
|
var resourcesDir;
|
|
37860
38027
|
function setResourcesDir(dir) {
|
|
37861
38028
|
resourcesDir = dir;
|
|
@@ -37882,25 +38049,25 @@ function getResourcesPath() {
|
|
|
37882
38049
|
function getResourcesBinPath() {
|
|
37883
38050
|
if (resourcesDir) {
|
|
37884
38051
|
const platformDir = getPlatformDir();
|
|
37885
|
-
const candidate =
|
|
37886
|
-
if (
|
|
38052
|
+
const candidate = join2(resourcesDir, "ios", "bin", platformDir);
|
|
38053
|
+
if (existsSync2(candidate)) {
|
|
37887
38054
|
return candidate;
|
|
37888
38055
|
}
|
|
37889
38056
|
}
|
|
37890
38057
|
if (process.platform === "darwin") {
|
|
37891
38058
|
const homebrewArmPath = "/opt/homebrew/bin";
|
|
37892
|
-
if (
|
|
38059
|
+
if (existsSync2(join2(homebrewArmPath, "idevice_id"))) {
|
|
37893
38060
|
return homebrewArmPath;
|
|
37894
38061
|
}
|
|
37895
38062
|
const homebrewIntelPath = "/usr/local/bin";
|
|
37896
|
-
if (
|
|
38063
|
+
if (existsSync2(join2(homebrewIntelPath, "idevice_id"))) {
|
|
37897
38064
|
return homebrewIntelPath;
|
|
37898
38065
|
}
|
|
37899
38066
|
}
|
|
37900
38067
|
if (process.platform === "linux") {
|
|
37901
38068
|
const linuxPaths = ["/usr/bin", "/usr/local/bin"];
|
|
37902
38069
|
for (const linuxPath of linuxPaths) {
|
|
37903
|
-
if (
|
|
38070
|
+
if (existsSync2(join2(linuxPath, "idevice_id"))) {
|
|
37904
38071
|
return linuxPath;
|
|
37905
38072
|
}
|
|
37906
38073
|
}
|
|
@@ -37908,250 +38075,14 @@ function getResourcesBinPath() {
|
|
|
37908
38075
|
return "";
|
|
37909
38076
|
}
|
|
37910
38077
|
|
|
37911
|
-
// src/logic/actions/tool.ts
|
|
37912
|
-
var execAsync = promisify2(execCallback);
|
|
37913
|
-
async function runIDeviceTool(toolName, args = [], options = {}) {
|
|
37914
|
-
const binPath = getResourcesBinPath();
|
|
37915
|
-
const ext = process.platform === "win32" ? ".exe" : "";
|
|
37916
|
-
const toolPath = binPath ? join2(binPath, `${toolName}${ext}`) : `${toolName}${ext}`;
|
|
37917
|
-
const command = `"${toolPath}" ${args.map((a) => `"${a}"`).join(" ")}`;
|
|
37918
|
-
return execIDevice(command, options);
|
|
37919
|
-
}
|
|
37920
|
-
async function execIDevice(command, options = {}) {
|
|
37921
|
-
const binPath = getResourcesBinPath();
|
|
37922
|
-
if (binPath) {
|
|
37923
|
-
options.cwd = binPath;
|
|
37924
|
-
}
|
|
37925
|
-
const result = await execAsync(command, {
|
|
37926
|
-
...options,
|
|
37927
|
-
env: process.env,
|
|
37928
|
-
windowsHide: true,
|
|
37929
|
-
encoding: "utf8"
|
|
37930
|
-
});
|
|
37931
|
-
return {
|
|
37932
|
-
stdout: result.stdout.toString(),
|
|
37933
|
-
stderr: result.stderr.toString()
|
|
37934
|
-
};
|
|
37935
|
-
}
|
|
37936
|
-
|
|
37937
|
-
// src/logic/actions/pair.ts
|
|
37938
|
-
var { logTask: logTask2, logInfo: logInfo3, logError: logError2 } = createLoggers("apple-kit:pair");
|
|
37939
|
-
async function isPaired(udid) {
|
|
37940
|
-
logTask2(`Checking pairing status for ${udid}`);
|
|
37941
|
-
try {
|
|
37942
|
-
const result = await runIDeviceTool("idevicepair", ["-u", udid, "validate"]);
|
|
37943
|
-
if (!result) {
|
|
37944
|
-
return false;
|
|
37945
|
-
}
|
|
37946
|
-
return result.stdout.toLowerCase().includes("success");
|
|
37947
|
-
} catch {
|
|
37948
|
-
return false;
|
|
37949
|
-
}
|
|
37950
|
-
}
|
|
37951
|
-
async function trustDevice(udid, timeout2 = 6e4, onWaitingForTrust) {
|
|
37952
|
-
logTask2(`Trusting device ${udid}`);
|
|
37953
|
-
if (await isPaired(udid)) {
|
|
37954
|
-
logInfo3(`Device ${udid} is already trusted`);
|
|
37955
|
-
return true;
|
|
37956
|
-
}
|
|
37957
|
-
logInfo3(`Initiating pairing for device ${udid}`);
|
|
37958
|
-
try {
|
|
37959
|
-
const pairResult = await pair(udid);
|
|
37960
|
-
if (pairResult) {
|
|
37961
|
-
logInfo3(`Device ${udid} paired successfully`);
|
|
37962
|
-
return true;
|
|
37963
|
-
}
|
|
37964
|
-
} catch (error) {
|
|
37965
|
-
logError2(`Pairing failed with ${udid}: ${error}`);
|
|
37966
|
-
}
|
|
37967
|
-
logInfo3("Please accept the trust dialog on the device...");
|
|
37968
|
-
onWaitingForTrust?.();
|
|
37969
|
-
try {
|
|
37970
|
-
await waitForPairing(udid, timeout2, 1e3);
|
|
37971
|
-
logInfo3(`Device ${udid} is now trusted`);
|
|
37972
|
-
return true;
|
|
37973
|
-
} catch {
|
|
37974
|
-
logInfo3(`Timeout waiting for trust acceptance on device ${udid}`);
|
|
37975
|
-
return false;
|
|
37976
|
-
}
|
|
37977
|
-
}
|
|
37978
|
-
async function waitForPairing(udid, timeout2 = 12e4, pollInterval = 1e3) {
|
|
37979
|
-
logTask2(`Waiting for pairing on device ${udid}`);
|
|
37980
|
-
const startTime = Date.now();
|
|
37981
|
-
while (Date.now() - startTime < timeout2) {
|
|
37982
|
-
if (await isPaired(udid)) {
|
|
37983
|
-
logInfo3(`Device ${udid} is now paired`);
|
|
37984
|
-
return true;
|
|
37985
|
-
}
|
|
37986
|
-
await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
|
|
37987
|
-
}
|
|
37988
|
-
throw new Error(`Timeout waiting for device pairing after ${timeout2}ms`);
|
|
37989
|
-
}
|
|
37990
|
-
async function pair(udid) {
|
|
37991
|
-
logTask2(`Initiating pairing for device ${udid}`);
|
|
37992
|
-
try {
|
|
37993
|
-
const result = await runIDeviceTool("idevicepair", ["-u", udid, "pair"]);
|
|
37994
|
-
if (!result) {
|
|
37995
|
-
return false;
|
|
37996
|
-
}
|
|
37997
|
-
return result.stdout.toLowerCase().includes("success");
|
|
37998
|
-
} catch (error) {
|
|
37999
|
-
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
38000
|
-
if (errorMsg.includes("Please accept the trust dialog")) {
|
|
38001
|
-
return false;
|
|
38002
|
-
}
|
|
38003
|
-
throw error;
|
|
38004
|
-
}
|
|
38005
|
-
}
|
|
38006
|
-
async function unpair(udid) {
|
|
38007
|
-
logTask2(`Un-pairing device ${udid}`);
|
|
38008
|
-
try {
|
|
38009
|
-
const result = await runIDeviceTool("idevicepair", ["-u", udid, "unpair"]);
|
|
38010
|
-
if (!result) {
|
|
38011
|
-
return false;
|
|
38012
|
-
}
|
|
38013
|
-
return result.stdout.toLowerCase().includes("success");
|
|
38014
|
-
} catch {
|
|
38015
|
-
return false;
|
|
38016
|
-
}
|
|
38017
|
-
}
|
|
38018
|
-
|
|
38019
|
-
// src/logic/actions/install.ts
|
|
38020
|
-
var { logTask: logTask3, logInfo: logInfo4 } = createLoggers("apple-kit:install");
|
|
38021
|
-
async function installManagedApp(ipaPath, udid, iosCli2, options) {
|
|
38022
|
-
const result = await iosCli2.installApp(udid, ipaPath);
|
|
38023
|
-
const client = await createMDMClient();
|
|
38024
|
-
logTask3("Installing app via MDM for management takeover");
|
|
38025
|
-
if (client) {
|
|
38026
|
-
await client.installApp(udid, options);
|
|
38027
|
-
}
|
|
38028
|
-
return result;
|
|
38029
|
-
}
|
|
38030
|
-
async function uninstallApp(bundleId, udid) {
|
|
38031
|
-
logTask3(`Uninstalling app ${bundleId} from device ${udid}`);
|
|
38032
|
-
if (!await isPaired(udid)) {
|
|
38033
|
-
await waitForPairing(udid, 1e4);
|
|
38034
|
-
}
|
|
38035
|
-
await runIDeviceTool("ideviceinstaller", ["-u", udid, "uninstall", bundleId]);
|
|
38036
|
-
}
|
|
38037
|
-
async function listApps(udid) {
|
|
38038
|
-
logTask3(`Listing apps on device ${udid}`);
|
|
38039
|
-
if (!await isPaired(udid)) {
|
|
38040
|
-
await waitForPairing(udid, 1e4);
|
|
38041
|
-
}
|
|
38042
|
-
try {
|
|
38043
|
-
const result = await runIDeviceTool("ideviceinstaller", ["-u", udid, "list"]);
|
|
38044
|
-
if (!result) {
|
|
38045
|
-
return [];
|
|
38046
|
-
}
|
|
38047
|
-
const { stdout } = result;
|
|
38048
|
-
return parseAppList(stdout);
|
|
38049
|
-
} catch {
|
|
38050
|
-
return [];
|
|
38051
|
-
}
|
|
38052
|
-
}
|
|
38053
|
-
async function isAppInstalled(bundleId, udid) {
|
|
38054
|
-
logTask3(`Checking if app ${bundleId} is installed on device ${udid}`);
|
|
38055
|
-
const apps = await listApps(udid);
|
|
38056
|
-
return apps.some((app) => app.bundleId === bundleId);
|
|
38057
|
-
}
|
|
38058
|
-
|
|
38059
|
-
// src/logic/actions/proxy.ts
|
|
38060
|
-
import { spawn } from "node:child_process";
|
|
38061
|
-
import { join as join3 } from "node:path";
|
|
38062
|
-
var { logTask: logTask4, logInfo: logInfo5, logError: logError3 } = createLoggers("apple-kit:proxy");
|
|
38063
|
-
function startPortForward(localPort, devicePort, udid, startupTimeout = 500) {
|
|
38064
|
-
return new Promise((resolve2, reject) => {
|
|
38065
|
-
logTask4(`Starting port forward ${localPort} -> ${devicePort} for device ${udid}`);
|
|
38066
|
-
const binPath = getResourcesBinPath();
|
|
38067
|
-
const ext = process.platform === "win32" ? ".exe" : "";
|
|
38068
|
-
const toolPath = binPath ? join3(binPath, `iproxy${ext}`) : `iproxy${ext}`;
|
|
38069
|
-
const spawnOptions = {
|
|
38070
|
-
windowsHide: true,
|
|
38071
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
38072
|
-
};
|
|
38073
|
-
if (binPath) {
|
|
38074
|
-
spawnOptions.cwd = binPath;
|
|
38075
|
-
}
|
|
38076
|
-
logInfo5(`Spawning iproxy with path: ${toolPath}`);
|
|
38077
|
-
logInfo5(`Arguments: ${[localPort.toString(), devicePort.toString(), "-u", udid].join(" ")}`);
|
|
38078
|
-
logInfo5(`Options: ${JSON.stringify(spawnOptions)}`);
|
|
38079
|
-
const child = spawn(
|
|
38080
|
-
toolPath,
|
|
38081
|
-
[localPort.toString(), devicePort.toString(), "-u", udid],
|
|
38082
|
-
spawnOptions
|
|
38083
|
-
);
|
|
38084
|
-
let hasResolved = false;
|
|
38085
|
-
let stderrOutput = "";
|
|
38086
|
-
child.stdout?.on("data", (data) => {
|
|
38087
|
-
logTask4(`${data.toString()}`);
|
|
38088
|
-
});
|
|
38089
|
-
child.stderr?.on("data", (data) => {
|
|
38090
|
-
logError3(`${data.toString()}`);
|
|
38091
|
-
const msg = data.toString();
|
|
38092
|
-
stderrOutput += msg;
|
|
38093
|
-
if (msg.toLowerCase().includes("error") && !hasResolved) {
|
|
38094
|
-
hasResolved = true;
|
|
38095
|
-
child.kill();
|
|
38096
|
-
reject(new Error(`Port forwarding failed: ${msg}`));
|
|
38097
|
-
}
|
|
38098
|
-
});
|
|
38099
|
-
child.on("error", (error) => {
|
|
38100
|
-
if (!hasResolved) {
|
|
38101
|
-
hasResolved = true;
|
|
38102
|
-
reject(new Error(`Failed to start iproxy: ${error.message}`));
|
|
38103
|
-
}
|
|
38104
|
-
});
|
|
38105
|
-
child.on("exit", (code) => {
|
|
38106
|
-
if (!hasResolved) {
|
|
38107
|
-
hasResolved = true;
|
|
38108
|
-
if (code !== 0 && code !== null) {
|
|
38109
|
-
reject(new Error(`iproxy exited with code ${code}: ${stderrOutput}`));
|
|
38110
|
-
}
|
|
38111
|
-
}
|
|
38112
|
-
});
|
|
38113
|
-
setTimeout(() => {
|
|
38114
|
-
if (!hasResolved) {
|
|
38115
|
-
hasResolved = true;
|
|
38116
|
-
logTask4(`Port forward started: ${localPort} -> ${devicePort} for device ${udid}`);
|
|
38117
|
-
resolve2({
|
|
38118
|
-
result: {
|
|
38119
|
-
localPort,
|
|
38120
|
-
devicePort
|
|
38121
|
-
},
|
|
38122
|
-
process: child
|
|
38123
|
-
});
|
|
38124
|
-
}
|
|
38125
|
-
}, startupTimeout);
|
|
38126
|
-
});
|
|
38127
|
-
}
|
|
38128
|
-
function killPortForwardProcess(process3) {
|
|
38129
|
-
if (process3 && !process3.killed) {
|
|
38130
|
-
logTask4("Killing port forward process");
|
|
38131
|
-
process3.kill();
|
|
38132
|
-
}
|
|
38133
|
-
}
|
|
38134
|
-
|
|
38135
|
-
// src/logic/activationFlow.ts
|
|
38136
|
-
import { unlink, writeFile } from "node:fs/promises";
|
|
38137
|
-
import { tmpdir } from "node:os";
|
|
38138
|
-
import { join as join5 } from "node:path";
|
|
38139
|
-
|
|
38140
|
-
// src/utils/wifiProfile.ts
|
|
38141
|
-
import { randomUUID } from "node:crypto";
|
|
38142
|
-
|
|
38143
38078
|
// src/utils/templateLoader.ts
|
|
38144
|
-
import { existsSync as existsSync2 } from "node:fs";
|
|
38145
|
-
import { readFile } from "node:fs/promises";
|
|
38146
|
-
import { dirname, isAbsolute, join as join4, resolve } from "node:path";
|
|
38147
|
-
import { fileURLToPath } from "node:url";
|
|
38148
38079
|
function resolveEnvPlistDir() {
|
|
38149
|
-
const envPath =
|
|
38150
|
-
if (!
|
|
38080
|
+
const envPath = join3(getResourcesPath(), "plist");
|
|
38081
|
+
if (!existsSync3(envPath)) {
|
|
38151
38082
|
return null;
|
|
38152
38083
|
}
|
|
38153
|
-
const absolutePath = isAbsolute(envPath) ? envPath :
|
|
38154
|
-
if (
|
|
38084
|
+
const absolutePath = isAbsolute(envPath) ? envPath : join3(process.cwd(), envPath);
|
|
38085
|
+
if (existsSync3(absolutePath)) {
|
|
38155
38086
|
return absolutePath;
|
|
38156
38087
|
}
|
|
38157
38088
|
return null;
|
|
@@ -38175,30 +38106,30 @@ function getPlistDir(overrideDir) {
|
|
|
38175
38106
|
} catch {
|
|
38176
38107
|
baseDir = process.cwd();
|
|
38177
38108
|
}
|
|
38178
|
-
const sourcePlistDir =
|
|
38179
|
-
if (
|
|
38109
|
+
const sourcePlistDir = join3(baseDir, "../plist");
|
|
38110
|
+
if (existsSync3(sourcePlistDir)) {
|
|
38180
38111
|
return sourcePlistDir;
|
|
38181
38112
|
}
|
|
38182
|
-
const distPlistDir =
|
|
38183
|
-
if (
|
|
38113
|
+
const distPlistDir = join3(baseDir, "../plist");
|
|
38114
|
+
if (existsSync3(distPlistDir)) {
|
|
38184
38115
|
return distPlistDir;
|
|
38185
38116
|
}
|
|
38186
|
-
const distPlistDir2 =
|
|
38187
|
-
if (
|
|
38117
|
+
const distPlistDir2 = join3(baseDir, "../dist/plist");
|
|
38118
|
+
if (existsSync3(distPlistDir2)) {
|
|
38188
38119
|
return distPlistDir2;
|
|
38189
38120
|
}
|
|
38190
|
-
const srcPlistFallback =
|
|
38191
|
-
if (
|
|
38121
|
+
const srcPlistFallback = join3(process.cwd(), "src/plist");
|
|
38122
|
+
if (existsSync3(srcPlistFallback)) {
|
|
38192
38123
|
return srcPlistFallback;
|
|
38193
38124
|
}
|
|
38194
|
-
const distPlistFallback =
|
|
38195
|
-
if (
|
|
38125
|
+
const distPlistFallback = join3(process.cwd(), "dist/plist");
|
|
38126
|
+
if (existsSync3(distPlistFallback)) {
|
|
38196
38127
|
return distPlistFallback;
|
|
38197
38128
|
}
|
|
38198
|
-
return
|
|
38129
|
+
return join3(process.cwd(), "src/plist");
|
|
38199
38130
|
}
|
|
38200
38131
|
async function loadTemplate(templateName, plistDir) {
|
|
38201
|
-
const templatePath =
|
|
38132
|
+
const templatePath = join3(getPlistDir(plistDir), templateName);
|
|
38202
38133
|
const content = await readFile(templatePath, "utf-8");
|
|
38203
38134
|
return content;
|
|
38204
38135
|
}
|
|
@@ -38228,7 +38159,7 @@ function escapeXml(str) {
|
|
|
38228
38159
|
}
|
|
38229
38160
|
|
|
38230
38161
|
// src/utils/wifiProfile.ts
|
|
38231
|
-
var { logInfo:
|
|
38162
|
+
var { logInfo: logInfo5 } = createLoggers("apple-kit:wifi-profile");
|
|
38232
38163
|
async function generateWifiProfile(config, options) {
|
|
38233
38164
|
const {
|
|
38234
38165
|
ssid,
|
|
@@ -38247,7 +38178,7 @@ async function generateWifiProfile(config, options) {
|
|
|
38247
38178
|
const payloadUuid = randomUUID().toUpperCase();
|
|
38248
38179
|
const profileId = `com.mce.wifi.${ssid.replace(/[^a-zA-Z0-9]/g, "")}.${Date.now()}`;
|
|
38249
38180
|
const payloadId = `${profileId}.payload`;
|
|
38250
|
-
|
|
38181
|
+
logInfo5(`Generating WiFi profile for SSID: ${ssid}, encryption: ${encryptionType}`);
|
|
38251
38182
|
const templateName = enterprise ? "wifi-enterprise.xml" : "wifi-standard.xml";
|
|
38252
38183
|
const template = await loadTemplate(templateName, options?.plistDir);
|
|
38253
38184
|
const variables = {
|
|
@@ -38286,7 +38217,7 @@ async function generateWifiProfile(config, options) {
|
|
|
38286
38217
|
async function generateWifiProfileFromEnv(options) {
|
|
38287
38218
|
const ssid = process.env.WIFI_SSID;
|
|
38288
38219
|
if (!ssid) {
|
|
38289
|
-
|
|
38220
|
+
logInfo5("WIFI_SSID not set, skipping WiFi profile generation");
|
|
38290
38221
|
return null;
|
|
38291
38222
|
}
|
|
38292
38223
|
const config = {
|
|
@@ -38298,7 +38229,7 @@ async function generateWifiProfileFromEnv(options) {
|
|
|
38298
38229
|
username: process.env.WIFI_USERNAME,
|
|
38299
38230
|
eapType: parseWifiEapType(process.env.WIFI_EAP_TYPE)
|
|
38300
38231
|
};
|
|
38301
|
-
|
|
38232
|
+
logInfo5(`Generating WiFi profile from env: SSID=${ssid}, enterprise=${config.enterprise}`);
|
|
38302
38233
|
return generateWifiProfile(config, options);
|
|
38303
38234
|
}
|
|
38304
38235
|
async function saveWifiProfileToTemp(profile) {
|
|
@@ -38309,7 +38240,7 @@ async function saveWifiProfileToTemp(profile) {
|
|
|
38309
38240
|
const fileName = `mce_wifi_${Date.now()}.mobileconfig`;
|
|
38310
38241
|
const filePath = path.join(tempDir, fileName);
|
|
38311
38242
|
await fs.writeFile(filePath, profile, "utf-8");
|
|
38312
|
-
|
|
38243
|
+
logInfo5(`WiFi profile saved to: ${filePath}`);
|
|
38313
38244
|
return filePath;
|
|
38314
38245
|
}
|
|
38315
38246
|
function getEapTypeNumber(eapType) {
|
|
@@ -38355,23 +38286,24 @@ function parseWifiEapType(value) {
|
|
|
38355
38286
|
// src/logic/activationFlow.ts
|
|
38356
38287
|
var DEFAULT_RETRIES = 150;
|
|
38357
38288
|
var DEFAULT_RETRY_DELAY_MS = 1e3;
|
|
38358
|
-
var { logTask:
|
|
38289
|
+
var { logTask: logTask3, logInfo: logInfo6, logError: logError2, setNamespace: setNamespace4 } = createLoggers("apple-kit:activation");
|
|
38359
38290
|
var ActivationFlow = class {
|
|
38360
|
-
|
|
38361
|
-
|
|
38362
|
-
|
|
38363
|
-
|
|
38291
|
+
constructor(udid, iosClient) {
|
|
38292
|
+
this.udid = udid;
|
|
38293
|
+
this.iosClient = iosClient;
|
|
38294
|
+
setNamespace4(`${udid}`);
|
|
38364
38295
|
}
|
|
38365
|
-
|
|
38296
|
+
mdmClient;
|
|
38297
|
+
async run(steps) {
|
|
38366
38298
|
this.mdmClient = await createMDMClient();
|
|
38367
|
-
|
|
38368
|
-
await this.retryActivateCommand("activate device", () => this.
|
|
38369
|
-
const wifiProfileIdentifier = await this.installWifiProfile(
|
|
38370
|
-
await this.installMdmProfile(
|
|
38371
|
-
await this.retryIosCommand("skip steps", () => this.
|
|
38372
|
-
return () => this.removeWifiProfile(
|
|
38373
|
-
}
|
|
38374
|
-
async installWifiProfile(
|
|
38299
|
+
logTask3(`Starting activation flow for device ${this.udid}`);
|
|
38300
|
+
await this.retryActivateCommand("activate device", () => this.iosClient.activate());
|
|
38301
|
+
const wifiProfileIdentifier = await this.installWifiProfile();
|
|
38302
|
+
await this.installMdmProfile();
|
|
38303
|
+
await this.retryIosCommand("skip steps", () => this.iosClient.skipSteps(steps));
|
|
38304
|
+
return () => this.removeWifiProfile(wifiProfileIdentifier);
|
|
38305
|
+
}
|
|
38306
|
+
async installWifiProfile() {
|
|
38375
38307
|
const wifiProfile = await generateWifiProfileFromEnv();
|
|
38376
38308
|
if (!wifiProfile) {
|
|
38377
38309
|
return void 0;
|
|
@@ -38380,20 +38312,20 @@ var ActivationFlow = class {
|
|
|
38380
38312
|
const wifiProfileIdentifier = getProfileIdentifierFromProfile(wifiProfile);
|
|
38381
38313
|
await this.retryIosCommand(
|
|
38382
38314
|
"install wifi profile",
|
|
38383
|
-
() => this.
|
|
38315
|
+
() => this.iosClient.installProfile(wifiProfilePath)
|
|
38384
38316
|
);
|
|
38385
38317
|
await removeTempFile(wifiProfilePath, "wifi profile");
|
|
38386
38318
|
return wifiProfileIdentifier;
|
|
38387
38319
|
}
|
|
38388
|
-
async installMdmProfile(
|
|
38389
|
-
|
|
38320
|
+
async installMdmProfile() {
|
|
38321
|
+
logTask3("Installing MDM enrollment profile");
|
|
38390
38322
|
const enrollmentProfile = await this.retry(
|
|
38391
38323
|
"generate mdm enrollment profile",
|
|
38392
38324
|
() => {
|
|
38393
38325
|
if (!this.mdmClient) {
|
|
38394
38326
|
throw new Error("MDM client not initialized");
|
|
38395
38327
|
}
|
|
38396
|
-
return this.mdmClient.generateEnrollmentProfile(udid);
|
|
38328
|
+
return this.mdmClient.generateEnrollmentProfile(this.udid);
|
|
38397
38329
|
},
|
|
38398
38330
|
(result) => result.status === "OK" && Boolean(result.profile)
|
|
38399
38331
|
);
|
|
@@ -38403,18 +38335,18 @@ var ActivationFlow = class {
|
|
|
38403
38335
|
const profilePath = await saveProfileToTemp(enrollmentProfile.profile, "mdm_profile");
|
|
38404
38336
|
await this.retryIosCommand(
|
|
38405
38337
|
"install mdm profile",
|
|
38406
|
-
() => this.
|
|
38338
|
+
() => this.iosClient.installProfile(profilePath)
|
|
38407
38339
|
);
|
|
38408
38340
|
await removeTempFile(profilePath, "mdm profile");
|
|
38409
38341
|
}
|
|
38410
|
-
async removeWifiProfile(
|
|
38342
|
+
async removeWifiProfile(profileIdentifier) {
|
|
38411
38343
|
if (!profileIdentifier) {
|
|
38412
38344
|
return;
|
|
38413
38345
|
}
|
|
38414
|
-
|
|
38346
|
+
logTask3("Removing WiFi profile");
|
|
38415
38347
|
await this.retryIosCommand(
|
|
38416
38348
|
"remove wifi profile",
|
|
38417
|
-
() => this.
|
|
38349
|
+
() => this.iosClient.removeProfile(profileIdentifier)
|
|
38418
38350
|
);
|
|
38419
38351
|
}
|
|
38420
38352
|
async retryIosCommand(label, command) {
|
|
@@ -38432,27 +38364,27 @@ var ActivationFlow = class {
|
|
|
38432
38364
|
}
|
|
38433
38365
|
} catch (error) {
|
|
38434
38366
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
38435
|
-
|
|
38367
|
+
logError2(`${label} failed: ${errorMsg}`);
|
|
38436
38368
|
}
|
|
38437
|
-
|
|
38369
|
+
logInfo6(`Retrying ${label}... ${attempt + 1} of ${retries}`);
|
|
38438
38370
|
await new Promise((resolve2) => setTimeout(resolve2, retryDelayMs));
|
|
38439
38371
|
}
|
|
38440
38372
|
throw new Error(`Failed to ${label} after ${retries} attempts`);
|
|
38441
38373
|
}
|
|
38442
38374
|
};
|
|
38443
38375
|
async function saveProfileToTemp(profile, prefix) {
|
|
38444
|
-
const tempFilePath =
|
|
38376
|
+
const tempFilePath = join4(tmpdir(), `mce_${prefix}_${Date.now()}.mobileconfig`);
|
|
38445
38377
|
await writeFile(tempFilePath, profile, "utf-8");
|
|
38446
|
-
|
|
38378
|
+
logInfo6(`Profile saved to: ${tempFilePath}`);
|
|
38447
38379
|
return tempFilePath;
|
|
38448
38380
|
}
|
|
38449
38381
|
async function removeTempFile(filePath, label) {
|
|
38450
38382
|
try {
|
|
38451
38383
|
await unlink(filePath);
|
|
38452
|
-
|
|
38384
|
+
logInfo6(`Removed ${label} temp file: ${filePath}`);
|
|
38453
38385
|
} catch (error) {
|
|
38454
38386
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
38455
|
-
|
|
38387
|
+
logError2(`Failed to remove ${label} temp file: ${errorMsg}`);
|
|
38456
38388
|
}
|
|
38457
38389
|
}
|
|
38458
38390
|
function getProfileIdentifierFromProfile(profile) {
|
|
@@ -38471,7 +38403,7 @@ function getProfileIdentifierFromProfile(profile) {
|
|
|
38471
38403
|
function resolveIosBinaryPath() {
|
|
38472
38404
|
const platform = process.platform;
|
|
38473
38405
|
const binaryName = platform === "win32" ? "ios.exe" : "ios";
|
|
38474
|
-
return
|
|
38406
|
+
return join4(getResourcesBinPath(), binaryName);
|
|
38475
38407
|
}
|
|
38476
38408
|
function isActivationSuccess(result) {
|
|
38477
38409
|
if (result.exitCode !== 0) {
|
|
@@ -38484,361 +38416,395 @@ function isActivationSuccess(result) {
|
|
|
38484
38416
|
return !hasFatal;
|
|
38485
38417
|
}
|
|
38486
38418
|
|
|
38487
|
-
// src/logic/
|
|
38488
|
-
import { spawn
|
|
38489
|
-
|
|
38490
|
-
|
|
38491
|
-
var
|
|
38492
|
-
|
|
38493
|
-
|
|
38494
|
-
if (!iosBinaryPath) {
|
|
38495
|
-
throw new Error("iosBinaryPath is required. Provide iosBinaryPath or resourcesDir.");
|
|
38496
|
-
}
|
|
38497
|
-
return createIosCli(iosBinaryPath);
|
|
38498
|
-
}
|
|
38499
|
-
if (!ios) {
|
|
38500
|
-
ios = iosCli();
|
|
38501
|
-
}
|
|
38502
|
-
function runIosCommand(iosBinaryPath, args) {
|
|
38503
|
-
return new Promise((resolve2, reject) => {
|
|
38504
|
-
logDetail(`Running command: ${iosBinaryPath} ${args.join(" ")}`);
|
|
38505
|
-
const child = spawn2(iosBinaryPath, args, {
|
|
38506
|
-
windowsHide: true,
|
|
38507
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
38508
|
-
});
|
|
38509
|
-
let stdout = "";
|
|
38510
|
-
let stderr = "";
|
|
38511
|
-
child.stdout?.on("data", (data) => {
|
|
38512
|
-
stdout += data.toString();
|
|
38513
|
-
});
|
|
38514
|
-
child.stderr?.on("data", (data) => {
|
|
38515
|
-
stderr += data.toString();
|
|
38516
|
-
});
|
|
38517
|
-
child.on("error", (error) => {
|
|
38518
|
-
reject(error);
|
|
38519
|
-
});
|
|
38520
|
-
child.on("close", (code) => {
|
|
38521
|
-
const output = stdout.split("\n").map((line) => line.trim()).filter((line) => line.length > 0).map((line) => safeParseJson(line)).filter((item) => Boolean(item));
|
|
38522
|
-
const logMessages = stderr.split("\n").map((line) => line.trim()).filter((line) => line.length > 0).map((line) => safeParseJson(line)).filter((item) => Boolean(item)).map((lineJson) => ({
|
|
38523
|
-
level: lineJson.level,
|
|
38524
|
-
msg: lineJson.msg,
|
|
38525
|
-
timestamp: lineJson.timestamp
|
|
38526
|
-
}));
|
|
38527
|
-
resolve2({
|
|
38528
|
-
command: iosBinaryPath,
|
|
38529
|
-
args,
|
|
38530
|
-
output,
|
|
38531
|
-
logMessages,
|
|
38532
|
-
exitCode: code ?? 0
|
|
38533
|
-
});
|
|
38534
|
-
});
|
|
38535
|
-
});
|
|
38536
|
-
}
|
|
38537
|
-
function safeParseJson(line) {
|
|
38538
|
-
try {
|
|
38539
|
-
const parsed = JSON.parse(line);
|
|
38540
|
-
return parsed && typeof parsed === "object" ? parsed : void 0;
|
|
38541
|
-
} catch {
|
|
38542
|
-
return void 0;
|
|
38419
|
+
// src/logic/iosClient.ts
|
|
38420
|
+
import { spawn } from "node:child_process";
|
|
38421
|
+
|
|
38422
|
+
// src/logic/profileParser.ts
|
|
38423
|
+
var ProfileParser = class {
|
|
38424
|
+
isRecord(value) {
|
|
38425
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
38543
38426
|
}
|
|
38544
|
-
|
|
38545
|
-
|
|
38546
|
-
|
|
38547
|
-
}
|
|
38548
|
-
function getStringField(record, key) {
|
|
38549
|
-
const value = record[key];
|
|
38550
|
-
return typeof value === "string" ? value : void 0;
|
|
38551
|
-
}
|
|
38552
|
-
function getBooleanField(record, key) {
|
|
38553
|
-
const value = record[key];
|
|
38554
|
-
return typeof value === "boolean" ? value : void 0;
|
|
38555
|
-
}
|
|
38556
|
-
function getNumberField(record, key) {
|
|
38557
|
-
const value = record[key];
|
|
38558
|
-
return typeof value === "number" ? value : void 0;
|
|
38559
|
-
}
|
|
38560
|
-
function getRecordField(record, key) {
|
|
38561
|
-
const value = record[key];
|
|
38562
|
-
return isRecord(value) ? value : void 0;
|
|
38563
|
-
}
|
|
38564
|
-
function toProfileManifest(record) {
|
|
38565
|
-
if (!record) {
|
|
38566
|
-
return void 0;
|
|
38427
|
+
getStringField(record, key) {
|
|
38428
|
+
const value = record[key];
|
|
38429
|
+
return typeof value === "string" ? value : void 0;
|
|
38567
38430
|
}
|
|
38568
|
-
|
|
38569
|
-
|
|
38570
|
-
|
|
38571
|
-
return void 0;
|
|
38431
|
+
getBooleanField(record, key) {
|
|
38432
|
+
const value = record[key];
|
|
38433
|
+
return typeof value === "boolean" ? value : void 0;
|
|
38572
38434
|
}
|
|
38573
|
-
|
|
38574
|
-
|
|
38575
|
-
|
|
38576
|
-
};
|
|
38577
|
-
}
|
|
38578
|
-
function toProfileMetadata(record) {
|
|
38579
|
-
if (!record) {
|
|
38580
|
-
return void 0;
|
|
38435
|
+
getNumberField(record, key) {
|
|
38436
|
+
const value = record[key];
|
|
38437
|
+
return typeof value === "number" ? value : void 0;
|
|
38581
38438
|
}
|
|
38582
|
-
|
|
38583
|
-
|
|
38584
|
-
|
|
38585
|
-
const payloadUuid = getStringField(record, "PayloadUUID");
|
|
38586
|
-
const payloadVersion = getNumberField(record, "PayloadVersion");
|
|
38587
|
-
if (payloadDescription === void 0 && payloadDisplayName === void 0 && payloadRemovalDisallowed === void 0 && payloadUuid === void 0 && payloadVersion === void 0) {
|
|
38588
|
-
return void 0;
|
|
38439
|
+
getRecordField(record, key) {
|
|
38440
|
+
const value = record[key];
|
|
38441
|
+
return this.isRecord(value) ? value : void 0;
|
|
38589
38442
|
}
|
|
38590
|
-
|
|
38591
|
-
|
|
38592
|
-
|
|
38593
|
-
|
|
38594
|
-
|
|
38595
|
-
|
|
38596
|
-
|
|
38597
|
-
|
|
38598
|
-
|
|
38599
|
-
|
|
38600
|
-
|
|
38601
|
-
|
|
38602
|
-
|
|
38603
|
-
if (!identifier && !manifest && !metadata && !status) {
|
|
38604
|
-
return void 0;
|
|
38443
|
+
toProfileManifest(record) {
|
|
38444
|
+
if (!record) {
|
|
38445
|
+
return void 0;
|
|
38446
|
+
}
|
|
38447
|
+
const description = this.getStringField(record, "Description");
|
|
38448
|
+
const isActive = this.getBooleanField(record, "IsActive");
|
|
38449
|
+
if (description === void 0 && isActive === void 0) {
|
|
38450
|
+
return void 0;
|
|
38451
|
+
}
|
|
38452
|
+
return {
|
|
38453
|
+
Description: description,
|
|
38454
|
+
IsActive: isActive
|
|
38455
|
+
};
|
|
38605
38456
|
}
|
|
38606
|
-
|
|
38607
|
-
|
|
38608
|
-
|
|
38609
|
-
|
|
38610
|
-
|
|
38611
|
-
|
|
38612
|
-
|
|
38613
|
-
|
|
38614
|
-
|
|
38615
|
-
|
|
38616
|
-
|
|
38617
|
-
|
|
38618
|
-
|
|
38619
|
-
|
|
38620
|
-
|
|
38621
|
-
|
|
38622
|
-
|
|
38623
|
-
|
|
38457
|
+
toProfileMetadata(record) {
|
|
38458
|
+
if (!record) {
|
|
38459
|
+
return void 0;
|
|
38460
|
+
}
|
|
38461
|
+
const payloadDescription = this.getStringField(record, "PayloadDescription");
|
|
38462
|
+
const payloadDisplayName = this.getStringField(record, "PayloadDisplayName");
|
|
38463
|
+
const payloadRemovalDisallowed = this.getBooleanField(record, "PayloadRemovalDisallowed");
|
|
38464
|
+
const payloadUuid = this.getStringField(record, "PayloadUUID");
|
|
38465
|
+
const payloadVersion = this.getNumberField(record, "PayloadVersion");
|
|
38466
|
+
if (payloadDescription === void 0 && payloadDisplayName === void 0 && payloadRemovalDisallowed === void 0 && payloadUuid === void 0 && payloadVersion === void 0) {
|
|
38467
|
+
return void 0;
|
|
38468
|
+
}
|
|
38469
|
+
return {
|
|
38470
|
+
PayloadDescription: payloadDescription,
|
|
38471
|
+
PayloadDisplayName: payloadDisplayName,
|
|
38472
|
+
PayloadRemovalDisallowed: payloadRemovalDisallowed,
|
|
38473
|
+
PayloadUUID: payloadUuid,
|
|
38474
|
+
PayloadVersion: payloadVersion
|
|
38475
|
+
};
|
|
38476
|
+
}
|
|
38477
|
+
toProfileListEntry(item) {
|
|
38478
|
+
const identifier = this.getStringField(item, "Identifier");
|
|
38479
|
+
const manifest = this.toProfileManifest(this.getRecordField(item, "Manifest"));
|
|
38480
|
+
const metadata = this.toProfileMetadata(this.getRecordField(item, "Metadata"));
|
|
38481
|
+
const status = this.getStringField(item, "Status");
|
|
38482
|
+
if (!identifier && !manifest && !metadata && !status) {
|
|
38483
|
+
return void 0;
|
|
38484
|
+
}
|
|
38485
|
+
return {
|
|
38486
|
+
Identifier: identifier,
|
|
38487
|
+
Manifest: manifest,
|
|
38488
|
+
Metadata: metadata,
|
|
38489
|
+
Status: status
|
|
38490
|
+
};
|
|
38491
|
+
}
|
|
38492
|
+
parseProfileListOutput(output) {
|
|
38493
|
+
const profiles = [];
|
|
38494
|
+
for (const item of output) {
|
|
38495
|
+
if (Array.isArray(item)) {
|
|
38496
|
+
for (const entry2 of item) {
|
|
38497
|
+
if (!this.isRecord(entry2)) {
|
|
38498
|
+
continue;
|
|
38499
|
+
}
|
|
38500
|
+
const profileEntry = this.toProfileListEntry(entry2);
|
|
38501
|
+
if (profileEntry) {
|
|
38502
|
+
profiles.push(profileEntry);
|
|
38503
|
+
}
|
|
38624
38504
|
}
|
|
38505
|
+
continue;
|
|
38506
|
+
}
|
|
38507
|
+
if (!this.isRecord(item)) {
|
|
38508
|
+
continue;
|
|
38509
|
+
}
|
|
38510
|
+
const entry = this.toProfileListEntry(item);
|
|
38511
|
+
if (entry) {
|
|
38512
|
+
profiles.push(entry);
|
|
38625
38513
|
}
|
|
38626
|
-
continue;
|
|
38627
|
-
}
|
|
38628
|
-
if (!isRecord(item)) {
|
|
38629
|
-
continue;
|
|
38630
38514
|
}
|
|
38631
|
-
|
|
38632
|
-
|
|
38633
|
-
|
|
38515
|
+
return profiles;
|
|
38516
|
+
}
|
|
38517
|
+
};
|
|
38518
|
+
|
|
38519
|
+
// src/logic/iosClient.ts
|
|
38520
|
+
var { logDetail: logDetail2, setNamespace: setNamespace5 } = createLoggers("");
|
|
38521
|
+
var IosClient = class {
|
|
38522
|
+
constructor(iosPath, udid, usbmuxdAddress) {
|
|
38523
|
+
this.iosPath = iosPath;
|
|
38524
|
+
this.udid = udid;
|
|
38525
|
+
this.usbmuxdAddress = usbmuxdAddress;
|
|
38526
|
+
setNamespace5(`apple-${this.udid}`);
|
|
38527
|
+
}
|
|
38528
|
+
safeParseJson(line) {
|
|
38529
|
+
try {
|
|
38530
|
+
const parsed = JSON.parse(line);
|
|
38531
|
+
return parsed && typeof parsed === "object" ? parsed : void 0;
|
|
38532
|
+
} catch {
|
|
38533
|
+
return void 0;
|
|
38634
38534
|
}
|
|
38635
38535
|
}
|
|
38636
|
-
|
|
38637
|
-
|
|
38638
|
-
|
|
38639
|
-
|
|
38640
|
-
|
|
38641
|
-
|
|
38642
|
-
|
|
38643
|
-
|
|
38644
|
-
|
|
38536
|
+
parseFsyncTreeStdout(stdout) {
|
|
38537
|
+
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);
|
|
38538
|
+
}
|
|
38539
|
+
parseIosOutput(output) {
|
|
38540
|
+
return output.split("\n").map((line) => line.trim()).filter((line) => line.length > 0).map((line) => this.safeParseJson(line)).filter((item) => Boolean(item));
|
|
38541
|
+
}
|
|
38542
|
+
spawnIosCommand(args) {
|
|
38543
|
+
logDetail2(`Running command: ${this.iosPath} ${args.join(" ")}`);
|
|
38544
|
+
logDetail2(`USBMUXD_SOCKET_ADDRESS: ${this.usbmuxdAddress}`);
|
|
38545
|
+
const child = spawn(this.iosPath, args, {
|
|
38645
38546
|
windowsHide: true,
|
|
38646
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
38647
|
-
|
|
38648
|
-
|
|
38649
|
-
|
|
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
|
-
}
|
|
38676
|
-
function createIosCli(iosBinaryPath) {
|
|
38677
|
-
return {
|
|
38678
|
-
async listDevices() {
|
|
38679
|
-
const raw = await runIosCommand(iosBinaryPath, ["list"]);
|
|
38680
|
-
const output = raw.output[0];
|
|
38681
|
-
if (!output) {
|
|
38682
|
-
throw new Error("Failed to list devices, see if usbmuxd is running");
|
|
38547
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
38548
|
+
env: {
|
|
38549
|
+
...process.env,
|
|
38550
|
+
USBMUXD_SOCKET_ADDRESS: this.usbmuxdAddress
|
|
38683
38551
|
}
|
|
38684
|
-
|
|
38685
|
-
|
|
38686
|
-
|
|
38687
|
-
|
|
38688
|
-
|
|
38689
|
-
|
|
38690
|
-
|
|
38691
|
-
|
|
38692
|
-
|
|
38693
|
-
|
|
38694
|
-
},
|
|
38695
|
-
async removeProfile(deviceId, profileName) {
|
|
38696
|
-
return runIosCommand(iosBinaryPath, ["profile", "remove", profileName, "--udid", deviceId]);
|
|
38697
|
-
},
|
|
38698
|
-
async skipSteps(deviceId, steps) {
|
|
38699
|
-
const resourcesDir2 = getResourcesPath();
|
|
38700
|
-
return runIosCommand(iosBinaryPath, [
|
|
38701
|
-
"prepare",
|
|
38702
|
-
...steps ? steps.map((step) => `--skip=${step}`) : ["--skip-all"],
|
|
38703
|
-
`--certfile=${join6(resourcesDir2, "cert.der")}`,
|
|
38704
|
-
`--orgname=${process.env.ORGANIZATION_NAME}`,
|
|
38705
|
-
"--udid",
|
|
38706
|
-
deviceId
|
|
38707
|
-
]);
|
|
38708
|
-
},
|
|
38709
|
-
async printSteps() {
|
|
38710
|
-
return runIosCommand(iosBinaryPath, ["prepare", "print-steps"]);
|
|
38711
|
-
},
|
|
38712
|
-
async activate(deviceId) {
|
|
38713
|
-
return runIosCommand(iosBinaryPath, ["activate", "--udid", deviceId]);
|
|
38714
|
-
},
|
|
38715
|
-
async pair(deviceId) {
|
|
38716
|
-
return runIosCommand(iosBinaryPath, ["pair", "--udid", deviceId]);
|
|
38717
|
-
},
|
|
38718
|
-
async forward(deviceId, fromPort, toPort) {
|
|
38719
|
-
return runIosCommand(iosBinaryPath, [
|
|
38720
|
-
"forward",
|
|
38721
|
-
`--port=${fromPort}:${toPort}`,
|
|
38722
|
-
"--udid",
|
|
38723
|
-
deviceId
|
|
38724
|
-
]);
|
|
38725
|
-
},
|
|
38726
|
-
async info(deviceId) {
|
|
38727
|
-
return runIosCommand(iosBinaryPath, ["info", "--udid", deviceId]);
|
|
38728
|
-
},
|
|
38729
|
-
async listProfiles(deviceId) {
|
|
38730
|
-
const raw = await runIosCommand(iosBinaryPath, ["profile", "list", "--udid", deviceId]);
|
|
38731
|
-
return {
|
|
38732
|
-
profiles: parseProfileListOutput(raw.output),
|
|
38733
|
-
raw
|
|
38734
|
-
};
|
|
38735
|
-
},
|
|
38736
|
-
async installApp(deviceId, ipaPath) {
|
|
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"]
|
|
38552
|
+
});
|
|
38553
|
+
return child;
|
|
38554
|
+
}
|
|
38555
|
+
runIosCommand(args) {
|
|
38556
|
+
return new Promise((resolve2, reject) => {
|
|
38557
|
+
const child = this.spawnIosCommand(args);
|
|
38558
|
+
let stdout = "";
|
|
38559
|
+
let stderr = "";
|
|
38560
|
+
child.stdout?.on("data", (data) => {
|
|
38561
|
+
stdout += data.toString();
|
|
38745
38562
|
});
|
|
38746
|
-
|
|
38747
|
-
|
|
38748
|
-
|
|
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);
|
|
38563
|
+
child.stderr?.on("data", (data) => {
|
|
38564
|
+
logDetail2(`Command data: ${data.toString()}`);
|
|
38565
|
+
stderr += data.toString();
|
|
38774
38566
|
});
|
|
38775
|
-
|
|
38776
|
-
|
|
38777
|
-
|
|
38778
|
-
|
|
38779
|
-
|
|
38780
|
-
|
|
38781
|
-
|
|
38782
|
-
|
|
38783
|
-
|
|
38784
|
-
|
|
38785
|
-
|
|
38786
|
-
|
|
38787
|
-
|
|
38788
|
-
|
|
38789
|
-
|
|
38790
|
-
|
|
38791
|
-
|
|
38792
|
-
|
|
38793
|
-
|
|
38794
|
-
|
|
38795
|
-
|
|
38796
|
-
|
|
38797
|
-
|
|
38798
|
-
|
|
38799
|
-
|
|
38800
|
-
|
|
38801
|
-
|
|
38802
|
-
|
|
38803
|
-
|
|
38804
|
-
|
|
38805
|
-
|
|
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 };
|
|
38567
|
+
child.on("error", (error) => {
|
|
38568
|
+
logDetail2(`Command error: ${error.message}`);
|
|
38569
|
+
reject(error);
|
|
38570
|
+
});
|
|
38571
|
+
child.on("close", (code) => {
|
|
38572
|
+
logDetail2(`Command closed: ${code}`);
|
|
38573
|
+
const output = this.parseIosOutput(stdout);
|
|
38574
|
+
const logMessages = this.parseIosOutput(stderr).map((item) => ({
|
|
38575
|
+
level: item.level,
|
|
38576
|
+
msg: item.msg,
|
|
38577
|
+
timestamp: item.timestamp
|
|
38578
|
+
}));
|
|
38579
|
+
resolve2({
|
|
38580
|
+
command: this.iosPath,
|
|
38581
|
+
args,
|
|
38582
|
+
output,
|
|
38583
|
+
logMessages,
|
|
38584
|
+
exitCode: code ?? 0,
|
|
38585
|
+
raw: {
|
|
38586
|
+
stdout,
|
|
38587
|
+
stderr
|
|
38588
|
+
}
|
|
38589
|
+
});
|
|
38590
|
+
});
|
|
38591
|
+
});
|
|
38592
|
+
}
|
|
38593
|
+
async listDevices() {
|
|
38594
|
+
const raw = await this.runIosCommand(["list"]);
|
|
38595
|
+
const output = raw.output[0];
|
|
38596
|
+
if (!output) {
|
|
38597
|
+
throw new Error("Failed to list devices, see if usbmuxd is running");
|
|
38817
38598
|
}
|
|
38818
|
-
|
|
38819
|
-
|
|
38599
|
+
return {
|
|
38600
|
+
udids: output.deviceList,
|
|
38601
|
+
raw
|
|
38602
|
+
};
|
|
38603
|
+
}
|
|
38604
|
+
async wipe() {
|
|
38605
|
+
return this.runIosCommand(["erase", "--force", "--udid", this.udid]);
|
|
38606
|
+
}
|
|
38607
|
+
async installProfile(profilePath) {
|
|
38608
|
+
return this.runIosCommand(["profile", "add", profilePath, "--udid", this.udid]);
|
|
38609
|
+
}
|
|
38610
|
+
async removeProfile(profileName) {
|
|
38611
|
+
return this.runIosCommand(["profile", "remove", profileName, "--udid", this.udid]);
|
|
38612
|
+
}
|
|
38613
|
+
async listProfiles() {
|
|
38614
|
+
const raw = await this.runIosCommand(["profile", "list", "--udid", this.udid]);
|
|
38615
|
+
const parser = new ProfileParser();
|
|
38616
|
+
return {
|
|
38617
|
+
profiles: parser.parseProfileListOutput(raw.output),
|
|
38618
|
+
raw
|
|
38619
|
+
};
|
|
38620
|
+
}
|
|
38621
|
+
async skipSteps(steps) {
|
|
38622
|
+
if (!process.env.CERT_FILE) {
|
|
38623
|
+
throw new Error("CERT_FILE is not set");
|
|
38624
|
+
}
|
|
38625
|
+
if (!process.env.ORGANIZATION_NAME) {
|
|
38626
|
+
throw new Error("ORGANIZATION_NAME is not set");
|
|
38627
|
+
}
|
|
38628
|
+
return this.runIosCommand([
|
|
38629
|
+
"prepare",
|
|
38630
|
+
...steps ? steps.map((step) => `--skip=${step}`) : ["--skip-all"],
|
|
38631
|
+
`--certfile=${process.env.CERT_FILE}`,
|
|
38632
|
+
`--orgname=${process.env.ORGANIZATION_NAME}`,
|
|
38633
|
+
"--udid",
|
|
38634
|
+
this.udid
|
|
38635
|
+
]);
|
|
38636
|
+
}
|
|
38637
|
+
async listSteps() {
|
|
38638
|
+
return this.runIosCommand(["prepare", "print-steps"]);
|
|
38639
|
+
}
|
|
38640
|
+
async activate() {
|
|
38641
|
+
return this.runIosCommand(["activate", "--udid", this.udid]);
|
|
38642
|
+
}
|
|
38643
|
+
async pair() {
|
|
38644
|
+
return this.runIosCommand(["pair", "--udid", this.udid]);
|
|
38645
|
+
}
|
|
38646
|
+
async forward({ fromPort, toPort }) {
|
|
38647
|
+
return this.spawnIosCommand(["forward", `--port=${fromPort}:${toPort}`, "--udid", this.udid]);
|
|
38648
|
+
}
|
|
38649
|
+
async info() {
|
|
38650
|
+
return this.runIosCommand(["info", "--udid", this.udid]);
|
|
38651
|
+
}
|
|
38652
|
+
async installApp(ipaPath) {
|
|
38653
|
+
return this.runIosCommand(["install", `--path=${ipaPath}`, "--udid", this.udid]);
|
|
38654
|
+
}
|
|
38655
|
+
async uninstallApp(bundleId) {
|
|
38656
|
+
return this.runIosCommand(["uninstall", bundleId, "--udid", this.udid]);
|
|
38657
|
+
}
|
|
38658
|
+
/*
|
|
38659
|
+
* preconditions: tunnel is started
|
|
38660
|
+
* postconditions: apps are listed
|
|
38661
|
+
* @param deviceId - the device ID
|
|
38662
|
+
* @returns the list of apps
|
|
38663
|
+
*/
|
|
38664
|
+
async listApps() {
|
|
38665
|
+
return (await this.runIosCommand(["app", "list", "--nojson", "--udid", this.udid])).raw.stdout.split("\n").map((line) => {
|
|
38666
|
+
const [bundleId, displayName, version] = line.split(" ");
|
|
38667
|
+
return {
|
|
38668
|
+
bundleId,
|
|
38669
|
+
displayName,
|
|
38670
|
+
version
|
|
38671
|
+
};
|
|
38672
|
+
});
|
|
38673
|
+
}
|
|
38674
|
+
async devMode() {
|
|
38675
|
+
return this.runIosCommand(["devmode", "enable", "--udid", this.udid]);
|
|
38676
|
+
}
|
|
38677
|
+
async tunnelStart(userspace = false) {
|
|
38678
|
+
const args = ["tunnel", "start", "--udid", this.udid, ...userspace ? ["--userspace"] : []];
|
|
38679
|
+
logDetail2(`Spawning tunnel: ${this.iosPath} ${args.join(" ")}`);
|
|
38680
|
+
const child = spawn(this.iosPath, args, {
|
|
38681
|
+
windowsHide: true,
|
|
38682
|
+
env: {
|
|
38683
|
+
...process.env,
|
|
38684
|
+
USBMUXD_SOCKET_ADDRESS: this.usbmuxdAddress
|
|
38685
|
+
},
|
|
38686
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
38687
|
+
});
|
|
38688
|
+
let settled = false;
|
|
38689
|
+
const cleanup = () => {
|
|
38690
|
+
child.off("error", onError);
|
|
38691
|
+
child.off("exit", onExit);
|
|
38692
|
+
child.stdout?.off("data", onReadyCheck);
|
|
38693
|
+
child.stderr?.off("data", onReadyCheck);
|
|
38694
|
+
clearTimeout(readyTimeout);
|
|
38695
|
+
};
|
|
38696
|
+
const finish = (result) => {
|
|
38697
|
+
if (settled) return;
|
|
38698
|
+
settled = true;
|
|
38699
|
+
cleanup();
|
|
38700
|
+
if (result.reject) throw result.reject;
|
|
38701
|
+
if (result.resolve !== void 0) return result.resolve;
|
|
38702
|
+
throw new Error("Tunnel process not found");
|
|
38703
|
+
};
|
|
38704
|
+
const onError = (err) => finish({ reject: err });
|
|
38705
|
+
const onExit = (code) => finish({ reject: new Error(`Tunnel exited early (code=${code})`) });
|
|
38706
|
+
const onReadyCheck = (data) => {
|
|
38707
|
+
const line = data.toString();
|
|
38708
|
+
const isReady = line.includes("Tunnel server started") || line.includes("tunnel") && (line.includes("listening") || line.includes("connected"));
|
|
38709
|
+
if (isReady) finish({ resolve: child });
|
|
38710
|
+
};
|
|
38711
|
+
const readyTimeout = setTimeout(() => finish({ resolve: child }), 1e4);
|
|
38712
|
+
child.once("error", onError);
|
|
38713
|
+
child.once("exit", onExit);
|
|
38714
|
+
child.stdout?.on("data", onReadyCheck);
|
|
38715
|
+
child.stderr?.on("data", onReadyCheck);
|
|
38716
|
+
return child;
|
|
38717
|
+
}
|
|
38718
|
+
async fsyncPull({
|
|
38719
|
+
app,
|
|
38720
|
+
srcPath,
|
|
38721
|
+
dstPath
|
|
38722
|
+
}) {
|
|
38723
|
+
return this.runIosCommand([
|
|
38724
|
+
"fsync",
|
|
38725
|
+
"--app",
|
|
38726
|
+
app,
|
|
38727
|
+
"pull",
|
|
38728
|
+
"--srcPath",
|
|
38729
|
+
srcPath,
|
|
38730
|
+
"--dstPath",
|
|
38731
|
+
dstPath,
|
|
38732
|
+
"--udid",
|
|
38733
|
+
this.udid
|
|
38734
|
+
]);
|
|
38735
|
+
}
|
|
38736
|
+
async fsyncPush({
|
|
38737
|
+
app,
|
|
38738
|
+
srcPath,
|
|
38739
|
+
dstPath
|
|
38740
|
+
}) {
|
|
38741
|
+
return this.runIosCommand([
|
|
38742
|
+
"fsync",
|
|
38743
|
+
"--app",
|
|
38744
|
+
app,
|
|
38745
|
+
"push",
|
|
38746
|
+
"--srcPath",
|
|
38747
|
+
srcPath,
|
|
38748
|
+
"--dstPath",
|
|
38749
|
+
dstPath,
|
|
38750
|
+
"--udid",
|
|
38751
|
+
this.udid
|
|
38752
|
+
]);
|
|
38753
|
+
}
|
|
38754
|
+
async fsyncTree({
|
|
38755
|
+
app,
|
|
38756
|
+
path
|
|
38757
|
+
}) {
|
|
38758
|
+
const args = [
|
|
38759
|
+
"fsync",
|
|
38760
|
+
"--app",
|
|
38761
|
+
app,
|
|
38762
|
+
"tree",
|
|
38763
|
+
"--udid",
|
|
38764
|
+
this.udid,
|
|
38765
|
+
...path !== void 0 && path !== "" ? ["--path", path] : []
|
|
38766
|
+
];
|
|
38767
|
+
const result = await this.runIosCommand(args);
|
|
38768
|
+
const entries = this.parseFsyncTreeStdout(result.raw.stdout);
|
|
38769
|
+
return { entries, raw: result };
|
|
38770
|
+
}
|
|
38771
|
+
};
|
|
38820
38772
|
|
|
38821
38773
|
// src/logic/appleDeviceKit.ts
|
|
38822
|
-
var { logInfo:
|
|
38774
|
+
var { logInfo: logInfo7, logError: logError3, setNamespace: setNamespace6 } = createLoggers("apple-kit");
|
|
38823
38775
|
var AppleDeviceKit = class {
|
|
38824
|
-
constructor(udid, logicalPort) {
|
|
38776
|
+
constructor(udid, logicalPort, usbmuxdAddress) {
|
|
38825
38777
|
this.logicalPort = logicalPort;
|
|
38826
38778
|
this.deviceId = udid;
|
|
38827
|
-
|
|
38828
|
-
|
|
38779
|
+
setNamespace6(`apple-${udid}`);
|
|
38780
|
+
logInfo7(
|
|
38829
38781
|
`AppleDeviceKit initialized for device: ${this.deviceId}, logical port: ${this.logicalPort}`
|
|
38830
38782
|
);
|
|
38831
38783
|
const iosBinaryPath = resolveIosBinaryPath();
|
|
38832
38784
|
if (!iosBinaryPath) {
|
|
38833
38785
|
throw new Error("iosBinaryPath is required. Provide iosBinaryPath or resourcesDir.");
|
|
38834
38786
|
}
|
|
38835
|
-
this.
|
|
38787
|
+
this.iosClient = new IosClient(iosBinaryPath, udid, usbmuxdAddress);
|
|
38788
|
+
this.deviceActions = new DeviceActions(this.deviceId, this.iosClient);
|
|
38789
|
+
this.installActions = new InstallActions(this.deviceId, this.iosClient);
|
|
38790
|
+
this.activationFlow = new ActivationFlow(this.deviceId, this.iosClient);
|
|
38791
|
+
this.proxyActions = new ProxyActions(this.deviceId, this.iosClient);
|
|
38792
|
+
this.iosClient.tunnelStart(true).then((process3) => {
|
|
38793
|
+
this.tunnelProcess = process3;
|
|
38794
|
+
}).catch((error) => {
|
|
38795
|
+
logError3(`Failed to start tunnel: ${error.message}`);
|
|
38796
|
+
});
|
|
38836
38797
|
}
|
|
38837
38798
|
deviceId;
|
|
38838
38799
|
proxyProcess = null;
|
|
38839
38800
|
localDevicePort = null;
|
|
38840
38801
|
isDisposed = false;
|
|
38841
|
-
|
|
38802
|
+
iosClient;
|
|
38803
|
+
deviceActions;
|
|
38804
|
+
installActions;
|
|
38805
|
+
activationFlow;
|
|
38806
|
+
proxyActions;
|
|
38807
|
+
tunnelProcess = null;
|
|
38842
38808
|
static setResourcesDir(dir) {
|
|
38843
38809
|
setResourcesDir(dir);
|
|
38844
38810
|
}
|
|
@@ -38852,14 +38818,18 @@ var AppleDeviceKit = class {
|
|
|
38852
38818
|
}
|
|
38853
38819
|
async info() {
|
|
38854
38820
|
this.ensureNotDisposed();
|
|
38855
|
-
return
|
|
38821
|
+
return this.deviceActions.info();
|
|
38822
|
+
}
|
|
38823
|
+
async listDevices() {
|
|
38824
|
+
this.ensureNotDisposed();
|
|
38825
|
+
return this.deviceActions.listDevices();
|
|
38856
38826
|
}
|
|
38857
38827
|
/**
|
|
38858
38828
|
* Check if device is paired/trusted with this computer
|
|
38859
38829
|
*/
|
|
38860
38830
|
async isPaired() {
|
|
38861
38831
|
this.ensureNotDisposed();
|
|
38862
|
-
return isPaired(
|
|
38832
|
+
return this.deviceActions.isPaired();
|
|
38863
38833
|
}
|
|
38864
38834
|
/**
|
|
38865
38835
|
* Wait for device to be paired
|
|
@@ -38870,7 +38840,7 @@ var AppleDeviceKit = class {
|
|
|
38870
38840
|
*/
|
|
38871
38841
|
async waitForPairing(timeout2 = 12e4, pollInterval = 1e3) {
|
|
38872
38842
|
this.ensureNotDisposed();
|
|
38873
|
-
return waitForPairing(
|
|
38843
|
+
return this.deviceActions.waitForPairing({ timeout: timeout2, pollInterval });
|
|
38874
38844
|
}
|
|
38875
38845
|
/**
|
|
38876
38846
|
* Attempt to pair/trust the device
|
|
@@ -38878,7 +38848,7 @@ var AppleDeviceKit = class {
|
|
|
38878
38848
|
*/
|
|
38879
38849
|
async pair() {
|
|
38880
38850
|
this.ensureNotDisposed();
|
|
38881
|
-
return pair(
|
|
38851
|
+
return this.deviceActions.pair();
|
|
38882
38852
|
}
|
|
38883
38853
|
/**
|
|
38884
38854
|
* Trust/pair the device - initiates pairing and waits for user to accept
|
|
@@ -38894,15 +38864,14 @@ var AppleDeviceKit = class {
|
|
|
38894
38864
|
* @returns true if device is now trusted
|
|
38895
38865
|
*/
|
|
38896
38866
|
async trustDevice(timeout2 = 6e4, onWaitingForTrust) {
|
|
38897
|
-
this.
|
|
38898
|
-
return trustDevice(this.deviceId, timeout2, onWaitingForTrust);
|
|
38867
|
+
return this.deviceActions.trustDevice({ timeout: timeout2, onWaitingForTrust });
|
|
38899
38868
|
}
|
|
38900
38869
|
/**
|
|
38901
38870
|
* Unpair/untrust the device
|
|
38902
38871
|
*/
|
|
38903
38872
|
async unpair() {
|
|
38904
38873
|
this.ensureNotDisposed();
|
|
38905
|
-
return unpair(
|
|
38874
|
+
return this.deviceActions.unpair();
|
|
38906
38875
|
}
|
|
38907
38876
|
/**
|
|
38908
38877
|
* Install an IPA file on the device (install agent)
|
|
@@ -38911,7 +38880,7 @@ var AppleDeviceKit = class {
|
|
|
38911
38880
|
*/
|
|
38912
38881
|
async installApp(ipaPath, options) {
|
|
38913
38882
|
this.ensureNotDisposed();
|
|
38914
|
-
return installManagedApp(ipaPath,
|
|
38883
|
+
return this.installActions.installManagedApp(ipaPath, options);
|
|
38915
38884
|
}
|
|
38916
38885
|
/**
|
|
38917
38886
|
* Uninstall an app by bundle ID (uninstall agent)
|
|
@@ -38920,7 +38889,7 @@ var AppleDeviceKit = class {
|
|
|
38920
38889
|
*/
|
|
38921
38890
|
async uninstallApp(bundleId) {
|
|
38922
38891
|
this.ensureNotDisposed();
|
|
38923
|
-
uninstallApp(bundleId
|
|
38892
|
+
return this.installActions.uninstallApp(bundleId);
|
|
38924
38893
|
}
|
|
38925
38894
|
/**
|
|
38926
38895
|
* Check if an app is installed on the device
|
|
@@ -38929,14 +38898,14 @@ var AppleDeviceKit = class {
|
|
|
38929
38898
|
*/
|
|
38930
38899
|
async isAppInstalled(bundleId) {
|
|
38931
38900
|
this.ensureNotDisposed();
|
|
38932
|
-
return isAppInstalled(bundleId
|
|
38901
|
+
return this.installActions.isAppInstalled(bundleId);
|
|
38933
38902
|
}
|
|
38934
38903
|
/**
|
|
38935
38904
|
* List all installed user applications
|
|
38936
38905
|
*/
|
|
38937
38906
|
async listApps() {
|
|
38938
38907
|
this.ensureNotDisposed();
|
|
38939
|
-
return listApps(
|
|
38908
|
+
return this.installActions.listApps();
|
|
38940
38909
|
}
|
|
38941
38910
|
/**
|
|
38942
38911
|
* Start port forwarding and wait for it to be ready.
|
|
@@ -38952,17 +38921,11 @@ var AppleDeviceKit = class {
|
|
|
38952
38921
|
* @param startupTimeout Time to wait for proxy to start (ms)
|
|
38953
38922
|
* @returns The port forward result with the allocated local port
|
|
38954
38923
|
*/
|
|
38955
|
-
async startPortForwardAsync(devicePort
|
|
38924
|
+
async startPortForwardAsync(devicePort) {
|
|
38956
38925
|
this.ensureNotDisposed();
|
|
38957
38926
|
this.killProxyProcess();
|
|
38958
38927
|
this.localDevicePort = await getPorts({ port: portNumbers(3e4, 31e3) });
|
|
38959
|
-
const
|
|
38960
|
-
this.localDevicePort,
|
|
38961
|
-
devicePort,
|
|
38962
|
-
this.deviceId,
|
|
38963
|
-
startupTimeout
|
|
38964
|
-
);
|
|
38965
|
-
this.proxyProcess = process3;
|
|
38928
|
+
const result = await this.proxyActions.startPortForward(this.localDevicePort, devicePort);
|
|
38966
38929
|
return result;
|
|
38967
38930
|
}
|
|
38968
38931
|
/**
|
|
@@ -38970,7 +38933,7 @@ var AppleDeviceKit = class {
|
|
|
38970
38933
|
*/
|
|
38971
38934
|
killProxyProcess() {
|
|
38972
38935
|
if (this.proxyProcess) {
|
|
38973
|
-
|
|
38936
|
+
this.proxyActions.killPortForward();
|
|
38974
38937
|
this.proxyProcess = null;
|
|
38975
38938
|
}
|
|
38976
38939
|
}
|
|
@@ -38983,24 +38946,17 @@ var AppleDeviceKit = class {
|
|
|
38983
38946
|
this.localDevicePort = null;
|
|
38984
38947
|
}
|
|
38985
38948
|
}
|
|
38986
|
-
/**
|
|
38987
|
-
* Get the activation state of the device
|
|
38988
|
-
*/
|
|
38989
|
-
async getActivationState() {
|
|
38990
|
-
this.ensureNotDisposed();
|
|
38991
|
-
return getActivationState(this.deviceId, this.iosCli);
|
|
38992
|
-
}
|
|
38993
38949
|
/**
|
|
38994
38950
|
* Wipe the device
|
|
38995
38951
|
*/
|
|
38996
38952
|
async wipe() {
|
|
38997
|
-
return
|
|
38953
|
+
return this.deviceActions.wipe();
|
|
38998
38954
|
}
|
|
38999
38955
|
async removeProfile(profileIdentifier) {
|
|
39000
|
-
return removeProfile(profileIdentifier
|
|
38956
|
+
return this.deviceActions.removeProfile(profileIdentifier);
|
|
39001
38957
|
}
|
|
39002
38958
|
async listProfiles() {
|
|
39003
|
-
return
|
|
38959
|
+
return this.deviceActions.listProfiles();
|
|
39004
38960
|
}
|
|
39005
38961
|
/**
|
|
39006
38962
|
* Activate the device using the activation flow.
|
|
@@ -39013,8 +38969,7 @@ var AppleDeviceKit = class {
|
|
|
39013
38969
|
*/
|
|
39014
38970
|
async activate() {
|
|
39015
38971
|
this.ensureNotDisposed();
|
|
39016
|
-
|
|
39017
|
-
return await flow.run(this.deviceId);
|
|
38972
|
+
return this.activationFlow.run();
|
|
39018
38973
|
}
|
|
39019
38974
|
/**
|
|
39020
38975
|
* Get the device UDID
|
|
@@ -39057,8 +39012,9 @@ var AppleDeviceKit = class {
|
|
|
39057
39012
|
if (this.isDisposed) {
|
|
39058
39013
|
return;
|
|
39059
39014
|
}
|
|
39060
|
-
|
|
39015
|
+
logInfo7(`Disposing AppleDeviceKit for device: ${this.deviceId}`);
|
|
39061
39016
|
this.closePortForward();
|
|
39017
|
+
this.tunnelProcess?.kill();
|
|
39062
39018
|
this.isDisposed = true;
|
|
39063
39019
|
}
|
|
39064
39020
|
/**
|
|
@@ -39071,8 +39027,7 @@ var AppleDeviceKit = class {
|
|
|
39071
39027
|
export {
|
|
39072
39028
|
ActivationFlow,
|
|
39073
39029
|
AppleDeviceKit,
|
|
39074
|
-
|
|
39075
|
-
iosCli
|
|
39030
|
+
IosClient
|
|
39076
39031
|
};
|
|
39077
39032
|
/*! Bundled license information:
|
|
39078
39033
|
|