Repository navigation
feat(run): hand out a TOTP code to a command with --totp - #223
Merged
Merged
Conversation
nodkey run --totp VAR=NAME gives the current TOTP code of a Bitwarden login item to one command, after a tap. Only a [secret.*] section with totp = true (bw store, ask = "always", no standing grants) hands one out. The broker makes the code; the seed never leaves it. A scheduled grant gives one fresh code per use. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
5 tasks done
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.
What and why
Fixes #212.
nodkey run --totp VAR=NAMEhands one TOTP code to one command, after a tap. Example:npm publish --otpandnpm trust, which fail withEOTPwithout a code.nodkey run --secret NPM_TOKEN=npm-token --totp NPM_OTP=npm-otp -- \ sh -c 'npm publish pkg.tgz --otp "$NPM_OTP"'[secret.*]section withtotp = true, only for a store of typebw. It needsask = "always"and nostanding = true;preapprove = trueis allowed. A[logins.*]item is not a CLI code.--totp VAR=NAME(at most one) sends the variable with"kind": "totp". A--secretsends nokindfield, as before.not_allowed). After the tap it runsbw sync --forceandbw get item, readslogin.totp, clears the password at once, makes the code of now withinternal/totp, and clears the seed and the key. The seed never leaves the broker.nodkey preapprove) gives one fresh code per use, up to its uses. No window and no standing grants.secret_sententry per code, with no code and no seed.Behavior for callers
Changes behavior for existing callers: no
A request without
--totpis the same on the wire. An old broker refuses the newkindfield (strict decoding): it fails closed, and the client adds a hint to update the broker.Tests
TestTOTPCode,TestTOTPRefused(totp secret as--secret,--totpfor a plain secret, two codes, another client, unknown name),TestTOTPNoSeed(no seed, steam seed, bad base32, store failure),TestTOTPPreapprove(2 uses, 2 fresh codes, then a tap),TestTOTPGrantToken,TestTOTPReloadEndsGrantbw):TestBWFetchTOTP,TestBWFetchTOTPRefused,TestOnlyBWHandsOutTOTPTestLoadBrokerTOTP,TestDiffTOTPTestSecretRefKind; client:TestParseArgsTOTP,TestTOTPHint, new cases inTestRunUsagego test -race ./...,go vet ./...,golangci-lint run --build-tags e2e: pass.Security review
Done with
.claude/agents/security-reviewer.md: no critical, high or medium findings. Low findings fixed: the batch example in the docs, more deny-path tests, the fix text of a bad seed, a hint for an old broker. Not fixed, on purpose: the code is a Go string (fromtotp.Key.Code) and cannot be cleared. It is a 6 to 8 digit code that lasts about 30 s, and the website-login path does the same; a change ofinternal/totpfor both paths can be a follow-up.Progress
Checklist
feat:,fix:,docs:...).docs/if a command or the config changes.🤖 Generated with Claude Code