dthree / vorpal

Node's framework for interactive CLIs
http://vorpal.js.org
MIT License
5.64k stars 280 forks source link

Input type 'password' shows characters while typing #67

Closed berndb closed 8 years ago

berndb commented 8 years ago

Until the return key is pressed, all password characters are shown as plain text:

password: my-secret-password

After the return key was pressed, the characters are replaced with * symbols:

password: ******************

As a sensitive user, I would like my password to be already hidden while typing. * symbols should be shown from the very beginning.

Is there an option to achieve this?


Example code:

var vorpal = require('vorpal')();

vorpal
    .command('connect')
    .action(function (params, cb) {
        this.prompt([{
            type: 'password',
            name: 'password',
            message: 'password: '
        }], cb);
    });

vorpal.show();
vorpal.exec('connect');
dthree commented 8 years ago

Vorpal uses Inquirer.js inputs, so this would be a bug with Inquirer.js itself, I believe. Please file it there.

berndb commented 8 years ago

Inquirer does it just fine and shows *s during typing.

From what I can see in the code, you intercept inquirer's key press events and then you output the characters directly to the screen. This is probably why the *s don't show up.


Example with Inquirer@0.11.0:

var inquirer = require('inquirer');

inquirer.prompt([{
    type: 'password',
    name: 'password',
    message: 'password: '
}], function () {
    console.log(arguments);
});
password: ******************
dthree commented 8 years ago

Oh got it.

patrickdevivo commented 8 years ago

+1 on a fix for this please. Any ideas?

scotthovestadt commented 8 years ago

Fixed. See: https://github.com/dthree/vorpal/pull/85

dthree commented 8 years ago

:+1: