diff --git a/.gitignore b/.gitignore index b845a4c..fed3a3e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ node_modules -dist coverage *.log diff --git a/dist/bundle.min.js b/dist/bundle.min.js new file mode 100644 index 0000000..6c0516d --- /dev/null +++ b/dist/bundle.min.js @@ -0,0 +1 @@ +!function(e,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r();else if("function"==typeof define&&define.amd)define([],r);else{var l=r();for(var t in l)("object"==typeof exports?exports:e)[t]=l[t]}}(this,(function(){return(()=>{"use strict";var e={597:(e,r,l)=>{l.d(r,{Ao:()=>t,XW:()=>n,Gp:()=>o,$v:()=>a,mw:()=>u,Gq:()=>i,BF:()=>s,uK:()=>v});var t=!0,n="ABCDEFGHIJKLMNOPQRSTUVWXYZ",o=!0,a="abcdefghijklmnopqrstuvwxyz",u=!1,i="!@#$%&*()=[]{}",s=!0,v="0123456789"},328:(e,r,l)=>{l.d(r,{Z:()=>n});var t=l(597);function n(e){var r,l,n,o,a,u,i,s,v=null!==(r=null==e?void 0:e.upperCase)&&void 0!==r?r:t.Ao,d=null!==(l=null==e?void 0:e.lowerCase)&&void 0!==l?l:t.Gp,h=null!==(n=null==e?void 0:e.special)&&void 0!==n?n:t.mw,c=null!==(o=null==e?void 0:e.number)&&void 0!==o?o:t.BF;if(!(v||d||h||c))throw new Error("You must set at least 1 character type.");var p=null!==(a=null==e?void 0:e.upperCaseCharacters)&&void 0!==a?a:t.XW,f=null!==(u=null==e?void 0:e.lowerCaseCharacters)&&void 0!==u?u:t.$v,g=null!==(i=null==e?void 0:e.specialCharacters)&&void 0!==i?i:t.Gq,w=null!==(s=null==e?void 0:e.numberCharacters)&&void 0!==s?s:t.uK,m="";return v&&(m+=p),d&&(m+=f),h&&(m+=g),c&&(m+=w),m}},2:(e,r,l)=>{function t(e,r){return Math.floor(Math.random()*(r-e+1)+e)}l.d(r,{Z:()=>t})},587:(e,r,l)=>{l.d(r,{default:()=>a});var t=l(328),n=l(2),o=l(597);const a=function(e){var r,l=null===(r=null==e?void 0:e.showStrength)||void 0===r||r,a=function(e){var r,l,a=null!==(r=null==e?void 0:e.passwordLength)&&void 0!==r?r:8;if(a<=0)throw new Error("passwordLength must be greater than 0.");for(var u=(0,t.Z)(e),i=function(e){var r,l,t,a,u,i,s,v,d,h=null!==(r=null==e?void 0:e.upperCase)&&void 0!==r?r:o.Ao,c=null!==(l=null==e?void 0:e.lowerCase)&&void 0!==l?l:o.Gp,p=null!==(t=null==e?void 0:e.special)&&void 0!==t?t:o.mw,f=null!==(a=null==e?void 0:e.number)&&void 0!==a?a:o.BF;if(!(h||c||p||f))throw new Error("You must set at least 1 character type.");var g={upperCase:null!==(u=null==e?void 0:e.upperCaseCharacters)&&void 0!==u?u:o.XW,lowerCase:null!==(i=null==e?void 0:e.lowerCaseCharacters)&&void 0!==i?i:o.$v,special:null!==(s=null==e?void 0:e.specialCharacters)&&void 0!==s?s:o.Gq,number:null!==(v=null==e?void 0:e.numberCharacters)&&void 0!==v?v:o.uK},w=null!==(d=null==e?void 0:e.firstCharType)&&void 0!==d?d:"random";if("random"===w){var m=Object.values(g).flat().reduce((function(e,r){return"".concat(e).concat(r)}),"");if(""===m)throw new Error("You must at least 1 character.");return m[(0,n.Z)(0,m.length-1)]}var C=g[w];if(""===C)throw new Error("You must at least 1 character for ".concat(w,"."));return C[(0,n.Z)(0,C.length-1)]}(e),s=null!==(l=null==e?void 0:e.excludeEqualChars)&&void 0!==l&&l,v=i,d=1;d{l.d(r,{default:()=>o});var t=l(328),n=l(2);const o=function(e){var r=(0,t.Z)(e);return function(e){var r,l=null!==(r=null==e?void 0:e.stringLength)&&void 0!==r?r:8;if(l<=0)throw new Error("stringLength must be greater than 0.");for(var t="",o=e.possibleCharacters,a=0;a{l.d(r,{default:()=>o});var t=l(597),n=l(2);const o=function(e){var r,l,o,a,u,i,s,v,d,h,c,p,f,g=null!==(r=null==e?void 0:e.mask)&&void 0!==r?r:"@#$%-@#$%-@#$%-@#$%";if(0===g.length)throw new Error('Mask wrong. Please put something like "@#$%-@#$%-#@$%"');var w=null!==(l=null==e?void 0:e.upperCase)&&void 0!==l?l:t.Ao,m=null!==(o=null==e?void 0:e.lowerCase)&&void 0!==o?o:t.Gp,C=null!==(a=null==e?void 0:e.special)&&void 0!==a?a:t.mw,b=null!==(u=null==e?void 0:e.number)&&void 0!==u?u:t.BF;if(!(w||m||C||b))throw new Error("You must set at least 1 character type.");var M=null!==(i=null==e?void 0:e.upperCaseMask)&&void 0!==i?i:"@",y=null!==(s=null==e?void 0:e.lowerCaseMask)&&void 0!==s?s:"#",E=null!==(v=null==e?void 0:e.specialMask)&&void 0!==v?v:"$",Z=null!==(d=null==e?void 0:e.numberMask)&&void 0!==d?d:"%";if(!M||M.length>1)throw new Error("upperCaseMask must have 1 character");if(!y||y.length>1)throw new Error("lowerCaseMask must have 1 character");if(!E||E.length>1)throw new Error("specialMask must have 1 character");if(!Z||Z.length>1)throw new Error("numberMask must have 1 character");var k=null!==(h=null==e?void 0:e.upperCaseCharacters)&&void 0!==h?h:t.XW,S=null!==(c=null==e?void 0:e.lowerCaseCharacters)&&void 0!==c?c:t.$v,$=null!==(p=null==e?void 0:e.specialCharacters)&&void 0!==p?p:t.Gq,x=null!==(f=null==e?void 0:e.numberCharacters)&&void 0!==f?f:t.uK;if(!k)throw new Error("Set at least 1 character for upperCases");if(!S)throw new Error("Set at least 1 character for lowerCases");if(!$)throw new Error("Set at least 1 character for specials");if(!x)throw new Error("Set at least 1 character for numbers");for(var j="",G=0;G{for(var t in r)l.o(r,t)&&!l.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},l.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),l.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var t={};return(()=>{l.r(t),l.d(t,{generateRandomString:()=>e.default,generateRandomStringWithMask:()=>r.default,generateRandomPassword:()=>n.default});var e=l(594),r=l(293),n=l(587)})(),t})()})); \ No newline at end of file diff --git a/dist/generateRandomPassword.min.js b/dist/generateRandomPassword.min.js new file mode 100644 index 0000000..cae3da6 --- /dev/null +++ b/dist/generateRandomPassword.min.js @@ -0,0 +1 @@ +!function(e,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r();else if("function"==typeof define&&define.amd)define([],r);else{var l=r();for(var t in l)("object"==typeof exports?exports:e)[t]=l[t]}}(this,(function(){return(()=>{"use strict";var e={597:(e,r,l)=>{l.d(r,{Ao:()=>t,XW:()=>n,Gp:()=>o,$v:()=>a,mw:()=>u,Gq:()=>i,BF:()=>s,uK:()=>v});var t=!0,n="ABCDEFGHIJKLMNOPQRSTUVWXYZ",o=!0,a="abcdefghijklmnopqrstuvwxyz",u=!1,i="!@#$%&*()=[]{}",s=!0,v="0123456789"},328:(e,r,l)=>{l.d(r,{Z:()=>n});var t=l(597);function n(e){var r,l,n,o,a,u,i,s,v=null!==(r=null==e?void 0:e.upperCase)&&void 0!==r?r:t.Ao,d=null!==(l=null==e?void 0:e.lowerCase)&&void 0!==l?l:t.Gp,c=null!==(n=null==e?void 0:e.special)&&void 0!==n?n:t.mw,p=null!==(o=null==e?void 0:e.number)&&void 0!==o?o:t.BF;if(!(v||d||c||p))throw new Error("You must set at least 1 character type.");var h=null!==(a=null==e?void 0:e.upperCaseCharacters)&&void 0!==a?a:t.XW,f=null!==(u=null==e?void 0:e.lowerCaseCharacters)&&void 0!==u?u:t.$v,m=null!==(i=null==e?void 0:e.specialCharacters)&&void 0!==i?i:t.Gq,g=null!==(s=null==e?void 0:e.numberCharacters)&&void 0!==s?s:t.uK,w="";return v&&(w+=h),d&&(w+=f),c&&(w+=m),p&&(w+=g),w}},2:(e,r,l)=>{function t(e,r){return Math.floor(Math.random()*(r-e+1)+e)}l.d(r,{Z:()=>t})}},r={};function l(t){var n=r[t];if(void 0!==n)return n.exports;var o=r[t]={exports:{}};return e[t](o,o.exports,l),o.exports}l.d=(e,r)=>{for(var t in r)l.o(r,t)&&!l.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},l.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),l.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var t={};return(()=>{l.r(t),l.d(t,{generateRandomPassword:()=>o,default:()=>a});var e=l(328),r=l(2),n=l(597);function o(l){var t,o=null===(t=null==l?void 0:l.showStrength)||void 0===t||t,a=function(l){var t,o,a=null!==(t=null==l?void 0:l.passwordLength)&&void 0!==t?t:8;if(a<=0)throw new Error("passwordLength must be greater than 0.");for(var u=(0,e.Z)(l),i=function(e){var l,t,o,a,u,i,s,v,d,c=null!==(l=null==e?void 0:e.upperCase)&&void 0!==l?l:n.Ao,p=null!==(t=null==e?void 0:e.lowerCase)&&void 0!==t?t:n.Gp,h=null!==(o=null==e?void 0:e.special)&&void 0!==o?o:n.mw,f=null!==(a=null==e?void 0:e.number)&&void 0!==a?a:n.BF;if(!(c||p||h||f))throw new Error("You must set at least 1 character type.");var m={upperCase:null!==(u=null==e?void 0:e.upperCaseCharacters)&&void 0!==u?u:n.XW,lowerCase:null!==(i=null==e?void 0:e.lowerCaseCharacters)&&void 0!==i?i:n.$v,special:null!==(s=null==e?void 0:e.specialCharacters)&&void 0!==s?s:n.Gq,number:null!==(v=null==e?void 0:e.numberCharacters)&&void 0!==v?v:n.uK},g=null!==(d=null==e?void 0:e.firstCharType)&&void 0!==d?d:"random";if("random"===g){var w=Object.values(m).flat().reduce((function(e,r){return"".concat(e).concat(r)}),"");if(""===w)throw new Error("You must at least 1 character.");return w[(0,r.Z)(0,w.length-1)]}var b=m[g];if(""===b)throw new Error("You must at least 1 character for ".concat(g,"."));return b[(0,r.Z)(0,b.length-1)]}(l),s=null!==(o=null==l?void 0:l.excludeEqualChars)&&void 0!==o&&o,v=i,d=1;d{"use strict";var e={597:(e,r,t)=>{t.d(r,{Ao:()=>o,XW:()=>n,Gp:()=>l,$v:()=>i,mw:()=>u,Gq:()=>a,BF:()=>d,uK:()=>s});var o=!0,n="ABCDEFGHIJKLMNOPQRSTUVWXYZ",l=!0,i="abcdefghijklmnopqrstuvwxyz",u=!1,a="!@#$%&*()=[]{}",d=!0,s="0123456789"},328:(e,r,t)=>{t.d(r,{Z:()=>n});var o=t(597);function n(e){var r,t,n,l,i,u,a,d,s=null!==(r=null==e?void 0:e.upperCase)&&void 0!==r?r:o.Ao,v=null!==(t=null==e?void 0:e.lowerCase)&&void 0!==t?t:o.Gp,f=null!==(n=null==e?void 0:e.special)&&void 0!==n?n:o.mw,p=null!==(l=null==e?void 0:e.number)&&void 0!==l?l:o.BF;if(!(s||v||f||p))throw new Error("You must set at least 1 character type.");var c=null!==(i=null==e?void 0:e.upperCaseCharacters)&&void 0!==i?i:o.XW,h=null!==(u=null==e?void 0:e.lowerCaseCharacters)&&void 0!==u?u:o.$v,g=null!==(a=null==e?void 0:e.specialCharacters)&&void 0!==a?a:o.Gq,b=null!==(d=null==e?void 0:e.numberCharacters)&&void 0!==d?d:o.uK,m="";return s&&(m+=c),v&&(m+=h),f&&(m+=g),p&&(m+=b),m}},2:(e,r,t)=>{function o(e,r){return Math.floor(Math.random()*(r-e+1)+e)}t.d(r,{Z:()=>o})}},r={};function t(o){var n=r[o];if(void 0!==n)return n.exports;var l=r[o]={exports:{}};return e[o](l,l.exports,t),l.exports}t.d=(e,r)=>{for(var o in r)t.o(r,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:r[o]})},t.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),t.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{t.r(o),t.d(o,{generateRandomString:()=>n,default:()=>l});var e=t(328),r=t(2);function n(t){var o=(0,e.Z)(t);return function(e){var t,o=null!==(t=null==e?void 0:e.stringLength)&&void 0!==t?t:8;if(o<=0)throw new Error("stringLength must be greater than 0.");for(var n="",l=e.possibleCharacters,i=0;i{"use strict";var e={597:(e,r,o)=>{o.d(r,{Ao:()=>t,XW:()=>a,Gp:()=>l,$v:()=>n,mw:()=>i,Gq:()=>u,BF:()=>s,uK:()=>v});var t=!0,a="ABCDEFGHIJKLMNOPQRSTUVWXYZ",l=!0,n="abcdefghijklmnopqrstuvwxyz",i=!1,u="!@#$%&*()=[]{}",s=!0,v="0123456789"},2:(e,r,o)=>{function t(e,r){return Math.floor(Math.random()*(r-e+1)+e)}o.d(r,{Z:()=>t})}},r={};function o(t){var a=r[t];if(void 0!==a)return a.exports;var l=r[t]={exports:{}};return e[t](l,l.exports,o),l.exports}o.d=(e,r)=>{for(var t in r)o.o(r,t)&&!o.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},o.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var t={};return(()=>{o.r(t),o.d(t,{generateRandomStringWithMask:()=>a,default:()=>l});var e=o(597),r=o(2);function a(o){var t,a,l,n,i,u,s,v,d,c,h,f,p,w=null!==(t=null==o?void 0:o.mask)&&void 0!==t?t:"@#$%-@#$%-@#$%-@#$%";if(0===w.length)throw new Error('Mask wrong. Please put something like "@#$%-@#$%-#@$%"');var m=null!==(a=null==o?void 0:o.upperCase)&&void 0!==a?a:e.Ao,g=null!==(l=null==o?void 0:o.lowerCase)&&void 0!==l?l:e.Gp,b=null!==(n=null==o?void 0:o.special)&&void 0!==n?n:e.mw,y=null!==(i=null==o?void 0:o.number)&&void 0!==i?i:e.BF;if(!(m||g||b||y))throw new Error("You must set at least 1 character type.");var C=null!==(u=null==o?void 0:o.upperCaseMask)&&void 0!==u?u:"@",M=null!==(s=null==o?void 0:o.lowerCaseMask)&&void 0!==s?s:"#",k=null!==(v=null==o?void 0:o.specialMask)&&void 0!==v?v:"$",E=null!==(d=null==o?void 0:o.numberMask)&&void 0!==d?d:"%";if(!C||C.length>1)throw new Error("upperCaseMask must have 1 character");if(!M||M.length>1)throw new Error("lowerCaseMask must have 1 character");if(!k||k.length>1)throw new Error("specialMask must have 1 character");if(!E||E.length>1)throw new Error("numberMask must have 1 character");var S=null!==(c=null==o?void 0:o.upperCaseCharacters)&&void 0!==c?c:e.XW,$=null!==(h=null==o?void 0:o.lowerCaseCharacters)&&void 0!==h?h:e.$v,x=null!==(f=null==o?void 0:o.specialCharacters)&&void 0!==f?f:e.Gq,j=null!==(p=null==o?void 0:o.numberCharacters)&&void 0!==p?p:e.uK;if(!S)throw new Error("Set at least 1 character for upperCases");if(!$)throw new Error("Set at least 1 character for lowerCases");if(!x)throw new Error("Set at least 1 character for specials");if(!j)throw new Error("Set at least 1 character for numbers");for(var O="",P=0;P