forked from mkropat/secure-random-password
-
Notifications
You must be signed in to change notification settings - Fork 0
/
secure-random-password.min.js
1 lines (1 loc) · 6.28 KB
/
secure-random-password.min.js
1
!function(r){var t={};function e(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return r[n].call(o.exports,o,o.exports,e),o.l=!0,o.exports}e.m=r,e.c=t,e.d=function(r,t,n){e.o(r,t)||Object.defineProperty(r,t,{enumerable:!0,get:n})},e.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},e.t=function(r,t){if(1&t&&(r=e(r)),8&t)return r;if(4&t&&"object"==typeof r&&r&&r.__esModule)return r;var n=Object.create(null);if(e.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:r}),2&t&&"string"!=typeof r)for(var o in r)e.d(n,o,function(t){return r[t]}.bind(null,o));return n},e.n=function(r){var t=r&&r.__esModule?function(){return r.default}:function(){return r};return e.d(t,"a",t),t},e.o=function(r,t){return Object.prototype.hasOwnProperty.call(r,t)},e.p="",e(e.s=2)}([function(r,t){r.exports={}},function(r,t,e){"use strict";function n(r){return Array.apply(null,Array(r)).map((function(r,t){return t}))}function o(r){return Array.prototype.slice.call(r)}t.assign=function(){var r=o(arguments),t=r[0];return r.slice(1).filter((function(r){return!!r})).forEach((function(r){Object.keys(r).forEach((function(e){t[e]=r[e]}))})),t},t.intersection=function(r,t){r=o(r),t=o(t);var e={};r.forEach((function(r){e[r]=!0}));var n={};return t.forEach((function(r){n[r]=!0})),Object.keys(e).filter((function(r){return Object.prototype.hasOwnProperty.call(n,r)}))},t.isInteger=function(r){return"number"==typeof r&&isFinite(r)&&Math.floor(r)===r},t.isString=function(r){return"string"==typeof r||r instanceof String},t.range=n,t.repeat=function(r,t){return n(t).map((function(){return r}))},t.toArray=o},function(r,t,e){window.secureRandomPassword=e(3)},function(r,t,e){"use strict";var n=e(4).default,o=e(7),u=e(1);Object.keys(o).forEach((function(r){t[r]=o[r]}));var i=["Il1|","O0"];function a(r){var t={avoidAmbiguous:!0,characters:[o.lower,{characters:o.upper,exactly:1},{characters:o.symbols,exactly:1}],length:12,predicate:function(){return!0},random:n},e=function(r){if(!r.characters)return[];var t=Array.isArray(r.characters)?r.characters:[r.characters];t=t.map((function(r){return u.isString(r)?{characters:r}:r}));var e=!0===r.avoidAmbiguous?i:r.avoidAmbiguous||[];return function(r,t){var e=r.map((function(r){return r.characters})).join(""),n=t.filter((function(r){return u.intersection(r,e).length>1})).join("");r.forEach((function(r){r.characters=u.toArray(r.characters).filter((function(r){return n.indexOf(r)<0})).join("")}))}(t,e),t}(r=u.assign({},t,r));if(!u.isInteger(r.length))throw new Error("length must be an integer");if(r.length<1)throw new Error("length must be > 0");if(r.length<e.length)throw new Error("length must be >= # of character sets passed");if(e.some((function(r){return!r.characters})))throw new Error("No character set may be empty");if(0===e.length)throw new Error("Must pass one or more character sets");if("function"!=typeof r.predicate)throw new Error("predicate must be a function");var a,s=e.map((function(r){return r.exactly||1})).reduce((function(r,t){return r+t}),0);if(r.length<s)throw new Error("length is too short for character set rules");if(e.every((function(r){return r.exactly}))&&e.reduce((function(r,t){return r.exactly+t.exactly}),0)!==r.length)throw new Error("Must pass a set without exactly rule to generate the specified length");do{a=c(e,r.length,r.random)}while(!r.predicate(a));return a}function c(r,t,e){var n=r.map((function(r){return r.exactly?u.repeat(r.characters,r.exactly):[r.characters]})).reduce((function(r,t){return r.concat(t)})).map((function(r){return e.choose(r)})),o=r.filter((function(r){return!r.exactly})).map((function(r){return r.characters})).join(""),i=u.range(t-n.length).map((function(){return e.choose(o)}));return e.shuffle(n.concat(i)).join("")}t.randomPassword=a,t.randomString=function(r){var t={characters:[o.lower,o.upper,o.digits,o.symbols],length:20};return(r=u.assign({},t,r)).avoidAmbiguous=!1,a(r)}},function(r,t,e){"use strict";var n=e(5),o=e(1);function u(r){if("function"!=typeof r)throw new Error("Must pass a randomSource function");this._randomSource=r}function i(r){for(var t=0,e=1,n=(r=r||[]).length-1;n>=0;n--)t+=r[n]*e,e*=256;return t}u.prototype.choose=function(r){if(!r||!r.length)throw new Error("Must pass 1 or more choices");return r[this._getInt(r.length)]},u.prototype.getInt=function(r){if(void 0===r)throw new Error("Must pass an upper bound");if(!o.isInteger(r))throw new Error("Upper bound must be a number");if(r<1)throw new Error("Upper bound must be > 0");return this._getInt(r)},u.prototype._getInt=function(r){if(1===r)return 0;var t,e=Math.ceil(Math.log(r)/Math.log(256)),n=Math.pow(2,8*e)-Math.pow(2,8*e)%r;do{t=i(this._randomSource(e))}while(t>=n);return t%r},u.prototype.shuffle=function(r){r=Array.prototype.slice.call(r||[]);for(var t=[];r.length;)t.push(r.splice(this._getInt(r.length),1)[0]);return t},t.Random=u,t.default=new u(n)},function(r,t,e){(function(n,o){var u;!function(i){"use strict";function a(r,t){if(t=t||{type:"Array"},void 0!==n&&"number"==typeof n.pid)return function(r,t){var n=e(6).randomBytes(r);switch(t.type){case"Array":return[].slice.call(n);case"Buffer":return n;case"Uint8Array":for(var o=new Uint8Array(r),u=0;u<r;++u)o[u]=n.readUInt8(u);return o;default:throw new Error(t.type+" is unsupported.")}}(r,t);if(!(window.crypto||window.msCrypto))throw new Error("Your browser does not support window.crypto.");return function(r,t){var e=new Uint8Array(r);switch((window.crypto||window.msCrypto).getRandomValues(e),t.type){case"Array":return[].slice.call(e);case"Buffer":try{new o(1)}catch(r){throw new Error("Buffer not supported in this environment. Use Node.js or Browserify for browser support.")}return new o(e);case"Uint8Array":return e;default:throw new Error(t.type+" is unsupported.")}}(r,t)}void 0===(u=function(){return a}.apply(t,[]))||(r.exports=u),a.randomArray=function(r){return a(r,{type:"Array"})},a.randomUint8Array=function(r){return a(r,{type:"Uint8Array"})},a.randomBuffer=function(r){return a(r,{type:"Buffer"})}}()}).call(this,e(0),e(0).Buffer)},function(r,t){},function(r,t){t.lower="abcdefghijklmnopqrstuvwxyz",t.upper=t.lower.toUpperCase(),t.consonants="bcdfghjklmnpqrstvwxyz",t.vowels="aeiou",t.digits="1234567890",t.symbols="!@#$%^&*()",t.fullSymbols="!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",t.copyableSymbols="_"}]);