omegon 0.6.20 → 0.6.21

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.
@@ -317,6 +317,79 @@ const ociProvider: AuthProvider = {
317
317
  },
318
318
  };
319
319
 
320
+ const vaultProvider: AuthProvider = {
321
+ id: "vault",
322
+ name: "Vault",
323
+ cli: "vault",
324
+ tokenEnvVar: "VAULT_TOKEN",
325
+ refreshCommand: "vault login",
326
+
327
+ async check(pi, signal) {
328
+ // 1. Check CLI is installed
329
+ const which = await pi.exec("which", ["vault"], { signal, timeout: 3_000 });
330
+ if (which.code !== 0) {
331
+ return { provider: this.id, status: "missing", detail: "vault CLI not installed" };
332
+ }
333
+
334
+ // 2. Check VAULT_ADDR is configured — without it, no meaningful check is possible
335
+ const addr = process.env["VAULT_ADDR"];
336
+ if (!addr) {
337
+ return {
338
+ provider: this.id,
339
+ status: "none",
340
+ detail: "VAULT_ADDR not set",
341
+ refresh: this.refreshCommand,
342
+ secretHint: "VAULT_ADDR",
343
+ };
344
+ }
345
+
346
+ // 3. Run vault token lookup — read-only, returns token metadata (never the token itself)
347
+ // VAULT_TOKEN is read by the vault CLI from the environment; we never access it directly.
348
+ const result = await pi.exec("vault", ["token", "lookup", "-format=json"], { signal, timeout: 10_000 });
349
+
350
+ if (result.code === 0) {
351
+ try {
352
+ const data = JSON.parse(result.stdout.trim());
353
+ const tokenData = data?.data ?? {};
354
+
355
+ // Extract safe metadata — policies and expiry only, never the token value
356
+ const policies: string[] = tokenData.policies ?? [];
357
+ const displayName: string = tokenData.display_name ?? "";
358
+ const expireTime: string = tokenData.expire_time ?? "";
359
+
360
+ // Build a human-readable detail string
361
+ const parts: string[] = [];
362
+ if (displayName) parts.push(displayName);
363
+ if (policies.length > 0) parts.push(`policies: ${policies.filter(p => p !== "default").join(", ") || "default"}`);
364
+ if (expireTime) parts.push(`expires: ${expireTime.split("T")[0]}`);
365
+ else parts.push("no expiry");
366
+
367
+ return {
368
+ provider: this.id,
369
+ status: "ok",
370
+ detail: parts.join(" · ") || "authenticated",
371
+ refresh: this.refreshCommand,
372
+ };
373
+ } catch {
374
+ // JSON parse failed but command succeeded — still authenticated
375
+ return { provider: this.id, status: "ok", detail: "authenticated", refresh: this.refreshCommand };
376
+ }
377
+ }
378
+
379
+ // 4. Diagnose failure — truncate to 300 chars, never log token values
380
+ const output = (result.stdout + "\n" + result.stderr).trim();
381
+ const diag = diagnoseError(output);
382
+ return {
383
+ provider: this.id,
384
+ status: diag.status,
385
+ detail: `${addr} — ${diag.reason}`,
386
+ error: output.slice(0, 300),
387
+ refresh: this.refreshCommand,
388
+ secretHint: "VAULT_TOKEN",
389
+ };
390
+ },
391
+ };
392
+
320
393
  // ─── Provider Registry ───────────────────────────────────────────
321
394
 
322
395
  /** All providers, ordered by typical check priority. */
@@ -327,6 +400,7 @@ export const ALL_PROVIDERS: AuthProvider[] = [
327
400
  awsProvider,
328
401
  kubernetesProvider,
329
402
  ociProvider,
403
+ vaultProvider,
330
404
  ];
331
405
 
332
406
  export function findProvider(idOrName: string): AuthProvider | undefined {
@@ -205,6 +205,19 @@ export const DEPS: Dep[] = [
205
205
  },
206
206
 
207
207
  // --- Recommended: common workflows ---
208
+ {
209
+ id: "vault",
210
+ name: "Vault CLI",
211
+ purpose: "HashiCorp Vault authentication status checking and secret management",
212
+ usedBy: ["01-auth"],
213
+ tier: "optional",
214
+ check: () => hasCmd("vault"),
215
+ requires: ["nix"],
216
+ install: [
217
+ { platform: "any", cmd: "nix profile install nixpkgs#vault" },
218
+ ],
219
+ url: "https://developer.hashicorp.com/vault/install",
220
+ },
208
221
  {
209
222
  id: "gh",
210
223
  name: "GitHub CLI",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omegon",
3
- "version": "0.6.20",
3
+ "version": "0.6.21",
4
4
  "description": "Omegon — an opinionated distribution of pi (by Mario Zechner) with extensions for lifecycle management, memory, orchestration, and visualization",
5
5
  "bin": {
6
6
  "omegon": "bin/omegon.mjs",