@fonoster/common 0.15.9 → 0.15.10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fonoster/common",
3
- "version": "0.15.9",
3
+ "version": "0.15.10",
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.9",
21
+ "@fonoster/logger": "^0.15.10",
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": "38ed0c085c1b0daa73c2b73889bb08234c7a8343"
52
+ "gitHead": "530cdc7b78d5e4a9acc39382173676c40c456257"
53
53
  }
@@ -1,40 +0,0 @@
1
- /**
2
- * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
3
- * http://github.com/fonoster/fonoster
4
- *
5
- * This file is part of Fonoster
6
- *
7
- * Licensed under the MIT License (the "License");
8
- * you may not use this file except in compliance with
9
- * the License. You may obtain a copy of the License at
10
- *
11
- * https://opensource.org/licenses/MIT
12
- *
13
- * Unless required by applicable law or agreed to in writing, software
14
- * distributed under the License is distributed on an "AS IS" BASIS,
15
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- * See the License for the specific language governing permissions and
17
- * limitations under the License.
18
- */
19
- export type PasswordStrength = "weak" | "fair" | "strong";
20
- /**
21
- * Assesses the strength of a password based on various criteria.
22
- *
23
- * @param password - The password to assess
24
- * @returns PasswordStrength - 'weak', 'fair', or 'strong'
25
- */
26
- export declare function assessPasswordStrength(password: string): PasswordStrength;
27
- /**
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.
36
- *
37
- * @param strength - The password strength level
38
- * @returns A hex color value
39
- */
40
- export declare function getPasswordStrengthColor(strength: PasswordStrength): string;
@@ -1,84 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.assessPasswordStrength = assessPasswordStrength;
4
- exports.getPasswordStrengthScore = getPasswordStrengthScore;
5
- exports.getPasswordStrengthColor = getPasswordStrengthColor;
6
- /**
7
- * Assesses the strength of a password based on various criteria.
8
- *
9
- * @param password - The password to assess
10
- * @returns PasswordStrength - 'weak', 'fair', or 'strong'
11
- */
12
- function assessPasswordStrength(password) {
13
- if (!password || password.length < 8) {
14
- return "weak";
15
- }
16
- let score = 0;
17
- // Length contribution
18
- if (password.length >= 12)
19
- score += 2;
20
- else if (password.length >= 8)
21
- score += 1;
22
- // Character variety contribution
23
- if (/[a-z]/.test(password))
24
- score += 1; // lowercase
25
- if (/[A-Z]/.test(password))
26
- score += 1; // uppercase
27
- if (/\d/.test(password))
28
- score += 1; // numbers
29
- if (/[^a-zA-Z0-9]/.test(password))
30
- score += 1; // special characters
31
- // Determine strength based on score
32
- if (score >= 5)
33
- return "strong";
34
- if (score >= 3)
35
- return "fair";
36
- return "weak";
37
- }
38
- /**
39
- * Gets a numerical score (0-100) for the password strength.
40
- *
41
- * @param password - The password to assess
42
- * @returns A number between 0 and 100 representing password strength
43
- */
44
- function getPasswordStrengthScore(password) {
45
- if (!password || password.length < 8) {
46
- return 0;
47
- }
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
83
- }
84
- }