Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

heroku-cli-util

Package Overview
Dependencies
Maintainers
2
Versions
155
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

heroku-cli-util - npm Package Compare versions

Comparing version 5.7.1 to 5.7.2

84

lib/command.js

@@ -7,2 +7,4 @@ 'use strict';

let url = require('url');
let spawn = require('child_process').spawn;
let exec = require('child_process').exec;

@@ -33,2 +35,5 @@ function apiMiddleware (response, cb) {

}
if (context.reason) {
opts.headers = cli.extend(opts.headers, {'X-Heroku-Sudo-Reason': context.reason});
}
return new Heroku(opts);

@@ -61,2 +66,54 @@ }

function login () {
return new Promise(function (fulfill, error) {
spawn('heroku', ['login'], {stdio: 'inherit'})
.on('close', function (e) {
if (e === 0) fulfill();
else error(new Error('Authorization failed.'));
});
});
}
function getNewAPIKey () {
return new Promise(function (fulfill, reject) {
exec('heroku auth:token', function (error, stdout, stderr) {
if (stderr) console.error(stderr);
if (error) reject(error);
fulfill(stdout.trim());
});
});
}
function relogin () {
if (process.env.HEROKU_API_KEY) {
cli.error(`API key is currently set by the HEROKU_API_KEY environment variable.
Ensure this is set to a correct value or unset it to use the netrc file.`);
process.exit(1);
}
return login().then(getNewAPIKey);
}
function twoFactorPrompt(options, context) {
cli.yubikey.enable();
return cli.prompt('Two-factor code', {mask: true})
.then(function (secondFactor) {
cli.yubikey.disable();
return secondFactor;
})
.then(function (secondFactor) {
if (options.preauth) {
return cli.preauth(context.app, heroku(context), secondFactor);
} else {
context.secondFactor = secondFactor;
}
});
}
function reasonPrompt(context) {
return cli.prompt('Reason')
.then(function (reason) {
context.reason = reason;
});
}
module.exports = function command (options, fn) {

@@ -74,21 +131,16 @@ return function (context) {

.catch(function (err) {
if (err && err.body && err.body.id === 'two_factor') {
cli.yubikey.enable();
cli.prompt('Two-factor code', {mask: true})
.then(function (secondFactor) {
cli.yubikey.disable();
return secondFactor;
})
.then(function (secondFactor) {
if (options.preauth) {
return cli.preauth(context.app, heroku(context), secondFactor);
} else {
context.secondFactor = secondFactor;
}
})
if (err && err.body && err.body.id === 'unauthorized') {
cli.error(err.body.message || 'Unauthorized');
relogin()
.then(apiKey => context.auth = {password: apiKey})
.then(run)
.catch(handleErr);
return;
}
throw err;
else if (err && err.body && err.body.id === 'sudo_reason_required') {
cli.warn(err.body.message);
reasonPrompt(context).then(run).catch(handleErr);
}
else if (err && err.body && err.body.id === 'two_factor') {
twoFactorPrompt(options, context).then(run).catch(handleErr);
} else throw err;
}).catch(handleErr);

@@ -95,0 +147,0 @@ };

2

package.json
{
"name": "heroku-cli-util",
"version": "5.7.1",
"version": "5.7.2",
"description": "Set of helpful CLI utilities",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc