Gathering detailed insights and metrics for minimal-password-prompt
Gathering detailed insights and metrics for minimal-password-prompt
Gathering detailed insights and metrics for minimal-password-prompt
Gathering detailed insights and metrics for minimal-password-prompt
npm install minimal-password-prompt
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
3 Stars
39 Commits
2 Watching
1 Branches
1 Contributors
Updated on 15 Sept 2021
Minified
Minified + Gzipped
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-55.6%
24
Compared to previous day
Last week
6%
123
Compared to previous week
Last month
144.7%
394
Compared to previous month
Last year
13.7%
2,924
Compared to previous year
Minimal hidden password prompt for Node.js! [npm] [github]
package | dependencies | dependents | total lines of production code |
---|---|---|---|
minimal-password-prompt | 0 | 0 | 48 |
password-prompt | 2 | 43 | 2147 |
Seriously, you can also just copy and paste to your project:
1const stdin = process.stdin; 2const stdout = process.stdout; 3 4const captureStdin = (onData) => { 5 stdin.setEncoding('utf-8'); 6 stdin.setRawMode(true); 7 stdin.on('data', onData); 8 stdin.resume(); 9}; 10 11const releaseStdin = (onData) => { 12 stdin.pause(); 13 stdin.removeListener('data', onData); 14 stdin.setRawMode(false); 15 stdout.write('\n'); 16}; 17 18const prompt = (question, ctrlcExits = true) => ( 19 new Promise((resolve, reject) => { 20 let input = ''; 21 const onData = (data) => { 22 switch (data) { 23 case '\u000A': // \n 24 case '\u000D': // \r 25 case '\u0004': // Ctrl+D 26 releaseStdin(onData); 27 resolve(input); 28 break; 29 case '\u0003': // Ctrl+C 30 releaseStdin(onData); 31 ctrlcExits // exit or raise error 32 ? process.exit() 33 : reject(new Error('Ctrl+C')); 34 break; 35 case '\u0008': // Backspace 36 case '\u007F': // Delete 37 input = input.slice(0, -1); 38 break; 39 default: // any other 40 input += data; 41 }; 42 }; 43 captureStdin(onData); 44 stdout.write(question); 45 }) 46); 47 48module.exports = prompt;
(please sill do remember to include MIT license/copyright)
1const prompt = require('minimal-password-prompt'); 2 3prompt('enter password: ').then(pw => { 4 console.log(`Password: ${pw}`); 5});
or with async/await:
1const prompt = require('minimal-password-prompt'); 2 3(async () => { 4 const pw = await prompt('enter password: '); 5 console.log(`password: ${pw}`); 6})();
More examples here
Parameters:
question (String)
prompt output before user inputctrlcExits (Boolean)
, optional
Returns:
Promise<String>
user input during promptInstall with npm:
npm install --save minimal-password-prompt
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
10 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More