Skip to content

docs: lead with npm's browser 2FA flow; support NPM_CONFIG_OTP - #12

Merged
theoephraim merged 1 commit into
mainfrom
docs/npm-2fa-webauthn
Jul 30, 2026
Merged

docs: lead with npm's browser 2FA flow; support NPM_CONFIG_OTP#12
theoephraim merged 1 commit into
mainfrom
docs/npm-2fa-webauthn

Conversation

@theoephraim

Copy link
Copy Markdown
Member

npm is moving away from authenticator codes toward WebAuthn (passkeys and security keys), so the browser approval flow is what most people will actually hit — not a code passed on the command line. The docs were written the other way around.

Docs

  • The 2FA section now leads with the browser flow: npm kicks you out to the web, you approve with whatever your account uses (passkey, security key, or a code), and the approval is cached ~5 min so one covers the run. fledgling passes nothing.
  • --otp / NPM_CONFIG_OTP / --otp-secret moved into a collapsed legacy block, with a note that WebAuthn can't be automated headlessly at all — so if your account has moved off codes, those flags don't apply.
  • Both flags marked (legacy) in the run-options table.

Code

  • NPM_CONFIG_OTP is read as a fallback for --otp in both settings-construction paths (core.ts, interactive.ts).

npm honors NPM_CONFIG_OTP on its own since we shell out without overriding env, so this isn't what makes it work — but reading it explicitly keeps fledgling's "does this run need interactive 2FA?" check in sync. Previously, setting the env var still printed the browser-approval reminder and ran the auth warm-up.

No deprecation date or npm version is stated in the docs, since I don't have that confirmed — worth adding later if we do.

npm is moving away from authenticator codes toward WebAuthn (passkeys and
security keys), so the browser approval flow is what most people will hit.
Restructure the 2FA docs around it and demote --otp / --otp-secret to a
collapsed legacy fallback.

Also read NPM_CONFIG_OTP as a fallback for --otp. npm honors it on its own
anyway, but reading it here keeps our "does this run need interactive 2FA?"
checks in sync, so it no longer prints the browser-approval reminder or warms
npm's auth cache when a code was already supplied via the env var.
@github-actions

Copy link
Copy Markdown

bumpy-frog

The changes in this PR will be included in the next version bump.

patch Patch releases

  • fledgling 1.2.1 → 1.2.2

Bump files in this PR

Click here if you want to add another bump file to this PR


This comment is maintained by bumpy.

@theoephraim
theoephraim merged commit 844b019 into main Jul 30, 2026
1 check passed
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