Skip to content

Let trust-publishers satisfy npm's second factor - #12

Merged
lorisleiva merged 1 commit into
mainfrom
fix/trust-second-factor
Sep 14, 2026
Merged

lorisleiva merged 1 commit into
mainfrom
fix/trust-second-factor

Conversation

@lorisleiva

Copy link
Copy Markdown
Member

This PR fixes the first live run of release-tools trust-publishers, which failed with EOTP on npm trust list.

npm trust list requires a one-time password even to read, and npm only starts its browser/OTP flow when stdin and stdout are terminals (lib/utils/auth.js: if (!process.stdin.isTTY || !process.stdout.isTTY) throw err). The task captures stdout to parse the JSON output, so npm rethrew immediately instead of prompting.

withSecondFactor() now catches EOTP on a captured call, runs an interactive npm trust list <package> with the terminal attached (printing a hint to tick "skip 2FA for the next 5 minutes"), and retries once; a second EOTP fails loudly. Unit-tested on the decision logic and exercised end to end under a pseudo-TTY with a fake npm.

Found on the renderers-rust-cpi canary (codama-idl/renderers-rust-cpi#118).

`npm trust list` requires a one-time password even to read, and npm only
starts its browser/OTP flow when stdin and stdout are both terminals. The
task captures stdout to parse the JSON, so the first live run failed with
EOTP before any prompt.

withSecondFactor() now catches EOTP on a captured call, runs an interactive
`npm trust list` with the terminal attached (where the user can grant the
5-minute 2FA-free window), and retries once before failing loudly.
@lorisleiva
lorisleiva merged commit 9c5ebd5 into main Sep 14, 2026
1 check passed
@lorisleiva
lorisleiva deleted the fix/trust-second-factor branch September 14, 2026 15:15
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