UNPKG

lerna

Version:

Lerna is a fast, modern build system for managing and publishing multiple JavaScript/TypeScript packages from the same repository

44 lines (41 loc) 1.18 kB
import { getProfileData } from "./chunk-UXQPUJ7V.js"; import { getFetchConfig } from "./chunk-MDMOE4VM.js"; import { ValidationError } from "./chunk-WC2B4V4E.js"; // libs/commands/publish/src/lib/get-two-factor-auth-required.ts function getTwoFactorAuthRequired(options = {}) { const opts = getFetchConfig(options, { // don't wait forever for third-party failures to be dealt with fetchRetries: 0 }); opts.log.info("", "Checking two-factor auth mode"); return getProfileData(opts).then(success, failure); function success(result) { opts.log.silly("2FA", result.tfa); if (result.tfa.pending) { return false; } return result.tfa.mode === "auth-and-writes"; } function failure(err) { if (err.code === "E500" || err.code === "E404") { opts.log.warn( "EREGISTRY", `Registry "${opts.registry}" does not support 'npm profile get', skipping two-factor auth check...` ); return false; } opts.log.pause(); console.error(err.message); opts.log.resume(); throw new ValidationError("ETWOFACTOR", "Unable to obtain two-factor auth mode"); } } export { getTwoFactorAuthRequired };