fix(login): mask the API key prompt so a paste is visible - #8
Merged
Conversation
`kenari login --api-key` gave no feedback at all while typing or pasting. A paste is a single event, so a blank prompt left no way to tell whether the clipboard landed, and the command read as broken even when it worked. The prompt now shows one `*` per character. `askHidden` becomes `askSecret` and redraws from the interface's current line rather than the chunk readline hands over, so a paste that arrives as one chunk still shows its full width, backspace shrinks the row, and readline's cursor escapes do not leak into the output. Masking is skipped when stdout is redirected, to keep escape codes out of a capture file. An ASCII `*` rather than a bullet, which renders as `?` under a legacy Windows console codepage. A wrong clipboard is already caught by the existing local format check in setKey, so the mask does not need to reveal a prefix to be useful.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
kenari login --api-keyshowed nothing at all while you typed or pasted:A paste is a single event, so a blank prompt gives no way to tell whether the clipboard actually landed. The command reads as broken even when it works.
Change
askHiddenbecomesaskSecretand renders fromiface.lineon every readline refresh, rather than from the chunk readline happens to pass in. That is what makes a clipboard paste (which arrives as one chunk) show its full width, backspace shrink the row, and readline's cursor escapes stay out of the output.Masking is skipped when stdout is not a TTY, so escape codes never land in a capture file. The piped form (
echo "$KEY" | kenari login --api-key) is unaffected.An ASCII
*rather than a bullet: this repo runs Windows CI, and a bullet renders as?under a legacy console codepage.Why no visible prefix
A partial-reveal variant (
kn-f4ke*****) would confirm you pasted the right key, not just a key. Not needed:setKeyalready enforces/^kn-[A-Za-z0-9]{8,}$/locally, so aghp_token or a truncated key fails immediately with a clear error. The format check does that job without putting anything readable in scrollback.Verification
94/94 pass.
renderMaskedis asserted directly, because the failure mode here is silent: writing the line instead of the mask puts a live credential into scrollback and still "works".prompt + '*' * len(key)kn-The assertions were confirmed load-bearing by running them against a deliberately echoing renderer, which fails on
masked row. That was done in a throwaway script rather than by weakening the guard insrc/.The earlier Ctrl-D fix is intact: an abandoned prompt still exits 1 rather than 0.
Docs
README no longer claims the prompt is hidden, since it is now masked.