@rogatio/cli 3.0.0 → 5.0.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.
package/README.md CHANGED
@@ -39,7 +39,7 @@ rogatio <command> [options]
39
39
  | `rogatio edit [path]` | Launch the browser editor for `.rogatio.json`. |
40
40
  | `rogatio verify [path]` | Validate a `.rogatio.json` file (schema + compiler). |
41
41
  | `rogatio test [path] [url...]` | Run offline dry-run tests against `.rogatio.json`. |
42
- | `rogatio runtime <install\|trust\|untrust\|uninstall>` | Manage the native-messaging host manifest and request-body trust lifecycle. |
42
+ | `rogatio runtime <install\|uninstall>` | Register the native-messaging host (and, on capable platforms, the device-local CA) in one transactional install; `uninstall` removes the host manifest, the device-local CA files, and the CA trust installation (idempotent). |
43
43
  | `rogatio runtime host <path>` | Run the consolidated native-messaging host for the project (mock/pair/authorize over stdio). Normally launched by the browser; run manually only for debugging. |
44
44
 
45
45
  Global options: `--help, -h` and `--version, -v`. Run `rogatio <command> --help`
@@ -4309,41 +4309,84 @@ function createRequestBodyTrustController(options = {}) {
4309
4309
  reasons: [codeOf(error, "trust.write-failed")]
4310
4310
  };
4311
4311
  }
4312
+ const caTrustCaps = await detect();
4313
+ if (!caTrustCaps.caTrust) {
4314
+ try {
4315
+ await rm(manifestPath(), { force: true });
4316
+ } catch {
4317
+ }
4318
+ return unsupportedResult(caTrustCaps);
4319
+ }
4320
+ const trustResult = await trust();
4321
+ if (!trustResult.ok) {
4322
+ try {
4323
+ await rm(caKeyFile, { force: true });
4324
+ await rm(caPubFile, { force: true });
4325
+ await rm(caCertFile, { force: true });
4326
+ } catch {
4327
+ }
4328
+ try {
4329
+ await rm(manifestPath(), { force: true });
4330
+ } catch {
4331
+ }
4332
+ installerCalled = false;
4333
+ return trustResult;
4334
+ }
4312
4335
  return { ok: true, state: "installed" };
4313
4336
  }
4337
+ async function runCaTrust() {
4338
+ const caps = await detect();
4339
+ if (!caps.caTrust) {
4340
+ throw new TrustError(
4341
+ "trust.unsupported",
4342
+ "caTrust capability absent",
4343
+ caps.reasons
4344
+ );
4345
+ }
4346
+ if (!await existsFile(caKeyFile) || !await existsFile(caCertFile)) {
4347
+ const { privateKey } = generateCaKeyPair(TRUST_LIMITS.caKeyBits);
4348
+ const certResult = createCertificate(
4349
+ "CN=Rogatio Request-Body CA",
4350
+ privateKey,
4351
+ TRUST_LIMITS.caValidityDays
4352
+ );
4353
+ const certPem = certResult.certPem;
4354
+ const certKeyPem = certResult.keyPem;
4355
+ await writeFileAtomic(caKeyFile, certKeyPem);
4356
+ await writeFileAtomic(caPubFile, certPem);
4357
+ await writeFileAtomic(caCertFile, certPem);
4358
+ }
4359
+ if (caTrustInstaller && !installerCalled) {
4360
+ await caTrustInstaller(await readFile22(caCertFile, "utf8"));
4361
+ installerCalled = true;
4362
+ }
4363
+ }
4364
+ async function removeCa() {
4365
+ const caWasPresent = await existsFile(caKeyFile);
4366
+ await rm(caKeyFile, { force: true });
4367
+ await rm(caPubFile, { force: true });
4368
+ await rm(caCertFile, { force: true });
4369
+ if (caWasPresent && caTrustRemover) {
4370
+ await caTrustRemover();
4371
+ }
4372
+ }
4314
4373
  async function uninstall() {
4315
4374
  try {
4316
4375
  await rm(manifestPath(), { force: true });
4376
+ await removeCa();
4377
+ installerCalled = false;
4317
4378
  } catch (error) {
4318
4379
  return {
4319
4380
  ok: false,
4320
4381
  state: "unsupported",
4321
- reasons: [codeOf(error, "trust.write-failed")]
4382
+ reasons: [error instanceof Error ? error.message : String(error)]
4322
4383
  };
4323
4384
  }
4324
4385
  return { ok: true, state: "uninstalled" };
4325
4386
  }
4326
4387
  async function trust() {
4327
- const caps = await detect();
4328
- if (!caps.caTrust) return unsupportedResult(caps);
4329
4388
  try {
4330
- if (!await existsFile(caKeyFile) || !await existsFile(caCertFile)) {
4331
- const { privateKey } = generateCaKeyPair(TRUST_LIMITS.caKeyBits);
4332
- const certResult = createCertificate(
4333
- "CN=Rogatio Request-Body CA",
4334
- privateKey,
4335
- TRUST_LIMITS.caValidityDays
4336
- );
4337
- const certPem = certResult.certPem;
4338
- const certKeyPem = certResult.keyPem;
4339
- await writeFileAtomic(caKeyFile, certKeyPem);
4340
- await writeFileAtomic(caPubFile, certPem);
4341
- await writeFileAtomic(caCertFile, certPem);
4342
- }
4343
- if (caTrustInstaller && !installerCalled) {
4344
- await caTrustInstaller(await readFile22(caCertFile, "utf8"));
4345
- installerCalled = true;
4346
- }
4389
+ await runCaTrust();
4347
4390
  } catch (error) {
4348
4391
  return {
4349
4392
  ok: false,
@@ -4353,24 +4396,6 @@ function createRequestBodyTrustController(options = {}) {
4353
4396
  }
4354
4397
  return { ok: true, state: "trusted" };
4355
4398
  }
4356
- async function untrust() {
4357
- try {
4358
- if (await existsFile(caKeyFile) && caTrustRemover) {
4359
- await caTrustRemover();
4360
- }
4361
- await rm(caKeyFile, { force: true });
4362
- await rm(caPubFile, { force: true });
4363
- await rm(caCertFile, { force: true });
4364
- installerCalled = false;
4365
- } catch (error) {
4366
- return {
4367
- ok: false,
4368
- state: "unsupported",
4369
- reasons: [codeOf(error, "trust.internal")]
4370
- };
4371
- }
4372
- return { ok: true, state: "untrusted" };
4373
- }
4374
4399
  async function status() {
4375
4400
  let installed = false;
4376
4401
  try {
@@ -4388,7 +4413,7 @@ function createRequestBodyTrustController(options = {}) {
4388
4413
  capabilityReasons: caps.reasons
4389
4414
  };
4390
4415
  }
4391
- return { install, uninstall, trust, untrust, status };
4416
+ return { install, uninstall, status };
4392
4417
  }
4393
4418
 
4394
4419
  // packages/cli/src/commands/runtime.ts
@@ -4401,10 +4426,9 @@ runtime no longer serves an HTTP mock server; mock delivery happens in the
4401
4426
  consolidated native-messaging host (spec REQ-001..REQ-005).
4402
4427
 
4403
4428
  Request-body trust commands:
4404
- install Install the native-messaging host manifest (requires --extension-id)
4405
- trust Provision and trust the device-local CA
4406
- untrust Remove the device-local CA trust (idempotent)
4407
- uninstall Uninstall the native-messaging host manifest (idempotent)
4429
+ install Install the native-messaging host manifest and (on capable
4430
+ platforms) provision the device-local CA (requires --extension-id)
4431
+ uninstall Remove the native-messaging host manifest and the device-local CA trust (idempotent)
4408
4432
 
4409
4433
  Native host command:
4410
4434
  host [path] Run the consolidated native-messaging runtime host. The browser
@@ -4421,8 +4445,8 @@ Options:
4421
4445
  --root <dir> Root for confined file mocks (default: project directory)
4422
4446
  --help, -h Show this help
4423
4447
 
4424
- The device-local CA / PAC routing capability only affects request-body
4425
- interception, not the host control plane.`);
4448
+ The device-local CA / PAC routing capability is invoked from the unified
4449
+ install command on capable platforms; it does not have a separate verb.`);
4426
4450
  }
4427
4451
  function toMatcherOperations2(operations) {
4428
4452
  return operations.map(({ groupId, ruleId, matcher }) => ({
@@ -4490,7 +4514,7 @@ function reportTrust(subcommand, result, okMessage) {
4490
4514
  return 0;
4491
4515
  }
4492
4516
  console.error(
4493
- `trust ${subcommand} failed: ${(result.reasons ?? ["unknown"]).join(", ")}`
4517
+ `runtime ${subcommand} failed: ${(result.reasons ?? ["unknown"]).join(", ")}`
4494
4518
  );
4495
4519
  return 1;
4496
4520
  }
@@ -4518,25 +4542,13 @@ async function trustRuntimeCommand(args) {
4518
4542
  return reportTrust(
4519
4543
  "install",
4520
4544
  await controller.install(extensionId ?? ""),
4521
- "trust installed"
4522
- );
4523
- case "trust":
4524
- return reportTrust(
4525
- "trust",
4526
- await controller.trust(),
4527
- "trust established"
4528
- );
4529
- case "untrust":
4530
- return reportTrust(
4531
- "untrust",
4532
- await controller.untrust(),
4533
- "trust removed"
4545
+ "runtime install complete: manifest + device-local CA trusted"
4534
4546
  );
4535
4547
  case "uninstall":
4536
4548
  return reportTrust(
4537
4549
  "uninstall",
4538
4550
  await controller.uninstall(),
4539
- "trust manifest uninstalled"
4551
+ "runtime uninstall complete: manifest + device-local CA removed"
4540
4552
  );
4541
4553
  default:
4542
4554
  console.error(`Error: unknown runtime subcommand: ${subcommand ?? ""}`);
@@ -4643,11 +4655,11 @@ async function runtimeCommand(args, _options = {}) {
4643
4655
  return 0;
4644
4656
  }
4645
4657
  const first = args[0];
4646
- if (first === "install" || first === "trust" || first === "untrust" || first === "uninstall")
4658
+ if (first === "install" || first === "trust" || first === "uninstall")
4647
4659
  return trustRuntimeCommand(args);
4648
4660
  if (first === "host") return runtimeHostCommand(args.slice(1));
4649
4661
  console.error(
4650
- `Error: 'rogatio runtime' no longer starts or stops the runtime. Use 'rogatio runtime install|trust|untrust|uninstall' to manage the host manifest and request-body trust, or 'rogatio runtime host [path]' to run the native-messaging host. Start/stop is driven from the extension's controls.`
4662
+ `Error: 'rogatio runtime' no longer starts or stops the runtime. Use 'rogatio runtime install|uninstall' to manage the host manifest and request-body trust, or 'rogatio runtime host [path]' to run the native-messaging host. Start/stop is driven from the extension's controls.`
4651
4663
  );
4652
4664
  showRuntimeHelp();
4653
4665
  return 2;
@@ -5173,7 +5185,7 @@ Commands:
5173
5185
  edit [path] Launch browser editor for .rogatio.json
5174
5186
  test [path] [url...] Run offline dry-run tests against .rogatio.json
5175
5187
  verify [path] Validate .rogatio.json file
5176
- runtime <install|trust|untrust|uninstall|host> Native messaging runtime control and request-body trust management
5188
+ runtime <install|uninstall|host> Native messaging runtime control and request-body trust management
5177
5189
  runtime host [path] Run the consolidated native-messaging runtime host
5178
5190
 
5179
5191
  Global Options:
@@ -5225,10 +5237,9 @@ runtime no longer serves an HTTP mock server; mock delivery happens in the
5225
5237
  consolidated native-messaging host (spec REQ-001..REQ-005).
5226
5238
 
5227
5239
  Request-body trust commands:
5228
- install Install the native-messaging host manifest (requires --extension-id)
5229
- trust Provision and trust the device-local CA
5230
- untrust Remove the device-local CA trust (idempotent)
5231
- uninstall Uninstall the native-messaging host manifest (idempotent)
5240
+ install Install the native-messaging host manifest and (on capable
5241
+ platforms) provision the device-local CA (requires --extension-id)
5242
+ uninstall Remove the native-messaging host manifest and the device-local CA trust (idempotent)
5232
5243
 
5233
5244
  Native host command:
5234
5245
  host [path] Run the consolidated native-messaging runtime host. The browser
@@ -5245,8 +5256,8 @@ Options:
5245
5256
  --extension-id Extension ID for native messaging manifest (required for install)
5246
5257
  --help, -h Show this help
5247
5258
 
5248
- The device-local CA / PAC routing capability only affects request-body
5249
- interception, not the host control plane.
5259
+ The device-local CA / PAC routing capability is invoked from the unified
5260
+ install command on capable platforms; it does not have a separate verb.
5250
5261
 
5251
5262
  Exit codes:
5252
5263
  0 Stopped cleanly / success
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rogatio/cli",
3
- "version": "3.0.0",
3
+ "version": "5.0.0",
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.",