From e4707c7a4a00a23bc6aea79c8013d5e20b4a7ad3 Mon Sep 17 00:00:00 2001 From: Gustavo Valverde Date: Thu, 22 Jun 2023 14:45:41 -0400 Subject: [PATCH 1/5] ref(elements): make passwordLevel more readable --- .../elements/passwordLevel/index.tsx | 171 ++++++++---------- src/pages/register/stepper/step3.tsx | 16 -- 2 files changed, 73 insertions(+), 114 deletions(-) diff --git a/src/components/elements/passwordLevel/index.tsx b/src/components/elements/passwordLevel/index.tsx index 6f3f8ece..a3792617 100644 --- a/src/components/elements/passwordLevel/index.tsx +++ b/src/components/elements/passwordLevel/index.tsx @@ -1,69 +1,72 @@ import * as React from 'react'; import CheckCircleIcon from '@mui/icons-material/CheckCircle'; - import { Typography } from '@mui/material'; -// TODO: Refactor this with a simpler approach -export default function PasswordLevel({ passwordLevel }: any) { - return passwordLevel.length > 0 ? ( +interface PasswordRequirementProps { + met: boolean; + text: string; +} + +const PasswordRequirement: React.FC = ({ met, text }) => ( +
+ + + {text} + +
+); + +interface ProgressBarProps { + filled: boolean; + color: string; +} + +const ProgressBar: React.FC = ({ filled, color }) => ( +
+); + +const PASSWORD_LEVELS = [' Muy Bajo', ' Bajo', ' Medio', ' Fuerte']; +const ProgressBarColors = ['#E05D56', '#E0D256', '#B4E056', '#A3E056']; + +interface PasswordLevelProps { + passwordLevel: { + contains: string[]; + id: number; + length: number; + }; +} + +const PasswordLevel: React.FC = ({ passwordLevel }) => { + const requirements = [ + ['lowercase', 'Una letra minúscula'], + ['uppercase', 'Una letra mayúscula'], + ['number', 'Un número'], + ['symbol', 'Un caracter especial'], + ]; + + return passwordLevel?.length > 0 ? (
-
- - - Una letra minúscula - -
-
- ( + - - Una letra mayúscula - -
-
- - - Un número - -
-
- - - Un carácter especial - -
-
- = 10 ? 'success' : 'disabled'} - style={{ fontSize: '20px', marginBottom: '-4px', marginRight: '3px' }} - /> - - 10 caracteres como mínimo - -
+ ))} + = 8} + text="8 caracteres como mínimo" + />
- {passwordLevel.id >= 0 && ( -
( + = index} + color={color} /> - )} -
= 1 ? '#E0D256' : '#f1f1f1'}`, - borderRadius: '10px', - }} - /> -
= 2 ? '#B4E056' : '#f1f1f1'}`, - borderRadius: '10px', - }} - /> -
= 3 ? '#A3E056' : '#f1f1f1'}`, - borderRadius: '10px', - }} - /> + ))}
Nivel de contraseña - {passwordLevel.id === 0 && ' Muy Bajo'} - {passwordLevel.id === 1 && ' Bajo'} - {passwordLevel.id === 2 && ' Medio'} - {passwordLevel.id === 3 && ' Fuerte'} + {PASSWORD_LEVELS[passwordLevel.id]}
) : null; -} +}; + +export default PasswordLevel; diff --git a/src/pages/register/stepper/step3.tsx b/src/pages/register/stepper/step3.tsx index 03eda969..63bfcf21 100644 --- a/src/pages/register/stepper/step3.tsx +++ b/src/pages/register/stepper/step3.tsx @@ -205,21 +205,6 @@ export default function Step3({ handleNext, infoCedula }: any) { - - - Al menos 8 caracteres de largo -
- Al menos 3 de los siguientes: -
-
  • Letras minúsculas (a-z)
  • -
  • Letras mayúsculas (A-Z)
  • -
  • Números (0-9)
  • -
  • Caracteres especiales (por ejemplo, !@#$%^&*)
  • - - } - > -
    From c0515848e5763001bb8461bb8d1c8641dc7a9234 Mon Sep 17 00:00:00 2001 From: Gustavo Valverde Date: Thu, 22 Jun 2023 14:48:20 -0400 Subject: [PATCH 2/5] chore: minor fix --- src/components/elements/passwordLevel/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/elements/passwordLevel/index.tsx b/src/components/elements/passwordLevel/index.tsx index a3792617..30c7df47 100644 --- a/src/components/elements/passwordLevel/index.tsx +++ b/src/components/elements/passwordLevel/index.tsx @@ -35,7 +35,7 @@ const ProgressBar: React.FC = ({ filled, color }) => ( /> ); -const PASSWORD_LEVELS = [' Muy Bajo', ' Bajo', ' Medio', ' Fuerte']; +const PASSWORD_LEVELS = ['Muy Bajo', ' Bajo', ' Medio', ' Fuerte']; const ProgressBarColors = ['#E05D56', '#E0D256', '#B4E056', '#A3E056']; interface PasswordLevelProps { From d61b481ec26c1ac409bbe678648bbab8f244391f Mon Sep 17 00:00:00 2001 From: Gustavo Valverde Date: Thu, 22 Jun 2023 14:53:25 -0400 Subject: [PATCH 3/5] build(deps): fix vulnerability --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f81c0f04..70fb6d17 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "cookie": "^0.5.0", "cryptr": "^6.2.0", "eslint": "^8.40.0", - "eslint-config-next": "13.2.3", + "eslint-config-next": "13.4.7", "hibp": "^13.0.0", "next": "13.2.3", "next-recaptcha-v3": "^1.1.5", @@ -46,7 +46,7 @@ "@typescript-eslint/parser": "^5.59.5", "eslint-config-prettier": "^8.8.0", "eslint-import-resolver-typescript": "^3.5.5", - "eslint-plugin-import": "^2.26.0", + "eslint-plugin-import": "^2.27.5", "eslint-plugin-prettier": "^4.2.1", "install-peers": "^1.0.4", "prettier": ">=2.0.0" From 97ed010c085b5890393730c4d999e7695824b786 Mon Sep 17 00:00:00 2001 From: Gustavo Valverde Date: Thu, 22 Jun 2023 14:55:03 -0400 Subject: [PATCH 4/5] patch: audit-ci levels --- audit-ci.jsonc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/audit-ci.jsonc b/audit-ci.jsonc index 297adb59..2c408b28 100644 --- a/audit-ci.jsonc +++ b/audit-ci.jsonc @@ -3,7 +3,8 @@ // Add a $schema property to enable JSON schema validation. "$schema": "https://github.com/IBM/audit-ci/raw/main/docs/schema.json", // You only need one of ["low", "moderate", "high", "critical"]. - "moderate": true, + // TODO: lower this to "moderate" once the issue is resolved. + "high": true, "allowlist": [ { "GHSA-9c47-m6qq-7p4h|eslint-plugin-import>tsconfig-paths>json5": { From 2cd494c00a21ef571fee722e29ac23f42fa2f92d Mon Sep 17 00:00:00 2001 From: Gustavo Valverde Date: Thu, 22 Jun 2023 15:00:00 -0400 Subject: [PATCH 5/5] fix: forgot to install :) --- yarn.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/yarn.lock b/yarn.lock index 99747535..3c1aa227 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3804,10 +3804,10 @@ resolved "https://registry.yarnpkg.com/@next/env/-/env-13.2.3.tgz#77ca49edb3c1d7c5263bb8f2ebe686080e98279e" integrity sha512-FN50r/E+b8wuqyRjmGaqvqNDuWBWYWQiigfZ50KnSFH0f+AMQQyaZl+Zm2+CIpKk0fL9QxhLxOpTVA3xFHgFow== -"@next/eslint-plugin-next@13.2.3": - version "13.2.3" - resolved "https://registry.yarnpkg.com/@next/eslint-plugin-next/-/eslint-plugin-next-13.2.3.tgz#5af8ddeac6dbe028c812a0e59c41952c004d95d5" - integrity sha512-QmMPItnU7VeojI1KnuwL9SLFWEwmaNHNlnOGpoTwdLoSiP9sc8KYiAHWEc4/44L+cAdCxcZYvn7frcRNP5l84Q== +"@next/eslint-plugin-next@13.4.7": + version "13.4.7" + resolved "https://registry.yarnpkg.com/@next/eslint-plugin-next/-/eslint-plugin-next-13.4.7.tgz#7efeff2af76be0d9a176a957da21e3710b2e79cf" + integrity sha512-ANEPltxzXbyyG7CvqxdY4PmeM5+RyWdAJGufTHnU+LA/i3J6IDV2r8Z4onKwskwKEhwqzz5lMaSYGGXLyHX+mg== dependencies: glob "7.1.7" @@ -5313,12 +5313,12 @@ escape-string-regexp@^4.0.0: resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== -eslint-config-next@13.2.3: - version "13.2.3" - resolved "https://registry.yarnpkg.com/eslint-config-next/-/eslint-config-next-13.2.3.tgz#8a952bfd856f492684a30dd5fcdc8979c97c1cc2" - integrity sha512-kPulHiQEHGei9hIaaNGygHRc0UzlWM+3euOmYbxNkd2Nbhci5rrCDeMBMPSV8xgUssphDGmwDHWbk4VZz3rlZQ== +eslint-config-next@13.4.7: + version "13.4.7" + resolved "https://registry.yarnpkg.com/eslint-config-next/-/eslint-config-next-13.4.7.tgz#59c48ecb37175ccc057f621a07af894cc931574f" + integrity sha512-+IRAyD0+J1MZaTi9RQMPUfr6Q+GCZ1wOkK6XM52Vokh7VI4R6YFGOFzdkEFHl4ZyIX4FKa5vcwUP2WscSFNjNQ== dependencies: - "@next/eslint-plugin-next" "13.2.3" + "@next/eslint-plugin-next" "13.4.7" "@rushstack/eslint-patch" "^1.1.3" "@typescript-eslint/parser" "^5.42.0" eslint-import-resolver-node "^0.3.6" @@ -5363,7 +5363,7 @@ eslint-module-utils@^2.7.4: dependencies: debug "^3.2.7" -eslint-plugin-import@^2.26.0: +eslint-plugin-import@^2.26.0, eslint-plugin-import@^2.27.5: version "2.27.5" resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.27.5.tgz#876a6d03f52608a3e5bb439c2550588e51dd6c65" integrity sha512-LmEt3GVofgiGuiE+ORpnvP+kAm3h6MLZJ4Q5HCyHADofsb4VzXFsRiWj3c0OFiV+3DWFh0qg3v9gcPlfc3zRow==