-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathPasswordConstants.ts
61 lines (56 loc) · 1.92 KB
/
PasswordConstants.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
export type TScore = 0 | 1 | 2 | 3 | 4;
export type passwordKeys =
| "common"
| "commonNames"
| "dates"
| "extendedRepeat"
| "keyPattern"
| "namesByThemselves"
| "pwned"
| "recentYears"
| "sequences"
| "similarToCommon"
| "simpleRepeat"
| "straightRow"
| "topHundred"
| "topTen"
| "userInputs"
| "wordByItself";
export const passwordRegex = {
hasLowerCase: /[a-z]/,
hasNumber: /\d/,
hasSymbol: /\W/,
hasUpperCase: /[A-Z]/,
isLengthValid: /^.{8,25}$/,
isPasswordValid: /^(?=.*[a-z])(?=.*\d)(?=.*[A-Z])[!-~]{8,25}$/,
};
export const passwordValues = {
longPassword: 12,
maxLength: 25,
minLength: 8,
};
export const passwordErrorMessage = {
invalidLength: "You should enter 8-25 characters.",
missingCharacter:
"Password should have lower and uppercase English letters with numbers.",
PasswordError: "That password is incorrect. Please try again.",
};
export const warningMessages: Record<passwordKeys, string> = {
common: "This is a very common password.",
commonNames: "Common names and surnames are easy to guess.",
dates: "Dates are easy to guess.",
extendedRepeat:
'Repeated character patterns like "abcabcabc" are easy to guess.',
keyPattern: "Short keyboard patterns are easy to guess.",
namesByThemselves: "Single names or surnames are easy to guess.",
pwned: "Your password was exposed by a data breach on the Internet.",
recentYears: "Recent years are easy to guess.",
sequences: 'Common character sequences like "abc" are easy to guess.',
similarToCommon: "This is similar to a commonly used password.",
simpleRepeat: 'Repeated characters like "aaa" are easy to guess.',
straightRow: "Straight rows of keys on your keyboard are easy to guess.",
topHundred: "This is a frequently used password.",
topTen: "This is a heavily used password.",
userInputs: "There should not be any personal or page related data.",
wordByItself: "Single words are easy to guess.",
};