cf-keys 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Commands/password.js +23 -7
- package/package.json +1 -1
|
@@ -24,26 +24,42 @@ const generateSecurePassword = (length = 16, includeNumbers = true, includeSymbo
|
|
|
24
24
|
return password;
|
|
25
25
|
};
|
|
26
26
|
exports.generateSecurePassword = generateSecurePassword;
|
|
27
|
+
/**
|
|
28
|
+
* CLI Command definition for password generation.
|
|
29
|
+
* Supports: cf-keys password [length] OR cf-keys password -l [length]
|
|
30
|
+
*/
|
|
27
31
|
exports.passwordCmd = new commander_1.Command("password")
|
|
28
32
|
.description("Generates a cryptographically secure password")
|
|
29
|
-
.
|
|
33
|
+
.argument("[length]", "Password length (default: 16)")
|
|
34
|
+
.option("-l, --length <number>", "Password length (alternative option)")
|
|
30
35
|
.option("--no-symbols", "Exclude special characters")
|
|
31
36
|
.option("--no-numbers", "Exclude numbers")
|
|
32
|
-
.action((options) => {
|
|
37
|
+
.action((argLength, options) => {
|
|
33
38
|
try {
|
|
34
|
-
const
|
|
35
|
-
const
|
|
39
|
+
const rawLength = argLength || options.length || "16";
|
|
40
|
+
const length = parseInt(rawLength, 10);
|
|
41
|
+
if (isNaN(length) || length <= 0) {
|
|
42
|
+
throw new Error("Invalid length. Please provide a positive number.");
|
|
43
|
+
}
|
|
44
|
+
const useNumbers = options.numbers !== false;
|
|
45
|
+
const useSymbols = options.symbols !== false;
|
|
46
|
+
const password = (0, exports.generateSecurePassword)(length, useNumbers, useSymbols);
|
|
36
47
|
console.info(JSON.stringify({
|
|
48
|
+
status: "success",
|
|
37
49
|
type: "password",
|
|
38
50
|
value: password,
|
|
39
51
|
length: length,
|
|
40
52
|
config: {
|
|
41
|
-
symbols:
|
|
42
|
-
numbers:
|
|
53
|
+
symbols: useSymbols,
|
|
54
|
+
numbers: useNumbers,
|
|
43
55
|
},
|
|
44
56
|
}, null, 2));
|
|
45
57
|
}
|
|
46
58
|
catch (error) {
|
|
47
|
-
console.error(JSON.stringify({
|
|
59
|
+
console.error(JSON.stringify({
|
|
60
|
+
status: "error",
|
|
61
|
+
message: "Failed to generate password",
|
|
62
|
+
details: error.message,
|
|
63
|
+
}, null, 2));
|
|
48
64
|
}
|
|
49
65
|
});
|