Skip to content

fix(cli): never take secretKey or the facilitator key as an argument - #111

Merged
Eras256 merged 2 commits into
mainfrom
fix/cli-config-secret-no-argv
Oct 11, 2026
Merged

Eras256 merged 2 commits into
mainfrom
fix/cli-config-secret-no-argv

Conversation

@Eras256

@Eras256 Eras256 commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator

Follow-up to #108. Three more places took a credential as a command-line argument, where it stays in shell history and shows up in ps:

  • nirium config set secretKey <key>
  • nirium config set facilitatorApiKey <key>
  • nirium serve --api-key <key> / -k

All three now exit 1, save or use nothing, and explain why (including that the value just typed should be treated as exposed). --api-key is kept only as a hidden option so it can be refused with that message instead of commander's bare "unknown option"; it no longer shows in serve --help.

Where the values come from now:

  • secretKey: NIRIUM_SECRET_KEY, or nirium config set secretKey with no value (hidden prompt on a terminal, stdin otherwise). Only a valid S... seed is saved.
  • facilitator key: FACILITATOR_API_KEY, nirium config set facilitatorApiKey (same prompt/stdin), or a hidden prompt when serve runs in a terminal and nothing else is set.

The two "how to provide a key" messages and the README no longer suggest passing either key as an argument.

Breaking for anyone scripting these flags; it ships in 2.0.0 together with #108 and #109.

Stdin timeout

serve with no terminal and no FACILITATOR_API_KEY used to read stdin until EOF, so a pipe that never closes made it hang. It now waits at most 10 s, then exits 1 with the usual "Missing facilitator API key" error (measured: 10.9 s). NIRIUM_STDIN_TIMEOUT_MS overrides the 10 s; the test uses it. config set still reads stdin without a limit on purpose: a slow secret manager piping into it is legitimate there.

Tests

npm test in packages/cli: 26 pass, 0 fail (11 existing doctor tests, 8 config tests, 7 serve tests). Each test runs with its own temporary HOME, so it never touches a real ~/.niriumrc.json, and serve uses port 0 with no payment.

The hidden-prompt path can't run under node:test (no pseudo-terminal), so I checked it by hand through script for both config set secretKey and serve: the prompt shows, the value is used or saved, and it appears 0 times in the captured output.

No CI runs on packages/cli/** yet (#103), so the results above are local.

Co-Authored-By: Claude Sonnet 5.5 noreply@anthropic.com

🤖 Generated with Claude Code

Eras256 and others added 2 commits October 11, 2026 02:46
`nirium config set secretKey <key>`, `config set facilitatorApiKey <key>`
and `serve --api-key <key>` all put a credential in shell history and in
`ps`. They now exit 1, save or use nothing, and say why. The values come
from the environment (NIRIUM_SECRET_KEY / FACILITATOR_API_KEY), a hidden
prompt on a terminal, or stdin when there is none. Same reasoning as #108.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Without a terminal and without FACILITATOR_API_KEY, `serve` read stdin
until EOF, so an open pipe that never closed made it hang. It now stops
waiting after 10 s and exits 1 with the missing-key error.
NIRIUM_STDIN_TIMEOUT_MS overrides the 10 s (used by the test).
`config set` still reads stdin without a limit: a slow secret manager
piping into it is legitimate there.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@Eras256
Eras256 force-pushed the fix/cli-config-secret-no-argv branch from 0d0d094 to 9a41c6f Compare October 11, 2026 08:48
@Eras256
Eras256 marked this pull request as ready for review October 11, 2026 08:51
@Eras256
Eras256 merged commit d2e859d into main Oct 11, 2026
@Eras256
Eras256 deleted the fix/cli-config-secret-no-argv branch October 23, 2026 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant