@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.js
CHANGED
|
@@ -32,8 +32,7 @@ var index_exports = {};
|
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
ActivationFlow: () => ActivationFlow,
|
|
34
34
|
AppleDeviceKit: () => AppleDeviceKit,
|
|
35
|
-
|
|
36
|
-
iosCli: () => iosCli
|
|
35
|
+
IosClient: () => IosClient
|
|
37
36
|
});
|
|
38
37
|
module.exports = __toCommonJS(index_exports);
|
|
39
38
|
|
|
@@ -867,52 +866,52 @@ var require_src = __commonJS({
|
|
|
867
866
|
});
|
|
868
867
|
var import_debug = __toESM2(require_src());
|
|
869
868
|
function createLoggers(namespace, logLevel = process.env.LOG_LEVEL ?? "none") {
|
|
870
|
-
const
|
|
871
|
-
const
|
|
872
|
-
const
|
|
873
|
-
const
|
|
869
|
+
const logInfo8 = (0, import_debug.default)(`${namespace}:info`);
|
|
870
|
+
const logTask4 = (0, import_debug.default)(`${namespace}:task`);
|
|
871
|
+
const logError4 = (0, import_debug.default)(`${namespace}:error`);
|
|
872
|
+
const logDetail3 = (0, import_debug.default)(`${namespace}:detail`);
|
|
874
873
|
const logDebug = (0, import_debug.default)(`${namespace}:debug`);
|
|
875
874
|
const logWarning2 = (0, import_debug.default)(`${namespace}:warning`);
|
|
876
875
|
const logColor = (0, import_debug.default)(`${namespace}:color`);
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
876
|
+
logInfo8.color = "19";
|
|
877
|
+
logTask4.color = "25";
|
|
878
|
+
logError4.color = "1";
|
|
879
|
+
logDetail3.color = "199";
|
|
881
880
|
logWarning2.color = "186";
|
|
882
881
|
logDebug.color = "211";
|
|
883
882
|
logColor.enabled = true;
|
|
884
|
-
function
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
883
|
+
function setNamespace7(namespace2) {
|
|
884
|
+
logInfo8.namespace = `${namespace2}:info`;
|
|
885
|
+
logTask4.namespace = `${namespace2}:task`;
|
|
886
|
+
logError4.namespace = `${namespace2}:error`;
|
|
887
|
+
logDetail3.namespace = `${namespace2}:detail`;
|
|
889
888
|
logWarning2.namespace = `${namespace2}:warning`;
|
|
890
889
|
logDebug.namespace = `${namespace2}:debug`;
|
|
891
890
|
}
|
|
892
891
|
function setLogLevel(level) {
|
|
893
892
|
switch (level) {
|
|
894
893
|
case "info":
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
894
|
+
logInfo8.enabled = true;
|
|
895
|
+
logTask4.enabled = true;
|
|
896
|
+
logError4.enabled = true;
|
|
898
897
|
logWarning2.enabled = true;
|
|
899
|
-
|
|
898
|
+
logDetail3.enabled = false;
|
|
900
899
|
logDebug.enabled = false;
|
|
901
900
|
break;
|
|
902
901
|
case "debug":
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
902
|
+
logInfo8.enabled = true;
|
|
903
|
+
logTask4.enabled = true;
|
|
904
|
+
logError4.enabled = true;
|
|
906
905
|
logWarning2.enabled = true;
|
|
907
|
-
|
|
906
|
+
logDetail3.enabled = true;
|
|
908
907
|
logDebug.enabled = true;
|
|
909
908
|
break;
|
|
910
909
|
case "none":
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
910
|
+
logInfo8.enabled = false;
|
|
911
|
+
logTask4.enabled = false;
|
|
912
|
+
logError4.enabled = false;
|
|
914
913
|
logWarning2.enabled = false;
|
|
915
|
-
|
|
914
|
+
logDetail3.enabled = false;
|
|
916
915
|
logDebug.enabled = false;
|
|
917
916
|
break;
|
|
918
917
|
}
|
|
@@ -921,16 +920,16 @@ function createLoggers(namespace, logLevel = process.env.LOG_LEVEL ?? "none") {
|
|
|
921
920
|
function setColors(type, color) {
|
|
922
921
|
switch (type) {
|
|
923
922
|
case "info":
|
|
924
|
-
|
|
923
|
+
logInfo8.color = color;
|
|
925
924
|
break;
|
|
926
925
|
case "task":
|
|
927
|
-
|
|
926
|
+
logTask4.color = color;
|
|
928
927
|
break;
|
|
929
928
|
case "error":
|
|
930
|
-
|
|
929
|
+
logError4.color = color;
|
|
931
930
|
break;
|
|
932
931
|
case "detail":
|
|
933
|
-
|
|
932
|
+
logDetail3.color = color;
|
|
934
933
|
break;
|
|
935
934
|
case "warning":
|
|
936
935
|
logWarning2.color = color;
|
|
@@ -969,7 +968,7 @@ function createLoggers(namespace, logLevel = process.env.LOG_LEVEL ?? "none") {
|
|
|
969
968
|
`;
|
|
970
969
|
} else if (typeof value === "object") {
|
|
971
970
|
result += `
|
|
972
|
-
|
|
971
|
+
${logDataDetail(value, `${prefix} `)}
|
|
973
972
|
`;
|
|
974
973
|
} else {
|
|
975
974
|
result += `${value}
|
|
@@ -986,9 +985,9 @@ ${" ".repeat(40 - title.length / 2)}${title}
|
|
|
986
985
|
${" ".repeat(padding)}${"=".repeat(80)}`;
|
|
987
986
|
}
|
|
988
987
|
function logHeader(title) {
|
|
989
|
-
|
|
988
|
+
logInfo8(`${header(title, 2)}`);
|
|
990
989
|
}
|
|
991
|
-
function
|
|
990
|
+
function logDataObject3(title, ...args) {
|
|
992
991
|
const stack = new Error().stack?.split("\n")[2] || "";
|
|
993
992
|
const stackMatch = stack.match(/\((.*):(\d+):(\d+)\)$/) || stack.match(/at (.*):(\d+):(\d+)$/);
|
|
994
993
|
let callerDetails = "";
|
|
@@ -997,7 +996,7 @@ ${" ".repeat(padding)}${"=".repeat(80)}`;
|
|
|
997
996
|
const functionName = functionMatch ? functionMatch[1] : "<anonymous>";
|
|
998
997
|
callerDetails = `${functionName}`;
|
|
999
998
|
}
|
|
1000
|
-
|
|
999
|
+
logDetail3(`${header(`*${title}* ${callerDetails}`)}
|
|
1001
1000
|
${args.reduce((acc, arg) => `${acc}
|
|
1002
1001
|
${logDataDetail(arg)}`, "")}
|
|
1003
1002
|
|
|
@@ -1005,32 +1004,32 @@ ${"=".repeat(80)}`);
|
|
|
1005
1004
|
}
|
|
1006
1005
|
function logErrorObject(error, extraDetails) {
|
|
1007
1006
|
if (error instanceof Error) {
|
|
1008
|
-
|
|
1007
|
+
logError4(`${extraDetails ? header(extraDetails, 1) : header(error.message, 1)}
|
|
1009
1008
|
Error Message:
|
|
1010
1009
|
${error.message}
|
|
1011
1010
|
Error Stack:
|
|
1012
1011
|
${error.stack}
|
|
1013
1012
|
${"=".repeat(80)}`);
|
|
1014
1013
|
} else {
|
|
1015
|
-
|
|
1014
|
+
logError4(`${extraDetails ? header(extraDetails, 1) : header(String(error), 1)}
|
|
1016
1015
|
${"=".repeat(80)}`);
|
|
1017
1016
|
}
|
|
1018
1017
|
}
|
|
1019
1018
|
return {
|
|
1020
|
-
logInfo:
|
|
1021
|
-
logTask:
|
|
1022
|
-
logError:
|
|
1023
|
-
logDetail:
|
|
1019
|
+
logInfo: logInfo8,
|
|
1020
|
+
logTask: logTask4,
|
|
1021
|
+
logError: logError4,
|
|
1022
|
+
logDetail: logDetail3,
|
|
1024
1023
|
logDebug,
|
|
1025
1024
|
logWarning: logWarning2,
|
|
1026
1025
|
logColor,
|
|
1027
1026
|
setColors,
|
|
1028
1027
|
printColors,
|
|
1029
1028
|
logHeader,
|
|
1030
|
-
logDataObject:
|
|
1029
|
+
logDataObject: logDataObject3,
|
|
1031
1030
|
logErrorObject,
|
|
1032
1031
|
setLogLevel,
|
|
1033
|
-
setNamespace:
|
|
1032
|
+
setNamespace: setNamespace7
|
|
1034
1033
|
};
|
|
1035
1034
|
}
|
|
1036
1035
|
|
|
@@ -1170,35 +1169,125 @@ function portNumbers(from, to) {
|
|
|
1170
1169
|
}
|
|
1171
1170
|
|
|
1172
1171
|
// src/logic/actions/device.ts
|
|
1173
|
-
var
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
};
|
|
1189
|
-
}
|
|
1190
|
-
async function wipeDevice(udid, iosCli2) {
|
|
1191
|
-
logTask(`Wiping device ${udid}`);
|
|
1192
|
-
await iosCli2.wipe(udid);
|
|
1193
|
-
}
|
|
1194
|
-
async function removeProfile(profileIdentifier, udid, iosCli2) {
|
|
1195
|
-
logTask(`Removing profile ${profileIdentifier} from device ${udid}`);
|
|
1196
|
-
await iosCli2.removeProfile(udid, profileIdentifier);
|
|
1197
|
-
}
|
|
1198
|
-
async function listProfiles(udid, iosCli2) {
|
|
1199
|
-
logTask(`Listing profiles for device ${udid}`);
|
|
1200
|
-
return iosCli2.listProfiles(udid);
|
|
1172
|
+
var import_node_fs = require("node:fs");
|
|
1173
|
+
var import_node_fs2 = require("node:fs");
|
|
1174
|
+
var import_node_path = require("node:path");
|
|
1175
|
+
var { logTask, logInfo, logDetail, setNamespace, logDataObject } = createLoggers("apple-kit:device");
|
|
1176
|
+
function getAppleLockdownPath() {
|
|
1177
|
+
if (process.platform === "win32") {
|
|
1178
|
+
return (0, import_node_path.join)(process.env.ProgramData ?? "C:\\ProgramData", "Apple", "Lockdown");
|
|
1179
|
+
}
|
|
1180
|
+
if (process.platform === "darwin") {
|
|
1181
|
+
return "/var/db/lockdown";
|
|
1182
|
+
}
|
|
1183
|
+
if (process.platform === "linux") {
|
|
1184
|
+
return "/var/lib/lockdown";
|
|
1185
|
+
}
|
|
1186
|
+
return null;
|
|
1201
1187
|
}
|
|
1188
|
+
var DeviceActions = class {
|
|
1189
|
+
constructor(udid, iosClient) {
|
|
1190
|
+
this.udid = udid;
|
|
1191
|
+
this.iosClient = iosClient;
|
|
1192
|
+
setNamespace(`apple-${udid}`);
|
|
1193
|
+
}
|
|
1194
|
+
async info() {
|
|
1195
|
+
logInfo(`Getting device info for ${this.udid}`);
|
|
1196
|
+
const result = await this.iosClient.info();
|
|
1197
|
+
if (!result) {
|
|
1198
|
+
throw new Error("Failed to get device info");
|
|
1199
|
+
}
|
|
1200
|
+
return result.output[0];
|
|
1201
|
+
}
|
|
1202
|
+
async listDevices() {
|
|
1203
|
+
logInfo("Listing devices");
|
|
1204
|
+
return this.iosClient.listDevices();
|
|
1205
|
+
}
|
|
1206
|
+
async wipe() {
|
|
1207
|
+
logInfo(`Wiping device ${this.udid}`);
|
|
1208
|
+
await this.iosClient.wipe();
|
|
1209
|
+
}
|
|
1210
|
+
async removeProfile(profileIdentifier) {
|
|
1211
|
+
logInfo(`Removing profile ${profileIdentifier} from device ${this.udid}`);
|
|
1212
|
+
await this.iosClient.removeProfile(profileIdentifier);
|
|
1213
|
+
}
|
|
1214
|
+
async listProfiles() {
|
|
1215
|
+
logInfo(`Listing profiles for device ${this.udid}`);
|
|
1216
|
+
return this.iosClient.listProfiles();
|
|
1217
|
+
}
|
|
1218
|
+
async pair() {
|
|
1219
|
+
logInfo(`Pairing device ${this.udid}`);
|
|
1220
|
+
const result = await this.iosClient.pair();
|
|
1221
|
+
if (!result) {
|
|
1222
|
+
return false;
|
|
1223
|
+
}
|
|
1224
|
+
logDataObject("IOS pair results", { result });
|
|
1225
|
+
return result.raw.stderr.includes("Successfully paired");
|
|
1226
|
+
}
|
|
1227
|
+
async isPaired() {
|
|
1228
|
+
logInfo(`Checking if device ${this.udid} is paired`);
|
|
1229
|
+
try {
|
|
1230
|
+
const deviceInfo = await this.info();
|
|
1231
|
+
const trusted = deviceInfo.TrustedHostAttached === true;
|
|
1232
|
+
logDetail(`Device ${this.udid} TrustedHostAttached: ${trusted}`);
|
|
1233
|
+
return trusted;
|
|
1234
|
+
} catch (error) {
|
|
1235
|
+
logDetail(`Device ${this.udid} info failed (not paired or unreachable): ${error}`);
|
|
1236
|
+
return false;
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
async trustDevice({
|
|
1240
|
+
timeout: timeout2 = 6e4,
|
|
1241
|
+
onWaitingForTrust
|
|
1242
|
+
}) {
|
|
1243
|
+
logInfo(`Trusting device ${this.udid}`);
|
|
1244
|
+
if (await this.isPaired()) {
|
|
1245
|
+
logInfo(`Device ${this.udid} is already trusted (lockdown file exists)`);
|
|
1246
|
+
return true;
|
|
1247
|
+
}
|
|
1248
|
+
logInfo("Initiating pairing to show trust dialog on device...");
|
|
1249
|
+
await this.pair();
|
|
1250
|
+
logInfo("Please accept the trust dialog on the device...");
|
|
1251
|
+
onWaitingForTrust?.();
|
|
1252
|
+
try {
|
|
1253
|
+
await this.waitForPairing({ timeout: timeout2, pollInterval: 1e3 });
|
|
1254
|
+
logInfo(`Device ${this.udid} is now trusted`);
|
|
1255
|
+
return true;
|
|
1256
|
+
} catch {
|
|
1257
|
+
logInfo(`Timeout waiting for trust acceptance on device ${this.udid}`);
|
|
1258
|
+
return false;
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
async waitForPairing({
|
|
1262
|
+
timeout: timeout2 = 12e4,
|
|
1263
|
+
pollInterval = 1e3
|
|
1264
|
+
}) {
|
|
1265
|
+
logTask(`Waiting for pairing on device ${this.udid}`);
|
|
1266
|
+
const startTime = Date.now();
|
|
1267
|
+
while (Date.now() - startTime < timeout2) {
|
|
1268
|
+
if (await this.isPaired()) {
|
|
1269
|
+
logInfo(`Device ${this.udid} is now paired`);
|
|
1270
|
+
return true;
|
|
1271
|
+
}
|
|
1272
|
+
await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
|
|
1273
|
+
}
|
|
1274
|
+
throw new Error(`Timeout waiting for device pairing after ${timeout2}ms`);
|
|
1275
|
+
}
|
|
1276
|
+
async unpair() {
|
|
1277
|
+
logInfo(`Un-pairing device ${this.udid}`);
|
|
1278
|
+
const lockdownDir = getAppleLockdownPath();
|
|
1279
|
+
if (!lockdownDir) {
|
|
1280
|
+
throw new Error("Cannot determine lockdown directory for this platform");
|
|
1281
|
+
}
|
|
1282
|
+
const lockdownFile = (0, import_node_path.join)(lockdownDir, `${this.udid}.plist`);
|
|
1283
|
+
if (!(0, import_node_fs.existsSync)(lockdownFile)) {
|
|
1284
|
+
logInfo(`Lockdown file ${lockdownFile} not found, device is not paired`);
|
|
1285
|
+
return false;
|
|
1286
|
+
}
|
|
1287
|
+
(0, import_node_fs2.rmSync)(lockdownFile, { force: true });
|
|
1288
|
+
return true;
|
|
1289
|
+
}
|
|
1290
|
+
};
|
|
1202
1291
|
|
|
1203
1292
|
// ../mdm-client/dist/index.mjs
|
|
1204
1293
|
var import_node_crypto = require("node:crypto");
|
|
@@ -15315,16 +15404,16 @@ var require_printer = __commonJS2({
|
|
|
15315
15404
|
},
|
|
15316
15405
|
// Document
|
|
15317
15406
|
Document: {
|
|
15318
|
-
leave: (node) =>
|
|
15407
|
+
leave: (node) => join5(node.definitions, "\n\n")
|
|
15319
15408
|
},
|
|
15320
15409
|
OperationDefinition: {
|
|
15321
15410
|
leave(node) {
|
|
15322
|
-
const varDefs = hasMultilineItems(node.variableDefinitions) ? wrap("(\n",
|
|
15323
|
-
const prefix = wrap("", node.description, "\n") +
|
|
15411
|
+
const varDefs = hasMultilineItems(node.variableDefinitions) ? wrap("(\n", join5(node.variableDefinitions, "\n"), "\n)") : wrap("(", join5(node.variableDefinitions, ", "), ")");
|
|
15412
|
+
const prefix = wrap("", node.description, "\n") + join5(
|
|
15324
15413
|
[
|
|
15325
15414
|
node.operation,
|
|
15326
|
-
|
|
15327
|
-
|
|
15415
|
+
join5([node.name, varDefs]),
|
|
15416
|
+
join5(node.directives, " ")
|
|
15328
15417
|
],
|
|
15329
15418
|
" "
|
|
15330
15419
|
);
|
|
@@ -15332,7 +15421,7 @@ var require_printer = __commonJS2({
|
|
|
15332
15421
|
}
|
|
15333
15422
|
},
|
|
15334
15423
|
VariableDefinition: {
|
|
15335
|
-
leave: ({ variable, type, defaultValue, directives, description }) => wrap("", description, "\n") + variable + ": " + type + wrap(" = ", defaultValue) + wrap(" ",
|
|
15424
|
+
leave: ({ variable, type, defaultValue, directives, description }) => wrap("", description, "\n") + variable + ": " + type + wrap(" = ", defaultValue) + wrap(" ", join5(directives, " "))
|
|
15336
15425
|
},
|
|
15337
15426
|
SelectionSet: {
|
|
15338
15427
|
leave: ({ selections }) => block(selections)
|
|
@@ -15340,11 +15429,11 @@ var require_printer = __commonJS2({
|
|
|
15340
15429
|
Field: {
|
|
15341
15430
|
leave({ alias, name, arguments: args, directives, selectionSet }) {
|
|
15342
15431
|
const prefix = wrap("", alias, ": ") + name;
|
|
15343
|
-
let argsLine = prefix + wrap("(",
|
|
15432
|
+
let argsLine = prefix + wrap("(", join5(args, ", "), ")");
|
|
15344
15433
|
if (argsLine.length > MAX_LINE_LENGTH) {
|
|
15345
|
-
argsLine = prefix + wrap("(\n", indent(
|
|
15434
|
+
argsLine = prefix + wrap("(\n", indent(join5(args, "\n")), "\n)");
|
|
15346
15435
|
}
|
|
15347
|
-
return
|
|
15436
|
+
return join5([argsLine, join5(directives, " "), selectionSet], " ");
|
|
15348
15437
|
}
|
|
15349
15438
|
},
|
|
15350
15439
|
Argument: {
|
|
@@ -15352,14 +15441,14 @@ var require_printer = __commonJS2({
|
|
|
15352
15441
|
},
|
|
15353
15442
|
// Fragments
|
|
15354
15443
|
FragmentSpread: {
|
|
15355
|
-
leave: ({ name, directives }) => "..." + name + wrap(" ",
|
|
15444
|
+
leave: ({ name, directives }) => "..." + name + wrap(" ", join5(directives, " "))
|
|
15356
15445
|
},
|
|
15357
15446
|
InlineFragment: {
|
|
15358
|
-
leave: ({ typeCondition, directives, selectionSet }) =>
|
|
15447
|
+
leave: ({ typeCondition, directives, selectionSet }) => join5(
|
|
15359
15448
|
[
|
|
15360
15449
|
"...",
|
|
15361
15450
|
wrap("on ", typeCondition),
|
|
15362
|
-
|
|
15451
|
+
join5(directives, " "),
|
|
15363
15452
|
selectionSet
|
|
15364
15453
|
],
|
|
15365
15454
|
" "
|
|
@@ -15375,7 +15464,7 @@ var require_printer = __commonJS2({
|
|
|
15375
15464
|
description
|
|
15376
15465
|
}) => wrap("", description, "\n") + // Note: fragment variable definitions are experimental and may be changed
|
|
15377
15466
|
// or removed in the future.
|
|
15378
|
-
`fragment ${name}${wrap("(",
|
|
15467
|
+
`fragment ${name}${wrap("(", join5(variableDefinitions, ", "), ")")} on ${typeCondition} ${wrap("", join5(directives, " "), " ")}` + selectionSet
|
|
15379
15468
|
},
|
|
15380
15469
|
// Value
|
|
15381
15470
|
IntValue: {
|
|
@@ -15397,17 +15486,17 @@ var require_printer = __commonJS2({
|
|
|
15397
15486
|
leave: ({ value }) => value
|
|
15398
15487
|
},
|
|
15399
15488
|
ListValue: {
|
|
15400
|
-
leave: ({ values }) => "[" +
|
|
15489
|
+
leave: ({ values }) => "[" + join5(values, ", ") + "]"
|
|
15401
15490
|
},
|
|
15402
15491
|
ObjectValue: {
|
|
15403
|
-
leave: ({ fields }) => "{" +
|
|
15492
|
+
leave: ({ fields }) => "{" + join5(fields, ", ") + "}"
|
|
15404
15493
|
},
|
|
15405
15494
|
ObjectField: {
|
|
15406
15495
|
leave: ({ name, value }) => name + ": " + value
|
|
15407
15496
|
},
|
|
15408
15497
|
// Directive
|
|
15409
15498
|
Directive: {
|
|
15410
|
-
leave: ({ name, arguments: args }) => "@" + name + wrap("(",
|
|
15499
|
+
leave: ({ name, arguments: args }) => "@" + name + wrap("(", join5(args, ", "), ")")
|
|
15411
15500
|
},
|
|
15412
15501
|
// Type
|
|
15413
15502
|
NamedType: {
|
|
@@ -15421,138 +15510,138 @@ var require_printer = __commonJS2({
|
|
|
15421
15510
|
},
|
|
15422
15511
|
// Type System Definitions
|
|
15423
15512
|
SchemaDefinition: {
|
|
15424
|
-
leave: ({ description, directives, operationTypes }) => wrap("", description, "\n") +
|
|
15513
|
+
leave: ({ description, directives, operationTypes }) => wrap("", description, "\n") + join5(["schema", join5(directives, " "), block(operationTypes)], " ")
|
|
15425
15514
|
},
|
|
15426
15515
|
OperationTypeDefinition: {
|
|
15427
15516
|
leave: ({ operation, type }) => operation + ": " + type
|
|
15428
15517
|
},
|
|
15429
15518
|
ScalarTypeDefinition: {
|
|
15430
|
-
leave: ({ description, name, directives }) => wrap("", description, "\n") +
|
|
15519
|
+
leave: ({ description, name, directives }) => wrap("", description, "\n") + join5(["scalar", name, join5(directives, " ")], " ")
|
|
15431
15520
|
},
|
|
15432
15521
|
ObjectTypeDefinition: {
|
|
15433
|
-
leave: ({ description, name, interfaces, directives, fields }) => wrap("", description, "\n") +
|
|
15522
|
+
leave: ({ description, name, interfaces, directives, fields }) => wrap("", description, "\n") + join5(
|
|
15434
15523
|
[
|
|
15435
15524
|
"type",
|
|
15436
15525
|
name,
|
|
15437
|
-
wrap("implements ",
|
|
15438
|
-
|
|
15526
|
+
wrap("implements ", join5(interfaces, " & ")),
|
|
15527
|
+
join5(directives, " "),
|
|
15439
15528
|
block(fields)
|
|
15440
15529
|
],
|
|
15441
15530
|
" "
|
|
15442
15531
|
)
|
|
15443
15532
|
},
|
|
15444
15533
|
FieldDefinition: {
|
|
15445
|
-
leave: ({ description, name, arguments: args, type, directives }) => wrap("", description, "\n") + name + (hasMultilineItems(args) ? wrap("(\n", indent(
|
|
15534
|
+
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, " "))
|
|
15446
15535
|
},
|
|
15447
15536
|
InputValueDefinition: {
|
|
15448
|
-
leave: ({ description, name, type, defaultValue, directives }) => wrap("", description, "\n") +
|
|
15449
|
-
[name + ": " + type, wrap("= ", defaultValue),
|
|
15537
|
+
leave: ({ description, name, type, defaultValue, directives }) => wrap("", description, "\n") + join5(
|
|
15538
|
+
[name + ": " + type, wrap("= ", defaultValue), join5(directives, " ")],
|
|
15450
15539
|
" "
|
|
15451
15540
|
)
|
|
15452
15541
|
},
|
|
15453
15542
|
InterfaceTypeDefinition: {
|
|
15454
|
-
leave: ({ description, name, interfaces, directives, fields }) => wrap("", description, "\n") +
|
|
15543
|
+
leave: ({ description, name, interfaces, directives, fields }) => wrap("", description, "\n") + join5(
|
|
15455
15544
|
[
|
|
15456
15545
|
"interface",
|
|
15457
15546
|
name,
|
|
15458
|
-
wrap("implements ",
|
|
15459
|
-
|
|
15547
|
+
wrap("implements ", join5(interfaces, " & ")),
|
|
15548
|
+
join5(directives, " "),
|
|
15460
15549
|
block(fields)
|
|
15461
15550
|
],
|
|
15462
15551
|
" "
|
|
15463
15552
|
)
|
|
15464
15553
|
},
|
|
15465
15554
|
UnionTypeDefinition: {
|
|
15466
|
-
leave: ({ description, name, directives, types }) => wrap("", description, "\n") +
|
|
15467
|
-
["union", name,
|
|
15555
|
+
leave: ({ description, name, directives, types }) => wrap("", description, "\n") + join5(
|
|
15556
|
+
["union", name, join5(directives, " "), wrap("= ", join5(types, " | "))],
|
|
15468
15557
|
" "
|
|
15469
15558
|
)
|
|
15470
15559
|
},
|
|
15471
15560
|
EnumTypeDefinition: {
|
|
15472
|
-
leave: ({ description, name, directives, values }) => wrap("", description, "\n") +
|
|
15561
|
+
leave: ({ description, name, directives, values }) => wrap("", description, "\n") + join5(["enum", name, join5(directives, " "), block(values)], " ")
|
|
15473
15562
|
},
|
|
15474
15563
|
EnumValueDefinition: {
|
|
15475
|
-
leave: ({ description, name, directives }) => wrap("", description, "\n") +
|
|
15564
|
+
leave: ({ description, name, directives }) => wrap("", description, "\n") + join5([name, join5(directives, " ")], " ")
|
|
15476
15565
|
},
|
|
15477
15566
|
InputObjectTypeDefinition: {
|
|
15478
|
-
leave: ({ description, name, directives, fields }) => wrap("", description, "\n") +
|
|
15567
|
+
leave: ({ description, name, directives, fields }) => wrap("", description, "\n") + join5(["input", name, join5(directives, " "), block(fields)], " ")
|
|
15479
15568
|
},
|
|
15480
15569
|
DirectiveDefinition: {
|
|
15481
|
-
leave: ({ description, name, arguments: args, repeatable, locations }) => wrap("", description, "\n") + "directive @" + name + (hasMultilineItems(args) ? wrap("(\n", indent(
|
|
15570
|
+
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, " | ")
|
|
15482
15571
|
},
|
|
15483
15572
|
SchemaExtension: {
|
|
15484
|
-
leave: ({ directives, operationTypes }) =>
|
|
15485
|
-
["extend schema",
|
|
15573
|
+
leave: ({ directives, operationTypes }) => join5(
|
|
15574
|
+
["extend schema", join5(directives, " "), block(operationTypes)],
|
|
15486
15575
|
" "
|
|
15487
15576
|
)
|
|
15488
15577
|
},
|
|
15489
15578
|
ScalarTypeExtension: {
|
|
15490
|
-
leave: ({ name, directives }) =>
|
|
15579
|
+
leave: ({ name, directives }) => join5(["extend scalar", name, join5(directives, " ")], " ")
|
|
15491
15580
|
},
|
|
15492
15581
|
ObjectTypeExtension: {
|
|
15493
|
-
leave: ({ name, interfaces, directives, fields }) =>
|
|
15582
|
+
leave: ({ name, interfaces, directives, fields }) => join5(
|
|
15494
15583
|
[
|
|
15495
15584
|
"extend type",
|
|
15496
15585
|
name,
|
|
15497
|
-
wrap("implements ",
|
|
15498
|
-
|
|
15586
|
+
wrap("implements ", join5(interfaces, " & ")),
|
|
15587
|
+
join5(directives, " "),
|
|
15499
15588
|
block(fields)
|
|
15500
15589
|
],
|
|
15501
15590
|
" "
|
|
15502
15591
|
)
|
|
15503
15592
|
},
|
|
15504
15593
|
InterfaceTypeExtension: {
|
|
15505
|
-
leave: ({ name, interfaces, directives, fields }) =>
|
|
15594
|
+
leave: ({ name, interfaces, directives, fields }) => join5(
|
|
15506
15595
|
[
|
|
15507
15596
|
"extend interface",
|
|
15508
15597
|
name,
|
|
15509
|
-
wrap("implements ",
|
|
15510
|
-
|
|
15598
|
+
wrap("implements ", join5(interfaces, " & ")),
|
|
15599
|
+
join5(directives, " "),
|
|
15511
15600
|
block(fields)
|
|
15512
15601
|
],
|
|
15513
15602
|
" "
|
|
15514
15603
|
)
|
|
15515
15604
|
},
|
|
15516
15605
|
UnionTypeExtension: {
|
|
15517
|
-
leave: ({ name, directives, types }) =>
|
|
15606
|
+
leave: ({ name, directives, types }) => join5(
|
|
15518
15607
|
[
|
|
15519
15608
|
"extend union",
|
|
15520
15609
|
name,
|
|
15521
|
-
|
|
15522
|
-
wrap("= ",
|
|
15610
|
+
join5(directives, " "),
|
|
15611
|
+
wrap("= ", join5(types, " | "))
|
|
15523
15612
|
],
|
|
15524
15613
|
" "
|
|
15525
15614
|
)
|
|
15526
15615
|
},
|
|
15527
15616
|
EnumTypeExtension: {
|
|
15528
|
-
leave: ({ name, directives, values }) =>
|
|
15617
|
+
leave: ({ name, directives, values }) => join5(["extend enum", name, join5(directives, " "), block(values)], " ")
|
|
15529
15618
|
},
|
|
15530
15619
|
InputObjectTypeExtension: {
|
|
15531
|
-
leave: ({ name, directives, fields }) =>
|
|
15620
|
+
leave: ({ name, directives, fields }) => join5(["extend input", name, join5(directives, " "), block(fields)], " ")
|
|
15532
15621
|
},
|
|
15533
15622
|
// Schema Coordinates
|
|
15534
15623
|
TypeCoordinate: {
|
|
15535
15624
|
leave: ({ name }) => name
|
|
15536
15625
|
},
|
|
15537
15626
|
MemberCoordinate: {
|
|
15538
|
-
leave: ({ name, memberName }) =>
|
|
15627
|
+
leave: ({ name, memberName }) => join5([name, wrap(".", memberName)])
|
|
15539
15628
|
},
|
|
15540
15629
|
ArgumentCoordinate: {
|
|
15541
|
-
leave: ({ name, fieldName, argumentName }) =>
|
|
15630
|
+
leave: ({ name, fieldName, argumentName }) => join5([name, wrap(".", fieldName), wrap("(", argumentName, ":)")])
|
|
15542
15631
|
},
|
|
15543
15632
|
DirectiveCoordinate: {
|
|
15544
|
-
leave: ({ name }) =>
|
|
15633
|
+
leave: ({ name }) => join5(["@", name])
|
|
15545
15634
|
},
|
|
15546
15635
|
DirectiveArgumentCoordinate: {
|
|
15547
|
-
leave: ({ name, argumentName }) =>
|
|
15636
|
+
leave: ({ name, argumentName }) => join5(["@", name, wrap("(", argumentName, ":)")])
|
|
15548
15637
|
}
|
|
15549
15638
|
};
|
|
15550
|
-
function
|
|
15639
|
+
function join5(maybeArray, separator = "") {
|
|
15551
15640
|
var _maybeArray$filter$jo;
|
|
15552
15641
|
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 : "";
|
|
15553
15642
|
}
|
|
15554
15643
|
function block(array) {
|
|
15555
|
-
return wrap("{\n", indent(
|
|
15644
|
+
return wrap("{\n", indent(join5(array, "\n")), "\n}");
|
|
15556
15645
|
}
|
|
15557
15646
|
function wrap(start, maybeString, end = "") {
|
|
15558
15647
|
return maybeString != null && maybeString !== "" ? start + maybeString + end : "";
|
|
@@ -22799,7 +22888,7 @@ var require_execute = __commonJS2({
|
|
|
22799
22888
|
}
|
|
22800
22889
|
const returnType = fieldDef.type;
|
|
22801
22890
|
const resolveFn = (_fieldDef$resolve = fieldDef.resolve) !== null && _fieldDef$resolve !== void 0 ? _fieldDef$resolve : exeContext.fieldResolver;
|
|
22802
|
-
const
|
|
22891
|
+
const info = buildResolveInfo(
|
|
22803
22892
|
exeContext,
|
|
22804
22893
|
fieldDef,
|
|
22805
22894
|
fieldNodes,
|
|
@@ -22813,18 +22902,18 @@ var require_execute = __commonJS2({
|
|
|
22813
22902
|
exeContext.variableValues
|
|
22814
22903
|
);
|
|
22815
22904
|
const contextValue = exeContext.contextValue;
|
|
22816
|
-
const result = resolveFn(source, args, contextValue,
|
|
22905
|
+
const result = resolveFn(source, args, contextValue, info);
|
|
22817
22906
|
let completed;
|
|
22818
22907
|
if ((0, _isPromise.isPromise)(result)) {
|
|
22819
22908
|
completed = result.then(
|
|
22820
|
-
(resolved) => completeValue(exeContext, returnType, fieldNodes,
|
|
22909
|
+
(resolved) => completeValue(exeContext, returnType, fieldNodes, info, path, resolved)
|
|
22821
22910
|
);
|
|
22822
22911
|
} else {
|
|
22823
22912
|
completed = completeValue(
|
|
22824
22913
|
exeContext,
|
|
22825
22914
|
returnType,
|
|
22826
22915
|
fieldNodes,
|
|
22827
|
-
|
|
22916
|
+
info,
|
|
22828
22917
|
path,
|
|
22829
22918
|
result
|
|
22830
22919
|
);
|
|
@@ -22870,7 +22959,7 @@ var require_execute = __commonJS2({
|
|
|
22870
22959
|
exeContext.errors.push(error);
|
|
22871
22960
|
return null;
|
|
22872
22961
|
}
|
|
22873
|
-
function completeValue(exeContext, returnType, fieldNodes,
|
|
22962
|
+
function completeValue(exeContext, returnType, fieldNodes, info, path, result) {
|
|
22874
22963
|
if (result instanceof Error) {
|
|
22875
22964
|
throw result;
|
|
22876
22965
|
}
|
|
@@ -22879,13 +22968,13 @@ var require_execute = __commonJS2({
|
|
|
22879
22968
|
exeContext,
|
|
22880
22969
|
returnType.ofType,
|
|
22881
22970
|
fieldNodes,
|
|
22882
|
-
|
|
22971
|
+
info,
|
|
22883
22972
|
path,
|
|
22884
22973
|
result
|
|
22885
22974
|
);
|
|
22886
22975
|
if (completed === null) {
|
|
22887
22976
|
throw new Error(
|
|
22888
|
-
`Cannot return null for non-nullable field ${
|
|
22977
|
+
`Cannot return null for non-nullable field ${info.parentType.name}.${info.fieldName}.`
|
|
22889
22978
|
);
|
|
22890
22979
|
}
|
|
22891
22980
|
return completed;
|
|
@@ -22898,7 +22987,7 @@ var require_execute = __commonJS2({
|
|
|
22898
22987
|
exeContext,
|
|
22899
22988
|
returnType,
|
|
22900
22989
|
fieldNodes,
|
|
22901
|
-
|
|
22990
|
+
info,
|
|
22902
22991
|
path,
|
|
22903
22992
|
result
|
|
22904
22993
|
);
|
|
@@ -22911,7 +23000,7 @@ var require_execute = __commonJS2({
|
|
|
22911
23000
|
exeContext,
|
|
22912
23001
|
returnType,
|
|
22913
23002
|
fieldNodes,
|
|
22914
|
-
|
|
23003
|
+
info,
|
|
22915
23004
|
path,
|
|
22916
23005
|
result
|
|
22917
23006
|
);
|
|
@@ -22921,7 +23010,7 @@ var require_execute = __commonJS2({
|
|
|
22921
23010
|
exeContext,
|
|
22922
23011
|
returnType,
|
|
22923
23012
|
fieldNodes,
|
|
22924
|
-
|
|
23013
|
+
info,
|
|
22925
23014
|
path,
|
|
22926
23015
|
result
|
|
22927
23016
|
);
|
|
@@ -22931,10 +23020,10 @@ var require_execute = __commonJS2({
|
|
|
22931
23020
|
"Cannot complete value of unexpected output type: " + (0, _inspect.inspect)(returnType)
|
|
22932
23021
|
);
|
|
22933
23022
|
}
|
|
22934
|
-
function completeListValue(exeContext, returnType, fieldNodes,
|
|
23023
|
+
function completeListValue(exeContext, returnType, fieldNodes, info, path, result) {
|
|
22935
23024
|
if (!(0, _isIterableObject.isIterableObject)(result)) {
|
|
22936
23025
|
throw new _GraphQLError.GraphQLError(
|
|
22937
|
-
`Expected Iterable, but did not find one for field "${
|
|
23026
|
+
`Expected Iterable, but did not find one for field "${info.parentType.name}.${info.fieldName}".`
|
|
22938
23027
|
);
|
|
22939
23028
|
}
|
|
22940
23029
|
const itemType = returnType.ofType;
|
|
@@ -22949,7 +23038,7 @@ var require_execute = __commonJS2({
|
|
|
22949
23038
|
exeContext,
|
|
22950
23039
|
itemType,
|
|
22951
23040
|
fieldNodes,
|
|
22952
|
-
|
|
23041
|
+
info,
|
|
22953
23042
|
itemPath,
|
|
22954
23043
|
resolved
|
|
22955
23044
|
)
|
|
@@ -22959,7 +23048,7 @@ var require_execute = __commonJS2({
|
|
|
22959
23048
|
exeContext,
|
|
22960
23049
|
itemType,
|
|
22961
23050
|
fieldNodes,
|
|
22962
|
-
|
|
23051
|
+
info,
|
|
22963
23052
|
itemPath,
|
|
22964
23053
|
item
|
|
22965
23054
|
);
|
|
@@ -22998,11 +23087,11 @@ var require_execute = __commonJS2({
|
|
|
22998
23087
|
}
|
|
22999
23088
|
return serializedResult;
|
|
23000
23089
|
}
|
|
23001
|
-
function completeAbstractValue(exeContext, returnType, fieldNodes,
|
|
23090
|
+
function completeAbstractValue(exeContext, returnType, fieldNodes, info, path, result) {
|
|
23002
23091
|
var _returnType$resolveTy;
|
|
23003
23092
|
const resolveTypeFn = (_returnType$resolveTy = returnType.resolveType) !== null && _returnType$resolveTy !== void 0 ? _returnType$resolveTy : exeContext.typeResolver;
|
|
23004
23093
|
const contextValue = exeContext.contextValue;
|
|
23005
|
-
const runtimeType = resolveTypeFn(result, contextValue,
|
|
23094
|
+
const runtimeType = resolveTypeFn(result, contextValue, info, returnType);
|
|
23006
23095
|
if ((0, _isPromise.isPromise)(runtimeType)) {
|
|
23007
23096
|
return runtimeType.then(
|
|
23008
23097
|
(resolvedRuntimeType) => completeObjectValue(
|
|
@@ -23012,11 +23101,11 @@ var require_execute = __commonJS2({
|
|
|
23012
23101
|
exeContext,
|
|
23013
23102
|
returnType,
|
|
23014
23103
|
fieldNodes,
|
|
23015
|
-
|
|
23104
|
+
info,
|
|
23016
23105
|
result
|
|
23017
23106
|
),
|
|
23018
23107
|
fieldNodes,
|
|
23019
|
-
|
|
23108
|
+
info,
|
|
23020
23109
|
path,
|
|
23021
23110
|
result
|
|
23022
23111
|
)
|
|
@@ -23029,19 +23118,19 @@ var require_execute = __commonJS2({
|
|
|
23029
23118
|
exeContext,
|
|
23030
23119
|
returnType,
|
|
23031
23120
|
fieldNodes,
|
|
23032
|
-
|
|
23121
|
+
info,
|
|
23033
23122
|
result
|
|
23034
23123
|
),
|
|
23035
23124
|
fieldNodes,
|
|
23036
|
-
|
|
23125
|
+
info,
|
|
23037
23126
|
path,
|
|
23038
23127
|
result
|
|
23039
23128
|
);
|
|
23040
23129
|
}
|
|
23041
|
-
function ensureValidRuntimeType(runtimeTypeName, exeContext, returnType, fieldNodes,
|
|
23130
|
+
function ensureValidRuntimeType(runtimeTypeName, exeContext, returnType, fieldNodes, info, result) {
|
|
23042
23131
|
if (runtimeTypeName == null) {
|
|
23043
23132
|
throw new _GraphQLError.GraphQLError(
|
|
23044
|
-
`Abstract type "${returnType.name}" must resolve to an Object type at runtime for field "${
|
|
23133
|
+
`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.`,
|
|
23045
23134
|
fieldNodes
|
|
23046
23135
|
);
|
|
23047
23136
|
}
|
|
@@ -23052,7 +23141,7 @@ var require_execute = __commonJS2({
|
|
|
23052
23141
|
}
|
|
23053
23142
|
if (typeof runtimeTypeName !== "string") {
|
|
23054
23143
|
throw new _GraphQLError.GraphQLError(
|
|
23055
|
-
`Abstract type "${returnType.name}" must resolve to an Object type at runtime for field "${
|
|
23144
|
+
`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)}".`
|
|
23056
23145
|
);
|
|
23057
23146
|
}
|
|
23058
23147
|
const runtimeType = exeContext.schema.getType(runtimeTypeName);
|
|
@@ -23082,10 +23171,10 @@ var require_execute = __commonJS2({
|
|
|
23082
23171
|
}
|
|
23083
23172
|
return runtimeType;
|
|
23084
23173
|
}
|
|
23085
|
-
function completeObjectValue(exeContext, returnType, fieldNodes,
|
|
23174
|
+
function completeObjectValue(exeContext, returnType, fieldNodes, info, path, result) {
|
|
23086
23175
|
const subFieldNodes = collectSubfields(exeContext, returnType, fieldNodes);
|
|
23087
23176
|
if (returnType.isTypeOf) {
|
|
23088
|
-
const isTypeOf = returnType.isTypeOf(result, exeContext.contextValue,
|
|
23177
|
+
const isTypeOf = returnType.isTypeOf(result, exeContext.contextValue, info);
|
|
23089
23178
|
if ((0, _isPromise.isPromise)(isTypeOf)) {
|
|
23090
23179
|
return isTypeOf.then((resolvedIsTypeOf) => {
|
|
23091
23180
|
if (!resolvedIsTypeOf) {
|
|
@@ -23114,16 +23203,16 @@ var require_execute = __commonJS2({
|
|
|
23114
23203
|
}
|
|
23115
23204
|
);
|
|
23116
23205
|
}
|
|
23117
|
-
var defaultTypeResolver = function(value, contextValue,
|
|
23206
|
+
var defaultTypeResolver = function(value, contextValue, info, abstractType) {
|
|
23118
23207
|
if ((0, _isObjectLike.isObjectLike)(value) && typeof value.__typename === "string") {
|
|
23119
23208
|
return value.__typename;
|
|
23120
23209
|
}
|
|
23121
|
-
const possibleTypes =
|
|
23210
|
+
const possibleTypes = info.schema.getPossibleTypes(abstractType);
|
|
23122
23211
|
const promisedIsTypeOfResults = [];
|
|
23123
23212
|
for (let i = 0; i < possibleTypes.length; i++) {
|
|
23124
23213
|
const type = possibleTypes[i];
|
|
23125
23214
|
if (type.isTypeOf) {
|
|
23126
|
-
const isTypeOfResult = type.isTypeOf(value, contextValue,
|
|
23215
|
+
const isTypeOfResult = type.isTypeOf(value, contextValue, info);
|
|
23127
23216
|
if ((0, _isPromise.isPromise)(isTypeOfResult)) {
|
|
23128
23217
|
promisedIsTypeOfResults[i] = isTypeOfResult;
|
|
23129
23218
|
} else if (isTypeOfResult) {
|
|
@@ -23146,11 +23235,11 @@ var require_execute = __commonJS2({
|
|
|
23146
23235
|
}
|
|
23147
23236
|
};
|
|
23148
23237
|
exports2.defaultTypeResolver = defaultTypeResolver;
|
|
23149
|
-
var defaultFieldResolver = function(source, args, contextValue,
|
|
23238
|
+
var defaultFieldResolver = function(source, args, contextValue, info) {
|
|
23150
23239
|
if ((0, _isObjectLike.isObjectLike)(source) || typeof source === "function") {
|
|
23151
|
-
const property = source[
|
|
23240
|
+
const property = source[info.fieldName];
|
|
23152
23241
|
if (typeof property === "function") {
|
|
23153
|
-
return source[
|
|
23242
|
+
return source[info.fieldName](args, contextValue, info);
|
|
23154
23243
|
}
|
|
23155
23244
|
return property;
|
|
23156
23245
|
}
|
|
@@ -24177,7 +24266,7 @@ var require_subscribe = __commonJS2({
|
|
|
24177
24266
|
);
|
|
24178
24267
|
}
|
|
24179
24268
|
const path = (0, _Path.addPath)(void 0, responseName, rootType.name);
|
|
24180
|
-
const
|
|
24269
|
+
const info = (0, _execute.buildResolveInfo)(
|
|
24181
24270
|
exeContext,
|
|
24182
24271
|
fieldDef,
|
|
24183
24272
|
fieldNodes,
|
|
@@ -24193,7 +24282,7 @@ var require_subscribe = __commonJS2({
|
|
|
24193
24282
|
);
|
|
24194
24283
|
const contextValue = exeContext.contextValue;
|
|
24195
24284
|
const resolveFn = (_fieldDef$subscribe = fieldDef.subscribe) !== null && _fieldDef$subscribe !== void 0 ? _fieldDef$subscribe : exeContext.subscribeFieldResolver;
|
|
24196
|
-
const eventStream = await resolveFn(rootValue, args, contextValue,
|
|
24285
|
+
const eventStream = await resolveFn(rootValue, args, contextValue, info);
|
|
24197
24286
|
if (eventStream instanceof Error) {
|
|
24198
24287
|
throw eventStream;
|
|
24199
24288
|
}
|
|
@@ -34354,17 +34443,17 @@ var require_lib3 = __commonJS2({
|
|
|
34354
34443
|
throw new TypeError("Header pairs must be iterable");
|
|
34355
34444
|
}
|
|
34356
34445
|
const pairs = [];
|
|
34357
|
-
for (const
|
|
34358
|
-
if (typeof
|
|
34446
|
+
for (const pair of init) {
|
|
34447
|
+
if (typeof pair !== "object" || typeof pair[Symbol.iterator] !== "function") {
|
|
34359
34448
|
throw new TypeError("Each header pair must be iterable");
|
|
34360
34449
|
}
|
|
34361
|
-
pairs.push(Array.from(
|
|
34450
|
+
pairs.push(Array.from(pair));
|
|
34362
34451
|
}
|
|
34363
|
-
for (const
|
|
34364
|
-
if (
|
|
34452
|
+
for (const pair of pairs) {
|
|
34453
|
+
if (pair.length !== 2) {
|
|
34365
34454
|
throw new TypeError("Each header pair must be a name/value tuple");
|
|
34366
34455
|
}
|
|
34367
|
-
this.append(
|
|
34456
|
+
this.append(pair[0], pair[1]);
|
|
34368
34457
|
}
|
|
34369
34458
|
} else {
|
|
34370
34459
|
for (const key of Object.keys(init)) {
|
|
@@ -36515,52 +36604,52 @@ var require_src2 = __commonJS22({
|
|
|
36515
36604
|
});
|
|
36516
36605
|
var import_debug2 = __toESM22(require_src2());
|
|
36517
36606
|
function createLoggers2(namespace, logLevel = process.env.LOG_LEVEL ?? "none") {
|
|
36518
|
-
const
|
|
36519
|
-
const
|
|
36607
|
+
const logInfo222 = (0, import_debug2.default)(`${namespace}:info`);
|
|
36608
|
+
const logTask4 = (0, import_debug2.default)(`${namespace}:task`);
|
|
36520
36609
|
const logError22 = (0, import_debug2.default)(`${namespace}:error`);
|
|
36521
|
-
const
|
|
36610
|
+
const logDetail3 = (0, import_debug2.default)(`${namespace}:detail`);
|
|
36522
36611
|
const logDebug = (0, import_debug2.default)(`${namespace}:debug`);
|
|
36523
36612
|
const logWarning2 = (0, import_debug2.default)(`${namespace}:warning`);
|
|
36524
36613
|
const logColor = (0, import_debug2.default)(`${namespace}:color`);
|
|
36525
|
-
|
|
36526
|
-
|
|
36614
|
+
logInfo222.color = "19";
|
|
36615
|
+
logTask4.color = "25";
|
|
36527
36616
|
logError22.color = "1";
|
|
36528
|
-
|
|
36617
|
+
logDetail3.color = "199";
|
|
36529
36618
|
logWarning2.color = "186";
|
|
36530
36619
|
logDebug.color = "211";
|
|
36531
36620
|
logColor.enabled = true;
|
|
36532
|
-
function
|
|
36533
|
-
|
|
36534
|
-
|
|
36621
|
+
function setNamespace7(namespace2) {
|
|
36622
|
+
logInfo222.namespace = `${namespace2}:info`;
|
|
36623
|
+
logTask4.namespace = `${namespace2}:task`;
|
|
36535
36624
|
logError22.namespace = `${namespace2}:error`;
|
|
36536
|
-
|
|
36625
|
+
logDetail3.namespace = `${namespace2}:detail`;
|
|
36537
36626
|
logWarning2.namespace = `${namespace2}:warning`;
|
|
36538
36627
|
logDebug.namespace = `${namespace2}:debug`;
|
|
36539
36628
|
}
|
|
36540
36629
|
function setLogLevel(level) {
|
|
36541
36630
|
switch (level) {
|
|
36542
36631
|
case "info":
|
|
36543
|
-
|
|
36544
|
-
|
|
36632
|
+
logInfo222.enabled = true;
|
|
36633
|
+
logTask4.enabled = true;
|
|
36545
36634
|
logError22.enabled = true;
|
|
36546
36635
|
logWarning2.enabled = true;
|
|
36547
|
-
|
|
36636
|
+
logDetail3.enabled = false;
|
|
36548
36637
|
logDebug.enabled = false;
|
|
36549
36638
|
break;
|
|
36550
36639
|
case "debug":
|
|
36551
|
-
|
|
36552
|
-
|
|
36640
|
+
logInfo222.enabled = true;
|
|
36641
|
+
logTask4.enabled = true;
|
|
36553
36642
|
logError22.enabled = true;
|
|
36554
36643
|
logWarning2.enabled = true;
|
|
36555
|
-
|
|
36644
|
+
logDetail3.enabled = true;
|
|
36556
36645
|
logDebug.enabled = true;
|
|
36557
36646
|
break;
|
|
36558
36647
|
case "none":
|
|
36559
|
-
|
|
36560
|
-
|
|
36648
|
+
logInfo222.enabled = false;
|
|
36649
|
+
logTask4.enabled = false;
|
|
36561
36650
|
logError22.enabled = false;
|
|
36562
36651
|
logWarning2.enabled = false;
|
|
36563
|
-
|
|
36652
|
+
logDetail3.enabled = false;
|
|
36564
36653
|
logDebug.enabled = false;
|
|
36565
36654
|
break;
|
|
36566
36655
|
}
|
|
@@ -36569,16 +36658,16 @@ function createLoggers2(namespace, logLevel = process.env.LOG_LEVEL ?? "none") {
|
|
|
36569
36658
|
function setColors(type, color) {
|
|
36570
36659
|
switch (type) {
|
|
36571
36660
|
case "info":
|
|
36572
|
-
|
|
36661
|
+
logInfo222.color = color;
|
|
36573
36662
|
break;
|
|
36574
36663
|
case "task":
|
|
36575
|
-
|
|
36664
|
+
logTask4.color = color;
|
|
36576
36665
|
break;
|
|
36577
36666
|
case "error":
|
|
36578
36667
|
logError22.color = color;
|
|
36579
36668
|
break;
|
|
36580
36669
|
case "detail":
|
|
36581
|
-
|
|
36670
|
+
logDetail3.color = color;
|
|
36582
36671
|
break;
|
|
36583
36672
|
case "warning":
|
|
36584
36673
|
logWarning2.color = color;
|
|
@@ -36617,7 +36706,7 @@ function createLoggers2(namespace, logLevel = process.env.LOG_LEVEL ?? "none") {
|
|
|
36617
36706
|
`;
|
|
36618
36707
|
} else if (typeof value === "object") {
|
|
36619
36708
|
result += `
|
|
36620
|
-
|
|
36709
|
+
${logDataDetail(value, `${prefix} `)}
|
|
36621
36710
|
`;
|
|
36622
36711
|
} else {
|
|
36623
36712
|
result += `${value}
|
|
@@ -36634,9 +36723,9 @@ ${" ".repeat(40 - title.length / 2)}${title}
|
|
|
36634
36723
|
${" ".repeat(padding)}${"=".repeat(80)}`;
|
|
36635
36724
|
}
|
|
36636
36725
|
function logHeader(title) {
|
|
36637
|
-
|
|
36726
|
+
logInfo222(`${header(title, 2)}`);
|
|
36638
36727
|
}
|
|
36639
|
-
function
|
|
36728
|
+
function logDataObject22(title, ...args) {
|
|
36640
36729
|
const stack = new Error().stack?.split("\n")[2] || "";
|
|
36641
36730
|
const stackMatch = stack.match(/\((.*):(\d+):(\d+)\)$/) || stack.match(/at (.*):(\d+):(\d+)$/);
|
|
36642
36731
|
let callerDetails = "";
|
|
@@ -36645,7 +36734,7 @@ ${" ".repeat(padding)}${"=".repeat(80)}`;
|
|
|
36645
36734
|
const functionName = functionMatch ? functionMatch[1] : "<anonymous>";
|
|
36646
36735
|
callerDetails = `${functionName}`;
|
|
36647
36736
|
}
|
|
36648
|
-
|
|
36737
|
+
logDetail3(`${header(`*${title}* ${callerDetails}`)}
|
|
36649
36738
|
${args.reduce((acc, arg) => `${acc}
|
|
36650
36739
|
${logDataDetail(arg)}`, "")}
|
|
36651
36740
|
|
|
@@ -36665,20 +36754,20 @@ ${"=".repeat(80)}`);
|
|
|
36665
36754
|
}
|
|
36666
36755
|
}
|
|
36667
36756
|
return {
|
|
36668
|
-
logInfo:
|
|
36669
|
-
logTask:
|
|
36757
|
+
logInfo: logInfo222,
|
|
36758
|
+
logTask: logTask4,
|
|
36670
36759
|
logError: logError22,
|
|
36671
|
-
logDetail:
|
|
36760
|
+
logDetail: logDetail3,
|
|
36672
36761
|
logDebug,
|
|
36673
36762
|
logWarning: logWarning2,
|
|
36674
36763
|
logColor,
|
|
36675
36764
|
setColors,
|
|
36676
36765
|
printColors,
|
|
36677
36766
|
logHeader,
|
|
36678
|
-
logDataObject:
|
|
36767
|
+
logDataObject: logDataObject22,
|
|
36679
36768
|
logErrorObject,
|
|
36680
36769
|
setLogLevel,
|
|
36681
|
-
setNamespace:
|
|
36770
|
+
setNamespace: setNamespace7
|
|
36682
36771
|
};
|
|
36683
36772
|
}
|
|
36684
36773
|
var AUTHORIZE_QUERY = `
|
|
@@ -36698,7 +36787,7 @@ var TOKEN_QUERY = `
|
|
|
36698
36787
|
}
|
|
36699
36788
|
}
|
|
36700
36789
|
`;
|
|
36701
|
-
var { logInfo } = createLoggers2("auth");
|
|
36790
|
+
var { logInfo: logInfo2 } = createLoggers2("auth");
|
|
36702
36791
|
var random = (0, import_node_util.promisify)(import_node_crypto.randomBytes);
|
|
36703
36792
|
async function getAuthToken(credentials, apiUrl) {
|
|
36704
36793
|
const authApiUrl = apiUrl || process.env.AUTH_API_URL;
|
|
@@ -36707,7 +36796,7 @@ async function getAuthToken(credentials, apiUrl) {
|
|
|
36707
36796
|
}
|
|
36708
36797
|
const { clientDecorator, variantConfigurationKey } = credentials;
|
|
36709
36798
|
const frameworkId = credentials.frameworkId || `apple-kit-${Date.now()}`;
|
|
36710
|
-
|
|
36799
|
+
logInfo2(`Getting auth token for identifiers: ${variantConfigurationKey}`);
|
|
36711
36800
|
const randomSecret = (await random(8)).toString("hex");
|
|
36712
36801
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
36713
36802
|
const hash = (0, import_node_crypto.createHash)("sha256");
|
|
@@ -36778,7 +36867,7 @@ async function getAuthToken(credentials, apiUrl) {
|
|
|
36778
36867
|
}
|
|
36779
36868
|
async function readCredentialsFromFile(filePath) {
|
|
36780
36869
|
const fs = await import("node:fs/promises");
|
|
36781
|
-
|
|
36870
|
+
logInfo2(`Reading credentials from: ${filePath}`);
|
|
36782
36871
|
const content = await fs.readFile(filePath, "utf-8");
|
|
36783
36872
|
const credentials = JSON.parse(content);
|
|
36784
36873
|
if (!credentials.clientDecorator || !credentials.variantConfigurationKey) {
|
|
@@ -37613,24 +37702,24 @@ var require_src22 = __commonJS3({
|
|
|
37613
37702
|
var import_debug22 = __toESM32(require_src22());
|
|
37614
37703
|
function createLoggers22(namespace, logLevel = process.env.LOG_LEVEL ?? "none") {
|
|
37615
37704
|
const logInfo32 = (0, import_debug22.default)(`${namespace}:info`);
|
|
37616
|
-
const
|
|
37705
|
+
const logTask4 = (0, import_debug22.default)(`${namespace}:task`);
|
|
37617
37706
|
const logError22 = (0, import_debug22.default)(`${namespace}:error`);
|
|
37618
|
-
const
|
|
37707
|
+
const logDetail3 = (0, import_debug22.default)(`${namespace}:detail`);
|
|
37619
37708
|
const logDebug = (0, import_debug22.default)(`${namespace}:debug`);
|
|
37620
37709
|
const logWarning2 = (0, import_debug22.default)(`${namespace}:warning`);
|
|
37621
37710
|
const logColor = (0, import_debug22.default)(`${namespace}:color`);
|
|
37622
37711
|
logInfo32.color = "19";
|
|
37623
|
-
|
|
37712
|
+
logTask4.color = "25";
|
|
37624
37713
|
logError22.color = "1";
|
|
37625
|
-
|
|
37714
|
+
logDetail3.color = "199";
|
|
37626
37715
|
logWarning2.color = "186";
|
|
37627
37716
|
logDebug.color = "211";
|
|
37628
37717
|
logColor.enabled = true;
|
|
37629
|
-
function
|
|
37718
|
+
function setNamespace7(namespace2) {
|
|
37630
37719
|
logInfo32.namespace = `${namespace2}:info`;
|
|
37631
|
-
|
|
37720
|
+
logTask4.namespace = `${namespace2}:task`;
|
|
37632
37721
|
logError22.namespace = `${namespace2}:error`;
|
|
37633
|
-
|
|
37722
|
+
logDetail3.namespace = `${namespace2}:detail`;
|
|
37634
37723
|
logWarning2.namespace = `${namespace2}:warning`;
|
|
37635
37724
|
logDebug.namespace = `${namespace2}:debug`;
|
|
37636
37725
|
}
|
|
@@ -37638,26 +37727,26 @@ function createLoggers22(namespace, logLevel = process.env.LOG_LEVEL ?? "none")
|
|
|
37638
37727
|
switch (level) {
|
|
37639
37728
|
case "info":
|
|
37640
37729
|
logInfo32.enabled = true;
|
|
37641
|
-
|
|
37730
|
+
logTask4.enabled = true;
|
|
37642
37731
|
logError22.enabled = true;
|
|
37643
37732
|
logWarning2.enabled = true;
|
|
37644
|
-
|
|
37733
|
+
logDetail3.enabled = false;
|
|
37645
37734
|
logDebug.enabled = false;
|
|
37646
37735
|
break;
|
|
37647
37736
|
case "debug":
|
|
37648
37737
|
logInfo32.enabled = true;
|
|
37649
|
-
|
|
37738
|
+
logTask4.enabled = true;
|
|
37650
37739
|
logError22.enabled = true;
|
|
37651
37740
|
logWarning2.enabled = true;
|
|
37652
|
-
|
|
37741
|
+
logDetail3.enabled = true;
|
|
37653
37742
|
logDebug.enabled = true;
|
|
37654
37743
|
break;
|
|
37655
37744
|
case "none":
|
|
37656
37745
|
logInfo32.enabled = false;
|
|
37657
|
-
|
|
37746
|
+
logTask4.enabled = false;
|
|
37658
37747
|
logError22.enabled = false;
|
|
37659
37748
|
logWarning2.enabled = false;
|
|
37660
|
-
|
|
37749
|
+
logDetail3.enabled = false;
|
|
37661
37750
|
logDebug.enabled = false;
|
|
37662
37751
|
break;
|
|
37663
37752
|
}
|
|
@@ -37669,13 +37758,13 @@ function createLoggers22(namespace, logLevel = process.env.LOG_LEVEL ?? "none")
|
|
|
37669
37758
|
logInfo32.color = color;
|
|
37670
37759
|
break;
|
|
37671
37760
|
case "task":
|
|
37672
|
-
|
|
37761
|
+
logTask4.color = color;
|
|
37673
37762
|
break;
|
|
37674
37763
|
case "error":
|
|
37675
37764
|
logError22.color = color;
|
|
37676
37765
|
break;
|
|
37677
37766
|
case "detail":
|
|
37678
|
-
|
|
37767
|
+
logDetail3.color = color;
|
|
37679
37768
|
break;
|
|
37680
37769
|
case "warning":
|
|
37681
37770
|
logWarning2.color = color;
|
|
@@ -37714,7 +37803,7 @@ function createLoggers22(namespace, logLevel = process.env.LOG_LEVEL ?? "none")
|
|
|
37714
37803
|
`;
|
|
37715
37804
|
} else if (typeof value === "object") {
|
|
37716
37805
|
result += `
|
|
37717
|
-
|
|
37806
|
+
${logDataDetail(value, `${prefix} `)}
|
|
37718
37807
|
`;
|
|
37719
37808
|
} else {
|
|
37720
37809
|
result += `${value}
|
|
@@ -37733,7 +37822,7 @@ ${" ".repeat(padding)}${"=".repeat(80)}`;
|
|
|
37733
37822
|
function logHeader(title) {
|
|
37734
37823
|
logInfo32(`${header(title, 2)}`);
|
|
37735
37824
|
}
|
|
37736
|
-
function
|
|
37825
|
+
function logDataObject22(title, ...args) {
|
|
37737
37826
|
const stack = new Error().stack?.split("\n")[2] || "";
|
|
37738
37827
|
const stackMatch = stack.match(/\((.*):(\d+):(\d+)\)$/) || stack.match(/at (.*):(\d+):(\d+)$/);
|
|
37739
37828
|
let callerDetails = "";
|
|
@@ -37742,7 +37831,7 @@ ${" ".repeat(padding)}${"=".repeat(80)}`;
|
|
|
37742
37831
|
const functionName = functionMatch ? functionMatch[1] : "<anonymous>";
|
|
37743
37832
|
callerDetails = `${functionName}`;
|
|
37744
37833
|
}
|
|
37745
|
-
|
|
37834
|
+
logDetail3(`${header(`*${title}* ${callerDetails}`)}
|
|
37746
37835
|
${args.reduce((acc, arg) => `${acc}
|
|
37747
37836
|
${logDataDetail(arg)}`, "")}
|
|
37748
37837
|
|
|
@@ -37763,26 +37852,26 @@ ${"=".repeat(80)}`);
|
|
|
37763
37852
|
}
|
|
37764
37853
|
return {
|
|
37765
37854
|
logInfo: logInfo32,
|
|
37766
|
-
logTask:
|
|
37855
|
+
logTask: logTask4,
|
|
37767
37856
|
logError: logError22,
|
|
37768
|
-
logDetail:
|
|
37857
|
+
logDetail: logDetail3,
|
|
37769
37858
|
logDebug,
|
|
37770
37859
|
logWarning: logWarning2,
|
|
37771
37860
|
logColor,
|
|
37772
37861
|
setColors,
|
|
37773
37862
|
printColors,
|
|
37774
37863
|
logHeader,
|
|
37775
|
-
logDataObject:
|
|
37864
|
+
logDataObject: logDataObject22,
|
|
37776
37865
|
logErrorObject,
|
|
37777
37866
|
setLogLevel,
|
|
37778
|
-
setNamespace:
|
|
37867
|
+
setNamespace: setNamespace7
|
|
37779
37868
|
};
|
|
37780
37869
|
}
|
|
37781
|
-
var { logInfo:
|
|
37870
|
+
var { logInfo: logInfo22, logError, logWarning, logDataObject: logDataObject2 } = createLoggers22("mdm-client");
|
|
37782
37871
|
var MdmClient = class {
|
|
37783
37872
|
constructor(config) {
|
|
37784
37873
|
this.config = config;
|
|
37785
|
-
|
|
37874
|
+
logDataObject2("MDM Client Config", { config });
|
|
37786
37875
|
if (!config.endpoint) {
|
|
37787
37876
|
throw new Error("MDM endpoint is required");
|
|
37788
37877
|
}
|
|
@@ -37802,7 +37891,7 @@ var MdmClient = class {
|
|
|
37802
37891
|
}
|
|
37803
37892
|
client;
|
|
37804
37893
|
async generateEnrollmentProfile(deviceId) {
|
|
37805
|
-
|
|
37894
|
+
logInfo22(`Generating enrollment profile for device ${deviceId}`);
|
|
37806
37895
|
const result = await this.client.request(GENERATE_ENROLLMENT_PROFILE, {
|
|
37807
37896
|
input: {
|
|
37808
37897
|
deviceId,
|
|
@@ -37812,7 +37901,7 @@ var MdmClient = class {
|
|
|
37812
37901
|
return result.generateEnrollmentProfile;
|
|
37813
37902
|
}
|
|
37814
37903
|
async waitForDeviceToEnroll(deviceId, previousOpRef) {
|
|
37815
|
-
|
|
37904
|
+
logInfo22(`Waiting for device ${deviceId} to enroll...`);
|
|
37816
37905
|
const result = await this.client.request(WAIT_FOR_DEVICE_TO_ENROLL, {
|
|
37817
37906
|
input: {
|
|
37818
37907
|
deviceId,
|
|
@@ -37822,7 +37911,7 @@ var MdmClient = class {
|
|
|
37822
37911
|
return result.waitForDeviceToEnroll;
|
|
37823
37912
|
}
|
|
37824
37913
|
async installApp(deviceId, options) {
|
|
37825
|
-
|
|
37914
|
+
logInfo22(`Installing app on device ${deviceId}`);
|
|
37826
37915
|
try {
|
|
37827
37916
|
const result = await this.client.request(INSTALL_APP, {
|
|
37828
37917
|
input: {
|
|
@@ -37850,7 +37939,7 @@ async function createMDMClient() {
|
|
|
37850
37939
|
const credPath = process.env.CREDENTIALS_PATH;
|
|
37851
37940
|
if (!endpoint || !credPath) {
|
|
37852
37941
|
logWarning("MDM endpoint or credentials path is not set");
|
|
37853
|
-
|
|
37942
|
+
logDataObject2("Environment variables", { endpoint, credPath });
|
|
37854
37943
|
return void 0;
|
|
37855
37944
|
}
|
|
37856
37945
|
const credentials = await readCredentialsFromFile(credPath);
|
|
@@ -37862,32 +37951,109 @@ async function createMDMClient() {
|
|
|
37862
37951
|
});
|
|
37863
37952
|
}
|
|
37864
37953
|
|
|
37865
|
-
// src/logic/
|
|
37866
|
-
|
|
37867
|
-
|
|
37868
|
-
|
|
37869
|
-
|
|
37870
|
-
|
|
37871
|
-
|
|
37872
|
-
|
|
37873
|
-
|
|
37874
|
-
|
|
37875
|
-
|
|
37876
|
-
|
|
37954
|
+
// src/logic/actions/install.ts
|
|
37955
|
+
var { logInfo: logInfo3, setNamespace: setNamespace2 } = createLoggers("apple-kit:install");
|
|
37956
|
+
var InstallActions = class {
|
|
37957
|
+
constructor(udid, iosClient) {
|
|
37958
|
+
this.udid = udid;
|
|
37959
|
+
this.iosClient = iosClient;
|
|
37960
|
+
setNamespace2(`apple-${udid}`);
|
|
37961
|
+
}
|
|
37962
|
+
async installLocalApp(ipaPath) {
|
|
37963
|
+
logInfo3(`Installing app ${ipaPath} on device ${this.udid}`);
|
|
37964
|
+
return this.iosClient.installApp(ipaPath);
|
|
37965
|
+
}
|
|
37966
|
+
async installManagedApp(ipaPath, options) {
|
|
37967
|
+
const result = await this.iosClient.installApp(ipaPath);
|
|
37968
|
+
logInfo3("Installing app via MDM for management takeover");
|
|
37969
|
+
const mdmClient = await createMDMClient();
|
|
37970
|
+
if (!mdmClient) {
|
|
37971
|
+
throw new Error("Failed to create MDM client");
|
|
37972
|
+
}
|
|
37973
|
+
await mdmClient.installApp(this.udid, options);
|
|
37974
|
+
return result;
|
|
37975
|
+
}
|
|
37976
|
+
async uninstallApp(bundleId) {
|
|
37977
|
+
logInfo3(`Uninstalling app ${bundleId} from device ${this.udid}`);
|
|
37978
|
+
return await this.iosClient.uninstallApp(bundleId);
|
|
37979
|
+
}
|
|
37980
|
+
async listApps() {
|
|
37981
|
+
logInfo3(`Listing apps on device ${this.udid}`);
|
|
37982
|
+
const result = await this.iosClient.listApps();
|
|
37983
|
+
return result.map((app) => ({
|
|
37984
|
+
bundleId: app.bundleId,
|
|
37985
|
+
version: app.version,
|
|
37986
|
+
displayName: app.displayName,
|
|
37987
|
+
bundleVersion: app.version
|
|
37988
|
+
}));
|
|
37989
|
+
}
|
|
37990
|
+
async isAppInstalled(bundleId) {
|
|
37991
|
+
logInfo3(`Checking if app ${bundleId} is installed on device ${this.udid}`);
|
|
37992
|
+
const apps = await this.listApps();
|
|
37993
|
+
return apps.some((app) => app.bundleId === bundleId);
|
|
37994
|
+
}
|
|
37995
|
+
//TODO: add a method to launch an app, currently I've tried to launch it using ios launch
|
|
37996
|
+
// even if devmode is enabled and device restarted and using tunnel, it's not working.
|
|
37997
|
+
};
|
|
37998
|
+
|
|
37999
|
+
// src/logic/actions/proxy.ts
|
|
38000
|
+
var { logTask: logTask2, logInfo: logInfo4, setNamespace: setNamespace3 } = createLoggers("");
|
|
38001
|
+
var ProxyActions = class {
|
|
38002
|
+
constructor(udid, iosClient) {
|
|
38003
|
+
this.udid = udid;
|
|
38004
|
+
this.iosClient = iosClient;
|
|
38005
|
+
setNamespace3(`apple-${udid}`);
|
|
38006
|
+
}
|
|
38007
|
+
childProcess = /* @__PURE__ */ new Map();
|
|
38008
|
+
async startPortForward(localPort, devicePort) {
|
|
38009
|
+
logInfo4(`Starting port forward ${localPort} -> ${devicePort} for device ${this.udid}`);
|
|
38010
|
+
const result = await this.iosClient.forward({ fromPort: localPort, toPort: devicePort });
|
|
38011
|
+
return new Promise((resolve2, reject) => {
|
|
38012
|
+
const timeout2 = setTimeout(() => {
|
|
38013
|
+
reject(new Error("Port forwarding timed out"));
|
|
38014
|
+
}, 1e4);
|
|
38015
|
+
result.stdout?.on("data", (data) => {
|
|
38016
|
+
if (data.toString().includes("Started")) {
|
|
38017
|
+
clearTimeout(timeout2);
|
|
38018
|
+
resolve2({
|
|
38019
|
+
localPort,
|
|
38020
|
+
devicePort
|
|
38021
|
+
});
|
|
38022
|
+
}
|
|
37877
38023
|
});
|
|
38024
|
+
result.on("error", (err) => {
|
|
38025
|
+
clearTimeout(timeout2);
|
|
38026
|
+
reject(err);
|
|
38027
|
+
});
|
|
38028
|
+
});
|
|
38029
|
+
}
|
|
38030
|
+
async killPortForward() {
|
|
38031
|
+
const process3 = this.childProcess.get(this.udid);
|
|
38032
|
+
if (process3 && !process3.killed) {
|
|
38033
|
+
logTask2("Killing port forward process");
|
|
38034
|
+
process3.kill();
|
|
38035
|
+
this.childProcess.delete(this.udid);
|
|
37878
38036
|
}
|
|
37879
38037
|
}
|
|
37880
|
-
|
|
37881
|
-
}
|
|
38038
|
+
};
|
|
37882
38039
|
|
|
37883
|
-
// src/logic/
|
|
37884
|
-
var
|
|
37885
|
-
var
|
|
37886
|
-
var
|
|
38040
|
+
// src/logic/activationFlow.ts
|
|
38041
|
+
var import_promises2 = require("node:fs/promises");
|
|
38042
|
+
var import_node_os5 = require("node:os");
|
|
38043
|
+
var import_node_path4 = require("node:path");
|
|
38044
|
+
|
|
38045
|
+
// src/utils/wifiProfile.ts
|
|
38046
|
+
var import_node_crypto2 = require("node:crypto");
|
|
38047
|
+
|
|
38048
|
+
// src/utils/templateLoader.ts
|
|
38049
|
+
var import_node_fs4 = require("node:fs");
|
|
38050
|
+
var import_promises = require("node:fs/promises");
|
|
38051
|
+
var import_node_path3 = require("node:path");
|
|
38052
|
+
var import_node_url = require("node:url");
|
|
37887
38053
|
|
|
37888
38054
|
// src/logic/utils/resolvePath.ts
|
|
37889
|
-
var
|
|
37890
|
-
var
|
|
38055
|
+
var import_node_fs3 = require("node:fs");
|
|
38056
|
+
var import_node_path2 = require("node:path");
|
|
37891
38057
|
var resourcesDir;
|
|
37892
38058
|
function setResourcesDir(dir) {
|
|
37893
38059
|
resourcesDir = dir;
|
|
@@ -37914,25 +38080,25 @@ function getResourcesPath() {
|
|
|
37914
38080
|
function getResourcesBinPath() {
|
|
37915
38081
|
if (resourcesDir) {
|
|
37916
38082
|
const platformDir = getPlatformDir();
|
|
37917
|
-
const candidate = (0,
|
|
37918
|
-
if ((0,
|
|
38083
|
+
const candidate = (0, import_node_path2.join)(resourcesDir, "ios", "bin", platformDir);
|
|
38084
|
+
if ((0, import_node_fs3.existsSync)(candidate)) {
|
|
37919
38085
|
return candidate;
|
|
37920
38086
|
}
|
|
37921
38087
|
}
|
|
37922
38088
|
if (process.platform === "darwin") {
|
|
37923
38089
|
const homebrewArmPath = "/opt/homebrew/bin";
|
|
37924
|
-
if ((0,
|
|
38090
|
+
if ((0, import_node_fs3.existsSync)((0, import_node_path2.join)(homebrewArmPath, "idevice_id"))) {
|
|
37925
38091
|
return homebrewArmPath;
|
|
37926
38092
|
}
|
|
37927
38093
|
const homebrewIntelPath = "/usr/local/bin";
|
|
37928
|
-
if ((0,
|
|
38094
|
+
if ((0, import_node_fs3.existsSync)((0, import_node_path2.join)(homebrewIntelPath, "idevice_id"))) {
|
|
37929
38095
|
return homebrewIntelPath;
|
|
37930
38096
|
}
|
|
37931
38097
|
}
|
|
37932
38098
|
if (process.platform === "linux") {
|
|
37933
38099
|
const linuxPaths = ["/usr/bin", "/usr/local/bin"];
|
|
37934
38100
|
for (const linuxPath of linuxPaths) {
|
|
37935
|
-
if ((0,
|
|
38101
|
+
if ((0, import_node_fs3.existsSync)((0, import_node_path2.join)(linuxPath, "idevice_id"))) {
|
|
37936
38102
|
return linuxPath;
|
|
37937
38103
|
}
|
|
37938
38104
|
}
|
|
@@ -37940,258 +38106,22 @@ function getResourcesBinPath() {
|
|
|
37940
38106
|
return "";
|
|
37941
38107
|
}
|
|
37942
38108
|
|
|
37943
|
-
// src/logic/actions/tool.ts
|
|
37944
|
-
var execAsync = (0, import_node_util2.promisify)(import_node_child_process.exec);
|
|
37945
|
-
async function runIDeviceTool(toolName, args = [], options = {}) {
|
|
37946
|
-
const binPath = getResourcesBinPath();
|
|
37947
|
-
const ext = process.platform === "win32" ? ".exe" : "";
|
|
37948
|
-
const toolPath = binPath ? (0, import_node_path2.join)(binPath, `${toolName}${ext}`) : `${toolName}${ext}`;
|
|
37949
|
-
const command = `"${toolPath}" ${args.map((a) => `"${a}"`).join(" ")}`;
|
|
37950
|
-
return execIDevice(command, options);
|
|
37951
|
-
}
|
|
37952
|
-
async function execIDevice(command, options = {}) {
|
|
37953
|
-
const binPath = getResourcesBinPath();
|
|
37954
|
-
if (binPath) {
|
|
37955
|
-
options.cwd = binPath;
|
|
37956
|
-
}
|
|
37957
|
-
const result = await execAsync(command, {
|
|
37958
|
-
...options,
|
|
37959
|
-
env: process.env,
|
|
37960
|
-
windowsHide: true,
|
|
37961
|
-
encoding: "utf8"
|
|
37962
|
-
});
|
|
37963
|
-
return {
|
|
37964
|
-
stdout: result.stdout.toString(),
|
|
37965
|
-
stderr: result.stderr.toString()
|
|
37966
|
-
};
|
|
37967
|
-
}
|
|
37968
|
-
|
|
37969
|
-
// src/logic/actions/pair.ts
|
|
37970
|
-
var { logTask: logTask2, logInfo: logInfo3, logError: logError2 } = createLoggers("apple-kit:pair");
|
|
37971
|
-
async function isPaired(udid) {
|
|
37972
|
-
logTask2(`Checking pairing status for ${udid}`);
|
|
37973
|
-
try {
|
|
37974
|
-
const result = await runIDeviceTool("idevicepair", ["-u", udid, "validate"]);
|
|
37975
|
-
if (!result) {
|
|
37976
|
-
return false;
|
|
37977
|
-
}
|
|
37978
|
-
return result.stdout.toLowerCase().includes("success");
|
|
37979
|
-
} catch {
|
|
37980
|
-
return false;
|
|
37981
|
-
}
|
|
37982
|
-
}
|
|
37983
|
-
async function trustDevice(udid, timeout2 = 6e4, onWaitingForTrust) {
|
|
37984
|
-
logTask2(`Trusting device ${udid}`);
|
|
37985
|
-
if (await isPaired(udid)) {
|
|
37986
|
-
logInfo3(`Device ${udid} is already trusted`);
|
|
37987
|
-
return true;
|
|
37988
|
-
}
|
|
37989
|
-
logInfo3(`Initiating pairing for device ${udid}`);
|
|
37990
|
-
try {
|
|
37991
|
-
const pairResult = await pair(udid);
|
|
37992
|
-
if (pairResult) {
|
|
37993
|
-
logInfo3(`Device ${udid} paired successfully`);
|
|
37994
|
-
return true;
|
|
37995
|
-
}
|
|
37996
|
-
} catch (error) {
|
|
37997
|
-
logError2(`Pairing failed with ${udid}: ${error}`);
|
|
37998
|
-
}
|
|
37999
|
-
logInfo3("Please accept the trust dialog on the device...");
|
|
38000
|
-
onWaitingForTrust?.();
|
|
38001
|
-
try {
|
|
38002
|
-
await waitForPairing(udid, timeout2, 1e3);
|
|
38003
|
-
logInfo3(`Device ${udid} is now trusted`);
|
|
38004
|
-
return true;
|
|
38005
|
-
} catch {
|
|
38006
|
-
logInfo3(`Timeout waiting for trust acceptance on device ${udid}`);
|
|
38007
|
-
return false;
|
|
38008
|
-
}
|
|
38009
|
-
}
|
|
38010
|
-
async function waitForPairing(udid, timeout2 = 12e4, pollInterval = 1e3) {
|
|
38011
|
-
logTask2(`Waiting for pairing on device ${udid}`);
|
|
38012
|
-
const startTime = Date.now();
|
|
38013
|
-
while (Date.now() - startTime < timeout2) {
|
|
38014
|
-
if (await isPaired(udid)) {
|
|
38015
|
-
logInfo3(`Device ${udid} is now paired`);
|
|
38016
|
-
return true;
|
|
38017
|
-
}
|
|
38018
|
-
await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
|
|
38019
|
-
}
|
|
38020
|
-
throw new Error(`Timeout waiting for device pairing after ${timeout2}ms`);
|
|
38021
|
-
}
|
|
38022
|
-
async function pair(udid) {
|
|
38023
|
-
logTask2(`Initiating pairing for device ${udid}`);
|
|
38024
|
-
try {
|
|
38025
|
-
const result = await runIDeviceTool("idevicepair", ["-u", udid, "pair"]);
|
|
38026
|
-
if (!result) {
|
|
38027
|
-
return false;
|
|
38028
|
-
}
|
|
38029
|
-
return result.stdout.toLowerCase().includes("success");
|
|
38030
|
-
} catch (error) {
|
|
38031
|
-
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
38032
|
-
if (errorMsg.includes("Please accept the trust dialog")) {
|
|
38033
|
-
return false;
|
|
38034
|
-
}
|
|
38035
|
-
throw error;
|
|
38036
|
-
}
|
|
38037
|
-
}
|
|
38038
|
-
async function unpair(udid) {
|
|
38039
|
-
logTask2(`Un-pairing device ${udid}`);
|
|
38040
|
-
try {
|
|
38041
|
-
const result = await runIDeviceTool("idevicepair", ["-u", udid, "unpair"]);
|
|
38042
|
-
if (!result) {
|
|
38043
|
-
return false;
|
|
38044
|
-
}
|
|
38045
|
-
return result.stdout.toLowerCase().includes("success");
|
|
38046
|
-
} catch {
|
|
38047
|
-
return false;
|
|
38048
|
-
}
|
|
38049
|
-
}
|
|
38050
|
-
|
|
38051
|
-
// src/logic/actions/install.ts
|
|
38052
|
-
var { logTask: logTask3, logInfo: logInfo4 } = createLoggers("apple-kit:install");
|
|
38053
|
-
async function installManagedApp(ipaPath, udid, iosCli2, options) {
|
|
38054
|
-
const result = await iosCli2.installApp(udid, ipaPath);
|
|
38055
|
-
const client = await createMDMClient();
|
|
38056
|
-
logTask3("Installing app via MDM for management takeover");
|
|
38057
|
-
if (client) {
|
|
38058
|
-
await client.installApp(udid, options);
|
|
38059
|
-
}
|
|
38060
|
-
return result;
|
|
38061
|
-
}
|
|
38062
|
-
async function uninstallApp(bundleId, udid) {
|
|
38063
|
-
logTask3(`Uninstalling app ${bundleId} from device ${udid}`);
|
|
38064
|
-
if (!await isPaired(udid)) {
|
|
38065
|
-
await waitForPairing(udid, 1e4);
|
|
38066
|
-
}
|
|
38067
|
-
await runIDeviceTool("ideviceinstaller", ["-u", udid, "uninstall", bundleId]);
|
|
38068
|
-
}
|
|
38069
|
-
async function listApps(udid) {
|
|
38070
|
-
logTask3(`Listing apps on device ${udid}`);
|
|
38071
|
-
if (!await isPaired(udid)) {
|
|
38072
|
-
await waitForPairing(udid, 1e4);
|
|
38073
|
-
}
|
|
38074
|
-
try {
|
|
38075
|
-
const result = await runIDeviceTool("ideviceinstaller", ["-u", udid, "list"]);
|
|
38076
|
-
if (!result) {
|
|
38077
|
-
return [];
|
|
38078
|
-
}
|
|
38079
|
-
const { stdout } = result;
|
|
38080
|
-
return parseAppList(stdout);
|
|
38081
|
-
} catch {
|
|
38082
|
-
return [];
|
|
38083
|
-
}
|
|
38084
|
-
}
|
|
38085
|
-
async function isAppInstalled(bundleId, udid) {
|
|
38086
|
-
logTask3(`Checking if app ${bundleId} is installed on device ${udid}`);
|
|
38087
|
-
const apps = await listApps(udid);
|
|
38088
|
-
return apps.some((app) => app.bundleId === bundleId);
|
|
38089
|
-
}
|
|
38090
|
-
|
|
38091
|
-
// src/logic/actions/proxy.ts
|
|
38092
|
-
var import_node_child_process2 = require("node:child_process");
|
|
38093
|
-
var import_node_path3 = require("node:path");
|
|
38094
|
-
var { logTask: logTask4, logInfo: logInfo5, logError: logError3 } = createLoggers("apple-kit:proxy");
|
|
38095
|
-
function startPortForward(localPort, devicePort, udid, startupTimeout = 500) {
|
|
38096
|
-
return new Promise((resolve2, reject) => {
|
|
38097
|
-
logTask4(`Starting port forward ${localPort} -> ${devicePort} for device ${udid}`);
|
|
38098
|
-
const binPath = getResourcesBinPath();
|
|
38099
|
-
const ext = process.platform === "win32" ? ".exe" : "";
|
|
38100
|
-
const toolPath = binPath ? (0, import_node_path3.join)(binPath, `iproxy${ext}`) : `iproxy${ext}`;
|
|
38101
|
-
const spawnOptions = {
|
|
38102
|
-
windowsHide: true,
|
|
38103
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
38104
|
-
};
|
|
38105
|
-
if (binPath) {
|
|
38106
|
-
spawnOptions.cwd = binPath;
|
|
38107
|
-
}
|
|
38108
|
-
logInfo5(`Spawning iproxy with path: ${toolPath}`);
|
|
38109
|
-
logInfo5(`Arguments: ${[localPort.toString(), devicePort.toString(), "-u", udid].join(" ")}`);
|
|
38110
|
-
logInfo5(`Options: ${JSON.stringify(spawnOptions)}`);
|
|
38111
|
-
const child = (0, import_node_child_process2.spawn)(
|
|
38112
|
-
toolPath,
|
|
38113
|
-
[localPort.toString(), devicePort.toString(), "-u", udid],
|
|
38114
|
-
spawnOptions
|
|
38115
|
-
);
|
|
38116
|
-
let hasResolved = false;
|
|
38117
|
-
let stderrOutput = "";
|
|
38118
|
-
child.stdout?.on("data", (data) => {
|
|
38119
|
-
logTask4(`${data.toString()}`);
|
|
38120
|
-
});
|
|
38121
|
-
child.stderr?.on("data", (data) => {
|
|
38122
|
-
logError3(`${data.toString()}`);
|
|
38123
|
-
const msg = data.toString();
|
|
38124
|
-
stderrOutput += msg;
|
|
38125
|
-
if (msg.toLowerCase().includes("error") && !hasResolved) {
|
|
38126
|
-
hasResolved = true;
|
|
38127
|
-
child.kill();
|
|
38128
|
-
reject(new Error(`Port forwarding failed: ${msg}`));
|
|
38129
|
-
}
|
|
38130
|
-
});
|
|
38131
|
-
child.on("error", (error) => {
|
|
38132
|
-
if (!hasResolved) {
|
|
38133
|
-
hasResolved = true;
|
|
38134
|
-
reject(new Error(`Failed to start iproxy: ${error.message}`));
|
|
38135
|
-
}
|
|
38136
|
-
});
|
|
38137
|
-
child.on("exit", (code) => {
|
|
38138
|
-
if (!hasResolved) {
|
|
38139
|
-
hasResolved = true;
|
|
38140
|
-
if (code !== 0 && code !== null) {
|
|
38141
|
-
reject(new Error(`iproxy exited with code ${code}: ${stderrOutput}`));
|
|
38142
|
-
}
|
|
38143
|
-
}
|
|
38144
|
-
});
|
|
38145
|
-
setTimeout(() => {
|
|
38146
|
-
if (!hasResolved) {
|
|
38147
|
-
hasResolved = true;
|
|
38148
|
-
logTask4(`Port forward started: ${localPort} -> ${devicePort} for device ${udid}`);
|
|
38149
|
-
resolve2({
|
|
38150
|
-
result: {
|
|
38151
|
-
localPort,
|
|
38152
|
-
devicePort
|
|
38153
|
-
},
|
|
38154
|
-
process: child
|
|
38155
|
-
});
|
|
38156
|
-
}
|
|
38157
|
-
}, startupTimeout);
|
|
38158
|
-
});
|
|
38159
|
-
}
|
|
38160
|
-
function killPortForwardProcess(process3) {
|
|
38161
|
-
if (process3 && !process3.killed) {
|
|
38162
|
-
logTask4("Killing port forward process");
|
|
38163
|
-
process3.kill();
|
|
38164
|
-
}
|
|
38165
|
-
}
|
|
38166
|
-
|
|
38167
|
-
// src/logic/activationFlow.ts
|
|
38168
|
-
var import_promises2 = require("node:fs/promises");
|
|
38169
|
-
var import_node_os5 = require("node:os");
|
|
38170
|
-
var import_node_path5 = require("node:path");
|
|
38171
|
-
|
|
38172
|
-
// src/utils/wifiProfile.ts
|
|
38173
|
-
var import_node_crypto2 = require("node:crypto");
|
|
38174
|
-
|
|
38175
38109
|
// src/utils/templateLoader.ts
|
|
38176
|
-
var import_node_fs2 = require("node:fs");
|
|
38177
|
-
var import_promises = require("node:fs/promises");
|
|
38178
|
-
var import_node_path4 = require("node:path");
|
|
38179
|
-
var import_node_url = require("node:url");
|
|
38180
38110
|
var import_meta = {};
|
|
38181
38111
|
function resolveEnvPlistDir() {
|
|
38182
|
-
const envPath = (0,
|
|
38183
|
-
if (!(0,
|
|
38112
|
+
const envPath = (0, import_node_path3.join)(getResourcesPath(), "plist");
|
|
38113
|
+
if (!(0, import_node_fs4.existsSync)(envPath)) {
|
|
38184
38114
|
return null;
|
|
38185
38115
|
}
|
|
38186
|
-
const absolutePath = (0,
|
|
38187
|
-
if ((0,
|
|
38116
|
+
const absolutePath = (0, import_node_path3.isAbsolute)(envPath) ? envPath : (0, import_node_path3.join)(process.cwd(), envPath);
|
|
38117
|
+
if ((0, import_node_fs4.existsSync)(absolutePath)) {
|
|
38188
38118
|
return absolutePath;
|
|
38189
38119
|
}
|
|
38190
38120
|
return null;
|
|
38191
38121
|
}
|
|
38192
38122
|
function getPlistDir(overrideDir) {
|
|
38193
38123
|
if (overrideDir) {
|
|
38194
|
-
return (0,
|
|
38124
|
+
return (0, import_node_path3.resolve)(overrideDir);
|
|
38195
38125
|
}
|
|
38196
38126
|
const envPlistDir = resolveEnvPlistDir();
|
|
38197
38127
|
if (envPlistDir) {
|
|
@@ -38201,37 +38131,37 @@ function getPlistDir(overrideDir) {
|
|
|
38201
38131
|
try {
|
|
38202
38132
|
if (typeof import_meta !== "undefined" && import_meta.url) {
|
|
38203
38133
|
const currentFile = (0, import_node_url.fileURLToPath)(import_meta.url);
|
|
38204
|
-
baseDir = (0,
|
|
38134
|
+
baseDir = (0, import_node_path3.dirname)(currentFile);
|
|
38205
38135
|
} else {
|
|
38206
38136
|
baseDir = typeof __dirname !== "undefined" ? __dirname : process.cwd();
|
|
38207
38137
|
}
|
|
38208
38138
|
} catch {
|
|
38209
38139
|
baseDir = process.cwd();
|
|
38210
38140
|
}
|
|
38211
|
-
const sourcePlistDir = (0,
|
|
38212
|
-
if ((0,
|
|
38141
|
+
const sourcePlistDir = (0, import_node_path3.join)(baseDir, "../plist");
|
|
38142
|
+
if ((0, import_node_fs4.existsSync)(sourcePlistDir)) {
|
|
38213
38143
|
return sourcePlistDir;
|
|
38214
38144
|
}
|
|
38215
|
-
const distPlistDir = (0,
|
|
38216
|
-
if ((0,
|
|
38145
|
+
const distPlistDir = (0, import_node_path3.join)(baseDir, "../plist");
|
|
38146
|
+
if ((0, import_node_fs4.existsSync)(distPlistDir)) {
|
|
38217
38147
|
return distPlistDir;
|
|
38218
38148
|
}
|
|
38219
|
-
const distPlistDir2 = (0,
|
|
38220
|
-
if ((0,
|
|
38149
|
+
const distPlistDir2 = (0, import_node_path3.join)(baseDir, "../dist/plist");
|
|
38150
|
+
if ((0, import_node_fs4.existsSync)(distPlistDir2)) {
|
|
38221
38151
|
return distPlistDir2;
|
|
38222
38152
|
}
|
|
38223
|
-
const srcPlistFallback = (0,
|
|
38224
|
-
if ((0,
|
|
38153
|
+
const srcPlistFallback = (0, import_node_path3.join)(process.cwd(), "src/plist");
|
|
38154
|
+
if ((0, import_node_fs4.existsSync)(srcPlistFallback)) {
|
|
38225
38155
|
return srcPlistFallback;
|
|
38226
38156
|
}
|
|
38227
|
-
const distPlistFallback = (0,
|
|
38228
|
-
if ((0,
|
|
38157
|
+
const distPlistFallback = (0, import_node_path3.join)(process.cwd(), "dist/plist");
|
|
38158
|
+
if ((0, import_node_fs4.existsSync)(distPlistFallback)) {
|
|
38229
38159
|
return distPlistFallback;
|
|
38230
38160
|
}
|
|
38231
|
-
return (0,
|
|
38161
|
+
return (0, import_node_path3.join)(process.cwd(), "src/plist");
|
|
38232
38162
|
}
|
|
38233
38163
|
async function loadTemplate(templateName, plistDir) {
|
|
38234
|
-
const templatePath = (0,
|
|
38164
|
+
const templatePath = (0, import_node_path3.join)(getPlistDir(plistDir), templateName);
|
|
38235
38165
|
const content = await (0, import_promises.readFile)(templatePath, "utf-8");
|
|
38236
38166
|
return content;
|
|
38237
38167
|
}
|
|
@@ -38261,7 +38191,7 @@ function escapeXml(str) {
|
|
|
38261
38191
|
}
|
|
38262
38192
|
|
|
38263
38193
|
// src/utils/wifiProfile.ts
|
|
38264
|
-
var { logInfo:
|
|
38194
|
+
var { logInfo: logInfo5 } = createLoggers("apple-kit:wifi-profile");
|
|
38265
38195
|
async function generateWifiProfile(config, options) {
|
|
38266
38196
|
const {
|
|
38267
38197
|
ssid,
|
|
@@ -38280,7 +38210,7 @@ async function generateWifiProfile(config, options) {
|
|
|
38280
38210
|
const payloadUuid = (0, import_node_crypto2.randomUUID)().toUpperCase();
|
|
38281
38211
|
const profileId = `com.mce.wifi.${ssid.replace(/[^a-zA-Z0-9]/g, "")}.${Date.now()}`;
|
|
38282
38212
|
const payloadId = `${profileId}.payload`;
|
|
38283
|
-
|
|
38213
|
+
logInfo5(`Generating WiFi profile for SSID: ${ssid}, encryption: ${encryptionType}`);
|
|
38284
38214
|
const templateName = enterprise ? "wifi-enterprise.xml" : "wifi-standard.xml";
|
|
38285
38215
|
const template = await loadTemplate(templateName, options?.plistDir);
|
|
38286
38216
|
const variables = {
|
|
@@ -38319,7 +38249,7 @@ async function generateWifiProfile(config, options) {
|
|
|
38319
38249
|
async function generateWifiProfileFromEnv(options) {
|
|
38320
38250
|
const ssid = process.env.WIFI_SSID;
|
|
38321
38251
|
if (!ssid) {
|
|
38322
|
-
|
|
38252
|
+
logInfo5("WIFI_SSID not set, skipping WiFi profile generation");
|
|
38323
38253
|
return null;
|
|
38324
38254
|
}
|
|
38325
38255
|
const config = {
|
|
@@ -38331,7 +38261,7 @@ async function generateWifiProfileFromEnv(options) {
|
|
|
38331
38261
|
username: process.env.WIFI_USERNAME,
|
|
38332
38262
|
eapType: parseWifiEapType(process.env.WIFI_EAP_TYPE)
|
|
38333
38263
|
};
|
|
38334
|
-
|
|
38264
|
+
logInfo5(`Generating WiFi profile from env: SSID=${ssid}, enterprise=${config.enterprise}`);
|
|
38335
38265
|
return generateWifiProfile(config, options);
|
|
38336
38266
|
}
|
|
38337
38267
|
async function saveWifiProfileToTemp(profile) {
|
|
@@ -38342,7 +38272,7 @@ async function saveWifiProfileToTemp(profile) {
|
|
|
38342
38272
|
const fileName = `mce_wifi_${Date.now()}.mobileconfig`;
|
|
38343
38273
|
const filePath = path.join(tempDir, fileName);
|
|
38344
38274
|
await fs.writeFile(filePath, profile, "utf-8");
|
|
38345
|
-
|
|
38275
|
+
logInfo5(`WiFi profile saved to: ${filePath}`);
|
|
38346
38276
|
return filePath;
|
|
38347
38277
|
}
|
|
38348
38278
|
function getEapTypeNumber(eapType) {
|
|
@@ -38388,23 +38318,24 @@ function parseWifiEapType(value) {
|
|
|
38388
38318
|
// src/logic/activationFlow.ts
|
|
38389
38319
|
var DEFAULT_RETRIES = 150;
|
|
38390
38320
|
var DEFAULT_RETRY_DELAY_MS = 1e3;
|
|
38391
|
-
var { logTask:
|
|
38321
|
+
var { logTask: logTask3, logInfo: logInfo6, logError: logError2, setNamespace: setNamespace4 } = createLoggers("apple-kit:activation");
|
|
38392
38322
|
var ActivationFlow = class {
|
|
38393
|
-
|
|
38394
|
-
|
|
38395
|
-
|
|
38396
|
-
|
|
38323
|
+
constructor(udid, iosClient) {
|
|
38324
|
+
this.udid = udid;
|
|
38325
|
+
this.iosClient = iosClient;
|
|
38326
|
+
setNamespace4(`${udid}`);
|
|
38397
38327
|
}
|
|
38398
|
-
|
|
38328
|
+
mdmClient;
|
|
38329
|
+
async run(steps) {
|
|
38399
38330
|
this.mdmClient = await createMDMClient();
|
|
38400
|
-
|
|
38401
|
-
await this.retryActivateCommand("activate device", () => this.
|
|
38402
|
-
const wifiProfileIdentifier = await this.installWifiProfile(
|
|
38403
|
-
await this.installMdmProfile(
|
|
38404
|
-
await this.retryIosCommand("skip steps", () => this.
|
|
38405
|
-
return () => this.removeWifiProfile(
|
|
38406
|
-
}
|
|
38407
|
-
async installWifiProfile(
|
|
38331
|
+
logTask3(`Starting activation flow for device ${this.udid}`);
|
|
38332
|
+
await this.retryActivateCommand("activate device", () => this.iosClient.activate());
|
|
38333
|
+
const wifiProfileIdentifier = await this.installWifiProfile();
|
|
38334
|
+
await this.installMdmProfile();
|
|
38335
|
+
await this.retryIosCommand("skip steps", () => this.iosClient.skipSteps(steps));
|
|
38336
|
+
return () => this.removeWifiProfile(wifiProfileIdentifier);
|
|
38337
|
+
}
|
|
38338
|
+
async installWifiProfile() {
|
|
38408
38339
|
const wifiProfile = await generateWifiProfileFromEnv();
|
|
38409
38340
|
if (!wifiProfile) {
|
|
38410
38341
|
return void 0;
|
|
@@ -38413,20 +38344,20 @@ var ActivationFlow = class {
|
|
|
38413
38344
|
const wifiProfileIdentifier = getProfileIdentifierFromProfile(wifiProfile);
|
|
38414
38345
|
await this.retryIosCommand(
|
|
38415
38346
|
"install wifi profile",
|
|
38416
|
-
() => this.
|
|
38347
|
+
() => this.iosClient.installProfile(wifiProfilePath)
|
|
38417
38348
|
);
|
|
38418
38349
|
await removeTempFile(wifiProfilePath, "wifi profile");
|
|
38419
38350
|
return wifiProfileIdentifier;
|
|
38420
38351
|
}
|
|
38421
|
-
async installMdmProfile(
|
|
38422
|
-
|
|
38352
|
+
async installMdmProfile() {
|
|
38353
|
+
logTask3("Installing MDM enrollment profile");
|
|
38423
38354
|
const enrollmentProfile = await this.retry(
|
|
38424
38355
|
"generate mdm enrollment profile",
|
|
38425
38356
|
() => {
|
|
38426
38357
|
if (!this.mdmClient) {
|
|
38427
38358
|
throw new Error("MDM client not initialized");
|
|
38428
38359
|
}
|
|
38429
|
-
return this.mdmClient.generateEnrollmentProfile(udid);
|
|
38360
|
+
return this.mdmClient.generateEnrollmentProfile(this.udid);
|
|
38430
38361
|
},
|
|
38431
38362
|
(result) => result.status === "OK" && Boolean(result.profile)
|
|
38432
38363
|
);
|
|
@@ -38436,18 +38367,18 @@ var ActivationFlow = class {
|
|
|
38436
38367
|
const profilePath = await saveProfileToTemp(enrollmentProfile.profile, "mdm_profile");
|
|
38437
38368
|
await this.retryIosCommand(
|
|
38438
38369
|
"install mdm profile",
|
|
38439
|
-
() => this.
|
|
38370
|
+
() => this.iosClient.installProfile(profilePath)
|
|
38440
38371
|
);
|
|
38441
38372
|
await removeTempFile(profilePath, "mdm profile");
|
|
38442
38373
|
}
|
|
38443
|
-
async removeWifiProfile(
|
|
38374
|
+
async removeWifiProfile(profileIdentifier) {
|
|
38444
38375
|
if (!profileIdentifier) {
|
|
38445
38376
|
return;
|
|
38446
38377
|
}
|
|
38447
|
-
|
|
38378
|
+
logTask3("Removing WiFi profile");
|
|
38448
38379
|
await this.retryIosCommand(
|
|
38449
38380
|
"remove wifi profile",
|
|
38450
|
-
() => this.
|
|
38381
|
+
() => this.iosClient.removeProfile(profileIdentifier)
|
|
38451
38382
|
);
|
|
38452
38383
|
}
|
|
38453
38384
|
async retryIosCommand(label, command) {
|
|
@@ -38465,27 +38396,27 @@ var ActivationFlow = class {
|
|
|
38465
38396
|
}
|
|
38466
38397
|
} catch (error) {
|
|
38467
38398
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
38468
|
-
|
|
38399
|
+
logError2(`${label} failed: ${errorMsg}`);
|
|
38469
38400
|
}
|
|
38470
|
-
|
|
38401
|
+
logInfo6(`Retrying ${label}... ${attempt + 1} of ${retries}`);
|
|
38471
38402
|
await new Promise((resolve2) => setTimeout(resolve2, retryDelayMs));
|
|
38472
38403
|
}
|
|
38473
38404
|
throw new Error(`Failed to ${label} after ${retries} attempts`);
|
|
38474
38405
|
}
|
|
38475
38406
|
};
|
|
38476
38407
|
async function saveProfileToTemp(profile, prefix) {
|
|
38477
|
-
const tempFilePath = (0,
|
|
38408
|
+
const tempFilePath = (0, import_node_path4.join)((0, import_node_os5.tmpdir)(), `mce_${prefix}_${Date.now()}.mobileconfig`);
|
|
38478
38409
|
await (0, import_promises2.writeFile)(tempFilePath, profile, "utf-8");
|
|
38479
|
-
|
|
38410
|
+
logInfo6(`Profile saved to: ${tempFilePath}`);
|
|
38480
38411
|
return tempFilePath;
|
|
38481
38412
|
}
|
|
38482
38413
|
async function removeTempFile(filePath, label) {
|
|
38483
38414
|
try {
|
|
38484
38415
|
await (0, import_promises2.unlink)(filePath);
|
|
38485
|
-
|
|
38416
|
+
logInfo6(`Removed ${label} temp file: ${filePath}`);
|
|
38486
38417
|
} catch (error) {
|
|
38487
38418
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
38488
|
-
|
|
38419
|
+
logError2(`Failed to remove ${label} temp file: ${errorMsg}`);
|
|
38489
38420
|
}
|
|
38490
38421
|
}
|
|
38491
38422
|
function getProfileIdentifierFromProfile(profile) {
|
|
@@ -38504,7 +38435,7 @@ function getProfileIdentifierFromProfile(profile) {
|
|
|
38504
38435
|
function resolveIosBinaryPath() {
|
|
38505
38436
|
const platform = process.platform;
|
|
38506
38437
|
const binaryName = platform === "win32" ? "ios.exe" : "ios";
|
|
38507
|
-
return (0,
|
|
38438
|
+
return (0, import_node_path4.join)(getResourcesBinPath(), binaryName);
|
|
38508
38439
|
}
|
|
38509
38440
|
function isActivationSuccess(result) {
|
|
38510
38441
|
if (result.exitCode !== 0) {
|
|
@@ -38517,361 +38448,395 @@ function isActivationSuccess(result) {
|
|
|
38517
38448
|
return !hasFatal;
|
|
38518
38449
|
}
|
|
38519
38450
|
|
|
38520
|
-
// src/logic/
|
|
38521
|
-
var
|
|
38522
|
-
|
|
38523
|
-
|
|
38524
|
-
var
|
|
38525
|
-
|
|
38526
|
-
|
|
38527
|
-
if (!iosBinaryPath) {
|
|
38528
|
-
throw new Error("iosBinaryPath is required. Provide iosBinaryPath or resourcesDir.");
|
|
38529
|
-
}
|
|
38530
|
-
return createIosCli(iosBinaryPath);
|
|
38531
|
-
}
|
|
38532
|
-
if (!ios) {
|
|
38533
|
-
ios = iosCli();
|
|
38534
|
-
}
|
|
38535
|
-
function runIosCommand(iosBinaryPath, args) {
|
|
38536
|
-
return new Promise((resolve2, reject) => {
|
|
38537
|
-
logDetail(`Running command: ${iosBinaryPath} ${args.join(" ")}`);
|
|
38538
|
-
const child = (0, import_node_child_process3.spawn)(iosBinaryPath, args, {
|
|
38539
|
-
windowsHide: true,
|
|
38540
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
38541
|
-
});
|
|
38542
|
-
let stdout = "";
|
|
38543
|
-
let stderr = "";
|
|
38544
|
-
child.stdout?.on("data", (data) => {
|
|
38545
|
-
stdout += data.toString();
|
|
38546
|
-
});
|
|
38547
|
-
child.stderr?.on("data", (data) => {
|
|
38548
|
-
stderr += data.toString();
|
|
38549
|
-
});
|
|
38550
|
-
child.on("error", (error) => {
|
|
38551
|
-
reject(error);
|
|
38552
|
-
});
|
|
38553
|
-
child.on("close", (code) => {
|
|
38554
|
-
const output = stdout.split("\n").map((line) => line.trim()).filter((line) => line.length > 0).map((line) => safeParseJson(line)).filter((item) => Boolean(item));
|
|
38555
|
-
const logMessages = stderr.split("\n").map((line) => line.trim()).filter((line) => line.length > 0).map((line) => safeParseJson(line)).filter((item) => Boolean(item)).map((lineJson) => ({
|
|
38556
|
-
level: lineJson.level,
|
|
38557
|
-
msg: lineJson.msg,
|
|
38558
|
-
timestamp: lineJson.timestamp
|
|
38559
|
-
}));
|
|
38560
|
-
resolve2({
|
|
38561
|
-
command: iosBinaryPath,
|
|
38562
|
-
args,
|
|
38563
|
-
output,
|
|
38564
|
-
logMessages,
|
|
38565
|
-
exitCode: code ?? 0
|
|
38566
|
-
});
|
|
38567
|
-
});
|
|
38568
|
-
});
|
|
38569
|
-
}
|
|
38570
|
-
function safeParseJson(line) {
|
|
38571
|
-
try {
|
|
38572
|
-
const parsed = JSON.parse(line);
|
|
38573
|
-
return parsed && typeof parsed === "object" ? parsed : void 0;
|
|
38574
|
-
} catch {
|
|
38575
|
-
return void 0;
|
|
38451
|
+
// src/logic/iosClient.ts
|
|
38452
|
+
var import_node_child_process = require("node:child_process");
|
|
38453
|
+
|
|
38454
|
+
// src/logic/profileParser.ts
|
|
38455
|
+
var ProfileParser = class {
|
|
38456
|
+
isRecord(value) {
|
|
38457
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
38576
38458
|
}
|
|
38577
|
-
|
|
38578
|
-
|
|
38579
|
-
|
|
38580
|
-
}
|
|
38581
|
-
function getStringField(record, key) {
|
|
38582
|
-
const value = record[key];
|
|
38583
|
-
return typeof value === "string" ? value : void 0;
|
|
38584
|
-
}
|
|
38585
|
-
function getBooleanField(record, key) {
|
|
38586
|
-
const value = record[key];
|
|
38587
|
-
return typeof value === "boolean" ? value : void 0;
|
|
38588
|
-
}
|
|
38589
|
-
function getNumberField(record, key) {
|
|
38590
|
-
const value = record[key];
|
|
38591
|
-
return typeof value === "number" ? value : void 0;
|
|
38592
|
-
}
|
|
38593
|
-
function getRecordField(record, key) {
|
|
38594
|
-
const value = record[key];
|
|
38595
|
-
return isRecord(value) ? value : void 0;
|
|
38596
|
-
}
|
|
38597
|
-
function toProfileManifest(record) {
|
|
38598
|
-
if (!record) {
|
|
38599
|
-
return void 0;
|
|
38459
|
+
getStringField(record, key) {
|
|
38460
|
+
const value = record[key];
|
|
38461
|
+
return typeof value === "string" ? value : void 0;
|
|
38600
38462
|
}
|
|
38601
|
-
|
|
38602
|
-
|
|
38603
|
-
|
|
38604
|
-
return void 0;
|
|
38463
|
+
getBooleanField(record, key) {
|
|
38464
|
+
const value = record[key];
|
|
38465
|
+
return typeof value === "boolean" ? value : void 0;
|
|
38605
38466
|
}
|
|
38606
|
-
|
|
38607
|
-
|
|
38608
|
-
|
|
38609
|
-
};
|
|
38610
|
-
}
|
|
38611
|
-
function toProfileMetadata(record) {
|
|
38612
|
-
if (!record) {
|
|
38613
|
-
return void 0;
|
|
38467
|
+
getNumberField(record, key) {
|
|
38468
|
+
const value = record[key];
|
|
38469
|
+
return typeof value === "number" ? value : void 0;
|
|
38614
38470
|
}
|
|
38615
|
-
|
|
38616
|
-
|
|
38617
|
-
|
|
38618
|
-
const payloadUuid = getStringField(record, "PayloadUUID");
|
|
38619
|
-
const payloadVersion = getNumberField(record, "PayloadVersion");
|
|
38620
|
-
if (payloadDescription === void 0 && payloadDisplayName === void 0 && payloadRemovalDisallowed === void 0 && payloadUuid === void 0 && payloadVersion === void 0) {
|
|
38621
|
-
return void 0;
|
|
38471
|
+
getRecordField(record, key) {
|
|
38472
|
+
const value = record[key];
|
|
38473
|
+
return this.isRecord(value) ? value : void 0;
|
|
38622
38474
|
}
|
|
38623
|
-
|
|
38624
|
-
|
|
38625
|
-
|
|
38626
|
-
|
|
38627
|
-
|
|
38628
|
-
|
|
38629
|
-
|
|
38630
|
-
|
|
38631
|
-
|
|
38632
|
-
|
|
38633
|
-
|
|
38634
|
-
|
|
38635
|
-
|
|
38636
|
-
if (!identifier && !manifest && !metadata && !status) {
|
|
38637
|
-
return void 0;
|
|
38475
|
+
toProfileManifest(record) {
|
|
38476
|
+
if (!record) {
|
|
38477
|
+
return void 0;
|
|
38478
|
+
}
|
|
38479
|
+
const description = this.getStringField(record, "Description");
|
|
38480
|
+
const isActive = this.getBooleanField(record, "IsActive");
|
|
38481
|
+
if (description === void 0 && isActive === void 0) {
|
|
38482
|
+
return void 0;
|
|
38483
|
+
}
|
|
38484
|
+
return {
|
|
38485
|
+
Description: description,
|
|
38486
|
+
IsActive: isActive
|
|
38487
|
+
};
|
|
38638
38488
|
}
|
|
38639
|
-
|
|
38640
|
-
|
|
38641
|
-
|
|
38642
|
-
|
|
38643
|
-
|
|
38644
|
-
|
|
38645
|
-
|
|
38646
|
-
|
|
38647
|
-
|
|
38648
|
-
|
|
38649
|
-
|
|
38650
|
-
|
|
38651
|
-
|
|
38652
|
-
|
|
38653
|
-
|
|
38654
|
-
|
|
38655
|
-
|
|
38656
|
-
|
|
38489
|
+
toProfileMetadata(record) {
|
|
38490
|
+
if (!record) {
|
|
38491
|
+
return void 0;
|
|
38492
|
+
}
|
|
38493
|
+
const payloadDescription = this.getStringField(record, "PayloadDescription");
|
|
38494
|
+
const payloadDisplayName = this.getStringField(record, "PayloadDisplayName");
|
|
38495
|
+
const payloadRemovalDisallowed = this.getBooleanField(record, "PayloadRemovalDisallowed");
|
|
38496
|
+
const payloadUuid = this.getStringField(record, "PayloadUUID");
|
|
38497
|
+
const payloadVersion = this.getNumberField(record, "PayloadVersion");
|
|
38498
|
+
if (payloadDescription === void 0 && payloadDisplayName === void 0 && payloadRemovalDisallowed === void 0 && payloadUuid === void 0 && payloadVersion === void 0) {
|
|
38499
|
+
return void 0;
|
|
38500
|
+
}
|
|
38501
|
+
return {
|
|
38502
|
+
PayloadDescription: payloadDescription,
|
|
38503
|
+
PayloadDisplayName: payloadDisplayName,
|
|
38504
|
+
PayloadRemovalDisallowed: payloadRemovalDisallowed,
|
|
38505
|
+
PayloadUUID: payloadUuid,
|
|
38506
|
+
PayloadVersion: payloadVersion
|
|
38507
|
+
};
|
|
38508
|
+
}
|
|
38509
|
+
toProfileListEntry(item) {
|
|
38510
|
+
const identifier = this.getStringField(item, "Identifier");
|
|
38511
|
+
const manifest = this.toProfileManifest(this.getRecordField(item, "Manifest"));
|
|
38512
|
+
const metadata = this.toProfileMetadata(this.getRecordField(item, "Metadata"));
|
|
38513
|
+
const status = this.getStringField(item, "Status");
|
|
38514
|
+
if (!identifier && !manifest && !metadata && !status) {
|
|
38515
|
+
return void 0;
|
|
38516
|
+
}
|
|
38517
|
+
return {
|
|
38518
|
+
Identifier: identifier,
|
|
38519
|
+
Manifest: manifest,
|
|
38520
|
+
Metadata: metadata,
|
|
38521
|
+
Status: status
|
|
38522
|
+
};
|
|
38523
|
+
}
|
|
38524
|
+
parseProfileListOutput(output) {
|
|
38525
|
+
const profiles = [];
|
|
38526
|
+
for (const item of output) {
|
|
38527
|
+
if (Array.isArray(item)) {
|
|
38528
|
+
for (const entry2 of item) {
|
|
38529
|
+
if (!this.isRecord(entry2)) {
|
|
38530
|
+
continue;
|
|
38531
|
+
}
|
|
38532
|
+
const profileEntry = this.toProfileListEntry(entry2);
|
|
38533
|
+
if (profileEntry) {
|
|
38534
|
+
profiles.push(profileEntry);
|
|
38535
|
+
}
|
|
38657
38536
|
}
|
|
38537
|
+
continue;
|
|
38538
|
+
}
|
|
38539
|
+
if (!this.isRecord(item)) {
|
|
38540
|
+
continue;
|
|
38541
|
+
}
|
|
38542
|
+
const entry = this.toProfileListEntry(item);
|
|
38543
|
+
if (entry) {
|
|
38544
|
+
profiles.push(entry);
|
|
38658
38545
|
}
|
|
38659
|
-
continue;
|
|
38660
|
-
}
|
|
38661
|
-
if (!isRecord(item)) {
|
|
38662
|
-
continue;
|
|
38663
38546
|
}
|
|
38664
|
-
|
|
38665
|
-
|
|
38666
|
-
|
|
38547
|
+
return profiles;
|
|
38548
|
+
}
|
|
38549
|
+
};
|
|
38550
|
+
|
|
38551
|
+
// src/logic/iosClient.ts
|
|
38552
|
+
var { logDetail: logDetail2, setNamespace: setNamespace5 } = createLoggers("");
|
|
38553
|
+
var IosClient = class {
|
|
38554
|
+
constructor(iosPath, udid, usbmuxdAddress) {
|
|
38555
|
+
this.iosPath = iosPath;
|
|
38556
|
+
this.udid = udid;
|
|
38557
|
+
this.usbmuxdAddress = usbmuxdAddress;
|
|
38558
|
+
setNamespace5(`apple-${this.udid}`);
|
|
38559
|
+
}
|
|
38560
|
+
safeParseJson(line) {
|
|
38561
|
+
try {
|
|
38562
|
+
const parsed = JSON.parse(line);
|
|
38563
|
+
return parsed && typeof parsed === "object" ? parsed : void 0;
|
|
38564
|
+
} catch {
|
|
38565
|
+
return void 0;
|
|
38667
38566
|
}
|
|
38668
38567
|
}
|
|
38669
|
-
|
|
38670
|
-
|
|
38671
|
-
|
|
38672
|
-
|
|
38673
|
-
|
|
38674
|
-
|
|
38675
|
-
|
|
38676
|
-
|
|
38677
|
-
|
|
38568
|
+
parseFsyncTreeStdout(stdout) {
|
|
38569
|
+
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);
|
|
38570
|
+
}
|
|
38571
|
+
parseIosOutput(output) {
|
|
38572
|
+
return output.split("\n").map((line) => line.trim()).filter((line) => line.length > 0).map((line) => this.safeParseJson(line)).filter((item) => Boolean(item));
|
|
38573
|
+
}
|
|
38574
|
+
spawnIosCommand(args) {
|
|
38575
|
+
logDetail2(`Running command: ${this.iosPath} ${args.join(" ")}`);
|
|
38576
|
+
logDetail2(`USBMUXD_SOCKET_ADDRESS: ${this.usbmuxdAddress}`);
|
|
38577
|
+
const child = (0, import_node_child_process.spawn)(this.iosPath, args, {
|
|
38678
38578
|
windowsHide: true,
|
|
38679
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
38680
|
-
|
|
38681
|
-
|
|
38682
|
-
|
|
38683
|
-
child.stdout?.on("data", (data) => {
|
|
38684
|
-
stdout += data.toString();
|
|
38685
|
-
});
|
|
38686
|
-
child.stderr?.on("data", (data) => {
|
|
38687
|
-
stderr += data.toString();
|
|
38688
|
-
});
|
|
38689
|
-
child.on("error", (error) => {
|
|
38690
|
-
reject(error);
|
|
38691
|
-
});
|
|
38692
|
-
child.on("close", (code) => {
|
|
38693
|
-
const logMessages = stderr.split("\n").map((line) => line.trim()).filter((line) => line.length > 0).map((line) => safeParseJson(line)).filter((item) => Boolean(item)).map((lineJson) => ({
|
|
38694
|
-
level: lineJson.level,
|
|
38695
|
-
msg: lineJson.msg,
|
|
38696
|
-
timestamp: lineJson.timestamp
|
|
38697
|
-
}));
|
|
38698
|
-
const raw = {
|
|
38699
|
-
command: iosBinaryPath,
|
|
38700
|
-
args,
|
|
38701
|
-
output: [],
|
|
38702
|
-
logMessages,
|
|
38703
|
-
exitCode: code ?? 0
|
|
38704
|
-
};
|
|
38705
|
-
resolve2({ stdout, stderr, exitCode: code ?? 0, raw });
|
|
38706
|
-
});
|
|
38707
|
-
});
|
|
38708
|
-
}
|
|
38709
|
-
function createIosCli(iosBinaryPath) {
|
|
38710
|
-
return {
|
|
38711
|
-
async listDevices() {
|
|
38712
|
-
const raw = await runIosCommand(iosBinaryPath, ["list"]);
|
|
38713
|
-
const output = raw.output[0];
|
|
38714
|
-
if (!output) {
|
|
38715
|
-
throw new Error("Failed to list devices, see if usbmuxd is running");
|
|
38579
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
38580
|
+
env: {
|
|
38581
|
+
...process.env,
|
|
38582
|
+
USBMUXD_SOCKET_ADDRESS: this.usbmuxdAddress
|
|
38716
38583
|
}
|
|
38717
|
-
|
|
38718
|
-
|
|
38719
|
-
|
|
38720
|
-
|
|
38721
|
-
|
|
38722
|
-
|
|
38723
|
-
|
|
38724
|
-
|
|
38725
|
-
|
|
38726
|
-
|
|
38727
|
-
},
|
|
38728
|
-
async removeProfile(deviceId, profileName) {
|
|
38729
|
-
return runIosCommand(iosBinaryPath, ["profile", "remove", profileName, "--udid", deviceId]);
|
|
38730
|
-
},
|
|
38731
|
-
async skipSteps(deviceId, steps) {
|
|
38732
|
-
const resourcesDir2 = getResourcesPath();
|
|
38733
|
-
return runIosCommand(iosBinaryPath, [
|
|
38734
|
-
"prepare",
|
|
38735
|
-
...steps ? steps.map((step) => `--skip=${step}`) : ["--skip-all"],
|
|
38736
|
-
`--certfile=${(0, import_node_path6.join)(resourcesDir2, "cert.der")}`,
|
|
38737
|
-
`--orgname=${process.env.ORGANIZATION_NAME}`,
|
|
38738
|
-
"--udid",
|
|
38739
|
-
deviceId
|
|
38740
|
-
]);
|
|
38741
|
-
},
|
|
38742
|
-
async printSteps() {
|
|
38743
|
-
return runIosCommand(iosBinaryPath, ["prepare", "print-steps"]);
|
|
38744
|
-
},
|
|
38745
|
-
async activate(deviceId) {
|
|
38746
|
-
return runIosCommand(iosBinaryPath, ["activate", "--udid", deviceId]);
|
|
38747
|
-
},
|
|
38748
|
-
async pair(deviceId) {
|
|
38749
|
-
return runIosCommand(iosBinaryPath, ["pair", "--udid", deviceId]);
|
|
38750
|
-
},
|
|
38751
|
-
async forward(deviceId, fromPort, toPort) {
|
|
38752
|
-
return runIosCommand(iosBinaryPath, [
|
|
38753
|
-
"forward",
|
|
38754
|
-
`--port=${fromPort}:${toPort}`,
|
|
38755
|
-
"--udid",
|
|
38756
|
-
deviceId
|
|
38757
|
-
]);
|
|
38758
|
-
},
|
|
38759
|
-
async info(deviceId) {
|
|
38760
|
-
return runIosCommand(iosBinaryPath, ["info", "--udid", deviceId]);
|
|
38761
|
-
},
|
|
38762
|
-
async listProfiles(deviceId) {
|
|
38763
|
-
const raw = await runIosCommand(iosBinaryPath, ["profile", "list", "--udid", deviceId]);
|
|
38764
|
-
return {
|
|
38765
|
-
profiles: parseProfileListOutput(raw.output),
|
|
38766
|
-
raw
|
|
38767
|
-
};
|
|
38768
|
-
},
|
|
38769
|
-
async installApp(deviceId, ipaPath) {
|
|
38770
|
-
return runIosCommand(iosBinaryPath, ["install", `--path=${ipaPath}`, "--udid", deviceId]);
|
|
38771
|
-
},
|
|
38772
|
-
async tunnelStart(deviceId, userspace = false) {
|
|
38773
|
-
const args = ["tunnel", "start", "--udid", deviceId, ...userspace ? ["--userspace"] : []];
|
|
38774
|
-
logDetail(`Spawning tunnel: ${iosBinaryPath} ${args.join(" ")}`);
|
|
38775
|
-
const child = (0, import_node_child_process3.spawn)(iosBinaryPath, args, {
|
|
38776
|
-
windowsHide: true,
|
|
38777
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
38584
|
+
});
|
|
38585
|
+
return child;
|
|
38586
|
+
}
|
|
38587
|
+
runIosCommand(args) {
|
|
38588
|
+
return new Promise((resolve2, reject) => {
|
|
38589
|
+
const child = this.spawnIosCommand(args);
|
|
38590
|
+
let stdout = "";
|
|
38591
|
+
let stderr = "";
|
|
38592
|
+
child.stdout?.on("data", (data) => {
|
|
38593
|
+
stdout += data.toString();
|
|
38778
38594
|
});
|
|
38779
|
-
|
|
38780
|
-
|
|
38781
|
-
|
|
38782
|
-
child.off("error", onError);
|
|
38783
|
-
child.off("exit", onExit);
|
|
38784
|
-
child.stdout?.off("data", onReadyCheck);
|
|
38785
|
-
child.stderr?.off("data", onReadyCheck);
|
|
38786
|
-
clearTimeout(readyTimeout);
|
|
38787
|
-
};
|
|
38788
|
-
const finish = (result) => {
|
|
38789
|
-
if (settled) return;
|
|
38790
|
-
settled = true;
|
|
38791
|
-
cleanup();
|
|
38792
|
-
if (result.reject) reject(result.reject);
|
|
38793
|
-
else if (result.resolve !== void 0) resolve2(result.resolve);
|
|
38794
|
-
};
|
|
38795
|
-
const onError = (err) => finish({ reject: err });
|
|
38796
|
-
const onExit = (code) => finish({ reject: new Error(`Tunnel exited early (code=${code})`) });
|
|
38797
|
-
const onReadyCheck = (data) => {
|
|
38798
|
-
const line = data.toString();
|
|
38799
|
-
const isReady = line.includes("Tunnel server started") || line.includes("tunnel") && (line.includes("listening") || line.includes("connected"));
|
|
38800
|
-
if (isReady) finish({ resolve: child });
|
|
38801
|
-
};
|
|
38802
|
-
const readyTimeout = setTimeout(() => finish({ resolve: child }), 1e4);
|
|
38803
|
-
child.once("error", onError);
|
|
38804
|
-
child.once("exit", onExit);
|
|
38805
|
-
child.stdout?.on("data", onReadyCheck);
|
|
38806
|
-
child.stderr?.on("data", onReadyCheck);
|
|
38595
|
+
child.stderr?.on("data", (data) => {
|
|
38596
|
+
logDetail2(`Command data: ${data.toString()}`);
|
|
38597
|
+
stderr += data.toString();
|
|
38807
38598
|
});
|
|
38808
|
-
|
|
38809
|
-
|
|
38810
|
-
|
|
38811
|
-
|
|
38812
|
-
|
|
38813
|
-
|
|
38814
|
-
|
|
38815
|
-
|
|
38816
|
-
|
|
38817
|
-
|
|
38818
|
-
|
|
38819
|
-
|
|
38820
|
-
|
|
38821
|
-
|
|
38822
|
-
|
|
38823
|
-
|
|
38824
|
-
|
|
38825
|
-
|
|
38826
|
-
|
|
38827
|
-
|
|
38828
|
-
|
|
38829
|
-
|
|
38830
|
-
|
|
38831
|
-
|
|
38832
|
-
|
|
38833
|
-
|
|
38834
|
-
|
|
38835
|
-
|
|
38836
|
-
|
|
38837
|
-
|
|
38838
|
-
|
|
38839
|
-
"fsync",
|
|
38840
|
-
"--app",
|
|
38841
|
-
app,
|
|
38842
|
-
"tree",
|
|
38843
|
-
"--udid",
|
|
38844
|
-
deviceId,
|
|
38845
|
-
...path !== void 0 && path !== "" ? ["--path", path] : []
|
|
38846
|
-
];
|
|
38847
|
-
const { stdout, raw } = await runIosCommandWithRawStdout(iosBinaryPath, args);
|
|
38848
|
-
const entries = parseFsyncTreeStdout(stdout);
|
|
38849
|
-
return { entries, raw };
|
|
38599
|
+
child.on("error", (error) => {
|
|
38600
|
+
logDetail2(`Command error: ${error.message}`);
|
|
38601
|
+
reject(error);
|
|
38602
|
+
});
|
|
38603
|
+
child.on("close", (code) => {
|
|
38604
|
+
logDetail2(`Command closed: ${code}`);
|
|
38605
|
+
const output = this.parseIosOutput(stdout);
|
|
38606
|
+
const logMessages = this.parseIosOutput(stderr).map((item) => ({
|
|
38607
|
+
level: item.level,
|
|
38608
|
+
msg: item.msg,
|
|
38609
|
+
timestamp: item.timestamp
|
|
38610
|
+
}));
|
|
38611
|
+
resolve2({
|
|
38612
|
+
command: this.iosPath,
|
|
38613
|
+
args,
|
|
38614
|
+
output,
|
|
38615
|
+
logMessages,
|
|
38616
|
+
exitCode: code ?? 0,
|
|
38617
|
+
raw: {
|
|
38618
|
+
stdout,
|
|
38619
|
+
stderr
|
|
38620
|
+
}
|
|
38621
|
+
});
|
|
38622
|
+
});
|
|
38623
|
+
});
|
|
38624
|
+
}
|
|
38625
|
+
async listDevices() {
|
|
38626
|
+
const raw = await this.runIosCommand(["list"]);
|
|
38627
|
+
const output = raw.output[0];
|
|
38628
|
+
if (!output) {
|
|
38629
|
+
throw new Error("Failed to list devices, see if usbmuxd is running");
|
|
38850
38630
|
}
|
|
38851
|
-
|
|
38852
|
-
|
|
38631
|
+
return {
|
|
38632
|
+
udids: output.deviceList,
|
|
38633
|
+
raw
|
|
38634
|
+
};
|
|
38635
|
+
}
|
|
38636
|
+
async wipe() {
|
|
38637
|
+
return this.runIosCommand(["erase", "--force", "--udid", this.udid]);
|
|
38638
|
+
}
|
|
38639
|
+
async installProfile(profilePath) {
|
|
38640
|
+
return this.runIosCommand(["profile", "add", profilePath, "--udid", this.udid]);
|
|
38641
|
+
}
|
|
38642
|
+
async removeProfile(profileName) {
|
|
38643
|
+
return this.runIosCommand(["profile", "remove", profileName, "--udid", this.udid]);
|
|
38644
|
+
}
|
|
38645
|
+
async listProfiles() {
|
|
38646
|
+
const raw = await this.runIosCommand(["profile", "list", "--udid", this.udid]);
|
|
38647
|
+
const parser = new ProfileParser();
|
|
38648
|
+
return {
|
|
38649
|
+
profiles: parser.parseProfileListOutput(raw.output),
|
|
38650
|
+
raw
|
|
38651
|
+
};
|
|
38652
|
+
}
|
|
38653
|
+
async skipSteps(steps) {
|
|
38654
|
+
if (!process.env.CERT_FILE) {
|
|
38655
|
+
throw new Error("CERT_FILE is not set");
|
|
38656
|
+
}
|
|
38657
|
+
if (!process.env.ORGANIZATION_NAME) {
|
|
38658
|
+
throw new Error("ORGANIZATION_NAME is not set");
|
|
38659
|
+
}
|
|
38660
|
+
return this.runIosCommand([
|
|
38661
|
+
"prepare",
|
|
38662
|
+
...steps ? steps.map((step) => `--skip=${step}`) : ["--skip-all"],
|
|
38663
|
+
`--certfile=${process.env.CERT_FILE}`,
|
|
38664
|
+
`--orgname=${process.env.ORGANIZATION_NAME}`,
|
|
38665
|
+
"--udid",
|
|
38666
|
+
this.udid
|
|
38667
|
+
]);
|
|
38668
|
+
}
|
|
38669
|
+
async listSteps() {
|
|
38670
|
+
return this.runIosCommand(["prepare", "print-steps"]);
|
|
38671
|
+
}
|
|
38672
|
+
async activate() {
|
|
38673
|
+
return this.runIosCommand(["activate", "--udid", this.udid]);
|
|
38674
|
+
}
|
|
38675
|
+
async pair() {
|
|
38676
|
+
return this.runIosCommand(["pair", "--udid", this.udid]);
|
|
38677
|
+
}
|
|
38678
|
+
async forward({ fromPort, toPort }) {
|
|
38679
|
+
return this.spawnIosCommand(["forward", `--port=${fromPort}:${toPort}`, "--udid", this.udid]);
|
|
38680
|
+
}
|
|
38681
|
+
async info() {
|
|
38682
|
+
return this.runIosCommand(["info", "--udid", this.udid]);
|
|
38683
|
+
}
|
|
38684
|
+
async installApp(ipaPath) {
|
|
38685
|
+
return this.runIosCommand(["install", `--path=${ipaPath}`, "--udid", this.udid]);
|
|
38686
|
+
}
|
|
38687
|
+
async uninstallApp(bundleId) {
|
|
38688
|
+
return this.runIosCommand(["uninstall", bundleId, "--udid", this.udid]);
|
|
38689
|
+
}
|
|
38690
|
+
/*
|
|
38691
|
+
* preconditions: tunnel is started
|
|
38692
|
+
* postconditions: apps are listed
|
|
38693
|
+
* @param deviceId - the device ID
|
|
38694
|
+
* @returns the list of apps
|
|
38695
|
+
*/
|
|
38696
|
+
async listApps() {
|
|
38697
|
+
return (await this.runIosCommand(["app", "list", "--nojson", "--udid", this.udid])).raw.stdout.split("\n").map((line) => {
|
|
38698
|
+
const [bundleId, displayName, version] = line.split(" ");
|
|
38699
|
+
return {
|
|
38700
|
+
bundleId,
|
|
38701
|
+
displayName,
|
|
38702
|
+
version
|
|
38703
|
+
};
|
|
38704
|
+
});
|
|
38705
|
+
}
|
|
38706
|
+
async devMode() {
|
|
38707
|
+
return this.runIosCommand(["devmode", "enable", "--udid", this.udid]);
|
|
38708
|
+
}
|
|
38709
|
+
async tunnelStart(userspace = false) {
|
|
38710
|
+
const args = ["tunnel", "start", "--udid", this.udid, ...userspace ? ["--userspace"] : []];
|
|
38711
|
+
logDetail2(`Spawning tunnel: ${this.iosPath} ${args.join(" ")}`);
|
|
38712
|
+
const child = (0, import_node_child_process.spawn)(this.iosPath, args, {
|
|
38713
|
+
windowsHide: true,
|
|
38714
|
+
env: {
|
|
38715
|
+
...process.env,
|
|
38716
|
+
USBMUXD_SOCKET_ADDRESS: this.usbmuxdAddress
|
|
38717
|
+
},
|
|
38718
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
38719
|
+
});
|
|
38720
|
+
let settled = false;
|
|
38721
|
+
const cleanup = () => {
|
|
38722
|
+
child.off("error", onError);
|
|
38723
|
+
child.off("exit", onExit);
|
|
38724
|
+
child.stdout?.off("data", onReadyCheck);
|
|
38725
|
+
child.stderr?.off("data", onReadyCheck);
|
|
38726
|
+
clearTimeout(readyTimeout);
|
|
38727
|
+
};
|
|
38728
|
+
const finish = (result) => {
|
|
38729
|
+
if (settled) return;
|
|
38730
|
+
settled = true;
|
|
38731
|
+
cleanup();
|
|
38732
|
+
if (result.reject) throw result.reject;
|
|
38733
|
+
if (result.resolve !== void 0) return result.resolve;
|
|
38734
|
+
throw new Error("Tunnel process not found");
|
|
38735
|
+
};
|
|
38736
|
+
const onError = (err) => finish({ reject: err });
|
|
38737
|
+
const onExit = (code) => finish({ reject: new Error(`Tunnel exited early (code=${code})`) });
|
|
38738
|
+
const onReadyCheck = (data) => {
|
|
38739
|
+
const line = data.toString();
|
|
38740
|
+
const isReady = line.includes("Tunnel server started") || line.includes("tunnel") && (line.includes("listening") || line.includes("connected"));
|
|
38741
|
+
if (isReady) finish({ resolve: child });
|
|
38742
|
+
};
|
|
38743
|
+
const readyTimeout = setTimeout(() => finish({ resolve: child }), 1e4);
|
|
38744
|
+
child.once("error", onError);
|
|
38745
|
+
child.once("exit", onExit);
|
|
38746
|
+
child.stdout?.on("data", onReadyCheck);
|
|
38747
|
+
child.stderr?.on("data", onReadyCheck);
|
|
38748
|
+
return child;
|
|
38749
|
+
}
|
|
38750
|
+
async fsyncPull({
|
|
38751
|
+
app,
|
|
38752
|
+
srcPath,
|
|
38753
|
+
dstPath
|
|
38754
|
+
}) {
|
|
38755
|
+
return this.runIosCommand([
|
|
38756
|
+
"fsync",
|
|
38757
|
+
"--app",
|
|
38758
|
+
app,
|
|
38759
|
+
"pull",
|
|
38760
|
+
"--srcPath",
|
|
38761
|
+
srcPath,
|
|
38762
|
+
"--dstPath",
|
|
38763
|
+
dstPath,
|
|
38764
|
+
"--udid",
|
|
38765
|
+
this.udid
|
|
38766
|
+
]);
|
|
38767
|
+
}
|
|
38768
|
+
async fsyncPush({
|
|
38769
|
+
app,
|
|
38770
|
+
srcPath,
|
|
38771
|
+
dstPath
|
|
38772
|
+
}) {
|
|
38773
|
+
return this.runIosCommand([
|
|
38774
|
+
"fsync",
|
|
38775
|
+
"--app",
|
|
38776
|
+
app,
|
|
38777
|
+
"push",
|
|
38778
|
+
"--srcPath",
|
|
38779
|
+
srcPath,
|
|
38780
|
+
"--dstPath",
|
|
38781
|
+
dstPath,
|
|
38782
|
+
"--udid",
|
|
38783
|
+
this.udid
|
|
38784
|
+
]);
|
|
38785
|
+
}
|
|
38786
|
+
async fsyncTree({
|
|
38787
|
+
app,
|
|
38788
|
+
path
|
|
38789
|
+
}) {
|
|
38790
|
+
const args = [
|
|
38791
|
+
"fsync",
|
|
38792
|
+
"--app",
|
|
38793
|
+
app,
|
|
38794
|
+
"tree",
|
|
38795
|
+
"--udid",
|
|
38796
|
+
this.udid,
|
|
38797
|
+
...path !== void 0 && path !== "" ? ["--path", path] : []
|
|
38798
|
+
];
|
|
38799
|
+
const result = await this.runIosCommand(args);
|
|
38800
|
+
const entries = this.parseFsyncTreeStdout(result.raw.stdout);
|
|
38801
|
+
return { entries, raw: result };
|
|
38802
|
+
}
|
|
38803
|
+
};
|
|
38853
38804
|
|
|
38854
38805
|
// src/logic/appleDeviceKit.ts
|
|
38855
|
-
var { logInfo:
|
|
38806
|
+
var { logInfo: logInfo7, logError: logError3, setNamespace: setNamespace6 } = createLoggers("apple-kit");
|
|
38856
38807
|
var AppleDeviceKit = class {
|
|
38857
|
-
constructor(udid, logicalPort) {
|
|
38808
|
+
constructor(udid, logicalPort, usbmuxdAddress) {
|
|
38858
38809
|
this.logicalPort = logicalPort;
|
|
38859
38810
|
this.deviceId = udid;
|
|
38860
|
-
|
|
38861
|
-
|
|
38811
|
+
setNamespace6(`apple-${udid}`);
|
|
38812
|
+
logInfo7(
|
|
38862
38813
|
`AppleDeviceKit initialized for device: ${this.deviceId}, logical port: ${this.logicalPort}`
|
|
38863
38814
|
);
|
|
38864
38815
|
const iosBinaryPath = resolveIosBinaryPath();
|
|
38865
38816
|
if (!iosBinaryPath) {
|
|
38866
38817
|
throw new Error("iosBinaryPath is required. Provide iosBinaryPath or resourcesDir.");
|
|
38867
38818
|
}
|
|
38868
|
-
this.
|
|
38819
|
+
this.iosClient = new IosClient(iosBinaryPath, udid, usbmuxdAddress);
|
|
38820
|
+
this.deviceActions = new DeviceActions(this.deviceId, this.iosClient);
|
|
38821
|
+
this.installActions = new InstallActions(this.deviceId, this.iosClient);
|
|
38822
|
+
this.activationFlow = new ActivationFlow(this.deviceId, this.iosClient);
|
|
38823
|
+
this.proxyActions = new ProxyActions(this.deviceId, this.iosClient);
|
|
38824
|
+
this.iosClient.tunnelStart(true).then((process3) => {
|
|
38825
|
+
this.tunnelProcess = process3;
|
|
38826
|
+
}).catch((error) => {
|
|
38827
|
+
logError3(`Failed to start tunnel: ${error.message}`);
|
|
38828
|
+
});
|
|
38869
38829
|
}
|
|
38870
38830
|
deviceId;
|
|
38871
38831
|
proxyProcess = null;
|
|
38872
38832
|
localDevicePort = null;
|
|
38873
38833
|
isDisposed = false;
|
|
38874
|
-
|
|
38834
|
+
iosClient;
|
|
38835
|
+
deviceActions;
|
|
38836
|
+
installActions;
|
|
38837
|
+
activationFlow;
|
|
38838
|
+
proxyActions;
|
|
38839
|
+
tunnelProcess = null;
|
|
38875
38840
|
static setResourcesDir(dir) {
|
|
38876
38841
|
setResourcesDir(dir);
|
|
38877
38842
|
}
|
|
@@ -38885,14 +38850,18 @@ var AppleDeviceKit = class {
|
|
|
38885
38850
|
}
|
|
38886
38851
|
async info() {
|
|
38887
38852
|
this.ensureNotDisposed();
|
|
38888
|
-
return
|
|
38853
|
+
return this.deviceActions.info();
|
|
38854
|
+
}
|
|
38855
|
+
async listDevices() {
|
|
38856
|
+
this.ensureNotDisposed();
|
|
38857
|
+
return this.deviceActions.listDevices();
|
|
38889
38858
|
}
|
|
38890
38859
|
/**
|
|
38891
38860
|
* Check if device is paired/trusted with this computer
|
|
38892
38861
|
*/
|
|
38893
38862
|
async isPaired() {
|
|
38894
38863
|
this.ensureNotDisposed();
|
|
38895
|
-
return isPaired(
|
|
38864
|
+
return this.deviceActions.isPaired();
|
|
38896
38865
|
}
|
|
38897
38866
|
/**
|
|
38898
38867
|
* Wait for device to be paired
|
|
@@ -38903,7 +38872,7 @@ var AppleDeviceKit = class {
|
|
|
38903
38872
|
*/
|
|
38904
38873
|
async waitForPairing(timeout2 = 12e4, pollInterval = 1e3) {
|
|
38905
38874
|
this.ensureNotDisposed();
|
|
38906
|
-
return waitForPairing(
|
|
38875
|
+
return this.deviceActions.waitForPairing({ timeout: timeout2, pollInterval });
|
|
38907
38876
|
}
|
|
38908
38877
|
/**
|
|
38909
38878
|
* Attempt to pair/trust the device
|
|
@@ -38911,7 +38880,7 @@ var AppleDeviceKit = class {
|
|
|
38911
38880
|
*/
|
|
38912
38881
|
async pair() {
|
|
38913
38882
|
this.ensureNotDisposed();
|
|
38914
|
-
return pair(
|
|
38883
|
+
return this.deviceActions.pair();
|
|
38915
38884
|
}
|
|
38916
38885
|
/**
|
|
38917
38886
|
* Trust/pair the device - initiates pairing and waits for user to accept
|
|
@@ -38927,15 +38896,14 @@ var AppleDeviceKit = class {
|
|
|
38927
38896
|
* @returns true if device is now trusted
|
|
38928
38897
|
*/
|
|
38929
38898
|
async trustDevice(timeout2 = 6e4, onWaitingForTrust) {
|
|
38930
|
-
this.
|
|
38931
|
-
return trustDevice(this.deviceId, timeout2, onWaitingForTrust);
|
|
38899
|
+
return this.deviceActions.trustDevice({ timeout: timeout2, onWaitingForTrust });
|
|
38932
38900
|
}
|
|
38933
38901
|
/**
|
|
38934
38902
|
* Unpair/untrust the device
|
|
38935
38903
|
*/
|
|
38936
38904
|
async unpair() {
|
|
38937
38905
|
this.ensureNotDisposed();
|
|
38938
|
-
return unpair(
|
|
38906
|
+
return this.deviceActions.unpair();
|
|
38939
38907
|
}
|
|
38940
38908
|
/**
|
|
38941
38909
|
* Install an IPA file on the device (install agent)
|
|
@@ -38944,7 +38912,7 @@ var AppleDeviceKit = class {
|
|
|
38944
38912
|
*/
|
|
38945
38913
|
async installApp(ipaPath, options) {
|
|
38946
38914
|
this.ensureNotDisposed();
|
|
38947
|
-
return installManagedApp(ipaPath,
|
|
38915
|
+
return this.installActions.installManagedApp(ipaPath, options);
|
|
38948
38916
|
}
|
|
38949
38917
|
/**
|
|
38950
38918
|
* Uninstall an app by bundle ID (uninstall agent)
|
|
@@ -38953,7 +38921,7 @@ var AppleDeviceKit = class {
|
|
|
38953
38921
|
*/
|
|
38954
38922
|
async uninstallApp(bundleId) {
|
|
38955
38923
|
this.ensureNotDisposed();
|
|
38956
|
-
uninstallApp(bundleId
|
|
38924
|
+
return this.installActions.uninstallApp(bundleId);
|
|
38957
38925
|
}
|
|
38958
38926
|
/**
|
|
38959
38927
|
* Check if an app is installed on the device
|
|
@@ -38962,14 +38930,14 @@ var AppleDeviceKit = class {
|
|
|
38962
38930
|
*/
|
|
38963
38931
|
async isAppInstalled(bundleId) {
|
|
38964
38932
|
this.ensureNotDisposed();
|
|
38965
|
-
return isAppInstalled(bundleId
|
|
38933
|
+
return this.installActions.isAppInstalled(bundleId);
|
|
38966
38934
|
}
|
|
38967
38935
|
/**
|
|
38968
38936
|
* List all installed user applications
|
|
38969
38937
|
*/
|
|
38970
38938
|
async listApps() {
|
|
38971
38939
|
this.ensureNotDisposed();
|
|
38972
|
-
return listApps(
|
|
38940
|
+
return this.installActions.listApps();
|
|
38973
38941
|
}
|
|
38974
38942
|
/**
|
|
38975
38943
|
* Start port forwarding and wait for it to be ready.
|
|
@@ -38985,17 +38953,11 @@ var AppleDeviceKit = class {
|
|
|
38985
38953
|
* @param startupTimeout Time to wait for proxy to start (ms)
|
|
38986
38954
|
* @returns The port forward result with the allocated local port
|
|
38987
38955
|
*/
|
|
38988
|
-
async startPortForwardAsync(devicePort
|
|
38956
|
+
async startPortForwardAsync(devicePort) {
|
|
38989
38957
|
this.ensureNotDisposed();
|
|
38990
38958
|
this.killProxyProcess();
|
|
38991
38959
|
this.localDevicePort = await getPorts({ port: portNumbers(3e4, 31e3) });
|
|
38992
|
-
const
|
|
38993
|
-
this.localDevicePort,
|
|
38994
|
-
devicePort,
|
|
38995
|
-
this.deviceId,
|
|
38996
|
-
startupTimeout
|
|
38997
|
-
);
|
|
38998
|
-
this.proxyProcess = process3;
|
|
38960
|
+
const result = await this.proxyActions.startPortForward(this.localDevicePort, devicePort);
|
|
38999
38961
|
return result;
|
|
39000
38962
|
}
|
|
39001
38963
|
/**
|
|
@@ -39003,7 +38965,7 @@ var AppleDeviceKit = class {
|
|
|
39003
38965
|
*/
|
|
39004
38966
|
killProxyProcess() {
|
|
39005
38967
|
if (this.proxyProcess) {
|
|
39006
|
-
|
|
38968
|
+
this.proxyActions.killPortForward();
|
|
39007
38969
|
this.proxyProcess = null;
|
|
39008
38970
|
}
|
|
39009
38971
|
}
|
|
@@ -39016,24 +38978,17 @@ var AppleDeviceKit = class {
|
|
|
39016
38978
|
this.localDevicePort = null;
|
|
39017
38979
|
}
|
|
39018
38980
|
}
|
|
39019
|
-
/**
|
|
39020
|
-
* Get the activation state of the device
|
|
39021
|
-
*/
|
|
39022
|
-
async getActivationState() {
|
|
39023
|
-
this.ensureNotDisposed();
|
|
39024
|
-
return getActivationState(this.deviceId, this.iosCli);
|
|
39025
|
-
}
|
|
39026
38981
|
/**
|
|
39027
38982
|
* Wipe the device
|
|
39028
38983
|
*/
|
|
39029
38984
|
async wipe() {
|
|
39030
|
-
return
|
|
38985
|
+
return this.deviceActions.wipe();
|
|
39031
38986
|
}
|
|
39032
38987
|
async removeProfile(profileIdentifier) {
|
|
39033
|
-
return removeProfile(profileIdentifier
|
|
38988
|
+
return this.deviceActions.removeProfile(profileIdentifier);
|
|
39034
38989
|
}
|
|
39035
38990
|
async listProfiles() {
|
|
39036
|
-
return
|
|
38991
|
+
return this.deviceActions.listProfiles();
|
|
39037
38992
|
}
|
|
39038
38993
|
/**
|
|
39039
38994
|
* Activate the device using the activation flow.
|
|
@@ -39046,8 +39001,7 @@ var AppleDeviceKit = class {
|
|
|
39046
39001
|
*/
|
|
39047
39002
|
async activate() {
|
|
39048
39003
|
this.ensureNotDisposed();
|
|
39049
|
-
|
|
39050
|
-
return await flow.run(this.deviceId);
|
|
39004
|
+
return this.activationFlow.run();
|
|
39051
39005
|
}
|
|
39052
39006
|
/**
|
|
39053
39007
|
* Get the device UDID
|
|
@@ -39090,8 +39044,9 @@ var AppleDeviceKit = class {
|
|
|
39090
39044
|
if (this.isDisposed) {
|
|
39091
39045
|
return;
|
|
39092
39046
|
}
|
|
39093
|
-
|
|
39047
|
+
logInfo7(`Disposing AppleDeviceKit for device: ${this.deviceId}`);
|
|
39094
39048
|
this.closePortForward();
|
|
39049
|
+
this.tunnelProcess?.kill();
|
|
39095
39050
|
this.isDisposed = true;
|
|
39096
39051
|
}
|
|
39097
39052
|
/**
|
|
@@ -39105,8 +39060,7 @@ var AppleDeviceKit = class {
|
|
|
39105
39060
|
0 && (module.exports = {
|
|
39106
39061
|
ActivationFlow,
|
|
39107
39062
|
AppleDeviceKit,
|
|
39108
|
-
|
|
39109
|
-
iosCli
|
|
39063
|
+
IosClient
|
|
39110
39064
|
});
|
|
39111
39065
|
/*! Bundled license information:
|
|
39112
39066
|
|