From 9127bcf25e2390019e377eaf7c073b02181e4e2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sun, 21 Jun 2026 12:49:00 +0200 Subject: [PATCH] Added it and pl translations for password estimator, use lvenshtein distance and block partdb word --- .../password_strength_estimate_controller.js | 10 +++++++++- package.json | 2 ++ yarn.lock | 14 ++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/assets/controllers/elements/password_strength_estimate_controller.js b/assets/controllers/elements/password_strength_estimate_controller.js index 3a03b628..9ad2da1c 100644 --- a/assets/controllers/elements/password_strength_estimate_controller.js +++ b/assets/controllers/elements/password_strength_estimate_controller.js @@ -25,6 +25,8 @@ import * as zxcvbnEnPackage from '@zxcvbn-ts/language-en'; import * as zxcvbnDePackage from '@zxcvbn-ts/language-de'; import * as zxcvbnFrPackage from '@zxcvbn-ts/language-fr'; import * as zxcvbnJaPackage from '@zxcvbn-ts/language-ja'; +import * as zxcvbnItPackage from '@zxcvbn-ts/language-it'; +import * as zxcvbnPlPackage from '@zxcvbn-ts/language-pl'; import {trans} from '../../translator.js'; /* stimulusFetch: 'lazy' */ @@ -45,6 +47,10 @@ export default class extends Controller { return zxcvbnFrPackage.translations; } else if (locale.includes('ja')) { return zxcvbnJaPackage.translations; + } else if (locale.includes('it')) { + return zxcvbnItPackage.translations; + } else if (locale.includes('pl')) { + return zxcvbnPlPackage.translations; } //Fallback to english @@ -58,11 +64,14 @@ export default class extends Controller { //Configure zxcvbn const options = { graphs: zxcvbnCommonPackage.adjacencyGraphs, + useLevenshtein: true, dictionary: { ...zxcvbnCommonPackage.dictionary, // We could use the english dictionary here too, but it is very big. So we just use the common words ...zxcvbnEnPackage.dictionary, ...zxcvbnDePackage.dictionary, + + "partdb": ['part-db', 'partdb', 'part_db', 'part-db-symfony', 'partdb-symfony', 'part_db_symfony'], }, translations: this._getTranslations(), }; @@ -79,7 +88,6 @@ export default class extends Controller { //Estimate the password strength const result = await this._zxcvbnFactory.checkAsync(password); - console.log(result); //Update the badge this.badgeTarget.parentElement.classList.remove("d-none"); diff --git a/package.json b/package.json index 255c1828..568e6f76 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,8 @@ "@zxcvbn-ts/language-en": "^4.1.1", "@zxcvbn-ts/language-fr": "^4.1.1", "@zxcvbn-ts/language-ja": "^4.1.1", + "@zxcvbn-ts/language-it": "^4.1.1", + "@zxcvbn-ts/language-pl": "^4.1.1", "attr-accept": "^2.2.5", "barcode-detector": "^3.0.5", "bootbox": "^6.0.0", diff --git a/yarn.lock b/yarn.lock index c6b89ebd..523cce80 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2111,6 +2111,13 @@ dependencies: "@zxcvbn-ts/dictionary-compression" "^3.0.1" +"@zxcvbn-ts/language-it@^4.1.1": + version "4.1.1" + resolved "https://registry.yarnpkg.com/@zxcvbn-ts/language-it/-/language-it-4.1.1.tgz#b6fda40099e85a4fc1c5d14d75c9de8a304dd061" + integrity sha512-YxKCBO1rKuCMPYRyOxfUZA+3ju8OO8W9Qx8h/vHrHvuGIavK7L+fgXTUrhjHU8M+zE0pQZxS4wOdfgLFZaP57w== + dependencies: + "@zxcvbn-ts/dictionary-compression" "^3.0.1" + "@zxcvbn-ts/language-ja@^4.1.1": version "4.1.1" resolved "https://registry.yarnpkg.com/@zxcvbn-ts/language-ja/-/language-ja-4.1.1.tgz#acd36abe4f6083dceda22771148d0948e0e421d9" @@ -2118,6 +2125,13 @@ dependencies: "@zxcvbn-ts/dictionary-compression" "^3.0.1" +"@zxcvbn-ts/language-pl@^4.1.1": + version "4.1.1" + resolved "https://registry.yarnpkg.com/@zxcvbn-ts/language-pl/-/language-pl-4.1.1.tgz#627d4c365a69e3f78d3e2b6e9667d1b57b6cc1ff" + integrity sha512-hF6Qu9cyHx7sSEzNOQrJQntq8geoincsGvlOC0wkD43LnUVSTR49MKxdsifsemlQgtxR7aUKDgK/e/RFHOljoQ== + dependencies: + "@zxcvbn-ts/dictionary-compression" "^3.0.1" + acorn-import-phases@^1.0.3: version "1.0.4" resolved "https://registry.yarnpkg.com/acorn-import-phases/-/acorn-import-phases-1.0.4.tgz#16eb850ba99a056cb7cbfe872ffb8972e18c8bd7"