kubeagent 0.1.15 → 0.1.16

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 (2) hide show
  1. package/dist/auth.js +13 -3
  2. package/package.json +1 -1
package/dist/auth.js CHANGED
@@ -1,4 +1,4 @@
1
- import { readFileSync, writeFileSync, existsSync, mkdirSync, unlinkSync } from "node:fs";
1
+ import { readFileSync, writeFileSync, existsSync, mkdirSync, unlinkSync, chmodSync } from "node:fs";
2
2
  import { join } from "node:path";
3
3
  import { createServer } from "node:http";
4
4
  import { randomBytes } from "node:crypto";
@@ -31,8 +31,18 @@ export function loadAuth() {
31
31
  export function saveAuth(auth) {
32
32
  const dir = configDir();
33
33
  if (!existsSync(dir))
34
- mkdirSync(dir, { recursive: true });
35
- writeFileSync(authPath(), JSON.stringify(auth, null, 2));
34
+ mkdirSync(dir, { recursive: true, mode: 0o700 });
35
+ const path = authPath();
36
+ // Write with mode 0600 so only the owning user can read the file.
37
+ // This is the fallback for platforms where a system keychain is unavailable.
38
+ // To use the OS keychain instead (recommended for production), install `keytar`
39
+ // and store auth.token and auth.apiKey there, keeping only non-secret fields here.
40
+ writeFileSync(path, JSON.stringify(auth, null, 2), { mode: 0o600 });
41
+ // Ensure permissions even if the file already existed with looser permissions.
42
+ try {
43
+ chmodSync(path, 0o600);
44
+ }
45
+ catch { /* non-POSIX platforms ignore this */ }
36
46
  }
37
47
  export function clearAuth() {
38
48
  const path = authPath();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kubeagent",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
4
4
  "description": "AI-powered Kubernetes management CLI",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",