You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

@inquirer/password

Package Overview
Dependencies
Maintainers
2
Versions
115
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@inquirer/password - npm Package Compare versions

Comparing version
5.0.8
to
5.0.9
+3
-4
package.json
{
"name": "@inquirer/password",
"version": "5.0.8",
"version": "5.0.9",
"description": "Inquirer password prompt",

@@ -71,7 +71,6 @@ "keywords": [

"@inquirer/ansi": "^2.0.3",
"@inquirer/core": "^11.1.5",
"@inquirer/core": "^11.1.6",
"@inquirer/type": "^4.0.3"
},
"devDependencies": {
"@inquirer/testing": "^3.3.0",
"typescript": "^5.9.3"

@@ -92,3 +91,3 @@ },

"types": "./dist/index.d.ts",
"gitHead": "526eca2e64853510821ffd457561840ec0cbfb93"
"gitHead": "1ce03199b82b4a5fb6f7c97ce374c6da5087444f"
}
import { type Theme } from '@inquirer/core';
import type { PartialDeep } from '@inquirer/type';
type PasswordTheme = {
style: {
maskedText: string;
};
};
type PasswordConfig = {
message: string;
mask?: boolean | string;
validate?: (value: string) => boolean | string | Promise<string | boolean>;
theme?: PartialDeep<Theme<PasswordTheme>>;
};
declare const _default: import("@inquirer/type").Prompt<string, PasswordConfig>;
export default _default;
import { createPrompt, useState, useKeypress, usePrefix, isEnterKey, makeTheme, } from '@inquirer/core';
import { cursorHide } from '@inquirer/ansi';
const passwordTheme = {
style: {
maskedText: '[input is masked]',
},
};
export default createPrompt((config, done) => {
const { validate = () => true } = config;
const theme = makeTheme(passwordTheme, config.theme);
const [status, setStatus] = useState('idle');
const [errorMsg, setError] = useState();
const [value, setValue] = useState('');
const prefix = usePrefix({ status, theme });
useKeypress(async (key, rl) => {
// Ignore keypress while our prompt is doing other processing.
if (status !== 'idle') {
return;
}
if (isEnterKey(key)) {
const answer = value;
setStatus('loading');
const isValid = await validate(answer);
if (isValid === true) {
setValue(answer);
setStatus('done');
done(answer);
}
else {
// Reset the readline line value to the previous value. On line event, the value
// get cleared, forcing the user to re-enter the value instead of fixing it.
rl.write(value);
setError(isValid || 'You must provide a valid value');
setStatus('idle');
}
}
else {
setValue(rl.line);
setError(undefined);
}
});
const message = theme.style.message(config.message, status);
let formattedValue = '';
let helpTip;
if (config.mask) {
const maskChar = typeof config.mask === 'string' ? config.mask : '*';
formattedValue = maskChar.repeat(value.length);
}
else if (status !== 'done') {
helpTip = `${theme.style.help(theme.style.maskedText)}${cursorHide}`;
}
if (status === 'done') {
formattedValue = theme.style.answer(formattedValue);
}
let error = '';
if (errorMsg) {
error = theme.style.error(errorMsg);
}
return [[prefix, message, config.mask ? formattedValue : helpTip].join(' '), error];
});