@weirgate/cli 0.4.0 → 0.4.1

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
@@ -40,6 +40,9 @@ then `weirgate config propose --file config.json`: propose reads the exported fi
40
40
 
41
41
  ## Changes
42
42
 
43
+ - **0.4.1**: on macOS, `weirgate auth login` stores the key in the Keychain through
44
+ `security -i` on stdin, so the key no longer appears on the `security` command line,
45
+ where other local users and process listings could read it.
43
46
  - **0.4.0**: `weirgate auth login` and the local secret-entry page exit as soon as the
44
47
  browser is done (they used to wait on the browser's open connections). `config propose`
45
48
  and `config validate` accept a `config export` file as is. `weirgate audit list
package/dist/cli/index.js CHANGED
@@ -102,14 +102,27 @@ async function authCommand(verb, flags) {
102
102
  }));
103
103
  const client = new AgentApiClient({ apiKey: key, baseUrl: apiUrl, requireTenantKey: true });
104
104
  const identity = await client.whoami();
105
- const stored = spawnSync("security", ["add-generic-password", "-U", "-s", "weirgate-cli", "-a", "default", "-w", key], { stdio: "ignore" });
106
- if (stored.status !== 0)
107
- throw invocation("Unable to store key in macOS Keychain; use WEIRGATE_API_KEY instead.");
105
+ keychainStore(key);
108
106
  return identity;
109
107
  }
110
108
  const client = await clientFromEnvironment(flags);
111
109
  return client.whoami();
112
110
  }
111
+ /**
112
+ * Stores the key without putting it in argv (visible to `ps` and exec telemetry):
113
+ * `security -i` reads the command from stdin. The key must be a plain `wgk_` key
114
+ * (AgentApiClient already enforces this), so it cannot break out of the one command line.
115
+ */
116
+ function keychainStore(key) {
117
+ if (!/^wgk_[a-f0-9]{64}$/.test(key))
118
+ throw invocation("Unable to store key in macOS Keychain; use WEIRGATE_API_KEY instead.");
119
+ const stored = spawnSync("/usr/bin/security", ["-i"], {
120
+ input: `add-generic-password -U -s weirgate-cli -a default -w ${key}\n`,
121
+ stdio: ["pipe", "ignore", "ignore"],
122
+ });
123
+ if (stored.status !== 0)
124
+ throw invocation("Unable to store key in macOS Keychain; use WEIRGATE_API_KEY instead.");
125
+ }
113
126
  function keychainRead() {
114
127
  const result = spawnSync("security", ["find-generic-password", "-s", "weirgate-cli", "-a", "default", "-w"], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] });
115
128
  return result.status === 0 ? result.stdout.trim() : undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weirgate/cli",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Weirgate CLI and local stdio MCP server: scoped, proposal-first management of Weirgate apps.",
5
5
  "license": "MIT",
6
6
  "author": "Astraen Labs LLC",