@rogatio/cli 3.0.0 → 4.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\|untrust\|uninstall>` | Register the native-messaging host (and, on capable platforms, the device-local CA) in one transactional install; `untrust` removes CA trust; `uninstall` removes the host. |
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,8 +4309,58 @@ 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
+ }
4314
4364
  async function uninstall() {
4315
4365
  try {
4316
4366
  await rm(manifestPath(), { force: true });
@@ -4324,26 +4374,8 @@ function createRequestBodyTrustController(options = {}) {
4324
4374
  return { ok: true, state: "uninstalled" };
4325
4375
  }
4326
4376
  async function trust() {
4327
- const caps = await detect();
4328
- if (!caps.caTrust) return unsupportedResult(caps);
4329
4377
  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
- }
4378
+ await runCaTrust();
4347
4379
  } catch (error) {
4348
4380
  return {
4349
4381
  ok: false,
@@ -4388,7 +4420,7 @@ function createRequestBodyTrustController(options = {}) {
4388
4420
  capabilityReasons: caps.reasons
4389
4421
  };
4390
4422
  }
4391
- return { install, uninstall, trust, untrust, status };
4423
+ return { install, uninstall, untrust, status };
4392
4424
  }
4393
4425
 
4394
4426
  // packages/cli/src/commands/runtime.ts
@@ -4401,8 +4433,8 @@ runtime no longer serves an HTTP mock server; mock delivery happens in the
4401
4433
  consolidated native-messaging host (spec REQ-001..REQ-005).
4402
4434
 
4403
4435
  Request-body trust commands:
4404
- install Install the native-messaging host manifest (requires --extension-id)
4405
- trust Provision and trust the device-local CA
4436
+ install Install the native-messaging host manifest and (on capable
4437
+ platforms) provision the device-local CA (requires --extension-id)
4406
4438
  untrust Remove the device-local CA trust (idempotent)
4407
4439
  uninstall Uninstall the native-messaging host manifest (idempotent)
4408
4440
 
@@ -4421,8 +4453,8 @@ Options:
4421
4453
  --root <dir> Root for confined file mocks (default: project directory)
4422
4454
  --help, -h Show this help
4423
4455
 
4424
- The device-local CA / PAC routing capability only affects request-body
4425
- interception, not the host control plane.`);
4456
+ The device-local CA / PAC routing capability is invoked from the unified
4457
+ install command on capable platforms; it does not have a separate verb.`);
4426
4458
  }
4427
4459
  function toMatcherOperations2(operations) {
4428
4460
  return operations.map(({ groupId, ruleId, matcher }) => ({
@@ -4518,13 +4550,7 @@ async function trustRuntimeCommand(args) {
4518
4550
  return reportTrust(
4519
4551
  "install",
4520
4552
  await controller.install(extensionId ?? ""),
4521
- "trust installed"
4522
- );
4523
- case "trust":
4524
- return reportTrust(
4525
- "trust",
4526
- await controller.trust(),
4527
- "trust established"
4553
+ "runtime install complete: manifest + device-local CA trusted"
4528
4554
  );
4529
4555
  case "untrust":
4530
4556
  return reportTrust(
@@ -4647,7 +4673,7 @@ async function runtimeCommand(args, _options = {}) {
4647
4673
  return trustRuntimeCommand(args);
4648
4674
  if (first === "host") return runtimeHostCommand(args.slice(1));
4649
4675
  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.`
4676
+ `Error: 'rogatio runtime' no longer starts or stops the runtime. Use 'rogatio runtime install|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.`
4651
4677
  );
4652
4678
  showRuntimeHelp();
4653
4679
  return 2;
@@ -5173,7 +5199,7 @@ Commands:
5173
5199
  edit [path] Launch browser editor for .rogatio.json
5174
5200
  test [path] [url...] Run offline dry-run tests against .rogatio.json
5175
5201
  verify [path] Validate .rogatio.json file
5176
- runtime <install|trust|untrust|uninstall|host> Native messaging runtime control and request-body trust management
5202
+ runtime <install|untrust|uninstall|host> Native messaging runtime control and request-body trust management
5177
5203
  runtime host [path] Run the consolidated native-messaging runtime host
5178
5204
 
5179
5205
  Global Options:
@@ -5225,8 +5251,8 @@ runtime no longer serves an HTTP mock server; mock delivery happens in the
5225
5251
  consolidated native-messaging host (spec REQ-001..REQ-005).
5226
5252
 
5227
5253
  Request-body trust commands:
5228
- install Install the native-messaging host manifest (requires --extension-id)
5229
- trust Provision and trust the device-local CA
5254
+ install Install the native-messaging host manifest and (on capable
5255
+ platforms) provision the device-local CA (requires --extension-id)
5230
5256
  untrust Remove the device-local CA trust (idempotent)
5231
5257
  uninstall Uninstall the native-messaging host manifest (idempotent)
5232
5258
 
@@ -5245,8 +5271,8 @@ Options:
5245
5271
  --extension-id Extension ID for native messaging manifest (required for install)
5246
5272
  --help, -h Show this help
5247
5273
 
5248
- The device-local CA / PAC routing capability only affects request-body
5249
- interception, not the host control plane.
5274
+ The device-local CA / PAC routing capability is invoked from the unified
5275
+ install command on capable platforms; it does not have a separate verb.
5250
5276
 
5251
5277
  Exit codes:
5252
5278
  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": "4.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.",