@mcesystems/apple-kit 1.0.70 → 1.0.72

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