@node9/proxy 2.3.0 → 2.4.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 (3) hide show
  1. package/dist/cli.js +69 -95
  2. package/dist/cli.mjs +222 -248
  3. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -9810,7 +9810,7 @@ function claudeDesktopConfigPath(homeDir2 = import_os14.default.homedir()) {
9810
9810
  return import_path17.default.join(homeDir2, ".config", "Claude", "claude_desktop_config.json");
9811
9811
  }
9812
9812
  if (process.platform === "win32") {
9813
- const appData = process.env.APPDATA ?? import_path17.default.join(homeDir2, "AppData", "Roaming");
9813
+ const appData = process.env.APPDATA || import_path17.default.join(homeDir2, "AppData", "Roaming");
9814
9814
  return import_path17.default.join(appData, "Claude", "claude_desktop_config.json");
9815
9815
  }
9816
9816
  return null;
@@ -18303,7 +18303,7 @@ var init_ship = __esm({
18303
18303
  });
18304
18304
 
18305
18305
  // src/policy-snapshot/build.ts
18306
- function buildPolicySnapshot(config, activeShields, overrides, mcpTools = {}, statusEntries = [], syncHealth) {
18306
+ function buildPolicySnapshot(config, activeShields, overrides, mcpTools = {}, statusEntries = [], syncHealth, identity) {
18307
18307
  const p = config.policy;
18308
18308
  const statusByKey = /* @__PURE__ */ new Map();
18309
18309
  for (const s of statusEntries) {
@@ -18372,7 +18372,9 @@ function buildPolicySnapshot(config, activeShields, overrides, mcpTools = {}, st
18372
18372
  lastError: syncHealth.lastError,
18373
18373
  consecutiveFailures: syncHealth.consecutiveFailures
18374
18374
  }
18375
- }
18375
+ },
18376
+ // Machine identity — heals legacy machineId-less keys on the SaaS side.
18377
+ ...identity && { machineId: identity.machineId, platform: identity.platform }
18376
18378
  };
18377
18379
  }
18378
18380
  var MAX_RULES, MAX_EGRESS, MAX_MCP_SERVERS, MAX_MCP_TOOLS;
@@ -18748,6 +18750,34 @@ var init_ship2 = __esm({
18748
18750
  }
18749
18751
  });
18750
18752
 
18753
+ // src/machine-id.ts
18754
+ function getMachineId(homeDir2 = os34.homedir()) {
18755
+ const file = path37.join(homeDir2, ".node9", "machine-id");
18756
+ try {
18757
+ const existing = fs38.readFileSync(file, "utf-8").trim();
18758
+ if (UUID_RE.test(existing)) return existing;
18759
+ } catch {
18760
+ }
18761
+ const id = crypto5.randomUUID();
18762
+ try {
18763
+ fs38.mkdirSync(path37.dirname(file), { recursive: true });
18764
+ fs38.writeFileSync(file, id + "\n", { mode: 384 });
18765
+ } catch {
18766
+ }
18767
+ return id;
18768
+ }
18769
+ var crypto5, fs38, os34, path37, UUID_RE;
18770
+ var init_machine_id = __esm({
18771
+ "src/machine-id.ts"() {
18772
+ "use strict";
18773
+ crypto5 = __toESM(require("crypto"));
18774
+ fs38 = __toESM(require("fs"));
18775
+ os34 = __toESM(require("os"));
18776
+ path37 = __toESM(require("path"));
18777
+ UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
18778
+ }
18779
+ });
18780
+
18751
18781
  // src/daemon/sync.ts
18752
18782
  function emptySignals3() {
18753
18783
  return {
@@ -19199,7 +19229,10 @@ async function pushPolicySnapshot(creds) {
19199
19229
  resolveMcpStatus(),
19200
19230
  // fleet-ship Step 2: ship this machine's sync health so the dashboard can
19201
19231
  // show "sync failing" badges. readSyncHealth is local (same module, no circular).
19202
- readSyncHealth()
19232
+ readSyncHealth(),
19233
+ // Machine identity — heals legacy machineId-less keys on the SaaS side
19234
+ // (login-v2 duplicate-key fix). getMachineId mints on first need.
19235
+ { machineId: getMachineId(), platform: process.platform }
19203
19236
  );
19204
19237
  await shipPolicySnapshot(body, creds);
19205
19238
  } catch {
@@ -19223,7 +19256,8 @@ async function runPolicyPush() {
19223
19256
  // resolve ${VAR} placeholders — so this push reflects THIS process's env
19224
19257
  // (daemon here, user shell in runPolicyPush); see the P2 design's two-env note.
19225
19258
  resolveMcpStatus(),
19226
- readSyncHealth()
19259
+ readSyncHealth(),
19260
+ { machineId: getMachineId(), platform: process.platform }
19227
19261
  );
19228
19262
  const sent = await shipPolicySnapshot(body, creds);
19229
19263
  return sent ? { ok: true } : { ok: false, reason: "Push failed (network or server error)" };
@@ -19408,6 +19442,7 @@ var init_sync = __esm({
19408
19442
  init_scan_watermark();
19409
19443
  init_state2();
19410
19444
  init_audit();
19445
+ init_machine_id();
19411
19446
  FINDING_TO_SIGNAL3 = {
19412
19447
  dlp: "dlpFindings",
19413
19448
  pii: "piiFindings",
@@ -21561,74 +21596,36 @@ function uninstallSystemd() {
21561
21596
  function isSystemdInstalled() {
21562
21597
  return import_fs43.default.existsSync(SYSTEMD_UNIT);
21563
21598
  }
21599
+ function windowsStartupDir(homeDir2 = import_os39.default.homedir()) {
21600
+ const appData = process.env.APPDATA || import_path42.default.join(homeDir2, "AppData", "Roaming");
21601
+ return import_path42.default.join(appData, "Microsoft", "Windows", "Start Menu", "Programs", "Startup");
21602
+ }
21564
21603
  function windowsLauncherVbs(nodePath, scriptPath) {
21565
21604
  for (const p of [nodePath, scriptPath]) {
21566
21605
  if (p.includes('"')) throw new Error(`Illegal quote in path: ${p}`);
21567
21606
  }
21568
21607
  return [
21569
- "' Auto-generated by node9 \u2014 starts the approval daemon with no console window.",
21570
- "' Recreated on every `node9 daemon install`; safe to delete (uninstall does).",
21608
+ "' Auto-generated by node9 - starts the approval daemon with no console window.",
21609
+ "' Recreated by `node9 daemon install`; removed by `node9 daemon uninstall`.",
21571
21610
  'Set sh = CreateObject("Wscript.Shell")',
21572
21611
  'sh.Environment("PROCESS")("NODE9_AUTO_STARTED") = "1"',
21573
21612
  `sh.Run """${nodePath}"" ""${scriptPath}"" daemon", 0, False`,
21574
21613
  ""
21575
21614
  ].join("\r\n");
21576
21615
  }
21577
- function schtasksCreateArgs(launcherPath) {
21578
- return [
21579
- "/Create",
21580
- "/TN",
21581
- SCHTASKS_TASK,
21582
- "/TR",
21583
- `wscript.exe //B "${launcherPath}"`,
21584
- "/SC",
21585
- "ONLOGON",
21586
- "/F"
21587
- ];
21588
- }
21589
- function installSchtasks(binaryPath) {
21590
- const launcher = WIN_LAUNCHER();
21591
- const dir = import_path42.default.dirname(launcher);
21616
+ function installWindowsStartup(binaryPath) {
21617
+ const target = WIN_LAUNCHER();
21618
+ const dir = import_path42.default.dirname(target);
21592
21619
  if (!import_fs43.default.existsSync(dir)) import_fs43.default.mkdirSync(dir, { recursive: true });
21593
- import_fs43.default.writeFileSync(launcher, windowsLauncherVbs(process.execPath, binaryPath), "utf-8");
21594
- const create = (0, import_child_process3.spawnSync)("schtasks", schtasksCreateArgs(launcher), {
21595
- encoding: "utf8",
21596
- timeout: 1e4
21597
- });
21598
- if (create.status !== 0) {
21599
- throw new Error(
21600
- `schtasks /Create failed: ${create.stderr || create.stdout || "unknown error"}`
21601
- );
21602
- }
21603
- (0, import_child_process3.spawnSync)("schtasks", ["/Run", "/TN", SCHTASKS_TASK], { encoding: "utf8", timeout: 1e4 });
21620
+ import_fs43.default.writeFileSync(target, windowsLauncherVbs(process.execPath, binaryPath), "utf-8");
21621
+ (0, import_child_process3.spawnSync)("wscript.exe", ["//B", target], { encoding: "utf8", timeout: 1e4 });
21604
21622
  }
21605
- function uninstallSchtasks() {
21606
- (0, import_child_process3.spawnSync)("schtasks", ["/Delete", "/TN", SCHTASKS_TASK, "/F"], {
21607
- encoding: "utf8",
21608
- timeout: 1e4
21609
- });
21610
- const launcher = WIN_LAUNCHER();
21611
- if (import_fs43.default.existsSync(launcher)) {
21612
- try {
21613
- import_fs43.default.unlinkSync(launcher);
21614
- } catch {
21615
- }
21616
- }
21623
+ function uninstallWindowsStartup() {
21624
+ const target = WIN_LAUNCHER();
21625
+ if (import_fs43.default.existsSync(target)) import_fs43.default.unlinkSync(target);
21617
21626
  }
21618
- function isSchtasksInstalled() {
21619
- const r = (0, import_child_process3.spawnSync)("schtasks", ["/Query", "/TN", SCHTASKS_TASK], {
21620
- encoding: "utf8",
21621
- timeout: 5e3
21622
- });
21623
- return r.status === 0;
21624
- }
21625
- function isSchtasksEnabled() {
21626
- const r = (0, import_child_process3.spawnSync)("schtasks", ["/Query", "/TN", SCHTASKS_TASK, "/XML"], {
21627
- encoding: "utf8",
21628
- timeout: 5e3
21629
- });
21630
- if (r.status !== 0) return false;
21631
- return !/<Enabled>\s*false\s*<\/Enabled>/i.test(r.stdout ?? "");
21627
+ function isWindowsStartupInstalled() {
21628
+ return import_fs43.default.existsSync(WIN_LAUNCHER());
21632
21629
  }
21633
21630
  function stopRunningDaemon() {
21634
21631
  const pidFile = import_path42.default.join(import_os39.default.homedir(), ".node9", "daemon.pid");
@@ -21688,9 +21685,9 @@ function installDaemonService() {
21688
21685
  return { ok: true, platform: "systemd", alreadyInstalled };
21689
21686
  }
21690
21687
  if (process.platform === "win32") {
21691
- const alreadyInstalled = isSchtasksInstalled();
21692
- installSchtasks(binary);
21693
- return { ok: true, platform: "schtasks", alreadyInstalled };
21688
+ const alreadyInstalled = isWindowsStartupInstalled();
21689
+ installWindowsStartup(binary);
21690
+ return { ok: true, platform: "startup-folder", alreadyInstalled };
21694
21691
  }
21695
21692
  return {
21696
21693
  ok: false,
@@ -21714,8 +21711,8 @@ function uninstallDaemonService() {
21714
21711
  return { ok: true, platform: "systemd", alreadyInstalled: false };
21715
21712
  }
21716
21713
  if (process.platform === "win32") {
21717
- uninstallSchtasks();
21718
- return { ok: true, platform: "schtasks", alreadyInstalled: false };
21714
+ uninstallWindowsStartup();
21715
+ return { ok: true, platform: "startup-folder", alreadyInstalled: false };
21719
21716
  }
21720
21717
  return {
21721
21718
  ok: false,
@@ -21731,7 +21728,7 @@ function uninstallDaemonService() {
21731
21728
  function isDaemonServiceInstalled() {
21732
21729
  if (process.platform === "darwin") return isLaunchdInstalled();
21733
21730
  if (process.platform === "linux") return isSystemdInstalled();
21734
- if (process.platform === "win32") return isSchtasksInstalled();
21731
+ if (process.platform === "win32") return isWindowsStartupInstalled();
21735
21732
  return false;
21736
21733
  }
21737
21734
  function autostartRepairDecision(opts) {
@@ -21752,11 +21749,7 @@ function enableDaemonServiceQuiet() {
21752
21749
  return r.status === 0;
21753
21750
  }
21754
21751
  if (process.platform === "win32") {
21755
- const r = (0, import_child_process3.spawnSync)("schtasks", ["/Change", "/TN", SCHTASKS_TASK, "/ENABLE"], {
21756
- encoding: "utf8",
21757
- timeout: 5e3
21758
- });
21759
- return r.status === 0;
21752
+ return isWindowsStartupInstalled();
21760
21753
  }
21761
21754
  return process.platform === "darwin";
21762
21755
  } catch {
@@ -21812,13 +21805,13 @@ function isDaemonServiceEnabled() {
21812
21805
  return r.status === 0;
21813
21806
  }
21814
21807
  if (process.platform === "win32") {
21815
- return isSchtasksEnabled();
21808
+ return isWindowsStartupInstalled();
21816
21809
  }
21817
21810
  } catch {
21818
21811
  }
21819
21812
  return false;
21820
21813
  }
21821
- var import_fs43, import_path42, import_os39, import_child_process3, LAUNCHD_LABEL, LAUNCHD_PLIST, SYSTEMD_UNIT_DIR, SYSTEMD_UNIT, SCHTASKS_TASK, WIN_LAUNCHER;
21814
+ var import_fs43, import_path42, import_os39, import_child_process3, LAUNCHD_LABEL, LAUNCHD_PLIST, SYSTEMD_UNIT_DIR, SYSTEMD_UNIT, STARTUP_FILE, WIN_LAUNCHER;
21822
21815
  var init_service = __esm({
21823
21816
  "src/daemon/service.ts"() {
21824
21817
  "use strict";
@@ -21830,8 +21823,8 @@ var init_service = __esm({
21830
21823
  LAUNCHD_PLIST = import_path42.default.join(import_os39.default.homedir(), "Library", "LaunchAgents", `${LAUNCHD_LABEL}.plist`);
21831
21824
  SYSTEMD_UNIT_DIR = import_path42.default.join(import_os39.default.homedir(), ".config", "systemd", "user");
21832
21825
  SYSTEMD_UNIT = import_path42.default.join(SYSTEMD_UNIT_DIR, "node9-daemon.service");
21833
- SCHTASKS_TASK = "Node9Daemon";
21834
- WIN_LAUNCHER = () => import_path42.default.join(import_os39.default.homedir(), ".node9", "daemon-launcher.vbs");
21826
+ STARTUP_FILE = "node9-daemon.vbs";
21827
+ WIN_LAUNCHER = () => import_path42.default.join(windowsStartupDir(), STARTUP_FILE);
21835
21828
  }
21836
21829
  });
21837
21830
 
@@ -48424,27 +48417,8 @@ function resolveCloudEndpoint(pathSuffix, override) {
48424
48417
  return PROD_BASE + pathSuffix;
48425
48418
  }
48426
48419
 
48427
- // src/machine-id.ts
48428
- var crypto7 = __toESM(require("crypto"));
48429
- var fs47 = __toESM(require("fs"));
48430
- var os42 = __toESM(require("os"));
48431
- var path45 = __toESM(require("path"));
48432
- var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
48433
- function getMachineId(homeDir2 = os42.homedir()) {
48434
- const file = path45.join(homeDir2, ".node9", "machine-id");
48435
- try {
48436
- const existing = fs47.readFileSync(file, "utf-8").trim();
48437
- if (UUID_RE.test(existing)) return existing;
48438
- } catch {
48439
- }
48440
- const id = crypto7.randomUUID();
48441
- try {
48442
- fs47.mkdirSync(path45.dirname(file), { recursive: true });
48443
- fs47.writeFileSync(file, id + "\n", { mode: 384 });
48444
- } catch {
48445
- }
48446
- return id;
48447
- }
48420
+ // src/auth/device-login.ts
48421
+ init_machine_id();
48448
48422
 
48449
48423
  // src/utils/open-browser.ts
48450
48424
  var import_child_process6 = require("child_process");