Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

ts: Convert password_quality module to TypeScript.

Priyank Patelfdedced521f3
diff --git a/package.json b/package.json
index ca16986d74f..2058c57dcc5 100644
--- a/package.json
+++ b/package.json
@@ -92,6 +92,7 @@
"@types/terser-webpack-plugin": "^4.1.0",
"@types/webpack": "^4.4.32",
"@types/webpack-dev-server": "^3.1.6",
+ "@types/zxcvbn": "^4.4.1",
"@typescript-eslint/eslint-plugin": "^4.0.1",
"@typescript-eslint/parser": "^4.0.1",
"babel-plugin-rewire-ts": "^1.4.0",
diff --git a/static/js/password_quality.js b/static/js/password_quality.ts
similarity index 84%
rename from static/js/password_quality.js
rename to static/js/password_quality.ts
index b837d86a38e..96f56eb90f0 100644
--- a/static/js/password_quality.js
+++ b/static/js/password_quality.ts
@@ -9,7 +9,11 @@ import {$t} from "./i18n";
// Return a boolean indicating whether the password is acceptable.
// Also updates a Bootstrap progress bar control (a jQuery object)
// if provided.
-export function password_quality(password, bar, password_field) {
+export function password_quality(
+ password: string,
+ bar: JQuery | undefined,
+ password_field: JQuery,
+): boolean {
const min_length = password_field.data("minLength");
const min_guesses = password_field.data("minGuesses");
@@ -17,7 +21,7 @@ export function password_quality(password, bar, password_field) {
const acceptable = password.length >= min_length && result.guesses >= min_guesses;
if (bar !== undefined) {
- const t = result.crack_times_seconds.offline_slow_hashing_1e4_per_second;
+ const t = Number(result.crack_times_seconds.offline_slow_hashing_1e4_per_second);
let bar_progress = Math.min(1, Math.log(1 + t) / 22);
// Even if zxcvbn loves your short password, the bar should be
@@ -36,7 +40,7 @@ export function password_quality(password, bar, password_field) {
return acceptable;
}
-export function password_warning(password, password_field) {
+export function password_warning(password: string, password_field: JQuery): string {
const min_length = password_field.data("minLength");
if (password.length < min_length) {
diff --git a/version.py b/version.py
index 66307941106..2a14f285c8a 100644
--- a/version.py
+++ b/version.py
@@ -48,4 +48,4 @@ API_FEATURE_LEVEL = 77
# historical commits sharing the same major version, in which case a
# minor version bump suffices.
-PROVISION_VERSION = "153.1"
+PROVISION_VERSION = "153.2"
diff --git a/yarn.lock b/yarn.lock
index 0f4b4f59249..31f675545e7 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1775,6 +1775,11 @@
dependencies:
"@types/node" "*"
+"@types/zxcvbn@^4.4.1":
+ version "4.4.1"
+ resolved "https://registry.yarnpkg.com/@types/zxcvbn/-/zxcvbn-4.4.1.tgz#46e42cbdcee681b22181478feaf4af2bc4c1abd2"
+ integrity sha512-3NoqvZC2W5gAC5DZbTpCeJ251vGQmgcWIHQJGq2J240HY6ErQ9aWKkwfoKJlHLx+A83WPNTZ9+3cd2ILxbvr1w==
+
"@typescript-eslint/eslint-plugin@^4.0.1":
version "4.28.2"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.28.2.tgz#7a8320f00141666813d0ae43b49ee8244f7cf92a"