@rogatio/cli 5.2.1 → 5.2.2

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 (2) hide show
  1. package/dist/node/index.js +46 -38
  2. package/package.json +1 -1
@@ -22022,20 +22022,22 @@ var darwinAdapter = {
22022
22022
  }
22023
22023
  };
22024
22024
  var darwin_default = darwinAdapter;
22025
+ var CA_DIR = "/usr/local/share/ca-certificates";
22026
+ var CERT_PATH = posixJoin2(CA_DIR, "rogatio-ca.crt");
22027
+ function hasSudo() {
22028
+ const result = spawnSync2("sudo", ["-n", "true"], { timeout: 1e3 });
22029
+ return result.status === 0;
22030
+ }
22025
22031
  var linuxAdapter = {
22026
22032
  platform: "linux",
22027
22033
  defaultManifestDir: () => {
22028
22034
  const home = process.env.HOME ?? "";
22029
22035
  return posixJoin2(home, ".config/google-chrome/NativeMessagingHosts");
22030
22036
  },
22031
- defaultCaInstallPath: () => {
22032
- const home = process.env.HOME ?? "";
22033
- return posixJoin2(home, ".local/share/ca-certificates");
22034
- },
22037
+ defaultCaInstallPath: () => CA_DIR,
22035
22038
  detect() {
22036
22039
  const reasons = [];
22037
22040
  const manifestDir = this.defaultManifestDir();
22038
- const caDir = this.defaultCaInstallPath();
22039
22041
  const updateCa = spawnSync2("which", ["update-ca-certificates"], {
22040
22042
  timeout: 1e3
22041
22043
  });
@@ -22048,20 +22050,22 @@ var linuxAdapter = {
22048
22050
  reasons.push("manifest-dir-unwritable");
22049
22051
  }
22050
22052
  try {
22051
- accessSync2(caDir, constants3.W_OK);
22053
+ accessSync2(CA_DIR, constants3.W_OK);
22052
22054
  } catch (err) {
22053
22055
  if (err?.code === "ENOENT") {
22054
22056
  try {
22055
- accessSync2(dirname4(caDir), constants3.W_OK);
22057
+ accessSync2(dirname4(CA_DIR), constants3.W_OK);
22056
22058
  } catch {
22057
- reasons.push("ca-store-unwritable");
22059
+ if (!hasSudo()) {
22060
+ reasons.push("elevation-required");
22061
+ }
22058
22062
  }
22059
- } else {
22060
- reasons.push("ca-store-unwritable");
22063
+ } else if (!hasSudo()) {
22064
+ reasons.push("elevation-required");
22061
22065
  }
22062
22066
  }
22063
22067
  const manifest = !reasons.includes("tooling-missing") && !reasons.includes("manifest-dir-unwritable");
22064
- const caTrust = !reasons.includes("tooling-missing") && !reasons.includes("ca-store-unwritable");
22068
+ const caTrust = !reasons.includes("tooling-missing") && !reasons.includes("elevation-required");
22065
22069
  return {
22066
22070
  manifest,
22067
22071
  caTrust,
@@ -22069,37 +22073,41 @@ var linuxAdapter = {
22069
22073
  };
22070
22074
  },
22071
22075
  async caTrustInstaller(certPem) {
22072
- const caDir = this.defaultCaInstallPath();
22073
- const certPath = posixJoin2(caDir, "rogatio-ca.crt");
22074
22076
  try {
22075
- mkdirSync(caDir, { recursive: true });
22077
+ mkdirSync(CA_DIR, { recursive: true });
22076
22078
  } catch {
22077
22079
  throw new TrustError("trust.internal", "ca-store-unwritable", [
22078
22080
  "ca-store-unwritable"
22079
22081
  ]);
22080
22082
  }
22081
- try {
22082
- await new Promise((resolve22, reject) => {
22083
- const child = spawn2("sh", [
22083
+ const certResult = await new Promise(
22084
+ (resolve22) => {
22085
+ const child = spawn2("sudo", [
22086
+ "sh",
22084
22087
  "-c",
22085
- `cat > "${certPath}" << 'EOF'
22088
+ `cat > "${CERT_PATH}" << 'EOF'
22086
22089
  ${certPem}
22087
22090
  EOF`
22088
22091
  ]);
22089
- child.on(
22090
- "close",
22091
- (code) => code === 0 ? resolve22() : reject(new Error(`exit code ${code}`))
22092
- );
22093
- child.on("error", reject);
22094
- });
22095
- } catch {
22096
- throw new TrustError("trust.internal", "ca-store-unwritable", [
22097
- "ca-store-unwritable"
22098
- ]);
22092
+ let stderr = "";
22093
+ child.stderr?.on("data", (data) => {
22094
+ stderr += data.toString();
22095
+ });
22096
+ child.on("close", (code) => resolve22({ code: code ?? 1, stderr }));
22097
+ child.on("error", (err) => resolve22({ code: 1, stderr: err.message }));
22098
+ }
22099
+ );
22100
+ if (certResult.code !== 0) {
22101
+ const stderr = certResult.stderr.toLowerCase();
22102
+ let reason = "ca-store-unwritable";
22103
+ if (stderr.includes("permission") || stderr.includes("not permitted") || stderr.includes("no tty") || stderr.includes("terminal")) {
22104
+ reason = "elevation-required";
22105
+ }
22106
+ throw new TrustError("trust.internal", reason, [reason]);
22099
22107
  }
22100
22108
  const result = await new Promise(
22101
22109
  (resolve22) => {
22102
- const child = spawn2("update-ca-certificates");
22110
+ const child = spawn2("sudo", ["update-ca-certificates"]);
22103
22111
  let stderr = "";
22104
22112
  child.stderr?.on("data", (data) => {
22105
22113
  stderr += data.toString();
@@ -22111,17 +22119,15 @@ EOF`
22111
22119
  if (result.code !== 0) {
22112
22120
  const stderr = result.stderr.toLowerCase();
22113
22121
  let reason = "ca-store-unwritable";
22114
- if (stderr.includes("permission") || stderr.includes("not permitted")) {
22115
- reason = "ca-store-unwritable";
22122
+ if (stderr.includes("permission") || stderr.includes("not permitted") || stderr.includes("no tty") || stderr.includes("terminal")) {
22123
+ reason = "elevation-required";
22116
22124
  }
22117
22125
  throw new TrustError("trust.internal", reason, [reason]);
22118
22126
  }
22119
22127
  },
22120
22128
  async caTrustRemover() {
22121
- const caDir = this.defaultCaInstallPath();
22122
- const certPath = posixJoin2(caDir, "rogatio-ca.crt");
22123
22129
  try {
22124
- unlinkSync2(certPath);
22130
+ unlinkSync2(CERT_PATH);
22125
22131
  } catch {
22126
22132
  }
22127
22133
  }
@@ -24247,7 +24253,9 @@ consolidated native-messaging host (spec REQ-001..REQ-005).
24247
24253
 
24248
24254
  Request-body trust commands:
24249
24255
  install Install the native-messaging host manifest and (on capable
24250
- platforms) provision the device-local CA (requires --extension-id)
24256
+ platforms) provision the device-local CA (requires --extension-id).
24257
+ CA trust requires root/admin: Linux (sudo), macOS (keychain
24258
+ password), Windows (Administrator).
24251
24259
  uninstall Remove the native-messaging host manifest and the device-local CA trust (idempotent)
24252
24260
 
24253
24261
  Native host command:
@@ -24338,9 +24346,9 @@ function reportTrust(subcommand, result, okMessage) {
24338
24346
  const hints = {
24339
24347
  "tooling-missing": "Hint: install required tooling (macOS: security; Linux: update-ca-certificates; Windows: certutil is built-in)",
24340
24348
  "manifest-dir-unwritable": "Hint: check permissions on Chrome NativeMessagingHosts directory or run with appropriate access",
24341
- "keychain-unwritable": "Hint: macOS login keychain not writable; try running with appropriate keychain access or use sudo for system keychain (future slice)",
24342
- "ca-store-unwritable": "Hint: ~/.local/share/ca-certificates not writable; check permissions",
24343
- "elevation-required": "Hint: Windows system certificate store requires Administrator; re-run in elevated terminal (future slice)"
24349
+ "keychain-unwritable": "Hint: macOS login keychain not writable; try running with appropriate keychain access or use sudo for system keychain",
24350
+ "ca-store-unwritable": "Hint: /usr/local/share/ca-certificates not writable; check directory permissions",
24351
+ "elevation-required": "Hint: device-local CA trust requires root (Linux: sudo, macOS: keychain password, Windows: Administrator). Re-run with elevated privileges"
24344
24352
  };
24345
24353
  for (const reason of reasons) {
24346
24354
  const hint = hints[reason];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rogatio/cli",
3
- "version": "5.2.1",
3
+ "version": "5.2.2",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Local-first browser request and response rules — editor host, file verification, test runner, and runtime dispatch.",