@iamproperty/components 5.1.0-beta10 → 5.1.0-beta11

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.
Files changed (39) hide show
  1. package/assets/css/components/component.reset.css +1 -1
  2. package/assets/css/components/component.reset.css.map +1 -1
  3. package/assets/css/core.min.css +1 -1
  4. package/assets/css/core.min.css.map +1 -1
  5. package/assets/css/style.min.css +1 -1
  6. package/assets/css/style.min.css.map +1 -1
  7. package/assets/js/components/accordion/accordion.component.min.js +1 -1
  8. package/assets/js/components/actionbar/actionbar.component.min.js +1 -1
  9. package/assets/js/components/address-lookup/address-lookup.component.min.js +1 -1
  10. package/assets/js/components/applied-filters/applied-filters.component.min.js +1 -1
  11. package/assets/js/components/card/card.component.min.js +1 -1
  12. package/assets/js/components/collapsible-side/collapsible-side.component.min.js +1 -1
  13. package/assets/js/components/fileupload/fileupload.component.min.js +1 -1
  14. package/assets/js/components/filterlist/filterlist.component.min.js +1 -1
  15. package/assets/js/components/header/header.component.min.js +1 -1
  16. package/assets/js/components/nav/nav.component.min.js +1 -1
  17. package/assets/js/components/notification/notification.component.min.js +1 -1
  18. package/assets/js/components/pagination/pagination.component.min.js +1 -1
  19. package/assets/js/components/search/search.component.min.js +1 -1
  20. package/assets/js/components/search/search.component.min.js.map +1 -1
  21. package/assets/js/components/table/table.component.min.js +1 -1
  22. package/assets/js/components/table/table.component.min.js.map +1 -1
  23. package/assets/js/components/tabs/tabs.component.min.js +1 -1
  24. package/assets/js/dynamic.min.js +5 -4
  25. package/assets/js/dynamic.min.js.map +1 -1
  26. package/assets/js/modules/helpers.js +5 -1
  27. package/assets/js/modules/inputs.js +57 -0
  28. package/assets/js/scripts.bundle.js +32 -31
  29. package/assets/js/scripts.bundle.js.map +1 -1
  30. package/assets/js/scripts.bundle.min.js +2 -2
  31. package/assets/js/scripts.bundle.min.js.map +1 -1
  32. package/assets/js/vendor/hibp.js +78 -0
  33. package/assets/sass/elements/forms.scss +19 -0
  34. package/assets/ts/modules/helpers.ts +6 -1
  35. package/assets/ts/modules/inputs.ts +79 -0
  36. package/assets/ts/vendor/hibp.ts +81 -0
  37. package/dist/components.es.js +11 -11
  38. package/dist/components.umd.js +11 -11
  39. package/package.json +1 -1
@@ -0,0 +1,78 @@
1
+ // @ts-nocheck
2
+ /**
3
+ * hibp.js
4
+ * @version v1
5
+ * @author Mehdi Bounya
6
+ *
7
+ * Report any bugs here: https://github.com/mehdibo/hibp-js
8
+ *
9
+ * The MIT License (http://www.opensource.org/licenses/mit-license.php)
10
+ *
11
+ * Permission is hereby granted, free of charge, to any person
12
+ * obtaining a copy of this software and associated documentation
13
+ * files (the "Software"), to deal in the Software without
14
+ * restriction, including without limitation the rights to use,
15
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ * copies of the Software, and to permit persons to whom the
17
+ * Software is furnished to do so, subject to the following
18
+ * conditions:
19
+ *
20
+ * The above copyright notice and this permission notice shall be
21
+ * included in all copies or substantial portions of the Software.
22
+ *
23
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
25
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
27
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
28
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
30
+ * OTHER DEALINGS IN THE SOFTWARE.
31
+ */
32
+ function sha1(string) {
33
+ var buffer = new TextEncoder("utf-8").encode(string);
34
+ return crypto.subtle.digest("SHA-1", buffer).then(function (buffer) {
35
+ // Get the hex code
36
+ var hexCodes = [];
37
+ var view = new DataView(buffer);
38
+ for (var i = 0; i < view.byteLength; i += 4) {
39
+ // Using getUint32 reduces the number of iterations needed (we process 4 bytes each time)
40
+ var value = view.getUint32(i);
41
+ // toString(16) will give the hex representation of the number without padding
42
+ var stringValue = value.toString(16);
43
+ // We use concatenation and slice for padding
44
+ var padding = '00000000';
45
+ var paddedValue = (padding + stringValue).slice(-padding.length);
46
+ hexCodes.push(paddedValue);
47
+ }
48
+ // Join all the hex strings into one
49
+ return hexCodes.join("");
50
+ });
51
+ }
52
+ const hibpCheck = (pwd, input) => {
53
+ // We hash the pwd first
54
+ sha1(pwd).then(function (hash) {
55
+ // We send the first 5 chars of the hash to hibp's API
56
+ const req = new XMLHttpRequest();
57
+ req.addEventListener("load", function () {
58
+ // When we get back a response from the server
59
+ // We create an array of lines and loop through them
60
+ const resp = this.responseText.split('\n');
61
+ const hashSub = hash.slice(5).toUpperCase();
62
+ var result = false;
63
+ for (let index in resp) {
64
+ // Check if the line matches the rest of the hash
65
+ if (resp[index].substring(0, 35) == hashSub) {
66
+ result = true;
67
+ break; // If found no need to continue the loop
68
+ }
69
+ }
70
+ // Trigger an event with the result
71
+ const event = new CustomEvent('hibpCheck', { detail: result });
72
+ input.dispatchEvent(event);
73
+ });
74
+ req.open('GET', 'https://api.pwnedpasswords.com/range/' + hash.substr(0, 5));
75
+ req.send();
76
+ });
77
+ };
78
+ export default hibpCheck;
@@ -410,6 +410,25 @@ iam-address-lookup:has([required]){
410
410
  --error-display: block;
411
411
  }
412
412
 
413
+ // Password checker
414
+ .pwd-checker {
415
+
416
+ display: block;
417
+ background-repeat: no-repeat!important;
418
+ background-position: left center;
419
+ background-size: 1em 1em;
420
+ padding-left: 1.5rem!important;
421
+ }
422
+ .pwd-checker.invalid-feedback {
423
+ background-image: escape-svg($icon-error);
424
+ }
425
+
426
+ .pwd-checker:not(.invalid-feedback) {
427
+ background-image: escape-svg($icon-tick)!important;
428
+ }
429
+ label:has(.pwd-checker.invalid-feedback):after {
430
+ display: none!important;
431
+ }
413
432
  // #endregion
414
433
 
415
434
  // #region radio/checkbox field
@@ -66,7 +66,12 @@ export const addGlobalEvents = (body) => {
66
66
 
67
67
  let form = event.target;
68
68
 
69
- if(form.querySelector(':invalid')){
69
+ // Reset password types
70
+ Array.from(form.querySelectorAll('[data-password-type]')).forEach((input,index) => {
71
+ input.setAttribute('type','password');
72
+ });
73
+
74
+ if(form.querySelector(':invalid') || form.querySelector('.pwd-checker[data-strength="1"]') || form.querySelector('.pwd-checker[data-strength="2"]')){
70
75
 
71
76
  form.classList.add('was-validated');
72
77
  event.preventDefault();
@@ -1,4 +1,6 @@
1
1
  // @ts-nocheck
2
+ import hibpCheck from '../vendor/hibp'
3
+
2
4
  const extendInputs = (body) => {
3
5
 
4
6
  function loadInput(){
@@ -79,6 +81,10 @@ const extendInputs = (body) => {
79
81
 
80
82
  if(input.hasAttribute('maxlength') && input.nextElementSibling)
81
83
  input.nextElementSibling.setAttribute("data-count", input.value.length);
84
+
85
+
86
+ if(input.hasAttribute('data-strength-checker'))
87
+ checkPWDStrength(input);
82
88
  }
83
89
  });
84
90
 
@@ -151,7 +157,80 @@ export const setMaxlengthVars = (input) => {
151
157
 
152
158
  export const changeType = (input,type) => {
153
159
 
160
+ if(input.hasAttribute('type') && input.getAttribute('type') == 'password')
161
+ input.setAttribute('data-password-type',true);
162
+
154
163
  input.setAttribute('type',type);
155
164
  }
156
165
 
166
+ export const checkPWDStrength = (input, check = 'no') => {
167
+
168
+ const pwdChecker = document.getElementById(input.getAttribute('data-strength-checker'))
169
+ const password = input.value;
170
+ const minChars = input.hasAttribute('minlength') ? input.getAttribute('minlength') : 12;
171
+
172
+ let strength = 1;
173
+ let strengthName = ['Very weak', 'Weak', 'Average', 'Strong', 'Very strong'];
174
+ let extraMsg = '';
175
+
176
+ //has number
177
+ if (password.match(/(?=.*[0-9])/))
178
+ strength += 1;
179
+ // has special character
180
+ if (password.match(/(?=.*[!,%,&,#,$,^,*,?,_,~,<,>,])/))
181
+ strength += 1;
182
+ // has lowercase alpha
183
+ if (password.match(/(?=.*[a-z])/))
184
+ strength += 1;
185
+ // has uppercase alpha
186
+ if (password.match(/(?=.*[A-Z])/))
187
+ strength += 1;
188
+
189
+ if (password.length < minChars){
190
+ strength = 1;
191
+ extraMsg = `(must be at least ${minChars} characters.)`;
192
+ }
193
+
194
+
195
+ // if the strength is above weak and above the minimum length do some kind of api call to check if its in a list of passwords
196
+
197
+ if(strength >= 3 && check == 'no'){
198
+ hibpCheck(password,input);
199
+
200
+
201
+ input.addEventListener('hibpCheck', function (event) {
202
+ checkhibpCheck(event, input)
203
+ });
204
+
205
+ function checkhibpCheck(event, input){
206
+
207
+ if(event.detail){ // found
208
+ checkPWDStrength(input,'danger');
209
+ } else { // not found
210
+ checkPWDStrength(input,'success');
211
+ }
212
+
213
+ input.removeEventListener("hibpCheck", checkhibpCheck); // Succeeds
214
+ }
215
+
216
+ }
217
+ else if(strength >= 3 && check == 'danger'){
218
+ strength = 3;
219
+ extraMsg = `(this password is very common)`;
220
+ }
221
+
222
+
223
+ if(pwdChecker){
224
+ if(strength <= 3)
225
+ pwdChecker.classList.add('invalid-feedback');
226
+ else
227
+ pwdChecker.classList.remove('invalid-feedback');
228
+
229
+ pwdChecker.setAttribute('data-strength',strength)
230
+ pwdChecker.innerHTML = `Password strength: ${strengthName[strength-1]} ${extraMsg}`;
231
+ }
232
+
233
+ }
234
+
235
+
157
236
  export default extendInputs;
@@ -0,0 +1,81 @@
1
+ // @ts-nocheck
2
+
3
+ /**
4
+ * hibp.js
5
+ * @version v1
6
+ * @author Mehdi Bounya
7
+ *
8
+ * Report any bugs here: https://github.com/mehdibo/hibp-js
9
+ *
10
+ * The MIT License (http://www.opensource.org/licenses/mit-license.php)
11
+ *
12
+ * Permission is hereby granted, free of charge, to any person
13
+ * obtaining a copy of this software and associated documentation
14
+ * files (the "Software"), to deal in the Software without
15
+ * restriction, including without limitation the rights to use,
16
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
17
+ * copies of the Software, and to permit persons to whom the
18
+ * Software is furnished to do so, subject to the following
19
+ * conditions:
20
+ *
21
+ * The above copyright notice and this permission notice shall be
22
+ * included in all copies or substantial portions of the Software.
23
+ *
24
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
26
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
28
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
29
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
30
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
31
+ * OTHER DEALINGS IN THE SOFTWARE.
32
+ */
33
+ function sha1(string){
34
+ var buffer = new TextEncoder("utf-8").encode(string);
35
+ return crypto.subtle.digest("SHA-1", buffer).then(function (buffer) {
36
+ // Get the hex code
37
+ var hexCodes = [];
38
+ var view = new DataView(buffer);
39
+ for (var i = 0; i < view.byteLength; i += 4) {
40
+ // Using getUint32 reduces the number of iterations needed (we process 4 bytes each time)
41
+ var value = view.getUint32(i)
42
+ // toString(16) will give the hex representation of the number without padding
43
+ var stringValue = value.toString(16)
44
+ // We use concatenation and slice for padding
45
+ var padding = '00000000'
46
+ var paddedValue = (padding + stringValue).slice(-padding.length)
47
+ hexCodes.push(paddedValue);
48
+ }
49
+ // Join all the hex strings into one
50
+ return hexCodes.join("");
51
+ });
52
+ }
53
+
54
+ const hibpCheck = (pwd,input) => {
55
+ // We hash the pwd first
56
+ sha1(pwd).then(function(hash){
57
+ // We send the first 5 chars of the hash to hibp's API
58
+ const req = new XMLHttpRequest();
59
+ req.addEventListener("load", function(){
60
+ // When we get back a response from the server
61
+ // We create an array of lines and loop through them
62
+ const resp = this.responseText.split('\n');
63
+ const hashSub = hash.slice(5).toUpperCase();
64
+ var result = false;
65
+ for(let index in resp){
66
+ // Check if the line matches the rest of the hash
67
+ if(resp[index].substring(0, 35) == hashSub){
68
+ result = true;
69
+ break; // If found no need to continue the loop
70
+ }
71
+ }
72
+ // Trigger an event with the result
73
+ const event = new CustomEvent('hibpCheck', {detail: result});
74
+ input.dispatchEvent(event);
75
+ });
76
+ req.open('GET', 'https://api.pwnedpasswords.com/range/'+hash.substr(0, 5));
77
+ req.send();
78
+ });
79
+ }
80
+
81
+ export default hibpCheck;
@@ -48,7 +48,7 @@ function vt(e, a, t, i, s, o) {
48
48
  }
49
49
  const Li = /* @__PURE__ */ y(gt, [["render", vt]]);
50
50
  /*!
51
- * iamKey v5.1.0-beta10
51
+ * iamKey v5.1.0-beta11
52
52
  * Copyright 2022-2023 iamproperty
53
53
  */
54
54
  const _t = function(e) {
@@ -557,7 +557,7 @@ class Mt extends HTMLElement {
557
557
  }
558
558
  }
559
559
  /*!
560
- * iamKey v5.1.0-beta10
560
+ * iamKey v5.1.0-beta11
561
561
  * Copyright 2022-2023 iamproperty
562
562
  */
563
563
  class ot extends HTMLElement {
@@ -1152,7 +1152,7 @@ const be = {
1152
1152
  props: {},
1153
1153
  mounted() {
1154
1154
  this.$nextTick(function() {
1155
- N(/* @__PURE__ */ Object.assign({ "../../../assets/js/components/accordion/accordion.component.js": () => import("./accordion.component-bd9af0d7.mjs"), "../../../assets/js/components/accordion/accordion.component.min.js": () => import("./accordion.component.min-7e34686c.mjs") }), "../../../assets/js/components/accordion/accordion.component.js").then((e) => {
1155
+ N(/* @__PURE__ */ Object.assign({ "../../../assets/js/components/accordion/accordion.component.js": () => import("./accordion.component-bd9af0d7.mjs"), "../../../assets/js/components/accordion/accordion.component.min.js": () => import("./accordion.component.min-915d29dd.mjs") }), "../../../assets/js/components/accordion/accordion.component.js").then((e) => {
1156
1156
  window.customElements.get("iam-accordion") || window.customElements.define("iam-accordion", e.default);
1157
1157
  }).catch((e) => {
1158
1158
  console.log(e.message);
@@ -1263,7 +1263,7 @@ const Ei = /* @__PURE__ */ y(xe, [["render", Ee]]), Te = {
1263
1263
  name: "Card",
1264
1264
  mounted() {
1265
1265
  this.$nextTick(function() {
1266
- N(/* @__PURE__ */ Object.assign({ "../../../assets/js/components/card/card.component.js": () => import("./card.component-3bb86b22.mjs"), "../../../assets/js/components/card/card.component.min.js": () => import("./card.component.min-9db932b7.mjs") }), "../../../assets/js/components/card/card.component.js").then((e) => {
1266
+ N(/* @__PURE__ */ Object.assign({ "../../../assets/js/components/card/card.component.js": () => import("./card.component-3bb86b22.mjs"), "../../../assets/js/components/card/card.component.min.js": () => import("./card.component.min-fd3b7162.mjs") }), "../../../assets/js/components/card/card.component.js").then((e) => {
1267
1267
  window.customElements.get("iam-card") || window.customElements.define("iam-card", e.default);
1268
1268
  }).catch((e) => {
1269
1269
  console.log(e.message);
@@ -1317,7 +1317,7 @@ const Hi = /* @__PURE__ */ y(Me, [["render", je]]), Ce = {
1317
1317
  },
1318
1318
  mounted() {
1319
1319
  this.$nextTick(function() {
1320
- N(/* @__PURE__ */ Object.assign({ "../../../assets/js/components/header/header.component.js": () => import("./header.component-cc8263fb.mjs"), "../../../assets/js/components/header/header.component.min.js": () => import("./header.component.min-71c8b950.mjs") }), "../../../assets/js/components/header/header.component.js").then((e) => {
1320
+ N(/* @__PURE__ */ Object.assign({ "../../../assets/js/components/header/header.component.js": () => import("./header.component-cc8263fb.mjs"), "../../../assets/js/components/header/header.component.min.js": () => import("./header.component.min-e7e9db8c.mjs") }), "../../../assets/js/components/header/header.component.js").then((e) => {
1321
1321
  window.customElements.get("iam-header") || window.customElements.define("iam-header", e.default);
1322
1322
  }).catch((e) => {
1323
1323
  console.log(e.message);
@@ -1713,7 +1713,7 @@ const Di = /* @__PURE__ */ y(oa, [["render", ya]]), wa = {
1713
1713
  name: "Nav",
1714
1714
  mounted() {
1715
1715
  this.$nextTick(function() {
1716
- N(/* @__PURE__ */ Object.assign({ "../../../assets/js/components/nav/nav.component.js": () => import("./nav.component-ff8d1484.mjs"), "../../../assets/js/components/nav/nav.component.min.js": () => import("./nav.component.min-1df4a8b8.mjs") }), "../../../assets/js/components/nav/nav.component.js").then((e) => {
1716
+ N(/* @__PURE__ */ Object.assign({ "../../../assets/js/components/nav/nav.component.js": () => import("./nav.component-ff8d1484.mjs"), "../../../assets/js/components/nav/nav.component.min.js": () => import("./nav.component.min-b6b9ead5.mjs") }), "../../../assets/js/components/nav/nav.component.js").then((e) => {
1717
1717
  window.customElements.get("iam-nav") || window.customElements.define("iam-nav", e.default);
1718
1718
  }).catch((e) => {
1719
1719
  console.log(e.message);
@@ -1833,7 +1833,7 @@ const Pa = {
1833
1833
  name: "Tabs",
1834
1834
  mounted() {
1835
1835
  this.$nextTick(function() {
1836
- N(/* @__PURE__ */ Object.assign({ "../../../assets/js/components/tabs/tabs.component.js": () => import("./tabs.component-1dfbdb3b.mjs"), "../../../assets/js/components/tabs/tabs.component.min.js": () => import("./tabs.component.min-8dcdde59.mjs") }), "../../../assets/js/components/tabs/tabs.component.js").then((e) => {
1836
+ N(/* @__PURE__ */ Object.assign({ "../../../assets/js/components/tabs/tabs.component.js": () => import("./tabs.component-1dfbdb3b.mjs"), "../../../assets/js/components/tabs/tabs.component.min.js": () => import("./tabs.component.min-d390ff06.mjs") }), "../../../assets/js/components/tabs/tabs.component.js").then((e) => {
1837
1837
  window.customElements.get("iam-tabs") || window.customElements.define("iam-tabs", e.default);
1838
1838
  }).catch((e) => {
1839
1839
  console.log(e.message);
@@ -1963,7 +1963,7 @@ function Za(e, a, t, i, s, o) {
1963
1963
  }
1964
1964
  const Oi = /* @__PURE__ */ y(Ka, [["render", Za]]);
1965
1965
  /*!
1966
- * iamKey v5.1.0-beta10
1966
+ * iamKey v5.1.0-beta11
1967
1967
  * Copyright 2022-2023 iamproperty
1968
1968
  */
1969
1969
  function ti(e, a) {
@@ -2059,7 +2059,7 @@ function ii(e, a, t, i, s, o) {
2059
2059
  }
2060
2060
  const Bi = /* @__PURE__ */ y(ai, [["render", ii]]);
2061
2061
  /*!
2062
- * iamKey v5.1.0-beta10
2062
+ * iamKey v5.1.0-beta11
2063
2063
  * Copyright 2022-2023 iamproperty
2064
2064
  */
2065
2065
  function ni(e, a) {
@@ -2229,7 +2229,7 @@ const Vi = /* @__PURE__ */ y(mi, [["render", hi]]), pi = {
2229
2229
  props: {},
2230
2230
  mounted() {
2231
2231
  this.$nextTick(function() {
2232
- N(/* @__PURE__ */ Object.assign({ "../../../assets/js/components/actionbar/actionbar.component.js": () => import("./actionbar.component-3f2c98c0.mjs"), "../../../assets/js/components/actionbar/actionbar.component.min.js": () => import("./actionbar.component.min-e086512b.mjs") }), "../../../assets/js/components/actionbar/actionbar.component.js").then((e) => {
2232
+ N(/* @__PURE__ */ Object.assign({ "../../../assets/js/components/actionbar/actionbar.component.js": () => import("./actionbar.component-3f2c98c0.mjs"), "../../../assets/js/components/actionbar/actionbar.component.min.js": () => import("./actionbar.component.min-9c9e2e41.mjs") }), "../../../assets/js/components/actionbar/actionbar.component.js").then((e) => {
2233
2233
  window.customElements.get("iam-actionbar") || window.customElements.define("iam-actionbar", e.default);
2234
2234
  }).catch((e) => {
2235
2235
  console.log(e.message);
@@ -2276,7 +2276,7 @@ function wi(e, a, t, i, s, o) {
2276
2276
  }
2277
2277
  const Gi = /* @__PURE__ */ y(yi, [["render", wi]]);
2278
2278
  /*!
2279
- * iamKey v5.1.0-beta10
2279
+ * iamKey v5.1.0-beta11
2280
2280
  * Copyright 2022-2023 iamproperty
2281
2281
  */
2282
2282
  window.dataLayer = window.dataLayer || [], window.dataLayer.push({ event: "customElementRegistered", element: "collapsible side menu" });