Skip to content

Commit

Permalink
Add 2FA support for npm version 9+ (#693)
Browse files Browse the repository at this point in the history
  • Loading branch information
DerTimonius committed Apr 14, 2023
1 parent eba203f commit 9cb4bfd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions source/npm/enable-2fa.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import {execa} from 'execa';
import {from, catchError} from 'rxjs';
import semver from 'semver';
import handleNpmError from './handle-npm-error.js';
import {version as npmVersionCheck} from './util.js';

export const getEnable2faArgs = (packageName, options) => {
const args = ['access', '2fa-required', packageName];
export const getEnable2faArgs = async (packageName, options) => {
const npmVersion = await npmVersionCheck();
const args = semver.satisfies(npmVersion, '>=9.0.0') ? ['access', 'set', 'mfa=publish', packageName] : ['access', '2fa-required', packageName];

if (options && options.otp) {
args.push('--otp', options.otp);
Expand Down

0 comments on commit 9cb4bfd

Please sign in to comment.