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.
@@ -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
- .option("-l, --length <numero>", "Password length", "16")
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 length = parseInt(options.length, 10);
35
- const password = (0, exports.generateSecurePassword)(length, options.numbers, options.symbols);
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: options.symbols,
42
- numbers: options.numbers,
53
+ symbols: useSymbols,
54
+ numbers: useNumbers,
43
55
  },
44
56
  }, null, 2));
45
57
  }
46
58
  catch (error) {
47
- console.error(JSON.stringify({ status: "error", details: error.message }, null, 2));
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
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cf-keys",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Suite global de generación de claves y credenciales",
5
5
  "main": "dist/lib.js",
6
6
  "types": "dist/lib.d.ts",