Adapt to the zxcvbn-ts v4 API, bump @zxcvbn-ts/language-common to match

v4 replaced the global `zxcvbnOptions`/`zxcvbnAsync` singleton with the
`ZxcvbnFactory` class. The warning/suggestion codes and options shape
are unchanged.
This commit is contained in:
Quentin Gliech
2026-07-02 22:22:33 +02:00
parent 720e55565a
commit 239dec3ee0
3 changed files with 17 additions and 9 deletions
+1 -1
View File
@@ -27,7 +27,7 @@
"@vector-im/compound-design-tokens": "10.2.0",
"@vector-im/compound-web": "^9.3.0",
"@zxcvbn-ts/core": "^4.1.2",
"@zxcvbn-ts/language-common": "^3.0.4",
"@zxcvbn-ts/language-common": "^4.1.2",
"classnames": "^2.5.1",
"date-fns": "^4.4.0",
"i18next": "^26.3.1",
@@ -1,10 +1,11 @@
// Copyright 2026 Element Creations Ltd.
// Copyright 2024, 2025 New Vector Ltd.
// Copyright 2024 The Matrix.org Foundation C.I.C.
//
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
// Please see LICENSE files in the repository root for full details.
import { zxcvbnAsync, zxcvbnOptions } from "@zxcvbn-ts/core";
import { ZxcvbnFactory } from "@zxcvbn-ts/core";
import * as zxcvbnCommonPackage from "@zxcvbn-ts/language-common";
import type { TFunction } from "i18next";
@@ -54,7 +55,7 @@ const options = {
l33tTable,
};
zxcvbnOptions.setOptions(options);
const zxcvbn = new ZxcvbnFactory(options);
export interface PasswordComplexity {
/** Score between 0 and 4 */
@@ -72,7 +73,7 @@ export async function estimatePasswordComplexity(
password: string,
t: TFunction,
): Promise<PasswordComplexity> {
const scorerResult = await zxcvbnAsync(password);
const scorerResult = await zxcvbn.checkAsync(password);
const improvementsText = [];
if (scorerResult.feedback.warning !== null) {
+12 -5
View File
@@ -54,8 +54,8 @@ importers:
specifier: ^4.1.2
version: 4.1.2
'@zxcvbn-ts/language-common':
specifier: ^3.0.4
version: 3.0.4
specifier: ^4.1.2
version: 4.1.2
classnames:
specifier: ^2.5.1
version: 2.5.1
@@ -2630,8 +2630,11 @@ packages:
'@zxcvbn-ts/core@4.1.2':
resolution: {integrity: sha512-RQmxWB3AMI+HGQErQdUv6Aq32aQhp6xOxrfgCP0+T9MsLZoP3xtLHuT8O8VojsUxdmQVZfJlYkYb1A0wOwIS+Q==}
'@zxcvbn-ts/language-common@3.0.4':
resolution: {integrity: sha512-viSNNnRYtc7ULXzxrQIVUNwHAPSXRtoIwy/Tq4XQQdIknBzw4vz36lQLF6mvhMlTIlpjoN/Z1GFu/fwiAlUSsw==}
'@zxcvbn-ts/dictionary-compression@3.0.1':
resolution: {integrity: sha512-p3KyPzxGc3vWSap5hHA6SllbUCmh7s+NtpGyC3qEWrxYJT9t9TUAzjPm48Okipo+UUyPQfDlIvTcs9JRShBFiQ==}
'@zxcvbn-ts/language-common@4.1.2':
resolution: {integrity: sha512-uJlBzhC9/KjPImqdnc1/lPxmdn4xKbkruN5p1mASWkXA0gli+GZ5LrVL+dqscA8Pcf4OfudE56TtCWeHljJOvA==}
acorn@8.17.0:
resolution: {integrity: sha512-xRQbDb9BnwDafYNn6Vwl839DYVjqXYb1XVGtWAZ1kcDc6iwAL4hg3B1dZlRiuENFeO2H53gFG3in621AdERVAg==}
@@ -6872,7 +6875,11 @@ snapshots:
dependencies:
fastest-levenshtein: 1.0.16
'@zxcvbn-ts/language-common@3.0.4': {}
'@zxcvbn-ts/dictionary-compression@3.0.1': {}
'@zxcvbn-ts/language-common@4.1.2':
dependencies:
'@zxcvbn-ts/dictionary-compression': 3.0.1
acorn@8.17.0: {}