Skip to content

fix(webauth): improve error messages around webauth in non-TTY#8952

Merged
wraithgar merged 1 commit intonpm:latestfrom
Andarist:fix/webauth-errors
Feb 3, 2026
Merged

fix(webauth): improve error messages around webauth in non-TTY#8952
wraithgar merged 1 commit intonpm:latestfrom
Andarist:fix/webauth-errors

Conversation

@Andarist
Copy link
Contributor

@Andarist Andarist commented Feb 2, 2026

Add webauth URLs to EOTP error messages

When npm returns an EOTP error with authUrl and doneUrl in the response body (web-based OTP flow), these URLs are now included in the error output.

What:

  • Display authUrl (for browser authentication) and doneUrl (for token retrieval) in non-TTY EOTP error messages
  • Include both URLs in --json output as error.authUrl and error.doneUrl
  • Adjusted messaging to differentiate webauth flow from traditional TOTP authenticator flow

Why:

  • In non-interactive/CI environments, the webauth URLs were not surfaced, making it impossible to complete authentication
  • Tools wrapping npm publish (like changesets) need access to these URLs to implement web OTP support
  • The doneUrl is required for polling to retrieve the token after browser authentication completes

@Andarist Andarist requested a review from a team as a code owner February 2, 2026 21:35
Copy link
Member

@wraithgar wraithgar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks good to go. My only concern was spreading json in the output error util, not knowing what else may try to set that attribute. Both the run and view commands also pass an error generated from getError already so we shouldn't have any surprises there.

@Andarist
Copy link
Contributor Author

Andarist commented Feb 3, 2026

Yeah, I definitely had some doubts about the ...json there but decided it's the best option. I don't mind adjusting this however you'd like though.

@wraithgar
Copy link
Member

All good, I think it sets up a nice pattern for future errors to arbitrarily add more context when in json mode.

@wraithgar wraithgar changed the title feat(webauth): improve error messages around webauth in non-TTY fix(webauth): improve error messages around webauth in non-TTY Feb 3, 2026
@wraithgar wraithgar merged commit 2242f25 into npm:latest Feb 3, 2026
20 checks passed
@github-actions github-actions bot mentioned this pull request Feb 3, 2026
reggi pushed a commit that referenced this pull request Feb 4, 2026
## Add webauth URLs to EOTP error messages

When npm returns an EOTP error with `authUrl` and `doneUrl` in the
response body (web-based OTP flow), these URLs are now included in the
error output.

**What:**
- Display `authUrl` (for browser authentication) and `doneUrl` (for
token retrieval) in non-TTY EOTP error messages
- Include both URLs in `--json` output as `error.authUrl` and
`error.doneUrl`
- Adjusted messaging to differentiate webauth flow from traditional TOTP
authenticator flow

**Why:**
- In non-interactive/CI environments, the webauth URLs were not
surfaced, making it impossible to complete authentication
- Tools wrapping `npm publish` (like
[changesets](changesets/changesets#1773)) need
access to these URLs to implement web OTP support
- The `doneUrl` is required for polling to retrieve the token after
browser authentication completes
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.

2 participants