@fonoster/common 0.15.8 → 0.15.9
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.
|
@@ -25,9 +25,16 @@ export type PasswordStrength = "weak" | "fair" | "strong";
|
|
|
25
25
|
*/
|
|
26
26
|
export declare function assessPasswordStrength(password: string): PasswordStrength;
|
|
27
27
|
/**
|
|
28
|
-
* Gets a
|
|
28
|
+
* Gets a numerical score (0-100) for the password strength.
|
|
29
|
+
*
|
|
30
|
+
* @param password - The password to assess
|
|
31
|
+
* @returns A number between 0 and 100 representing password strength
|
|
32
|
+
*/
|
|
33
|
+
export declare function getPasswordStrengthScore(password: string): number;
|
|
34
|
+
/**
|
|
35
|
+
* Gets a color value for displaying password strength in the progress bar.
|
|
29
36
|
*
|
|
30
37
|
* @param strength - The password strength level
|
|
31
|
-
* @returns A
|
|
38
|
+
* @returns A hex color value
|
|
32
39
|
*/
|
|
33
|
-
export declare function
|
|
40
|
+
export declare function getPasswordStrengthColor(strength: PasswordStrength): string;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.assessPasswordStrength = assessPasswordStrength;
|
|
4
|
-
exports.
|
|
4
|
+
exports.getPasswordStrengthScore = getPasswordStrengthScore;
|
|
5
|
+
exports.getPasswordStrengthColor = getPasswordStrengthColor;
|
|
5
6
|
/**
|
|
6
7
|
* Assesses the strength of a password based on various criteria.
|
|
7
8
|
*
|
|
@@ -35,20 +36,49 @@ function assessPasswordStrength(password) {
|
|
|
35
36
|
return "weak";
|
|
36
37
|
}
|
|
37
38
|
/**
|
|
38
|
-
* Gets a
|
|
39
|
+
* Gets a numerical score (0-100) for the password strength.
|
|
39
40
|
*
|
|
40
|
-
* @param
|
|
41
|
-
* @returns A
|
|
41
|
+
* @param password - The password to assess
|
|
42
|
+
* @returns A number between 0 and 100 representing password strength
|
|
42
43
|
*/
|
|
43
|
-
function
|
|
44
|
-
if (
|
|
45
|
-
return
|
|
46
|
-
}
|
|
47
|
-
if (strength === "fair") {
|
|
48
|
-
return "Fair password - consider adding more variety";
|
|
44
|
+
function getPasswordStrengthScore(password) {
|
|
45
|
+
if (!password || password.length < 8) {
|
|
46
|
+
return 0;
|
|
49
47
|
}
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
let score = 0;
|
|
49
|
+
// Length contribution (max 30 points)
|
|
50
|
+
if (password.length >= 16)
|
|
51
|
+
score += 30;
|
|
52
|
+
else if (password.length >= 12)
|
|
53
|
+
score += 25;
|
|
54
|
+
else if (password.length >= 8)
|
|
55
|
+
score += 20;
|
|
56
|
+
// Character variety contribution (max 70 points)
|
|
57
|
+
if (/[a-z]/.test(password))
|
|
58
|
+
score += 15; // lowercase
|
|
59
|
+
if (/[A-Z]/.test(password))
|
|
60
|
+
score += 15; // uppercase
|
|
61
|
+
if (/\d/.test(password))
|
|
62
|
+
score += 15; // numbers
|
|
63
|
+
if (/[^a-zA-Z0-9]/.test(password))
|
|
64
|
+
score += 25; // special characters (weighted higher)
|
|
65
|
+
return Math.min(score, 100);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Gets a color value for displaying password strength in the progress bar.
|
|
69
|
+
*
|
|
70
|
+
* @param strength - The password strength level
|
|
71
|
+
* @returns A hex color value
|
|
72
|
+
*/
|
|
73
|
+
function getPasswordStrengthColor(strength) {
|
|
74
|
+
switch (strength) {
|
|
75
|
+
case "strong":
|
|
76
|
+
return "#10b981"; // green-500
|
|
77
|
+
case "fair":
|
|
78
|
+
return "#f59e0b"; // amber-500
|
|
79
|
+
case "weak":
|
|
80
|
+
return "#ef4444"; // red-500
|
|
81
|
+
default:
|
|
82
|
+
return "#6b7280"; // gray-500
|
|
52
83
|
}
|
|
53
|
-
return "Please enter your new password";
|
|
54
84
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fonoster/common",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.9",
|
|
4
4
|
"description": "Common library for Fonoster projects",
|
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
6
6
|
"homepage": "https://github.com/fonoster/fonoster#readme",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"clean": "rimraf ./dist node_modules tsconfig.tsbuildinfo"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@fonoster/logger": "^0.15.
|
|
21
|
+
"@fonoster/logger": "^0.15.9",
|
|
22
22
|
"@grpc/grpc-js": "~1.10.6",
|
|
23
23
|
"@grpc/proto-loader": "^0.7.12",
|
|
24
24
|
"@influxdata/influxdb-client": "^1.35.0",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@types/nodemailer": "^6.4.14"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "38ed0c085c1b0daa73c2b73889bb08234c7a8343"
|
|
53
53
|
}
|