@rogatio/cli 6.20.2 → 6.20.3
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 +153 -87
- package/package.json +4 -4
package/dist/node/index.js
CHANGED
|
@@ -2283,21 +2283,23 @@ import { basename, dirname as dirname2, isAbsolute as isAbsolute2, join as join2
|
|
|
2283
2283
|
import { X509Certificate } from "node:crypto";
|
|
2284
2284
|
import { generateKeyPairSync, webcrypto } from "node:crypto";
|
|
2285
2285
|
import { spawn, spawnSync } from "node:child_process";
|
|
2286
|
-
import { accessSync, constants as
|
|
2287
|
-
import { mkdtemp
|
|
2288
|
-
import { tmpdir } from "node:os";
|
|
2289
|
-
import { dirname as dirname3, join as
|
|
2286
|
+
import { accessSync, constants as constants3 } from "node:fs";
|
|
2287
|
+
import { mkdtemp as mkdtemp2, rm as rm3 } from "node:fs/promises";
|
|
2288
|
+
import { tmpdir as tmpdir2 } from "node:os";
|
|
2289
|
+
import { dirname as dirname3, join as join4 } from "node:path";
|
|
2290
2290
|
import { join as posixJoin } from "node:path/posix";
|
|
2291
|
+
import { constants as constants2 } from "node:fs";
|
|
2292
|
+
import { lstat as lstat2, mkdtemp, open as open3, rm as rm2 } from "node:fs/promises";
|
|
2293
|
+
import { tmpdir } from "node:os";
|
|
2294
|
+
import { join as join3 } from "node:path";
|
|
2291
2295
|
import { spawn as spawn2, spawnSync as spawnSync2 } from "node:child_process";
|
|
2292
|
-
import { accessSync as accessSync2, constants as
|
|
2296
|
+
import { accessSync as accessSync2, constants as constants4, mkdirSync, unlinkSync } from "node:fs";
|
|
2293
2297
|
import { dirname as dirname4 } from "node:path";
|
|
2294
2298
|
import { join as posixJoin2 } from "node:path/posix";
|
|
2295
2299
|
import { spawn as spawn3, spawnSync as spawnSync3 } from "node:child_process";
|
|
2296
|
-
import { accessSync as accessSync3, constants as
|
|
2297
|
-
import { tmpdir as tmpdir2 } from "node:os";
|
|
2298
|
-
import { join as join4 } from "node:path";
|
|
2300
|
+
import { accessSync as accessSync3, constants as constants5 } from "node:fs";
|
|
2299
2301
|
import { join as posixJoin3 } from "node:path/posix";
|
|
2300
|
-
import { constants as
|
|
2302
|
+
import { constants as constants6 } from "node:fs";
|
|
2301
2303
|
import { open as open4, realpath as realpath2 } from "node:fs/promises";
|
|
2302
2304
|
import { isAbsolute as isAbsolute3 } from "node:path";
|
|
2303
2305
|
import { Buffer as Buffer2 } from "node:buffer";
|
|
@@ -23153,6 +23155,84 @@ function createRequestBodyTrustController(options = {}) {
|
|
|
23153
23155
|
}
|
|
23154
23156
|
return { install, uninstall, status, verify: verify2 };
|
|
23155
23157
|
}
|
|
23158
|
+
var INSTALL_CERT_NAME = "ca.crt";
|
|
23159
|
+
function optionalFlag(flag) {
|
|
23160
|
+
return typeof flag === "number" ? flag : 0;
|
|
23161
|
+
}
|
|
23162
|
+
function exclusiveWriteFlags() {
|
|
23163
|
+
return constants2.O_WRONLY | constants2.O_CREAT | constants2.O_EXCL | constants2.O_TRUNC | optionalFlag(constants2.O_NOFOLLOW);
|
|
23164
|
+
}
|
|
23165
|
+
function readFlags() {
|
|
23166
|
+
return constants2.O_RDONLY | optionalFlag(constants2.O_NOFOLLOW) | optionalFlag(constants2.O_NONBLOCK);
|
|
23167
|
+
}
|
|
23168
|
+
function refuseCertificateFile(message) {
|
|
23169
|
+
throw new TrustError("trust.internal", message, [
|
|
23170
|
+
"certificate-file-rejected"
|
|
23171
|
+
]);
|
|
23172
|
+
}
|
|
23173
|
+
async function writeExclusiveCertificate(certPath, pem) {
|
|
23174
|
+
const handle = await open3(certPath, exclusiveWriteFlags(), 384);
|
|
23175
|
+
try {
|
|
23176
|
+
await handle.writeFile(Buffer.from(pem, "utf8"));
|
|
23177
|
+
await handle.chmod(384);
|
|
23178
|
+
} finally {
|
|
23179
|
+
await handle.close();
|
|
23180
|
+
}
|
|
23181
|
+
}
|
|
23182
|
+
async function assertCertificateReady(certPath, pem) {
|
|
23183
|
+
let info;
|
|
23184
|
+
try {
|
|
23185
|
+
info = await lstat2(certPath);
|
|
23186
|
+
} catch {
|
|
23187
|
+
refuseCertificateFile("certificate file is not a regular file");
|
|
23188
|
+
}
|
|
23189
|
+
if (!info.isFile() || info.isSymbolicLink() || info.isFIFO()) {
|
|
23190
|
+
refuseCertificateFile("certificate file is not a regular file");
|
|
23191
|
+
}
|
|
23192
|
+
let handle;
|
|
23193
|
+
try {
|
|
23194
|
+
handle = await open3(certPath, readFlags());
|
|
23195
|
+
const opened = await handle.stat();
|
|
23196
|
+
if (!opened.isFile() || opened.isFIFO() || opened.isSymbolicLink()) {
|
|
23197
|
+
refuseCertificateFile("certificate file is not a regular file");
|
|
23198
|
+
}
|
|
23199
|
+
const bytes = await handle.readFile();
|
|
23200
|
+
if (!bytes.equals(Buffer.from(pem, "utf8"))) {
|
|
23201
|
+
refuseCertificateFile(
|
|
23202
|
+
"certificate file does not match the certificate to install"
|
|
23203
|
+
);
|
|
23204
|
+
}
|
|
23205
|
+
if (!isInstallableCaCertificate(bytes.toString("utf8"))) {
|
|
23206
|
+
throw new TrustError("trust.internal", "invalid-ca-certificate", [
|
|
23207
|
+
"invalid-ca-certificate"
|
|
23208
|
+
]);
|
|
23209
|
+
}
|
|
23210
|
+
} catch (error) {
|
|
23211
|
+
if (error instanceof TrustError) throw error;
|
|
23212
|
+
refuseCertificateFile("certificate file is not a regular file");
|
|
23213
|
+
} finally {
|
|
23214
|
+
await handle?.close().catch(() => void 0);
|
|
23215
|
+
}
|
|
23216
|
+
}
|
|
23217
|
+
async function withInstallCertificateFile(pem, use) {
|
|
23218
|
+
if (!isInstallableCaCertificate(pem)) {
|
|
23219
|
+
throw new TrustError("trust.internal", "invalid-ca-certificate", [
|
|
23220
|
+
"invalid-ca-certificate"
|
|
23221
|
+
]);
|
|
23222
|
+
}
|
|
23223
|
+
const directory = await mkdtemp(join3(tmpdir(), "rogatio-ca-"));
|
|
23224
|
+
try {
|
|
23225
|
+
const certPath = join3(directory, INSTALL_CERT_NAME);
|
|
23226
|
+
await writeExclusiveCertificate(certPath, pem);
|
|
23227
|
+
await assertCertificateReady(certPath, pem);
|
|
23228
|
+
await use(certPath);
|
|
23229
|
+
} finally {
|
|
23230
|
+
try {
|
|
23231
|
+
await rm2(directory, { recursive: true, force: true });
|
|
23232
|
+
} catch {
|
|
23233
|
+
}
|
|
23234
|
+
}
|
|
23235
|
+
}
|
|
23156
23236
|
var PREVIOUS_CA_PEM_MAX_BYTES = 16 * 1024;
|
|
23157
23237
|
function spawnSecurity(args) {
|
|
23158
23238
|
return new Promise((resolve12) => {
|
|
@@ -23191,12 +23271,12 @@ var darwinAdapter = {
|
|
|
23191
23271
|
reasons.push("tooling-missing");
|
|
23192
23272
|
}
|
|
23193
23273
|
try {
|
|
23194
|
-
accessSync(manifestDir,
|
|
23274
|
+
accessSync(manifestDir, constants3.W_OK);
|
|
23195
23275
|
} catch {
|
|
23196
23276
|
reasons.push("manifest-dir-unwritable");
|
|
23197
23277
|
}
|
|
23198
23278
|
try {
|
|
23199
|
-
accessSync(caDir,
|
|
23279
|
+
accessSync(caDir, constants3.W_OK);
|
|
23200
23280
|
} catch {
|
|
23201
23281
|
reasons.push("keychain-unwritable");
|
|
23202
23282
|
}
|
|
@@ -23210,44 +23290,31 @@ var darwinAdapter = {
|
|
|
23210
23290
|
},
|
|
23211
23291
|
async caTrustInstaller(certPem) {
|
|
23212
23292
|
const keychain = this.defaultCaInstallPath();
|
|
23213
|
-
const tmpPath = join3(tmpdir(), `rogatio-ca-${Date.now()}.crt`);
|
|
23214
23293
|
try {
|
|
23215
|
-
|
|
23216
|
-
|
|
23217
|
-
throw new TrustError("trust.internal", "keychain-unwritable", [
|
|
23218
|
-
"keychain-unwritable"
|
|
23219
|
-
]);
|
|
23220
|
-
}
|
|
23221
|
-
const result = await new Promise(
|
|
23222
|
-
(resolve12) => {
|
|
23223
|
-
const child = spawn("security", [
|
|
23294
|
+
await withInstallCertificateFile(certPem, async (certPath) => {
|
|
23295
|
+
const result = await spawnSecurity([
|
|
23224
23296
|
"add-trusted-cert",
|
|
23225
23297
|
"-d",
|
|
23226
23298
|
"-r",
|
|
23227
23299
|
"trustRoot",
|
|
23228
23300
|
"-k",
|
|
23229
23301
|
keychain,
|
|
23230
|
-
|
|
23302
|
+
certPath
|
|
23231
23303
|
]);
|
|
23232
|
-
|
|
23233
|
-
|
|
23234
|
-
|
|
23235
|
-
|
|
23236
|
-
|
|
23237
|
-
|
|
23238
|
-
|
|
23239
|
-
|
|
23240
|
-
|
|
23241
|
-
|
|
23242
|
-
|
|
23243
|
-
|
|
23244
|
-
|
|
23245
|
-
|
|
23246
|
-
let reason = "keychain-unwritable";
|
|
23247
|
-
if (stderr.includes("permission") || stderr.includes("auth")) {
|
|
23248
|
-
reason = "keychain-unwritable";
|
|
23249
|
-
}
|
|
23250
|
-
throw new TrustError("trust.internal", reason, [reason]);
|
|
23304
|
+
if (result.code !== 0) {
|
|
23305
|
+
const stderr = result.stderr.toLowerCase();
|
|
23306
|
+
let reason = "keychain-unwritable";
|
|
23307
|
+
if (stderr.includes("permission") || stderr.includes("auth")) {
|
|
23308
|
+
reason = "keychain-unwritable";
|
|
23309
|
+
}
|
|
23310
|
+
throw new TrustError("trust.internal", reason, [reason]);
|
|
23311
|
+
}
|
|
23312
|
+
});
|
|
23313
|
+
} catch (error) {
|
|
23314
|
+
if (error instanceof TrustError) throw error;
|
|
23315
|
+
throw new TrustError("trust.internal", "keychain-unwritable", [
|
|
23316
|
+
"keychain-unwritable"
|
|
23317
|
+
]);
|
|
23251
23318
|
}
|
|
23252
23319
|
},
|
|
23253
23320
|
async caTrustRemover() {
|
|
@@ -23289,17 +23356,11 @@ var darwinAdapter = {
|
|
|
23289
23356
|
]);
|
|
23290
23357
|
}
|
|
23291
23358
|
const keychain = this.defaultCaInstallPath();
|
|
23292
|
-
const dir = await
|
|
23293
|
-
const tmpPath =
|
|
23359
|
+
const dir = await mkdtemp2(join4(tmpdir2(), "rogatio-ca-"));
|
|
23360
|
+
const tmpPath = join4(dir, "previous.crt");
|
|
23294
23361
|
let failed = false;
|
|
23295
23362
|
try {
|
|
23296
|
-
|
|
23297
|
-
try {
|
|
23298
|
-
await handle.writeFile(certPem, "utf8");
|
|
23299
|
-
await handle.chmod(384);
|
|
23300
|
-
} finally {
|
|
23301
|
-
await handle.close();
|
|
23302
|
-
}
|
|
23363
|
+
await writeExclusiveCertificate(tmpPath, certPem);
|
|
23303
23364
|
const trust = await spawnSecurity(["remove-trusted-cert", "-d", tmpPath]);
|
|
23304
23365
|
if (trust.code !== 0 && !securityMiss(trust.stderr)) failed = true;
|
|
23305
23366
|
const item = await spawnSecurity([
|
|
@@ -23314,7 +23375,7 @@ var darwinAdapter = {
|
|
|
23314
23375
|
failed = true;
|
|
23315
23376
|
} finally {
|
|
23316
23377
|
try {
|
|
23317
|
-
await
|
|
23378
|
+
await rm3(dir, { recursive: true, force: true });
|
|
23318
23379
|
} catch {
|
|
23319
23380
|
}
|
|
23320
23381
|
}
|
|
@@ -23352,7 +23413,7 @@ function exists(path2) {
|
|
|
23352
23413
|
}
|
|
23353
23414
|
function writable(path2) {
|
|
23354
23415
|
try {
|
|
23355
|
-
accessSync2(path2,
|
|
23416
|
+
accessSync2(path2, constants4.W_OK);
|
|
23356
23417
|
return true;
|
|
23357
23418
|
} catch {
|
|
23358
23419
|
return false;
|
|
@@ -23389,7 +23450,7 @@ function p11kitAnchorsDir() {
|
|
|
23389
23450
|
function needsElevation(dir) {
|
|
23390
23451
|
if (writable(dir)) return false;
|
|
23391
23452
|
try {
|
|
23392
|
-
accessSync2(dir,
|
|
23453
|
+
accessSync2(dir, constants4.W_OK);
|
|
23393
23454
|
} catch (err) {
|
|
23394
23455
|
if (nodeCode(err) === "ENOENT" && writable(dirname4(dir))) return false;
|
|
23395
23456
|
}
|
|
@@ -23406,13 +23467,13 @@ function manifestDirFor(browser) {
|
|
|
23406
23467
|
}
|
|
23407
23468
|
function canHostManifest(dir) {
|
|
23408
23469
|
try {
|
|
23409
|
-
accessSync2(dir,
|
|
23470
|
+
accessSync2(dir, constants4.W_OK);
|
|
23410
23471
|
return true;
|
|
23411
23472
|
} catch (err) {
|
|
23412
23473
|
if (nodeCode(err) !== "ENOENT") return false;
|
|
23413
23474
|
}
|
|
23414
23475
|
try {
|
|
23415
|
-
accessSync2(dirname4(dir),
|
|
23476
|
+
accessSync2(dirname4(dir), constants4.W_OK);
|
|
23416
23477
|
return true;
|
|
23417
23478
|
} catch {
|
|
23418
23479
|
return false;
|
|
@@ -23542,7 +23603,7 @@ var linuxAdapter = {
|
|
|
23542
23603
|
},
|
|
23543
23604
|
async caTrustRemover() {
|
|
23544
23605
|
try {
|
|
23545
|
-
|
|
23606
|
+
unlinkSync(DEBIAN_CERT);
|
|
23546
23607
|
} catch {
|
|
23547
23608
|
}
|
|
23548
23609
|
if (!toolOnPath("update-ca-trust")) return;
|
|
@@ -23603,7 +23664,7 @@ var win32Adapter = {
|
|
|
23603
23664
|
reasons.push("tooling-missing");
|
|
23604
23665
|
}
|
|
23605
23666
|
try {
|
|
23606
|
-
accessSync3(manifestDir,
|
|
23667
|
+
accessSync3(manifestDir, constants5.W_OK);
|
|
23607
23668
|
} catch {
|
|
23608
23669
|
reasons.push("manifest-dir-unwritable");
|
|
23609
23670
|
}
|
|
@@ -23616,37 +23677,42 @@ var win32Adapter = {
|
|
|
23616
23677
|
};
|
|
23617
23678
|
},
|
|
23618
23679
|
async caTrustInstaller(certPem) {
|
|
23619
|
-
const tmpPath = join4(tmpdir2(), `rogatio-ca-${Date.now()}.crt`);
|
|
23620
23680
|
try {
|
|
23621
|
-
|
|
23622
|
-
|
|
23681
|
+
await withInstallCertificateFile(certPem, async (certPath) => {
|
|
23682
|
+
const result = await new Promise(
|
|
23683
|
+
(resolve12) => {
|
|
23684
|
+
const child = spawn3("certutil", [
|
|
23685
|
+
"-addstore",
|
|
23686
|
+
"-f",
|
|
23687
|
+
"Root",
|
|
23688
|
+
certPath
|
|
23689
|
+
]);
|
|
23690
|
+
let stderr = "";
|
|
23691
|
+
child.stderr?.on("data", (data) => {
|
|
23692
|
+
stderr += data.toString();
|
|
23693
|
+
});
|
|
23694
|
+
child.on("close", (code) => resolve12({ code: code ?? 1, stderr }));
|
|
23695
|
+
child.on(
|
|
23696
|
+
"error",
|
|
23697
|
+
(err) => resolve12({ code: 1, stderr: err.message })
|
|
23698
|
+
);
|
|
23699
|
+
}
|
|
23700
|
+
);
|
|
23701
|
+
if (result.code !== 0) {
|
|
23702
|
+
const stderr = result.stderr.toLowerCase();
|
|
23703
|
+
let reason = "elevation-required";
|
|
23704
|
+
if (stderr.includes("access denied") || stderr.includes("permission")) {
|
|
23705
|
+
reason = "elevation-required";
|
|
23706
|
+
}
|
|
23707
|
+
throw new TrustError("trust.internal", reason, [reason]);
|
|
23708
|
+
}
|
|
23709
|
+
});
|
|
23710
|
+
} catch (error) {
|
|
23711
|
+
if (error instanceof TrustError) throw error;
|
|
23623
23712
|
throw new TrustError("trust.internal", "elevation-required", [
|
|
23624
23713
|
"elevation-required"
|
|
23625
23714
|
]);
|
|
23626
23715
|
}
|
|
23627
|
-
const result = await new Promise(
|
|
23628
|
-
(resolve12) => {
|
|
23629
|
-
const child = spawn3("certutil", ["-addstore", "-f", "Root", tmpPath]);
|
|
23630
|
-
let stderr = "";
|
|
23631
|
-
child.stderr?.on("data", (data) => {
|
|
23632
|
-
stderr += data.toString();
|
|
23633
|
-
});
|
|
23634
|
-
child.on("close", (code) => resolve12({ code: code ?? 1, stderr }));
|
|
23635
|
-
child.on("error", (err) => resolve12({ code: 1, stderr: err.message }));
|
|
23636
|
-
}
|
|
23637
|
-
);
|
|
23638
|
-
try {
|
|
23639
|
-
unlinkSync3(tmpPath);
|
|
23640
|
-
} catch {
|
|
23641
|
-
}
|
|
23642
|
-
if (result.code !== 0) {
|
|
23643
|
-
const stderr = result.stderr.toLowerCase();
|
|
23644
|
-
let reason = "elevation-required";
|
|
23645
|
-
if (stderr.includes("access denied") || stderr.includes("permission")) {
|
|
23646
|
-
reason = "elevation-required";
|
|
23647
|
-
}
|
|
23648
|
-
throw new TrustError("trust.internal", reason, [reason]);
|
|
23649
|
-
}
|
|
23650
23716
|
},
|
|
23651
23717
|
async caTrustRemover() {
|
|
23652
23718
|
const result = await new Promise(
|
|
@@ -24586,7 +24652,7 @@ async function resolveConfinedRoot(value) {
|
|
|
24586
24652
|
}
|
|
24587
24653
|
let directory;
|
|
24588
24654
|
try {
|
|
24589
|
-
directory = await open4(value,
|
|
24655
|
+
directory = await open4(value, constants6.O_RDONLY | constants6.O_DIRECTORY);
|
|
24590
24656
|
const info = await directory.stat();
|
|
24591
24657
|
if (!info.isDirectory()) return failure("runtime.root-invalid");
|
|
24592
24658
|
return { ok: true, value: await realpath2(value) };
|
|
@@ -33439,7 +33505,7 @@ function errorMessage(error) {
|
|
|
33439
33505
|
}
|
|
33440
33506
|
|
|
33441
33507
|
// packages/cli/src/commands/runtime.ts
|
|
33442
|
-
import { chmod, mkdir as mkdir5, rm as
|
|
33508
|
+
import { chmod, mkdir as mkdir5, rm as rm4, writeFile as writeFile4 } from "node:fs/promises";
|
|
33443
33509
|
import { dirname as dirname10, join as join9, resolve as resolve8 } from "node:path";
|
|
33444
33510
|
function generateHostWrapper(rogatioCommand, logPath) {
|
|
33445
33511
|
const parts = rogatioCommand.split(" ");
|
|
@@ -33550,11 +33616,11 @@ Note: reload the extension at chrome://extensions for the native host to be dete
|
|
|
33550
33616
|
case "uninstall": {
|
|
33551
33617
|
const uninstallResult = await controller.uninstall();
|
|
33552
33618
|
try {
|
|
33553
|
-
await
|
|
33619
|
+
await rm4(hostPath, { force: true });
|
|
33554
33620
|
} catch {
|
|
33555
33621
|
}
|
|
33556
33622
|
try {
|
|
33557
|
-
await
|
|
33623
|
+
await rm4(join9(installRoot, "runtime-host.log"), { force: true });
|
|
33558
33624
|
} catch {
|
|
33559
33625
|
}
|
|
33560
33626
|
return reportTrust(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rogatio/cli",
|
|
3
|
-
"version": "6.20.
|
|
3
|
+
"version": "6.20.3",
|
|
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.",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"ajv": "8.20.0",
|
|
44
|
-
"koffi": "3.3.
|
|
44
|
+
"koffi": "3.3.3"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@rogatio/compiler": "workspace:*",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"@rogatio/requestly-import": "workspace:*",
|
|
51
51
|
"@rogatio/runtime": "workspace:*",
|
|
52
52
|
"@rogatio/schema": "workspace:*",
|
|
53
|
-
"@types/node": "26.6.
|
|
53
|
+
"@types/node": "26.6.5",
|
|
54
54
|
"typescript": "7.0.2",
|
|
55
|
-
"vitest": "5.0.
|
|
55
|
+
"vitest": "5.0.4"
|
|
56
56
|
}
|
|
57
57
|
}
|