Support NPM OTP token

Open
#1,135 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
typescript
Domain
cli, release

Research direction

Start with bin/publib-npm around the npm publish invocation referenced in the issue, then inspect the surrounding publishing flow and existing tests. Compare the proposed environment-variable and interactive approaches against the npm OTP behavior. Done means publishing with a 2FA-enabled npm account can receive an OTP through a documented, tested path.

Written by the indexing model from the issue text.

Description

feature-request
Problem

NPM package can't be published with publib when 2FA is configured in the target NPM account.

Details

npm publish command used in publib-npm (source) requires an --opt flag when 2FA is configured. There's no equivalent env variable according to NPM docs.

Workaround

I was able to publish an NPM package by editing publib sources in node_modules. I added the --otp flag in node_modules/.bin/publib-npm:

  npm publish ${tag} ${access} ${file} --otp <my_temp_code> 2>&1 | tee ${log}
Suggested Solution

An NPM_OTP_TOKEN env variable could be supported by publib and used as the --otp flag value in the npm publish command. This won't be the optimal solution, though, as the OTP token is short-lived and will have to be updated right before running the publib command. A better solution would be to somehow allow npm publish to run in interactive mode and prompt the user for the OTP token. (see NPM OTP option docs).

Dominant language
TypeScript
Stars
61
Forks
25
Avg merge
3m
Merged PRs (30d)
17

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from cdklabs/publib

All issues in cdklabs/publib

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.