Repository navigation
Let trust-publishers satisfy npm's second factor - #12
Merged
Merged
Conversation
`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.
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.
This PR fixes the first live run of
release-tools trust-publishers, which failed withEOTPonnpm trust list.npm trust listrequires 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 catchesEOTPon a captured call, runs an interactivenpm trust list <package>with the terminal attached (printing a hint to tick "skip 2FA for the next 5 minutes"), and retries once; a secondEOTPfails loudly. Unit-tested on the decision logic and exercised end to end under a pseudo-TTY with a fakenpm.Found on the renderers-rust-cpi canary (codama-idl/renderers-rust-cpi#118).