local-id-scan-journey
Version:
A React component for GBG ID verification and document scanning with bundled SDK
3 lines • 24.7 kB
JavaScript
/*! For license information please see vendor.sjcl.f4547262815d41f5fc42.js.LICENSE.txt */
;(this.webpackChunkGBG_Idscan=this.webpackChunkGBG_Idscan||[]).push([[423],{4545:(t,e,i)=>{var n,r={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(t){this.toString=function(){return"CORRUPT: "+this.message},this.message=t},invalid:function(t){this.toString=function(){return"INVALID: "+this.message},this.message=t},bug:function(t){this.toString=function(){return"BUG: "+this.message},this.message=t},notReady:function(t){this.toString=function(){return"NOT READY: "+this.message},this.message=t}}};function o(t,e,i){if(4!==e.length)throw new r.exception.invalid("invalid aes block size");var n=t.b[i],o=e[0]^n[0],a=e[i?3:1]^n[1],c=e[2]^n[2];e=e[i?1:3]^n[3];var s,h,l,d,u=n.length/4-2,f=4,p=[0,0,0,0];t=(s=t.s[i])[0];var m=s[1],y=s[2],g=s[3],b=s[4];for(d=0;d<u;d++)s=t[o>>>24]^m[a>>16&255]^y[c>>8&255]^g[255&e]^n[f],h=t[a>>>24]^m[c>>16&255]^y[e>>8&255]^g[255&o]^n[f+1],l=t[c>>>24]^m[e>>16&255]^y[o>>8&255]^g[255&a]^n[f+2],e=t[e>>>24]^m[o>>16&255]^y[a>>8&255]^g[255&c]^n[f+3],f+=4,o=s,a=h,c=l;for(d=0;4>d;d++)p[i?3&-d:d]=b[o>>>24]<<24^b[a>>16&255]<<16^b[c>>8&255]<<8^b[255&e]^n[f++],s=o,o=a,a=c,c=e,e=s;return p}function a(t,e){var i,n,r,o=t.F,a=t.b,c=o[0],s=o[1],h=o[2],l=o[3],d=o[4],u=o[5],f=o[6],p=o[7];for(i=0;64>i;i++)16>i?n=e[i]:(n=e[i+1&15],r=e[i+14&15],n=e[15&i]=(n>>>7^n>>>18^n>>>3^n<<25^n<<14)+(r>>>17^r>>>19^r>>>10^r<<15^r<<13)+e[15&i]+e[i+9&15]|0),n=n+p+(d>>>6^d>>>11^d>>>25^d<<26^d<<21^d<<7)+(f^d&(u^f))+a[i],p=f,f=u,u=d,d=l+n|0,l=h,h=s,c=n+((s=c)&h^l&(s^h))+(s>>>2^s>>>13^s>>>22^s<<30^s<<19^s<<10)|0;o[0]=o[0]+c|0,o[1]=o[1]+s|0,o[2]=o[2]+h|0,o[3]=o[3]+l|0,o[4]=o[4]+d|0,o[5]=o[5]+u|0,o[6]=o[6]+f|0,o[7]=o[7]+p|0}function c(t,e){var i,n=r.random.K[t],o=[];for(i in n)n.hasOwnProperty(i)&&o.push(n[i]);for(i=0;i<o.length;i++)o[i](e)}function s(t,e){"undefined"!=typeof window&&window.performance&&"function"==typeof window.performance.now?t.addEntropy(window.performance.now(),e,"loadtime"):t.addEntropy((new Date).valueOf(),e,"loadtime")}function h(t){t.b=l(t).concat(l(t)),t.L=new r.cipher.aes(t.b)}function l(t){for(var e=0;4>e&&(t.h[e]=t.h[e]+1|0,!t.h[e]);e++);return t.L.encrypt(t.h)}function d(t,e){return function(){e.apply(t,arguments)}}r.cipher.aes=function(t){this.s[0][0][0]||this.O();var e,i,n,o,a=this.s[0][4],c=this.s[1],s=1;if(4!==(e=t.length)&&6!==e&&8!==e)throw new r.exception.invalid("invalid aes key size");for(this.b=[n=t.slice(0),o=[]],t=e;t<4*e+28;t++)i=n[t-1],(0==t%e||8===e&&4==t%e)&&(i=a[i>>>24]<<24^a[i>>16&255]<<16^a[i>>8&255]<<8^a[255&i],0==t%e&&(i=i<<8^i>>>24^s<<24,s=s<<1^283*(s>>7))),n[t]=n[t-e]^i;for(e=0;t;e++,t--)i=n[3&e?t:t-4],o[e]=4>=t||4>e?i:c[0][a[i>>>24]]^c[1][a[i>>16&255]]^c[2][a[i>>8&255]]^c[3][a[255&i]]},r.cipher.aes.prototype={encrypt:function(t){return o(this,t,0)},decrypt:function(t){return o(this,t,1)},s:[[[],[],[],[],[]],[[],[],[],[],[]]],O:function(){var t,e,i,n,r,o,a,c=this.s[0],s=this.s[1],h=c[4],l=s[4],d=[],u=[];for(t=0;256>t;t++)u[(d[t]=t<<1^283*(t>>7))^t]=t;for(e=i=0;!h[e];e^=n||1,i=u[i]||1)for(o=(o=i^i<<1^i<<2^i<<3^i<<4)>>8^255&o^99,h[e]=o,l[o]=e,a=16843009*(r=d[t=d[n=d[e]]])^65537*t^257*n^16843008*e,r=257*d[o]^16843008*o,t=0;4>t;t++)c[t][e]=r=r<<24^r>>>8,s[t][o]=a=a<<24^a>>>8;for(t=0;5>t;t++)c[t]=c[t].slice(0),s[t]=s[t].slice(0)}},r.bitArray={bitSlice:function(t,e,i){return t=r.bitArray.$(t.slice(e/32),32-(31&e)).slice(1),void 0===i?t:r.bitArray.clamp(t,i-e)},extract:function(t,e,i){var n=Math.floor(-e-i&31);return(-32&(e+i-1^e)?t[e/32|0]<<32-n^t[e/32+1|0]>>>n:t[e/32|0]>>>n)&(1<<i)-1},concat:function(t,e){if(0===t.length||0===e.length)return t.concat(e);var i=t[t.length-1],n=r.bitArray.getPartial(i);return 32===n?t.concat(e):r.bitArray.$(e,n,0|i,t.slice(0,t.length-1))},bitLength:function(t){var e=t.length;return 0===e?0:32*(e-1)+r.bitArray.getPartial(t[e-1])},clamp:function(t,e){if(32*t.length<e)return t;var i=(t=t.slice(0,Math.ceil(e/32))).length;return e&=31,0<i&&e&&(t[i-1]=r.bitArray.partial(e,t[i-1]&2147483648>>e-1,1)),t},partial:function(t,e,i){return 32===t?e:(i?0|e:e<<32-t)+1099511627776*t},getPartial:function(t){return Math.round(t/1099511627776)||32},equal:function(t,e){if(r.bitArray.bitLength(t)!==r.bitArray.bitLength(e))return!1;var i,n=0;for(i=0;i<t.length;i++)n|=t[i]^e[i];return 0===n},$:function(t,e,i,n){var o;for(o=0,void 0===n&&(n=[]);32<=e;e-=32)n.push(i),i=0;if(0===e)return n.concat(t);for(o=0;o<t.length;o++)n.push(i|t[o]>>>e),i=t[o]<<32-e;return o=t.length?t[t.length-1]:0,t=r.bitArray.getPartial(o),n.push(r.bitArray.partial(e+t&31,32<e+t?i:n.pop(),1)),n},i:function(t,e){return[t[0]^e[0],t[1]^e[1],t[2]^e[2],t[3]^e[3]]},byteswapM:function(t){var e,i;for(e=0;e<t.length;++e)i=t[e],t[e]=i>>>24|i>>>8&65280|(65280&i)<<8|i<<24;return t}},r.codec.utf8String={fromBits:function(t){var e,i,n="",o=r.bitArray.bitLength(t);for(e=0;e<o/8;e++)!(3&e)&&(i=t[e/4]),n+=String.fromCharCode(i>>>8>>>8>>>8),i<<=8;return decodeURIComponent(escape(n))},toBits:function(t){t=unescape(encodeURIComponent(t));var e,i=[],n=0;for(e=0;e<t.length;e++)n=n<<8|t.charCodeAt(e),!(3&~e)&&(i.push(n),n=0);return 3&e&&i.push(r.bitArray.partial(8*(3&e),n)),i}},r.codec.hex={fromBits:function(t){var e,i="";for(e=0;e<t.length;e++)i+=(0xf00000000000+(0|t[e])).toString(16).substr(4);return i.substr(0,r.bitArray.bitLength(t)/4)},toBits:function(t){var e,i,n=[];for(i=(t=t.replace(/\s|0x/g,"")).length,t+="00000000",e=0;e<t.length;e+=8)n.push(0^parseInt(t.substr(e,8),16));return r.bitArray.clamp(n,4*i)}},r.codec.base32={B:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",X:"0123456789ABCDEFGHIJKLMNOPQRSTUV",BITS:32,BASE:5,REMAINING:27,fromBits:function(t,e,i){var n=r.codec.base32.BASE,o=r.codec.base32.REMAINING,a="",c=0,s=r.codec.base32.B,h=0,l=r.bitArray.bitLength(t);for(i&&(s=r.codec.base32.X),i=0;a.length*n<l;)a+=s.charAt((h^t[i]>>>c)>>>o),c<n?(h=t[i]<<n-c,c+=o,i++):(h<<=n,c-=n);for(;7&a.length&&!e;)a+="=";return a},toBits:function(t,e){t=t.replace(/\s|=/g,"").toUpperCase();var i,n,o=r.codec.base32.BITS,a=r.codec.base32.BASE,c=r.codec.base32.REMAINING,s=[],h=0,l=r.codec.base32.B,d=0,u="base32";for(e&&(l=r.codec.base32.X,u="base32hex"),i=0;i<t.length;i++){if(0>(n=l.indexOf(t.charAt(i)))){if(!e)try{return r.codec.base32hex.toBits(t)}catch(t){}throw new r.exception.invalid("this isn't "+u+"!")}h>c?(h-=c,s.push(d^n>>>h),d=n<<o-h):d^=n<<o-(h+=a)}return 56&h&&s.push(r.bitArray.partial(56&h,d,1)),s}},r.codec.base32hex={fromBits:function(t,e){return r.codec.base32.fromBits(t,e,1)},toBits:function(t){return r.codec.base32.toBits(t,1)}},r.codec.base64={B:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",fromBits:function(t,e,i){var n="",o=0,a=r.codec.base64.B,c=0,s=r.bitArray.bitLength(t);for(i&&(a=a.substr(0,62)+"-_"),i=0;6*n.length<s;)n+=a.charAt((c^t[i]>>>o)>>>26),6>o?(c=t[i]<<6-o,o+=26,i++):(c<<=6,o-=6);for(;3&n.length&&!e;)n+="=";return n},toBits:function(t,e){t=t.replace(/\s|=/g,"");var i,n,o=[],a=0,c=r.codec.base64.B,s=0;for(e&&(c=c.substr(0,62)+"-_"),i=0;i<t.length;i++){if(0>(n=c.indexOf(t.charAt(i))))throw new r.exception.invalid("this isn't base64!");26<a?(a-=26,o.push(s^n>>>a),s=n<<32-a):s^=n<<32-(a+=6)}return 56&a&&o.push(r.bitArray.partial(56&a,s,1)),o}},r.codec.base64url={fromBits:function(t){return r.codec.base64.fromBits(t,1,1)},toBits:function(t){return r.codec.base64.toBits(t,1)}},r.hash.sha256=function(t){this.b[0]||this.O(),t?(this.F=t.F.slice(0),this.A=t.A.slice(0),this.l=t.l):this.reset()},r.hash.sha256.hash=function(t){return(new r.hash.sha256).update(t).finalize()},r.hash.sha256.prototype={blockSize:512,reset:function(){return this.F=this.Y.slice(0),this.A=[],this.l=0,this},update:function(t){"string"==typeof t&&(t=r.codec.utf8String.toBits(t));var e,i=this.A=r.bitArray.concat(this.A,t);if(e=this.l,9007199254740991<(t=this.l=e+r.bitArray.bitLength(t)))throw new r.exception.invalid("Cannot hash more than 2^53 - 1 bits");if("undefined"!=typeof Uint32Array){var n=new Uint32Array(i),o=0;for(e=512+e-(512+e&511);e<=t;e+=512)a(this,n.subarray(16*o,16*(o+1))),o+=1;i.splice(0,16*o)}else for(e=512+e-(512+e&511);e<=t;e+=512)a(this,i.splice(0,16));return this},finalize:function(){var t,e=this.A,i=this.F;for(t=(e=r.bitArray.concat(e,[r.bitArray.partial(1,1)])).length+2;15&t;t++)e.push(0);for(e.push(Math.floor(this.l/4294967296)),e.push(0|this.l);e.length;)a(this,e.splice(0,16));return this.reset(),i},Y:[],b:[],O:function(){function t(t){return 4294967296*(t-Math.floor(t))|0}for(var e,i,n=0,r=2;64>n;r++){for(i=!0,e=2;e*e<=r;e++)if(0==r%e){i=!1;break}i&&(8>n&&(this.Y[n]=t(Math.pow(r,.5))),this.b[n]=t(Math.pow(r,1/3)),n++)}}},r.mode.ccm={name:"ccm",G:[],listenProgress:function(t){r.mode.ccm.G.push(t)},unListenProgress:function(t){-1<(t=r.mode.ccm.G.indexOf(t))&&r.mode.ccm.G.splice(t,1)},fa:function(t){var e,i=r.mode.ccm.G.slice();for(e=0;e<i.length;e+=1)i[e](t)},encrypt:function(t,e,i,n,o){var a,c=e.slice(0),s=r.bitArray,h=s.bitLength(i)/8,l=s.bitLength(c)/8;if(o=o||64,n=n||[],7>h)throw new r.exception.invalid("ccm: iv must be at least 7 bytes");for(a=2;4>a&&l>>>8*a;a++);return a<15-h&&(a=15-h),i=s.clamp(i,8*(15-a)),e=r.mode.ccm.V(t,e,i,n,o,a),c=r.mode.ccm.C(t,c,i,e,o,a),s.concat(c.data,c.tag)},decrypt:function(t,e,i,n,o){o=o||64,n=n||[];var a=r.bitArray,c=a.bitLength(i)/8,s=a.bitLength(e),h=a.clamp(e,s-o),l=a.bitSlice(e,s-o);s=(s-o)/8;if(7>c)throw new r.exception.invalid("ccm: iv must be at least 7 bytes");for(e=2;4>e&&s>>>8*e;e++);if(e<15-c&&(e=15-c),i=a.clamp(i,8*(15-e)),h=r.mode.ccm.C(t,h,i,l,o,e),t=r.mode.ccm.V(t,h.data,i,n,o,e),!a.equal(h.tag,t))throw new r.exception.corrupt("ccm: tag doesn't match");return h.data},na:function(t,e,i,n,o,a){var c=[],s=r.bitArray,h=s.i;if(n=[s.partial(8,(e.length?64:0)|n-2<<2|a-1)],(n=s.concat(n,i))[3]|=o,n=t.encrypt(n),e.length)for(65279>=(i=s.bitLength(e)/8)?c=[s.partial(16,i)]:4294967295>=i&&(c=s.concat([s.partial(16,65534)],[i])),c=s.concat(c,e),e=0;e<c.length;e+=4)n=t.encrypt(h(n,c.slice(e,e+4).concat([0,0,0])));return n},V:function(t,e,i,n,o,a){var c=r.bitArray,s=c.i;if((o/=8)%2||4>o||16<o)throw new r.exception.invalid("ccm: invalid tag length");if(4294967295<n.length||4294967295<e.length)throw new r.exception.bug("ccm: can't deal with 4GiB or more data");for(i=r.mode.ccm.na(t,n,i,o,c.bitLength(e)/8,a),n=0;n<e.length;n+=4)i=t.encrypt(s(i,e.slice(n,n+4).concat([0,0,0])));return c.clamp(i,8*o)},C:function(t,e,i,n,o,a){var c,s=r.bitArray;c=s.i;var h=e.length,l=s.bitLength(e),d=h/50,u=d;if(i=s.concat([s.partial(8,a-1)],i).concat([0,0,0]).slice(0,4),n=s.bitSlice(c(n,t.encrypt(i)),0,o),!h)return{tag:n,data:[]};for(c=0;c<h;c+=4)c>d&&(r.mode.ccm.fa(c/h),d+=u),i[3]++,o=t.encrypt(i),e[c]^=o[0],e[c+1]^=o[1],e[c+2]^=o[2],e[c+3]^=o[3];return{tag:n,data:s.clamp(e,l)}}},r.mode.ocb2={name:"ocb2",encrypt:function(t,e,i,n,o,a){if(128!==r.bitArray.bitLength(i))throw new r.exception.invalid("ocb iv must be 128 bits");var c,s=r.mode.ocb2.S,h=r.bitArray,l=h.i,d=[0,0,0,0];i=s(t.encrypt(i));var u,f=[];for(n=n||[],o=o||64,c=0;c+4<e.length;c+=4)d=l(d,u=e.slice(c,c+4)),f=f.concat(l(i,t.encrypt(l(i,u)))),i=s(i);return u=e.slice(c),e=h.bitLength(u),c=t.encrypt(l(i,[0,0,0,e])),u=h.clamp(l(u.concat([0,0,0]),c),e),d=l(d,l(u.concat([0,0,0]),c)),d=t.encrypt(l(d,l(i,s(i)))),n.length&&(d=l(d,a?n:r.mode.ocb2.pmac(t,n))),f.concat(h.concat(u,h.clamp(d,o)))},decrypt:function(t,e,i,n,o,a){if(128!==r.bitArray.bitLength(i))throw new r.exception.invalid("ocb iv must be 128 bits");o=o||64;var c,s,h=r.mode.ocb2.S,l=r.bitArray,d=l.i,u=[0,0,0,0],f=h(t.encrypt(i)),p=r.bitArray.bitLength(e)-o,m=[];for(n=n||[],i=0;i+4<p/32;i+=4)c=d(f,t.decrypt(d(f,e.slice(i,i+4)))),u=d(u,c),m=m.concat(c),f=h(f);if(s=p-32*i,c=t.encrypt(d(f,[0,0,0,s])),c=d(c,l.clamp(e.slice(i),s).concat([0,0,0])),u=d(u,c),u=t.encrypt(d(u,d(f,h(f)))),n.length&&(u=d(u,a?n:r.mode.ocb2.pmac(t,n))),!l.equal(l.clamp(u,o),l.bitSlice(e,p)))throw new r.exception.corrupt("ocb: tag doesn't match");return m.concat(l.clamp(c,s))},pmac:function(t,e){var i,n=r.mode.ocb2.S,o=r.bitArray,a=o.i,c=[0,0,0,0],s=a(s=t.encrypt([0,0,0,0]),n(n(s)));for(i=0;i+4<e.length;i+=4)s=n(s),c=a(c,t.encrypt(a(s,e.slice(i,i+4))));return i=e.slice(i),128>o.bitLength(i)&&(s=a(s,n(s)),i=o.concat(i,[-2147483648,0,0,0])),c=a(c,i),t.encrypt(a(n(a(s,n(s))),c))},S:function(t){return[t[0]<<1^t[1]>>>31,t[1]<<1^t[2]>>>31,t[2]<<1^t[3]>>>31,t[3]<<1^135*(t[0]>>>31)]}},r.mode.gcm={name:"gcm",encrypt:function(t,e,i,n,o){var a=e.slice(0);return e=r.bitArray,n=n||[],t=r.mode.gcm.C(!0,t,a,n,i,o||128),e.concat(t.data,t.tag)},decrypt:function(t,e,i,n,o){var a=e.slice(0),c=r.bitArray,s=c.bitLength(a);if(n=n||[],(o=o||128)<=s?(e=c.bitSlice(a,s-o),a=c.bitSlice(a,0,s-o)):(e=a,a=[]),t=r.mode.gcm.C(!1,t,a,n,i,o),!c.equal(t.tag,e))throw new r.exception.corrupt("gcm: tag doesn't match");return t.data},ka:function(t,e){var i,n,o,a,c,s=r.bitArray.i;for(o=[0,0,0,0],a=e.slice(0),i=0;128>i;i++){for((n=!!(t[Math.floor(i/32)]&1<<31-i%32))&&(o=s(o,a)),c=!!(1&a[3]),n=3;0<n;n--)a[n]=a[n]>>>1|(1&a[n-1])<<31;a[0]>>>=1,c&&(a[0]^=-520093696)}return o},j:function(t,e,i){var n,o=i.length;for(e=e.slice(0),n=0;n<o;n+=4)e[0]^=4294967295&i[n],e[1]^=4294967295&i[n+1],e[2]^=4294967295&i[n+2],e[3]^=4294967295&i[n+3],e=r.mode.gcm.ka(e,t);return e},C:function(t,e,i,n,o,a){var c,s,h,l,d,u,f,p,m=r.bitArray;for(u=i.length,f=m.bitLength(i),p=m.bitLength(n),s=m.bitLength(o),c=e.encrypt([0,0,0,0]),96===s?(o=o.slice(0),o=m.concat(o,[1])):(o=r.mode.gcm.j(c,[0,0,0,0],o),o=r.mode.gcm.j(c,o,[0,0,Math.floor(s/4294967296),4294967295&s])),s=r.mode.gcm.j(c,[0,0,0,0],n),d=o.slice(0),n=s.slice(0),t||(n=r.mode.gcm.j(c,s,i)),l=0;l<u;l+=4)d[3]++,h=e.encrypt(d),i[l]^=h[0],i[l+1]^=h[1],i[l+2]^=h[2],i[l+3]^=h[3];return i=m.clamp(i,f),t&&(n=r.mode.gcm.j(c,s,i)),t=[Math.floor(p/4294967296),4294967295&p,Math.floor(f/4294967296),4294967295&f],n=r.mode.gcm.j(c,n,t),h=e.encrypt(o),n[0]^=h[0],n[1]^=h[1],n[2]^=h[2],n[3]^=h[3],{tag:m.bitSlice(n,0,a),data:i}}},r.misc.hmac=function(t,e){this.W=e=e||r.hash.sha256;var i,n=[[],[]],o=e.prototype.blockSize/32;for(this.w=[new e,new e],t.length>o&&(t=e.hash(t)),i=0;i<o;i++)n[0][i]=909522486^t[i],n[1][i]=1549556828^t[i];this.w[0].update(n[0]),this.w[1].update(n[1]),this.R=new e(this.w[0])},r.misc.hmac.prototype.encrypt=r.misc.hmac.prototype.mac=function(t){if(this.aa)throw new r.exception.invalid("encrypt on already updated hmac called!");return this.update(t),this.digest(t)},r.misc.hmac.prototype.reset=function(){this.R=new this.W(this.w[0]),this.aa=!1},r.misc.hmac.prototype.update=function(t){this.aa=!0,this.R.update(t)},r.misc.hmac.prototype.digest=function(){var t=this.R.finalize();t=new this.W(this.w[1]).update(t).finalize();return this.reset(),t},r.misc.pbkdf2=function(t,e,i,n,o){if(i=i||1e4,0>n||0>i)throw new r.exception.invalid("invalid params to pbkdf2");"string"==typeof t&&(t=r.codec.utf8String.toBits(t)),"string"==typeof e&&(e=r.codec.utf8String.toBits(e)),t=new(o=o||r.misc.hmac)(t);var a,c,s,h,l=[],d=r.bitArray;for(h=1;32*l.length<(n||1);h++){for(o=a=t.encrypt(d.concat(e,[h])),c=1;c<i;c++)for(a=t.encrypt(a),s=0;s<a.length;s++)o[s]^=a[s];l=l.concat(o)}return n&&(l=d.clamp(l,n)),l},r.prng=function(t){this.c=[new r.hash.sha256],this.m=[0],this.P=0,this.H={},this.N=0,this.U={},this.Z=this.f=this.o=this.ha=0,this.b=[0,0,0,0,0,0,0,0],this.h=[0,0,0,0],this.L=void 0,this.M=t,this.D=!1,this.K={progress:{},seeded:{}},this.u=this.ga=0,this.I=1,this.J=2,this.ca=65536,this.T=[0,48,64,96,128,192,256,384,512,768,1024],this.da=3e4,this.ba=80},r.prng.prototype={randomWords:function(t,e){var i,n,o=[];if((i=this.isReady(e))===this.u)throw new r.exception.notReady("generator isn't seeded");if(i&this.J){i=!(i&this.I),n=[];var a,c=0;for(this.Z=n[0]=(new Date).valueOf()+this.da,a=0;16>a;a++)n.push(4294967296*Math.random()|0);for(a=0;a<this.c.length&&(n=n.concat(this.c[a].finalize()),c+=this.m[a],this.m[a]=0,i||!(this.P&1<<a));a++);for(this.P>=1<<this.c.length&&(this.c.push(new r.hash.sha256),this.m.push(0)),this.f-=c,c>this.o&&(this.o=c),this.P++,this.b=r.hash.sha256.hash(this.b.concat(n)),this.L=new r.cipher.aes(this.b),i=0;4>i&&(this.h[i]=this.h[i]+1|0,!this.h[i]);i++);}for(i=0;i<t;i+=4)0==(i+1)%this.ca&&h(this),n=l(this),o.push(n[0],n[1],n[2],n[3]);return h(this),o.slice(0,t)},setDefaultParanoia:function(t,e){if(0===t&&"Setting paranoia=0 will ruin your security; use it only for testing"!==e)throw new r.exception.invalid("Setting paranoia=0 will ruin your security; use it only for testing");this.M=t},addEntropy:function(t,e,i){i=i||"user";var n,o,a=(new Date).valueOf(),s=this.H[i],h=this.isReady(),l=0;switch(void 0===(n=this.U[i])&&(n=this.U[i]=this.ha++),void 0===s&&(s=this.H[i]=0),this.H[i]=(this.H[i]+1)%this.c.length,typeof t){case"number":void 0===e&&(e=1),this.c[s].update([n,this.N++,1,e,a,1,0|t]);break;case"object":if("[object Uint32Array]"===(i=Object.prototype.toString.call(t))){for(o=[],i=0;i<t.length;i++)o.push(t[i]);t=o}else for("[object Array]"!==i&&(l=1),i=0;i<t.length&&!l;i++)"number"!=typeof t[i]&&(l=1);if(!l){if(void 0===e)for(i=e=0;i<t.length;i++)for(o=t[i];0<o;)e++,o>>>=1;this.c[s].update([n,this.N++,2,e,a,t.length].concat(t))}break;case"string":void 0===e&&(e=t.length),this.c[s].update([n,this.N++,3,e,a,t.length]),this.c[s].update(t);break;default:l=1}if(l)throw new r.exception.bug("random: addEntropy only supports number, array of numbers or string");this.m[s]+=e,this.f+=e,h===this.u&&(this.isReady()!==this.u&&c("seeded",Math.max(this.o,this.f)),c("progress",this.getProgress()))},isReady:function(t){return t=this.T[void 0!==t?t:this.M],this.o&&this.o>=t?this.m[0]>this.ba&&(new Date).valueOf()>this.Z?this.J|this.I:this.I:this.f>=t?this.J|this.u:this.u},getProgress:function(t){return t=this.T[t||this.M],this.o>=t||this.f>t?1:this.f/t},startCollectors:function(){if(!this.D){if(this.a={loadTimeCollector:d(this,this.ma),mouseCollector:d(this,this.oa),keyboardCollector:d(this,this.la),accelerometerCollector:d(this,this.ea),touchCollector:d(this,this.qa)},window.addEventListener)window.addEventListener("load",this.a.loadTimeCollector,!1),window.addEventListener("mousemove",this.a.mouseCollector,!1),window.addEventListener("keypress",this.a.keyboardCollector,!1),window.addEventListener("devicemotion",this.a.accelerometerCollector,!1),window.addEventListener("touchmove",this.a.touchCollector,!1);else{if(!document.attachEvent)throw new r.exception.bug("can't attach event");document.attachEvent("onload",this.a.loadTimeCollector),document.attachEvent("onmousemove",this.a.mouseCollector),document.attachEvent("keypress",this.a.keyboardCollector)}this.D=!0}},stopCollectors:function(){this.D&&(window.removeEventListener?(window.removeEventListener("load",this.a.loadTimeCollector,!1),window.removeEventListener("mousemove",this.a.mouseCollector,!1),window.removeEventListener("keypress",this.a.keyboardCollector,!1),window.removeEventListener("devicemotion",this.a.accelerometerCollector,!1),window.removeEventListener("touchmove",this.a.touchCollector,!1)):document.detachEvent&&(document.detachEvent("onload",this.a.loadTimeCollector),document.detachEvent("onmousemove",this.a.mouseCollector),document.detachEvent("keypress",this.a.keyboardCollector)),this.D=!1)},addEventListener:function(t,e){this.K[t][this.ga++]=e},removeEventListener:function(t,e){var i,n,r=this.K[t],o=[];for(n in r)r.hasOwnProperty(n)&&r[n]===e&&o.push(n);for(i=0;i<o.length;i++)delete r[n=o[i]]},la:function(){s(this,1)},oa:function(t){var e,i;try{e=t.x||t.clientX||t.offsetX||0,i=t.y||t.clientY||t.offsetY||0}catch(t){i=e=0}0!=e&&0!=i&&this.addEntropy([e,i],2,"mouse"),s(this,0)},qa:function(t){t=t.touches[0]||t.changedTouches[0],this.addEntropy([t.pageX||t.clientX,t.pageY||t.clientY],1,"touch"),s(this,0)},ma:function(){s(this,2)},ea:function(t){if(t=t.accelerationIncludingGravity.x||t.accelerationIncludingGravity.y||t.accelerationIncludingGravity.z,window.orientation){var e=window.orientation;"number"==typeof e&&this.addEntropy(e,1,"accelerometer")}t&&this.addEntropy(t,2,"accelerometer"),s(this,0)}},r.random=new r.prng(6);t:try{var u,f,p,m;if(m=t.exports){var y;try{y=i(1565)}catch(t){y=null}m=f=y}if(m&&f.randomBytes)u=f.randomBytes(128),u=new Uint32Array(new Uint8Array(u).buffer),r.random.addEntropy(u,1024,"crypto['randomBytes']");else if("undefined"!=typeof window&&"undefined"!=typeof Uint32Array){if(p=new Uint32Array(32),window.crypto&&window.crypto.getRandomValues)window.crypto.getRandomValues(p);else{if(!window.msCrypto||!window.msCrypto.getRandomValues)break t;window.msCrypto.getRandomValues(p)}r.random.addEntropy(p,1024,"crypto['getRandomValues']")}}catch(t){"undefined"!=typeof window&&window.console}r.json={defaults:{v:1,iter:1e4,ks:128,ts:64,mode:"ccm",adata:"",cipher:"aes"},ja:function(t,e,i,n){i=i||{},n=n||{};var o,a=r.json,c=a.g({iv:r.random.randomWords(4,0)},a.defaults);if(a.g(c,i),i=c.adata,"string"==typeof c.salt&&(c.salt=r.codec.base64.toBits(c.salt)),"string"==typeof c.iv&&(c.iv=r.codec.base64.toBits(c.iv)),!r.mode[c.mode]||!r.cipher[c.cipher]||"string"==typeof t&&100>=c.iter||64!==c.ts&&96!==c.ts&&128!==c.ts||128!==c.ks&&192!==c.ks&&256!==c.ks||2>c.iv.length||4<c.iv.length)throw new r.exception.invalid("json encrypt: invalid parameters");return"string"==typeof t?(t=(o=r.misc.cachedPbkdf2(t,c)).key.slice(0,c.ks/32),c.salt=o.salt):r.ecc&&t instanceof r.ecc.elGamal.publicKey&&(o=t.kem(),c.kemtag=o.tag,t=o.key.slice(0,c.ks/32)),"string"==typeof e&&(e=r.codec.utf8String.toBits(e)),"string"==typeof i&&(c.adata=i=r.codec.utf8String.toBits(i)),o=new r.cipher[c.cipher](t),a.g(n,c),n.key=t,c.ct="ccm"===c.mode&&r.arrayBuffer&&r.arrayBuffer.ccm&&e instanceof ArrayBuffer?r.arrayBuffer.ccm.encrypt(o,e,c.iv,i,c.ts):r.mode[c.mode].encrypt(o,e,c.iv,i,c.ts),c},encrypt:function(t,e,i,n){var o=r.json,a=o.ja.apply(o,arguments);return o.encode(a)},ia:function(t,e,i,n){i=i||{},n=n||{};var o,a,c=r.json;if(o=(e=c.g(c.g(c.g({},c.defaults),e),i,!0)).adata,"string"==typeof e.salt&&(e.salt=r.codec.base64.toBits(e.salt)),"string"==typeof e.iv&&(e.iv=r.codec.base64.toBits(e.iv)),!r.mode[e.mode]||!r.cipher[e.cipher]||"string"==typeof t&&100>=e.iter||64!==e.ts&&96!==e.ts&&128!==e.ts||128!==e.ks&&192!==e.ks&&256!==e.ks||!e.iv||2>e.iv.length||4<e.iv.length)throw new r.exception.invalid("json decrypt: invalid parameters");return"string"==typeof t?(t=(a=r.misc.cachedPbkdf2(t,e)).key.slice(0,e.ks/32),e.salt=a.salt):r.ecc&&t instanceof r.ecc.elGamal.secretKey&&(t=t.unkem(r.codec.base64.toBits(e.kemtag)).slice(0,e.ks/32)),"string"==typeof o&&(o=r.codec.utf8String.toBits(o)),a=new r.cipher[e.cipher](t),o="ccm"===e.mode&&r.arrayBuffer&&r.arrayBuffer.ccm&&e.ct instanceof ArrayBuffer?r.arrayBuffer.ccm.decrypt(a,e.ct,e.iv,e.tag,o,e.ts):r.mode[e.mode].decrypt(a,e.ct,e.iv,o,e.ts),c.g(n,e),n.key=t,1===i.raw?o:r.codec.utf8String.fromBits(o)},decrypt:function(t,e,i,n){var o=r.json;return o.ia(t,o.decode(e),i,n)},encode:function(t){var e,i="{",n="";for(e in t)if(t.hasOwnProperty(e)){if(!e.match(/^[a-z0-9]+$/i))throw new r.exception.invalid("json encode: invalid property name");switch(i+=n+'"'+e+'":',n=",",typeof t[e]){case"number":case"boolean":i+=t[e];break;case"string":i+='"'+escape(t[e])+'"';break;case"object":i+='"'+r.codec.base64.fromBits(t[e],0)+'"';break;default:throw new r.exception.bug("json encode: unsupported type")}}return i+"}"},decode:function(t){if(!(t=t.replace(/\s/g,"")).match(/^\{.*\}$/))throw new r.exception.invalid("json decode: this isn't json!");t=t.replace(/^\{|\}$/g,"").split(/,/);var e,i,n={};for(e=0;e<t.length;e++){if(!(i=t[e].match(/^\s*(?:(["']?)([a-z][a-z0-9]*)\1)\s*:\s*(?:(-?\d+)|"([a-z0-9+\/%*_.@=\-]*)"|(true|false))$/i)))throw new r.exception.invalid("json decode: this isn't json!");null!=i[3]?n[i[2]]=parseInt(i[3],10):null!=i[4]?n[i[2]]=i[2].match(/^(ct|adata|salt|iv)$/)?r.codec.base64.toBits(i[4]):unescape(i[4]):null!=i[5]&&(n[i[2]]="true"===i[5])}return n},g:function(t,e,i){if(void 0===t&&(t={}),void 0===e)return t;for(var n in e)if(e.hasOwnProperty(n)){if(i&&void 0!==t[n]&&t[n]!==e[n])throw new r.exception.invalid("required parameter overridden");t[n]=e[n]}return t},sa:function(t,e){var i,n={};for(i in t)t.hasOwnProperty(i)&&t[i]!==e[i]&&(n[i]=t[i]);return n},ra:function(t,e){var i,n={};for(i=0;i<e.length;i++)void 0!==t[e[i]]&&(n[e[i]]=t[e[i]]);return n}},r.encrypt=r.json.encrypt,r.decrypt=r.json.decrypt,r.misc.pa={},r.misc.cachedPbkdf2=function(t,e){var i,n=r.misc.pa;return i=(e=e||{}).iter||1e3,(i=(n=n[t]=n[t]||{})[i]=n[i]||{firstSalt:e.salt&&e.salt.length?e.salt.slice(0):r.random.randomWords(2,0)})[n=void 0===e.salt?i.firstSalt:e.salt]=i[n]||r.misc.pbkdf2(t,n,e.iter),{key:i[n].slice(0),salt:n.slice(0)}},t.exports&&(t.exports=r),void 0===(n=function(){return r}.apply(e,[]))||(t.exports=n)}}]);
//# sourceMappingURL=vendor.sjcl.f4547262815d41f5fc42.js.map