@mnemonik/cli 7.109.3 → 7.111.0

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.
Files changed (104) hide show
  1. package/dist/auth/credentials.js +297 -36
  2. package/dist/auth/index.d.ts +2 -0
  3. package/dist/auth/index.d.ts.map +1 -1
  4. package/dist/auth/index.js +1914 -19
  5. package/dist/auth/index.js.map +1 -1
  6. package/dist/auth/machineName.d.ts +8 -0
  7. package/dist/auth/machineName.d.ts.map +1 -0
  8. package/dist/auth/machineName.js +23 -0
  9. package/dist/auth/machineName.js.map +1 -0
  10. package/dist/consent.d.ts +29 -0
  11. package/dist/consent.d.ts.map +1 -0
  12. package/dist/consent.js +87 -0
  13. package/dist/consent.js.map +1 -0
  14. package/dist/diagnostics.js +301 -40
  15. package/dist/digests.json +102 -90
  16. package/dist/help.d.ts.map +1 -1
  17. package/dist/help.js +59 -44
  18. package/dist/help.js.map +1 -1
  19. package/dist/humanReason.d.ts +8 -0
  20. package/dist/humanReason.d.ts.map +1 -1
  21. package/dist/humanReason.js +44 -16
  22. package/dist/humanReason.js.map +1 -1
  23. package/dist/identity/migrate.js +1835 -44
  24. package/dist/install/hosts.d.ts +2 -0
  25. package/dist/install/hosts.d.ts.map +1 -1
  26. package/dist/install/hosts.js +23 -14
  27. package/dist/install/hosts.js.map +1 -1
  28. package/dist/install/journal.js +124 -11
  29. package/dist/install/journey.d.ts +20 -0
  30. package/dist/install/journey.d.ts.map +1 -1
  31. package/dist/install/journey.js +1913 -82
  32. package/dist/install/journey.js.map +1 -1
  33. package/dist/install/ownership.d.ts.map +1 -1
  34. package/dist/install/ownership.js +1818 -10
  35. package/dist/install/ownership.js.map +1 -1
  36. package/dist/install/transaction.js +1913 -19
  37. package/dist/install/ui.js +1910 -15
  38. package/dist/installation.js +133 -10
  39. package/dist/launcher.js +108 -4
  40. package/dist/output.d.ts +3 -0
  41. package/dist/output.d.ts.map +1 -1
  42. package/dist/output.js +11 -1
  43. package/dist/output.js.map +1 -1
  44. package/dist/preflight.d.ts +5 -0
  45. package/dist/preflight.d.ts.map +1 -1
  46. package/dist/preflight.js +14 -12
  47. package/dist/preflight.js.map +1 -1
  48. package/dist/project/eligibility.js +1917 -22
  49. package/dist/project/records.js +121 -8
  50. package/dist/project.d.ts +15 -0
  51. package/dist/project.d.ts.map +1 -1
  52. package/dist/project.js +229 -15
  53. package/dist/project.js.map +1 -1
  54. package/dist/router.d.ts +2 -0
  55. package/dist/router.d.ts.map +1 -1
  56. package/dist/router.js +2164 -122
  57. package/dist/router.js.map +1 -1
  58. package/dist/runtime/releaseSource.d.ts +6 -0
  59. package/dist/runtime/releaseSource.d.ts.map +1 -1
  60. package/dist/runtime/releaseSource.js +1933 -32
  61. package/dist/runtime/releaseSource.js.map +1 -1
  62. package/dist/runtime/selfUpdate.js +1809 -8
  63. package/dist/runtime/signers.js +28 -9
  64. package/dist/runtime/store.js +18 -6
  65. package/dist/runtime/updateCheck.d.ts +4 -0
  66. package/dist/runtime/updateCheck.d.ts.map +1 -0
  67. package/dist/runtime/updateCheck.js +6695 -0
  68. package/dist/runtime/updateCheck.js.map +1 -0
  69. package/dist/sbom.json +21 -21
  70. package/dist/scanner/control.d.ts +27 -1
  71. package/dist/scanner/control.d.ts.map +1 -1
  72. package/dist/scanner/control.js +207 -36
  73. package/dist/scanner/control.js.map +1 -1
  74. package/dist/scanner/discover.d.ts +5 -0
  75. package/dist/scanner/discover.d.ts.map +1 -1
  76. package/dist/scanner/discover.js +16 -6
  77. package/dist/scanner/discover.js.map +1 -1
  78. package/dist/scanner/enable.d.ts +2 -0
  79. package/dist/scanner/enable.d.ts.map +1 -1
  80. package/dist/scanner/enable.js +152 -14
  81. package/dist/scanner/enable.js.map +1 -1
  82. package/dist/scanner/picker.d.ts.map +1 -1
  83. package/dist/scanner/picker.js +5 -6
  84. package/dist/scanner/picker.js.map +1 -1
  85. package/dist/scanner/service.d.ts +2 -0
  86. package/dist/scanner/service.d.ts.map +1 -1
  87. package/dist/scanner/service.js +279 -54
  88. package/dist/scanner/service.js.map +1 -1
  89. package/dist/scanner/update.d.ts +8 -0
  90. package/dist/scanner/update.d.ts.map +1 -1
  91. package/dist/scanner/update.js +254 -20
  92. package/dist/scanner/update.js.map +1 -1
  93. package/dist/scanner-release.json +35 -30
  94. package/dist/screens/journey.d.ts +6 -1
  95. package/dist/screens/journey.d.ts.map +1 -1
  96. package/dist/screens/journey.js +29 -8
  97. package/dist/screens/journey.js.map +1 -1
  98. package/dist/status.d.ts +21 -0
  99. package/dist/status.d.ts.map +1 -1
  100. package/dist/status.js +1993 -39
  101. package/dist/status.js.map +1 -1
  102. package/dist/vendor/local-setup.js +256 -29
  103. package/dist/vendor/shared/runtimeSigners.js +38 -11
  104. package/package.json +31 -31
@@ -21,7 +21,6 @@ import { basename, dirname, join, resolve, sep, win32 } from "node:path";
21
21
  import { createHash, createPublicKey, randomUUID, timingSafeEqual, verify as verifySignature } from "node:crypto";
22
22
  import { execFile, execFileSync } from "node:child_process";
23
23
  import { promisify } from "node:util";
24
- import { hostname } from "node:os";
25
24
  function decodeBase64(text, length) {
26
25
  const bytes = Buffer.from(text, "base64");
27
26
  if (bytes.length !== length || bytes.toString("base64") !== text)
@@ -101,13 +100,30 @@ function readIdentity(stdout2) {
101
100
  throw new Error("acl_identity_unavailable");
102
101
  return { name: match[1], sid: match[2] };
103
102
  }
103
+ function* readWindowsIdentity() {
104
+ const user = readIdentity(yield [windowsCommand("whoami.exe"), identityArgs]);
105
+ if (!ADMINISTRATOR_RID.test(user.sid))
106
+ return user;
107
+ const groups = yield [windowsCommand("whoami.exe"), groupArgs];
108
+ const local = /^"[^"\r\n]*","[^"\r\n]*","S-1-5-113",/m.test(groups);
109
+ return {
110
+ ...user,
111
+ localAdministratorSid: local ? `${user.sid.slice(0, user.sid.lastIndexOf("-"))}-500` : null
112
+ };
113
+ }
104
114
  function windowsCurrentAccountSync() {
105
- return currentIdentity ??= readIdentity(hookExecuteSync(windowsCommand("whoami.exe"), identityArgs));
115
+ if (currentIdentity)
116
+ return currentIdentity;
117
+ const commands = readWindowsIdentity();
118
+ let step = commands.next();
119
+ while (!step.done)
120
+ step = commands.next(hookExecuteSync(...step.value));
121
+ return currentIdentity = step.value;
106
122
  }
107
123
  async function windowsIdentity(run) {
108
124
  if (currentIdentity)
109
125
  return currentIdentity;
110
- identityPending ??= run(windowsCommand("whoami.exe"), identityArgs).then((result) => currentIdentity = readIdentity(stdout(result))).finally(() => {
126
+ identityPending ??= drive(readWindowsIdentity(), run).then((identity) => currentIdentity = identity).finally(() => {
111
127
  identityPending = void 0;
112
128
  });
113
129
  return identityPending;
@@ -164,8 +180,8 @@ function privateEntries(entries, user, directory) {
164
180
  const ace = /^\(([AD]);((?:OI|CI|NP|IO|ID|SA|FA)*);[A-Za-z0-9]+;;;((?:S-1-(?:\d+-)+\d+)|[A-Z]{2})\)$/.exec(line);
165
181
  if (!ace)
166
182
  throw new Error("acl_unavailable");
167
- const ownAlias = ace[3] === "LA" && user.sid.endsWith("-500") && user.name.toLowerCase().startsWith(hostname().toLowerCase() + "\\");
168
- return (!directory || !ace[2]?.includes("ID")) && (ace[1] === "D" || ace[3] === user.sid || ownAlias);
183
+ const sid = ace[3] === "LA" ? user.localAdministratorSid : ace[3];
184
+ return (!directory || !ace[2]?.includes("ID")) && (ace[1] === "D" || sid === user.sid);
169
185
  });
170
186
  }
171
187
  function* prepareAclDirectory(state) {
@@ -188,7 +204,7 @@ function* prepareAclDirectory(state) {
188
204
  if (!stat.isDirectory() || stat.isSymbolicLink())
189
205
  throw new Error("acl_permissions");
190
206
  if (!auditDirectories.has(directory)) {
191
- currentIdentity ??= readIdentity(yield [windowsCommand("whoami.exe"), identityArgs]);
207
+ currentIdentity ??= yield* readWindowsIdentity();
192
208
  yield [windowsCommand("icacls.exe"), aclArgs(directory, currentIdentity.sid, created)];
193
209
  if (!created) {
194
210
  const temp = join(directory, `.acl-${randomUUID()}.tmp`);
@@ -285,7 +301,8 @@ function* hookPermission(path, created, session, directory = true) {
285
301
  if (lstatSync(session).isSymbolicLink() || !lstatSync(marker).isFile() || lstatSync(marker).isSymbolicLink())
286
302
  throw new Error("cache unavailable");
287
303
  receipt = JSON.parse(readFileSync(marker, "utf8"));
288
- if (!receipt || !receipt.paths || !receipt.identity || !/^S-1-(?:\d+-)+\d+$/.test(receipt.identity.sid) || typeof receipt.identity.name !== "string")
304
+ if (!receipt || !receipt.paths || !receipt.identity || !/^S-1-(?:\d+-)+\d+$/.test(receipt.identity.sid) || typeof receipt.identity.name !== "string" || // Written before LA was resolved by SID: re-read the token instead.
305
+ ADMINISTRATOR_RID.test(receipt.identity.sid) && receipt.identity.localAdministratorSid === void 0)
289
306
  receipt = void 0;
290
307
  } catch {
291
308
  }
@@ -297,7 +314,7 @@ function* hookPermission(path, created, session, directory = true) {
297
314
  receipts.set(session, receipt);
298
315
  return;
299
316
  }
300
- currentIdentity ??= readIdentity(yield [windowsCommand("whoami.exe"), identityArgs]);
317
+ currentIdentity ??= yield* readWindowsIdentity();
301
318
  const user = currentIdentity;
302
319
  if (receipt && receipt.identity.sid !== user.sid)
303
320
  receipt = void 0;
@@ -444,7 +461,7 @@ async function auditWindowsPermissions(state, paths, run = hookExecute, recursiv
444
461
  }
445
462
  return verdicts;
446
463
  }
447
- var execute, quote, RELEASE_MINISIGN_PUBLIC_KEY, identityArgs, currentIdentity, receipts, ttl, fresh, identityPending, aclArgs, hookOptions, hookExecute, stdout, auditDirectories, directoryPending, ownerWidth, unknownOwner;
464
+ var execute, quote, RELEASE_MINISIGN_PUBLIC_KEY, identityArgs, groupArgs, ADMINISTRATOR_RID, currentIdentity, receipts, ttl, fresh, identityPending, aclArgs, hookOptions, hookExecute, stdout, auditDirectories, directoryPending, ownerWidth, unknownOwner;
448
465
  var init_runtimeSigners = __esm({
449
466
  "packages/shared/dist/runtimeSigners.js"() {
450
467
  "use strict";
@@ -461,6 +478,8 @@ var init_runtimeSigners = __esm({
461
478
  quote = (text) => `'${text.replaceAll("'", "''")}'`;
462
479
  RELEASE_MINISIGN_PUBLIC_KEY = "RWSBYwgbjz0qKB4/ToA3dywBiAlQeBjoQpib4OHdjP2nDbpQnOVqpPm0";
463
480
  identityArgs = ["/user", "/fo", "csv", "/nh"];
481
+ groupArgs = ["/groups", "/fo", "csv", "/nh"];
482
+ ADMINISTRATOR_RID = /^S-1-5-21-\d+-\d+-\d+-500$/;
464
483
  receipts = /* @__PURE__ */ new Map();
465
484
  ttl = 10 * 6e4;
466
485
  fresh = (time) => time !== void 0 && Date.now() >= time && Date.now() - time < ttl;
@@ -16,7 +16,6 @@ import { basename, dirname, join, resolve, sep, win32 } from "node:path";
16
16
  import { createHash, createPublicKey, randomUUID, timingSafeEqual, verify as verifySignature } from "node:crypto";
17
17
  import { execFile, execFileSync } from "node:child_process";
18
18
  import { promisify } from "node:util";
19
- import { hostname } from "node:os";
20
19
  function decodeBase64(text, length) {
21
20
  const bytes = Buffer.from(text, "base64");
22
21
  if (bytes.length !== length || bytes.toString("base64") !== text)
@@ -96,10 +95,21 @@ function readIdentity(stdout2) {
96
95
  throw new Error("acl_identity_unavailable");
97
96
  return { name: match[1], sid: match[2] };
98
97
  }
98
+ function* readWindowsIdentity() {
99
+ const user = readIdentity(yield [windowsCommand("whoami.exe"), identityArgs]);
100
+ if (!ADMINISTRATOR_RID.test(user.sid))
101
+ return user;
102
+ const groups = yield [windowsCommand("whoami.exe"), groupArgs];
103
+ const local = /^"[^"\r\n]*","[^"\r\n]*","S-1-5-113",/m.test(groups);
104
+ return {
105
+ ...user,
106
+ localAdministratorSid: local ? `${user.sid.slice(0, user.sid.lastIndexOf("-"))}-500` : null
107
+ };
108
+ }
99
109
  async function windowsIdentity(run) {
100
110
  if (currentIdentity)
101
111
  return currentIdentity;
102
- identityPending ??= run(windowsCommand("whoami.exe"), identityArgs).then((result) => currentIdentity = readIdentity(stdout(result))).finally(() => {
112
+ identityPending ??= drive(readWindowsIdentity(), run).then((identity) => currentIdentity = identity).finally(() => {
103
113
  identityPending = void 0;
104
114
  });
105
115
  return identityPending;
@@ -152,8 +162,8 @@ function privateEntries(entries, user, directory) {
152
162
  const ace = /^\(([AD]);((?:OI|CI|NP|IO|ID|SA|FA)*);[A-Za-z0-9]+;;;((?:S-1-(?:\d+-)+\d+)|[A-Z]{2})\)$/.exec(line);
153
163
  if (!ace)
154
164
  throw new Error("acl_unavailable");
155
- const ownAlias = ace[3] === "LA" && user.sid.endsWith("-500") && user.name.toLowerCase().startsWith(hostname().toLowerCase() + "\\");
156
- return (!directory || !ace[2]?.includes("ID")) && (ace[1] === "D" || ace[3] === user.sid || ownAlias);
165
+ const sid = ace[3] === "LA" ? user.localAdministratorSid : ace[3];
166
+ return (!directory || !ace[2]?.includes("ID")) && (ace[1] === "D" || sid === user.sid);
157
167
  });
158
168
  }
159
169
  function* prepareAclDirectory(state) {
@@ -176,7 +186,7 @@ function* prepareAclDirectory(state) {
176
186
  if (!stat.isDirectory() || stat.isSymbolicLink())
177
187
  throw new Error("acl_permissions");
178
188
  if (!auditDirectories.has(directory)) {
179
- currentIdentity ??= readIdentity(yield [windowsCommand("whoami.exe"), identityArgs]);
189
+ currentIdentity ??= yield* readWindowsIdentity();
180
190
  yield [windowsCommand("icacls.exe"), aclArgs(directory, currentIdentity.sid, created)];
181
191
  if (!created) {
182
192
  const temp = join(directory, `.acl-${randomUUID()}.tmp`);
@@ -339,7 +349,7 @@ async function auditWindowsPermissions(state, paths, run = hookExecute, recursiv
339
349
  }
340
350
  return verdicts;
341
351
  }
342
- var execute, quote, RELEASE_MINISIGN_PUBLIC_KEY, identityArgs, currentIdentity, ttl, identityPending, aclArgs, hookOptions, hookExecute, stdout, auditDirectories, directoryPending, ownerWidth, unknownOwner;
352
+ var execute, quote, RELEASE_MINISIGN_PUBLIC_KEY, identityArgs, groupArgs, ADMINISTRATOR_RID, currentIdentity, ttl, identityPending, aclArgs, hookOptions, hookExecute, stdout, auditDirectories, directoryPending, ownerWidth, unknownOwner;
343
353
  var init_runtimeSigners = __esm({
344
354
  "packages/shared/dist/runtimeSigners.js"() {
345
355
  "use strict";
@@ -356,6 +366,8 @@ var init_runtimeSigners = __esm({
356
366
  quote = (text) => `'${text.replaceAll("'", "''")}'`;
357
367
  RELEASE_MINISIGN_PUBLIC_KEY = "RWSBYwgbjz0qKB4/ToA3dywBiAlQeBjoQpib4OHdjP2nDbpQnOVqpPm0";
358
368
  identityArgs = ["/user", "/fo", "csv", "/nh"];
369
+ groupArgs = ["/groups", "/fo", "csv", "/nh"];
370
+ ADMINISTRATOR_RID = /^S-1-5-21-\d+-\d+-\d+-500$/;
359
371
  ttl = 10 * 6e4;
360
372
  aclArgs = (path, sid, created = false) => [
361
373
  path,
@@ -0,0 +1,4 @@
1
+ import type { ReadinessUpdateCheck } from '@mnemonik/shared';
2
+ export declare function recordUpdateCheck(stateDir: string, result: ReadinessUpdateCheck['result'], now?: () => number): Promise<void>;
3
+ export declare function readUpdateCheck(stateDir: string): Promise<ReadinessUpdateCheck | undefined>;
4
+ //# sourceMappingURL=updateCheck.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"updateCheck.d.ts","sourceRoot":"","sources":["../../src/runtime/updateCheck.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAS7D,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,oBAAoB,CAAC,QAAQ,CAAC,EACtC,GAAG,GAAE,MAAM,MAAiB,GAC3B,OAAO,CAAC,IAAI,CAAC,CAOf;AAED,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,GAAG,SAAS,CAAC,CAcjG"}