Sunday, 2 April 2017

Node JS prompt library doesn't hide password

I'm using the prompt library for Node.js and I have this code:

// Entry point for the program
var prompt =require ('prompt' )
var Basic = require('./helper/basic')
var program = require('./helper/cli-args')

var pwd = new Basic()

var promptSchema = {
  properties: {
    sprintID: {
      description: "Enter sprint ID",
      type: 'integer'
    },
    password: {
      description: "Enter the password for " + program.user,
      hidden: true
    }
  }
}
prompt.start()
prompt.get(promptSchema, function (err,result) {
  if (err) console.log(err)
  program.sprint = result.sprintID
  pwd.setDigest(result.password)
  prompt.stop()
  console.log ("Sprint ID: ", program.sprint)
  console.log("Basic: ", pwd.digest);
})

The Basic class is very simple :

// Basic authentication
var base64 = require('base-64')
var program = require ('../helper/cli-args')

class Basic {
  setDigest(pwd) {
    this.digest = base64.encode(program.user.concat(":").concat(pwd))
  }
}
module.exports = Basic

The problem I have is that the promp doesn't hide the password. Here is an output:

$ npm start

jira@1.0.0 start D:\Documents\Programmation\NodeJS\jira node index.js

prompt: Enter sprint ID: 156 prompt: Enter the password for sikkache: Not the real Password Sprint ID: 156 Basic: c2lra2FjaGU6Tm90IHRoZSByZWFsIFBhc3N3b3Jk

As you can see, the password is clear.

Can anyone help me, I really need the password to be hidden.



via Sélim Ikkache

No comments:

Post a Comment