@mcesystems/apple-kit 1.0.51 → 1.0.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +148 -213
- package/dist/index.js.map +4 -4
- package/dist/index.mjs +147 -212
- package/dist/index.mjs.map +4 -4
- package/dist/resources/plist/certificate-trust.xml +3 -1
- package/dist/types/logic/actions/install.d.ts +1 -0
- package/dist/types/logic/actions/install.d.ts.map +1 -1
- package/dist/types/logic/activationFlow.d.ts +2 -3
- package/dist/types/logic/activationFlow.d.ts.map +1 -1
- package/dist/types/logic/iosCli.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -15027,19 +15027,19 @@ var require_printer = __commonJS({
|
|
|
15027
15027
|
},
|
|
15028
15028
|
// Document
|
|
15029
15029
|
Document: function Document(node) {
|
|
15030
|
-
return
|
|
15030
|
+
return join9(node.definitions, "\n\n") + "\n";
|
|
15031
15031
|
},
|
|
15032
15032
|
OperationDefinition: function OperationDefinition(node) {
|
|
15033
15033
|
var op = node.operation;
|
|
15034
15034
|
var name = node.name;
|
|
15035
|
-
var varDefs = wrap("(",
|
|
15036
|
-
var directives =
|
|
15035
|
+
var varDefs = wrap("(", join9(node.variableDefinitions, ", "), ")");
|
|
15036
|
+
var directives = join9(node.directives, " ");
|
|
15037
15037
|
var selectionSet = node.selectionSet;
|
|
15038
|
-
return !name && !directives && !varDefs && op === "query" ? selectionSet :
|
|
15038
|
+
return !name && !directives && !varDefs && op === "query" ? selectionSet : join9([op, join9([name, varDefs]), directives, selectionSet], " ");
|
|
15039
15039
|
},
|
|
15040
15040
|
VariableDefinition: function VariableDefinition(_ref) {
|
|
15041
15041
|
var variable = _ref.variable, type = _ref.type, defaultValue = _ref.defaultValue, directives = _ref.directives;
|
|
15042
|
-
return variable + ": " + type + wrap(" = ", defaultValue) + wrap(" ",
|
|
15042
|
+
return variable + ": " + type + wrap(" = ", defaultValue) + wrap(" ", join9(directives, " "));
|
|
15043
15043
|
},
|
|
15044
15044
|
SelectionSet: function SelectionSet(_ref2) {
|
|
15045
15045
|
var selections = _ref2.selections;
|
|
@@ -15047,7 +15047,7 @@ var require_printer = __commonJS({
|
|
|
15047
15047
|
},
|
|
15048
15048
|
Field: function Field(_ref3) {
|
|
15049
15049
|
var alias = _ref3.alias, name = _ref3.name, args = _ref3.arguments, directives = _ref3.directives, selectionSet = _ref3.selectionSet;
|
|
15050
|
-
return
|
|
15050
|
+
return join9([wrap("", alias, ": ") + name + wrap("(", join9(args, ", "), ")"), join9(directives, " "), selectionSet], " ");
|
|
15051
15051
|
},
|
|
15052
15052
|
Argument: function Argument(_ref4) {
|
|
15053
15053
|
var name = _ref4.name, value = _ref4.value;
|
|
@@ -15056,18 +15056,18 @@ var require_printer = __commonJS({
|
|
|
15056
15056
|
// Fragments
|
|
15057
15057
|
FragmentSpread: function FragmentSpread(_ref5) {
|
|
15058
15058
|
var name = _ref5.name, directives = _ref5.directives;
|
|
15059
|
-
return "..." + name + wrap(" ",
|
|
15059
|
+
return "..." + name + wrap(" ", join9(directives, " "));
|
|
15060
15060
|
},
|
|
15061
15061
|
InlineFragment: function InlineFragment(_ref6) {
|
|
15062
15062
|
var typeCondition = _ref6.typeCondition, directives = _ref6.directives, selectionSet = _ref6.selectionSet;
|
|
15063
|
-
return
|
|
15063
|
+
return join9(["...", wrap("on ", typeCondition), join9(directives, " "), selectionSet], " ");
|
|
15064
15064
|
},
|
|
15065
15065
|
FragmentDefinition: function FragmentDefinition(_ref7) {
|
|
15066
15066
|
var name = _ref7.name, typeCondition = _ref7.typeCondition, variableDefinitions = _ref7.variableDefinitions, directives = _ref7.directives, selectionSet = _ref7.selectionSet;
|
|
15067
15067
|
return (
|
|
15068
15068
|
// Note: fragment variable definitions are experimental and may be changed
|
|
15069
15069
|
// or removed in the future.
|
|
15070
|
-
"fragment ".concat(name).concat(wrap("(",
|
|
15070
|
+
"fragment ".concat(name).concat(wrap("(", join9(variableDefinitions, ", "), ")"), " ") + "on ".concat(typeCondition, " ").concat(wrap("", join9(directives, " "), " ")) + selectionSet
|
|
15071
15071
|
);
|
|
15072
15072
|
},
|
|
15073
15073
|
// Value
|
|
@@ -15096,11 +15096,11 @@ var require_printer = __commonJS({
|
|
|
15096
15096
|
},
|
|
15097
15097
|
ListValue: function ListValue(_ref13) {
|
|
15098
15098
|
var values = _ref13.values;
|
|
15099
|
-
return "[" +
|
|
15099
|
+
return "[" + join9(values, ", ") + "]";
|
|
15100
15100
|
},
|
|
15101
15101
|
ObjectValue: function ObjectValue(_ref14) {
|
|
15102
15102
|
var fields = _ref14.fields;
|
|
15103
|
-
return "{" +
|
|
15103
|
+
return "{" + join9(fields, ", ") + "}";
|
|
15104
15104
|
},
|
|
15105
15105
|
ObjectField: function ObjectField(_ref15) {
|
|
15106
15106
|
var name = _ref15.name, value = _ref15.value;
|
|
@@ -15109,7 +15109,7 @@ var require_printer = __commonJS({
|
|
|
15109
15109
|
// Directive
|
|
15110
15110
|
Directive: function Directive(_ref16) {
|
|
15111
15111
|
var name = _ref16.name, args = _ref16.arguments;
|
|
15112
|
-
return "@" + name + wrap("(",
|
|
15112
|
+
return "@" + name + wrap("(", join9(args, ", "), ")");
|
|
15113
15113
|
},
|
|
15114
15114
|
// Type
|
|
15115
15115
|
NamedType: function NamedType(_ref17) {
|
|
@@ -15127,7 +15127,7 @@ var require_printer = __commonJS({
|
|
|
15127
15127
|
// Type System Definitions
|
|
15128
15128
|
SchemaDefinition: function SchemaDefinition(_ref20) {
|
|
15129
15129
|
var directives = _ref20.directives, operationTypes = _ref20.operationTypes;
|
|
15130
|
-
return
|
|
15130
|
+
return join9(["schema", join9(directives, " "), block(operationTypes)], " ");
|
|
15131
15131
|
},
|
|
15132
15132
|
OperationTypeDefinition: function OperationTypeDefinition(_ref21) {
|
|
15133
15133
|
var operation = _ref21.operation, type = _ref21.type;
|
|
@@ -15135,85 +15135,85 @@ var require_printer = __commonJS({
|
|
|
15135
15135
|
},
|
|
15136
15136
|
ScalarTypeDefinition: addDescription(function(_ref22) {
|
|
15137
15137
|
var name = _ref22.name, directives = _ref22.directives;
|
|
15138
|
-
return
|
|
15138
|
+
return join9(["scalar", name, join9(directives, " ")], " ");
|
|
15139
15139
|
}),
|
|
15140
15140
|
ObjectTypeDefinition: addDescription(function(_ref23) {
|
|
15141
15141
|
var name = _ref23.name, interfaces = _ref23.interfaces, directives = _ref23.directives, fields = _ref23.fields;
|
|
15142
|
-
return
|
|
15142
|
+
return join9(["type", name, wrap("implements ", join9(interfaces, " & ")), join9(directives, " "), block(fields)], " ");
|
|
15143
15143
|
}),
|
|
15144
15144
|
FieldDefinition: addDescription(function(_ref24) {
|
|
15145
15145
|
var name = _ref24.name, args = _ref24.arguments, type = _ref24.type, directives = _ref24.directives;
|
|
15146
|
-
return name + (hasMultilineItems(args) ? wrap("(\n", indent(
|
|
15146
|
+
return name + (hasMultilineItems(args) ? wrap("(\n", indent(join9(args, "\n")), "\n)") : wrap("(", join9(args, ", "), ")")) + ": " + type + wrap(" ", join9(directives, " "));
|
|
15147
15147
|
}),
|
|
15148
15148
|
InputValueDefinition: addDescription(function(_ref25) {
|
|
15149
15149
|
var name = _ref25.name, type = _ref25.type, defaultValue = _ref25.defaultValue, directives = _ref25.directives;
|
|
15150
|
-
return
|
|
15150
|
+
return join9([name + ": " + type, wrap("= ", defaultValue), join9(directives, " ")], " ");
|
|
15151
15151
|
}),
|
|
15152
15152
|
InterfaceTypeDefinition: addDescription(function(_ref26) {
|
|
15153
15153
|
var name = _ref26.name, directives = _ref26.directives, fields = _ref26.fields;
|
|
15154
|
-
return
|
|
15154
|
+
return join9(["interface", name, join9(directives, " "), block(fields)], " ");
|
|
15155
15155
|
}),
|
|
15156
15156
|
UnionTypeDefinition: addDescription(function(_ref27) {
|
|
15157
15157
|
var name = _ref27.name, directives = _ref27.directives, types = _ref27.types;
|
|
15158
|
-
return
|
|
15158
|
+
return join9(["union", name, join9(directives, " "), types && types.length !== 0 ? "= " + join9(types, " | ") : ""], " ");
|
|
15159
15159
|
}),
|
|
15160
15160
|
EnumTypeDefinition: addDescription(function(_ref28) {
|
|
15161
15161
|
var name = _ref28.name, directives = _ref28.directives, values = _ref28.values;
|
|
15162
|
-
return
|
|
15162
|
+
return join9(["enum", name, join9(directives, " "), block(values)], " ");
|
|
15163
15163
|
}),
|
|
15164
15164
|
EnumValueDefinition: addDescription(function(_ref29) {
|
|
15165
15165
|
var name = _ref29.name, directives = _ref29.directives;
|
|
15166
|
-
return
|
|
15166
|
+
return join9([name, join9(directives, " ")], " ");
|
|
15167
15167
|
}),
|
|
15168
15168
|
InputObjectTypeDefinition: addDescription(function(_ref30) {
|
|
15169
15169
|
var name = _ref30.name, directives = _ref30.directives, fields = _ref30.fields;
|
|
15170
|
-
return
|
|
15170
|
+
return join9(["input", name, join9(directives, " "), block(fields)], " ");
|
|
15171
15171
|
}),
|
|
15172
15172
|
DirectiveDefinition: addDescription(function(_ref31) {
|
|
15173
15173
|
var name = _ref31.name, args = _ref31.arguments, repeatable = _ref31.repeatable, locations = _ref31.locations;
|
|
15174
|
-
return "directive @" + name + (hasMultilineItems(args) ? wrap("(\n", indent(
|
|
15174
|
+
return "directive @" + name + (hasMultilineItems(args) ? wrap("(\n", indent(join9(args, "\n")), "\n)") : wrap("(", join9(args, ", "), ")")) + (repeatable ? " repeatable" : "") + " on " + join9(locations, " | ");
|
|
15175
15175
|
}),
|
|
15176
15176
|
SchemaExtension: function SchemaExtension(_ref32) {
|
|
15177
15177
|
var directives = _ref32.directives, operationTypes = _ref32.operationTypes;
|
|
15178
|
-
return
|
|
15178
|
+
return join9(["extend schema", join9(directives, " "), block(operationTypes)], " ");
|
|
15179
15179
|
},
|
|
15180
15180
|
ScalarTypeExtension: function ScalarTypeExtension(_ref33) {
|
|
15181
15181
|
var name = _ref33.name, directives = _ref33.directives;
|
|
15182
|
-
return
|
|
15182
|
+
return join9(["extend scalar", name, join9(directives, " ")], " ");
|
|
15183
15183
|
},
|
|
15184
15184
|
ObjectTypeExtension: function ObjectTypeExtension(_ref34) {
|
|
15185
15185
|
var name = _ref34.name, interfaces = _ref34.interfaces, directives = _ref34.directives, fields = _ref34.fields;
|
|
15186
|
-
return
|
|
15186
|
+
return join9(["extend type", name, wrap("implements ", join9(interfaces, " & ")), join9(directives, " "), block(fields)], " ");
|
|
15187
15187
|
},
|
|
15188
15188
|
InterfaceTypeExtension: function InterfaceTypeExtension(_ref35) {
|
|
15189
15189
|
var name = _ref35.name, directives = _ref35.directives, fields = _ref35.fields;
|
|
15190
|
-
return
|
|
15190
|
+
return join9(["extend interface", name, join9(directives, " "), block(fields)], " ");
|
|
15191
15191
|
},
|
|
15192
15192
|
UnionTypeExtension: function UnionTypeExtension(_ref36) {
|
|
15193
15193
|
var name = _ref36.name, directives = _ref36.directives, types = _ref36.types;
|
|
15194
|
-
return
|
|
15194
|
+
return join9(["extend union", name, join9(directives, " "), types && types.length !== 0 ? "= " + join9(types, " | ") : ""], " ");
|
|
15195
15195
|
},
|
|
15196
15196
|
EnumTypeExtension: function EnumTypeExtension(_ref37) {
|
|
15197
15197
|
var name = _ref37.name, directives = _ref37.directives, values = _ref37.values;
|
|
15198
|
-
return
|
|
15198
|
+
return join9(["extend enum", name, join9(directives, " "), block(values)], " ");
|
|
15199
15199
|
},
|
|
15200
15200
|
InputObjectTypeExtension: function InputObjectTypeExtension(_ref38) {
|
|
15201
15201
|
var name = _ref38.name, directives = _ref38.directives, fields = _ref38.fields;
|
|
15202
|
-
return
|
|
15202
|
+
return join9(["extend input", name, join9(directives, " "), block(fields)], " ");
|
|
15203
15203
|
}
|
|
15204
15204
|
};
|
|
15205
15205
|
function addDescription(cb) {
|
|
15206
15206
|
return function(node) {
|
|
15207
|
-
return
|
|
15207
|
+
return join9([node.description, cb(node)], "\n");
|
|
15208
15208
|
};
|
|
15209
15209
|
}
|
|
15210
|
-
function
|
|
15210
|
+
function join9(maybeArray, separator) {
|
|
15211
15211
|
return maybeArray ? maybeArray.filter(function(x) {
|
|
15212
15212
|
return x;
|
|
15213
15213
|
}).join(separator || "") : "";
|
|
15214
15214
|
}
|
|
15215
15215
|
function block(array) {
|
|
15216
|
-
return array && array.length !== 0 ? "{\n" + indent(
|
|
15216
|
+
return array && array.length !== 0 ? "{\n" + indent(join9(array, "\n")) + "\n}" : "";
|
|
15217
15217
|
}
|
|
15218
15218
|
function wrap(start, maybeString, end) {
|
|
15219
15219
|
return maybeString ? start + maybeString + (end || "") : "";
|
|
@@ -33361,12 +33361,11 @@ async function installApp(ipaPath, udid, options) {
|
|
|
33361
33361
|
const mdmClient = await resolveMdmClient(options.mdm);
|
|
33362
33362
|
const mdmInstallOptions = getMdmInstallOptions(options.mdm);
|
|
33363
33363
|
await mdmClient.installApp(udid, mdmInstallOptions);
|
|
33364
|
-
return;
|
|
33365
33364
|
}
|
|
33365
|
+
await installLocalApp(ipaPath, udid);
|
|
33366
|
+
}
|
|
33367
|
+
async function installLocalApp(ipaPath, udid) {
|
|
33366
33368
|
logTask(`Installing app ${ipaPath} on device ${udid}`);
|
|
33367
|
-
if (!await isPaired(udid)) {
|
|
33368
|
-
await waitForPairing(udid, 1e4);
|
|
33369
|
-
}
|
|
33370
33369
|
await runIDeviceTool("ideviceinstaller", ["-u", udid, "install", ipaPath]);
|
|
33371
33370
|
}
|
|
33372
33371
|
async function uninstallApp(bundleId, udid) {
|
|
@@ -33657,16 +33656,13 @@ function killPortForwardProcess(process2) {
|
|
|
33657
33656
|
|
|
33658
33657
|
// src/logic/activationFlow.ts
|
|
33659
33658
|
import { existsSync as existsSync4 } from "node:fs";
|
|
33660
|
-
import {
|
|
33661
|
-
import { tmpdir
|
|
33662
|
-
import { dirname as dirname3, join as
|
|
33659
|
+
import { unlink, writeFile } from "node:fs/promises";
|
|
33660
|
+
import { tmpdir } from "node:os";
|
|
33661
|
+
import { dirname as dirname3, join as join7, resolve as resolve4 } from "node:path";
|
|
33663
33662
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
33664
33663
|
|
|
33665
|
-
// src/utils/
|
|
33664
|
+
// src/utils/wifiProfile.ts
|
|
33666
33665
|
import { randomUUID } from "node:crypto";
|
|
33667
|
-
import { writeFile } from "node:fs/promises";
|
|
33668
|
-
import { tmpdir } from "node:os";
|
|
33669
|
-
import { join as join7 } from "node:path";
|
|
33670
33666
|
|
|
33671
33667
|
// src/utils/templateLoader.ts
|
|
33672
33668
|
import { existsSync as existsSync3 } from "node:fs";
|
|
@@ -33755,56 +33751,7 @@ function escapeXml(str) {
|
|
|
33755
33751
|
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
33756
33752
|
}
|
|
33757
33753
|
|
|
33758
|
-
// src/utils/trustProfile.ts
|
|
33759
|
-
async function generateTrustProfile(config, options) {
|
|
33760
|
-
const {
|
|
33761
|
-
organizationName,
|
|
33762
|
-
certificateBase64,
|
|
33763
|
-
certificateDisplayName = `${organizationName} Enterprise Certificate`,
|
|
33764
|
-
profileDisplayName = `${organizationName} Enterprise Trust`
|
|
33765
|
-
} = config;
|
|
33766
|
-
const profileUuid = randomUUID().toUpperCase();
|
|
33767
|
-
const certificateUuid = randomUUID().toUpperCase();
|
|
33768
|
-
const orgShortName = organizationName.split(/\s+/)[0].toLowerCase();
|
|
33769
|
-
const timestamp = Date.now();
|
|
33770
|
-
const profileId = `com.${orgShortName}.enterprise.trust.${timestamp}`;
|
|
33771
|
-
const payloadId = `${profileId}.cert`;
|
|
33772
|
-
logInfo(`Generating trust profile for: ${organizationName}`);
|
|
33773
|
-
const cleanCertBase64 = certificateBase64.replace(/-----BEGIN CERTIFICATE-----/g, "").replace(/-----END CERTIFICATE-----/g, "").replace(/\s/g, "");
|
|
33774
|
-
const template = await loadTemplate("certificate-trust.xml", options?.plistDir);
|
|
33775
|
-
const certificateFileName = `${orgShortName}_enterprise.cer`;
|
|
33776
|
-
const variables = {
|
|
33777
|
-
organizationName,
|
|
33778
|
-
certificateBase64: cleanCertBase64,
|
|
33779
|
-
certificateDescription: `Trusts ${organizationName} enterprise apps`,
|
|
33780
|
-
certificateDisplayName,
|
|
33781
|
-
profileDisplayName,
|
|
33782
|
-
profileId,
|
|
33783
|
-
profileUuid,
|
|
33784
|
-
payloadId,
|
|
33785
|
-
certificateUuid,
|
|
33786
|
-
certificateFileName,
|
|
33787
|
-
removalDisallowed: "false"
|
|
33788
|
-
};
|
|
33789
|
-
return processTemplate(template, variables);
|
|
33790
|
-
}
|
|
33791
|
-
async function generateTrustProfileFromEnv(organizationName, options) {
|
|
33792
|
-
const certBase64 = process.env.TRUST_CERT_BASE64;
|
|
33793
|
-
if (!certBase64) {
|
|
33794
|
-
logInfo("TRUST_CERT_BASE64 environment variable not set, skipping trust profile generation.");
|
|
33795
|
-
return void 0;
|
|
33796
|
-
}
|
|
33797
|
-
return generateTrustProfile(
|
|
33798
|
-
{
|
|
33799
|
-
organizationName,
|
|
33800
|
-
certificateBase64: certBase64
|
|
33801
|
-
},
|
|
33802
|
-
options
|
|
33803
|
-
);
|
|
33804
|
-
}
|
|
33805
|
-
|
|
33806
33754
|
// src/utils/wifiProfile.ts
|
|
33807
|
-
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
33808
33755
|
async function generateWifiProfile(config, options) {
|
|
33809
33756
|
const {
|
|
33810
33757
|
ssid,
|
|
@@ -33819,8 +33766,8 @@ async function generateWifiProfile(config, options) {
|
|
|
33819
33766
|
eapType = "PEAP",
|
|
33820
33767
|
acceptAnyCertificate = true
|
|
33821
33768
|
} = config;
|
|
33822
|
-
const profileUuid =
|
|
33823
|
-
const payloadUuid =
|
|
33769
|
+
const profileUuid = randomUUID().toUpperCase();
|
|
33770
|
+
const payloadUuid = randomUUID().toUpperCase();
|
|
33824
33771
|
const profileId = `com.mce.wifi.${ssid.replace(/[^a-zA-Z0-9]/g, "")}.${Date.now()}`;
|
|
33825
33772
|
const payloadId = `${profileId}.payload`;
|
|
33826
33773
|
logInfo(`Generating WiFi profile for SSID: ${ssid}, encryption: ${encryptionType}`);
|
|
@@ -33991,6 +33938,9 @@ function createIosCli(iosBinaryPath) {
|
|
|
33991
33938
|
async installProfile(deviceId, profilePath) {
|
|
33992
33939
|
return runIosCommand(iosBinaryPath, ["profile", "add", profilePath, "--udid", deviceId]);
|
|
33993
33940
|
},
|
|
33941
|
+
async removeProfile(deviceId, profileName) {
|
|
33942
|
+
return runIosCommand(iosBinaryPath, ["profile", "remove", profileName, "--udid", deviceId]);
|
|
33943
|
+
},
|
|
33994
33944
|
async skipSteps(deviceId) {
|
|
33995
33945
|
return runIosCommand(iosBinaryPath, ["prepare", "--skip-all", "--udid", deviceId]);
|
|
33996
33946
|
},
|
|
@@ -34016,11 +33966,16 @@ function createIosCli(iosBinaryPath) {
|
|
|
34016
33966
|
|
|
34017
33967
|
// src/logic/activationFlow.ts
|
|
34018
33968
|
var DEFAULT_RETRIES = 150;
|
|
34019
|
-
var DEFAULT_RETRY_DELAY_MS =
|
|
33969
|
+
var DEFAULT_RETRY_DELAY_MS = 1e3;
|
|
33970
|
+
var TIME_BETWEEN_INSTALLS = 5e3;
|
|
33971
|
+
var TIME_TO_WAIT_FOR_MANAGED_APP_INSTALL = 1e4;
|
|
33972
|
+
function sleep(ms) {
|
|
33973
|
+
return new Promise((resolve5) => setTimeout(resolve5, ms));
|
|
33974
|
+
}
|
|
34020
33975
|
var ActivationFlow = class {
|
|
34021
33976
|
iosCli;
|
|
34022
33977
|
mdmClientPromise;
|
|
34023
|
-
organizationName;
|
|
33978
|
+
// private readonly organizationName?: string;
|
|
34024
33979
|
resourcesDir;
|
|
34025
33980
|
constructor(config) {
|
|
34026
33981
|
const iosBinaryPath = resolveIosBinaryPath(config);
|
|
@@ -34029,7 +33984,6 @@ var ActivationFlow = class {
|
|
|
34029
33984
|
}
|
|
34030
33985
|
this.iosCli = createIosCli(iosBinaryPath);
|
|
34031
33986
|
this.mdmClientPromise = createMdmClientFromEnv({ resourcesDir: config.resourcesDir });
|
|
34032
|
-
this.organizationName = config.organizationName ?? process.env.ORGANIZATION_NAME;
|
|
34033
33987
|
this.resourcesDir = config.resourcesDir;
|
|
34034
33988
|
}
|
|
34035
33989
|
async run(udid) {
|
|
@@ -34042,25 +33996,27 @@ var ActivationFlow = class {
|
|
|
34042
33996
|
await this.retryIosCommand("wipe", () => this.iosCli.wipe(udid));
|
|
34043
33997
|
return "wiped";
|
|
34044
33998
|
}
|
|
34045
|
-
await this.installWifiProfile(udid);
|
|
33999
|
+
const wifiProfileIdentifier = await this.installWifiProfile(udid);
|
|
34046
34000
|
await this.installMdmProfile(udid);
|
|
34047
|
-
await this.installTrustProfile(udid);
|
|
34048
|
-
await this.installResourcesIpa(udid);
|
|
34049
34001
|
await this.retryIosCommand("skip steps", () => this.iosCli.skipSteps(udid));
|
|
34002
|
+
await this.installManagedApp(udid);
|
|
34003
|
+
await sleep(TIME_TO_WAIT_FOR_MANAGED_APP_INSTALL);
|
|
34004
|
+
await this.removeWifiProfile(udid, wifiProfileIdentifier);
|
|
34050
34005
|
return "activated";
|
|
34051
34006
|
}
|
|
34052
34007
|
async installWifiProfile(udid) {
|
|
34053
|
-
const
|
|
34054
|
-
const wifiProfile = await generateWifiProfileFromEnv({ plistDir });
|
|
34008
|
+
const wifiProfile = await generateWifiProfileFromEnv();
|
|
34055
34009
|
if (!wifiProfile) {
|
|
34056
|
-
return;
|
|
34010
|
+
return void 0;
|
|
34057
34011
|
}
|
|
34058
34012
|
const wifiProfilePath = await saveWifiProfileToTemp(wifiProfile);
|
|
34013
|
+
const wifiProfileIdentifier = getProfileIdentifierFromProfile(wifiProfile);
|
|
34059
34014
|
await this.retryIosCommand(
|
|
34060
34015
|
"install wifi profile",
|
|
34061
34016
|
() => this.iosCli.installProfile(udid, wifiProfilePath)
|
|
34062
34017
|
);
|
|
34063
34018
|
await removeTempFile(wifiProfilePath, "wifi profile");
|
|
34019
|
+
return wifiProfileIdentifier;
|
|
34064
34020
|
}
|
|
34065
34021
|
async getActivationState(udid) {
|
|
34066
34022
|
const infoResult = await this.retryIosCommand("device info", () => this.iosCli.info(udid));
|
|
@@ -34071,15 +34027,6 @@ var ActivationFlow = class {
|
|
|
34071
34027
|
return activationState;
|
|
34072
34028
|
}
|
|
34073
34029
|
async installMdmProfile(udid) {
|
|
34074
|
-
const offlineProfilePath = getResourcesEnrollmentProfilePath(this.resourcesDir, udid);
|
|
34075
|
-
if (offlineProfilePath) {
|
|
34076
|
-
logTask("Installing MDM enrollment profile from resources");
|
|
34077
|
-
await this.retryIosCommand(
|
|
34078
|
-
"install mdm profile",
|
|
34079
|
-
() => this.iosCli.installProfile(udid, offlineProfilePath)
|
|
34080
|
-
);
|
|
34081
|
-
return;
|
|
34082
|
-
}
|
|
34083
34030
|
const client = await this.requireMdmClient();
|
|
34084
34031
|
logTask("Installing MDM enrollment profile");
|
|
34085
34032
|
const enrollmentProfile = await this.retry(
|
|
@@ -34097,46 +34044,47 @@ var ActivationFlow = class {
|
|
|
34097
34044
|
);
|
|
34098
34045
|
await removeTempFile(profilePath, "mdm profile");
|
|
34099
34046
|
}
|
|
34100
|
-
async installTrustProfile(udid) {
|
|
34101
|
-
|
|
34102
|
-
|
|
34103
|
-
|
|
34104
|
-
|
|
34105
|
-
|
|
34106
|
-
|
|
34107
|
-
|
|
34108
|
-
|
|
34109
|
-
|
|
34110
|
-
|
|
34111
|
-
|
|
34112
|
-
|
|
34113
|
-
|
|
34114
|
-
|
|
34115
|
-
|
|
34116
|
-
|
|
34117
|
-
|
|
34118
|
-
|
|
34119
|
-
|
|
34120
|
-
|
|
34121
|
-
|
|
34122
|
-
|
|
34123
|
-
|
|
34124
|
-
|
|
34125
|
-
);
|
|
34047
|
+
// private async installTrustProfile(udid: string): Promise<void> {
|
|
34048
|
+
// const resourcesProfilePath = getResourcesTrustProfilePath(this.resourcesDir);
|
|
34049
|
+
// if (existsSync(resourcesProfilePath)) {
|
|
34050
|
+
// logTask("Installing trust profile from resources");
|
|
34051
|
+
// await this.retryIosCommand("install trust profile", () =>
|
|
34052
|
+
// this.iosCli.installProfile(udid, resourcesProfilePath)
|
|
34053
|
+
// );
|
|
34054
|
+
// return;
|
|
34055
|
+
// }
|
|
34056
|
+
// if (!this.organizationName) {
|
|
34057
|
+
// logError("ORGANIZATION_NAME is required to generate trust profile");
|
|
34058
|
+
// throw new Error("ORGANIZATION_NAME is required for trust profile generation");
|
|
34059
|
+
// }
|
|
34060
|
+
// const trustProfile = await generateTrustProfileFromEnv(this.organizationName);
|
|
34061
|
+
// if (!trustProfile) {
|
|
34062
|
+
// return;
|
|
34063
|
+
// }
|
|
34064
|
+
// logTask("Generating trust profile and saving to resources");
|
|
34065
|
+
// await ensureResourcesDirExists(this.resourcesDir);
|
|
34066
|
+
// await writeFile(resourcesProfilePath, trustProfile, "utf-8");
|
|
34067
|
+
// await this.retryIosCommand("install trust profile", () =>
|
|
34068
|
+
// this.iosCli.installProfile(udid, resourcesProfilePath)
|
|
34069
|
+
// );
|
|
34070
|
+
// }
|
|
34071
|
+
async installManagedApp(udid) {
|
|
34072
|
+
const ipaPath = resolveManagedAppPath(this.resourcesDir);
|
|
34073
|
+
await installLocalApp(ipaPath, udid);
|
|
34074
|
+
const mdmInstallOptions = getMdmInstallOptionsFromEnv();
|
|
34075
|
+
const client = await this.requireMdmClient();
|
|
34076
|
+
logTask("Installing app via MDM for management takeover");
|
|
34077
|
+
await sleep(TIME_BETWEEN_INSTALLS);
|
|
34078
|
+
client.installApp(udid, mdmInstallOptions);
|
|
34126
34079
|
}
|
|
34127
|
-
async
|
|
34128
|
-
|
|
34129
|
-
if (!ipaPath) {
|
|
34080
|
+
async removeWifiProfile(udid, profileIdentifier) {
|
|
34081
|
+
if (!profileIdentifier) {
|
|
34130
34082
|
return;
|
|
34131
34083
|
}
|
|
34132
|
-
logTask(
|
|
34133
|
-
await this.
|
|
34134
|
-
"
|
|
34135
|
-
|
|
34136
|
-
await installApp(ipaPath, udid);
|
|
34137
|
-
return true;
|
|
34138
|
-
},
|
|
34139
|
-
(result) => result
|
|
34084
|
+
logTask("Removing WiFi profile");
|
|
34085
|
+
await this.retryIosCommand(
|
|
34086
|
+
"remove wifi profile",
|
|
34087
|
+
() => this.iosCli.removeProfile(udid, profileIdentifier)
|
|
34140
34088
|
);
|
|
34141
34089
|
}
|
|
34142
34090
|
async requireMdmClient() {
|
|
@@ -34170,8 +34118,8 @@ var ActivationFlow = class {
|
|
|
34170
34118
|
}
|
|
34171
34119
|
};
|
|
34172
34120
|
async function saveProfileToTemp(profile, prefix) {
|
|
34173
|
-
const tempFilePath =
|
|
34174
|
-
await
|
|
34121
|
+
const tempFilePath = join7(tmpdir(), `mce_${prefix}_${Date.now()}.mobileconfig`);
|
|
34122
|
+
await writeFile(tempFilePath, profile, "utf-8");
|
|
34175
34123
|
logInfo(`Profile saved to: ${tempFilePath}`);
|
|
34176
34124
|
return tempFilePath;
|
|
34177
34125
|
}
|
|
@@ -34184,74 +34132,61 @@ async function removeTempFile(filePath, label) {
|
|
|
34184
34132
|
logError(`Failed to remove ${label} temp file: ${errorMsg}`);
|
|
34185
34133
|
}
|
|
34186
34134
|
}
|
|
34187
|
-
function
|
|
34188
|
-
const resolvedResourcesDir = resolveResourcesDir(resourcesDir);
|
|
34189
|
-
return join8(resolvedResourcesDir, "trust_profile.mobileconfig");
|
|
34190
|
-
}
|
|
34191
|
-
async function ensureResourcesDirExists(resourcesDir) {
|
|
34135
|
+
function resolveManagedAppPath(resourcesDir) {
|
|
34192
34136
|
const resolvedResourcesDir = resolveResourcesDir(resourcesDir);
|
|
34193
|
-
|
|
34194
|
-
|
|
34195
|
-
|
|
34196
|
-
if (resourcesDir) {
|
|
34197
|
-
return resolve4(resourcesDir);
|
|
34137
|
+
const ipaPath = join7(resolvedResourcesDir, "deviceagent.ipa");
|
|
34138
|
+
if (!existsSync4(ipaPath)) {
|
|
34139
|
+
throw new Error(`Managed app IPA not found at ${ipaPath}`);
|
|
34198
34140
|
}
|
|
34199
|
-
|
|
34200
|
-
const currentDir = dirname3(currentFile);
|
|
34201
|
-
const packageRoot = join8(currentDir, "..", "..");
|
|
34202
|
-
return join8(packageRoot, "resources");
|
|
34141
|
+
return ipaPath;
|
|
34203
34142
|
}
|
|
34204
|
-
function
|
|
34205
|
-
|
|
34143
|
+
function getMdmInstallOptionsFromEnv() {
|
|
34144
|
+
const appId = process.env.MDM_APP_ID;
|
|
34145
|
+
const url = process.env.MDM_APP_URL;
|
|
34146
|
+
const waitForInstalled = parseBooleanEnv(process.env.MDM_APP_WAIT_FOR_INSTALLED);
|
|
34147
|
+
if (!appId && !url) {
|
|
34148
|
+
throw new Error("MDM install requires MDM_APP_ID or MDM_APP_URL.");
|
|
34149
|
+
}
|
|
34150
|
+
return {
|
|
34151
|
+
appId,
|
|
34152
|
+
url,
|
|
34153
|
+
waitForInstalled
|
|
34154
|
+
};
|
|
34206
34155
|
}
|
|
34207
|
-
|
|
34208
|
-
|
|
34209
|
-
|
|
34210
|
-
|
|
34211
|
-
|
|
34212
|
-
|
|
34213
|
-
|
|
34214
|
-
|
|
34215
|
-
|
|
34216
|
-
|
|
34217
|
-
continue;
|
|
34218
|
-
}
|
|
34219
|
-
const name = entry.name.toLowerCase();
|
|
34220
|
-
if (name.endsWith(".ipa")) {
|
|
34221
|
-
return join8(dir, entry.name);
|
|
34222
|
-
}
|
|
34223
|
-
}
|
|
34156
|
+
function parseBooleanEnv(value) {
|
|
34157
|
+
if (!value) {
|
|
34158
|
+
return void 0;
|
|
34159
|
+
}
|
|
34160
|
+
const normalized = value.trim().toLowerCase();
|
|
34161
|
+
if (normalized === "true" || normalized === "1" || normalized === "yes") {
|
|
34162
|
+
return true;
|
|
34163
|
+
}
|
|
34164
|
+
if (normalized === "false" || normalized === "0" || normalized === "no") {
|
|
34165
|
+
return false;
|
|
34224
34166
|
}
|
|
34225
34167
|
return void 0;
|
|
34226
34168
|
}
|
|
34227
|
-
function
|
|
34228
|
-
|
|
34229
|
-
|
|
34230
|
-
|
|
34231
|
-
|
|
34232
|
-
|
|
34233
|
-
|
|
34234
|
-
|
|
34235
|
-
|
|
34236
|
-
}
|
|
34237
|
-
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
34238
|
-
logError(`Failed to read resources directory ${dir}: ${errorMsg}`);
|
|
34169
|
+
function getProfileIdentifierFromProfile(profile) {
|
|
34170
|
+
const pattern = /<key>PayloadIdentifier<\/key>\s*<string>([^<]+)<\/string>/g;
|
|
34171
|
+
const matches = [];
|
|
34172
|
+
let match = pattern.exec(profile);
|
|
34173
|
+
while (match) {
|
|
34174
|
+
matches.push(match[1].trim());
|
|
34175
|
+
match = pattern.exec(profile);
|
|
34176
|
+
}
|
|
34177
|
+
if (matches.length === 0) {
|
|
34239
34178
|
return void 0;
|
|
34240
34179
|
}
|
|
34180
|
+
return matches[matches.length - 1];
|
|
34241
34181
|
}
|
|
34242
|
-
function
|
|
34243
|
-
|
|
34244
|
-
|
|
34245
|
-
const candidates = [
|
|
34246
|
-
udid ? join8(mdmDir, `enrollment_${udid}.mobileconfig`) : void 0,
|
|
34247
|
-
join8(mdmDir, "enrollment.mobileconfig")
|
|
34248
|
-
];
|
|
34249
|
-
for (const candidate of candidates) {
|
|
34250
|
-
if (candidate && existsSync4(candidate)) {
|
|
34251
|
-
return candidate;
|
|
34252
|
-
}
|
|
34182
|
+
function resolveResourcesDir(resourcesDir) {
|
|
34183
|
+
if (resourcesDir) {
|
|
34184
|
+
return resolve4(resourcesDir);
|
|
34253
34185
|
}
|
|
34254
|
-
|
|
34186
|
+
const currentFile = fileURLToPath2(import.meta.url);
|
|
34187
|
+
const currentDir = dirname3(currentFile);
|
|
34188
|
+
const packageRoot = join7(currentDir, "..", "..");
|
|
34189
|
+
return join7(packageRoot, "resources");
|
|
34255
34190
|
}
|
|
34256
34191
|
function resolveIosBinaryPath(config) {
|
|
34257
34192
|
if (config.iosBinaryPath) {
|
|
@@ -34262,7 +34197,7 @@ function resolveIosBinaryPath(config) {
|
|
|
34262
34197
|
}
|
|
34263
34198
|
const platform = process.platform;
|
|
34264
34199
|
const binaryName = platform === "win32" ? "ios.exe" : "ios";
|
|
34265
|
-
return
|
|
34200
|
+
return join7(resolveResourcesDir(config.resourcesDir), "ios", "bin", platform, binaryName);
|
|
34266
34201
|
}
|
|
34267
34202
|
function getActivationState2(output) {
|
|
34268
34203
|
if (!Array.isArray(output) || output.length === 0) {
|
|
@@ -34537,7 +34472,7 @@ var AppleDeviceKit = class {
|
|
|
34537
34472
|
|
|
34538
34473
|
// src/logic/actions/usbmuxd.ts
|
|
34539
34474
|
import { spawn as spawn3 } from "node:child_process";
|
|
34540
|
-
import { join as
|
|
34475
|
+
import { join as join8 } from "node:path";
|
|
34541
34476
|
var usbmuxdProcess = null;
|
|
34542
34477
|
function startUsbmuxd(foreground = false, options) {
|
|
34543
34478
|
const current = usbmuxdProcess;
|
|
@@ -34547,7 +34482,7 @@ function startUsbmuxd(foreground = false, options) {
|
|
|
34547
34482
|
}
|
|
34548
34483
|
const binPath = getResourcesBinPath({ resourcesDir: options?.resourcesDir });
|
|
34549
34484
|
const ext = process.platform === "win32" ? ".exe" : "";
|
|
34550
|
-
const toolPath = binPath ?
|
|
34485
|
+
const toolPath = binPath ? join8(binPath, `usbmuxd${ext}`) : `usbmuxd${ext}`;
|
|
34551
34486
|
const args = foreground ? ["-f"] : [];
|
|
34552
34487
|
const spawnOptions = {
|
|
34553
34488
|
windowsHide: true,
|