@andrewthecoder/secure-password-generator 0.1.2 → 0.2.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/README.md +0 -0
- package/andrewthecoder-secure-password-generator-0.1.0.tgz +0 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +48 -0
- package/dist/index.d.ts +0 -0
- package/dist/index.js +0 -0
- package/jest.config.js +0 -0
- package/package.json +4 -1
- package/src/__tests__/index.test.ts +0 -0
- package/src/cli.ts +52 -0
- package/src/index.ts +0 -0
- package/tsconfig.json +0 -0
package/README.md
CHANGED
|
File without changes
|
|
File without changes
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { generate, PasswordGenerationError } from './index.js';
|
|
3
|
+
const args = process.argv.slice(2);
|
|
4
|
+
// Default values
|
|
5
|
+
let minLength = 16;
|
|
6
|
+
let maxLength = 24;
|
|
7
|
+
// Parse arguments
|
|
8
|
+
if (args.includes('--help') || args.includes('-h')) {
|
|
9
|
+
console.log(`Usage: secure-password-generator [minLength] [maxLength]
|
|
10
|
+
|
|
11
|
+
Generate a cryptographically secure random password.
|
|
12
|
+
|
|
13
|
+
Arguments:
|
|
14
|
+
minLength Minimum password length (default: 16)
|
|
15
|
+
maxLength Maximum password length (default: 24)
|
|
16
|
+
|
|
17
|
+
Options:
|
|
18
|
+
-h, --help Show this help message
|
|
19
|
+
|
|
20
|
+
Examples:
|
|
21
|
+
npx @andrewthecoder/secure-password-generator
|
|
22
|
+
npx @andrewthecoder/secure-password-generator 12 20
|
|
23
|
+
npx @andrewthecoder/secure-password-generator 32 32`);
|
|
24
|
+
process.exit(0);
|
|
25
|
+
}
|
|
26
|
+
if (args.length >= 1) {
|
|
27
|
+
minLength = parseInt(args[0], 10);
|
|
28
|
+
}
|
|
29
|
+
if (args.length >= 2) {
|
|
30
|
+
maxLength = parseInt(args[1], 10);
|
|
31
|
+
}
|
|
32
|
+
if (isNaN(minLength) || isNaN(maxLength)) {
|
|
33
|
+
console.error('Error: Arguments must be valid numbers');
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
const password = generate(minLength, maxLength);
|
|
38
|
+
console.log(password);
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
if (error instanceof PasswordGenerationError) {
|
|
42
|
+
console.error(`Error: ${error.message}`);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
console.error('An unexpected error occurred');
|
|
46
|
+
}
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
package/dist/index.d.ts
CHANGED
|
File without changes
|
package/dist/index.js
CHANGED
|
File without changes
|
package/jest.config.js
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@andrewthecoder/secure-password-generator",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "A secure password generator written in TypeScript",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
"main": "dist/index.js",
|
|
9
9
|
"types": "dist/index.d.ts",
|
|
10
10
|
"type": "module",
|
|
11
|
+
"bin": {
|
|
12
|
+
"secure-password-generator": "dist/cli.js"
|
|
13
|
+
},
|
|
11
14
|
"scripts": {
|
|
12
15
|
"build": "tsc",
|
|
13
16
|
"test": "jest",
|
|
File without changes
|
package/src/cli.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { generate, PasswordGenerationError } from './index.js';
|
|
3
|
+
|
|
4
|
+
const args = process.argv.slice(2);
|
|
5
|
+
|
|
6
|
+
// Default values
|
|
7
|
+
let minLength = 16;
|
|
8
|
+
let maxLength = 24;
|
|
9
|
+
|
|
10
|
+
// Parse arguments
|
|
11
|
+
if (args.includes('--help') || args.includes('-h')) {
|
|
12
|
+
console.log(`Usage: secure-password-generator [minLength] [maxLength]
|
|
13
|
+
|
|
14
|
+
Generate a cryptographically secure random password.
|
|
15
|
+
|
|
16
|
+
Arguments:
|
|
17
|
+
minLength Minimum password length (default: 16)
|
|
18
|
+
maxLength Maximum password length (default: 24)
|
|
19
|
+
|
|
20
|
+
Options:
|
|
21
|
+
-h, --help Show this help message
|
|
22
|
+
|
|
23
|
+
Examples:
|
|
24
|
+
npx @andrewthecoder/secure-password-generator
|
|
25
|
+
npx @andrewthecoder/secure-password-generator 12 20
|
|
26
|
+
npx @andrewthecoder/secure-password-generator 32 32`);
|
|
27
|
+
process.exit(0);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (args.length >= 1) {
|
|
31
|
+
minLength = parseInt(args[0], 10);
|
|
32
|
+
}
|
|
33
|
+
if (args.length >= 2) {
|
|
34
|
+
maxLength = parseInt(args[1], 10);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (isNaN(minLength) || isNaN(maxLength)) {
|
|
38
|
+
console.error('Error: Arguments must be valid numbers');
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
try {
|
|
43
|
+
const password = generate(minLength, maxLength);
|
|
44
|
+
console.log(password);
|
|
45
|
+
} catch (error) {
|
|
46
|
+
if (error instanceof PasswordGenerationError) {
|
|
47
|
+
console.error(`Error: ${error.message}`);
|
|
48
|
+
} else {
|
|
49
|
+
console.error('An unexpected error occurred');
|
|
50
|
+
}
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
package/src/index.ts
CHANGED
|
File without changes
|
package/tsconfig.json
CHANGED
|
File without changes
|