@enso-ui/auth 3.1.8 → 3.1.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enso-ui/auth",
3
- "version": "3.1.8",
3
+ "version": "3.1.9",
4
4
  "description": "UI auth package",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -12,13 +12,22 @@
12
12
  height="4"
13
13
  stroke-width="4"
14
14
  :x="x(i)"
15
- :stroke="i <= score() + 1 ? 'green' : 'orangered'"/>
15
+ :stroke="i <= scoreValue + 1 ? 'green' : 'orangered'"/>
16
16
  </svg>
17
17
  </transition>
18
18
  </template>
19
19
 
20
20
  <script>
21
- import zxcvbn from 'zxcvbn';
21
+ let zxcvbnPromise;
22
+
23
+ const getZxcvbn = async () => {
24
+ if (!zxcvbnPromise) {
25
+ zxcvbnPromise = import('zxcvbn')
26
+ .then(({ default: zxcvbn }) => zxcvbn);
27
+ }
28
+
29
+ return zxcvbnPromise;
30
+ };
22
31
 
23
32
  export default {
24
33
  name: 'PasswordStrength',
@@ -30,12 +39,26 @@ export default {
30
39
  },
31
40
  },
32
41
 
33
- methods: {
34
- score() {
35
- return this.password
36
- ? zxcvbn(this.password).score
37
- : 6;
42
+ data: () => ({
43
+ scoreValue: 0,
44
+ }),
45
+
46
+ watch: {
47
+ password: {
48
+ immediate: true,
49
+ async handler(password) {
50
+ if (!password) {
51
+ this.scoreValue = 0;
52
+ return;
53
+ }
54
+
55
+ const zxcvbn = await getZxcvbn();
56
+ this.scoreValue = zxcvbn(password).score;
57
+ },
38
58
  },
59
+ },
60
+
61
+ methods: {
39
62
  x(i) {
40
63
  const x = 2.5 + (i - 1) * 15 + (i - 1) * 5;
41
64
  return `${x}%`;