@fr0st/ui-passwordstrength 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 elusivecodes
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # FrostUI PasswordStrength
2
+
3
+ **FrostUI PasswordStrength** is a free, open-source Password Strength component for *JavaScript*.
4
+
5
+ It is built on top of the [FrostUI](https://github.com/elusivecodes/FrostUI) library.
6
+
7
+
8
+ ## Table Of Contents
9
+ - [Installation](#installation)
10
+ - [Usage](#usage)
11
+
12
+
13
+
14
+ ## Installation
15
+
16
+ **Dependencies**
17
+
18
+ - [fQuery](https://github.com/elusivecodes/fQuery)
19
+ - [FrostUI](https://github.com/elusivecodes/FrostUI)
20
+
21
+ **CSS**
22
+
23
+ ```html
24
+ <link rel="stylesheet" href="/path/to/frost-ui.min.css" />
25
+ ```
26
+
27
+ **JS**
28
+
29
+ ```html
30
+ <script type="text/javascript" src="/path/to/frost-ui-bundle.min.js"></script>
31
+ <script type="text/javascript" src="/path/to/frost-ui-passwordstrength.min.js"></script>
32
+ ```
33
+
34
+
35
+ ## Usage
36
+
37
+ Check the demo folder for examples. Full documentation and website coming soon™.
@@ -0,0 +1,333 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@fr0st/ui'), require('@fr0st/query')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', '@fr0st/ui', '@fr0st/query'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.UI = global.UI || {}, global.UI, global.fQuery));
5
+ })(this, (function (exports, ui, $) { 'use strict';
6
+
7
+ /**
8
+ * PasswordStrength Class
9
+ * @class
10
+ */
11
+ class PasswordStrength extends ui.BaseComponent {
12
+ /**
13
+ * New PasswordStrength constructor.
14
+ * @param {HTMLElement} node The input node.
15
+ * @param {object} [options] The options to create the PasswordStrength with.
16
+ */
17
+ constructor(node, options) {
18
+ super(node, options);
19
+
20
+ if (this._options.container) {
21
+ this._container = $.findOne(this._options.container);
22
+ } else {
23
+ this._container = $.closest(this._node, ':not(.form-input):not(.input-group)');
24
+ }
25
+
26
+ this._render();
27
+ this._refresh();
28
+ this._events();
29
+ }
30
+
31
+ /**
32
+ * Dispose the PasswordStrength.
33
+ */
34
+ dispose() {
35
+ $.remove(this._progress);
36
+ $.removeEvent(this._node, 'input.ui.passwordstrength');
37
+
38
+ this._container = null;
39
+ this._progress = null;
40
+ this._progressBar = null;
41
+
42
+ super.dispose();
43
+ }
44
+
45
+ /**
46
+ * Get the password strength.
47
+ * @return {number} The password strength. (0, 100)
48
+ */
49
+ getStrength() {
50
+ const value = $.getValue(this._node);
51
+
52
+ return this.constructor.getStrength(value);
53
+ }
54
+ }
55
+
56
+ /**
57
+ * Attach events for the PasswordStrength.
58
+ */
59
+ function _events() {
60
+ $.addEvent(this._node, 'input.ui.passwordstrength', (_) => {
61
+ this._refresh();
62
+ });
63
+ }
64
+
65
+ /**
66
+ * Refresh the password strength.
67
+ */
68
+ function _refresh() {
69
+ const strength = this.getStrength();
70
+
71
+ let nextLevel;
72
+ for (const level of this._options.levels) {
73
+ if (strength < level.score) {
74
+ break;
75
+ }
76
+
77
+ nextLevel = level;
78
+ }
79
+
80
+ $.setStyle(this._progressBar, { width: `${strength}%` });
81
+ $.setAttribute(this._progressBar, {
82
+ class: this.constructor.classes.progressBar,
83
+ 'aria-valuenow': strength,
84
+ });
85
+
86
+ $.addClass(this._progressBar, nextLevel.class);
87
+
88
+ if (this._options.striped) {
89
+ $.addClass(this._progressBar, this.constructor.classes.progressBarStriped);
90
+ }
91
+
92
+ if (nextLevel.text) {
93
+ $.setText(this._progressBar, nextLevel.text);
94
+ }
95
+ }
96
+
97
+ /**
98
+ * Render the password strength element.
99
+ */
100
+ function _render() {
101
+ this._progress = $.create('div', {
102
+ class: this.constructor.classes.progress,
103
+ });
104
+
105
+ this._progressBar = $.create('div', {
106
+ attributes: {
107
+ 'role': 'progressbar',
108
+ 'aria-valuemin': 0,
109
+ 'aria-valuemax': 100,
110
+ },
111
+ });
112
+
113
+ $.append(this._progress, this._progressBar);
114
+ $.append(this._container, this._progress);
115
+ }
116
+
117
+ /**
118
+ * Find character sequences in a string.
119
+ * @param {string} string The input string.
120
+ * @param {array} locations The character locations.
121
+ * @return {array} The character sequences.
122
+ */
123
+ function findSequences(string, locations) {
124
+ const sequences = [];
125
+ let sequence = [];
126
+
127
+ for (let i = 0; i < locations.length - 1; i++) {
128
+ const current = locations[i];
129
+ const next = locations[i + 1];
130
+ const distance = next - current;
131
+
132
+ const char = string[current];
133
+ const nextChar = string[next];
134
+ const charDistance = nextChar.charCodeAt(0) - char.charCodeAt(0);
135
+
136
+ if (distance === 1 && charDistance === 1) {
137
+ if (!sequence.length) {
138
+ sequence.push(char);
139
+ }
140
+ sequence.push(nextChar);
141
+ } else if (sequence.length) {
142
+ sequences.push(sequence);
143
+ sequence = [];
144
+ }
145
+ }
146
+
147
+ if (sequence.length) {
148
+ sequences.push(sequence);
149
+ }
150
+
151
+ return sequences;
152
+ }
153
+ /**
154
+ * Get the strength of a password.
155
+ * @param {string} password The password.
156
+ * @return {number} The password strength.
157
+ */
158
+ function getStrength(password) {
159
+ if (password.match(/^password/i)) {
160
+ password = password.substring(8);
161
+ }
162
+
163
+ const length = password.length;
164
+
165
+ let score = 0;
166
+
167
+ if (length) {
168
+ score += length * 6;
169
+ }
170
+
171
+ const upper = [];
172
+ const lower = [];
173
+ const numbers = [];
174
+ const symbols = [];
175
+ const dictionary = {};
176
+
177
+ for (let i = 0; i < length; i++) {
178
+ const char = password[i];
179
+ const code = char.charCodeAt(0);
180
+
181
+ if (code >= 48 && code <= 57) {
182
+ numbers.push(i);
183
+ } else if (code >= 65 && code <= 90) {
184
+ upper.push(i);
185
+ } else if (code >= 97 && code <= 122) {
186
+ lower.push(i);
187
+ } else {
188
+ symbols.push(i);
189
+ }
190
+
191
+ if (!(char in dictionary)) {
192
+ dictionary[char] = 0;
193
+ }
194
+
195
+ dictionary[char]++;
196
+ }
197
+
198
+ // reward upper/lower case
199
+ if (upper.length !== length && lower.length !== length) {
200
+ if (upper.length) {
201
+ score += length - upper.length;
202
+ }
203
+
204
+ if (lower.length) {
205
+ score += length - lower.length;
206
+ }
207
+ }
208
+
209
+ // reward numbers
210
+ if (numbers.length !== length) {
211
+ score += numbers.length * 3;
212
+ }
213
+
214
+ // reward symbols
215
+ score += symbols.length * 6;
216
+
217
+ // reward inner numbers/symbols
218
+ for (const list of [numbers, symbols]) {
219
+ const reward = list.filter((v) => v && v !== length - 1).length;
220
+ score += reward * 3;
221
+ }
222
+
223
+ // punish only letters
224
+ if (!numbers.length && !symbols.length) {
225
+ score -= length;
226
+ }
227
+
228
+ // punish only numbers
229
+ if (!upper.length && !lower.length && !symbols.length) {
230
+ score -= length;
231
+ }
232
+
233
+ // punish no symbols
234
+ if (!symbols.length) {
235
+ score -= length;
236
+ }
237
+
238
+ // repeating characters
239
+ const repeats = Object.values(dictionary)
240
+ .reduce((acc, count) => acc + count - 1, 0);
241
+
242
+ if (repeats > 0) {
243
+ score -= repeats;
244
+ }
245
+
246
+ if (length >= 2) {
247
+ // consecutive characters
248
+ const matches = password.matchAll(/(.)\1+/g);
249
+
250
+ for (const match of matches) {
251
+ score -= Math.min(match[0].length, 12) * 3;
252
+ }
253
+
254
+ const lowerPassword = password.toLowerCase();
255
+
256
+ // sequential letters
257
+ const letters = upper.concat(lower);
258
+ const letterSequences = findSequences(lowerPassword, letters);
259
+ for (const sequence of letterSequences) {
260
+ if (sequence.length > 2) {
261
+ score -= (Math.min(sequence.length - 2, 16)) * 3;
262
+ }
263
+ }
264
+
265
+ // sequential numbers
266
+ const numberSequences = findSequences(lowerPassword, numbers);
267
+ for (const sequence of numberSequences) {
268
+ if (sequence.length > 2) {
269
+ score -= (Math.min(sequence.length - 2, 16)) * 3;
270
+ }
271
+ }
272
+ }
273
+
274
+ return $._clamp(score, 0, 100);
275
+ }
276
+
277
+ // PasswordStrength default options
278
+ PasswordStrength.defaults = {
279
+ levels: [
280
+ {
281
+ score: 0,
282
+ class: 'text-bg-danger',
283
+ text: 'Very Weak',
284
+ },
285
+ {
286
+ score: 20,
287
+ class: 'text-bg-danger',
288
+ text: 'Weak',
289
+ },
290
+ {
291
+ score: 40,
292
+ class: 'text-bg-warning',
293
+ text: 'Normal',
294
+ },
295
+ {
296
+ score: 60,
297
+ class: 'text-bg-success',
298
+ text: 'Strong',
299
+ },
300
+ {
301
+ score: 80,
302
+ class: 'text-bg-success',
303
+ text: 'Very Strong',
304
+ },
305
+ ],
306
+ container: null,
307
+ striped: false,
308
+ };
309
+
310
+ // PasswordStrength classes
311
+ PasswordStrength.classes = {
312
+ progress: 'progress mt-2',
313
+ progressBar: 'progress-bar',
314
+ progressBarStriped: 'progress-bar-striped',
315
+ };
316
+
317
+ // PasswordStrength static
318
+ PasswordStrength.getStrength = getStrength;
319
+
320
+ // PasswordStrength prototype
321
+ const proto = PasswordStrength.prototype;
322
+
323
+ proto._events = _events;
324
+ proto._refresh = _refresh;
325
+ proto._render = _render;
326
+
327
+ // PasswordStrength init
328
+ ui.initComponent('passwordstrength', PasswordStrength);
329
+
330
+ exports.PasswordStrength = PasswordStrength;
331
+
332
+ }));
333
+ //# sourceMappingURL=frost-ui-passwordstrength.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frost-ui-passwordstrength.js","sources":["../src/password-strength.js","../src/prototype/events.js","../src/prototype/helpers.js","../src/prototype/render.js","../src/static/helpers.js","../src/index.js"],"sourcesContent":["import $ from '@fr0st/query';\nimport { BaseComponent } from '@fr0st/ui';\n\n/**\n * PasswordStrength Class\n * @class\n */\nexport default class PasswordStrength extends BaseComponent {\n /**\n * New PasswordStrength constructor.\n * @param {HTMLElement} node The input node.\n * @param {object} [options] The options to create the PasswordStrength with.\n */\n constructor(node, options) {\n super(node, options);\n\n if (this._options.container) {\n this._container = $.findOne(this._options.container);\n } else {\n this._container = $.closest(this._node, ':not(.form-input):not(.input-group)');\n }\n\n this._render();\n this._refresh();\n this._events();\n }\n\n /**\n * Dispose the PasswordStrength.\n */\n dispose() {\n $.remove(this._progress);\n $.removeEvent(this._node, 'input.ui.passwordstrength');\n\n this._container = null;\n this._progress = null;\n this._progressBar = null;\n\n super.dispose();\n }\n\n /**\n * Get the password strength.\n * @return {number} The password strength. (0, 100)\n */\n getStrength() {\n const value = $.getValue(this._node);\n\n return this.constructor.getStrength(value);\n }\n}\n","import $ from '@fr0st/query';\n\n/**\n * Attach events for the PasswordStrength.\n */\nexport function _events() {\n $.addEvent(this._node, 'input.ui.passwordstrength', (_) => {\n this._refresh();\n });\n};\n","import $ from '@fr0st/query';\n\n/**\n * Refresh the password strength.\n */\nexport function _refresh() {\n const strength = this.getStrength();\n\n let nextLevel;\n for (const level of this._options.levels) {\n if (strength < level.score) {\n break;\n }\n\n nextLevel = level;\n }\n\n $.setStyle(this._progressBar, { width: `${strength}%` });\n $.setAttribute(this._progressBar, {\n class: this.constructor.classes.progressBar,\n 'aria-valuenow': strength,\n });\n\n $.addClass(this._progressBar, nextLevel.class);\n\n if (this._options.striped) {\n $.addClass(this._progressBar, this.constructor.classes.progressBarStriped);\n }\n\n if (nextLevel.text) {\n $.setText(this._progressBar, nextLevel.text);\n }\n};\n","import $ from '@fr0st/query';\n\n/**\n * Render the password strength element.\n */\nexport function _render() {\n this._progress = $.create('div', {\n class: this.constructor.classes.progress,\n });\n\n this._progressBar = $.create('div', {\n attributes: {\n 'role': 'progressbar',\n 'aria-valuemin': 0,\n 'aria-valuemax': 100,\n },\n });\n\n $.append(this._progress, this._progressBar);\n $.append(this._container, this._progress);\n};\n","import $ from '@fr0st/query';\n\n/**\n * Find character sequences in a string.\n * @param {string} string The input string.\n * @param {array} locations The character locations.\n * @return {array} The character sequences.\n */\nfunction findSequences(string, locations) {\n const sequences = [];\n let sequence = [];\n\n for (let i = 0; i < locations.length - 1; i++) {\n const current = locations[i];\n const next = locations[i + 1];\n const distance = next - current;\n\n const char = string[current];\n const nextChar = string[next];\n const charDistance = nextChar.charCodeAt(0) - char.charCodeAt(0);\n\n if (distance === 1 && charDistance === 1) {\n if (!sequence.length) {\n sequence.push(char);\n }\n sequence.push(nextChar);\n } else if (sequence.length) {\n sequences.push(sequence);\n sequence = [];\n }\n }\n\n if (sequence.length) {\n sequences.push(sequence);\n }\n\n return sequences;\n};\n\n/**\n * Get the strength of a password.\n * @param {string} password The password.\n * @return {number} The password strength.\n */\nexport function getStrength(password) {\n if (password.match(/^password/i)) {\n password = password.substring(8);\n }\n\n const length = password.length;\n\n let score = 0;\n\n if (length) {\n score += length * 6;\n }\n\n const upper = [];\n const lower = [];\n const numbers = [];\n const symbols = [];\n const dictionary = {};\n\n for (let i = 0; i < length; i++) {\n const char = password[i];\n const code = char.charCodeAt(0);\n\n if (code >= 48 && code <= 57) {\n numbers.push(i);\n } else if (code >= 65 && code <= 90) {\n upper.push(i);\n } else if (code >= 97 && code <= 122) {\n lower.push(i);\n } else {\n symbols.push(i);\n }\n\n if (!(char in dictionary)) {\n dictionary[char] = 0;\n }\n\n dictionary[char]++;\n }\n\n // reward upper/lower case\n if (upper.length !== length && lower.length !== length) {\n if (upper.length) {\n score += length - upper.length;\n }\n\n if (lower.length) {\n score += length - lower.length;\n }\n }\n\n // reward numbers\n if (numbers.length !== length) {\n score += numbers.length * 3;\n }\n\n // reward symbols\n score += symbols.length * 6;\n\n // reward inner numbers/symbols\n for (const list of [numbers, symbols]) {\n const reward = list.filter((v) => v && v !== length - 1).length;\n score += reward * 3;\n }\n\n // punish only letters\n if (!numbers.length && !symbols.length) {\n score -= length;\n }\n\n // punish only numbers\n if (!upper.length && !lower.length && !symbols.length) {\n score -= length;\n }\n\n // punish no symbols\n if (!symbols.length) {\n score -= length;\n }\n\n // repeating characters\n const repeats = Object.values(dictionary)\n .reduce((acc, count) => acc + count - 1, 0);\n\n if (repeats > 0) {\n score -= repeats;\n }\n\n if (length >= 2) {\n // consecutive characters\n const matches = password.matchAll(/(.)\\1+/g);\n\n for (const match of matches) {\n score -= Math.min(match[0].length, 12) * 3;\n }\n\n const lowerPassword = password.toLowerCase();\n\n // sequential letters\n const letters = upper.concat(lower);\n const letterSequences = findSequences(lowerPassword, letters);\n for (const sequence of letterSequences) {\n if (sequence.length > 2) {\n score -= (Math.min(sequence.length - 2, 16)) * 3;\n }\n }\n\n // sequential numbers\n const numberSequences = findSequences(lowerPassword, numbers);\n for (const sequence of numberSequences) {\n if (sequence.length > 2) {\n score -= (Math.min(sequence.length - 2, 16)) * 3;\n }\n }\n }\n\n return $._clamp(score, 0, 100);\n};\n","import { initComponent } from '@fr0st/ui';\nimport PasswordStrength from './password-strength.js';\nimport { _events } from './prototype/events.js';\nimport { _refresh } from './prototype/helpers.js';\nimport { _render } from './prototype/render.js';\nimport { getStrength } from './static/helpers.js';\n\n// PasswordStrength default options\nPasswordStrength.defaults = {\n levels: [\n {\n score: 0,\n class: 'text-bg-danger',\n text: 'Very Weak',\n },\n {\n score: 20,\n class: 'text-bg-danger',\n text: 'Weak',\n },\n {\n score: 40,\n class: 'text-bg-warning',\n text: 'Normal',\n },\n {\n score: 60,\n class: 'text-bg-success',\n text: 'Strong',\n },\n {\n score: 80,\n class: 'text-bg-success',\n text: 'Very Strong',\n },\n ],\n container: null,\n striped: false,\n};\n\n// PasswordStrength classes\nPasswordStrength.classes = {\n progress: 'progress mt-2',\n progressBar: 'progress-bar',\n progressBarStriped: 'progress-bar-striped',\n};\n\n// PasswordStrength static\nPasswordStrength.getStrength = getStrength;\n\n// PasswordStrength prototype\nconst proto = PasswordStrength.prototype;\n\nproto._events = _events;\nproto._refresh = _refresh;\nproto._render = _render;\n\n// PasswordStrength init\ninitComponent('passwordstrength', PasswordStrength);\n\nexport default PasswordStrength;\n"],"names":["BaseComponent","initComponent"],"mappings":";;;;;;IAGA;IACA;IACA;IACA;IACe,MAAM,gBAAgB,SAASA,gBAAa,CAAC;IAC5D;IACA;IACA;IACA;IACA;IACA,IAAI,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE;IAC/B,QAAQ,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC7B;IACA,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE;IACrC,YAAY,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IACjE,SAAS,MAAM;IACf,YAAY,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,qCAAqC,CAAC,CAAC;IAC3F,SAAS;AACT;IACA,QAAQ,IAAI,CAAC,OAAO,EAAE,CAAC;IACvB,QAAQ,IAAI,CAAC,QAAQ,EAAE,CAAC;IACxB,QAAQ,IAAI,CAAC,OAAO,EAAE,C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E,EAAE;IACrB,YAAY,KAAK,EAAE,iBAAiB;IACpC,YAAY,IAAI,EAAE,QAAQ;IAC1B,SAAS;IACT,QAAQ;IACR,YAAY,KAAK,EAAE,EAAE;IACrB,YAAY,KAAK,EAAE,iBAAiB;IACpC,YAAY,IAAI,EAAE,aAAa;IAC/B,SAAS;IACT,KAAK;IACL,IAAI,SAAS,EAAE,IAAI;IACnB,IAAI,OAAO,EAAE,KAAK;IAClB,CAAC,CAAC;AACF;IACA;IACA,gBAAgB,CAAC,OAAO,GAAG;IAC3B,IAAI,QAAQ,EAAE,eAAe;IAC7B,IAAI,WAAW,EAAE,cAAc;IAC/B,IAAI,kBAAkB,EAAE,sBAAsB;IAC9C,CAAC,CAAC;AACF;IACA;IACA,gBAAgB,CAAC,WAAW,GAAG,WAAW,CAAC;AAC3C;IACA;IACA,MAAM,KAAK,GAAG,gBAAgB,CAAC,SAAS,CAAC;AACzC;IACA,KAAK,CAAC,OAAO,GAAG,OAAO,CAAC;IACxB,KAAK,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC1B,KAAK,CAAC,OAAO,GAAG,OAAO,CAAC;AACxB;IACA;AACAC,oBAAa,CAAC,kBAAkB,EAAE,gBAAgB,CAAC;;;;;;;;"}
@@ -0,0 +1 @@
1
+ !function(t,s){"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("@fr0st/ui"),require("@fr0st/query")):"function"==typeof define&&define.amd?define(["exports","@fr0st/ui","@fr0st/query"],s):s((t="undefined"!=typeof globalThis?globalThis:t||self).UI=t.UI||{},t.UI,t.fQuery)}(this,(function(t,s,e){"use strict";class r extends s.BaseComponent{constructor(t,s){super(t,s),this._options.container?this._container=e.findOne(this._options.container):this._container=e.closest(this._node,":not(.form-input):not(.input-group)"),this._render(),this._refresh(),this._events()}dispose(){e.remove(this._progress),e.removeEvent(this._node,"input.ui.passwordstrength"),this._container=null,this._progress=null,this._progressBar=null,super.dispose()}getStrength(){const t=e.getValue(this._node);return this.constructor.getStrength(t)}}function n(t,s){const e=[];let r=[];for(let n=0;n<s.length-1;n++){const o=s[n],i=s[n+1],h=i-o,a=t[o],c=t[i],l=c.charCodeAt(0)-a.charCodeAt(0);1===h&&1===l?(r.length||r.push(a),r.push(c)):r.length&&(e.push(r),r=[])}return r.length&&e.push(r),e}r.defaults={levels:[{score:0,class:"text-bg-danger",text:"Very Weak"},{score:20,class:"text-bg-danger",text:"Weak"},{score:40,class:"text-bg-warning",text:"Normal"},{score:60,class:"text-bg-success",text:"Strong"},{score:80,class:"text-bg-success",text:"Very Strong"}],container:null,striped:!1},r.classes={progress:"progress mt-2",progressBar:"progress-bar",progressBarStriped:"progress-bar-striped"},r.getStrength=function(t){t.match(/^password/i)&&(t=t.substring(8));const s=t.length;let r=0;s&&(r+=6*s);const o=[],i=[],h=[],a=[],c={};for(let e=0;e<s;e++){const s=t[e],r=s.charCodeAt(0);r>=48&&r<=57?h.push(e):r>=65&&r<=90?o.push(e):r>=97&&r<=122?i.push(e):a.push(e),s in c||(c[s]=0),c[s]++}o.length!==s&&i.length!==s&&(o.length&&(r+=s-o.length),i.length&&(r+=s-i.length)),h.length!==s&&(r+=3*h.length),r+=6*a.length;for(const t of[h,a])r+=3*t.filter((t=>t&&t!==s-1)).length;h.length||a.length||(r-=s),o.length||i.length||a.length||(r-=s),a.length||(r-=s);const l=Object.values(c).reduce(((t,s)=>t+s-1),0);if(l>0&&(r-=l),s>=2){const s=t.matchAll(/(.)\1+/g);for(const t of s)r-=3*Math.min(t[0].length,12);const e=t.toLowerCase(),a=n(e,o.concat(i));for(const t of a)t.length>2&&(r-=3*Math.min(t.length-2,16));const c=n(e,h);for(const t of c)t.length>2&&(r-=3*Math.min(t.length-2,16))}return e._clamp(r,0,100)};const o=r.prototype;o._events=function(){e.addEvent(this._node,"input.ui.passwordstrength",(t=>{this._refresh()}))},o._refresh=function(){const t=this.getStrength();let s;for(const e of this._options.levels){if(t<e.score)break;s=e}e.setStyle(this._progressBar,{width:`${t}%`}),e.setAttribute(this._progressBar,{class:this.constructor.classes.progressBar,"aria-valuenow":t}),e.addClass(this._progressBar,s.class),this._options.striped&&e.addClass(this._progressBar,this.constructor.classes.progressBarStriped),s.text&&e.setText(this._progressBar,s.text)},o._render=function(){this._progress=e.create("div",{class:this.constructor.classes.progress}),this._progressBar=e.create("div",{attributes:{role:"progressbar","aria-valuemin":0,"aria-valuemax":100}}),e.append(this._progress,this._progressBar),e.append(this._container,this._progress)},s.initComponent("passwordstrength",r),t.PasswordStrength=r}));
@@ -0,0 +1 @@
1
+ {"version":3,"names":["PasswordStrength","BaseComponent","constructor","node","options","super","this","_options","container","_container","$","findOne","closest","_node","_render","_refresh","_events","dispose","remove","_progress","removeEvent","_progressBar","getStrength","value","getValue","findSequences","string","locations","sequences","sequence","i","length","current","next","distance","char","nextChar","charDistance","charCodeAt","push","defaults","levels","score","class","text","striped","classes","progress","progressBar","progressBarStriped","password","match","substring","upper","lower","numbers","symbols","dictionary","code","list","filter","v","repeats","Object","values","reduce","acc","count","matches","matchAll","Math","min","lowerPassword","toLowerCase","letterSequences","concat","numberSequences","_clamp","proto","prototype","addEvent","_","strength","nextLevel","level","setStyle","width","setAttribute","addClass","setText","create","attributes","role","append","initComponent"],"sources":["../src/password-strength.js","../src/static/helpers.js","../src/index.js","../src/prototype/events.js","../src/prototype/helpers.js","../src/prototype/render.js"],"sourcesContent":["import $ from '@fr0st/query';\nimport { BaseComponent } from '@fr0st/ui';\n\n/**\n * PasswordStrength Class\n * @class\n */\nexport default class PasswordStrength extends BaseComponent {\n /**\n * New PasswordStrength constructor.\n * @param {HTMLElement} node The input node.\n * @param {object} [options] The options to create the PasswordStrength with.\n */\n constructor(node, options) {\n super(node, options);\n\n if (this._options.container) {\n this._container = $.findOne(this._options.container);\n } else {\n this._container = $.closest(this._node, ':not(.form-input):not(.input-group)');\n }\n\n this._render();\n this._refresh();\n this._events();\n }\n\n /**\n * Dispose the PasswordStrength.\n */\n dispose() {\n $.remove(this._progress);\n $.removeEvent(this._node, 'input.ui.passwordstrength');\n\n this._container = null;\n this._progress = null;\n this._progressBar = null;\n\n super.dispose();\n }\n\n /**\n * Get the password strength.\n * @return {number} The password strength. (0, 100)\n */\n getStrength() {\n const value = $.getValue(this._node);\n\n return this.constructor.getStrength(value);\n }\n}\n","import $ from '@fr0st/query';\n\n/**\n * Find character sequences in a string.\n * @param {string} string The input string.\n * @param {array} locations The character locations.\n * @return {array} The character sequences.\n */\nfunction findSequences(string, locations) {\n const sequences = [];\n let sequence = [];\n\n for (let i = 0; i < locations.length - 1; i++) {\n const current = locations[i];\n const next = locations[i + 1];\n const distance = next - current;\n\n const char = string[current];\n const nextChar = string[next];\n const charDistance = nextChar.charCodeAt(0) - char.charCodeAt(0);\n\n if (distance === 1 && charDistance === 1) {\n if (!sequence.length) {\n sequence.push(char);\n }\n sequence.push(nextChar);\n } else if (sequence.length) {\n sequences.push(sequence);\n sequence = [];\n }\n }\n\n if (sequence.length) {\n sequences.push(sequence);\n }\n\n return sequences;\n};\n\n/**\n * Get the strength of a password.\n * @param {string} password The password.\n * @return {number} The password strength.\n */\nexport function getStrength(password) {\n if (password.match(/^password/i)) {\n password = password.substring(8);\n }\n\n const length = password.length;\n\n let score = 0;\n\n if (length) {\n score += length * 6;\n }\n\n const upper = [];\n const lower = [];\n const numbers = [];\n const symbols = [];\n const dictionary = {};\n\n for (let i = 0; i < length; i++) {\n const char = password[i];\n const code = char.charCodeAt(0);\n\n if (code >= 48 && code <= 57) {\n numbers.push(i);\n } else if (code >= 65 && code <= 90) {\n upper.push(i);\n } else if (code >= 97 && code <= 122) {\n lower.push(i);\n } else {\n symbols.push(i);\n }\n\n if (!(char in dictionary)) {\n dictionary[char] = 0;\n }\n\n dictionary[char]++;\n }\n\n // reward upper/lower case\n if (upper.length !== length && lower.length !== length) {\n if (upper.length) {\n score += length - upper.length;\n }\n\n if (lower.length) {\n score += length - lower.length;\n }\n }\n\n // reward numbers\n if (numbers.length !== length) {\n score += numbers.length * 3;\n }\n\n // reward symbols\n score += symbols.length * 6;\n\n // reward inner numbers/symbols\n for (const list of [numbers, symbols]) {\n const reward = list.filter((v) => v && v !== length - 1).length;\n score += reward * 3;\n }\n\n // punish only letters\n if (!numbers.length && !symbols.length) {\n score -= length;\n }\n\n // punish only numbers\n if (!upper.length && !lower.length && !symbols.length) {\n score -= length;\n }\n\n // punish no symbols\n if (!symbols.length) {\n score -= length;\n }\n\n // repeating characters\n const repeats = Object.values(dictionary)\n .reduce((acc, count) => acc + count - 1, 0);\n\n if (repeats > 0) {\n score -= repeats;\n }\n\n if (length >= 2) {\n // consecutive characters\n const matches = password.matchAll(/(.)\\1+/g);\n\n for (const match of matches) {\n score -= Math.min(match[0].length, 12) * 3;\n }\n\n const lowerPassword = password.toLowerCase();\n\n // sequential letters\n const letters = upper.concat(lower);\n const letterSequences = findSequences(lowerPassword, letters);\n for (const sequence of letterSequences) {\n if (sequence.length > 2) {\n score -= (Math.min(sequence.length - 2, 16)) * 3;\n }\n }\n\n // sequential numbers\n const numberSequences = findSequences(lowerPassword, numbers);\n for (const sequence of numberSequences) {\n if (sequence.length > 2) {\n score -= (Math.min(sequence.length - 2, 16)) * 3;\n }\n }\n }\n\n return $._clamp(score, 0, 100);\n};\n","import { initComponent } from '@fr0st/ui';\nimport PasswordStrength from './password-strength.js';\nimport { _events } from './prototype/events.js';\nimport { _refresh } from './prototype/helpers.js';\nimport { _render } from './prototype/render.js';\nimport { getStrength } from './static/helpers.js';\n\n// PasswordStrength default options\nPasswordStrength.defaults = {\n levels: [\n {\n score: 0,\n class: 'text-bg-danger',\n text: 'Very Weak',\n },\n {\n score: 20,\n class: 'text-bg-danger',\n text: 'Weak',\n },\n {\n score: 40,\n class: 'text-bg-warning',\n text: 'Normal',\n },\n {\n score: 60,\n class: 'text-bg-success',\n text: 'Strong',\n },\n {\n score: 80,\n class: 'text-bg-success',\n text: 'Very Strong',\n },\n ],\n container: null,\n striped: false,\n};\n\n// PasswordStrength classes\nPasswordStrength.classes = {\n progress: 'progress mt-2',\n progressBar: 'progress-bar',\n progressBarStriped: 'progress-bar-striped',\n};\n\n// PasswordStrength static\nPasswordStrength.getStrength = getStrength;\n\n// PasswordStrength prototype\nconst proto = PasswordStrength.prototype;\n\nproto._events = _events;\nproto._refresh = _refresh;\nproto._render = _render;\n\n// PasswordStrength init\ninitComponent('passwordstrength', PasswordStrength);\n\nexport default PasswordStrength;\n","import $ from '@fr0st/query';\n\n/**\n * Attach events for the PasswordStrength.\n */\nexport function _events() {\n $.addEvent(this._node, 'input.ui.passwordstrength', (_) => {\n this._refresh();\n });\n};\n","import $ from '@fr0st/query';\n\n/**\n * Refresh the password strength.\n */\nexport function _refresh() {\n const strength = this.getStrength();\n\n let nextLevel;\n for (const level of this._options.levels) {\n if (strength < level.score) {\n break;\n }\n\n nextLevel = level;\n }\n\n $.setStyle(this._progressBar, { width: `${strength}%` });\n $.setAttribute(this._progressBar, {\n class: this.constructor.classes.progressBar,\n 'aria-valuenow': strength,\n });\n\n $.addClass(this._progressBar, nextLevel.class);\n\n if (this._options.striped) {\n $.addClass(this._progressBar, this.constructor.classes.progressBarStriped);\n }\n\n if (nextLevel.text) {\n $.setText(this._progressBar, nextLevel.text);\n }\n};\n","import $ from '@fr0st/query';\n\n/**\n * Render the password strength element.\n */\nexport function _render() {\n this._progress = $.create('div', {\n class: this.constructor.classes.progress,\n });\n\n this._progressBar = $.create('div', {\n attributes: {\n 'role': 'progressbar',\n 'aria-valuemin': 0,\n 'aria-valuemax': 100,\n },\n });\n\n $.append(this._progress, this._progressBar);\n $.append(this._container, this._progress);\n};\n"],"mappings":"0UAOe,MAAMA,UAAyBC,gBAM1CC,YAAYC,EAAMC,GACdC,MAAMF,EAAMC,GAERE,KAAKC,SAASC,UACdF,KAAKG,WAAaC,EAAEC,QAAQL,KAAKC,SAASC,WAE1CF,KAAKG,WAAaC,EAAEE,QAAQN,KAAKO,MAAO,uCAG5CP,KAAKQ,UACLR,KAAKS,WACLT,KAAKU,SACb,CAKIC,UACIP,EAAEQ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OAIzBlF,EAAEmF,OAAOvF,KAAKa,UAAWb,KAAKe,cAC9BX,EAAEmF,OAAOvF,KAAKG,WAAYH,KAAKa,UACnC,EHsCA2E,gBAAc,mBAAoB9F,G"}
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@fr0st/ui-passwordstrength",
3
+ "version": "2.0.0",
4
+ "description": "FrostUI-PasswordStrength is a free, open-source Password Strength component for Javascript.",
5
+ "keywords": [
6
+ "ui",
7
+ "component",
8
+ "password",
9
+ "strength",
10
+ "front-end",
11
+ "web"
12
+ ],
13
+ "homepage": "https://github.com/elusivecodes/FrostUI-PasswordStrength",
14
+ "bugs": {
15
+ "url": "https://github.com/elusivecodes/FrostUI-PasswordStrength/issues",
16
+ "email": "elusivecodes@gmail.com"
17
+ },
18
+ "main": "src/index.js",
19
+ "type": "module",
20
+ "files": [
21
+ "dist",
22
+ "/LICENSE",
23
+ "/README.md",
24
+ "src"
25
+ ],
26
+ "scripts": {
27
+ "build": "npm run js-compile && npm run js-minify",
28
+ "js-compile": "rollup --config",
29
+ "js-lint": "eslint --ext .js .",
30
+ "js-minify": "terser --compress passes=2 --mangle --source-map \"content=dist/frost-ui-passwordstrength.js.map\" --output dist/frost-ui-passwordstrength.min.js dist/frost-ui-passwordstrength.js"
31
+ },
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "https://github.com/elusivecodes/FrostUI-PasswordStrength.git"
35
+ },
36
+ "author": "Elusive",
37
+ "license": "MIT",
38
+ "private": false,
39
+ "devDependencies": {
40
+ "@rollup/plugin-node-resolve": "^15.0.2",
41
+ "eslint": "^8.41.0",
42
+ "eslint-config-google": "^0.14.0",
43
+ "rollup": "^3.23.0",
44
+ "terser": "^5.17.6"
45
+ }
46
+ }
package/src/index.js ADDED
@@ -0,0 +1,61 @@
1
+ import { initComponent } from '@fr0st/ui';
2
+ import PasswordStrength from './password-strength.js';
3
+ import { _events } from './prototype/events.js';
4
+ import { _refresh } from './prototype/helpers.js';
5
+ import { _render } from './prototype/render.js';
6
+ import { getStrength } from './static/helpers.js';
7
+
8
+ // PasswordStrength default options
9
+ PasswordStrength.defaults = {
10
+ levels: [
11
+ {
12
+ score: 0,
13
+ class: 'text-bg-danger',
14
+ text: 'Very Weak',
15
+ },
16
+ {
17
+ score: 20,
18
+ class: 'text-bg-danger',
19
+ text: 'Weak',
20
+ },
21
+ {
22
+ score: 40,
23
+ class: 'text-bg-warning',
24
+ text: 'Normal',
25
+ },
26
+ {
27
+ score: 60,
28
+ class: 'text-bg-success',
29
+ text: 'Strong',
30
+ },
31
+ {
32
+ score: 80,
33
+ class: 'text-bg-success',
34
+ text: 'Very Strong',
35
+ },
36
+ ],
37
+ container: null,
38
+ striped: false,
39
+ };
40
+
41
+ // PasswordStrength classes
42
+ PasswordStrength.classes = {
43
+ progress: 'progress mt-2',
44
+ progressBar: 'progress-bar',
45
+ progressBarStriped: 'progress-bar-striped',
46
+ };
47
+
48
+ // PasswordStrength static
49
+ PasswordStrength.getStrength = getStrength;
50
+
51
+ // PasswordStrength prototype
52
+ const proto = PasswordStrength.prototype;
53
+
54
+ proto._events = _events;
55
+ proto._refresh = _refresh;
56
+ proto._render = _render;
57
+
58
+ // PasswordStrength init
59
+ initComponent('passwordstrength', PasswordStrength);
60
+
61
+ export default PasswordStrength;
@@ -0,0 +1,51 @@
1
+ import $ from '@fr0st/query';
2
+ import { BaseComponent } from '@fr0st/ui';
3
+
4
+ /**
5
+ * PasswordStrength Class
6
+ * @class
7
+ */
8
+ export default class PasswordStrength extends BaseComponent {
9
+ /**
10
+ * New PasswordStrength constructor.
11
+ * @param {HTMLElement} node The input node.
12
+ * @param {object} [options] The options to create the PasswordStrength with.
13
+ */
14
+ constructor(node, options) {
15
+ super(node, options);
16
+
17
+ if (this._options.container) {
18
+ this._container = $.findOne(this._options.container);
19
+ } else {
20
+ this._container = $.closest(this._node, ':not(.form-input):not(.input-group)');
21
+ }
22
+
23
+ this._render();
24
+ this._refresh();
25
+ this._events();
26
+ }
27
+
28
+ /**
29
+ * Dispose the PasswordStrength.
30
+ */
31
+ dispose() {
32
+ $.remove(this._progress);
33
+ $.removeEvent(this._node, 'input.ui.passwordstrength');
34
+
35
+ this._container = null;
36
+ this._progress = null;
37
+ this._progressBar = null;
38
+
39
+ super.dispose();
40
+ }
41
+
42
+ /**
43
+ * Get the password strength.
44
+ * @return {number} The password strength. (0, 100)
45
+ */
46
+ getStrength() {
47
+ const value = $.getValue(this._node);
48
+
49
+ return this.constructor.getStrength(value);
50
+ }
51
+ }
@@ -0,0 +1,10 @@
1
+ import $ from '@fr0st/query';
2
+
3
+ /**
4
+ * Attach events for the PasswordStrength.
5
+ */
6
+ export function _events() {
7
+ $.addEvent(this._node, 'input.ui.passwordstrength', (_) => {
8
+ this._refresh();
9
+ });
10
+ };
@@ -0,0 +1,33 @@
1
+ import $ from '@fr0st/query';
2
+
3
+ /**
4
+ * Refresh the password strength.
5
+ */
6
+ export function _refresh() {
7
+ const strength = this.getStrength();
8
+
9
+ let nextLevel;
10
+ for (const level of this._options.levels) {
11
+ if (strength < level.score) {
12
+ break;
13
+ }
14
+
15
+ nextLevel = level;
16
+ }
17
+
18
+ $.setStyle(this._progressBar, { width: `${strength}%` });
19
+ $.setAttribute(this._progressBar, {
20
+ class: this.constructor.classes.progressBar,
21
+ 'aria-valuenow': strength,
22
+ });
23
+
24
+ $.addClass(this._progressBar, nextLevel.class);
25
+
26
+ if (this._options.striped) {
27
+ $.addClass(this._progressBar, this.constructor.classes.progressBarStriped);
28
+ }
29
+
30
+ if (nextLevel.text) {
31
+ $.setText(this._progressBar, nextLevel.text);
32
+ }
33
+ };
@@ -0,0 +1,21 @@
1
+ import $ from '@fr0st/query';
2
+
3
+ /**
4
+ * Render the password strength element.
5
+ */
6
+ export function _render() {
7
+ this._progress = $.create('div', {
8
+ class: this.constructor.classes.progress,
9
+ });
10
+
11
+ this._progressBar = $.create('div', {
12
+ attributes: {
13
+ 'role': 'progressbar',
14
+ 'aria-valuemin': 0,
15
+ 'aria-valuemax': 100,
16
+ },
17
+ });
18
+
19
+ $.append(this._progress, this._progressBar);
20
+ $.append(this._container, this._progress);
21
+ };
@@ -0,0 +1,162 @@
1
+ import $ from '@fr0st/query';
2
+
3
+ /**
4
+ * Find character sequences in a string.
5
+ * @param {string} string The input string.
6
+ * @param {array} locations The character locations.
7
+ * @return {array} The character sequences.
8
+ */
9
+ function findSequences(string, locations) {
10
+ const sequences = [];
11
+ let sequence = [];
12
+
13
+ for (let i = 0; i < locations.length - 1; i++) {
14
+ const current = locations[i];
15
+ const next = locations[i + 1];
16
+ const distance = next - current;
17
+
18
+ const char = string[current];
19
+ const nextChar = string[next];
20
+ const charDistance = nextChar.charCodeAt(0) - char.charCodeAt(0);
21
+
22
+ if (distance === 1 && charDistance === 1) {
23
+ if (!sequence.length) {
24
+ sequence.push(char);
25
+ }
26
+ sequence.push(nextChar);
27
+ } else if (sequence.length) {
28
+ sequences.push(sequence);
29
+ sequence = [];
30
+ }
31
+ }
32
+
33
+ if (sequence.length) {
34
+ sequences.push(sequence);
35
+ }
36
+
37
+ return sequences;
38
+ };
39
+
40
+ /**
41
+ * Get the strength of a password.
42
+ * @param {string} password The password.
43
+ * @return {number} The password strength.
44
+ */
45
+ export function getStrength(password) {
46
+ if (password.match(/^password/i)) {
47
+ password = password.substring(8);
48
+ }
49
+
50
+ const length = password.length;
51
+
52
+ let score = 0;
53
+
54
+ if (length) {
55
+ score += length * 6;
56
+ }
57
+
58
+ const upper = [];
59
+ const lower = [];
60
+ const numbers = [];
61
+ const symbols = [];
62
+ const dictionary = {};
63
+
64
+ for (let i = 0; i < length; i++) {
65
+ const char = password[i];
66
+ const code = char.charCodeAt(0);
67
+
68
+ if (code >= 48 && code <= 57) {
69
+ numbers.push(i);
70
+ } else if (code >= 65 && code <= 90) {
71
+ upper.push(i);
72
+ } else if (code >= 97 && code <= 122) {
73
+ lower.push(i);
74
+ } else {
75
+ symbols.push(i);
76
+ }
77
+
78
+ if (!(char in dictionary)) {
79
+ dictionary[char] = 0;
80
+ }
81
+
82
+ dictionary[char]++;
83
+ }
84
+
85
+ // reward upper/lower case
86
+ if (upper.length !== length && lower.length !== length) {
87
+ if (upper.length) {
88
+ score += length - upper.length;
89
+ }
90
+
91
+ if (lower.length) {
92
+ score += length - lower.length;
93
+ }
94
+ }
95
+
96
+ // reward numbers
97
+ if (numbers.length !== length) {
98
+ score += numbers.length * 3;
99
+ }
100
+
101
+ // reward symbols
102
+ score += symbols.length * 6;
103
+
104
+ // reward inner numbers/symbols
105
+ for (const list of [numbers, symbols]) {
106
+ const reward = list.filter((v) => v && v !== length - 1).length;
107
+ score += reward * 3;
108
+ }
109
+
110
+ // punish only letters
111
+ if (!numbers.length && !symbols.length) {
112
+ score -= length;
113
+ }
114
+
115
+ // punish only numbers
116
+ if (!upper.length && !lower.length && !symbols.length) {
117
+ score -= length;
118
+ }
119
+
120
+ // punish no symbols
121
+ if (!symbols.length) {
122
+ score -= length;
123
+ }
124
+
125
+ // repeating characters
126
+ const repeats = Object.values(dictionary)
127
+ .reduce((acc, count) => acc + count - 1, 0);
128
+
129
+ if (repeats > 0) {
130
+ score -= repeats;
131
+ }
132
+
133
+ if (length >= 2) {
134
+ // consecutive characters
135
+ const matches = password.matchAll(/(.)\1+/g);
136
+
137
+ for (const match of matches) {
138
+ score -= Math.min(match[0].length, 12) * 3;
139
+ }
140
+
141
+ const lowerPassword = password.toLowerCase();
142
+
143
+ // sequential letters
144
+ const letters = upper.concat(lower);
145
+ const letterSequences = findSequences(lowerPassword, letters);
146
+ for (const sequence of letterSequences) {
147
+ if (sequence.length > 2) {
148
+ score -= (Math.min(sequence.length - 2, 16)) * 3;
149
+ }
150
+ }
151
+
152
+ // sequential numbers
153
+ const numberSequences = findSequences(lowerPassword, numbers);
154
+ for (const sequence of numberSequences) {
155
+ if (sequence.length > 2) {
156
+ score -= (Math.min(sequence.length - 2, 16)) * 3;
157
+ }
158
+ }
159
+ }
160
+
161
+ return $._clamp(score, 0, 100);
162
+ };
package/src/wrapper.js ADDED
@@ -0,0 +1,3 @@
1
+ import PasswordStrength from './index.js';
2
+
3
+ export { PasswordStrength };