Skip to content

Commit

Permalink
[DDW-502] Spending password should not be longer than 255 characters (#…
Browse files Browse the repository at this point in the history
…2287)

* [DDW-502]: Add password max length validation

* [DDW-502]: Update changelog

* [DDW-502] Merges develop

* [DDW-502]: Use password length min and max constant variables

* [DDW-502]: Bump up polymorph package dependency

* [DDW-502]: Fix yarn.lock

* [DDW-502] Fix yarn.lock

* [DDW-502]: Bump up polymorph package dependency

* [DDW-502]: Update yarn.lock

* [DDW-502]: Fix yarn.lock

* [DDW-502]: Fix yarn.lock

* [DDW-502] Fix yarn.lock

* [DDW-502] Fix yarn.lock

Co-authored-by: Nikola Glumac <niglumac@gmail.com>
  • Loading branch information
Yakov Karavelov and nikolaglumac committed Jan 11, 2021
1 parent 68ff0e0 commit ee9bbe9
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 45 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -10,6 +10,7 @@ Changelog

### Chores

- Applied validation to spending password to be not longer than 255 characters ([PR 2287](https://github.com/input-output-hk/daedalus/pull/2287))
- Update `axios` package ([PR 2291](https://github.com/input-output-hk/daedalus/pull/2291))

## 3.1.0
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -228,7 +228,7 @@
"react-intl": "2.7.2",
"react-lottie": "1.2.3",
"react-markdown": "4.3.1",
"react-polymorph": "0.9.7-rc.10",
"react-polymorph": "0.9.7-rc.11",
"react-router": "5.2.0",
"react-router-dom": "5.2.0",
"react-svg-inline": "2.1.1",
Expand Down
2 changes: 1 addition & 1 deletion source/renderer/app/i18n/global-messages.js
Expand Up @@ -71,7 +71,7 @@ export default defineMessages({
passwordInstructions: {
id: 'global.passwordInstructions',
defaultMessage:
'!!!Note that password needs to be at least 10 characters long.',
'!!!Note that password needs to be at least 10 characters and at most 255 characters long.',
description: 'Password instructions note.',
},
cancel: {
Expand Down
2 changes: 1 addition & 1 deletion source/renderer/app/i18n/locales/defaultMessages.json
Expand Up @@ -14144,7 +14144,7 @@
}
},
{
"defaultMessage": "!!!Note that password needs to be at least 10 characters long.",
"defaultMessage": "!!!Note that password needs to be at least 10 characters and at most 255 characters long.",
"description": "Password instructions note.",
"end": {
"column": 3,
Expand Down
2 changes: 1 addition & 1 deletion source/renderer/app/i18n/locales/en-US.json
Expand Up @@ -155,7 +155,7 @@
"global.language.german": "German",
"global.language.japanese": "Japanese / 日本語",
"global.language.korean": "Korean",
"global.passwordInstructions": "The password needs to be <strong>at least 10 characters</strong> long.",
"global.passwordInstructions": "The password needs to be <strong>at least 10 characters</strong> and <strong>at most 255 characters</strong> long.",
"global.punctuation.colon": ":",
"global.punctuation.dot": ".",
"global.range.from": "from",
Expand Down
2 changes: 1 addition & 1 deletion source/renderer/app/i18n/locales/ja-JP.json
Expand Up @@ -155,7 +155,7 @@
"global.language.german": "ドイツ語",
"global.language.japanese": "日本語",
"global.language.korean": "韓国語",
"global.passwordInstructions": "パスワードは<strong>10文字以上</strong>で設定してください。",
"global.passwordInstructions": "パスワードは<strong>10文字以上255文字以内</strong>で設定してください。",
"global.punctuation.colon": "",
"global.punctuation.dot": "",
"global.range.from": "開始",
Expand Down
10 changes: 8 additions & 2 deletions source/renderer/app/utils/validations.js
Expand Up @@ -3,6 +3,9 @@ import BigNumber from 'bignumber.js';
import isInt from 'validator/lib/isInt';
import { every } from 'lodash';

const MIN_PASSWORD_LENGTH = 10;
const MAX_PASSWORD_LENGTH = 255;

export const isValidWalletName = (walletName: string) => {
const nameLength = walletName.length;
return nameLength >= 3 && nameLength <= 40;
Expand Down Expand Up @@ -53,11 +56,14 @@ export const isUnicaseString = (password: string) =>
every(password.split(''), (char) => isCaselessString(char));

/**
* Enforces passwords without spaces and a minimum of 10 characters.
* Enforces passwords without spaces and a minimum of 10 characters and a maximum of 255 characters.
*/
export const isValidSpendingPassword = (password: string): boolean => {
// Should contain at least 10 characters
return password.length >= 10;
return (
password.length >= MIN_PASSWORD_LENGTH &&
password.length <= MAX_PASSWORD_LENGTH
);
};

// eslint-disable-next-line max-len
Expand Down
44 changes: 6 additions & 38 deletions yarn.lock
Expand Up @@ -1296,37 +1296,13 @@
version "0.14.0"
resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.14.0.tgz#9fb3a3cf3132328151f353de4632e01e52102bea"

"@sinonjs/commons@^1":
"@sinonjs/commons@^1", "@sinonjs/commons@^1.6.0", "@sinonjs/commons@^1.7.0", "@sinonjs/commons@^1.8.1":
version "1.8.1"
resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.8.1.tgz#e7df00f98a203324f6dc7cc606cad9d4a8ab2217"
dependencies:
type-detect "4.0.8"

"@sinonjs/commons@^1.6.0":
version "1.8.1"
resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.8.1.tgz#e7df00f98a203324f6dc7cc606cad9d4a8ab2217"
dependencies:
type-detect "4.0.8"

"@sinonjs/commons@^1.7.0":
version "1.8.1"
resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.8.1.tgz#e7df00f98a203324f6dc7cc606cad9d4a8ab2217"
dependencies:
type-detect "4.0.8"

"@sinonjs/commons@^1.8.1":
version "1.8.1"
resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.8.1.tgz#e7df00f98a203324f6dc7cc606cad9d4a8ab2217"
dependencies:
type-detect "4.0.8"

"@sinonjs/fake-timers@^6.0.0":
version "6.0.1"
resolved "https://registry.yarnpkg.com/@sinonjs/fake-timers/-/fake-timers-6.0.1.tgz#293674fccb3262ac782c7aadfdeca86b10c75c40"
dependencies:
"@sinonjs/commons" "^1.7.0"

"@sinonjs/fake-timers@^6.0.1":
"@sinonjs/fake-timers@^6.0.0", "@sinonjs/fake-timers@^6.0.1":
version "6.0.1"
resolved "https://registry.yarnpkg.com/@sinonjs/fake-timers/-/fake-timers-6.0.1.tgz#293674fccb3262ac782c7aadfdeca86b10c75c40"
dependencies:
Expand All @@ -1339,15 +1315,7 @@
"@sinonjs/commons" "^1"
"@sinonjs/samsam" "^5.0.2"

"@sinonjs/samsam@^5.0.2":
version "5.3.0"
resolved "https://registry.yarnpkg.com/@sinonjs/samsam/-/samsam-5.3.0.tgz#1d2f0743dc54bf13fe9d508baefacdffa25d4329"
dependencies:
"@sinonjs/commons" "^1.6.0"
lodash.get "^4.4.2"
type-detect "^4.0.8"

"@sinonjs/samsam@^5.3.0":
"@sinonjs/samsam@^5.0.2", "@sinonjs/samsam@^5.3.0":
version "5.3.0"
resolved "https://registry.yarnpkg.com/@sinonjs/samsam/-/samsam-5.3.0.tgz#1d2f0743dc54bf13fe9d508baefacdffa25d4329"
dependencies:
Expand Down Expand Up @@ -12586,9 +12554,9 @@ react-modal@3.1.12:
prop-types "^15.5.10"
warning "^3.0.0"

react-polymorph@0.9.7-rc.10:
version "0.9.7-rc.10"
resolved "https://registry.yarnpkg.com/react-polymorph/-/react-polymorph-0.9.7-rc.10.tgz#78080178047d20fc02db3f666a35d430f0f28fb8"
react-polymorph@0.9.7-rc.11:
version "0.9.7-rc.11"
resolved "https://registry.yarnpkg.com/react-polymorph/-/react-polymorph-0.9.7-rc.11.tgz#e297dd5cbe0dc359dff10e881c5558c2080b7d38"
dependencies:
"@tippyjs/react" "4.2.0"
create-react-context "0.2.2"
Expand Down

0 comments on commit ee9bbe9

Please sign in to comment.