@rogatio/cli 5.2.0 → 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.
- package/dist/node/index.js +64 -47
- package/package.json +1 -1
package/dist/node/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// packages/cli/src/index.ts
|
|
4
4
|
import { realpathSync } from "node:fs";
|
|
5
|
-
import { basename as basename4, dirname as
|
|
5
|
+
import { basename as basename4, dirname as dirname8, resolve as resolve8 } from "node:path";
|
|
6
6
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
7
7
|
|
|
8
8
|
// packages/runtime/dist/node/index.js
|
|
@@ -1176,6 +1176,7 @@ import { dirname as dirname3, join as join3 } from "node:path";
|
|
|
1176
1176
|
import { join as posixJoin } from "node:path/posix";
|
|
1177
1177
|
import { spawn as spawn2, spawnSync as spawnSync2 } from "node:child_process";
|
|
1178
1178
|
import { accessSync as accessSync2, constants as constants3, mkdirSync, unlinkSync as unlinkSync2 } from "node:fs";
|
|
1179
|
+
import { dirname as dirname4 } from "node:path";
|
|
1179
1180
|
import { join as posixJoin2 } from "node:path/posix";
|
|
1180
1181
|
import { spawn as spawn3, spawnSync as spawnSync3 } from "node:child_process";
|
|
1181
1182
|
import { accessSync as accessSync3, constants as constants4, unlinkSync as unlinkSync3, writeFileSync as writeFileSync2 } from "node:fs";
|
|
@@ -22021,20 +22022,22 @@ var darwinAdapter = {
|
|
|
22021
22022
|
}
|
|
22022
22023
|
};
|
|
22023
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
|
+
}
|
|
22024
22031
|
var linuxAdapter = {
|
|
22025
22032
|
platform: "linux",
|
|
22026
22033
|
defaultManifestDir: () => {
|
|
22027
22034
|
const home = process.env.HOME ?? "";
|
|
22028
22035
|
return posixJoin2(home, ".config/google-chrome/NativeMessagingHosts");
|
|
22029
22036
|
},
|
|
22030
|
-
defaultCaInstallPath: () =>
|
|
22031
|
-
const home = process.env.HOME ?? "";
|
|
22032
|
-
return posixJoin2(home, ".local/share/ca-certificates");
|
|
22033
|
-
},
|
|
22037
|
+
defaultCaInstallPath: () => CA_DIR,
|
|
22034
22038
|
detect() {
|
|
22035
22039
|
const reasons = [];
|
|
22036
22040
|
const manifestDir = this.defaultManifestDir();
|
|
22037
|
-
const caDir = this.defaultCaInstallPath();
|
|
22038
22041
|
const updateCa = spawnSync2("which", ["update-ca-certificates"], {
|
|
22039
22042
|
timeout: 1e3
|
|
22040
22043
|
});
|
|
@@ -22047,12 +22050,22 @@ var linuxAdapter = {
|
|
|
22047
22050
|
reasons.push("manifest-dir-unwritable");
|
|
22048
22051
|
}
|
|
22049
22052
|
try {
|
|
22050
|
-
accessSync2(
|
|
22051
|
-
} catch {
|
|
22052
|
-
|
|
22053
|
+
accessSync2(CA_DIR, constants3.W_OK);
|
|
22054
|
+
} catch (err) {
|
|
22055
|
+
if (err?.code === "ENOENT") {
|
|
22056
|
+
try {
|
|
22057
|
+
accessSync2(dirname4(CA_DIR), constants3.W_OK);
|
|
22058
|
+
} catch {
|
|
22059
|
+
if (!hasSudo()) {
|
|
22060
|
+
reasons.push("elevation-required");
|
|
22061
|
+
}
|
|
22062
|
+
}
|
|
22063
|
+
} else if (!hasSudo()) {
|
|
22064
|
+
reasons.push("elevation-required");
|
|
22065
|
+
}
|
|
22053
22066
|
}
|
|
22054
22067
|
const manifest = !reasons.includes("tooling-missing") && !reasons.includes("manifest-dir-unwritable");
|
|
22055
|
-
const caTrust = !reasons.includes("tooling-missing") && !reasons.includes("
|
|
22068
|
+
const caTrust = !reasons.includes("tooling-missing") && !reasons.includes("elevation-required");
|
|
22056
22069
|
return {
|
|
22057
22070
|
manifest,
|
|
22058
22071
|
caTrust,
|
|
@@ -22060,37 +22073,41 @@ var linuxAdapter = {
|
|
|
22060
22073
|
};
|
|
22061
22074
|
},
|
|
22062
22075
|
async caTrustInstaller(certPem) {
|
|
22063
|
-
const caDir = this.defaultCaInstallPath();
|
|
22064
|
-
const certPath = posixJoin2(caDir, "rogatio-ca.crt");
|
|
22065
22076
|
try {
|
|
22066
|
-
mkdirSync(
|
|
22077
|
+
mkdirSync(CA_DIR, { recursive: true });
|
|
22067
22078
|
} catch {
|
|
22068
22079
|
throw new TrustError("trust.internal", "ca-store-unwritable", [
|
|
22069
22080
|
"ca-store-unwritable"
|
|
22070
22081
|
]);
|
|
22071
22082
|
}
|
|
22072
|
-
|
|
22073
|
-
|
|
22074
|
-
const child = spawn2("
|
|
22083
|
+
const certResult = await new Promise(
|
|
22084
|
+
(resolve22) => {
|
|
22085
|
+
const child = spawn2("sudo", [
|
|
22086
|
+
"sh",
|
|
22075
22087
|
"-c",
|
|
22076
|
-
`cat > "${
|
|
22088
|
+
`cat > "${CERT_PATH}" << 'EOF'
|
|
22077
22089
|
${certPem}
|
|
22078
22090
|
EOF`
|
|
22079
22091
|
]);
|
|
22080
|
-
|
|
22081
|
-
|
|
22082
|
-
|
|
22083
|
-
);
|
|
22084
|
-
child.on("
|
|
22085
|
-
|
|
22086
|
-
|
|
22087
|
-
|
|
22088
|
-
|
|
22089
|
-
|
|
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]);
|
|
22090
22107
|
}
|
|
22091
22108
|
const result = await new Promise(
|
|
22092
22109
|
(resolve22) => {
|
|
22093
|
-
const child = spawn2("update-ca-certificates");
|
|
22110
|
+
const child = spawn2("sudo", ["update-ca-certificates"]);
|
|
22094
22111
|
let stderr = "";
|
|
22095
22112
|
child.stderr?.on("data", (data) => {
|
|
22096
22113
|
stderr += data.toString();
|
|
@@ -22102,17 +22119,15 @@ EOF`
|
|
|
22102
22119
|
if (result.code !== 0) {
|
|
22103
22120
|
const stderr = result.stderr.toLowerCase();
|
|
22104
22121
|
let reason = "ca-store-unwritable";
|
|
22105
|
-
if (stderr.includes("permission") || stderr.includes("not permitted")) {
|
|
22106
|
-
reason = "
|
|
22122
|
+
if (stderr.includes("permission") || stderr.includes("not permitted") || stderr.includes("no tty") || stderr.includes("terminal")) {
|
|
22123
|
+
reason = "elevation-required";
|
|
22107
22124
|
}
|
|
22108
22125
|
throw new TrustError("trust.internal", reason, [reason]);
|
|
22109
22126
|
}
|
|
22110
22127
|
},
|
|
22111
22128
|
async caTrustRemover() {
|
|
22112
|
-
const caDir = this.defaultCaInstallPath();
|
|
22113
|
-
const certPath = posixJoin2(caDir, "rogatio-ca.crt");
|
|
22114
22129
|
try {
|
|
22115
|
-
unlinkSync2(
|
|
22130
|
+
unlinkSync2(CERT_PATH);
|
|
22116
22131
|
} catch {
|
|
22117
22132
|
}
|
|
22118
22133
|
}
|
|
@@ -23739,12 +23754,12 @@ function createRoutes(context) {
|
|
|
23739
23754
|
}
|
|
23740
23755
|
|
|
23741
23756
|
// packages/cli/src/utils/asset-paths.ts
|
|
23742
|
-
import { dirname as
|
|
23757
|
+
import { dirname as dirname5, resolve as resolve3 } from "node:path";
|
|
23743
23758
|
import { fileURLToPath } from "node:url";
|
|
23744
|
-
function isDistBuild(here =
|
|
23759
|
+
function isDistBuild(here = dirname5(fileURLToPath(import.meta.url))) {
|
|
23745
23760
|
return here.includes("/dist/") || here.includes("\\dist\\");
|
|
23746
23761
|
}
|
|
23747
|
-
function editorAssetPaths(here =
|
|
23762
|
+
function editorAssetPaths(here = dirname5(fileURLToPath(import.meta.url))) {
|
|
23748
23763
|
const editorRoot = isDistBuild(here) ? resolve3(here, "..", "editor") : resolve3(here, "..", "..", "..", "editor", "dist", "browser");
|
|
23749
23764
|
return {
|
|
23750
23765
|
bundle: resolve3(editorRoot, "index.js"),
|
|
@@ -23811,7 +23826,7 @@ async function launchBrowser(url) {
|
|
|
23811
23826
|
// packages/cli/src/utils/file.ts
|
|
23812
23827
|
import { randomBytes as randomBytes4 } from "node:crypto";
|
|
23813
23828
|
import { mkdir as mkdir3, readFile as readFile5, rename as rename2, writeFile as writeFile3 } from "node:fs/promises";
|
|
23814
|
-
import { basename as basename3, dirname as
|
|
23829
|
+
import { basename as basename3, dirname as dirname6, join as join5 } from "node:path";
|
|
23815
23830
|
var ProjectFileError = class extends Error {
|
|
23816
23831
|
code;
|
|
23817
23832
|
path;
|
|
@@ -23861,10 +23876,10 @@ async function readProject(path2) {
|
|
|
23861
23876
|
}
|
|
23862
23877
|
}
|
|
23863
23878
|
async function writeProject(path2, data) {
|
|
23864
|
-
const tempName = `.${basename3(
|
|
23865
|
-
const tempPath = join5(
|
|
23879
|
+
const tempName = `.${basename3(dirname6(path2))}.${randomBytes4(8).toString("hex")}.tmp`;
|
|
23880
|
+
const tempPath = join5(dirname6(path2), tempName);
|
|
23866
23881
|
try {
|
|
23867
|
-
await mkdir3(
|
|
23882
|
+
await mkdir3(dirname6(path2), { recursive: true });
|
|
23868
23883
|
await writeFile3(tempPath, JSON.stringify(data, null, 2), "utf-8");
|
|
23869
23884
|
await rename2(tempPath, path2);
|
|
23870
23885
|
} catch (e) {
|
|
@@ -24227,7 +24242,7 @@ function generateEditorHtml(apiBase, csrfToken, filePath, aiConfigured) {
|
|
|
24227
24242
|
}
|
|
24228
24243
|
|
|
24229
24244
|
// packages/cli/src/commands/runtime.ts
|
|
24230
|
-
import { dirname as
|
|
24245
|
+
import { dirname as dirname7, isAbsolute, join as join6, relative, resolve as resolve5, sep as sep2 } from "node:path";
|
|
24231
24246
|
function showRuntimeHelp() {
|
|
24232
24247
|
console.log(`Usage: rogatio runtime <command> [options]
|
|
24233
24248
|
rogatio runtime host [path]
|
|
@@ -24238,7 +24253,9 @@ consolidated native-messaging host (spec REQ-001..REQ-005).
|
|
|
24238
24253
|
|
|
24239
24254
|
Request-body trust commands:
|
|
24240
24255
|
install Install the native-messaging host manifest and (on capable
|
|
24241
|
-
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).
|
|
24242
24259
|
uninstall Remove the native-messaging host manifest and the device-local CA trust (idempotent)
|
|
24243
24260
|
|
|
24244
24261
|
Native host command:
|
|
@@ -24329,9 +24346,9 @@ function reportTrust(subcommand, result, okMessage) {
|
|
|
24329
24346
|
const hints = {
|
|
24330
24347
|
"tooling-missing": "Hint: install required tooling (macOS: security; Linux: update-ca-certificates; Windows: certutil is built-in)",
|
|
24331
24348
|
"manifest-dir-unwritable": "Hint: check permissions on Chrome NativeMessagingHosts directory or run with appropriate access",
|
|
24332
|
-
"keychain-unwritable": "Hint: macOS login keychain not writable; try running with appropriate keychain access or use sudo for system keychain
|
|
24333
|
-
"ca-store-unwritable": "Hint:
|
|
24334
|
-
"elevation-required": "Hint:
|
|
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"
|
|
24335
24352
|
};
|
|
24336
24353
|
for (const reason of reasons) {
|
|
24337
24354
|
const hint = hints[reason];
|
|
@@ -24452,7 +24469,7 @@ async function runtimeHostCommand(args) {
|
|
|
24452
24469
|
}
|
|
24453
24470
|
return 1;
|
|
24454
24471
|
}
|
|
24455
|
-
const rootDir = root ?? (inputPath === "-" ? process.cwd() :
|
|
24472
|
+
const rootDir = root ?? (inputPath === "-" ? process.cwd() : dirname7(filePath));
|
|
24456
24473
|
const mocksResult = buildMockConfigs(compileResult.operations, rootDir);
|
|
24457
24474
|
if (!mocksResult.ok) {
|
|
24458
24475
|
console.error(`Error: ${mocksResult.message}`);
|
|
@@ -24918,7 +24935,7 @@ async function verifyCommand(args, stdinInput, captureOutput = false) {
|
|
|
24918
24935
|
}
|
|
24919
24936
|
|
|
24920
24937
|
// packages/cli/src/index.ts
|
|
24921
|
-
var __dirname =
|
|
24938
|
+
var __dirname = dirname8(fileURLToPath2(import.meta.url));
|
|
24922
24939
|
var packageJsonPath = resolve8(
|
|
24923
24940
|
__dirname,
|
|
24924
24941
|
isDistBuild(__dirname) ? "../../package.json" : "../package.json"
|
package/package.json
CHANGED