Skip to content

Commit fd295e0

Browse files
authored
Merge pull request #1511 from giomiglietta/feat-increase-maximum-password-length-256
feat: increased max password length to 256
2 parents d141b6e + d0eed6a commit fd295e0

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

ts/session/constants.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export const PASSWORD_LENGTH = {
124124
*/
125125
MIN_PASSWORD_LEN: 6,
126126
/**
127-
* 64 chars
127+
* 256 chars
128128
*/
129-
MAX_PASSWORD_LEN: 64,
129+
MAX_PASSWORD_LEN: 256,
130130
};

ts/test/session/unit/utils/Password_test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ describe('Password Util', () => {
5858
});
5959
});
6060

61-
it('should return an error if password is not between 6 and 64 characters', () => {
62-
const invalid = ['a', 'abcde', '#'.repeat(65), '#'.repeat(100)];
61+
it('should return an error if password is not between 6 and 256 characters', () => {
62+
const invalid = ['a', 'abcde', '#'.repeat(257), '#'.repeat(300)];
6363
invalid.forEach(pass => {
6464
assert.strictEqual(
6565
PasswordUtil.validatePassword(pass),
66-
'Password must be between 6 and 64 characters long'
66+
'Password must be between 6 and 256 characters long'
6767
);
6868
});
6969
});

ts/util/passwordUtils.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,25 @@ export const generateHash = (phrase: string) => phrase && sha512(phrase);
1313
export const matchesHash = (phrase: string | null, hash: string) =>
1414
phrase && sha512(phrase) === hash;
1515

16+
const passwordArgs = {
17+
min: PASSWORD_LENGTH.MIN_PASSWORD_LEN.toString(),
18+
max: PASSWORD_LENGTH.MAX_PASSWORD_LEN.toString(),
19+
};
20+
1621
export const validatePassword = (phrase: string) => {
1722
if (!isString(phrase)) {
1823
return tr('passwordError');
1924
}
2025

2126
if (phrase.length === 0) {
22-
return tr('passwordErrorLength');
27+
return tr('passwordErrorLength', passwordArgs);
2328
}
2429

2530
if (
2631
phrase.length < PASSWORD_LENGTH.MIN_PASSWORD_LEN ||
2732
phrase.length > PASSWORD_LENGTH.MAX_PASSWORD_LEN
2833
) {
29-
return tr('passwordErrorLength');
34+
return tr('passwordErrorLength', passwordArgs);
3035
}
3136

3237
// Restrict characters to letters, numbers and symbols

0 commit comments

Comments
 (0)