@fonoster/common 0.15.5 → 0.15.8

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.
@@ -35,7 +35,7 @@ service Applications {
35
35
  rpc UpdateApplication(UpdateApplicationRequest) returns (UpdateApplicationResponse) {}
36
36
  // Delete an application
37
37
  rpc DeleteApplication(DeleteApplicationRequest) returns (DeleteApplicationResponse) {}
38
- // Evaluate the intellgence for an Autopilot application
38
+ // Evaluate the intelligence for an Autopilot application
39
39
  rpc EvaluateIntelligence(EvaluateIntelligenceRequest) returns (EvaluateIntelligenceResponse);
40
40
  // Create an Ephemeral Agent to perform test calls to an application
41
41
  rpc CreateTestToken(google.protobuf.Empty) returns (TestTokenResponse) {}
@@ -0,0 +1,33 @@
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 user-friendly message describing the password strength.
29
+ *
30
+ * @param strength - The password strength level
31
+ * @returns A human-readable message about the password strength
32
+ */
33
+ export declare function getPasswordStrengthMessage(strength: PasswordStrength): string;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.assessPasswordStrength = assessPasswordStrength;
4
+ exports.getPasswordStrengthMessage = getPasswordStrengthMessage;
5
+ /**
6
+ * Assesses the strength of a password based on various criteria.
7
+ *
8
+ * @param password - The password to assess
9
+ * @returns PasswordStrength - 'weak', 'fair', or 'strong'
10
+ */
11
+ function assessPasswordStrength(password) {
12
+ if (!password || password.length < 8) {
13
+ return "weak";
14
+ }
15
+ let score = 0;
16
+ // Length contribution
17
+ if (password.length >= 12)
18
+ score += 2;
19
+ else if (password.length >= 8)
20
+ score += 1;
21
+ // Character variety contribution
22
+ if (/[a-z]/.test(password))
23
+ score += 1; // lowercase
24
+ if (/[A-Z]/.test(password))
25
+ score += 1; // uppercase
26
+ if (/\d/.test(password))
27
+ score += 1; // numbers
28
+ if (/[^a-zA-Z0-9]/.test(password))
29
+ score += 1; // special characters
30
+ // Determine strength based on score
31
+ if (score >= 5)
32
+ return "strong";
33
+ if (score >= 3)
34
+ return "fair";
35
+ return "weak";
36
+ }
37
+ /**
38
+ * Gets a user-friendly message describing the password strength.
39
+ *
40
+ * @param strength - The password strength level
41
+ * @returns A human-readable message about the password strength
42
+ */
43
+ function getPasswordStrengthMessage(strength) {
44
+ if (strength === "strong") {
45
+ return "Ahoy! Your password is strong!";
46
+ }
47
+ if (strength === "fair") {
48
+ return "Fair password - consider adding more variety";
49
+ }
50
+ if (strength === "weak") {
51
+ return "Weak password - try a longer password with more variety";
52
+ }
53
+ return "Please enter your new password";
54
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fonoster/common",
3
- "version": "0.15.5",
3
+ "version": "0.15.8",
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",
@@ -49,5 +49,5 @@
49
49
  "devDependencies": {
50
50
  "@types/nodemailer": "^6.4.14"
51
51
  },
52
- "gitHead": "624a7946ab7a3b6c034fca216a4f901cc95259dd"
52
+ "gitHead": "495f3f9135aae42d8d0867fac272f95df63d155b"
53
53
  }