@senticor/hive 1.130.1 → 1.132.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.
Files changed (3) hide show
  1. package/README.md +23 -0
  2. package/hive.cjs +219 -10
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -106,6 +106,29 @@ your tenant. Until the address is verified, they only see their own tenant.
106
106
  Removing someone ends their access to this tenant. If they leave altogether, ask your platform operator to
107
107
  disable their login.
108
108
 
109
+ ## Set the authority your tenant's notices name
110
+
111
+ A tenant keeps the authority its notices name, the court for each kind of remedy, the account a payment goes
112
+ to and the signature line in a profile. Every member reads it; with the tenant role `admin` you write the next
113
+ version. The feature is experimental: a platform admin has to allow it for your tenant first.
114
+
115
+ ```bash
116
+ hive issuer-profile show # in effect now, the newest, every version
117
+ hive issuer-profile show --content > profile.json # the newest content, to edit
118
+ hive issuer-profile set --file profile.json # writes the next version
119
+ hive issuer-profile set --file profile.json --valid-from 2027-01-01T00:00:00Z
120
+ ```
121
+
122
+ `profile.json` holds `authority` (required: `name`, `seat`), and optionally `courts`, `payment` and
123
+ `signature`. `set` reads the newest version itself and writes nothing when it refuses:
124
+
125
+ | Code | What it means | What to do |
126
+ | --- | --- | --- |
127
+ | `ISSUER_PROFILE_INVALID` | A value is wrong; the message names the field and why | Correct it in the file and run `set` again |
128
+ | `ISSUER_PROFILE_VERSION_CONFLICT` | Someone wrote a version since the command read it | Run `show --content`, apply your change, run `set` again |
129
+ | `TENANT_ROLE_REQUIRED` | You do not hold the tenant role `admin` | Ask a platform admin |
130
+ | `EXPERIMENTAL_FEATURE_NOT_ENABLED` | Your tenant may not use profiles yet | Ask a platform admin |
131
+
109
132
  ## Updating
110
133
 
111
134
  Because this is an npm-managed install, update it with npm — `hive upgrade` is
package/hive.cjs CHANGED
@@ -9387,16 +9387,19 @@ function remoteFailureHandled() {
9387
9387
  var HiveClient = class {
9388
9388
  baseUrl;
9389
9389
  tenant;
9390
+ breakGlass;
9390
9391
  verbose;
9391
9392
  constructor(opts = {}) {
9392
9393
  this.baseUrl = (opts.apiUrl || process.env.HIVE_API_URL || "http://localhost:8787").replace(/\/+$/, "");
9393
9394
  this.tenant = opts.tenant === null ? null : opts.tenant || process.env.HIVE_TENANT || process.env.HIVE_TENANT_ID || "default";
9395
+ this.breakGlass = opts.breakGlass ?? null;
9394
9396
  this.verbose = !!opts.verbose;
9395
9397
  }
9396
9398
  /** Tenant + auth headers every request to the Hive API carries. */
9397
9399
  async _baseHeaders(accept) {
9398
9400
  const headers = { accept };
9399
9401
  if (this.tenant) headers["x-hive-tenant"] = this.tenant;
9402
+ if (this.breakGlass) headers["x-hive-break-glass"] = this.breakGlass;
9400
9403
  try {
9401
9404
  const token = envToken()?.token || await getValidToken();
9402
9405
  if (token) headers["authorization"] = `Bearer ${token}`;
@@ -9670,6 +9673,16 @@ function describeAppliedTenant(selection) {
9670
9673
  return `Sent X-Hive-Tenant: ${selection.value} (${selection.source}, from ${selection.origin})`;
9671
9674
  }
9672
9675
 
9676
+ // src/lib/break-glass.ts
9677
+ init_cjs_shims();
9678
+ var sent = false;
9679
+ function recordBreakGlass(reason) {
9680
+ sent = reason !== null;
9681
+ }
9682
+ function breakGlassSent() {
9683
+ return sent;
9684
+ }
9685
+
9673
9686
  // src/lib/errors.ts
9674
9687
  var CliCommandError = class extends Error {
9675
9688
  exitCode;
@@ -9755,7 +9768,8 @@ function remoteFailureRemediation(data) {
9755
9768
  return scope + "The requested tenant is not in your active memberships. " + (pinned ? "It is a saved pin, not something this command asked for \u2014 run 'hive config clear --tenant' to drop it. " : "If the tenant is saved in CLI config, run 'hive config clear --tenant'. ") + "Platform-scoped commands (hive org *, hive admin list|grant|revoke) ignore a pin already; for other platform-admin operations (mission create) omit --tenant / HIVE_TENANT. Run 'hive diag authz' to list memberships and optionally pin one with 'hive config use --tenant=<displayKey>'.";
9756
9769
  }
9757
9770
  if (code === "MISSION_NOT_FOUND") {
9758
- return scope + "The mission id was not found in the CURRENT tenant scope. A mission is only visible under the tenant it was created in \u2014 check you are using the same --tenant / HIVE_TENANT (or self-tenant) as at create time. Run 'hive mission list --tenant <tenant>' to find the scope that owns it.";
9771
+ return scope + "The mission id was not found in the CURRENT tenant scope. A mission is only visible under the tenant it was created in \u2014 check you are using the same --tenant / HIVE_TENANT (or self-tenant) as at create time. Run 'hive mission list --tenant <tenant>' to find the scope that owns it." + // #503: since #501 a platform admin who is not a member gets this 404 too.
9772
+ (breakGlassSent() ? "" : ' A platform admin who is not a member of the mission reaches it with --break-glass "<ticket reference>", audited.');
9759
9773
  }
9760
9774
  return void 0;
9761
9775
  }
@@ -9996,8 +10010,14 @@ function ctx(args, opts = {}) {
9996
10010
  origin: tenantSelectorOrigin(resolvedTenant.source),
9997
10011
  applied: tenant !== null
9998
10012
  });
10013
+ const breakGlass = resolveBreakGlass(args);
10014
+ recordBreakGlass(breakGlass);
10015
+ if (breakGlass && shouldEmitHuman(args)) {
10016
+ noteOnce(`Note: breaking glass ("${breakGlass}"): admin access beyond your mission memberships, audited with this reason.`);
10017
+ }
9999
10018
  const client = new HiveClient({
10000
10019
  apiUrl: args.apiUrl ?? process.env.HIVE_API_URL ?? cfg.apiUrl,
10020
+ breakGlass,
10001
10021
  // env (HIVE_TENANT / legacy HIVE_TENANT_ID) must win over the saved config,
10002
10022
  // or a scripted command with HIVE_TENANT_ID set would hit the saved tenant
10003
10023
  // instead of the intended environment one (Codex P2).
@@ -10006,6 +10026,22 @@ function ctx(args, opts = {}) {
10006
10026
  });
10007
10027
  return { client, fmt: args.json ? "json" : args.format ?? "table" };
10008
10028
  }
10029
+ var BREAK_GLASS_REASON_MAX = 200;
10030
+ var PRINTABLE_LATIN1 = /^[\x20-\x7e\xa0-\xff]+$/;
10031
+ function resolveBreakGlass(args) {
10032
+ const flag = args.breakGlass;
10033
+ const raw = typeof flag === "string" ? flag : process.env.HIVE_BREAK_GLASS;
10034
+ if (raw === void 0 || flag === void 0 && raw === "") return null;
10035
+ const reason = raw.trim();
10036
+ if (!reason || reason.length > BREAK_GLASS_REASON_MAX || !PRINTABLE_LATIN1.test(reason)) {
10037
+ throw commandError(
10038
+ "BREAK_GLASS_REASON_INVALID",
10039
+ 2,
10040
+ `The break-glass reason must be 1-${BREAK_GLASS_REASON_MAX} characters on one line, letters (German included), digits and punctuation, no symbols such as \u20AC (--break-glass / HIVE_BREAK_GLASS).`
10041
+ );
10042
+ }
10043
+ return reason;
10044
+ }
10009
10045
  function resolvesToSelfTenant(resolved) {
10010
10046
  if (resolved.source === "default") return true;
10011
10047
  return resolved.source === "pinned" && resolved.value === "default";
@@ -10247,6 +10283,7 @@ var globalArgs = {
10247
10283
  apiUrl: { type: "string", description: "API base URL (env: HIVE_API_URL)" },
10248
10284
  tenant: { type: "string", description: "Tenant selector: tenant displayKey (e.g. 'bms') or UUID, sent as X-Hive-Tenant. The legacy 'tenant:<key>' form is retired (env: HIVE_TENANT)" },
10249
10285
  caFile: { type: "string", description: "PEM CA bundle to trust for self-signed/on-prem TLS (env: HIVE_CA_FILE; or set NODE_EXTRA_CA_CERTS)" },
10286
+ breakGlass: { type: "string", description: "Platform admins: reach missions beyond your memberships, audited with this reason: a ticket reference, no personal data (1-200 characters), sent as X-Hive-Break-Glass (env: HIVE_BREAK_GLASS)" },
10250
10287
  insecure: { type: "boolean", description: "Skip TLS verification PROCESS-WIDE (incl. child processes like upgrade downloads) \u2014 DANGEROUS, trusted host only (env: HIVE_TLS_INSECURE)" },
10251
10288
  format: { type: "string", description: "Output: json | table | yaml (default: table)" },
10252
10289
  json: { type: "boolean", description: "Alias for --format json" },
@@ -10433,22 +10470,22 @@ var artifactName = injectedString(
10433
10470
  true ? "hive-cli" : void 0
10434
10471
  ) || String(process.env.HIVE_CLI_ARTIFACT_NAME || "hive-cli").trim() || "hive-cli";
10435
10472
  var packageVersion = injectedString(
10436
- true ? "1.130.1" : void 0
10473
+ true ? "1.132.0" : void 0
10437
10474
  ) || String(process.env.HIVE_CLI_PACKAGE_VERSION || "").trim() || readPackageVersion();
10438
10475
  var releaseVersion = injectedString(
10439
- true ? "1.130.1" : void 0
10476
+ true ? "1.132.0" : void 0
10440
10477
  ) || String(process.env.HIVE_CLI_RELEASE_VERSION || "").trim() || packageVersion || "dev";
10441
10478
  var releaseChannel = injectedString(
10442
10479
  true ? "final" : void 0
10443
10480
  ) || String(process.env.HIVE_CLI_RELEASE_CHANNEL || "").trim() || (releaseVersion.includes("-rc.") ? "rc" : releaseVersion === "dev" ? "dev" : "final");
10444
10481
  var buildCommit = injectedString(
10445
- true ? "531c7b24a669b695549818635bc517730623f7c4" : void 0
10482
+ true ? "0df6dc8d14dc4effc5459e082d9eac117d375c28" : void 0
10446
10483
  ) || String(process.env.HIVE_CLI_BUILD_COMMIT || "").trim() || "unknown";
10447
10484
  var buildTimestamp = injectedString(
10448
- true ? "2026-11-09T22:51:01Z" : void 0
10485
+ true ? "2026-11-10T11:27:57Z" : void 0
10449
10486
  ) || String(process.env.HIVE_CLI_BUILD_TIMESTAMP || "").trim() || "unknown";
10450
10487
  var ociRef = injectedString(
10451
- true ? "registry.onstackit.cloud/senticor/hive-cli:1.130.1" : void 0
10488
+ true ? "registry.onstackit.cloud/senticor/hive-cli:1.132.0" : void 0
10452
10489
  ) || String(process.env.HIVE_CLI_OCI_REF || "").trim() || `registry.onstackit.cloud/senticor/${artifactName}:${releaseVersion}`;
10453
10490
  var RELEASE_INFO = Object.freeze({
10454
10491
  packageVersion,
@@ -33426,6 +33463,177 @@ var members2 = defineCommand({
33426
33463
  }
33427
33464
  });
33428
33465
 
33466
+ // src/commands/issuer-profile.ts
33467
+ init_cjs_shims();
33468
+ var profileArg = {
33469
+ profile: { type: "string", description: "Profile id (default: default)" }
33470
+ };
33471
+ var NEXT_STEP = {
33472
+ ISSUER_PROFILE_INVALID: (file2) => `Nothing was written. Correct the field named above${file2 ? ` in ${file2}` : ""} and run the command again.`,
33473
+ ISSUER_PROFILE_VERSION_CONFLICT: () => "Nothing was written: someone wrote a newer version since it was read. Run 'hive issuer-profile show --content' to see it, apply your change to it, and run 'hive issuer-profile set' again.",
33474
+ ISSUER_PROFILE_NOT_FOUND: () => "The active tenant has no versions of this profile. Write the first one with 'hive issuer-profile set --file <profile.json>'.",
33475
+ TENANT_ROLE_REQUIRED: () => "Writing a profile needs the tenant role 'admin' in the active tenant, or a platform admin.",
33476
+ EXPERIMENTAL_FEATURE_NOT_ENABLED: () => "This tenant may not use issuing-authority profiles yet: a platform admin has to allow it the experimental feature 'issuer-profiles'."
33477
+ };
33478
+ function refusedField(data) {
33479
+ const field = recordOf2(recordOf2(data).details).field;
33480
+ return typeof field === "string" && field ? field : void 0;
33481
+ }
33482
+ function refusal(res, action, file2) {
33483
+ const err = remoteFailureError(res.status, res.data, action);
33484
+ const code = remoteErrorFields(res.data).code;
33485
+ const field = refusedField(res.data);
33486
+ if (field && !err.message.includes(field)) err.message += ` (field: ${field})`;
33487
+ const next = NEXT_STEP[code]?.(file2);
33488
+ if (next) {
33489
+ err.remediation = next;
33490
+ err.message += ` \u2014 ${next}`;
33491
+ }
33492
+ return err;
33493
+ }
33494
+ function ensureOk3(res, action, file2) {
33495
+ if (!isHttpOk(res.status)) throw refusal(res, action, file2);
33496
+ }
33497
+ async function activeTenant(client) {
33498
+ const selection = appliedTenantSelection();
33499
+ if (selection?.applied && selection.value) return selection.value;
33500
+ const me = await client.get("/api/me");
33501
+ ensureOk3(me, "read the active tenant");
33502
+ const tenantId = recordOf2(recordOf2(me.data).activeTenant).tenantId;
33503
+ if (typeof tenantId !== "string" || !tenantId) {
33504
+ throw commandError("TENANT_UNKNOWN", 1, "The API did not name your active tenant. Pass --tenant <displayKey>.");
33505
+ }
33506
+ return tenantId;
33507
+ }
33508
+ function profileIdOf(args) {
33509
+ return String(args.profile || "").trim() || "default";
33510
+ }
33511
+ async function profilePath(client, args) {
33512
+ return `/api/tenants/${enc(await activeTenant(client))}/issuer-profiles/${enc(profileIdOf(args))}`;
33513
+ }
33514
+ function pendingOf(profile) {
33515
+ const latest = recordOf2(profile.latest);
33516
+ const effective = recordOf2(profile.effective);
33517
+ if (typeof latest.version !== "number" || latest.version === effective.version) return null;
33518
+ return { version: latest.version, validFrom: String(latest.validFrom) };
33519
+ }
33520
+ function contentFromFile(file2) {
33521
+ const parsed = readJsonFile(file2);
33522
+ const content = isPlainObject(parsed) && isPlainObject(parsed.content) && parsed.authority === void 0 ? parsed.content : parsed;
33523
+ if (!isPlainObject(content)) {
33524
+ throw commandError("INVALID_PROFILE_FILE", 1, `${file2} must hold the profile content as a JSON object (authority, courts, payment, signature).`);
33525
+ }
33526
+ return content;
33527
+ }
33528
+ function printContent(content) {
33529
+ process.stdout.write(`${JSON.stringify(content ?? null, null, 2)}
33530
+ `);
33531
+ }
33532
+ var issuerProfile = defineCommand({
33533
+ meta: { name: "issuer-profile", description: "Read and write the authority, courts, payment and signature the active tenant's notices name" },
33534
+ args: withOwnArgs({ ...profileArg }),
33535
+ default: "show",
33536
+ subCommands: {
33537
+ list: defineCommand({
33538
+ meta: { name: "list", description: "List the active tenant's profiles and their newest version" },
33539
+ args: withOwnArgs(),
33540
+ async run({ args }) {
33541
+ printContextNotice(args);
33542
+ const { client, fmt } = ctx(args);
33543
+ const res = await client.get(`/api/tenants/${enc(await activeTenant(client))}/issuer-profiles`);
33544
+ ensureOk3(res, "list issuing-authority profiles");
33545
+ return output(res.data, fmt);
33546
+ }
33547
+ }),
33548
+ show: defineCommand({
33549
+ meta: { name: "show", description: "Show a profile: the version in effect, the newest one and every version (--version n: one version)" },
33550
+ args: withOwnArgs({
33551
+ ...profileArg,
33552
+ version: { type: "string", description: "Show this one version, as a seal names it" },
33553
+ content: { type: "boolean", description: "Print only the content of the newest version (or of --version), as JSON to edit and pass to 'set --file'" }
33554
+ }),
33555
+ async run({ args }) {
33556
+ printContextNotice(args);
33557
+ const { client, fmt } = ctx(args);
33558
+ const base = await profilePath(client, args);
33559
+ if (args.version !== void 0) {
33560
+ const res2 = await client.get(`${base}/versions/${enc(args.version)}`);
33561
+ ensureOk3(res2, "read the profile version");
33562
+ if (args.content) return printContent(recordOf2(recordOf2(res2.data).version).content);
33563
+ return output(res2.data, fmt);
33564
+ }
33565
+ const res = await client.get(base);
33566
+ ensureOk3(res, "read the profile");
33567
+ if (!args.content) return output(res.data, fmt);
33568
+ const profile = recordOf2(res.data);
33569
+ const pending2 = pendingOf(profile);
33570
+ if (pending2 && args.quiet !== true) {
33571
+ process.stderr.write(`Note: version ${pending2.version} is not in effect yet (from ${pending2.validFrom}); this is its content.
33572
+ `);
33573
+ }
33574
+ return printContent(recordOf2(profile.latest).content);
33575
+ }
33576
+ }),
33577
+ set: defineCommand({
33578
+ meta: { name: "set", description: "Write the next version of a profile from a JSON file (--file); refusals name the field" },
33579
+ args: withOwnArgs({
33580
+ ...profileArg,
33581
+ file: { type: "string", description: "JSON file with the profile content (authority, courts, payment, signature)" },
33582
+ validFrom: { type: "string", description: "ISO timestamp from which the version applies; default now, never in the past" },
33583
+ expectedVersion: { type: "string", description: "The newest version you read, 0 for a new profile; read from the API when omitted" }
33584
+ }),
33585
+ async run({ args }) {
33586
+ printContextNotice(args);
33587
+ req(args, "file");
33588
+ const file2 = String(args.file);
33589
+ let expectedVersion;
33590
+ if (args.expectedVersion !== void 0) {
33591
+ if (!/^\d{1,9}$/.test(String(args.expectedVersion))) {
33592
+ throw commandError("INVALID_EXPECTED_VERSION", 1, "--expected-version must be a whole number, 0 for a new profile.");
33593
+ }
33594
+ expectedVersion = Number(args.expectedVersion);
33595
+ }
33596
+ const content = contentFromFile(file2);
33597
+ const { client, fmt } = ctx(args);
33598
+ const base = await profilePath(client, args);
33599
+ let pending2 = null;
33600
+ if (expectedVersion === void 0) {
33601
+ const read = await client.get(base);
33602
+ if (read.status === 404 && remoteErrorFields(read.data).code === "ISSUER_PROFILE_NOT_FOUND") {
33603
+ remoteFailureHandled();
33604
+ expectedVersion = 0;
33605
+ } else {
33606
+ ensureOk3(read, "read the profile");
33607
+ const profile = recordOf2(read.data);
33608
+ expectedVersion = Number(profile.latestVersion);
33609
+ pending2 = pendingOf(profile);
33610
+ }
33611
+ }
33612
+ const res = await client.put(base, {
33613
+ expectedVersion,
33614
+ content,
33615
+ ...args.validFrom ? { validFrom: String(args.validFrom) } : {}
33616
+ });
33617
+ ensureOk3(res, "write the profile version", file2);
33618
+ const written = recordOf2(recordOf2(res.data).version);
33619
+ const validFrom = String(written.validFrom);
33620
+ return output({
33621
+ ok: true,
33622
+ profileId: profileIdOf(args),
33623
+ versionBefore: expectedVersion,
33624
+ version: written.version,
33625
+ validFrom,
33626
+ inEffect: Date.parse(validFrom) <= Date.now(),
33627
+ sha256: written.sha256,
33628
+ // A pending version still applies from its own start until this one starts.
33629
+ ...pending2 ? { pendingBefore: { ...pending2, stillTakesEffect: Date.parse(pending2.validFrom) < Date.parse(validFrom) } } : {},
33630
+ content: written.content
33631
+ }, fmt);
33632
+ }
33633
+ })
33634
+ }
33635
+ });
33636
+
33429
33637
  // src/commands/infra.ts
33430
33638
  init_cjs_shims();
33431
33639
  var import_node_path9 = __toESM(require("path"), 1);
@@ -33724,7 +33932,7 @@ async function runAuthzDiag(args) {
33724
33932
  const diagnostics = await client.get("/api/system/diagnostics/authz");
33725
33933
  const meBody = asObject(me.data);
33726
33934
  const request = asObject(meBody.request);
33727
- const activeTenant = asObject(meBody.activeTenant);
33935
+ const activeTenant2 = asObject(meBody.activeTenant);
33728
33936
  const diagnosticsBody = asObject(diagnostics.data);
33729
33937
  const diagnosticsMetrics = asObject(diagnosticsBody.metrics);
33730
33938
  const hasAcquireMetric = diagnosticsMetrics.authzStoreAcquireDuration === true;
@@ -33759,9 +33967,9 @@ async function runAuthzDiag(args) {
33759
33967
  requestId: typeof request.requestId === "string" ? request.requestId : typeof meBody.requestId === "string" ? meBody.requestId : null,
33760
33968
  tenantSelectionSource: typeof request.tenantSelectionSource === "string" ? request.tenantSelectionSource : null,
33761
33969
  activeTenant: {
33762
- tenantId: typeof activeTenant.tenantId === "string" ? activeTenant.tenantId : null,
33763
- displayKey: typeof activeTenant.displayKey === "string" ? activeTenant.displayKey : null,
33764
- kind: typeof activeTenant.kind === "string" ? activeTenant.kind : null
33970
+ tenantId: typeof activeTenant2.tenantId === "string" ? activeTenant2.tenantId : null,
33971
+ displayKey: typeof activeTenant2.displayKey === "string" ? activeTenant2.displayKey : null,
33972
+ kind: typeof activeTenant2.kind === "string" ? activeTenant2.kind : null
33765
33973
  },
33766
33974
  // #1586: surface the caller's memberships (displayKey + status) — this is
33767
33975
  // the command the TENANT_NOT_ALLOWED hint points at, so it must show the
@@ -38291,6 +38499,7 @@ var main = defineCommand({
38291
38499
  admin,
38292
38500
  org,
38293
38501
  members: members2,
38502
+ "issuer-profile": issuerProfile,
38294
38503
  // Infrastructure
38295
38504
  health,
38296
38505
  status,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@senticor/hive",
3
- "version": "1.130.1",
3
+ "version": "1.132.0",
4
4
  "description": "Cognitive Hive OS — unified CLI",
5
5
  "type": "commonjs",
6
6
  "bin": {